From 52cffc4ab8e9787a6f233295502c7c9788dddae1 Mon Sep 17 00:00:00 2001
From: fxl <473369119@qq.com>
Date: 星期二, 07 三月 2023 10:45:17 +0800
Subject: [PATCH] 3.7

---
 src/main/java/com/hxzkoa/controller/FenceController.java |  327 ++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 317 insertions(+), 10 deletions(-)

diff --git a/src/main/java/com/hxzkoa/controller/FenceController.java b/src/main/java/com/hxzkoa/controller/FenceController.java
index 39a9e52..87f5d92 100644
--- a/src/main/java/com/hxzkoa/controller/FenceController.java
+++ b/src/main/java/com/hxzkoa/controller/FenceController.java
@@ -2,9 +2,14 @@
 
 import java.io.IOException;
 import java.io.OutputStream;
+import java.math.BigDecimal;
 import java.text.ParseException;
 import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
 import java.util.List;
+import java.util.Map;
+
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
@@ -18,13 +23,20 @@
 import com.hxzkoa.json.tb_anchor_nearby;
 import com.hxzkoa.json.tb_department;
 import com.hxzkoa.json.tb_fence;
+import com.hxzkoa.json.tb_fence2;
+import com.hxzkoa.json.tb_map;
 import com.hxzkoa.json.tb_shipin;
+import com.hxzkoa.json.tb_system;
+import com.hxzkoa.json.tb_tag;
 import com.hxzkoa.json.tb_tongbuanchor;
 import com.hxzkoa.json.tb_xunjianbaobiao;
 import com.hxzkoa.json.tb_xunjianset;
+import com.hxzkoa.services.AttendanceService;
 import com.hxzkoa.services.BasicInfoService;
 import com.hxzkoa.services.FenceService;
 import com.hxzkoa.services.LabelService;
+import com.hxzkoa.services.SysSettingService;
+import com.hxzkoa.services.ZhwService;
 import com.hxzkoa.udp.GetNowTime;
 import com.hxzkoa.udp.Udp_Out;
 /*import com.hxzkoa.udp.Udp_Receive;*/
@@ -41,9 +53,15 @@
 	@Autowired
 	private FenceService fenceService;
 	@Autowired
+	private ZhwService ZhwService;
+	@Autowired
 	private BasicInfoService basicInfoService;
 	@Autowired
 	private LabelService labelService;
+	@Autowired
+	private SysSettingService sysSettingService;
+	@Autowired
+	private AttendanceService attendanceService;
 
 	@RequestMapping(value = "/fenceList.do", method = { RequestMethod.POST, RequestMethod.GET })
 	public String fenceList(HttpServletRequest request) throws ParseException {
@@ -55,6 +73,128 @@
 		return toPage;
 	}
 	
+	@ResponseBody
+	@RequestMapping(value = "/fenceLista.do", method = { RequestMethod.POST, RequestMethod.GET })
+	public JSONObject fenceLista(HttpServletRequest request) throws ParseException {
+		JSONObject json = new JSONObject();
+		List<tb_fence2> fenceList = fenceService.getFenceListaaa();
+		if (fenceList.size() > 0) {
+			double xmaxz = Double.parseDouble(fenceList.get(0).getZuobiao()[0].split(",")[0]);
+			double ymaxz = Double.parseDouble(fenceList.get(0).getZuobiao()[0].split(",")[1]);
+			double xminz = Double.parseDouble(fenceList.get(0).getZuobiao()[0].split(",")[0]);
+			double yminz = Double.parseDouble(fenceList.get(0).getZuobiao()[0].split(",")[1]);
+			for(int i = 0; i < fenceList.size(); i++) {
+				Map<BigDecimal,BigDecimal> bigDecimals = new HashMap<>();
+				String[] aaa = fenceList.get(i).getZuobiao();
+				for(int j = 0; j < aaa.length; j++) {
+					String[] bbb = aaa[j].split(",");
+					bigDecimals.put(new BigDecimal(bbb[0]),new BigDecimal(bbb[1]));
+				}
+				String vvv = getPoint(bigDecimals);
+				fenceList.get(i).setCenterpoint(vvv);
+				String[] zuobiaos = fenceList.get(i).getZuobiao();
+				double xmax = Double.parseDouble(zuobiaos[0].split(",")[0]);
+				double ymax = Double.parseDouble(zuobiaos[0].split(",")[1]);
+				double xmin = Double.parseDouble(zuobiaos[0].split(",")[0]);
+				double ymin = Double.parseDouble(zuobiaos[0].split(",")[1]);
+				for (int j = 0;j < zuobiaos.length; j++) {
+					String[] zuobiao = zuobiaos[j].split(",");
+					if (Double.parseDouble(zuobiao[0]) > xmax) {
+						xmax = Double.parseDouble(zuobiao[0]);
+					}
+					if (Double.parseDouble(zuobiao[1]) > ymax) {
+						ymax = Double.parseDouble(zuobiao[1]);
+					}
+					if (Double.parseDouble(zuobiao[0]) < xmin) {
+						xmin = Double.parseDouble(zuobiao[0]);
+					}
+					if (Double.parseDouble(zuobiao[1]) < ymin) {
+						ymin = Double.parseDouble(zuobiao[1]);
+					}
+				}
+				if (xmax > xmaxz) {
+					xmaxz = xmax;
+				}
+				if (ymax > ymaxz) {
+					ymaxz = ymax;
+				}
+				if (xmin < xminz) {
+					xminz = xmin;
+				}
+				if (ymin < yminz) {
+					yminz = ymin;
+				}
+			}
+			for (int i = 0; i < fenceList.size(); i++) {
+				fenceList.get(i).setMax(xmaxz+","+ymaxz);
+				fenceList.get(i).setMin(xminz+","+yminz);
+			}
+		}
+		json.put("dataList", fenceList);
+		return json;
+	}
+	
+	@ResponseBody
+	@RequestMapping(value = "/findidfence.do", method = { RequestMethod.POST, RequestMethod.GET })
+	public JSONObject findidfence(HttpServletRequest request) throws ParseException {
+		JSONObject json = new JSONObject();
+		List<tb_fence2> fenceList = fenceService.getFenceListm();
+		if (fenceList.size() > 0) {
+			double xmaxz = Double.parseDouble(fenceList.get(0).getZuobiao()[0].split(",")[0]);
+			double ymaxz = Double.parseDouble(fenceList.get(0).getZuobiao()[0].split(",")[1]);
+			double xminz = Double.parseDouble(fenceList.get(0).getZuobiao()[0].split(",")[0]);
+			double yminz = Double.parseDouble(fenceList.get(0).getZuobiao()[0].split(",")[1]);
+			for(int i = 0; i < fenceList.size(); i++) {
+				Map<BigDecimal,BigDecimal> bigDecimals = new HashMap<>();
+				String[] aaa = fenceList.get(i).getZuobiao();
+				for(int j = 0; j < aaa.length; j++) {
+					String[] bbb = aaa[j].split(",");
+					bigDecimals.put(new BigDecimal(bbb[0]),new BigDecimal(bbb[1]));
+				}
+				String vvv = getPoint(bigDecimals);
+				fenceList.get(i).setCenterpoint(vvv);
+				String[] zuobiaos = fenceList.get(i).getZuobiao();
+				double xmax = Double.parseDouble(zuobiaos[0].split(",")[0]);
+				double ymax = Double.parseDouble(zuobiaos[0].split(",")[1]);
+				double xmin = Double.parseDouble(zuobiaos[0].split(",")[0]);
+				double ymin = Double.parseDouble(zuobiaos[0].split(",")[1]);
+				for (int j = 0;j < zuobiaos.length; j++) {
+					String[] zuobiao = zuobiaos[j].split(",");
+					if (Double.parseDouble(zuobiao[0]) > xmax) {
+						xmax = Double.parseDouble(zuobiao[0]);
+					}
+					if (Double.parseDouble(zuobiao[1]) > ymax) {
+						ymax = Double.parseDouble(zuobiao[1]);
+					}
+					if (Double.parseDouble(zuobiao[0]) < xmin) {
+						xmin = Double.parseDouble(zuobiao[0]);
+					}
+					if (Double.parseDouble(zuobiao[1]) < ymin) {
+						ymin = Double.parseDouble(zuobiao[1]);
+					}
+				}
+				if (xmax > xmaxz) {
+					xmaxz = xmax;
+				}
+				if (ymax > ymaxz) {
+					ymaxz = ymax;
+				}
+				if (xmin < xminz) {
+					xminz = xmin;
+				}
+				if (ymin < yminz) {
+					yminz = ymin;
+				}
+			}
+			for (int i = 0; i < fenceList.size(); i++) {
+				fenceList.get(i).setMax(xmaxz+","+ymaxz);
+				fenceList.get(i).setMin(xminz+","+yminz);
+			}
+		}
+		json.put("dataList", fenceList);
+		return json;
+	}
+	
 	@RequestMapping(value = "/jiankongManagement.do", method = { RequestMethod.POST, RequestMethod.GET })
 	public String jiankongManagement(HttpServletRequest request) {
 		String toPage = "forward:/hxzk/fence/jiankongManagement.jsp";
@@ -74,14 +214,18 @@
 	public void shipinManagement_add(HttpServletRequest request) throws IOException {
 			tb_shipin shipin = new tb_shipin();
 			shipin.setFencename(request.getParameter("fencename"));
-			shipin.setShebeiid(request.getParameter("shebeiid"));
-			shipin.setTongdaoid(request.getParameter("tongdaoid"));
+			shipin.setYonghuming(request.getParameter("yonghuming"));
+			shipin.setMima(request.getParameter("mima"));
 			shipin.setPosx(request.getParameter("posx"));
 			shipin.setPosy(request.getParameter("posy"));
 			shipin.setPosz(request.getParameter("posz"));
 			shipin.setFloor(request.getParameter("floor"));
 			shipin.setName(request.getParameter("name"));
+			shipin.setBaoliu1(request.getParameter("baoliu1"));
 			fenceService.shipinManagement_add(shipin);
+			List<tb_shipin> shipins = fenceService.searchshipinManagement(shipin.getName());
+			String xieyi = "BSTOCS1,ADDSP,"+shipin.getFencename()+","+shipin.getYonghuming()+","+shipin.getMima()+","+shipin.getPosx()+","+shipin.getPosy()+","+shipin.getPosz()+","+shipin.getFloor()+","+shipin.getName()+",END";
+			Udp_Out.udp_to_cs(xieyi);
 	}
 	
 	@RequestMapping(value = "/shipinManagement_modify.do", method = { RequestMethod.POST, RequestMethod.GET })
@@ -92,14 +236,17 @@
 		String[] id = idstr.split(",");
 		shipin.setId(Integer.parseInt(id[0]));
 		shipin.setFencename(request.getParameter("fencename"));
-		shipin.setShebeiid(request.getParameter("shebeiid"));
-		shipin.setTongdaoid(request.getParameter("tongdaoid"));
+		shipin.setYonghuming(request.getParameter("yonghuming"));
+		shipin.setMima(request.getParameter("mima"));
 		shipin.setPosx(request.getParameter("posx"));
 		shipin.setPosy(request.getParameter("posy"));
 		shipin.setPosz(request.getParameter("posz"));
 		shipin.setFloor(request.getParameter("floor"));
 		shipin.setName(request.getParameter("name"));
+		shipin.setBaoliu1(request.getParameter("baoliu1"));
 		fenceService.shipinManagement_modify(shipin);
+		String xieyi = "BSTOCS1,ALTERSP,"+shipin.getFencename()+","+shipin.getYonghuming()+","+shipin.getMima()+","+shipin.getPosx()+","+shipin.getPosy()+","+shipin.getPosz()+","+shipin.getFloor()+","+shipin.getName()+",END";
+		Udp_Out.udp_to_cs(xieyi);
 	}
 	
 	@ResponseBody
@@ -108,6 +255,12 @@
 		String checkValStr = request.getParameter("checkVal");
 		checkValStr = checkValStr.replaceAll("\"", "");
 		String[] checkVal = checkValStr.split(",");
+		for (int i = 0;i < checkVal.length;i++) {
+			//System.out.print("鎵ц浜�"+checkVal[i]);
+			List shebeiid = fenceService.idfindshebeiid(checkVal[i]);
+			String xieyi = "BSTOCS1,DELETESP,"+shebeiid.get(0)+",END";
+			Udp_Out.udp_to_cs(xieyi);
+		}
 		fenceService.shipinManagement_delete(checkVal);
 	}
 	
@@ -115,6 +268,8 @@
 	@RequestMapping(value = "/shipinManagement_deleteAll.do", method = { RequestMethod.POST, RequestMethod.GET })
 	public void shipinManagement_deleteAll(HttpServletRequest request) {
 		fenceService.shipinManagement_deleteAll();
+		String xieyi = "BSTOCS1,DELETEALLSP,END";
+		Udp_Out.udp_to_cs(xieyi);
 	}
 	
 	@ResponseBody
@@ -122,7 +277,7 @@
 	public String shipinManagement_search(HttpServletRequest request) throws IOException {
 		JSONObject json = new JSONObject();
 		String input = request.getParameter("input");
-		System.out.print(input);
+		//System.out.print(input);
 		int curPage = 1;
 		List<Integer> pageList = new ArrayList<Integer>();
 		List<tb_shipin> shipinManagementList = fenceService.searchshipinManagement(input);
@@ -130,7 +285,7 @@
 		json.put("dataList", shipinManagementList);
 		json.put("pageList", pageList);
 		json.put("curPage", curPage);
-		System.out.print(json.toString());
+		//System.out.print(json.toString());
 		return json.toString();
 	}
 	
@@ -139,7 +294,7 @@
 	public String shipinManagement_ssearch(HttpServletRequest request) throws IOException {
 		JSONObject json = new JSONObject();
 		String input = request.getParameter("input");
-		System.out.print(input);
+		//System.out.print(input);
 		int curPage = 1;
 		List<Integer> pageList = new ArrayList<Integer>();
 		List<tb_shipin> shipinManagementList = fenceService.searchshipinManagement(input);
@@ -147,7 +302,7 @@
 		json.put("dataList", shipinManagementList);
 		json.put("pageList", pageList);
 		json.put("curPage", curPage);
-		System.out.print(json.toString());
+		//System.out.print(json.toString());
 		return json.toString();
 	}
 	
@@ -185,14 +340,56 @@
 		tb_fence fence = new tb_fence();
 		fence.setBumen(request.getParameter("bumen"));
 		fence.setName(request.getParameter("name"));
+		String zuobiao = request.getParameter("zuobiao");
+		fence.setStart(request.getParameter("start"));
+		fence.setStop(request.getParameter("stop"));
+		fence.setBaoliu1(request.getParameter("gaodu"));
+		fence.setId(Integer.parseInt(request.getParameter("id")));
+		List<tb_fence> fenceaa = fenceService.searchFenceLisa(String.valueOf(fence.getId()));
+		String baowen = "";
+		if (fenceaa.get(0).getShape().equals("澶氳竟褰�")) {
+			String[] zuobiaos = zuobiao.split(",");
+			String str = "";
+			for (int i=0; i<zuobiaos.length; i++) {
+				if (i == zuobiaos.length-1) {
+					str += zuobiaos[i];
+					break;
+				}
+				if (i%2 == 0) {
+					str += zuobiaos[i]+":";
+				} else {
+					str += zuobiaos[i]+";";
+				}
+			}
+			baowen = str;
+		} else {
+			baowen = zuobiao.replace(",", ":");
+		}
+		fence.setZuobiao(zuobiao);
+		fenceService.fenceList_modifya(fence);
+		List<tb_fence> fenceListList = fenceService.searchFenceListid(fence.getId());
+		String xieyi = "BSTOCS1,ALTERFENCE,"+fenceListList.get(0).getFloor()+","+fenceListList.get(0).getType()+","+fence.getBumen()+","+fence.getName()+","+baowen+","+fenceListList.get(0).getShape()+","+fence.getStart()+","+fence.getStop()+","+fenceListList.get(0).getAddtime()+","+fenceListList.get(0).getColor()+",END";
+		Udp_Out.udp_to_cs(xieyi);
+	}
+	
+	@ResponseBody
+	@RequestMapping(value = "/fenceList_modifya.do", method = { RequestMethod.POST, RequestMethod.GET })
+	public String fenceList_modifya(HttpServletRequest request) throws ParseException {
+		tb_fence fence = new tb_fence();
+		fence.setBumen(request.getParameter("bumen"));
+		fence.setName(request.getParameter("name"));
 		fence.setZuobiao(request.getParameter("zuobiao"));
 		fence.setStart(request.getParameter("start"));
-		fence.setStart(request.getParameter("stop"));
+		fence.setStop(request.getParameter("stop"));
+		fence.setBaoliu1(request.getParameter("gaodu"));
+		fence.setBaoliu3(request.getParameter("baoliu3"));
+		fence.setBaoliu4(request.getParameter("baoliu4"));
 		fence.setId(Integer.parseInt(request.getParameter("id")));
-		fenceService.fenceList_modify(fence);
+		int aaa = fenceService.fenceList_modify(fence);
 		List<tb_fence> fenceListList = fenceService.searchFenceListid(fence.getId());
 		String xieyi = "BSTOCS1,ALTERFENCE,"+fenceListList.get(0).getFloor()+","+fenceListList.get(0).getType()+","+fence.getBumen()+","+fence.getName()+","+fence.getZuobiao()+","+fenceListList.get(0).getShape()+","+fence.getStart()+","+fence.getStop()+","+fenceListList.get(0).getAddtime()+","+fenceListList.get(0).getColor()+",END";
 		Udp_Out.udp_to_cs(xieyi);
+		return ""+aaa;
 	}
 
 	@ResponseBody
@@ -201,7 +398,20 @@
 		String checkValStr = request.getParameter("checkVal");
 		checkValStr = checkValStr.replaceAll("\"", "");
 		String[] checkVal = checkValStr.split(",");
+		for (int i = 0; i < checkVal.length; i++) {
+			String fences = fenceService.searchFenceListid2(Integer.parseInt(checkVal[i]));
+			String xieyi = "BSTOCS1,DELETEFECNCE,"+fences+",END";
+			Udp_Out.udp_to_cs(xieyi);
+		}
 		fenceService.fenceList_delete(checkVal);
+	}
+	
+	@ResponseBody
+	@RequestMapping(value = "/fenceList_deletea.do", method = { RequestMethod.POST, RequestMethod.GET })
+	public String fenceList_deletea(HttpServletRequest request) throws NumberFormatException, ParseException {
+		String checkValStr = request.getParameter("checkVal");
+		checkValStr = checkValStr.replaceAll("\"", "");
+		String[] checkVal = checkValStr.split(",");
 		for (int i = 0; i < checkVal.length; i++) {
 			List<tb_fence> fences = fenceService.searchFenceListid(Integer.parseInt(checkVal[i]));
 			tb_fence fence = new tb_fence();
@@ -209,6 +419,8 @@
 			String xieyi = "BSTOCS1,DELETEFECNCE,"+fence.getName()+",END";
 			Udp_Out.udp_to_cs(xieyi);
 		}
+		int aaa = fenceService.fenceList_delete(checkVal);
+		return ""+aaa;
 	}
 
 	@ResponseBody
@@ -218,6 +430,15 @@
 		String xieyi = "BSTOCS1,DELETEALLFENCE,END";
 		Udp_Out.udp_to_cs(xieyi);
 	}
+	
+	@ResponseBody
+	@RequestMapping(value = "/fenceList_deleteAlla.do", method = { RequestMethod.POST, RequestMethod.GET })
+	public String fenceList_deleteAlla(HttpServletRequest request) {
+		int aaa = fenceService.fenceList_deleteAll();
+		String xieyi = "BSTOCS1,DELETEALLFENCE,END";
+		Udp_Out.udp_to_cs(xieyi);
+		return ""+aaa;
+	}
 
 	@ResponseBody
 	@RequestMapping(value = "/fenceList_search.do", method = { RequestMethod.POST, RequestMethod.GET })
@@ -228,6 +449,16 @@
 		json.put("dataList", fenceListList);
 		return json.toString();
 	}
+	
+	@ResponseBody
+	@RequestMapping(value = "/fenceList_searcha.do", method = { RequestMethod.POST, RequestMethod.GET })
+	public JSONObject fenceList_searcha(HttpServletRequest request) throws ParseException {
+		String input = request.getParameter("type");
+		List<tb_fence> fenceListList = fenceService.searchFenceList(input);
+		JSONObject json = new JSONObject();
+		json.put("dataList", fenceListList);
+		return json;
+	}
 
 	@RequestMapping(value = "/inspectionSettings.do", method = { RequestMethod.POST, RequestMethod.GET })
 	public String inspectionSettings(HttpServletRequest request) {
@@ -462,4 +693,80 @@
 		//
 		fenceService.xunjianbaobiao_add(xunjianbaobiao);
 	}
+	
+	@ResponseBody
+	@RequestMapping(value = "/baidufence.do", method = { RequestMethod.POST, RequestMethod.GET })
+	public String baidufence(HttpServletRequest request) {
+		JSONObject json = new JSONObject();
+		List<tb_fence> fences = fenceService.getFenceList();
+		List<String> fences2 = new ArrayList<>();
+		for (int i=0; i<fences.size(); i++) {
+			if (fences.get(i).getFloor().equals("鐧惧害鍦板浘") ) {
+				fences2.add(fences.get(i).getZuobiao());
+			}
+		}
+		json.put("fences", fences2);
+		return json.toString();
+	}
+	
+	@ResponseBody
+	@RequestMapping(value = "/kaishijianting.do", method = { RequestMethod.POST, RequestMethod.GET })
+	public void kaishijianting(HttpServletRequest request) {
+		String tagid = request.getParameter("tagid");
+		String xieyi = "BSTOCS1,URTADDFENCE,鍑哄幓鍛婅,Start,"+tagid+",END";
+		Udp_Out.udp_to_cs(xieyi);
+	}
+	
+	@ResponseBody
+	@RequestMapping(value = "/jieshujianting.do", method = { RequestMethod.POST, RequestMethod.GET })
+	public void jieshujianting(HttpServletRequest request) {
+		String tagid = request.getParameter("tagid");
+		String xieyi = "BSTOCS1,URTADDFENCE,鍑哄幓鍛婅,Stop,"+tagid+",END";
+		Udp_Out.udp_to_cs(xieyi);
+	}
+	
+	@ResponseBody
+	@RequestMapping(value = "/huoquzuobiao.do", method = { RequestMethod.POST, RequestMethod.GET })
+	public String huoquzuobiao(HttpServletRequest request) {
+		JSONObject json = new JSONObject();
+		List<tb_system> systems = sysSettingService.getSetting();
+		json.put("dataList", systems);
+		return json.toString();
+	}
+	
+	@ResponseBody
+	@RequestMapping(value = "/enablefence.do", method = { RequestMethod.POST, RequestMethod.GET })
+	public String enablefence(HttpServletRequest request) {
+		tb_fence fence = new tb_fence();
+		fence.setBaoliu7(request.getParameter("str"));
+		fence.setId(Integer.valueOf(request.getParameter("id")));
+		int aaa = fenceService.enablefence(fence);
+		return ""+aaa;
+	}
+	
+	private static String getPoint(Map<BigDecimal, BigDecimal> bigDecimals) {
+        int point_num = bigDecimals.size(); //鍧愭爣鐐逛釜鏁�
+        double X = 0;
+        double Y = 0;
+        double Z = 0;
+        for(Map.Entry entry : bigDecimals.entrySet()) {
+            double lat = Float.parseFloat(entry.getKey().toString()) * Math.PI / 180;
+            double lng = Float.parseFloat(entry.getValue().toString()) * Math.PI / 180;
+            double x = Math.cos(lat) * Math.cos(lng);
+            double y = Math.cos(lat) * Math.sin(lng);
+            double z = Math.sin(lat);
+            X += x;
+            Y += y;
+            Z += z;
+        }
+        X = X / point_num;
+        Y = Y / point_num;
+        Z = Z / point_num;
+
+        double tmp_lng = Math.atan2(Y, X);
+        double tmp_lat = Math.atan2(Z, Math.sqrt(X * X + Y * Y));
+
+        String vvv = Math.round(tmp_lat * 180 / Math.PI * 100.0)/100.0 + "," + Math.round(tmp_lng * 180 / Math.PI * 100.0)/100.0;
+        return vvv;
+    }
 }

--
Gitblit v1.10.0