From fb8529359bbae75a662fbf32086b296b7a854163 Mon Sep 17 00:00:00 2001
From: 81041 <81041@192.168.10.25>
Date: 星期二, 30 十月 2018 16:31:06 +0800
Subject: [PATCH] 实时左下角加区县
---
gx_tieta/src/com/fgkj/dao/impl/ram/Bts_station_stateImpl.java | 129 ++++++++++++++++++++++++++++++++++++++----
1 files changed, 116 insertions(+), 13 deletions(-)
diff --git a/gx_tieta/src/com/fgkj/dao/impl/ram/Bts_station_stateImpl.java b/gx_tieta/src/com/fgkj/dao/impl/ram/Bts_station_stateImpl.java
index 2f69c1c..09a7d35 100644
--- a/gx_tieta/src/com/fgkj/dao/impl/ram/Bts_station_stateImpl.java
+++ b/gx_tieta/src/com/fgkj/dao/impl/ram/Bts_station_stateImpl.java
@@ -10,9 +10,11 @@
import com.fgkj.dao.CallBack;
import com.fgkj.dao.DAOHelper;
import com.fgkj.dao.LimitNumberFactory;
+import com.fgkj.dao.UinfDaoFactory;
import com.fgkj.db.DBUtil;
import com.fgkj.dto.BattInf;
import com.fgkj.dto.Page;
+import com.fgkj.dto.User_inf;
import com.fgkj.dto.ram.Bts_station_state;
public class Bts_station_stateImpl implements BaseDAO,CallBack{
@@ -44,7 +46,7 @@
//鏌ヨ鏈烘埧瀹炴椂鐘舵��
public List serchByCondition(Object obj) {
BattInf binf=(BattInf) obj;
- Page p=new Page();
+ Page p=binf.getPage();
Connection conn=DBUtil.getConn();
String numberSql="SELECT FOUND_ROWS() number";//瀛樻斁鎬绘暟
String sql="select SQL_CALC_FOUND_ROWS distinct station_id,dev_id,record_datetime,station_stat,station_poff_start_time,station_fadian_start_time" +
@@ -52,10 +54,73 @@
" ,tb_battinf.stationname,tb_battinf.stationname1,tb_battinf.stationname2,tb_battinf.stationname3 " +
" from db_ram_db.tb_bts_station_state,db_battinf.tb_battinf " +
" where tb_bts_station_state.dev_id=db_battinf.tb_battinf.FBSDeviceId " +
- " and tb_bts_station_state.station_id=db_battinf.tb_battinf.StationId " +
- " and tb_battinf.stationname1 like ? and tb_battinf.stationname2 like ? and tb_battinf.stationname3 like ? " +
- " and stationid like ? limit ? ,? ";
- List<Bts_station_state> list=DAOHelper.executeQueryLimit(sql, conn, new Object[]{"%"+binf.getStationName1()+"%","%"+binf.getStationName2()+"%","%"+binf.getStationName3()+"%","%"+binf.getStationId()+"%",(p.getPageCurr()-1)*p.getPageSize(),p.getPageSize()},new CallBack() {
+ " and tb_battinf.stationname1 like ? and tb_battinf.stationname2 like ? and tb_battinf.stationname3 like ? " +
+ " and stationid like ? " ;
+ /*" and tb_bts_station_state.station_id in (" +
+ " select distinct db_battinf.tb_battinf.stationid " +
+ " from db_battinf.tb_battinf " +
+ " left outer join db_user.tb_user_battgroup_baojigroup_battgroup on db_user.tb_user_battgroup_baojigroup_battgroup.stationid=db_battinf.tb_battinf.stationid " +
+ " left outer join db_user.tb_user_battgroup_baojigroup_usr on db_user.tb_user_battgroup_baojigroup_usr.baoji_group_id=db_user.tb_user_battgroup_baojigroup_battgroup.baoji_group_id " +
+ " left outer join db_user.tb_user_inf on tb_user_inf.uid=db_user.tb_user_battgroup_baojigroup_usr.uid " +
+ " where db_user.tb_user_inf.uid=? and tb_battinf.stationname1 like ? and tb_battinf.stationname2 like ? and tb_battinf.stationname3 like ? ) " +
+ " and stationid like ? " ;*/
+ //鐢ㄦ埛绠$悊
+ String userSql=" and StationId in(" +
+ " select distinct db_user.tb_user_battgroup_baojigroup_battgroup.StationId from db_user.tb_user_battgroup_baojigroup_battgroup,db_user.tb_user_battgroup_baojigroup_usr where db_user.tb_user_battgroup_baojigroup_battgroup.baoji_group_id=db_user.tb_user_battgroup_baojigroup_usr.baoji_group_id and db_user.tb_user_battgroup_baojigroup_usr.uId=?" +
+ " ) ";
+ sql+=userSql;
+ if(binf.getBattGroupNum()>1){
+ sql+=" and ( ";
+ }
+ //鎺夌珯
+ String diaozhanSql=" ((station_stat&32)>1) ";
+ if((binf.getBattGroupNum()&32)>1){
+ sql+=diaozhanSql;
+ }
+ if((binf.getBattGroupNum()&16)>1&&(binf.getBattGroupNum()>32)){
+ sql+=" or ";
+ }
+ //寮�闂�
+ String dooropenSql=" ((station_stat&16)>1) ";
+ if((binf.getBattGroupNum()&16)>1){
+ sql+=dooropenSql;
+ }
+ if((binf.getBattGroupNum()&8)>1&&(binf.getBattGroupNum()>16)){
+ sql+=" or ";
+ }
+ //鍙戠數
+ String fadianSql=" ((station_stat&8)>1) ";
+ if((binf.getBattGroupNum()&8)>1){
+ sql+=fadianSql;
+ }
+ if((binf.getBattGroupNum()&4)>1&&(binf.getBattGroupNum()>8)){
+ sql+=" or ";
+ }
+ //缁埅
+ String xuhangSql=" ((station_stat&4)>1) ";
+ if((binf.getBattGroupNum()&4)>1){
+ sql+=xuhangSql;
+ }
+ if((binf.getBattGroupNum()&2)>1&&(binf.getBattGroupNum()>4)){
+ sql+=" or ";
+ }
+ //鍋滅數
+ String poffSql=" ((station_stat&2)>1) ";
+ if((binf.getBattGroupNum()&2)>1){
+ sql+=poffSql;
+ }
+
+ if(binf.getBattGroupNum()>1){
+ sql+=" ) ";
+ }
+ if(binf.getBattGroupNum()==0){
+ sql+=" and station_stat<0 "; //褰撴病鏈夐�夋嫨鎯宠鏌ョ湅鐨勬満鎴垮紓甯哥姸鎬佹槸绛涢��
+ }
+ //鍒嗛〉
+ String orderSql=" limit ? ,? ";
+ sql+=orderSql;
+ //System.out.println(sql);
+ List<Bts_station_state> list=DAOHelper.executeQueryLimit(sql, conn, new Object[]{"%"+binf.getStationName1()+"%","%"+binf.getStationName2()+"%","%"+binf.getStationName3()+"%","%"+binf.getStationId()+"%",binf.getNum(),(p.getPageCurr()-1)*p.getPageSize(),p.getPageSize()},new CallBack() {
public List getResults(ResultSet rs) {
List list=new ArrayList();
@@ -66,19 +131,19 @@
b.setDev_id(rs.getInt("dev_id"));
b.setRecord_datetime(rs.getTimestamp("record_datetime"));
b.setStation_stat(rs.getInt("station_stat"));
- if(((b.getStation_stat()>>4)&1)==1){
+ if(((b.getStation_stat()>>5)&1)==1){
b.setStation_stat_diaozhan(1);//鎺夌珯
}
- if(((b.getStation_stat()>>3)&1)==1){
+ if(((b.getStation_stat()>>4)&1)==1){
b.setStation_stat_dooropen(1);//寮�闂�
}
- if(((b.getStation_stat()>>2)&1)==1){
+ if(((b.getStation_stat()>>3)&1)==1){
b.setStation_stat_fadian(1); //鍙戠數
}
- if(((b.getStation_stat()>>1)&1)==1){
+ if(((b.getStation_stat()>>2)&1)==1){
b.setStation_stat_xuhang(1);//缁埅
}
- if((b.getStation_stat()&1)==1){
+ if(((b.getStation_stat()>>1)&1)==1){
b.setStation_stat_poff(1); //鍋滅數
}
b.setStation_poff_start_time(rs.getTimestamp("station_poff_start_time"));
@@ -111,27 +176,65 @@
}
return list;
}
-
+ //鏌ヨ褰撳墠鏈烘埧鍋滅數鏁�
+ public int serchByState(Object obj) {
+ User_inf uinf=(User_inf) obj;
+ String sql=" select count(*) as nums from db_ram_db.tb_bts_station_state where station_stat&2>1 " +
+ " and tb_bts_station_state.station_id in (" +
+ " select distinct db_battinf.tb_battinf.stationid " +
+ " from db_battinf.tb_battinf " +
+ " left outer join db_user.tb_user_battgroup_baojigroup_battgroup on db_user.tb_user_battgroup_baojigroup_battgroup.stationid=db_battinf.tb_battinf.stationid " +
+ " left outer join db_user.tb_user_battgroup_baojigroup_usr on db_user.tb_user_battgroup_baojigroup_usr.baoji_group_id=db_user.tb_user_battgroup_baojigroup_battgroup.baoji_group_id " +
+ " left outer join db_user.tb_user_inf on tb_user_inf.uid=db_user.tb_user_battgroup_baojigroup_usr.uid " +
+ " where db_user.tb_user_inf.uid=? ) " ;
+ List list=DAOHelper.executeQuery(sql, DBUtil.getConn(), new Object[]{uinf.getUId()}, new CallBack() {
+
+ public List getResults(ResultSet rs) {
+ List list=new ArrayList();
+ try {
+ while(rs.next()){
+ list.add(rs.getInt("nums"));
+ }
+ } catch (SQLException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ return list;
+ }
+ });
+ int nums=0;//鎬绘暟
+ if(list!=null&&list.size()>0){
+ nums=(Integer) list.get(list.size()-1);
+ }
+ return nums;
+ }
public List serchByInfo(Object obj) {
// TODO Auto-generated method stub
return null;
}
-
public static void main(String[] args) {
Bts_station_stateImpl bimpl=new Bts_station_stateImpl();
BattInf binf=new BattInf();
+ binf.setNum(1002);
binf.setStationName1("");
binf.setStationName2("");
binf.setStationName3("");
binf.setStationId("");
+ binf.setBattGroupNum(36);
+ User_inf uinf=new User_inf();
+ uinf.setUId(1002);
Page p=new Page();
p.setPageCurr(1);
p.setPageSize(10);
binf.setPage(p);
List<Bts_station_state> list=bimpl.serchByCondition(binf);
for (Bts_station_state bs : list) {
- System.out.println(bs.getStation_stat_diaozhan()+" "+bs.getStation_stat_dooropen()+" "+bs.getStation_stat_fadian()+" "+bs.getStation_stat_xuhang()+" "+bs.getStation_stat_poff());
+ //System.out.println(bs.getStation_stat_diaozhan()+" "+bs.getStation_stat_dooropen()+" "+bs.getStation_stat_fadian()+" "+bs.getStation_stat_xuhang()+" "+bs.getStation_stat_poff());
System.out.println(bs);
}
+ /*int nums=bimpl.serchByState(uinf);
+ System.out.println(nums);*/
}
+
+
}
--
Gitblit v1.9.1