From 37336922a1df99ac1636e398e12e64dedfba10e5 Mon Sep 17 00:00:00 2001
From: 15832144755 <67030627+15832144755@users.noreply.github.com>
Date: 星期四, 18 十一月 2021 16:15:16 +0800
Subject: [PATCH] 11.18完整39

---
 src/main/java/com/hxzkoa/services/ZhwService.java |  219 ++++++++++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 203 insertions(+), 16 deletions(-)

diff --git a/src/main/java/com/hxzkoa/services/ZhwService.java b/src/main/java/com/hxzkoa/services/ZhwService.java
index efb30d5..7420717 100644
--- a/src/main/java/com/hxzkoa/services/ZhwService.java
+++ b/src/main/java/com/hxzkoa/services/ZhwService.java
@@ -43,7 +43,9 @@
 import com.hxzkoa.json.tb_icon;
 import com.hxzkoa.json.tb_map;
 import com.hxzkoa.json.tb_person;
+import com.hxzkoa.json.tb_qihou;
 import com.hxzkoa.json.tb_realinwarning;
+import com.hxzkoa.json.tb_realkaoqing;
 import com.hxzkoa.json.tb_realocation;
 import com.hxzkoa.json.tb_realpositoin;
 import com.hxzkoa.json.tb_shipin;
@@ -55,6 +57,8 @@
 import com.hxzkoa.json.tb_warning;
 import com.hxzkoa.json.tb_xunjianbaobiao;
 import com.hxzkoa.json.tb_xunjianset;
+import com.hxzkoa.util.Config;
+import com.hxzkoa.util.ModifyConfig;
 
 @Service
 public class ZhwService {
@@ -233,7 +237,7 @@
 		cs.tb_caozuo("tb_fence", 1);
 		query = this.em.createNativeQuery(sql);
 		query.setParameter("id", fence.getId());
-		query.setParameter("floor", Integer.parseInt(fence.getFloor()));
+		query.setParameter("floor", fence.getFloor());
 		query.setParameter("type", fence.getType());
 		query.setParameter("bumen", fence.getBumen());
 		query.setParameter("name", fence.getName());
@@ -247,6 +251,28 @@
 	}
 	
 	@Transactional
+	public int sanweiFence_add(tb_fence fence) {
+		String sql = null;
+		Query query = null;
+		sql = "INSERT INTO tb_fence(id,floor,type,bumen,name,zuobiao,shape,start,stop,addtime,color,baoliu1) VALUES(:id,:floor,:type,:bumen,:name,:zuobiao,:shape,:start,:stop,now(),:color,:baoliu1)";
+		cs.tb_caozuo("tb_fence", 1);
+		query = this.em.createNativeQuery(sql);
+		query.setParameter("id", fence.getId());
+		query.setParameter("floor", fence.getFloor());
+		query.setParameter("type", fence.getType());
+		query.setParameter("bumen", fence.getBumen());
+		query.setParameter("name", fence.getName());
+		query.setParameter("zuobiao", fence.getZuobiao());
+		query.setParameter("shape", fence.getShape());
+		query.setParameter("start", fence.getStart());
+		query.setParameter("stop", fence.getStop());
+		query.setParameter("color", fence.getColor());
+		query.setParameter("baoliu1", fence.getBaoliu1());
+		int executeUpdate = query.executeUpdate();
+		return executeUpdate;
+	}
+	
+	@Transactional
 	public int xunjianSet_add(String name) {
 		String sql = null;
 		Query query = null;
@@ -302,19 +328,19 @@
 		Query query = null;
 		SimpleDateFormat dateFormat=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
 		Date now=dateFormat.parse(begin_time);
-		System.out.print(now);
+		//System.out.print(now);
 		SimpleDateFormat dateFormat2=new SimpleDateFormat("yyyyMMdd");
 		String now2 = dateFormat2.format(now);
-		System.out.print(now2);
-//		System.out.print(begin_time);
-//		System.out.print(end_time);
-//		System.out.print(tag_id);
-//		System.out.print(floor);
+		//System.out.print(now2);
+//		//System.out.print(begin_time);
+//		//System.out.print(end_time);
+//		//System.out.print(tag_id);
+//		//System.out.print(floor);
 		
 		sql = "SELECT tagid,x,y,z,layer,time FROM tb_track_"+now2+" WHERE layer= '"+floor+"' AND tagid= '"+tag_id+"' AND time>= '"+begin_time+"' AND time<= '"+end_time+"' ORDER BY time";
 //		sql = "SELECT tagid,x,y,z,layer,time FROM tb_track WHERE layer= '"+floor+"' AND tagid= '"+tag_id+"' AND time>= '"+begin_time+"' AND time<= '"+end_time+"'";
 		
-		System.out.print(sql);
+		//System.out.print(sql);
 		query = this.em.createNativeQuery(sql);
 		List resultList = query.getResultList();
 		List<tb_track> tb_trackList = new ArrayList<tb_track>();
@@ -471,7 +497,40 @@
 	public List<tb_person> getpersonLocation(String floor) {
 		String sql = null;
 		Query query = null;
-		sql = "SELECT a.* FROM tb_person AS a,( SELECT p_tagid, max( p_addtiem ) time FROM tb_person GROUP BY p_tagid ) AS b WHERE a.p_addtiem = b.time AND a.p_tagid = b.p_tagid AND a.p_floor='"+floor+"'";
+		sql = "SELECT * FROM tb_person WHERE p_floor='"+floor+"'";
+		query = this.em.createNativeQuery(sql);
+		List resultList = query.getResultList();
+		List<tb_person> tb_realocationList = new ArrayList<tb_person>();
+		if (resultList.size() > 0) {
+			for (int i = 0; i < resultList.size(); i++) {
+				tb_person realocation = new tb_person();
+				Object[] obj = (Object[]) resultList.get(i);
+				realocation.setP_name((String) obj[1]);
+				realocation.setP_tagid((String) obj[2]);
+				realocation.setP_x((String) obj[12]);
+				realocation.setP_y((String) obj[13]);
+				realocation.setP_floor((String) obj[14]);
+				realocation.setP_sos((String) obj[15]);
+				realocation.setP_online((String) obj[16]);
+				realocation.setP_power((String) obj[17]);
+				realocation.setP_kaoqing((String) obj[18]);
+				realocation.setP_fence((String) obj[19]);
+				realocation.setP_fencename((String) obj[20]);
+				realocation.setP_kaoqqingname((String) obj[21]);
+				realocation.setP_image((String) obj[22]);
+				realocation.setP_addtiem((String) obj[23]);
+				realocation.setP_sousuo((String) obj[25]);
+				realocation.setP_shipin((String) obj[26]);
+				tb_realocationList.add(realocation);
+			}
+		}
+		return tb_realocationList;
+	}
+	
+	public List<tb_person> getpersonLocationsan() {
+		String sql = null;
+		Query query = null;
+		sql = "SELECT * FROM tb_person";
 		query = this.em.createNativeQuery(sql);
 		List resultList = query.getResultList();
 		List<tb_person> tb_realocationList = new ArrayList<tb_person>();
@@ -504,7 +563,7 @@
 	public List<tb_person> getpersonLocation_all() {
 		String sql = null;
 		Query query = null;
-		sql = "SELECT a.* FROM tb_person AS a,( SELECT p_tagid, max( p_addtiem ) time FROM tb_person GROUP BY p_tagid ) AS b WHERE a.p_addtiem = b.time AND a.p_tagid = b.p_tagid";
+		sql = "SELECT * FROM tb_person";
 		query = this.em.createNativeQuery(sql);
 		List resultList = query.getResultList();
 		List<tb_person> tb_realocationList = new ArrayList<tb_person>();
@@ -649,7 +708,7 @@
 				gps.setGps_NS((String) obj[3]);
 				gps.setGsp_jingdu((String) obj[4]);
 				gps.setGps_EW((String) obj[5]);
-				gps.setGps_state((String) obj[23]);
+				gps.setGps_state((String) obj[25]);
 				gps.setGps_num((String) obj[7]);
 				gps.setGps_hdop((String) obj[8]);
 				gps.setGps_haiba_gao((String) obj[9]);
@@ -662,7 +721,7 @@
 				gps.setGps_power((String) obj[16]);
 				gps.setGps_sos((String) obj[17]);
 				gps.setAddtime((String) obj[18]);
-				gps.setName((String) obj[22]);
+				gps.setName((String) obj[24]);
 				tb_gpsList.add(gps);
 			}
 		}
@@ -677,7 +736,7 @@
 		SimpleDateFormat dateFormat2=new SimpleDateFormat("yyyyMMdd");
 		String now2 = dateFormat2.format(now);
 		sql = "SELECT a.*,b.p_name FROM tb_gps_track_"+now2+" AS a, tb_person AS b WHERE a.tagid= '"+tag_id+"' AND a.addtime>= '"+begin_time+"' AND a.addtime<= '"+end_time+"' AND a.tagid=b.p_tagid ORDER BY addtime";
-		System.out.print(sql);
+		//System.out.print(sql);
 		query = this.em.createNativeQuery(sql);
 		List resultList = query.getResultList();
 		List<tb_gps> tb_trackList = new ArrayList<tb_gps>();
@@ -887,16 +946,16 @@
 		Query query = null;
 		sql = "SELECT p_fencename from tb_person WHERE p_tagid="+tagid;
 		query = this.em.createNativeQuery(sql);
-//		System.out.print(sql);
+//		//System.out.print(sql);
 		List resultList = query.getResultList();
-//		System.out.print(resultList.size());
+//		//System.out.print(resultList.size());
 		List<tb_person> tb_person = new ArrayList<tb_person>();
 		if (resultList.size() > 0) {
 			for (int i = 0; i < resultList.size(); i++) {
 				tb_person person = new tb_person();
 //				Object[] obj = (Object[]) resultList.get(i);
 				person.setP_fencename(resultList.get(i) == null ? "" : resultList.get(i).toString());
-//				System.out.print(person.getP_fencename());
+//				//System.out.print(person.getP_fencename());
 				tb_person.add(person);
 			}
 		}
@@ -922,5 +981,133 @@
 		}
 		return tb_shipinList;
 	}
+	
+	public List<tb_qihou> qihoucha() {
+		String sql = null;
+		Query query = null;
+		sql = "SELECT id,time,place,weather,wd,sd FROM tb_qihou";
+		query = this.em.createNativeQuery(sql);
+		List resultList = query.getResultList();
+		List<tb_qihou> tb_qihouList = new ArrayList<tb_qihou>();
+		if (resultList.size() > 0) {
+			for (int i = 0; i < resultList.size(); i++) {
+				tb_qihou qihou = new tb_qihou();
+				Object[] obj = (Object[]) resultList.get(i);
+				qihou.setId((int) obj[0]);
+				qihou.setTime(obj[1] == null ? "" : obj[1].toString());
+				qihou.setPlace(obj[2] == null ? "" : obj[2].toString());
+				qihou.setWeather(obj[3] == null ? "" : obj[3].toString());
+				qihou.setWd(obj[4] == null ? "" : obj[4].toString());
+				qihou.setSd(obj[5] == null ? "" : obj[5].toString());
+				tb_qihouList.add(qihou);
+			}
+		}
+		return tb_qihouList;
+	}
+	
+	public List<tb_qihou> qihoucha(int page) {
+		String sql = null;
+		Query query = null;
+		sql = "SELECT id,time,place,weather,wd,sd FROM (SELECT id,time,place,weather,wd,sd FROM tb_qihou ORDER BY time DESC) s LIMIT :start,:end";
+		query = this.em.createNativeQuery(sql);
+		query.setParameter("start", (page - 1) * Integer.parseInt(ModifyConfig.readData(Config.getPageConfig(), "perPage")));
+		query.setParameter("end", Integer.parseInt(ModifyConfig.readData(Config.getPageConfig(), "perPage")));
+		List resultList = query.getResultList();
+		List<tb_qihou> tb_qihouList = new ArrayList<tb_qihou>();
+		if (resultList.size() > 0) {
+			for (int i = 0; i < resultList.size(); i++) {
+				tb_qihou qihou = new tb_qihou();
+				Object[] obj = (Object[]) resultList.get(i);
+				qihou.setId((int) obj[0]);
+				qihou.setTime(obj[1] == null ? "" : obj[1].toString());
+				qihou.setPlace(obj[2] == null ? "" : obj[2].toString());
+				qihou.setWeather(obj[3] == null ? "" : obj[3].toString());
+				qihou.setWd(obj[4] == null ? "" : obj[4].toString());
+				qihou.setSd(obj[5] == null ? "" : obj[5].toString());
+				tb_qihouList.add(qihou);
+			}
+		}
+		return tb_qihouList;
+	}
+	
+	@Transactional
+	public int qihouzeng(tb_qihou qihou) {
+		String sql = null;
+		Query query = null;
+		sql = "INSERT INTO tb_qihou(time,place,weather,wd,sd) VALUES(now(),:place,:weather,:wd,:sd)";
+		query = this.em.createNativeQuery(sql);
+		query.setParameter("place", qihou.getPlace());
+		query.setParameter("weather", qihou.getWeather());
+		query.setParameter("wd", qihou.getWd());
+		query.setParameter("sd", qihou.getSd());
+		int executeUpdate = query.executeUpdate();
+		return executeUpdate;
+	}
+	
+	@Transactional
+	public void qihoudelete(String[] checkVal) {
+		String sql = null;
+		Query query = null;
+		for (int i = 0; i < checkVal.length; i++) {
+			sql = "DELETE FROM tb_qihou WHERE id = :id";
+			query = this.em.createNativeQuery(sql);
+			query.setParameter("id", checkVal[i]);
+			query.executeUpdate();
+		}
+	}
+
+	@Transactional
+	public void qihoudeleteAll() {
+		String sql = null;
+		Query query = null;
+		sql = "DELETE FROM tb_qihou";
+		query = this.em.createNativeQuery(sql);
+		query.executeUpdate();
+	}
+
+	@Transactional
+	public void qihougai(tb_qihou qihou) {
+		String sql = null;
+		Query query = null;
+		sql = "UPDATE tb_qihou SET place=:place,weather=:weather,wd=:wd,sd=:sd WHERE id=:id";
+		query = this.em.createNativeQuery(sql);
+		query.setParameter("id", qihou.getId());
+		query.setParameter("place", qihou.getPlace());
+		query.setParameter("weather", qihou.getWeather());
+		query.setParameter("wd", qihou.getWd());
+		query.setParameter("sd", qihou.getSd());
+		query.executeUpdate();
+	}
+	
+	public int getqihouManagementCount() {
+		String sql = null;
+		Query query = null;
+		sql = "SELECT count(1) FROM tb_qihou";
+		query = this.em.createNativeQuery(sql);
+		return Integer.parseInt(query.getSingleResult().toString());
+	}
+	
+	public List<tb_realkaoqing> getkaoqinsan() {
+		String sql = null;
+		Query query = null;
+		sql = "SELECT * FROM tb_realkaoqing";
+		query = this.em.createNativeQuery(sql);
+		List resultList = query.getResultList();
+		List<tb_realkaoqing> tb_realkaoqinList = new ArrayList<tb_realkaoqing>();
+		if (resultList.size() > 0) {
+			for (int i = 0; i < resultList.size(); i++) {
+				tb_realkaoqing realocation = new tb_realkaoqing();
+				Object[] obj = (Object[]) resultList.get(i);
+				realocation.setArea((String) obj[1]);
+				realocation.setName((String) obj[2]);
+				realocation.setBumen((String) obj[3]);
+				realocation.setTagid((String) obj[4]);
+				realocation.setIntime((String) obj[5]);
+				realocation.setJuli((String) obj[7]);
+				tb_realkaoqinList.add(realocation);
+			}
+		}
+		return tb_realkaoqinList;
+	}
 		
 }

--
Gitblit v1.10.0