yzt
2023-05-05 953cbbf76091fee9d40045f91c06daee496fe5b3
src/main/java/com/hxzkoa/services/AnchorService.java
@@ -15,6 +15,7 @@
import com.hxzkoa.json.tb_achor;
import com.hxzkoa.json.tb_anchor_nearby;
import com.hxzkoa.json.tb_anchorhistory;
import com.hxzkoa.json.tb_shebei;
import com.hxzkoa.json.tb_tongbuanchor;
import com.hxzkoa.json.tb_wifi;
@@ -92,7 +93,36 @@
      sql = "SELECT id,anchorid,POSX,POSY,POSZ,layer,zu,liangcheng,anchormode,anchorip,version,gonglv,jiaozhundistance,GreateTime FROM (SELECT id,anchorid,POSX,POSY,POSZ,layer,zu,liangcheng,anchormode,anchorip,version,gonglv,jiaozhundistance,GreateTime FROM tb_achor ORDER BY id 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")));
      query.setParameter("end", 50);
      List resultList = query.getResultList();
      List<tb_achor> tb_achorList = new ArrayList<tb_achor>();
      if (resultList.size() > 0) {
         for (int i = 0; i < resultList.size(); i++) {
            tb_achor achor = new tb_achor();
            Object[] obj = (Object[]) resultList.get(i);
            achor.setId((int) obj[0]);
            achor.setAnchormode(obj[8] == null ? "" : obj[8].toString());
            achor.setAnchorid(obj[1] == null ? "" : obj[1].toString());
            achor.setPOSX(obj[2] == null ? "" : obj[2].toString());
            achor.setPOSY(obj[3] == null ? "" : obj[3].toString());
            achor.setPOSZ(obj[4] == null ? "" : obj[4].toString());
            achor.setLayer(obj[5] == null ? "" : obj[5].toString());
            achor.setZu(obj[6] == null ? "" : obj[6].toString());
            achor.setLiangcheng(obj[7] == null ? "" : obj[7].toString());
            achor.setAnchorip(obj[9] == null ? "" : obj[9].toString());
            achor.setVersion(obj[10] == null ? "" : obj[10].toString());
            achor.setGreateTime(obj[13] == null ? "" : obj[13].toString());
            tb_achorList.add(achor);
         }
      }
      return tb_achorList;
   }
   public List<tb_achor> getAnchorManagementa() {
      String sql = null;
      Query query = null;
      sql = "SELECT id,anchorid,POSX,POSY,POSZ,layer,zu,liangcheng,anchormode,anchorip,version,gonglv,jiaozhundistance,GreateTime,baoliu6,baoliu7 FROM (SELECT id,anchorid,POSX,POSY,POSZ,layer,zu,liangcheng,anchormode,anchorip,version,gonglv,jiaozhundistance,GreateTime,baoliu6,baoliu7 FROM tb_achor ORDER BY id DESC) s";
      query = this.em.createNativeQuery(sql);
      List resultList = query.getResultList();
      List<tb_achor> tb_achorList = new ArrayList<tb_achor>();
      if (resultList.size() > 0) {
@@ -146,6 +176,36 @@
      }
      return tb_achorList;
   }
   public List<tb_achor> searchAnchorManagementaa(String input) {
      String sql = null;
      Query query = null;
      sql = "SELECT id,anchorid,POSX,POSY,POSZ,layer,zu,liangcheng,anchormode,anchorip,version,gonglv,jiaozhundistance,GreateTime,baoliu6,baoliu7 FROM tb_achor WHERE anchorid = :anchorid";
      query = this.em.createNativeQuery(sql);
      query.setParameter("anchorid", input);
      List resultList = query.getResultList();
      List<tb_achor> tb_achorList = new ArrayList<tb_achor>();
      if (resultList.size() > 0) {
         for (int i = 0; i < resultList.size(); i++) {
            tb_achor achor = new tb_achor();
            Object[] obj = (Object[]) resultList.get(i);
            achor.setId((int) obj[0]);
            achor.setAnchormode(obj[8] == null ? "" : obj[8].toString());
            achor.setAnchorid(obj[1] == null ? "" : obj[1].toString());
            achor.setPOSX(obj[14] == null ? "" : obj[14].toString());
            achor.setPOSY(obj[15] == null ? "" : obj[15].toString());
            achor.setPOSZ(obj[4] == null ? "" : obj[4].toString());
            achor.setLayer(obj[5] == null ? "" : obj[5].toString());
            achor.setZu(obj[6] == null ? "" : obj[6].toString());
            achor.setLiangcheng(obj[7] == null ? "" : obj[7].toString());
            achor.setAnchorip(obj[9] == null ? "" : obj[9].toString());
            achor.setVersion(obj[10] == null ? "" : obj[10].toString());
            achor.setGreateTime(obj[13] == null ? "" : obj[13].toString());
            tb_achorList.add(achor);
         }
      }
      return tb_achorList;
   }
   public int getAnchorManagementCount() {
      String sql = null;
@@ -194,9 +254,49 @@
      int executeUpdate = query.executeUpdate();
      return executeUpdate;
   }
   @Transactional
   public int anchorManagement_addaa(tb_achor achor) {
      //默认值逻辑处理
      if(("").equals(achor.getPOSX())){
         achor.setPOSX("0");
      }
      if(("").equals(achor.getPOSY())){
         achor.setPOSY("0");
      }
      if(("").equals(achor.getPOSZ())){
         achor.setPOSZ("0");
      }
      if(("").equals(achor.getLayer())){
         achor.setLayer("0");
      }
      if(("").equals(achor.getZu())){
         achor.setZu("0");
      }
      if(("").equals(achor.getLiangcheng())){
         achor.setLiangcheng("无限制");
      }
      String sql = null;
      Query query = null;
      sql = "INSERT INTO tb_achor(anchorid,baoliu6,baoliu7,POSZ,layer,zu,liangcheng,anchorip,anchormode,version,greateTime) VALUES(:anchorid,:POSX,:POSY,:POSZ,:layer,:zu,:liangcheng,:anchorip,:anchormode,:version,now())";
      cs.tb_caozuo("tb_achor", 1);
      query = this.em.createNativeQuery(sql);
      query.setParameter("anchorid", achor.getAnchorid());
      query.setParameter("POSX", achor.getPOSX());
      query.setParameter("POSY", achor.getPOSY());
      query.setParameter("POSZ", achor.getPOSZ());
      query.setParameter("layer", achor.getLayer());
      query.setParameter("zu", achor.getZu());
      query.setParameter("liangcheng", achor.getLiangcheng());
      query.setParameter("anchorip", achor.getAnchorip());
      query.setParameter("anchormode", achor.getAnchormode());
      query.setParameter("version", achor.getVersion());
      int executeUpdate = query.executeUpdate();
      return executeUpdate;
   }
   @Transactional
   public void anchorManagement_modify(tb_achor achor) {
   public int anchorManagement_modify(tb_achor achor) {
      String sql = null;
      Query query = null;
      sql = "UPDATE tb_achor SET POSX=:POSX,POSY=:POSY,POSZ=:POSZ,layer=:layer,zu=:zu,liangcheng=:liangcheng,anchorip=:anchorip WHERE anchorid=:anchorid";
@@ -210,7 +310,27 @@
      query.setParameter("zu", achor.getZu());
      query.setParameter("liangcheng", achor.getLiangcheng());
      query.setParameter("anchorip", achor.getAnchorip());
      query.executeUpdate();
      int aaa = query.executeUpdate();
      return aaa;
   }
   @Transactional
   public int anchorManagement_modifyaa(tb_achor achor) {
      String sql = null;
      Query query = null;
      sql = "UPDATE tb_achor SET baoliu6=:POSX,baoliu7=:POSY,POSZ=:POSZ,layer=:layer,zu=:zu,liangcheng=:liangcheng,anchorip=:anchorip WHERE anchorid=:anchorid";
      cs.tb_caozuo("tb_achor", 3);
      query = this.em.createNativeQuery(sql);
      query.setParameter("anchorid", achor.getAnchorid());
      query.setParameter("POSX", achor.getPOSX());
      query.setParameter("POSY", achor.getPOSY());
      query.setParameter("POSZ", achor.getPOSZ());
      query.setParameter("layer", achor.getLayer());
      query.setParameter("zu", achor.getZu());
      query.setParameter("liangcheng", achor.getLiangcheng());
      query.setParameter("anchorip", achor.getAnchorip());
      int aaa = query.executeUpdate();
      return aaa;
   }
   @Transactional
@@ -218,19 +338,20 @@
      String sql = null;
      Query query = null;
      for (int i = 0; i < checkVal.length; i++) {
         int id = Integer.parseInt(checkVal[i]);
//       int id = Integer.parseInt(checkVal[i]);
         sql = "DELETE FROM tb_anchor_nearby WHERE anchorid = :id";
         cs.tb_caozuo("tb_anchor_nearby", 2);
         query = this.em.createNativeQuery(sql);
         query.setParameter("id", id);
         query.setParameter("id", checkVal[i]);
         query.executeUpdate();
      }
   }
   
   @Transactional
   public void anchorManagement_delete(String[] checkVal) {
   public int anchorManagement_delete(String[] checkVal) {
      String sql = null;
      Query query = null;
      int aaa = checkVal.length;
      for (int i = 0; i < checkVal.length; i++) {
         int id = Integer.parseInt(checkVal[i]);
         sql = "DELETE FROM tb_achor WHERE id = :id";
@@ -239,6 +360,22 @@
         query.setParameter("id", id);
         query.executeUpdate();
      }
      return aaa;
   }
   @Transactional
   public int anchorManagement_deletea(String[] checkVal) {
      String sql = null;
      Query query = null;
      int aaa = checkVal.length;
      for (int i = 0; i < checkVal.length; i++) {
         sql = "DELETE FROM tb_achor WHERE anchorid = :anchorid";
         cs.tb_caozuo("tb_achor", 2);
         query = this.em.createNativeQuery(sql);
         query.setParameter("anchorid", checkVal[i]);
         query.executeUpdate();
      }
      return aaa;
   }
   
   @Transactional
@@ -246,23 +383,24 @@
      String sql = null;
      Query query = null;
      for (int i = 0; i < checkVal.length; i++) {
         int id = Integer.parseInt(checkVal[i]);
//       int id = Integer.parseInt(checkVal[i]);
         sql = "DELETE FROM tb_tongbuanchor WHERE anchorid = :id";
         cs.tb_caozuo("tb_tongbuanchor", 2);
         query = this.em.createNativeQuery(sql);
         query.setParameter("id", id);
         query.setParameter("id", checkVal[i]);
         query.executeUpdate();
      }
   }
   @Transactional
   public void anchorManagement_deleteAll() {
   public int anchorManagement_deleteAll() {
      String sql = null;
      Query query = null;
      sql = "DELETE FROM tb_achor";
      cs.tb_caozuo("tb_achor", 2);
      query = this.em.createNativeQuery(sql);
      query.executeUpdate();
      int aaa = query.executeUpdate();
      return aaa;
   }
   public List<tb_anchor_nearby> getProximityConfiguration() {
@@ -618,8 +756,112 @@
            list.add(shebei);
         }
      }
      //System.out.print(list);
      return list;
   }
   
   public List<tb_shebei> getbiaoqianshebei2() {
      String sql = null;
      Query query = null;
      sql = "SELECT p.p_tagid,p.p_online,p.p_name,p.p_power,t.version,p.p_addtiem FROM tb_person AS p,tb_tag AS t WHERE p.p_tagid = t.tag_id";
      query = this.em.createNativeQuery(sql);
      List resultList = query.getResultList();
      List<tb_shebei> list = new ArrayList<tb_shebei>();
      if (resultList.size() > 0) {
         for (int i = 0; i < resultList.size(); i++) {
            tb_shebei shebei = new tb_shebei();
            Object[] obj = (Object[]) resultList.get(i);
            shebei.setZhuangtai(obj[1] == null ? "" : obj[1].toString());
            shebei.setId(obj[0] == null ? "" : obj[0].toString());
            shebei.setDuixiang(obj[2] == null ? "" : obj[2].toString());
            shebei.setBanben(obj[4] == null ? "" : obj[4].toString());
            shebei.setXiangqing(obj[3] == null ? "" : obj[3].toString());
            shebei.setTime(obj[5] == null ? "" : obj[5].toString());
            list.add(shebei);
         }
      }
      return list;
   }
   public List<tb_achor> searchidAnchorManagement(String id) {
      String sql = null;
      Query query = null;
      sql = "SELECT id,anchorid,POSX,POSY,POSZ,layer,zu,liangcheng,anchormode,anchorip,version,gonglv,jiaozhundistance,GreateTime FROM tb_achor WHERE id = :id";
      query = this.em.createNativeQuery(sql);
      query.setParameter("id", id);
      List resultList = query.getResultList();
      List<tb_achor> tb_achorList = new ArrayList<tb_achor>();
      if (resultList.size() > 0) {
         for (int i = 0; i < resultList.size(); i++) {
            tb_achor achor = new tb_achor();
            Object[] obj = (Object[]) resultList.get(i);
            achor.setId((int) obj[0]);
            achor.setAnchormode(obj[8] == null ? "" : obj[8].toString());
            achor.setAnchorid(obj[1] == null ? "" : obj[1].toString());
            achor.setPOSX(obj[2] == null ? "" : obj[2].toString());
            achor.setPOSY(obj[3] == null ? "" : obj[3].toString());
            achor.setPOSZ(obj[4] == null ? "" : obj[4].toString());
            achor.setLayer(obj[5] == null ? "" : obj[5].toString());
            achor.setZu(obj[6] == null ? "" : obj[6].toString());
            achor.setLiangcheng(obj[7] == null ? "" : obj[7].toString());
            achor.setAnchorip(obj[9] == null ? "" : obj[9].toString());
            achor.setVersion(obj[10] == null ? "" : obj[10].toString());
            achor.setGreateTime(obj[13] == null ? "" : obj[13].toString());
            tb_achorList.add(achor);
         }
      }
      return tb_achorList;
   }
   public String searchidAnchorManagement2(String id) {
      String sql = null;
      Query query = null;
      sql = "SELECT anchorid FROM tb_achor WHERE id = :id";
      query = this.em.createNativeQuery(sql);
      query.setParameter("id", id);
      List resultList = query.getResultList();
      String status = resultList.get(0).toString();
      return status;
   }
   public List<tb_anchorhistory> getAnchorhistory() {
      String sql = null;
      Query query = null;
      sql = "SELECT id,anchorid,state,addtime FROM tb_anchor_history_record ORDER BY id DESC";
      query = this.em.createNativeQuery(sql);
      List resultList = query.getResultList();
      List<tb_anchorhistory> tb_achorList = new ArrayList<tb_anchorhistory>();
      if (resultList.size() > 0) {
         for (int i = 0; i < resultList.size(); i++) {
            tb_anchorhistory achor = new tb_anchorhistory();
            Object[] obj = (Object[]) resultList.get(i);
            achor.setId((int) obj[0]);
            achor.setAnchorid(obj[1] == null ? "" : obj[1].toString());
            achor.setState(obj[2] == null ? "" : obj[2].toString());
            achor.setAddtime(obj[3] == null ? "" : obj[3].toString());
            tb_achorList.add(achor);
         }
      }
      return tb_achorList;
   }
   public List<tb_anchorhistory> getidAnchorhistory(String aaa) {
      String sql = null;
      Query query = null;
      sql = "SELECT id,anchorid,state,addtime FROM tb_anchor_history_record where addtime like '"+aaa+"____________'";
      query = this.em.createNativeQuery(sql);
      List resultList = query.getResultList();
      List<tb_anchorhistory> tb_achorList = new ArrayList<tb_anchorhistory>();
      if (resultList.size() > 0) {
         for (int i = 0; i < resultList.size(); i++) {
            tb_anchorhistory achor = new tb_anchorhistory();
            Object[] obj = (Object[]) resultList.get(i);
            achor.setId((int) obj[0]);
            achor.setAnchorid(obj[1] == null ? "" : obj[1].toString());
            achor.setState(obj[2] == null ? "" : obj[2].toString());
            achor.setAddtime(obj[3] == null ? "" : obj[3].toString());
            tb_achorList.add(achor);
         }
      }
      return tb_achorList;
   }
}