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/ShowController.java |  142 ++++++++++++++++++++++++++++++++++++++++------
 1 files changed, 122 insertions(+), 20 deletions(-)

diff --git a/src/main/java/com/hxzkoa/controller/ShowController.java b/src/main/java/com/hxzkoa/controller/ShowController.java
index 28850dd..f8716c7 100644
--- a/src/main/java/com/hxzkoa/controller/ShowController.java
+++ b/src/main/java/com/hxzkoa/controller/ShowController.java
@@ -3,12 +3,16 @@
 import java.io.File;
 import java.io.FileWriter;
 import java.io.IOException;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 
+import javax.servlet.ServletContext;
 import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpSession;
 
 import org.hibernate.dialect.function.VarArgsSQLFunction;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -18,16 +22,23 @@
 import org.springframework.web.bind.annotation.ResponseBody;
 
 import com.hxzkoa.json.tb_achor;
+import com.hxzkoa.json.tb_department;
+import com.hxzkoa.json.tb_login;
+import com.hxzkoa.json.tb_person;
 import com.hxzkoa.json.tb_shebei;
 import com.hxzkoa.json.tb_shishi;
 import com.hxzkoa.json.tb_system;
 import com.hxzkoa.json.tb_tag;
+import com.hxzkoa.json.tb_user;
 import com.hxzkoa.json.vo_kaoqin_p;
 import com.hxzkoa.services.AnchorService;
 import com.hxzkoa.services.AttendanceService;
+import com.hxzkoa.services.BasicInfoService;
 import com.hxzkoa.services.LabelService;
+import com.hxzkoa.services.LoginService;
 import com.hxzkoa.services.SysSettingService;
 import com.hxzkoa.services.WarningService;
+import com.hxzkoa.services.ZhwService;
 /*import com.hxzkoa.udp.Udp_Receive;*/
 import com.hxzkoa.util.Config;
 import com.hxzkoa.util.HttpUtil;
@@ -47,6 +58,12 @@
 	private WarningService warningService;
 	@Autowired
 	private SysSettingService sysSettingService;
+	@Autowired
+	private LoginService loginService;
+	@Autowired
+	private ZhwService zhwService;
+	@Autowired
+	private BasicInfoService basicInfoService;
 	
 	/* Udp_Receive receive; */
 	
@@ -71,6 +88,22 @@
 
 	@RequestMapping(value = "/show.do", method = { RequestMethod.POST, RequestMethod.GET })
 	public String show(HttpServletRequest request) {
+//		tb_user user = loginService.login("瓒呯骇绠$悊鍛�");
+		HttpSession session = request.getSession();
+//		ServletContext application = session.getServletContext();
+//		application.setAttribute("username", user.getUsername());
+//		application.setAttribute("password", user.getPassword());
+//		application.setAttribute("superuser", user.getSuperuser());
+//		application.setAttribute("deleteq", user.getDeleteq());
+//		application.setAttribute("alertq", user.getAlertq());
+//		application.setAttribute("deleteall", user.getDeleteall());
+//		session.setAttribute("username", user.getUsername());
+//		session.setAttribute("password", user.getPassword());
+//		session.setAttribute("superuser", user.getSuperuser());
+//		session.setAttribute("deleteq", user.getDeleteq());
+//		session.setAttribute("alertq", user.getAlertq());
+//		session.setAttribute("deleteall", user.getDeleteall());
+//		session.setAttribute("fenceq", user.getFenceq());
 //		tb_system system = new tb_system();
 //		system.setUdpPort("8234");
 //		JSONObject jsonObject = JSONObject.fromObject(system);
@@ -95,6 +128,48 @@
 //		}
 		String toPage = "forward:/hxzk/index.jsp";
 		//String toPage = "forward:/hxzk/mapshow/mapShow.jsp";
+		String ip = request.getHeader("x-forwarded-for");
+        if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
+            ip = request.getHeader("X-Real-IP");
+        }
+        if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
+            ip = request.getHeader("X-Forwarded-For");
+        }
+        if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
+            ip = request.getHeader("Proxy-Client-IP");
+        }
+        if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
+            ip = request.getHeader("WL-Proxy-Client-IP");
+        }
+        if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
+            ip = request.getHeader("HTTP_CLIENT_IP");
+        }
+        if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
+            ip = request.getHeader("HTTP_X_FORWARDED_FOR");
+        }
+        if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
+            ip = request.getRemoteAddr();
+            if (ip.equals("127.0.0.1") || ip.equals("0:0:0:0:0:0:0:1")) {
+                //鏍规嵁缃戝崱鍙栨湰鏈洪厤缃殑IP
+                InetAddress inet = null;
+                try {
+                    inet = InetAddress.getLocalHost();
+                } catch (UnknownHostException e) {
+                    e.printStackTrace();
+                }
+                ip = inet.getHostAddress();
+            }
+        }
+        if (ip != null && ip.length() > 15) {
+            if (ip.indexOf(",") > 0) {
+                ip = ip.substring(0, ip.indexOf(","));
+            }
+        }
+        String username=(String)session.getAttribute("username");
+        tb_login login = new tb_login();
+        login.setIp(ip);
+        login.setUsername(username);
+        loginService.login_add(login);
 		// 鍩虹珯淇℃伅
 		List<tb_achor> anchorManagementList = anchorService.getAnchorManagementsi();
 //		List<tb_shebei> shebei = anchorService.getShebei();
@@ -161,25 +236,27 @@
 			reWarningSummary_v.add((int) warningSummaryTypeMap.get(key));
 		}
 		// 鐜板満宸ョ
-		Map realAttendanceTypeMap = attendanceService.getRealAttendanceType();
+		List<tb_department> dapartments = basicInfoService.getDepartmentManagement();
 		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));
+		for(int i=0;i<dapartments.size();i++) {
+			 int num = labelService.getdepartmentCount2(dapartments.get(i).getDepartmentName());
+			 realAttendance_k.add(dapartments.get(i).getDepartmentName());
+			 realAttendance_v.add(num);
 		}
 		// 缁熻鏁版嵁
-		Map realtongjiTypeMap = attendanceService.getRealtongjiType();
-		List<String> realtongji_k = new ArrayList<String>();
-		List<Integer> realtongji_v = new ArrayList<Integer>();
-		Iterator<String> realtongjiTypeIter = realtongjiTypeMap.keySet().iterator();
-		while (realtongjiTypeIter.hasNext()) {
-			String key = realtongjiTypeIter.next();
-			realtongji_k.add(key);
-			realtongji_v.add((int) realtongjiTypeMap.get(key));
-		}
+		List<Object> shishilist = attendanceService.gettongjishuju();
+		List<String> realtongji_k = (List<String>)shishilist.get(0);
+		List<String> realtongji_v = (List<String>)shishilist.get(1);
+//		Map realtongjiTypeMap = attendanceService.getRealtongjiType();
+//		List<String> realtongji_k = new ArrayList<String>();
+//		List<Integer> realtongji_v = new ArrayList<Integer>();
+//		Iterator<String> realtongjiTypeIter = realtongjiTypeMap.keySet().iterator();
+//		while (realtongjiTypeIter.hasNext()) {
+//			String key = realtongjiTypeIter.next();
+//			realtongji_k.add(key);
+//			realtongji_v.add((int) realtongjiTypeMap.get(key));
+//		}
 		// 绯荤粺璁剧疆
 		List<tb_system> systemlist = sysSettingService.getSetting();
 		// 瀹炴椂鏁版嵁
@@ -193,6 +270,8 @@
 //			realshishi_v.add((int) realshishiTypeMap.get(key));
 //		}
 //		request.setAttribute("shebei", shebei);
+		List<tb_person> persons = zhwService.getbumen();
+		request.setAttribute("persons", persons);
 		request.setAttribute("anchorManagementList", anchorManagementList);
 		request.setAttribute("labelManagementList", reLabelManagementList);
 //		request.setAttribute("realAttendanceList", reRealAttendanceList);
@@ -263,7 +342,7 @@
 	public List<tb_shebei> setshebei(HttpServletRequest request) {
 		// 璁惧鏁版嵁
 		List<tb_shebei> achorlist = anchorService.getjizhanshebei();
-		List<tb_shebei> taglist = anchorService.getbiaoqianshebei();
+		List<tb_shebei> taglist = anchorService.getbiaoqianshebei2();
 		for(int i = 0;i <taglist.size();i++) {
 			achorlist.add(taglist.get(i));
 		}
@@ -280,15 +359,38 @@
 	@RequestMapping(value = "/setgongzhongnum.do", method = { RequestMethod.POST, RequestMethod.GET })
 	@ResponseBody
 	public List<Object> setgongzhongnum(){
-		List<Object> gongzhongnum = attendanceService.getgongzhongnum();
+		List<Object> gongzhongnum = new ArrayList<>();
+		List<tb_department> dapartments = basicInfoService.getDepartmentManagement();
+		List<String> gongzhongk = new ArrayList<String>();
+		List<Integer> gongzhong = new ArrayList<Integer>();
+		for(int i=0;i<dapartments.size();i++) {
+			 int num = labelService.getdepartmentCount2(dapartments.get(i).getDepartmentName());
+			 gongzhongk.add(dapartments.get(i).getDepartmentName());
+			 gongzhong.add(num);
+		}
+		gongzhongnum.add(gongzhongk);
+		gongzhongnum.add(gongzhong);
 		return gongzhongnum;
 	}
 	
 	@RequestMapping(value = "/setgaojingnum.do", method = { RequestMethod.POST, RequestMethod.GET })
 	@ResponseBody
-	public List<Integer> setgaojingnum(){
-		List<Integer> gaojingnum = attendanceService.getgaojingnum();
-		return gaojingnum;
+	public JSONObject setgaojingnum(){
+//		List<Integer> gaojingnum = attendanceService.getgaojingnum();
+//		return gaojingnum;
+		JSONObject jsons = new JSONObject();
+		Map warningSummaryTypeMap = warningService.getWarningSummaryType();
+		List<String> reWarningSummary_k = new ArrayList<String>();
+		List<Integer> reWarningSummary_v = new ArrayList<Integer>();
+		Iterator<String> warningSummaryTypeIter = warningSummaryTypeMap.keySet().iterator();
+		while (warningSummaryTypeIter.hasNext()) {
+			String key = warningSummaryTypeIter.next();
+			reWarningSummary_k.add(key);
+			reWarningSummary_v.add((int) warningSummaryTypeMap.get(key));
+		}
+		jsons.put("key", reWarningSummary_k);
+		jsons.put("value", reWarningSummary_v);
+		return jsons;
 	}
 	
 }

--
Gitblit v1.10.0