| | |
| | | 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; |
| | | import com.hxzkoa.json.tb_system; |
| | | import com.hxzkoa.json.tb_tag; |
| | | import com.hxzkoa.json.tb_tagpower; |
| | |
| | | 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 { |
| | |
| | | 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()); |
| | |
| | | } |
| | | |
| | | @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; |
| | |
| | | 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>(); |
| | |
| | | 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>(); |
| | |
| | | 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>(); |
| | | 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); |
| | | } |
| | | } |
| | |
| | | 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>(); |
| | |
| | | public List<tb_gps> getGPS() { |
| | | String sql = null; |
| | | Query query = null; |
| | | sql = "SELECT a.*,c.p_name FROM tb_gps AS a,( SELECT tagid, max(addtime) time FROM tb_gps GROUP BY tagid ) AS b, tb_person as c WHERE a.addtime = b.time AND a.tagid = b.tagid AND c.p_tagid=a.tagid"; |
| | | sql = "SELECT a.*,c.p_name,c.p_online FROM tb_gps AS a,( SELECT tagid, max(addtime) time FROM tb_gps GROUP BY tagid ) AS b, tb_person as c WHERE a.addtime = b.time AND a.tagid = b.tagid AND c.p_tagid=a.tagid"; |
| | | query = this.em.createNativeQuery(sql); |
| | | List resultList = query.getResultList(); |
| | | List<tb_gps> tb_gpsList = new ArrayList<tb_gps>(); |
| | |
| | | gps.setGps_NS((String) obj[3]); |
| | | gps.setGsp_jingdu((String) obj[4]); |
| | | gps.setGps_EW((String) obj[5]); |
| | | gps.setGps_state((String) obj[6]); |
| | | 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]); |
| | |
| | | gps.setGps_power((String) obj[16]); |
| | | gps.setGps_sos((String) obj[17]); |
| | | gps.setAddtime((String) obj[18]); |
| | | gps.setName((String) obj[19]); |
| | | gps.setName((String) obj[24]); |
| | | tb_gpsList.add(gps); |
| | | } |
| | | } |
| | |
| | | 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>(); |
| | |
| | | String sql = null; |
| | | Query query = null; |
| | | sql = "UPDATE tb_person SET p_fence=0 WHERE p_tagid=:tagid"; |
| | | cs.tb_caozuo("tb_gps", 3); |
| | | cs.tb_caozuo("tb_person", 3); |
| | | query = this.em.createNativeQuery(sql); |
| | | query.setParameter("tagid", tagid); |
| | | int executeUpdate = query.executeUpdate(); |
| | |
| | | String sql = null; |
| | | Query query = null; |
| | | sql = "UPDATE tb_person SET p_sos=0 WHERE p_tagid=:tagid"; |
| | | cs.tb_caozuo("tb_gps", 3); |
| | | cs.tb_caozuo("tb_person", 3); |
| | | query = this.em.createNativeQuery(sql); |
| | | query.setParameter("tagid", tagid); |
| | | int executeUpdate = query.executeUpdate(); |
| | | return executeUpdate; |
| | | } |
| | | |
| | | @Transactional |
| | | public int shipin(String tagid) { |
| | | String sql = null; |
| | | Query query = null; |
| | | sql = "UPDATE tb_person SET p_shipin=0 WHERE p_tagid=:tagid"; |
| | | cs.tb_caozuo("tb_person", 3); |
| | | query = this.em.createNativeQuery(sql); |
| | | query.setParameter("tagid", tagid); |
| | | int executeUpdate = query.executeUpdate(); |
| | |
| | | String status = resultList.get(0).toString(); |
| | | return status; |
| | | } |
| | | |
| | | public List<tb_person> getfencename(String tagid) { |
| | | String sql = null; |
| | | Query query = null; |
| | | sql = "SELECT p_fencename from tb_person WHERE p_tagid="+tagid; |
| | | query = this.em.createNativeQuery(sql); |
| | | // //System.out.print(sql); |
| | | List resultList = query.getResultList(); |
| | | // //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()); |
| | | tb_person.add(person); |
| | | } |
| | | } |
| | | return tb_person; |
| | | } |
| | | |
| | | public List<tb_shipin> getshebeiid(String fencename) { |
| | | String sql = null; |
| | | Query query = null; |
| | | sql = "SELECT shebeiid,tongdaoid from tb_shipin WHERE fencename=:fencename"; |
| | | query = this.em.createNativeQuery(sql); |
| | | query.setParameter("fencename", fencename); |
| | | List resultList = query.getResultList(); |
| | | List<tb_shipin> tb_shipinList = new ArrayList<tb_shipin>(); |
| | | if (resultList.size() > 0) { |
| | | for (int i = 0; i < resultList.size(); i++) { |
| | | tb_shipin shipin = new tb_shipin(); |
| | | Object[] obj = (Object[]) resultList.get(i); |
| | | shipin.setShebeiid((String) obj[0]); |
| | | shipin.setTongdaoid((String) obj[1]); |
| | | tb_shipinList.add(shipin); |
| | | } |
| | | } |
| | | 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; |
| | | } |
| | | |
| | | } |