| | |
| | | package com.hxzkoa.controller; |
| | | |
| | | import java.awt.geom.Point2D; |
| | | import java.io.BufferedReader; |
| | | import java.io.File; |
| | | import java.io.IOException; |
| | | import java.io.InputStreamReader; |
| | | import java.io.OutputStream; |
| | | import java.sql.Date; |
| | | import java.sql.Time; |
| | |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.HashMap; |
| | | import java.util.Iterator; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | |
| | | import com.hxzkoa.services.SysSettingService; |
| | | import com.hxzkoa.services.ZhwService; |
| | | import com.hxzkoa.services.AnchorService; |
| | | import com.hxzkoa.services.AttendanceService; |
| | | import com.hxzkoa.services.FenceService; |
| | | import com.hxzkoa.udp.Dell_Ip; |
| | | import com.hxzkoa.udp.GetNowTime; |
| | |
| | | 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; |
| | |
| | | private AnchorService AnchorService; |
| | | @Autowired |
| | | private FenceService fenceService; |
| | | @Autowired |
| | | private AttendanceService attendanceService; |
| | | |
| | | httpsos sos = new httpsos(); |
| | | |
| | | Process process ; |
| | | |
| | | private Map<Integer,Process> map=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"; |
| | |
| | | for (int i =0;i < fenceList.size(); i++) { |
| | | fencenames.add(fenceList.get(i).getName()); |
| | | } |
| | | Map realAttendanceTypeMap = attendanceService.getRealAttendanceType(); |
| | | List<String> realAttendance_k = new ArrayList<String>(); |
| | | // List<Integer> realAttendance_v = new ArrayList<Integer>(); |
| | | Iterator<String> realAttendanceTypeIter = realAttendanceTypeMap.keySet().iterator(); |
| | | while (realAttendanceTypeIter.hasNext()) { |
| | | String key = realAttendanceTypeIter.next(); |
| | | realAttendance_k.add(key); |
| | | // realAttendance_v.add((int) realAttendanceTypeMap.get(key)); |
| | | } |
| | | request.setAttribute("guanlianList", realAttendance_k); |
| | | request.setAttribute("fenceList", fencenames); |
| | | request.setAttribute("floorList", floorList); |
| | | return toPage; |
| | |
| | | fence.setStop(end); |
| | | |
| | | fence.setColor(request.getParameter("yanse")); |
| | | ZhwService.drawFence_add(fence); |
| | | int aaa = ZhwService.drawFence_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); |
| | | |
| | |
| | | ZhwService.fenceInout_add(name,zb_inout,shape,floor); |
| | | } |
| | | |
| | | return 0; |
| | | return aaa; |
| | | } |
| | | |
| | | @RequestMapping(value = "/sanweiFence.do", method = { RequestMethod.POST, RequestMethod.GET }) |
| | |
| | | fence.setStop(end); |
| | | |
| | | fence.setColor(request.getParameter("yanse")); |
| | | ZhwService.sanweiFence_add(fence); |
| | | int aaa = 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(); |
| | |
| | | ZhwService.fenceInout_add(name,zb_inout,shape,floor); |
| | | } |
| | | |
| | | return 0; |
| | | return aaa; |
| | | } |
| | | |
| | | @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"; |
| | | List<tb_map> floorList = ZhwService.getFloor(); |
| | | List<tb_fence> 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<tb_track> 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<tb_track> tagList = ZhwService.getTagtrack(tag_id, begin_time, end_time, floor); |
| | | return tagList; |
| | | } |
| | | |
| | | @RequestMapping(value="/trackTagid.do", method = { RequestMethod.POST, RequestMethod.GET }) |
| | | @ResponseBody |
| | | public List<tb_track> queryTagid(HttpServletRequest request) throws ParseException { |
| | |
| | | String begin_time = request.getParameter("begin_value"); |
| | | String end_time = request.getParameter("end_value"); |
| | | String floor = request.getParameter("floor_value"); |
| | | final List<tb_track> tagList = ZhwService.getTagtrack(tag_id, begin_time, end_time, floor); |
| | | return tagList; |
| | | String fence = request.getParameter("fence"); |
| | | if (fence.equals("空")) { |
| | | final List<tb_track> tagList = ZhwService.getTagtrack(tag_id, begin_time, end_time, floor); |
| | | return tagList; |
| | | } else { |
| | | final List<tb_track> tagList = ZhwService.getTagtrack(tag_id, begin_time, end_time, floor); |
| | | final List<tb_track> tagList2 = new ArrayList<>(); |
| | | for (int i=0;i<tagList.size();i++) { |
| | | Point2D.Double dian = new Point2D.Double(Double.parseDouble(tagList.get(i).getX()),Double.parseDouble(tagList.get(i).getY())); |
| | | String[] fences = fence.split(";"); |
| | | List<Point2D.Double> fencedian = new ArrayList<>(); |
| | | for (int j=0;j<fences.length;j++) { |
| | | String[] aaa = fences[j].split(","); |
| | | Point2D.Double diana = new Point2D.Double(Double.parseDouble(aaa[0]),Double.parseDouble(aaa[1])); |
| | | fencedian.add(diana); |
| | | } |
| | | if (isInPolygon(dian,fencedian)) { |
| | | tagList2.add(tagList.get(i)); |
| | | } |
| | | } |
| | | return tagList2; |
| | | } |
| | | } |
| | | |
| | | @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<tb_track> tagList = ZhwService.getTagtrack(tag_id, begin_time, end_time, floor); |
| | | json.put("dataList", tagList); |
| | | return json; |
| | | } else { |
| | | final List<tb_track> tagList = ZhwService.getTagtrack(tag_id, begin_time, end_time, floor); |
| | | final List<tb_track> tagList2 = new ArrayList<>(); |
| | | for (int i=0;i<tagList.size();i++) { |
| | | Point2D.Double dian = new Point2D.Double(Double.parseDouble(tagList.get(i).getX()),Double.parseDouble(tagList.get(i).getY())); |
| | | String[] fences = fence.split(";"); |
| | | List<Point2D.Double> fencedian = new ArrayList<>(); |
| | | for (int j=0;j<fences.length;j++) { |
| | | String[] aaa = fences[j].split(","); |
| | | Point2D.Double diana = new Point2D.Double(Double.parseDouble(aaa[0]),Double.parseDouble(aaa[1])); |
| | | fencedian.add(diana); |
| | | } |
| | | if (isInPolygon(dian,fencedian)) { |
| | | tagList2.add(tagList.get(i)); |
| | | } |
| | | } |
| | | json.put("dataList", tagList2); |
| | | return json; |
| | | } |
| | | } |
| | | |
| | | @RequestMapping(value="/getRealPosition.do", method = { RequestMethod.POST, RequestMethod.GET }) |
| | |
| | | return finalPositionList; |
| | | } |
| | | |
| | | @ResponseBody |
| | | @RequestMapping(value="/getpersonid.do",method = { RequestMethod.POST, RequestMethod.GET }) |
| | | public JSONObject getpersonid(HttpServletRequest request) { |
| | | String tagid = request.getParameter("tagid"); |
| | | List<tb_person> realTrackList = ZhwService.getpersonid(tagid); |
| | | JSONObject json = new JSONObject(); |
| | | json.put("X", realTrackList.get(0).getP_x()); |
| | | json.put("Y", realTrackList.get(0).getP_y()); |
| | | return json; |
| | | } |
| | | |
| | | @ResponseBody |
| | | @RequestMapping(value="/getgpsid.do",method = { RequestMethod.POST, RequestMethod.GET }) |
| | | public JSONObject getgpsid(HttpServletRequest request) { |
| | | String tagid = request.getParameter("tagid"); |
| | | List<tb_gps> 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<ArrayList<tb_track>> getRealTrack(HttpServletRequest request) { |
| | |
| | | @RequestMapping(value="/getSysSetting_list.do", method = { RequestMethod.POST, RequestMethod.GET }) |
| | | @ResponseBody |
| | | public List<tb_system> getSysSetting_list(HttpServletRequest request) { |
| | | List<tb_system> settingList = sysSettingService.getSetting(); |
| | | List<tb_system> settingList = sysSettingService.getSetting(); |
| | | return settingList; |
| | | } |
| | | |
| | |
| | | List<tb_gps> finalGPSList = new ArrayList<tb_gps>(); |
| | | 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")) { |
| | | finalGPSList.add(node); |
| | | 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<tb_gps> gpsList = ZhwService.getGPS(); |
| | | |
| | | List<tb_gps> finalGPSList = new ArrayList<tb_gps>(); |
| | | 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<tb_gps> getGPSTrack(HttpServletRequest request) throws ParseException { |
| | |
| | | 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<tb_gps> 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<tb_map> qiehuanditu_option(HttpServletRequest request) { |
| | |
| | | return finalPositionList; |
| | | } |
| | | |
| | | @RequestMapping(value="/getRealPositionsana.do", method = { RequestMethod.POST, RequestMethod.GET }) |
| | | @ResponseBody |
| | | public JSONObject getRealPositionsana(HttpServletRequest request) { |
| | | long timeStart = 0; |
| | | |
| | | JSONObject json = new JSONObject(); |
| | | |
| | | //根据时间筛选出数据 |
| | | 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()); |
| | | position.setFangkeid(node.getP_fangkeid()); |
| | | position.setJingdu(node.getP_jingdu()); |
| | | position.setWeidu(node.getP_weidu()); |
| | | position.setGaocheng(node.getP_gaocheng()); |
| | | |
| | | finalPositionList.add(position); |
| | | } |
| | | json.put("dataList", finalPositionList); |
| | | return json; |
| | | } |
| | | |
| | | @RequestMapping(value="/getkaoqinsan.do", method = { RequestMethod.POST, RequestMethod.GET }) |
| | | @ResponseBody |
| | | public List<tb_realkaoqing> getkaoqinsan(HttpServletRequest request) { |
| | | List<tb_realkaoqing> realkaoqingList = ZhwService.getkaoqinsan(); |
| | | System.out.print("------------------------"); |
| | | System.out.print("------------------------"+realkaoqingList.get(0).getName()); |
| | | return realkaoqingList; |
| | | } |
| | | |
| | |
| | | Udp_Out.udp_to_cs(xieyi); |
| | | } |
| | | |
| | | @RequestMapping("bofang.do") |
| | | public void shangchuan2() { |
| | | 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://admin:hxzk20151102@192.168.3.64: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(); |
| | | } |
| | | |
| | | 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++) { |
| | |
| | | xy.add(my); |
| | | return xy; |
| | | } |
| | | |
| | | public static boolean isInPolygon(Point2D.Double point, List<Point2D.Double> 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; |
| | | } |
| | | } |
| | | } |