package com.hxzkoa.controller; import java.awt.geom.Point2D; import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStream; import java.net.URL; import java.net.URLEncoder; //import java.sql.Date; import java.util.Date; import java.sql.Time; import java.sql.Timestamp; import java.text.DecimalFormat; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Arrays; import java.util.Calendar; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; import javax.servlet.ServletContext; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; 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.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_department; import com.hxzkoa.json.tb_fence; import com.hxzkoa.json.tb_fence_inout; import com.hxzkoa.json.tb_gas; import com.hxzkoa.json.tb_gps; import com.hxzkoa.json.tb_history_power; import com.hxzkoa.json.tb_jingwei; import com.hxzkoa.json.tb_jobhistory; import com.hxzkoa.json.tb_map; import com.hxzkoa.json.tb_message; import com.hxzkoa.json.tb_nav; 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.services.SysSettingService; import com.hxzkoa.services.ZhwService; import com.hxzkoa.services.AnchorService; import com.hxzkoa.services.AttendanceService; import com.hxzkoa.services.BasicInfoService; import com.hxzkoa.services.FenceService; import com.hxzkoa.services.LabelService; import com.hxzkoa.services.MapService; import com.hxzkoa.udp.Dell_Ip; import com.hxzkoa.udp.GetNowTime; import com.hxzkoa.udp.ReadPeizhiMessage; import com.hxzkoa.udp.Read_Write_Anchor_Message; 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 com.hxzkoa.util.RtspToMP4; import jxl.Sheet; import jxl.Workbook; import jxl.read.biff.BiffException; import net.sf.json.JSONObject; @Controller public class ZhwController { private Logger logger = LoggerFactory.getLogger(this.getClass()); public static String MSG_LOGIN_FAIL = ResourceUtils .getString("msg.login.fail"); @Autowired private ZhwService ZhwService; @Autowired private SysSettingService sysSettingService; @Autowired private AnchorService AnchorService; @Autowired private FenceService fenceService; @Autowired private AttendanceService attendanceService; @Autowired private BasicInfoService basicInfoService; @Autowired private LabelService labelService; @Autowired private MapService mapService; httpsos sos = new httpsos(); Process process ; private Map map=new HashMap<>(); private Map persons=new HashMap<>(); @ResponseBody @RequestMapping("/Shipinstart") public void Start(Integer id, String FileName) { String ffmpegPath="F:\\ffmpeg\\ffmpeg-4.4-essentials_build\\bin\\ffmpeg.exe"; String streamUrl="rtsp://admin:hxzk20151102@192.168.1.64:554/Streaming/Channels/101"; String FilePath="E:\\data\\MP4\\"+FileName; RtspToMP4 tomp4 = new RtspToMP4(); Process process = tomp4.StartRecord(ffmpegPath, streamUrl, FilePath); if(null!=process){ map.put(id,process); } } @RequestMapping("/Shipinstop") public void stop(Integer id) { if(map.containsKey(id)){ Process process = map.get(id); if(null!=process){ RtspToMP4 tomp4 = new RtspToMP4(); tomp4.stopRecord(process); } } } @RequestMapping(value = "/drawFence_init.do", method = { RequestMethod.POST, RequestMethod.GET }) public String drawFence_init(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String toPage = "forward:/hxzk/fence/drawFence.jsp"; List floorList = ZhwService.getFloor(); List fenceList = fenceService.getFenceList(); List fencenames = new ArrayList<>(); for (int i =0;i < fenceList.size(); i++) { fencenames.add(fenceList.get(i).getName()); } List realAttendance_k = new ArrayList(); List departments = basicInfoService.getDepartmentManagement2(); for (int i =0;i < departments.size(); i++) { realAttendance_k.add(departments.get(i).getDepartmentName()); } request.setAttribute("guanlianList", realAttendance_k); request.setAttribute("fenceList", fencenames); request.setAttribute("floorList", floorList); return toPage; } @RequestMapping(value = "/xiangdaototwo.do", method = { RequestMethod.POST, RequestMethod.GET }) public String xiangdaototwo(HttpServletRequest request) { String toPage = "forward:/hxzk/fence/drawFencexiangdao.jsp"; List floorList = ZhwService.getFloor(); List fenceList = fenceService.getFenceList(); List fencenames = new ArrayList<>(); for (int i =0;i < fenceList.size(); i++) { fencenames.add(fenceList.get(i).getName()); } List realAttendance_k = new ArrayList(); List departments = basicInfoService.getDepartmentManagement2(); for (int i =0;i < departments.size(); i++) { realAttendance_k.add(departments.get(i).getDepartmentName()); } List labelManagementListaa = labelService.getLabelManagementa(); request.setAttribute("labelManagementListaa", labelManagementListaa); request.setAttribute("guanlianList", realAttendance_k); request.setAttribute("fenceList", fencenames); request.setAttribute("floorList", floorList); return toPage; } @RequestMapping(value = "/drawFence.do", method = { RequestMethod.POST, RequestMethod.GET }) public String drawFence(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String floor_number = request.getParameter("value"); String toPage = "forward:/hxzk/fence/drawFence.jsp"; List mapList = ZhwService.getMap(floor_number); request.setAttribute("value", mapList); request.getRequestDispatcher(toPage).forward(request, response); return toPage; } @RequestMapping(value="/floornumTomap.do", method = { RequestMethod.POST, RequestMethod.GET }) @ResponseBody public List floorNumtoMap(HttpServletRequest request) { String floor_number = request.getParameter("value"); final List mapList = ZhwService.getMap(floor_number); return mapList; } @RequestMapping(value="/floornumTomap_all.do", method = { RequestMethod.POST, RequestMethod.GET }) @ResponseBody public List floornumTomap_all(HttpServletRequest request) { final List mapList = ZhwService.getMap_all(); return mapList; } @RequestMapping(value="/floornumTomap_all2.do", method = { RequestMethod.POST, RequestMethod.GET }) @ResponseBody public List floornumTomap_all2(HttpServletRequest request) { String floor = request.getParameter("floor"); final List mapList = ZhwService.getMap_all2(floor); return mapList; } @RequestMapping(value="/getFloorByMapname.do", method = { RequestMethod.POST, RequestMethod.GET }) @ResponseBody public List getFloorByMapname(HttpServletRequest request) { String mapname = request.getParameter("map"); final List mapList = ZhwService.getFloorByMapname(mapname); return mapList; } @RequestMapping(value="/getFloorFence.do", method = { RequestMethod.POST, RequestMethod.GET }) @ResponseBody public List getFloorFence(HttpServletRequest request) { String floor_number = request.getParameter("value"); final List fenceList = ZhwService.getFence(floor_number); final List fenceList2 = new ArrayList(); for (int i = 0; i < fenceList.size(); i++) { if (!fenceList.get(i).getType().equals("变电站")) { fenceList2.add(fenceList.get(i)); } } return fenceList2; } @RequestMapping(value="/getFloorFence_all.do", method = { RequestMethod.POST, RequestMethod.GET }) @ResponseBody public List getFloorFence_all(HttpServletRequest request) { final List fenceList = ZhwService.getFence_all(); return fenceList; } @RequestMapping(value="/getGas_list.do", method = { RequestMethod.POST, RequestMethod.GET }) @ResponseBody public List getGas_list(HttpServletRequest request) { final List fenceList = ZhwService.getGas(); return fenceList; } @RequestMapping(value = "/saveFence.do", method = { RequestMethod.POST, RequestMethod.GET }) @ResponseBody public int drawFence_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")); int aaa = 1; List fencesss = ZhwService.getFenceaaa(fence.getName()); if (fencesss.size() == 0) { aaa = 0; String xingzhuang = request.getParameter("xingzhuang"); fence.setShape(xingzhuang); String zuobiao =(String) request.getParameter("zuobiao"); String baowen = ""; if (xingzhuang.equals("多边形")) { String[] zuobiaos = zuobiao.split(","); String str = ""; for (int i=0; i labelManagementList = labelService.getLabelManagement(1); List labelManagementListaa = labelService.getLabelManagementa(); request.setAttribute("labelManagementList", labelManagementList); request.setAttribute("labelManagementListaa", labelManagementListaa); int curPage = 1; int count = labelService.getLabelManagementCount(); int minPage = PageUtil.getMinPage(count); // System.out.print(minPage); request.setAttribute("pageList", PageUtil.getPage(minPage)); request.setAttribute("curPage", curPage); return toPage; } @RequestMapping(value = "/saveFence2.do", method = { RequestMethod.POST, RequestMethod.GET }) public String drawFence_add2(HttpServletRequest request) { String toPage = "forward:/hxzk/label/labelManagementxiangdaothree.jsp"; tb_fence fence = new tb_fence(); fence.setFloor(request.getParameter("layer")); fence.setType(request.getParameter("weilanleixing")); fence.setBaoliu2(request.getParameter("tagid")); fence.setName(request.getParameter("quyumingcheng")); // String zuobiao =(String) request.getParameter("zuobiao"); String zuobiao = ZhwService.getfencezuobiao(); fence.setZuobiao(zuobiao); fence.setShape("多边形"); String start = "00:00:00"; String end = "23:59:59"; fence.setStart(start); fence.setStop(end); fence.setColor(request.getParameter("yanse")); List realAttendance_k = new ArrayList(); List departments = basicInfoService.getDepartmentManagement2(); for (int i =0;i < departments.size(); i++) { realAttendance_k.add(departments.get(i).getDepartmentName()); } request.setAttribute("guanlianList", realAttendance_k); request.setAttribute("fence", fence); return toPage; } @RequestMapping(value = "/saveFence3.do", method = { RequestMethod.POST, RequestMethod.GET }) @ResponseBody public void drawFence_add3(HttpServletRequest request) { tb_fence fence = new tb_fence(); fence.setFloor(request.getParameter("floor")); fence.setType(request.getParameter("type")); fence.setBaoliu2(request.getParameter("baoliu2")); fence.setName(request.getParameter("name")); // String zuobiao =(String) request.getParameter("zuobiao"); String zuobiao = ZhwService.getfencezuobiao(); fence.setZuobiao(zuobiao); String haibagao = ZhwService.getfencehaibagao(); fence.setBaoliu6(haibagao); fence.setShape(request.getParameter("shape")); fence.setStart(request.getParameter("start")); fence.setStop(request.getParameter("stop")); fence.setColor(request.getParameter("color")); fence.setBaoliu3(request.getParameter("baoliu3")); fence.setBaoliu1(request.getParameter("baoliu1")); fence.setBumen(request.getParameter("bumen")); fence.setBaoliu4(request.getParameter("baoliu4")); int aaa = ZhwService.drawFence_add2(fence); String xieyi = "BSTOCS1,ADDFENCE,"+fence.getFloor()+","+fence.getType()+","+fence.getBumen()+","+fence.getName()+","+fence.getZuobiao().replace(",", ":")+","+fence.getShape()+","+fence.getStart()+","+fence.getStop()+","+GetNowTime.now()+","+fence.getColor()+","+fence.getBaoliu1()+","+fence.getBaoliu6()+","+fence.getBaoliu2()+","+fence.getBaoliu3()+","+fence.getBaoliu4()+",END"; Udp_Out.udp_to_cs(xieyi); String type = request.getParameter("type"); String name = request.getParameter("name"); String floor = request.getParameter("floor"); String shape = request.getParameter("shape"); if(type.equals("巡检区域")) { ZhwService.xunjianSet_add(name); } else if (type.equals("定位区域")) { String[] zb_list = zuobiao.split(","); String zb_inout = ""; for (int i=0;i fencesss = ZhwService.getFenceaaa(fence.getName()); if (fencesss.size() == 0) { aaa = 0; fence.setBaoliu1(request.getParameter("fencegao")); String zuobiao =(String) request.getParameter("zuobiao"); String zuobiaodufen = (String) request.getParameter("zuobiaodufen"); zuobiao = zuobiao.replace(",", ":"); 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()+","+zuobiao+","+fence.getShape()+","+fence.getStart()+","+fence.getStop()+","+GetNowTime.now()+","+fence.getColor()+","+fence.getBaoliu1()+",END"; Udp_Out.udp_to_cs(xieyi); sysSettingService.guiling(); 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 floorList = ZhwService.getFloor(); List fenceList = fenceService.getFenceList2(); request.setAttribute("fenceList", fenceList); request.setAttribute("floorList", floorList); return toPage; } @RequestMapping(value="/trackTagid2.do", method = { RequestMethod.POST, RequestMethod.GET }) @ResponseBody public List queryTagid2(HttpServletRequest request) throws ParseException { String tag_id = request.getParameter("tag_value"); String begin_time = request.getParameter("begin_value"); String end_time = request.getParameter("end_value"); String floor = request.getParameter("floor_value"); final List tagList = ZhwService.getTagtrack(tag_id, begin_time, end_time, floor); return tagList; } @RequestMapping(value="/trackTagid.do", method = { RequestMethod.POST, RequestMethod.GET }) @ResponseBody public List queryTagid(HttpServletRequest request) throws ParseException { String panduan = request.getParameter("panduan"); String tag_id = request.getParameter("tag_value"); String begin_time = request.getParameter("begin_value"); String end_time = request.getParameter("end_value"); String floor = request.getParameter("floor_value"); String fence = request.getParameter("fence"); if (fence.equals("空")) { List tagList = new ArrayList<>(); if (panduan.equals("true")) { tagList = ZhwService.getTagtrack(tag_id, begin_time, end_time, floor); } else { tagList = ZhwService.getTagtrack2(tag_id, begin_time, end_time, floor); } return tagList; } else { List tagList = new ArrayList<>(); if (panduan.equals("true")) { tagList = ZhwService.getTagtrack(tag_id, begin_time, end_time, floor); } else { tagList = ZhwService.getTagtrack2(tag_id, begin_time, end_time, floor); } final List tagList2 = new ArrayList<>(); for (int i=0;i fencedian = new ArrayList<>(); for (int j=0;j queryTagid3(HttpServletRequest request) throws ParseException { String tag_id = request.getParameter("tagid"); String begin_time = request.getParameter("begin"); String end_time = request.getParameter("end"); List tagList = ZhwService.getTagtrack3(tag_id, begin_time, end_time); return tagList; } @RequestMapping(value="/trackTagida.do", method = { RequestMethod.POST, RequestMethod.GET }) @ResponseBody public JSONObject queryTagida(HttpServletRequest request) throws ParseException { String tag_id = request.getParameter("tag_value"); String begin_time = request.getParameter("begin_value"); String end_time = request.getParameter("end_value"); String floor = request.getParameter("floor_value"); String fence = request.getParameter("fence"); JSONObject json = new JSONObject(); if (fence.equals("空")) { final List tagList = ZhwService.getTagtrack(tag_id, begin_time, end_time, floor); json.put("dataList", tagList); return json; } else { final List tagList = ZhwService.getTagtrack(tag_id, begin_time, end_time, floor); final List tagList2 = new ArrayList<>(); for (int i=0;i fencedian = new ArrayList<>(); for (int j=0;j getRealPosition(HttpServletRequest request) { String floor = request.getParameter("floor"); //根据时间筛选出数据 List realLocationList = ZhwService.getpersonLocation(floor); List finalPositionList = new ArrayList(); //根据每个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.setBumen(node.getP_department()); position.setBaoliu22(node.getBaoliu22()); // position.setPhone(node.getP_phone()); // position.setIdcardnum(node.getP_idcardnum()); // position.setJingdu(node.getP_jingdu()); // position.setWeidu(node.getP_weidu()); // position.setGaocheng(node.getBaoliu10()); finalPositionList.add(position); } return finalPositionList; } @RequestMapping(value="/getRealPositiona.do", method = { RequestMethod.POST, RequestMethod.GET }) @ResponseBody public JSONObject getRealPositiona(HttpServletRequest request) { String floor = request.getParameter("floor"); JSONObject json = new JSONObject(); //根据时间筛选出数据 List realLocationList = ZhwService.getpersonLocation(floor); List finalPositionList = new ArrayList(); //根据每个tagid取tb_tag:[tag_id,state(静止1or运动0),power,status(在线1or离线0),addtime],放入tb_position中 for (tb_person node : realLocationList) { if (node.getP_online().equals("1")) { 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(""+((double)Math.round(Double.parseDouble(node.getP_x()))/100)); position.setPosy(""+((double)Math.round(Double.parseDouble(node.getP_y()))/100)); 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.setBumen(node.getP_department()); position.setPhone(node.getP_phone()); position.setIdcardnum(node.getP_idcardnum()); position.setJingdu(node.getP_jingdu()); position.setWeidu(node.getP_weidu()); position.setGaocheng(node.getBaoliu10()); finalPositionList.add(position); } } json.put("dataList", finalPositionList); return json; } @RequestMapping(value="/getRealPosition_all.do", method = { RequestMethod.POST, RequestMethod.GET }) @ResponseBody public List getRealPosition_all(HttpServletRequest request) { //根据时间筛选出数据 List realLocationList = ZhwService.getpersonLocation_all(); List finalPositionList = new ArrayList(); //根据每个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.setFloor(node.getP_floor()); 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.setShipin(node.getP_shipin()); position.setShipingname(node.getP_shipingname()); position.setChaichu(node.getBaoliu6()); position.setBaoliu20(node.getBaoliu20()); position.setBaoliu21(node.getBaoliu21()); finalPositionList.add(position); } return finalPositionList; } @ResponseBody @RequestMapping(value="/getpersonid.do",method = { RequestMethod.POST, RequestMethod.GET }) public JSONObject getpersonid(HttpServletRequest request) { String tagid = request.getParameter("tagid"); List realTrackList = ZhwService.getpersonid(tagid); JSONObject json = new JSONObject(); json.put("X", realTrackList.get(0).getP_x()); json.put("Y", realTrackList.get(0).getP_y()); json.put("time", realTrackList.get(0).getP_addtiem()); return json; } @ResponseBody @RequestMapping(value="/getgpsid.do",method = { RequestMethod.POST, RequestMethod.GET }) public JSONObject getgpsid(HttpServletRequest request) { String tagid = request.getParameter("tagid"); List realTrackList = ZhwService.getgpsid(tagid); JSONObject json = new JSONObject(); json.put("jingdu", realTrackList.get(0).getGsp_jingdu()); json.put("weidu", realTrackList.get(0).getGps_weidu()); json.put("haibagao", realTrackList.get(0).getGps_haiba_gao()); return json; } @RequestMapping(value="/getRealTrack.do", method = { RequestMethod.POST, RequestMethod.GET }) @ResponseBody public List> getRealTrack(HttpServletRequest request) { String tagid = request.getParameter("tagid"); String[] taglist = tagid.split(","); String floor = request.getParameter("floor"); Long time_range = Long.parseLong(request.getParameter("time")) * 1000;// ms*1000=s long timeNow = System.currentTimeMillis(); long timeStart = timeNow - time_range; // long timeStart = 0; Timestamp ts=new Timestamp(timeStart); String start_str=ts.toString(); // start time string //start_str="2021-03-01 10:26:00"; List realTrackList = ZhwService.getRealPosTrack(taglist, start_str, floor); //get all tag in a list List tagList = new ArrayList(); for (tb_track node : realTrackList) { if (tagList.contains(node.getTagid())) { continue; } else { tagList.add(node.getTagid()); } } // sort all track data by tagid List> tmpRealTrackList = new ArrayList>(); List> finalRealTrackList = new ArrayList>(); for (String tag : tagList) { tmpRealTrackList.add(new ArrayList()); } for (tb_track node : realTrackList) { int index = tagList.indexOf(node.getTagid()); tmpRealTrackList.get(index).add(node); } return tmpRealTrackList; } @RequestMapping(value="/getRealTrack_all.do", method = { RequestMethod.POST, RequestMethod.GET }) @ResponseBody public List getRealTrack_all(HttpServletRequest request) { String tagid = request.getParameter("tagid"); String[] taglist = tagid.split(","); Long time_range = Long.parseLong(request.getParameter("time")) * 1000;// ms*1000=s long timeNow = System.currentTimeMillis(); long timeStart = timeNow - time_range; // long timeStart = 0; Timestamp ts=new Timestamp(timeStart); String start_str=ts.toString(); // start time string // String start_str="2021-03-01 10:26:00"; List realTrackList = ZhwService.getRealPosTrack_all(taglist, start_str); // List finalRealTrackList = new ArrayList(); return realTrackList; // if (realTrackList.size()<=100) { // return realTrackList; // } else { // int lenth = realTrackList.size(); // int interval = (int) Math.floor(lenth/100); // for (int i=0;i anchorList = ZhwService.getAnchor(); request.setAttribute("anchorList", anchorList); return toPage; } @RequestMapping(value="/getAnchorip.do", method = { RequestMethod.POST, RequestMethod.GET }) @ResponseBody public List getAnchorip(HttpServletRequest request) { String anchorid = request.getParameter("anchorid"); final List anchoripList = ZhwService.getAnchorip(anchorid); return anchoripList; } @RequestMapping(value="/getSysSetting_list.do", method = { RequestMethod.POST, RequestMethod.GET }) @ResponseBody public List getSysSetting_list(HttpServletRequest request) { List settingList = sysSettingService.getSetting(); return settingList; } @RequestMapping(value="/getSysSetting_list2.do", method = { RequestMethod.POST, RequestMethod.GET }) @ResponseBody public String getSysSetting_list2(HttpServletRequest request) { JSONObject json = new JSONObject(); List settingList = sysSettingService.getSetting(); List navList = ZhwService.getnav(); List persons = ZhwService.getbumen(); List realAttendance_k = new ArrayList(); List departments = basicInfoService.getDepartmentManagement2(); for (int i =0;i < departments.size(); i++) { realAttendance_k.add(departments.get(i).getDepartmentName()); } json.put("dataList", settingList); json.put("dataList2", navList); json.put("dataList3", persons); json.put("dataList4", realAttendance_k); return json.toString(); } @RequestMapping(value="/getSysSetting_list3.do", method = { RequestMethod.POST, RequestMethod.GET }) @ResponseBody public String getSysSetting_list3(HttpServletRequest request) { JSONObject json = new JSONObject(); List settingList = sysSettingService.getSetting(); List navList = ZhwService.getnav(); List persons = ZhwService.getbumen(); List realAttendance_k = new ArrayList(); List departments = basicInfoService.getDepartmentManagement2(); for (int i =0;i < departments.size(); i++) { realAttendance_k.add(departments.get(i).getDepartmentName()); } HttpSession session = request.getSession(); ServletContext application = session.getServletContext(); String username = application.getAttribute("username").toString(); json.put("xianuser", username); json.put("dataList", settingList); json.put("dataList2", navList); json.put("dataList3", persons); json.put("dataList4", realAttendance_k); return json.toString(); } @RequestMapping(value="/getAnchorInfo.do", method = { RequestMethod.POST, RequestMethod.GET }) @ResponseBody public List getAnchorInfo(HttpServletRequest request) { String floor = request.getParameter("floor"); final List anchoripList = ZhwService.getAnchorInfo(floor); return anchoripList; } @RequestMapping(value="/getAnchorInfo_all.do", method = { RequestMethod.POST, RequestMethod.GET }) @ResponseBody public List getAnchorInfo_all(HttpServletRequest request) { final List anchoripList = ZhwService.getAnchorInfo_all(); return anchoripList; } @RequestMapping(value="/getGPS.do", method = { RequestMethod.POST, RequestMethod.GET }) @ResponseBody public List getGPS(HttpServletRequest request) { final List gpsList = ZhwService.getGPS(); List finalGPSList = new ArrayList(); for ( tb_gps node : gpsList) { if (node.getGsp_jingdu() != null && !node.getGsp_jingdu().equals("00000.000000") && node.getGps_weidu() != null && !node.getGps_weidu().equals("00000.000000")) { String[] jingdu = node.getGsp_jingdu().split("\\."); String[] weidu = node.getGps_weidu().split("\\."); if (jingdu[0].length() == 3 && weidu[0].length() == 2) { finalGPSList.add(node); } } }; return finalGPSList; } @RequestMapping(value="/getGPSa.do", method = { RequestMethod.POST, RequestMethod.GET }) @ResponseBody public JSONObject getGPSa(HttpServletRequest request) { JSONObject json = new JSONObject(); final List gpsList = ZhwService.getGPS(); List finalGPSList = new ArrayList(); for ( tb_gps node : gpsList) { if (node.getGsp_jingdu() != null && !node.getGsp_jingdu().equals("00000.000000") && node.getGps_weidu() != null && !node.getGps_weidu().equals("00000.000000")) { String[] jingdu = node.getGsp_jingdu().split("\\."); String[] weidu = node.getGps_weidu().split("\\."); if (jingdu[0].length() == 3 && weidu[0].length() == 2) { finalGPSList.add(node); } } }; json.put("dataList", finalGPSList); return json; } @RequestMapping(value="/getGPSTrack.do", method = { RequestMethod.POST, RequestMethod.GET }) @ResponseBody public List getGPSTrack(HttpServletRequest request) throws ParseException { String tag_id = request.getParameter("tag_value"); String begin_time = request.getParameter("begin_value"); String end_time = request.getParameter("end_value"); final List finalGPSList = ZhwService.getGPStrack(tag_id, begin_time, end_time); return finalGPSList; } @RequestMapping(value="/getGPSTracka.do", method = { RequestMethod.POST, RequestMethod.GET }) @ResponseBody public JSONObject getGPSTracka(HttpServletRequest request) throws ParseException { String tag_id = request.getParameter("tag_value"); String begin_time = request.getParameter("begin_value"); String end_time = request.getParameter("end_value"); final List finalGPSList = ZhwService.getGPStrack(tag_id, begin_time, end_time); JSONObject json = new JSONObject(); json.put("dataList", finalGPSList); return json; } @RequestMapping(value="/qiehuanditu_option.do", method = { RequestMethod.POST, RequestMethod.GET }) @ResponseBody public List qiehuanditu_option(HttpServletRequest request) { List mapList = ZhwService.getFloor(); return mapList; } @RequestMapping(value="/qiehuanditu_option2.do", method = { RequestMethod.POST, RequestMethod.GET }) @ResponseBody public List qiehuanditu_option2(HttpServletRequest request) { String floor = request.getParameter("floor"); List mapList = ZhwService.getFloor2(floor); return mapList; } @RequestMapping(value = "/qiehuanditu_save.do", method = { RequestMethod.POST, RequestMethod.GET }) public String qiehuanditu_save(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { //String toPage = "forward:/show.do"; 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")); return "1"; } @RequestMapping(value="/qiehuanditu_get.do", method = { RequestMethod.POST, RequestMethod.GET }) @ResponseBody public List qiehuanditu_get(HttpServletRequest request) { List systemlist = sysSettingService.getSetting(); List maplist = new ArrayList(); String map = systemlist.get(0).getYulan_map(); maplist.add(map); return maplist; } @RequestMapping(value="/qiehuanditu1.do", method = { RequestMethod.POST, RequestMethod.GET }) @ResponseBody public List qiehuanditu1(HttpServletRequest request) { List maps = mapService.getMapManagement(); List maplist = new ArrayList(); String map = maps.get(0).getMapname(); maplist.add(map); return maplist; } @RequestMapping(value = "/getAnchor_read_config.do", method = { RequestMethod.POST, RequestMethod.GET }) public void getAnchor_read_config(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { byte[] byt=Read_Write_Anchor_Message.ReadData((byte)0x2,(byte)0x50); System.out.println("读取配置信息:"+BytesToHex.bytesToHex(byt)); String ip = request.getParameter("ip"); List settingList = sysSettingService.getSetting(); Udp_Out.out(byt, byt.length, ip, settingList.get(0).getUdpPort().toString(), settingList.get(0).getWifi_mdel().toString()); //( , , ,udp_port, wifi_mode) } @RequestMapping(value = "/modify_anchor_version.do", method = { RequestMethod.POST, RequestMethod.GET }) public void modify_anchor_version(HttpServletRequest request) throws IOException { String jsonString = RequestUtils.getRequestJsonString(request, Config.getCharset()); tb_achor anchor = (tb_achor) JSONObject.toBean(JSONObject.fromObject(jsonString), tb_achor.class); AnchorService.anchorManagement_modify_ip_ver(anchor); } @RequestMapping(value="/read_anchor_config_done.do", method = { RequestMethod.POST, RequestMethod.GET }) @ResponseBody public List read_anchor_config_done(HttpServletRequest request) { String filePath = Config.getAnchorConfig(); List peizhilist = new ArrayList(); String peizhi = ModifyConfig.readData(filePath, "readpeizhi"); peizhilist.add(peizhi); String shebeimoshi = ModifyConfig.readData(filePath, "shebeimoshi"); peizhilist.add(shebeimoshi); String zhudongceju = ModifyConfig.readData(filePath, "zhudongceju"); peizhilist.add(zhudongceju); String kaiqixintiao = ModifyConfig.readData(filePath, "kaiqixintiao"); peizhilist.add(kaiqixintiao); String jizhanid = ModifyConfig.readData(filePath, "jizhanid"); peizhilist.add(jizhanid); String fashegonglv = ModifyConfig.readData(filePath, "fashegonglv"); peizhilist.add(fashegonglv); String wuchajiaozhun = ModifyConfig.readData(filePath, "wuchajiaozhun"); peizhilist.add(wuchajiaozhun); String lvbocanshu = ModifyConfig.readData(filePath, "lvbocanshu"); peizhilist.add(lvbocanshu); String tongxunxiaozu = ModifyConfig.readData(filePath, "tongxunxiaozu"); peizhilist.add(tongxunxiaozu); String tongxunpinlv = ModifyConfig.readData(filePath, "tongxunpinlv"); peizhilist.add(tongxunpinlv); String tongxunshangxian = ModifyConfig.readData(filePath, "tongxunshangxian"); peizhilist.add(tongxunshangxian); String gujianbanben = ModifyConfig.readData(filePath, "gujianbanben"); peizhilist.add(gujianbanben); String tongbujizhan = ModifyConfig.readData(filePath, "tongbujizhan"); peizhilist.add(tongbujizhan); String tongbuleixing = ModifyConfig.readData(filePath, "tongbuleixing"); peizhilist.add(tongbuleixing); String linjinjizhanshuliang = ModifyConfig.readData(filePath, "linjinjizhanshuliang"); peizhilist.add(linjinjizhanshuliang); String linjinjizhan1 = ModifyConfig.readData(filePath, "linjinjizhan1"); peizhilist.add(linjinjizhan1); String linjinjizhan2 = ModifyConfig.readData(filePath, "linjinjizhan2"); peizhilist.add(linjinjizhan2); String linjinjizhan3 = ModifyConfig.readData(filePath, "linjinjizhan3"); peizhilist.add(linjinjizhan3); String linjinjizhan4 = ModifyConfig.readData(filePath, "linjinjizhan4"); peizhilist.add(linjinjizhan4); String linjinjizhan5 = ModifyConfig.readData(filePath, "linjinjizhan5"); peizhilist.add(linjinjizhan5); String linjinjizhan6 = ModifyConfig.readData(filePath, "linjinjizhan6"); peizhilist.add(linjinjizhan6); String linjinjizhan7 = ModifyConfig.readData(filePath, "linjinjizhan7"); peizhilist.add(linjinjizhan7); String linjinjizhan8 = ModifyConfig.readData(filePath, "linjinjizhan8"); peizhilist.add(linjinjizhan8); String qiehuanjuli = ModifyConfig.readData(filePath, "qiehuanjuli"); peizhilist.add(qiehuanjuli); return peizhilist; } @RequestMapping(value="/modify_anchor_config_done.do", method = { RequestMethod.POST, RequestMethod.GET }) @ResponseBody public List modify_anchor_config_done(HttpServletRequest request) { String ip=request.getParameter("ip"); String filePath = Config.getAnchorConfig(); List peizhilist = new ArrayList(); String peizhi = ModifyConfig.readData(filePath, "readpeizhi"); if (peizhi.equals("done")) { ModifyConfig.writeData(filePath, "shebeimoshi", request.getParameter("shebeimoshi")); ModifyConfig.writeData(filePath, "zhudongceju", request.getParameter("zhudongceju")); ModifyConfig.writeData(filePath, "kaiqixintiao", request.getParameter("kaiqixintiao")); ModifyConfig.writeData(filePath, "jizhanid", request.getParameter("jizhanid")); ModifyConfig.writeData(filePath, "fashegonglv", request.getParameter("fashegonglv")); ModifyConfig.writeData(filePath, "wuchajiaozhun", request.getParameter("wuchajiaozhun")); ModifyConfig.writeData(filePath, "lvbocanshu", request.getParameter("lvbocanshu")); ModifyConfig.writeData(filePath, "tongxunxiaozu", request.getParameter("tongxunxiaozu")); ModifyConfig.writeData(filePath, "tongxunpinlv", request.getParameter("tongxunpinlv")); ModifyConfig.writeData(filePath, "tongxunshangxian", request.getParameter("tongxunshangxian")); ModifyConfig.writeData(filePath, "gujianbanben", request.getParameter("gujianbanben")); ModifyConfig.writeData(filePath, "tongbujizhan", request.getParameter("tongbujizhan")); ModifyConfig.writeData(filePath, "tongbuleixing", request.getParameter("tongbuleixing")); ModifyConfig.writeData(filePath, "linjinjizhanshuliang", request.getParameter("linjinjizhanshuliang")); ModifyConfig.writeData(filePath, "linjinjizhan1", request.getParameter("linjinjizhan1")); ModifyConfig.writeData(filePath, "linjinjizhan2", request.getParameter("linjinjizhan2")); ModifyConfig.writeData(filePath, "linjinjizhan3", request.getParameter("linjinjizhan3")); ModifyConfig.writeData(filePath, "linjinjizhan4", request.getParameter("linjinjizhan4")); ModifyConfig.writeData(filePath, "linjinjizhan5", request.getParameter("linjinjizhan5")); ModifyConfig.writeData(filePath, "linjinjizhan6", request.getParameter("linjinjizhan6")); ModifyConfig.writeData(filePath, "linjinjizhan7", request.getParameter("linjinjizhan7")); ModifyConfig.writeData(filePath, "linjinjizhan8", request.getParameter("linjinjizhan8")); ModifyConfig.writeData(filePath, "qiehuanjuli", request.getParameter("qiehuanjuli")); byte[] byt = ReadPeizhiMessage.save(request.getParameter("jizhanid"), request.getParameter("fashegonglv"), request.getParameter("wuchajiaozhun"), request.getParameter("lvbocanshu"), request.getParameter("tongxunxiaozu"), request.getParameter("tongxunpinlv"), request.getParameter("tongxunshangxian"), request.getParameter("shebeimoshi"), request.getParameter("linjinjizhanshuliang"), request.getParameter("linjinjizhan1"), request.getParameter("linjinjizhan2"), request.getParameter("linjinjizhan3"), request.getParameter("linjinjizhan4"), request.getParameter("linjinjizhan5"), request.getParameter("linjinjizhan6"), request.getParameter("linjinjizhan7"), request.getParameter("linjinjizhan8"), "", request.getParameter("qiehuanjuli"), request.getParameter("zhudongceju"), request.getParameter("kaiqixintiao"), request.getParameter("tongbujizhan"), request.getParameter("tongbuleixing")); List settingList = sysSettingService.getSetting(); System.out.println("保存配置信息是:"+BytesToHex.bytesToHex(byt)); Udp_Out.out(byt,byt.length,ip, settingList.get(0).getUdpPort().toString(), settingList.get(0).getWifi_mdel().toString() ); } List modi = new ArrayList(); modi.add("1"); return modi; } @RequestMapping(value="/modify_all_anchor_config.do", method = { RequestMethod.POST, RequestMethod.GET }) @ResponseBody public List modify_all_anchor_config(HttpServletRequest request) { String filePath = Config.getAnchorConfig(); ModifyConfig.writeData(filePath, "fashegonglv", request.getParameter("fashegonglv")); ModifyConfig.writeData(filePath, "wuchajiaozhun", request.getParameter("wuchajiaozhun")); ModifyConfig.writeData(filePath, "lvbocanshu", request.getParameter("lvbocanshu")); ModifyConfig.writeData(filePath, "tongxunxiaozu", request.getParameter("tongxunxiaozu")); ModifyConfig.writeData(filePath, "tongxunpinlv", request.getParameter("tongxunpinlv")); ModifyConfig.writeData(filePath, "tongxunshangxian", request.getParameter("tongxunshangxian")); ModifyConfig.writeData(filePath, "tongbujizhan", request.getParameter("tongbujizhan")); ModifyConfig.writeData(filePath, "tongbuleixing", request.getParameter("tongbuleixing")); byte[] byt = ReadPeizhiMessage.alert_all_anchor(request.getParameter("fashegonglv"), request.getParameter("wuchajiaozhun"), request.getParameter("lvbocanshu"), request.getParameter("tongxunxiaozu"), request.getParameter("tongxunpinlv"), request.getParameter("tongxunshangxian"), request.getParameter("tongbujizhan"), request.getParameter("tongbuleixing")); List settingList = sysSettingService.getSetting(); String port = settingList.get(0).getUdpPort().toString(); String wifi_mode = settingList.get(0).getWifi_mdel().toString(); System.out.println("修改所有基站信息是:"+BytesToHex.bytesToHex(byt)); List anchorIpList = ZhwService.getALlAnchor(); if (anchorIpList.size()!=0) { for(int i=0; i modi = new ArrayList(); modi.add("1"); return modi; } @RequestMapping(value="/restart_anchor.do", method = { RequestMethod.POST, RequestMethod.GET }) @ResponseBody public List restart_anchor(HttpServletRequest request) { byte[] byt=Read_Write_Anchor_Message.WriteData((byte)0x60,(byte)0x2,1); System.out.println("重启基站信息是:"+BytesToHex.bytesToHex(byt)); String ip=request.getParameter("ip"); List settingList = sysSettingService.getSetting(); Udp_Out.out(byt,byt.length,ip,settingList.get(0).getUdpPort().toString(), settingList.get(0).getWifi_mdel().toString()); List rslt = new ArrayList(); rslt.add("1"); return rslt; } @RequestMapping(value="/reset_anchor.do", method = { RequestMethod.POST, RequestMethod.GET }) @ResponseBody public List reset_anchor(HttpServletRequest request) { byte[] byt=Read_Write_Anchor_Message.WriteData((byte)0x62,(byte)0x2,1); System.out.println("恢复出厂设置信息是:"+BytesToHex.bytesToHex(byt)); String ip=request.getParameter("ip"); List settingList = sysSettingService.getSetting(); Udp_Out.out(byt,byt.length,ip,settingList.get(0).getUdpPort().toString(), settingList.get(0).getWifi_mdel().toString()); List rslt = new ArrayList(); rslt.add("1"); return rslt; } @RequestMapping(value="/anchorCeju.do", method = { RequestMethod.POST, RequestMethod.GET }) @ResponseBody public List anchorCeju(HttpServletRequest request) { String begin=request.getParameter("begin"); System.out.println("begin"+begin); List settingList = sysSettingService.getSetting(); if (begin.equals("true")) { //点击了开始测距 String ip_a = request.getParameter("beice"); String beice_anchor = request.getParameter("beice_anchor"); String filePath = Config.getAnchorConfig(); ModifyConfig.writeData(filePath, "beice_anchor", beice_anchor); byte[] byt=Read_Write_Anchor_Message.WriteData((byte)0x10,(byte)0x2,1); System.out.println("基站开始测距:"+BytesToHex.bytesToHex(byt)); Udp_Out.out(byt,byt.length,ip_a, settingList.get(0).getUdpPort().toString(), settingList.get(0).getWifi_mdel().toString()); } else if (begin.equals("false")) { //点击了取消测距 String ip_a = request.getParameter("beice"); String ip_b = request.getParameter("ceju"); byte[] byt=Read_Write_Anchor_Message.WriteData((byte)0x10,(byte)0x2,0); System.out.println("基站取消测距:"+BytesToHex.bytesToHex(byt)); Udp_Out.out(byt,byt.length,ip_a,settingList.get(0).getUdpPort().toString(), settingList.get(0).getWifi_mdel().toString()); byte[] byt2=Read_Write_Anchor_Message.WriteData((byte)0x10,(byte)0x2,0); System.out.println("基站取消测距:"+BytesToHex.bytesToHex(byt2)); Udp_Out.out(byt2,byt2.length,ip_b, settingList.get(0).getUdpPort().toString(), settingList.get(0).getWifi_mdel().toString()); } List rslt = new ArrayList(); rslt.add("1"); return rslt; } @RequestMapping(value="/getAnchorhuce.do", method = { RequestMethod.POST, RequestMethod.GET }) @ResponseBody public List getAnchorhuce(HttpServletRequest request) { String filePath = Config.getAnchorConfig(); String huceju = ModifyConfig.readData(filePath, "huceju"); System.out.println("huceju"+huceju); List rslt = new ArrayList(); rslt.add(huceju); return rslt; } @RequestMapping(value = "/gpsRecord_add.do", method = { RequestMethod.POST, RequestMethod.GET }) public void gpsRecord_add(HttpServletRequest request) throws IOException { String jsonString = RequestUtils.getRequestJsonString(request, Config.getCharset()); logger.info("传入数据IData:" + jsonString); tb_gps gps = (tb_gps) JSONObject.toBean(JSONObject.fromObject(jsonString), tb_gps.class); List searchGpsList = ZhwService.searchGps(gps.getTagid()); if (searchGpsList.size()>0){ ZhwService.gpsRecord_modify(gps); } else { ZhwService.gpsRecord_add(gps); } } @RequestMapping(value = "/gpsTrack_add.do", method = { RequestMethod.POST, RequestMethod.GET }) public void gpsTrack_add(HttpServletRequest request) throws IOException { String jsonString = RequestUtils.getRequestJsonString(request, Config.getCharset()); logger.info("传入数据IData:" + jsonString); tb_gps gps = (tb_gps) JSONObject.toBean(JSONObject.fromObject(jsonString), tb_gps.class); ZhwService.gpsTrack_add(gps); } @RequestMapping(value = "/httpsos.do", method = { RequestMethod.POST, RequestMethod.GET }) public void http(HttpServletRequest request) throws IOException { String jsonString = RequestUtils.getRequestJsonString(request, Config.getCharset()); JSONObject str = JSONObject.fromObject(jsonString); sos = (httpsos)JSONObject.toBean(str, httpsos.class); } @RequestMapping(value = "/sosgaojing.do", method = { RequestMethod.POST, RequestMethod.GET }) public void sosgaojing(HttpServletRequest request) throws IOException { String tagid=request.getParameter("tagid"); ZhwService.sosgao(tagid); String xieyi = "BSTOCS1,DELLWARN," +tagid+ ",SOS,END"; Udp_Out.udp_to_cs(xieyi); } @RequestMapping(value = "/fencegaojing.do", method = { RequestMethod.POST, RequestMethod.GET }) public void fencegaojing(HttpServletRequest request) throws IOException { String tagid=request.getParameter("tagid"); String type=request.getParameter("type"); ZhwService.fencegao(tagid); String xieyi = "BSTOCS1,DELLWARN," +tagid+ ","+type+",END"; Udp_Out.udp_to_cs(xieyi); } @RequestMapping(value = "/chaichugaojing.do", method = { RequestMethod.POST, RequestMethod.GET }) public void chaichugaojing(HttpServletRequest request) throws IOException { String tagid=request.getParameter("tagid"); ZhwService.chaichugao(tagid); String xieyi = "BSTOCS1,DELLWARN," +tagid+ ",被拆除,END"; Udp_Out.udp_to_cs(xieyi); } @RequestMapping(value = "/jinmengaojing.do", method = { RequestMethod.POST, RequestMethod.GET }) public void jinmengaojing(HttpServletRequest request) throws IOException { String tagid=request.getParameter("tagid"); ZhwService.jinmengao(tagid); String xieyi = "BSTOCS1,DELLWARN," +tagid+ ",未授权进入告警,END"; Udp_Out.udp_to_cs(xieyi); } @RequestMapping(value = "/chumengaojing.do", method = { RequestMethod.POST, RequestMethod.GET }) public void chumengaojing(HttpServletRequest request) throws IOException { String tagid=request.getParameter("tagid"); ZhwService.chumengao(tagid); String xieyi = "BSTOCS1,DELLWARN," +tagid+ ",未授权出门告警,END"; Udp_Out.udp_to_cs(xieyi); } @RequestMapping(value = "/gaojingzongchuli.do", method = { RequestMethod.POST, RequestMethod.GET }) public void gaojingzongchuli(HttpServletRequest request) throws IOException { List soslist = ZhwService.getsosgaojing(); String xieyi = "BSTOCS1,DELLWARNALL,END"; Udp_Out.udp_to_cs(xieyi); for (int i=0; i fencelist = ZhwService.getfencegaojing(); for (int i=0; i chufencelist = ZhwService.getchufencegaojing(); for (int i=0; i jinchumenlist = ZhwService.getjinchumengaojing(); for (int i=0; i shipinzhuangtai(HttpServletRequest request){ String tagid=request.getParameter("tagid"); ZhwService.shipin(tagid); List fencename = ZhwService.getfencename(tagid); // //System.out.print(fencename.get(0).getP_fencename()); List id = ZhwService.getshebeiid(fencename.get(0).getP_fencename()); // //System.out.print(id.get(0).getShebeiid()); List bb =null; return id; } @RequestMapping(value = "/shipinzhuangtai2.do", method = { RequestMethod.POST, RequestMethod.GET }) public void shipinzhuangtai2(HttpServletRequest request){ String tagid=request.getParameter("tagid"); ZhwService.shipin(tagid); } @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[] tagids = tagid.split(","); String xieyi = "BSTOCS1,sousuo,"+tagids[0]+",END"; Udp_Out.udp_to_cs(xieyi); } @RequestMapping(value = "/sousuoquxiao.do", method = { RequestMethod.POST, RequestMethod.GET }) public void sousuoquxiao(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 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 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 labelList = labelService.getLabelManagement(); // for (int i = 0; i < labelList.size(); i++) { // String tag_id = labelList.get(i).getTag_id(); // // 修改标签同时需要修改tb_person 需要先查再改否则覆盖空 // List 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_qihouList = ZhwService.qihoucha(); String[] rowName = { "ID", "时间", "地点", "天气", "温度", "湿度" }; List 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 qihouTemplateList = ZhwService.qihoucha(1); String[] rowName = { "时间", "地点", "天气", "温度", "湿度"}; List 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 qihouManagementList = ZhwService.qihoucha(page); List 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 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 getRealPositionsan(HttpServletRequest request) { long timeStart = 0; //根据时间筛选出数据 List 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)/100;//-54732 Double yo = -(y)/100;//+10268 List xy = ZhwController.cal2(xo, yo); node.setP_x((xy.get(0)).toString()); node.setP_y((xy.get(1)).toString()); } List finalPositionList = new ArrayList(); //根据每个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="/getRealPositionsan2.do", method = { RequestMethod.POST, RequestMethod.GET }) @ResponseBody public List getRealPositionsan2(HttpServletRequest request) { long timeStart = 0; //根据时间筛选出数据 List realLocationList = ZhwService.getpersonLocationsan(); List finalPositionList = new ArrayList(); //根据每个tagid取tb_tag:[tag_id,state(静止1or运动0),power,status(在线1or离线0),addtime],放入tb_position中 for (tb_person node : realLocationList) { double jiao = 0.00; if (persons.containsKey(node.getP_tagid())) { double x1 = Double.valueOf(node.getP_x()); double y1 = Double.valueOf(node.getP_y()); double x2 = Double.valueOf(persons.get(node.getP_tagid())[0]); double y2 = Double.valueOf(persons.get(node.getP_tagid())[1]); double c = x1-x2; double a = y1-y2; if (node.getBaoliu22() != null && node.getBaoliu22() != "") { if (node.getBaoliu22().equals("0")) { jiao = Math.toDegrees(Math.atan2(c, a)); } else { String[] xy = node.getBaoliu23().split(","); jiao = Math.toDegrees(Math.atan2(Double.valueOf(xy[0]), Double.valueOf(xy[1]))); } if (String.valueOf(jiao).equals("0.0")) { jiao = Double.valueOf(persons.get(node.getP_tagid())[2]).doubleValue(); } } } 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.setSex(node.getP_sex()); position.setMinzu(node.getP_minzu()); position.setPhone(node.getP_phone()); position.setBumen(node.getP_department()); 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()); position.setJiao(String.valueOf(jiao)); position.setBaoliu22(node.getBaoliu22()); position.setBaoliu23(node.getBaoliu23()); position.setBaoliu24(node.getBaoliu24()); String[] bb = new String[]{node.getP_x(),node.getP_y(),String.valueOf(jiao)}; persons.put(node.getP_tagid(), bb); finalPositionList.add(position); } return finalPositionList; } @RequestMapping(value="/getRealPositionsan3.do", method = { RequestMethod.POST, RequestMethod.GET }) @ResponseBody public List getRealPositionsan3(HttpServletRequest request) { long timeStart = 0; String floor = request.getParameter("floor"); //根据时间筛选出数据 List realLocationList = ZhwService.getpersonLocationsan3(floor); List finalPositionList = new ArrayList(); //根据每个tagid取tb_tag:[tag_id,state(静止1or运动0),power,status(在线1or离线0),addtime],放入tb_position中 for (tb_person node : realLocationList) { double jiao = 0.00; if (persons.containsKey(node.getP_tagid())) { double x1 = Double.valueOf(node.getP_x()); double y1 = Double.valueOf(node.getP_y()); double x2 = Double.valueOf(persons.get(node.getP_tagid())[0]); double y2 = Double.valueOf(persons.get(node.getP_tagid())[1]); double c = x1-x2; double a = y1-y2; if (node.getBaoliu22().equals("0")) { jiao = Math.toDegrees(Math.atan2(c, a)); } else { String[] xy = node.getBaoliu23().split(","); jiao = Math.toDegrees(Math.atan2(Double.valueOf(xy[0]), Double.valueOf(xy[1]))); } if (String.valueOf(jiao).equals("0.0")) { jiao = Double.valueOf(persons.get(node.getP_tagid())[2]).doubleValue(); } } 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.setSex(node.getP_sex()); position.setMinzu(node.getP_minzu()); position.setPhone(node.getP_phone()); position.setBumen(node.getP_department()); 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()); position.setJiao(String.valueOf(jiao)); position.setBaoliu22(node.getBaoliu22()); position.setBaoliu23(node.getBaoliu23()); position.setBaoliu24(node.getBaoliu24()); String[] bb = new String[]{node.getP_x(),node.getP_y(),String.valueOf(jiao)}; persons.put(node.getP_tagid(), bb); finalPositionList.add(position); } return finalPositionList; } public double qiujiao(int a,int b,int c) { double angle = 0.00; if (a+b-c!=0) { angle=Math.toDegrees(Math.acos((a*a+b*b-c*c)/(2*a*b)));//C的角度 } return angle; } @RequestMapping(value="/getRealPositionsana.do", method = { RequestMethod.POST, RequestMethod.GET }) @ResponseBody public JSONObject getRealPositionsana(HttpServletRequest request) { long timeStart = 0; JSONObject json = new JSONObject(); //根据时间筛选出数据 List realLocationList = ZhwService.getpersonLocationsan2(); // 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 xy = ZhwController.cal2(xo, yo); // node.setP_x((xy.get(0)).toString()); // node.setP_y((xy.get(1)).toString()); // } List finalPositionList = new ArrayList(); //根据每个tagid取tb_tag:[tag_id,state(静止1or运动0),power,status(在线1or离线0),addtime],放入tb_position中 for (tb_person node : realLocationList) { // if (node.getP_online().equals("1")) { 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.setIdcardnum(node.getP_idcardnum()); position.setPosx(node.getP_x()); position.setPosy(node.getP_y()); position.setFloor(node.getP_floor()); 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()); position.setFangkeid(node.getP_fangkeid()); position.setJingdu(node.getP_jingdu()); position.setWeidu(node.getP_weidu()); position.setGaocheng(node.getP_gaocheng()); position.setPhone(node.getP_phone()); position.setType(node.getP_type()); finalPositionList.add(position); // } } json.put("dataList", finalPositionList); return json; } @RequestMapping(value="/getkaoqinsan.do", method = { RequestMethod.POST, RequestMethod.GET }) @ResponseBody public List getkaoqinsan(HttpServletRequest request) { List realkaoqingList = ZhwService.getkaoqinsan(); return realkaoqingList; } @RequestMapping(value = "/xiafazhendong.do", method = { RequestMethod.POST, RequestMethod.GET }) public void xiafazhendong(HttpServletRequest request) throws IOException { String tagid=request.getParameter("tagid"); String xieyi = "55BB,TAG_SHAKE,10,"+tagid+",END"; Udp_Out.udp_to_cs(xieyi); } @RequestMapping("bofang.do") public void shangchuan2(HttpServletRequest request) { String name = request.getParameter("name"); List shipins = fenceService.searchshipinManagement(name); String yonghuming = shipins.get(0).getYonghuming(); String mima = shipins.get(0).getMima(); String ipdizhi = shipins.get(0).getBaoliu1(); int flag = -1; // 输出ffmpeg推流日志 String ffmpegPath = "F:\\ffmpeg\\ffmpeg-4.4-essentials_build\\bin\\"; try { String command = ffmpegPath; command += "ffmpeg -rtsp_transport tcp"; // ffmpeg开头,-re代表按照帧率发送,在推流时必须有 command += " -i \"rtsp://"+yonghuming+":"+mima+"@"+ipdizhi+":554/Streaming/Channels/102\""; // 指定要推送的视频 command += " -q 0 -f mpegts -codec:v mpeg1video -s 1280x720 http://127.0.0.1:8081/123456"; // 指定推送服务器,-f:指定格式 1280 720 System.out.println("ffmpeg推流命令:" + command); process = Runtime.getRuntime().exec(command); // 输出ffmpeg推流日志 BufferedReader br= new BufferedReader(new InputStreamReader(process.getErrorStream())); String line = ""; while ((line = br.readLine()) != null) { System.out.println("视频推流信息[" + line + "]"); } flag = process.waitFor(); //这里是为了区分不同的流,需求会打开多个摄像头,根据token //后面可以对不需要的流关闭 } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } @RequestMapping("tingzhibofang.do") public void tingzhibofang() { process.destroy(); } @RequestMapping(value = "jingweijuli.do", method = { RequestMethod.POST, RequestMethod.GET }) public String tojisuan(HttpServletRequest request, HttpServletResponse response){ String toPage = "forward:/hxzk/basicInfo/jisuan.jsp"; List findjingwei = ZhwService.getjingwei(); request.setAttribute("dataList", findjingwei); return toPage; } @ResponseBody @RequestMapping(value = "jisuanjingwei.do", method = { RequestMethod.POST, RequestMethod.GET }) public JSONObject jisuanjingwei (String str) { JSONObject json = new JSONObject(); String disab = disab(str); String[] split = str.split(";"); String qishi = split[1]+"/"+split[0]; String zhongzhi = split[3]+"/"+split[2]; tb_jingwei jingwei = new tb_jingwei(); SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String format = simpleDateFormat.format(new Date()); jingwei.setQishi(qishi); jingwei.setZhongzhi(zhongzhi); jingwei.setJieguo(disab); jingwei.setAddtime(format); ZhwService.addjingwei(jingwei); List findjingwei = ZhwService.getjingwei(); json.put("jieguo",disab); json.put("dataList",findjingwei); return json; } @ResponseBody @RequestMapping(value = "jisuanjingwei2.do", method = { RequestMethod.POST, RequestMethod.GET }) public JSONObject jisuanjingwei2 (String str) { JSONObject json = new JSONObject(); String[] split = str.split(";"); double[] sy = gpstodu(split[1], split[0]); String str2 = sy[1]+";"+sy[0]; json.put("jieguo",str2); return json; } @ResponseBody @RequestMapping(value = "jisuanjingwei3.do", method = { RequestMethod.POST, RequestMethod.GET }) public JSONObject jisuanjingwei3 (HttpServletRequest request) { JSONObject json = new JSONObject(); String qidian = request.getParameter("qidian"); String zhongdian = request.getParameter("zhongdian"); String[] qidians = qidian.split(","); String[] zhongdians = zhongdian.split(","); String str = qidians[2]+";"+qidians[4]+";"+zhongdians[2]+";"+zhongdians[4]; String disab = disab(str); String[] split = str.split(";"); String qishi = split[1]+"/"+split[0]; String zhongzhi = split[3]+"/"+split[2]; tb_jingwei jingwei = new tb_jingwei(); SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String format = simpleDateFormat.format(new Date()); jingwei.setQishi(qishi); jingwei.setZhongzhi(zhongzhi); jingwei.setJieguo(disab); jingwei.setAddtime(format); ZhwService.addjingwei(jingwei); List findjingwei = ZhwService.getjingwei(); json.put("jieguo",disab); json.put("dataList",findjingwei); return json; } @ResponseBody @RequestMapping(value = "/startjob.do", method = { RequestMethod.POST, RequestMethod.GET }) public String startjob(HttpServletRequest request) { List fences = fenceService.getFenceLista(); for (int i = 0;i fences = fenceService.getFenceLista(); for (int i = 0;i fences = fenceService.getFenceLista(); for (int i = 0;i tb_jobhistorys = fenceService.getzuoye(); json.put("dataList", tb_jobhistorys); return json; } @ResponseBody @RequestMapping(value = "/jobexport.do", method = { RequestMethod.POST, RequestMethod.GET }) public String jobexport(HttpServletRequest request, HttpServletResponse response) { List tb_jobhistorys = fenceService.getzuoye(); String[] rowName = { "序号", "操作步骤", "围栏名称", "关联部门", "关联标签", "围栏高度", "围栏绘制时间", "记录时间", "备注" }; List dataList = objectToArray_job(tb_jobhistorys); ExcelUtils excel = new ExcelUtils("作业历史", rowName, dataList); OutputStream out; String fileName = ""; try { fileName = "Excel-" + String.valueOf(System.currentTimeMillis()).substring(4, 13) + ".xls"; String filePath2 = request.getServletContext().getRealPath("/") + "hxzk/image/excels/"+fileName; out = new FileOutputStream(filePath2); excel.export(out); out.flush(); out.close(); } catch (Exception e) { e.printStackTrace(); } return fileName; } @RequestMapping(value = "/tiaozhuanfa.do", method = { RequestMethod.POST, RequestMethod.GET }) public String tiaozhuanfa(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String floor = request.getParameter("floor"); String toPage = "forward:/hxzk/mapshow/mapShowfa.jsp"; request.setAttribute("floor", floor); return toPage; } @ResponseBody @RequestMapping(value = "/getmessagea.do", method = { RequestMethod.POST, RequestMethod.GET}) public String getmessagea(HttpServletRequest request) { JSONObject json = new JSONObject(); List messages = ZhwService.getmessage(); Date date = new Date(); SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Calendar cal = Calendar.getInstance(); cal.setTime(date); cal.add(Calendar.DATE, -3); String date2 = simpleDateFormat.format(cal.getTime()); ZhwService.deletemessage(date2); json.put("dataList", messages); return json.toString(); } @RequestMapping(value = "/sendmessage.do", method = {RequestMethod.POST, RequestMethod.GET}) public void sendmessage(HttpServletRequest request) { HttpSession session = request.getSession(); ServletContext application = session.getServletContext(); String username = application.getAttribute("username").toString(); String arr = request.getParameter("arr"); String message = request.getParameter("message"); if (arr.equals("all")) { List persons = ZhwService.getbumen(); for (int i=0; i0?(int)timeDelta:(int)Math.abs(timeDelta); return secondsDelta; } /**计算2个时分秒的差*/ public static int get_time_cha_HMS(String a,String b) { final String HHmmss = "HH:mm:ss"; Date date1=parseDateByPattern(a, HHmmss); Date date2=parseDateByPattern(b, HHmmss); return getTimeDelta(date1, date2); } /**计算时间差返回boolean*/ public static boolean shijiancha(String time,int p) { boolean a=false; int b= get_time_cha_s(GetNowTime.now(),time); //当前时间和之前时间差大于某个数值p if(b>p) { a=true; } return a; } // 作业信息 导出表格 对象转数组 public static List objectToArray_job(List history_powerList) { List reList = new ArrayList<>(); for (int i = 0; i < history_powerList.size(); i++) { List words = new ArrayList(); tb_jobhistory history_power = (tb_jobhistory) history_powerList.get(i); words.add(history_power.getId() + ""); words.add(history_power.getType()); words.add(history_power.getFencename()); words.add(history_power.getDepartment()); words.add(history_power.getTagid()); words.add(history_power.getHigh()); words.add(history_power.getFenceaddtime()); words.add(history_power.getAddtime()); words.add(history_power.getBeizhu()); String[] array = words.toArray(new String[0]); reList.add(array); } return reList; } public static List objectToArray_qihouManagement2(List tb_qihouList) { List reList = new ArrayList<>(); for (int i = 0; i < tb_qihouList.size(); i++) { List words = new ArrayList(); 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 objectToArray_qihouManagement(List tb_qihouList) { List reList = new ArrayList<>(); for (int i = 0; i < tb_qihouList.size(); i++) { List words = new ArrayList(); 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 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 xy = new ArrayList(); xy.add(mx); xy.add(my); return xy; } public static boolean isInPolygon(Point2D.Double point, List pts){ int N = pts.size(); boolean boundOrVertex = true; int intersectCount = 0;//交叉点数量 double precision = 2e-10; //浮点类型计算时候与0比较时候的容差 Point2D.Double p1, p2;//临近顶点 Point2D.Double p = point; //当前点 p1 = pts.get(0); for(int i = 1; i <= N; ++i){ if(p.equals(p1)){ return boundOrVertex; } p2 = pts.get(i % N); if(p.x < Math.min(p1.x, p2.x) || p.x > Math.max(p1.x, p2.x)){ p1 = p2; continue; } //射线穿过算法 if(p.x > Math.min(p1.x, p2.x) && p.x < Math.max(p1.x, p2.x)){ if(p.y <= Math.max(p1.y, p2.y)){ if(p1.x == p2.x && p.y >= Math.min(p1.y, p2.y)){ return boundOrVertex; } if(p1.y == p2.y){ if(p1.y == p.y){ return boundOrVertex; }else{ ++intersectCount; } }else{ double xinters = (p.x - p1.x) * (p2.y - p1.y) / (p2.x - p1.x) + p1.y; if(Math.abs(p.y - xinters) < precision){ return boundOrVertex; } if(p.y < xinters){ ++intersectCount; } } } }else{ if(p.x == p2.x && p.y <= p2.y){ Point2D.Double p3 = pts.get((i+1) % N); if(p.x >= Math.min(p1.x, p3.x) && p.x <= Math.max(p1.x, p3.x)){ ++intersectCount; }else{ intersectCount += 2; } } } p1 = p2; } if(intersectCount % 2 == 0){//偶数在多边形外 return false; } else { //奇数在多边形内 return true; } } public static String todu(String strs) { int i = strs.indexOf('.'); String strDu = 1 < 0 ? strs : strs.substring(0, i); String strFen = ""; String strMiao = ""; if (i > 0) { Float fen = Float.parseFloat(strs.substring(i)); strFen = Float.toString(fen * 60); i = strFen.indexOf('.'); if (i > 0) { Float miao = Float.parseFloat(strFen.substring(i)); strFen = strFen.substring(0, i); strMiao = Float.toString(miao * 60); i = strMiao.indexOf('.'); strMiao = strMiao.substring(0, i + 4); strMiao = String.format("%.2f", Float.parseFloat(strMiao)); } } String Du = strDu + strFen + strMiao; return Du; } static double a=6378.137; static double e=0.0818192; static double k0=0.9996; static double e2=e*e; static double e4=e2*e2; static double e6=e4*e2; static double E0=500; static double N0=0; static String floor="0"; static double lat_a =0; static double lon_a =0; static double lon_b=0; static double lat_b=0; static double xa=0; static double ya=0; static double xb=0; static double yb=0; static int k=0; static int sizes=2; static double[] xycs=null; static double utme0; static double utmn0; static double c; static double s; static double t; static double f; /**计算2个经纬度的距离*/ public static String disab(String jwd) { DecimalFormat df = new DecimalFormat("0.00"); String[] bb=jwd.split(";"); double jd0=Double.parseDouble(bb[1]); double wd0=Double.parseDouble(bb[0]); double jd1=Double.parseDouble(bb[3]); double wd1=Double.parseDouble(bb[2]); double[] a=run_gps2xyurt(wd0,jd0,wd1,jd1); double disa=a[0]*a[0]+a[1]*a[1]; double dis=Math.sqrt(Math.abs(disa))*100; String temp = df.format(dis); System.out.println(jwd+"的距离是:"+temp); return temp; } public static double[] run_gps2xyurt( double lat0, double lon0, double lat, double lon) { int[] realxy=new int[2]; double[] xycs=initiize_ublox_zeropoint(lat0, lon0,0); double x0=xycs[0]; double y0=xycs[1]; double c=xycs[2]; double s=xycs[3]; double[] xy=new double[2]; double x= ubloxraw2xy(lat,lon)[0]-x0; double y=ubloxraw2xy(lat,lon)[1]-y0; xy[0] =c*x - s*y; xy[1] =s*x + c*y; // double x1=xy[1]*100; // double y1=xy[0]*100; // // realxy[0]=(int)x1; // realxy[1]=(int)y1; return xy; } public static double[] initiize_ublox_zeropoint(double lat, double lon, double th){ double[] xycs=new double[4]; xycs[0]=ubloxraw2xy(lat,lon)[0]; xycs[1]=ubloxraw2xy(lat,lon)[1]; double th1=th*Math.PI/180;//x轴与正北方向夹角th(单位是度) xycs[2]=Math.cos(th1); xycs[3]=Math.sin(th1); return xycs; } public static double[] ubloxraw2xy(double lat, double lon) { double[] xy=new double[3]; double lond = ublox_dm2d(lon); double latd = ublox_dm2d(lat); double[] dxy = utm(latd, lond); xy[0]= dxy[0]* 1000; xy[1]= dxy[1]* 1000; xy[2]= dxy[2]; return xy; } public static double ublox_dm2d(double ddmm_dot_m) { double d0=Math.floor(ddmm_dot_m/100); double d=d0+(ddmm_dot_m-d0*100)/60; return d; } public static double[] utm(double lat,double lon) { double[] dxy=new double[3]; double zonenum1=lon/6; //floor是地板的意思,表示向下取整 if(zonenum1>0) { zonenum1=Math.floor(zonenum1); }else {//向上取整 zonenum1=Math.ceil(zonenum1);//向上取整 } double Zonenum=zonenum1+31; double lambda0=((Zonenum-1)*6-180+3)*(Math.PI)/180; double phi=lat*(Math.PI)/180; double lambda=lon*(Math.PI)/180; double v=1/Math.sqrt((1-e2*Math.pow(Math.sin(phi),2))); double A=(lambda-lambda0)* Math.cos(phi); double A2=A*A; double A3=A2*A; double A4=A3*A; double A5=A4*A; double A6=A5*A; double T=Math.tan(phi)* Math.tan(phi); double T2=T*T; double C=e2* Math.cos(phi)* Math.cos(phi)/(1-e2); double C2=C*C; double s=(1-e2/4-3*e4/64-5*e6/256)* phi- (3*e2/8+3*e4/32+45*e6/1024)* Math.sin(2*phi)+ (15*e4/256+45*e6/1024)* Math.sin(4* phi)-35*e6/3072* Math.sin(6*phi); dxy[0]=E0+k0*a*v*(A+(1-T+C)*A3/6+(5-18*T+T2)*A5/120); dxy[1]=N0+k0*a*(s+v* Math.tan(phi)*(A2/2+(5-T+9*C+4*C2)*A4/24+(61-58*T+T2)*A6/720)); dxy[2]=Zonenum; return dxy; } //度分转度 public static String todufen(String Du, String Fen, String Miao) { Float strDu = Float.valueOf(Du); Float strFen = Float.valueOf(Fen) / 60; Float strMiao = Float.valueOf(Miao) / 60; Float dufenmiao = strDu + strFen + strMiao; String format = String.format("%.6f", dufenmiao); return format; } public static double[] gpstodu(String gps_weidu, String gps_jingdu) { double[] a = {0, 0}; String weidu = todufen(gps_weidu.substring(0, 2), gps_weidu.substring(2, 4), gps_weidu.substring(4)); String jingdu = todufen(gps_jingdu.substring(0, 3), gps_jingdu.substring(3, 5), gps_jingdu.substring(5)); a[0] = Double.parseDouble(weidu); a[1] = Double.parseDouble(jingdu); return a; } }