From bc131131c5c96f8cb3bed679d4a359820c22e335 Mon Sep 17 00:00:00 2001
From: 15832144755 <67030627+15832144755@users.noreply.github.com>
Date: 星期四, 17 三月 2022 09:38:47 +0800
Subject: [PATCH] 3.17

---
 src/main/java/com/hxzkoa/controller/ZhwController.java |  862 ++++++++++++++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 784 insertions(+), 78 deletions(-)

diff --git a/src/main/java/com/hxzkoa/controller/ZhwController.java b/src/main/java/com/hxzkoa/controller/ZhwController.java
index a5ede81..cf42145 100644
--- a/src/main/java/com/hxzkoa/controller/ZhwController.java
+++ b/src/main/java/com/hxzkoa/controller/ZhwController.java
@@ -1,6 +1,11 @@
 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.sql.Timestamp;
@@ -9,6 +14,7 @@
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.HashMap;
+import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 
@@ -22,7 +28,9 @@
 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;
@@ -32,6 +40,8 @@
 import com.hxzkoa.json.tb_gps;
 import com.hxzkoa.json.tb_map;
 import com.hxzkoa.json.tb_person;
+import com.hxzkoa.json.tb_qihou;
+import com.hxzkoa.json.tb_realkaoqing;
 import com.hxzkoa.json.tb_realocation;
 import com.hxzkoa.json.tb_realpositoin;
 import com.hxzkoa.json.tb_shipin;
@@ -41,6 +51,8 @@
 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.udp.ReadPeizhiMessage;
@@ -48,10 +60,16 @@
 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;
 
 
@@ -67,13 +85,61 @@
 	private SysSettingService sysSettingService; 
 	@Autowired
 	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";
 		List<tb_map> floorList = ZhwService.getFloor();
+		List<tb_fence> fenceList = fenceService.getFenceList();
+		List<String> fencenames = new ArrayList<>();
+		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;
 	}
@@ -137,7 +203,12 @@
 	@ResponseBody
 	public int drawFence_add(HttpServletRequest request) {
 		tb_fence fence = new tb_fence();
-		fence.setFloor(request.getParameter("layer"));
+		String layer = request.getParameter("layer");
+		if(!layer.equals("鐧惧害鍦板浘")) {
+			Integer layerjj = Integer.parseInt(layer);	
+			layer = layerjj.toString();
+		}
+		fence.setFloor(layer);
 		fence.setType(request.getParameter("weilanleixing"));
 		fence.setBumen(request.getParameter("guanlianduixiang"));
 		fence.setName(request.getParameter("quyumingcheng"));
@@ -153,7 +224,7 @@
 		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);
 		
@@ -178,17 +249,86 @@
 			ZhwService.fenceInout_add(name,zb_inout,shape,floor);
 		}
 		
-		return 0;
+		return aaa;
+	}
+	
+	@RequestMapping(value = "/sanweiFence.do", method = { RequestMethod.POST, RequestMethod.GET })
+	@ResponseBody
+	public int sanweiFence_add(HttpServletRequest request) {
+		tb_fence fence = new tb_fence();
+		String layer = request.getParameter("layer");
+		if(!layer.equals("鐧惧害鍦板浘") && !layer.equals("鎵嬪姩杈撳叆") && !layer.equals("鑷姩杈撳叆")) {
+			Integer layerjj = Integer.parseInt(layer);	
+			layer = layerjj.toString();
+		}else {
+			layer = "鐧惧害鍦板浘";
+		}
+		fence.setFloor(layer);
+		fence.setType(request.getParameter("weilanleixing"));
+		fence.setBumen(request.getParameter("guanlianduixiang"));
+		fence.setName(request.getParameter("quyumingcheng"));
+		fence.setBaoliu1(request.getParameter("fencegao"));
+		String zuobiao =(String) request.getParameter("zuobiao");
+		String zuobiaodufen = (String) request.getParameter("zuobiaodufen");
+		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"));
+		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();
+		String type = request.getParameter("weilanleixing");
+		String name = request.getParameter("quyumingcheng");
+		String floor = request.getParameter("layer");
+		String shape = request.getParameter("xingzhuang");
+		
+		if(type.equals("宸℃鍖哄煙")) {
+			ZhwService.xunjianSet_add(name);
+		} else if (type.equals("瀹氫綅鍖哄煙")) {
+			String[] zb_list = zuobiao.split(",");
+			String zb_inout = "";
+			for (int i=0;i<zb_list.length;i++) {
+				zb_inout += zb_list[i];
+				if (i%2==0) {
+					zb_inout += ",";
+				} else if (i%2==1 && i!=zb_list.length-1) {
+					zb_inout += ";";
+				}
+			}
+			ZhwService.fenceInout_add(name,zb_inout,shape,floor);
+		}
+		
+		return 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 {  
@@ -196,53 +336,81 @@
 	    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 })
 	@ResponseBody
 	public List<tb_realpositoin> getRealPosition(HttpServletRequest request) { 
-		//浠巘b_person涓彇鏈�鏂版洿鏂扮殑[p_tagid,p_x,p_y,p_floor,p_addtime]
 		String floor = request.getParameter("floor");
-//		long timeNow =  System.currentTimeMillis(); 
-//		long timeStart = timeNow - 10000; //鍙�10s鍐呮渶鏂扮殑涓�鏉℃暟鎹綔涓哄綋鍓嶇殑瀹炴椂浣嶇疆锛屽悗鏈熷彲鏇存敼锛屾澶勪负ms鍗曚綅
-		long timeStart = 0;
 		
 		//鏍规嵁鏃堕棿绛涢�夊嚭鏁版嵁
 		List<tb_person> realLocationList = ZhwService.getpersonLocation(floor);
-		List<tb_person> personLocationList = new ArrayList<tb_person>();
-		for ( tb_person node : realLocationList) {
-			String timeRecent = node.getP_addtiem();
-			Timestamp ts = Timestamp.valueOf(timeRecent);
-			long times = ts.getTime();
-			System.out.println("times"+times);
-			if (times >= timeStart) {
-				personLocationList.add(node);
-			}
-		}
 		
 		List<tb_realpositoin> finalPositionList = new ArrayList<tb_realpositoin>();
 		
 		//鏍规嵁姣忎釜tagid鍙杢b_tag:[tag_id,state(闈欐1or杩愬姩0),power,status(鍦ㄧ嚎1or绂荤嚎0),addtime]锛屾斁鍏b_position涓�
-		for (tb_person node : personLocationList) {
-			List<tb_tag> taglist = new ArrayList<tb_tag>();
-			List<tb_person> personlist = new ArrayList<tb_person>();
-			
+		for (tb_person node : realLocationList) {
 			String tagid = node.getP_tagid();
-			taglist = ZhwService.getRealTagState(tagid);
-			personlist = ZhwService.getRealpersonState(tagid);
-			
 			tb_realpositoin position = new tb_realpositoin();
 			position.setTagid(tagid);
-			
-			if (personlist.isEmpty()) {
-				position.setPower("");
-				position.setLife("");
-			} else {
-				position.setPower(personlist.get(0).getP_power());
-				position.setLife(personlist.get(0).getP_online());
-			}
+			position.setPower(node.getP_power());
+			position.setLife(node.getP_online());
 			position.setName(node.getP_name());
 			position.setPosx(node.getP_x());
 			position.setPosy(node.getP_y());
@@ -260,43 +428,19 @@
 	@RequestMapping(value="/getRealPosition_all.do", method = { RequestMethod.POST, RequestMethod.GET })
 	@ResponseBody
 	public List<tb_realpositoin> getRealPosition_all(HttpServletRequest request) { 
-		//浠巘b_person涓彇鏈�鏂版洿鏂扮殑[p_tagid,p_x,p_y,p_floor,p_addtime]
-//		long timeNow =  System.currentTimeMillis(); 
-		//long timeStart = timeNow - 10000; //鍙�10s鍐呮渶鏂扮殑涓�鏉℃暟鎹綔涓哄綋鍓嶇殑瀹炴椂浣嶇疆锛屽悗鏈熷彲鏇存敼锛屾澶勪负ms鍗曚綅
-		long timeStart = 0;
 		
 		//鏍规嵁鏃堕棿绛涢�夊嚭鏁版嵁
 		List<tb_person> realLocationList = ZhwService.getpersonLocation_all();
-		List<tb_person> personLocationList = new ArrayList<tb_person>();
-		for ( tb_person node : realLocationList) {
-			String timeRecent = node.getP_addtiem();
-			Timestamp ts = Timestamp.valueOf(timeRecent);
-			long times = ts.getTime();
-			System.out.println("times"+times);
-			if (times >= timeStart) {
-				personLocationList.add(node);
-			}
-		}
 		
 		List<tb_realpositoin> finalPositionList = new ArrayList<tb_realpositoin>();
 		
 		//鏍规嵁姣忎釜tagid鍙杢b_tag:[tag_id,state(闈欐1or杩愬姩0),power,status(鍦ㄧ嚎1or绂荤嚎0),addtime]锛屾斁鍏b_position涓�
-		for (tb_person node : personLocationList) {
-			List<tb_tag> taglist = new ArrayList<tb_tag>();
-			
+		for (tb_person node : realLocationList) {
 			String tagid = node.getP_tagid();
-			taglist = ZhwService.getRealTagState(tagid);
-			
 			tb_realpositoin position = new tb_realpositoin();
 			position.setTagid(tagid);
-			
-			if (taglist.isEmpty()) {
-				position.setPower("");
-				position.setLife("");
-			} else {
-				position.setPower(taglist.get(0).getPower());
-				position.setLife(taglist.get(0).getStatus());
-			}
+			position.setPower(node.getP_power());
+			position.setLife(node.getP_online());
 			position.setFloor(node.getP_floor());
 			position.setName(node.getP_name());
 			position.setPosx(node.getP_x());
@@ -304,13 +448,36 @@
 			position.setSos(node.getP_sos());
 			position.setTime(node.getP_addtiem());
 			position.setFence(node.getP_fence());
-			
+			position.setChaichu(node.getBaoliu6());
 			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<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) {
@@ -399,7 +566,7 @@
 	@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;
 	}
 	
@@ -422,23 +589,40 @@
 	@ResponseBody
 	public List<tb_gps> getGPS(HttpServletRequest request) {  
 		final List<tb_gps> gpsList = ZhwService.getGPS();
-		long timeNow =  System.currentTimeMillis(); 
-		long timeStart = timeNow - 1000; //鍙�1s鍐呮渶鏂扮殑涓�鏉℃暟鎹綔涓哄綋鍓嶇殑瀹炴椂浣嶇疆锛屽悗鏈熷彲鏇存敼锛屾澶勪负ms鍗曚綅
-//		long timeStart = 0;
 		
 		List<tb_gps> finalGPSList = new ArrayList<tb_gps>();
 		for ( tb_gps node : gpsList) {
-			//浠呭彇鏈�鏂版洿鏂版椂闂村湪褰撳墠鏃堕棿鍗佺鍐呯殑鏁版嵁
-//			String timeRecent = node.getAddtime();
-//			Timestamp ts = Timestamp.valueOf(timeRecent);
-//			long times = ts.getTime();
-//			if (times >= timeStart) {
-				finalGPSList.add(node);
-//			}
+			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<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 {  
@@ -449,6 +633,18 @@
 		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) {  
@@ -462,7 +658,7 @@
 		String map_now = request.getParameter("map_now");
 		String filePath = Config.getMapConfig();
 		ModifyConfig.writeData(filePath,"map_now",map_now);
-		System.out.print(ModifyConfig.readData(filePath, "map_now"));
+		//System.out.print(ModifyConfig.readData(filePath, "map_now"));
 		return "1";
 	}
 	
@@ -473,8 +669,8 @@
 //		String map = ModifyConfig.readData(filePath, "map_now");
 //		List<String> maplist = new ArrayList<String>();
 //		maplist.add(map);
-//		System.out.print("read data");
-//		System.out.print(map);
+//		//System.out.print("read data");
+//		//System.out.print(map);
 		List<tb_system> systemlist = sysSettingService.getSetting();
 		List<String> maplist = new ArrayList<String>();
 		String map = systemlist.get(0).getYulan_map();
@@ -735,12 +931,50 @@
 	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 = "/gaojingzongchuli.do", method = { RequestMethod.POST, RequestMethod.GET })
+	public void gaojingzongchuli(HttpServletRequest request) throws IOException {
+		List<tb_person> soslist = ZhwService.getsosgaojing();
+		for (int i=0; i<soslist.size(); i++) {
+			String tagid = soslist.get(i).getP_tagid();
+			ZhwService.sosgao(tagid);
+			String xieyi = "BSTOCS1,DELLWARN," +tagid+ ",SOS,END";
+			Udp_Out.udp_to_cs(xieyi);
+		}
+		List<tb_person> fencelist = ZhwService.getfencegaojing();
+		for (int i=0; i<fencelist.size(); i++) {
+			String tagid = fencelist.get(i).getP_tagid();
+			ZhwService.fencegao(tagid);
+			String xieyi = "BSTOCS1,DELLWARN," +tagid+ ",鍗遍櫓鍖哄煙,END";
+			Udp_Out.udp_to_cs(xieyi);
+		}
+		List<tb_person> chufencelist = ZhwService.getchufencegaojing();
+		for (int i=0; i<fencelist.size(); i++) {
+			String tagid = chufencelist.get(i).getP_tagid();
+			ZhwService.fencegao(tagid);
+			String xieyi = "BSTOCS1,DELLWARN," +tagid+ ",鍑哄尯鍩熷憡璀�,END";
+			Udp_Out.udp_to_cs(xieyi);
+		}
 	}
 	
 	@ResponseBody
@@ -749,9 +983,9 @@
 		String tagid=request.getParameter("tagid");
 		ZhwService.shipin(tagid);
 		List<tb_person> fencename = ZhwService.getfencename(tagid);
-//		System.out.print(fencename.get(0).getP_fencename());
+//		//System.out.print(fencename.get(0).getP_fencename());
 		List<tb_shipin> id = ZhwService.getshebeiid(fencename.get(0).getP_fencename());
-//		System.out.print(id.get(0).getShebeiid());
+//		//System.out.print(id.get(0).getShebeiid());
 		List<tb_shipin> bb =null;
 		return id;
 	}
@@ -769,4 +1003,476 @@
 		String xieyi = "BSTOCS1,give_up_sousuo,END";
 		Udp_Out.udp_to_cs(xieyi);
 	}
+	
+	@RequestMapping(value = "/qihouManagement.do", method = { RequestMethod.POST, RequestMethod.GET })
+	public String qihouManagement(HttpServletRequest request) {
+		String toPage = "forward:/hxzk/qihou.jsp";
+		List<tb_qihou> qihouManagementList = ZhwService.qihoucha(1);
+		request.setAttribute("qihouManagementList", qihouManagementList);
+		int curPage = 1;
+		int count = ZhwService.getqihouManagementCount();
+		int minPage = PageUtil.getMinPage(count);
+		request.setAttribute("pageList", PageUtil.getPage(minPage));
+		request.setAttribute("curPage", curPage);
+		return toPage;
+	}
+
+	@RequestMapping(value = "/qihouManagement_add.do", method = { RequestMethod.POST, RequestMethod.GET })
+	public void qihouManagement_add(HttpServletRequest request) throws IOException {
+		tb_qihou qihou = new tb_qihou();
+		qihou.setPlace(request.getParameter("place"));
+		qihou.setWeather(request.getParameter("weather"));
+		qihou.setWd(request.getParameter("wd"));
+		qihou.setSd(request.getParameter("sd"));
+		ZhwService.qihouzeng(qihou);
+	}
+
+	@RequestMapping(value = "/qihouManagement_modify.do", method = { RequestMethod.POST, RequestMethod.GET })
+	public void qihouManagement_modify(HttpServletRequest request) {
+		tb_qihou qihou = new tb_qihou();
+		String id = request.getParameter("id");
+		qihou.setId(Integer.parseInt(id));
+		qihou.setPlace(request.getParameter("place"));
+		qihou.setWeather(request.getParameter("weather"));
+		qihou.setWd(request.getParameter("wd"));
+		qihou.setSd(request.getParameter("sd"));
+		ZhwService.qihougai(qihou);
+	}
+
+//	@RequestMapping(value = "/labelManagement_modifyAll.do", method = { RequestMethod.POST, RequestMethod.GET })
+//	public void labelManagement_modifyAll(HttpServletRequest request) {
+//		tb_tag tag = new tb_tag();
+//		tag.setGaodu(request.getParameter("gaodu"));
+//		tag.setSudu(request.getParameter("sudu"));
+//		tag.setPinglv(request.getParameter("pinglv"));
+//		labelService.labelManagement_modifyAll(tag);
+//		String xieyi = "BSTOCS1,ALTERALLTAG,"+tag.getGaodu()+","+tag.getSudu()+","+tag.getPinglv()+",END";
+//		Udp_Out.udp_to_cs(xieyi);
+//		// 闇�瑕侀亶鍘嗕慨鏀�
+//		List<tb_tag> labelList = labelService.getLabelManagement();
+//		for (int i = 0; i < labelList.size(); i++) {
+//			String tag_id = labelList.get(i).getTag_id();
+//			// 淇敼鏍囩鍚屾椂闇�瑕佷慨鏀箃b_person 闇�瑕佸厛鏌ュ啀鏀瑰惁鍒欒鐩栫┖
+//			List<tb_person> searchPersonManagement = basicInfoService.searchPersonManagement(tag_id);
+//			if(searchPersonManagement!=null){
+//				tb_person person = searchPersonManagement.get(0);
+//				person.setP_tagid(tag.getTag_id());
+//				person.setP_name(tag.getState());
+//				person.setP_power(tag.getPower());
+//				basicInfoService.personManagement_modify(person);
+//			}
+//		}
+//	}
+
+	@ResponseBody
+	@RequestMapping(value = "/qihouManagement_delete.do", method = { RequestMethod.POST, RequestMethod.GET })
+	public void qihouManagement_delete(HttpServletRequest request) {
+		String checkValStr = request.getParameter("checkVal");
+		checkValStr = checkValStr.replaceAll("\"", "");
+		String[] checkVal = checkValStr.split(",");
+		ZhwService.qihoudelete(checkVal);
+	}
+
+	@ResponseBody
+	@RequestMapping(value = "/qihouManagement_deleteAll.do", method = { RequestMethod.POST, RequestMethod.GET })
+	public void qihouManagement_deleteAll(HttpServletRequest request) {
+		ZhwService.qihoudeleteAll();
+	}
+	
+	@ResponseBody
+	@RequestMapping(value = "/qihouManagement_export.do", method = { RequestMethod.POST, RequestMethod.GET })
+	public String qihouManagement_export(HttpServletRequest request, HttpServletResponse response) {
+		String toPage = "forward:/hxzk/qihou.jsp";
+		List<tb_qihou> tb_qihouList = ZhwService.qihoucha();
+		String[] rowName = { "ID", "鏃堕棿", "鍦扮偣", "澶╂皵", "娓╁害", "婀垮害" };
+		List<Object[]> dataList = objectToArray_qihouManagement(tb_qihouList);
+		ExcelUtils excel = new ExcelUtils("姘斿�欐暟鎹�", rowName, dataList);
+		OutputStream out;
+		try {
+			String fileName = "Excel-" + String.valueOf(System.currentTimeMillis()).substring(4, 13) + ".xls";
+			String headStr = "attachment; filename=\"" + fileName + "\"";
+			response.setContentType("APPLICATION/OCTET-STREAM");
+			response.setHeader("Content-Disposition", headStr);
+			out = response.getOutputStream();
+			excel.export(out);
+			out.flush();
+			out.close();
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+		return toPage;
+	}
+	
+	@ResponseBody
+	@RequestMapping(value = "/qihouManagement_exportTemplate.do", method = { RequestMethod.POST, RequestMethod.GET })
+	public String qihouManagement_exportTemplate(HttpServletRequest request, HttpServletResponse response) {
+		String toPage = "forward:/hxzk/qihou.jsp";
+		List<tb_qihou> qihouTemplateList = ZhwService.qihoucha(1);
+		String[] rowName = { "鏃堕棿", "鍦扮偣", "澶╂皵", "娓╁害", "婀垮害"};
+		List<Object[]> dataList = objectToArray_qihouManagement2(qihouTemplateList);
+		ExcelUtils excel = new ExcelUtils("姘斿�欐ā鏉�", rowName, dataList);
+		OutputStream out;
+		try {
+			String fileName = "Excel-" + String.valueOf(System.currentTimeMillis()).substring(4, 13) + ".xls";
+			String headStr = "attachment; filename=\"" + fileName + "\"";
+			response.setContentType("APPLICATION/OCTET-STREAM");
+			response.setHeader("Content-Disposition", headStr);
+			out = response.getOutputStream();
+			excel.export(out);
+			out.flush();
+			out.close();
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+		return toPage;
+	}
+	
+	@ResponseBody
+	@RequestMapping(value = "/qihouManagement_page.do", method = { RequestMethod.POST, RequestMethod.GET })
+	public String qihouManagement_page(HttpServletRequest request) {
+		String pageStr = request.getParameter("page");
+		String curPageStr = request.getParameter("curPage");
+		int count = ZhwService.getqihouManagementCount();
+		int minPage = PageUtil.getMinPage(count);
+		int curPage = Integer.parseInt(curPageStr);
+		int page = 1;
+		if ("pre".equals(pageStr)) {
+			if (curPage > 1) {
+				page = curPage - 1;
+			}
+		} else if ("next".equals(pageStr)) {
+			if (curPage < minPage) {
+				page = curPage + 1;
+			}
+		} else {
+			page = Integer.parseInt(pageStr);
+		}
+		List<tb_qihou> qihouManagementList = ZhwService.qihoucha(page);
+		List<Integer> pageList = PageUtil.getPage(PageUtil.getLocPage(page, curPage), page, minPage);
+		JSONObject json = new JSONObject();
+		json.put("dataList", qihouManagementList);
+		json.put("pageList", pageList);
+		json.put("curPage", page);
+		return json.toString();
+	}
+	
+	@RequestMapping(value = "/uploadqihou.do")
+	public String uploadqihou(@RequestParam("file") MultipartFile[] files, HttpServletRequest request) {
+		String toPage = "forward:/hxzk/qihou.jsp";
+		String filePath = request.getServletContext().getRealPath("/") + "hxzk\\upload\\";
+		String filename = files[0].getOriginalFilename();
+		try {
+			File existFile = new File(filePath);
+			if (!existFile.exists()) {
+				existFile.mkdir();
+			}
+			for (MultipartFile file : files) {
+				file.transferTo(new File(filePath + file.getOriginalFilename()));
+				//System.out.print(file.getOriginalFilename());
+			}
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+		int result = 0;
+		String path = filePath + filename;
+		// 閫夊彇Excel鏂囦欢寰楀埌宸ヤ綔钖�
+		Workbook workbook;
+		try {
+			File file = new File(path);
+			workbook = Workbook.getWorkbook(file);
+			// 閫夋嫨宸ヤ綔琛紝閫氳繃Workbook鐨刧etSheet鏂规硶閫夋嫨绗竴涓伐浣滆〃锛堜粠0寮�濮嬶級
+			Sheet sheet = workbook.getSheet(0);
+			int rows = sheet.getRows();
+			// 閫夋嫨Cell锛岃鍙栧崟鍏冩牸 閫氳繃Sheet鐨刧etCell鏂规硶閫夋嫨浣嶇疆涓篊2鐨勫崟鍏冩牸锛堜袱涓弬鏁伴兘浠�0寮�濮嬶級
+			for (int i = 3; i < rows; i++) {
+				// 璇诲彇淇℃伅锛岄�氳繃Cell鐨刧etContents鏂规硶璇诲彇鍗曞厓鏍肩殑鍊兼妸鍗曞厓鏍间腑鐨勪俊鎭互瀛楃鐨勫舰寮忚鍙栧嚭鏉�
+				// String status = sheet.getCell(0, i).getContents();
+				String time = sheet.getCell(0, i).getContents();
+				String place = sheet.getCell(1, i).getContents();
+				String weather = sheet.getCell(2, i).getContents();
+				String wd = sheet.getCell(3, i).getContents();
+				String sd = sheet.getCell(4, i).getContents();
+					tb_qihou qihou = new tb_qihou();
+					// tag.setStatus(status);
+					qihou.setTime(time);
+					qihou.setPlace(place);
+					qihou.setWeather(weather);
+					qihou.setWd(wd);
+					qihou.setSd(sd);
+					result = ZhwService.qihouzeng(qihou);
+			}
+			// 閲婃斁璧勬簮
+			workbook.close();
+		} catch (BiffException e) {
+			e.printStackTrace();
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+		request.setAttribute("resultList", result);
+		List<tb_qihou> qihouManagementList = ZhwService.qihoucha(1);
+		request.setAttribute("qihouManagementList", qihouManagementList);
+		int curPage = 1;
+		int count = ZhwService.getqihouManagementCount();
+		int minPage = PageUtil.getMinPage(count);
+		request.setAttribute("pageList", PageUtil.getPage(minPage));
+		request.setAttribute("curPage", curPage);
+		File file = new File(path);
+		file.delete();
+		return toPage;
+	}
+	
+	@RequestMapping(value="/getRealPositionsan.do", method = { RequestMethod.POST, RequestMethod.GET })
+	@ResponseBody
+	public List<tb_realpositoin> getRealPositionsan(HttpServletRequest request) { 
+		long timeStart = 0;
+		
+		//鏍规嵁鏃堕棿绛涢�夊嚭鏁版嵁
+		List<tb_person> realLocationList = ZhwService.getpersonLocationsan();
+		for ( tb_person node : realLocationList) {
+			Double x = Double.valueOf(node.getP_x());
+			Double y = Double.valueOf(node.getP_y());
+			Double xo = (x-54732)/100;
+			Double yo = -(y+10268)/100;
+			List<Double> xy = ZhwController.cal2(xo, yo);
+			node.setP_x((xy.get(0)).toString());
+			node.setP_y((xy.get(1)).toString());
+		}
+		
+		List<tb_realpositoin> finalPositionList = new ArrayList<tb_realpositoin>();
+		
+		//鏍规嵁姣忎釜tagid鍙杢b_tag:[tag_id,state(闈欐1or杩愬姩0),power,status(鍦ㄧ嚎1or绂荤嚎0),addtime]锛屾斁鍏b_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="/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鍙杢b_tag:[tag_id,state(闈欐1or杩愬姩0),power,status(鍦ㄧ嚎1or绂荤嚎0),addtime]锛屾斁鍏b_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;
+	}
+	
+	@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() {
+        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浠h〃鎸夌収甯х巼鍙戦�侊紝鍦ㄦ帹娴佹椂蹇呴』鏈�
+            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++) {
+			List<String> words = new ArrayList<String>();
+			tb_qihou qihou = (tb_qihou) tb_qihouList.get(i);
+			words.add(qihou.getTime());
+			words.add(qihou.getPlace());
+			words.add(qihou.getWeather());
+			words.add(qihou.getWd());
+			words.add(qihou.getSd());
+			String[] array = words.toArray(new String[0]);
+			reList.add(array);
+		}
+		return reList;
+	}
+	
+	// tb_qihou 瀵煎嚭琛ㄦ牸 瀵硅薄杞暟缁�
+		public static List<Object[]> objectToArray_qihouManagement(List<tb_qihou> tb_qihouList) {
+			List<Object[]> reList = new ArrayList<>();
+			for (int i = 0; i < tb_qihouList.size(); i++) {
+				List<String> words = new ArrayList<String>();
+				tb_qihou qihou = (tb_qihou) tb_qihouList.get(i);
+				words.add(String.valueOf(qihou.getId()));
+				words.add(qihou.getTime());
+				words.add(qihou.getPlace());
+				words.add(qihou.getWeather());
+				words.add(qihou.getWd());
+				words.add(qihou.getSd());
+				String[] array = words.toArray(new String[0]);
+				reList.add(array);
+			}
+			return reList;
+		}
+		
+		/**
+		  * 浠0 + 877涓哄師鐐�
+		  * @param px X鍧愭爣
+		  * @param py y鍧愭爣
+		  */
+		 private static List<Double> cal2(double px, double py) {
+		  double mx1 = 12738394.2203293;
+		  double my1 = 4586352.97186441;
+		  double rx = 1.0439323780911336;
+		  double ry = 1.0443204318588795;
+		  
+		  double mx = mx1 + px * rx;
+		  double my = my1 + py * ry;
+		  
+		  List<Double> xy = new ArrayList<Double>();
+		  xy.add(mx);
+		  xy.add(my);
+		  return xy;
+		 }
+		 
+		 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;
+		        }
+		    }
 }

--
Gitblit v1.10.0