From c007fe5c53a88495130b6c6e5ec9b7fc9ad1c9e1 Mon Sep 17 00:00:00 2001
From: 81041 <81041@192.168.10.33>
Date: 星期四, 11 十月 2018 16:09:27 +0800
Subject: [PATCH] 配组继续修改

---
 gx_tieta/src/com/fgkj/dao/impl/BattInfImpl.java |  261 ++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 252 insertions(+), 9 deletions(-)

diff --git a/gx_tieta/src/com/fgkj/dao/impl/BattInfImpl.java b/gx_tieta/src/com/fgkj/dao/impl/BattInfImpl.java
index 4c076cd..d55984c 100644
--- a/gx_tieta/src/com/fgkj/dao/impl/BattInfImpl.java
+++ b/gx_tieta/src/com/fgkj/dao/impl/BattInfImpl.java
@@ -25,6 +25,7 @@
 import com.fgkj.db.DBUtil;
 import com.fgkj.db.IDatabaseName;
 import com.fgkj.dto.BattInf;
+import com.fgkj.dto.BattInf_Rebuild;
 import com.fgkj.dto.BattMap_information;
 import com.fgkj.dto.Batt_Maint_Dealarm;
 import com.fgkj.dto.Batt_maint_inf;
@@ -3280,6 +3281,31 @@
 		} );
 		return list;
 	}
+	//鏌ヨ鎵�鏈夌殑鐪佷唤(宸︿晶瀵艰埅绗竴灞傦紝鏌ユ墍鏈夌殑鐪佷唤)
+	public List serchAllStation_all(Object obj){
+		BattInf binf=(BattInf) obj;;
+		String sql="select DISTINCT StationName1 " +
+				" FROM db_battinf.tb_battinf " +
+				" ORDER BY CONVERT( StationName1 USING gbk ) COLLATE gbk_chinese_ci ASC";
+		List list=DAOHelper.executeQuery(sql, DBUtil.getConn(), null,new CallBack() {
+			
+			public List getResults(ResultSet rs) {
+				List list=new ArrayList();
+					try {
+						while(rs.next()){
+							BattInf batt = new BattInf();
+							batt.setStationName1(rs.getString("stationName1"));
+							list.add(batt);
+						}
+					} catch (SQLException e) {
+						// TODO Auto-generated catch block
+						e.printStackTrace();
+					}
+				return list;
+			}
+		} );
+		return list;
+	}
 	
 	//鏌ヨ绠$悊鐨勫競(宸︿晶瀵艰埅绗簩灞傦紝鏌ユ墍鏈夌殑甯�,num涓瓨鏀緐id)
 	public List serchStationName2(Object obj){
@@ -3291,6 +3317,33 @@
 				" ) and StationName1 like ? " +
 				" ORDER BY CONVERT( StationName2 USING gbk ) COLLATE gbk_chinese_ci ASC ";
 		List list=DAOHelper.executeQuery(sql, DBUtil.getConn(), new Object[]{binf.getNum(),"%"+binf.getStationName1()+"%"},new CallBack() {
+			
+			public List getResults(ResultSet rs) {
+				List list=new ArrayList();
+					try {
+						while(rs.next()){
+							BattInf batt = new BattInf();
+							batt.setStationName1(rs.getString("stationName1"));
+							batt.setStationName2(rs.getString("stationName2"));
+							list.add(batt);
+						}
+					} catch (SQLException e) {
+						// TODO Auto-generated catch block
+						e.printStackTrace();
+					}
+				return list;
+			}
+		} );
+		return list;
+	}
+	//鏌ヨ绠$悊鐨勫競(宸︿晶瀵艰埅绗簩灞傦紝鏌ユ墍鏈夌殑甯�)
+	public List serchStationName2_all(Object obj){
+		BattInf binf=(BattInf) obj;
+		String sql="select DISTINCT StationName1,StationName2  " +
+				" FROM db_battinf.tb_battinf " +
+				" where StationName1 like ? " +
+				" ORDER BY CONVERT( StationName2 USING gbk ) COLLATE gbk_chinese_ci ASC ";
+		List list=DAOHelper.executeQuery(sql, DBUtil.getConn(), new Object[]{"%"+binf.getStationName1()+"%"},new CallBack() {
 			
 			public List getResults(ResultSet rs) {
 				List list=new ArrayList();
@@ -3344,6 +3397,38 @@
 		} );
 		return list;
 	}
+	//鏌ヨ绠$悊鐨勬満鎴�(宸︿晶瀵艰埅绗笁灞傦紝鏌ユ墍鏈夌殑鏈烘埧)
+	public List serchStationName3_all(Object obj){
+		BattInf binf=(BattInf) obj;
+		String sql="select DISTINCT StationName,StationName1,StationName2,StationName3,stationid,fbsdeviceid,FBSDeviceName  " +
+				" FROM db_battinf.tb_battinf " +
+				" where StationName1 like ? and StationName2 like ?  " +
+				" ORDER BY CONVERT( StationName USING gbk ) COLLATE gbk_chinese_ci ASC ";
+		List list=DAOHelper.executeQuery(sql, DBUtil.getConn(), new Object[]{"%"+binf.getStationName1()+"%","%"+binf.getStationName2()+"%"},new CallBack() {
+			
+			public List getResults(ResultSet rs) {
+				List list=new ArrayList();
+					try {
+						while(rs.next()){
+							BattInf batt = new BattInf();
+							batt.setStationName(rs.getString("stationName"));
+							batt.setStationName1(rs.getString("stationName1"));
+							batt.setStationName2(rs.getString("stationName2"));
+							batt.setStationName3(rs.getString("stationName3"));
+							batt.setStationId(rs.getString("stationId"));
+							batt.setFBSDeviceName(rs.getString("fBSDeviceName"));
+							batt.setFBSDeviceId(rs.getInt("fBSDeviceId"));
+							list.add(batt);
+						}
+					} catch (SQLException e) {
+						// TODO Auto-generated catch block
+						e.printStackTrace();
+					}
+				return list;
+			}
+		} );
+		return list;
+	}
    
 	
 	//鏍规嵁鏈烘埧id鏌ヨ鏈烘埧涓嬬殑鐢垫睜缁勪俊鎭�(宸︿晶瀵艰埅绗洓灞�,鏍规嵁鏈烘埧鏌ヨ涓嬮潰鐨勭數姹犵粍,num涓瓨鏀緐id)
@@ -3361,8 +3446,59 @@
 		sql+=userSql;
 		//鎺掑簭
 		String orderSql=" ORDER BY StationName1,battgroupId ";
+		sql+=orderSql;
 		//System.out.println(sql);
 		List list=DAOHelper.executeQuery(sql, DBUtil.getConn(),new Object[]{"%"+binf.getStationName1()+"%","%"+binf.getStationName2()+"%","%"+binf.getStationName()+"%","%"+binf.getStationId()+"%",binf.getNum()},new CallBack() {
+			
+			public List getResults(ResultSet rs) {
+				List list = new ArrayList();
+				try {
+					while (rs.next()) {
+						BattInf batt = new BattInf();
+						batt.setStationName(rs.getString("stationName"));
+						batt.setStationId(rs.getString("StationId"));
+						batt.setStationIp(rs.getString("StationIP"));
+						batt.setBattGroupName(rs.getString("BattGroupName").trim());
+						batt.setBattGroupName1(rs.getString("BattGroupName1").trim());
+						batt.setBattGroupName2(rs.getString("BattGroupName2").trim());
+						batt.setFBSDeviceId(rs.getInt("fBSDeviceId"));
+						batt.setMonCount(rs.getInt("MonCount"));
+						batt.setBattGroupId(rs.getInt("battgroupId"));
+						batt.setMonCapStd(rs.getFloat("monCapStd"));
+						batt.setMonVolStd(rs.getFloat("monVolStd"));
+						batt.setMonResStd(rs.getFloat("MonResStd"));
+						batt.setMonSerStd(rs.getFloat("MonSerStd"));
+						batt.setBattProducer(rs.getString("BattProducer"));
+						batt.setBattInUseDate(rs.getDate("BattInUseDate"));
+						batt.setGroupIndexInFBSDevice(rs.getInt("groupIndexInFBSDevice"));
+						list.add(batt);
+					}
+				} catch (SQLException e) {
+					e.printStackTrace();
+				}
+				return list;
+			}
+		});
+		return list;
+		}
+	//鏍规嵁鏈烘埧id鏌ヨ鏈烘埧涓嬬殑鐢垫睜缁勪俊鎭�(宸︿晶瀵艰埅绗洓灞�,鏍规嵁鏈烘埧鏌ヨ涓嬮潰鐨勭數姹犵粍,num涓瓨鏀緐id)
+	public List serchBattByStation_all(Object obj){
+		BattInf binf=(BattInf) obj;
+		String sql="select DISTINCT StationName,StationId,StationIP,FBSDeviceId,BattGroupName,BattGroupName1,BattGroupName2,MonCount,battgroupId,MonCapStd,MonVolStd,MonResStd,MonSerStd,BattProducer,BattInUseDate,GroupIndexInFBSDevice " +
+				"from db_battinf.tb_battinf  where StationName1 like ? and StationName2 like ?  and  StationName like ?  ";
+	    //鏈烘埧id
+		String idSqlT=" and  Stationid like ? ";
+		sql+=idSqlT;
+		//鐢ㄦ埛绠$悊
+		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;
+		//鎺掑簭
+		String orderSql=" ORDER BY StationName1,battgroupId ";
+		sql+=orderSql;
+		//System.out.println(sql);
+		List list=DAOHelper.executeQuery(sql, DBUtil.getConn(),new Object[]{"%"+binf.getStationName1()+"%","%"+binf.getStationName2()+"%","%"+binf.getStationName()+"%","%"+binf.getStationId()+"%"},new CallBack() {
 			
 			public List getResults(ResultSet rs) {
 				List list = new ArrayList();
@@ -3483,10 +3619,15 @@
 	//鐢垫睜閰嶇粍绠$悊(閲嶈)
 	public List serchMakeGroup(Object obj){
 		BattInf binf=(BattInf) obj;
-		String sql="SELECT distinct BattGroupId,battgroupname,stationid,stationname1,stationname2,stationname,stationname3,BattProducer,MonVolStd,MonCapStd,monCount from db_battinf.tb_battinf where stationname2 like ? ";
+		String sql="SELECT distinct BattGroupId,battgroupname,stationid,stationname1,stationname2,stationname,stationname3,BattProducer,MonVolStd,MonCapStd,monCount " +
+				" ,battinf_re.old_stationname,old_battgroupname,old_battproducer,old_stationid,old_battgroupid,old_monum,new_stationname,new_battgroupname,new_battproducer,new_stationid,new_battgroupid,new_monum,rebuild_time,rebuild_uid,rebuild_address,rebuild_clear_type " +
+				" from db_battinf.tb_battinf " +
+				" left outer join (select * from db_battinf.tb_battinf_rebuild where tb_battinf_rebuild.rebuild_clear_type=1 ) as battinf_re " +
+				" on BattGroupId=battinf_re.new_battgroupid or BattGroupId=battinf_re.old_battgroupid " +
+				" where stationname2 like ? ";
 		//閫変腑鍝佺墝涓�鑷�
-		String producerSqlT=" order by BattProducer,MonCapStd,MonVolStd ";//涓�鑷�
-		String producerSqlF=" order by MonCapStd,MonVolStd ";//涓嶄竴鑷�
+		String producerSqlT=" order by BattProducer,MonCapStd,MonVolStd,BattGroupId ";//涓�鑷�
+		String producerSqlF=" order by MonCapStd,MonVolStd,BattGroupId ";//涓嶄竴鑷�
 		if(binf.getBattProducer().equals("1")){
 			sql+=producerSqlT;
 		}else{
@@ -3495,7 +3636,8 @@
 		List list=DAOHelper.executeQuery(sql, DBUtil.getConn(), new Object[]{"%"+binf.getStationName2()+"%"}, new CallBack() {
 			
 			public List getResults(ResultSet rs) {
-				List list=new ArrayList();
+				List<BattInf> list=new ArrayList();
+				int battgroupid=0;
 				try {
 					while(rs.next()){
 						BattInf binf=new BattInf();
@@ -3510,6 +3652,34 @@
 						binf.setMonVolStd(rs.getFloat("monVolStd"));
 						binf.setMonCapStd(rs.getFloat("monCapStd"));
 						binf.setMonCount(rs.getInt("monCount"));
+						
+						BattInf_Rebuild brinf=new BattInf_Rebuild();
+						brinf.setNew_battgroupid(rs.getInt("new_battgroupid"));
+						brinf.setNew_battgroupname(rs.getString("new_battgroupname"));
+						brinf.setNew_battproducer(rs.getString("new_battproducer"));
+						brinf.setNew_monum(rs.getInt("new_monum"));
+						brinf.setNew_stationid(rs.getString("new_stationid"));
+						brinf.setNew_stationname(rs.getString("new_stationname"));
+						brinf.setOld_battgroupid(rs.getInt("old_battgroupid"));
+						brinf.setOld_battgroupname(rs.getString("old_battgroupname"));
+						brinf.setOld_battproducer(rs.getString("old_battproducer"));
+						brinf.setOld_monum(rs.getInt("old_monum"));
+						brinf.setOld_stationid(rs.getString("old_stationid"));
+						brinf.setOld_stationname(rs.getString("old_stationname"));
+						brinf.setRebuild_address(rs.getString("rebuild_address"));
+						brinf.setRebuild_clear_type(rs.getInt("rebuild_clear_type"));
+						brinf.setRebuild_time(rs.getTimestamp("rebuild_time"));
+						brinf.setRebuild_uid(rs.getInt("rebuild_uid"));
+						
+                        if(binf.getBattGroupId()==battgroupid){
+							((ArrayList)list.get(list.size()-1).getObj()).add(brinf);
+							continue;
+						}
+						List listr=new ArrayList();
+						listr.add(brinf);
+						binf.setObj(listr);
+						battgroupid=binf.getBattGroupId();
+						
 						list.add(binf);
 					}
 				} catch (SQLException e) {
@@ -3521,15 +3691,87 @@
 		});
 		return list;
 	}
+	//鐢垫睜閰嶇粍绠$悊(閲嶈)
+	public List serchGroupByInfor(Object obj){
+		BattInf binf=(BattInf) obj;
+		String sql="SELECT distinct BattGroupId,battgroupname,stationid,stationname1,stationname2,stationname,stationname3,BattProducer,MonVolStd,MonCapStd,monCount " +
+				" ,battinf_re.old_stationname,old_battgroupname,old_battproducer,old_stationid,old_battgroupid,old_monum,new_stationname,new_battgroupname,new_battproducer,new_stationid,new_battgroupid,new_monum,rebuild_time,rebuild_uid,rebuild_address,rebuild_clear_type " +
+				" from db_battinf.tb_battinf " +
+				" left outer join (select * from db_battinf.tb_battinf_rebuild where tb_battinf_rebuild.rebuild_clear_type=1 ) as battinf_re " +
+				" on BattGroupId=battinf_re.new_battgroupid or BattGroupId=battinf_re.old_battgroupid " +
+				" where stationname1 like ? and stationname2 like ? and stationname3 like ?  and battgroupname like ?  and battgroupid=? ";
+		List list=DAOHelper.executeQuery(sql, DBUtil.getConn(), new Object[]{"%"+binf.getStationName1()+"%","%"+binf.getStationName2()+"%","%"+binf.getStationName3()+"%","%"+binf.getBattGroupName()+"%",binf.getBattGroupId()}, new CallBack() {
+			
+			public List getResults(ResultSet rs) {
+				List<BattInf> list=new ArrayList();
+				int battgroupid=0;
+				try {
+					while(rs.next()){
+						BattInf binf=new BattInf();
+						binf.setBattGroupId(rs.getInt("battGroupId"));
+						binf.setBattGroupName(rs.getString("battGroupName"));
+						binf.setStationId(rs.getString("stationId"));
+						binf.setStationName(rs.getString("stationName"));
+						binf.setStationName1(rs.getString("stationName1"));
+						binf.setStationName2(rs.getString("stationName2"));
+						binf.setStationName3(rs.getString("stationName3"));
+						binf.setBattProducer(rs.getString("battProducer"));
+						binf.setMonVolStd(rs.getFloat("monVolStd"));
+						binf.setMonCapStd(rs.getFloat("monCapStd"));
+						binf.setMonCount(rs.getInt("monCount"));
+						
+						BattInf_Rebuild brinf=new BattInf_Rebuild();
+						brinf.setNew_battgroupid(rs.getInt("new_battgroupid"));
+						brinf.setNew_battgroupname(rs.getString("new_battgroupname"));
+						brinf.setNew_battproducer(rs.getString("new_battproducer"));
+						brinf.setNew_monum(rs.getInt("new_monum"));
+						brinf.setNew_stationid(rs.getString("new_stationid"));
+						brinf.setNew_stationname(rs.getString("new_stationname"));
+						brinf.setOld_battgroupid(rs.getInt("old_battgroupid"));
+						brinf.setOld_battgroupname(rs.getString("old_battgroupname"));
+						brinf.setOld_battproducer(rs.getString("old_battproducer"));
+						brinf.setOld_monum(rs.getInt("old_monum"));
+						brinf.setOld_stationid(rs.getString("old_stationid"));
+						brinf.setOld_stationname(rs.getString("old_stationname"));
+						brinf.setRebuild_address(rs.getString("rebuild_address"));
+						brinf.setRebuild_clear_type(rs.getInt("rebuild_clear_type"));
+						brinf.setRebuild_time(rs.getTimestamp("rebuild_time"));
+						brinf.setRebuild_uid(rs.getInt("rebuild_uid"));
+						
+                        if(binf.getBattGroupId()==battgroupid){
+							((ArrayList)list.get(list.size()-1).getObj()).add(brinf);
+							continue;
+						}
+						List listr=new ArrayList();
+						listr.add(brinf);
+						binf.setObj(listr);
+						battgroupid=binf.getBattGroupId();
+						
+						list.add(binf);
+					}
+				} catch (SQLException e) {
+					// TODO Auto-generated catch block
+					e.printStackTrace();
+				}
+				return list;
+			}
+		});
+		return list;
+	}
+	
+	
 	public static void main(String[] args) throws ParseException {
 		//new BattInfImpl().searchAll();
 		
 		BattInfImpl biml = new BattInfImpl();
 		BattInf binf = new BattInf();
-		binf.setBattGroupId(1000967);
-		binf.setStationName("鍐呰挋鍙�");
-		binf.setStationName1("鍐呰挋鍙�");
-		
+		binf.setBattGroupId(1000001);
+		binf.setStationName("");
+		binf.setStationName1("");
+		binf.setStationName2("");
+		binf.setStationName3("姝︽眽婧愭殺瀹為獙瀹�1");
+		binf.setBattGroupName("");
+		binf.setBattProducer("1");
 		User_inf uinf=new User_inf();
 		uinf.setUId(1002);
 		
@@ -3554,7 +3796,8 @@
 		//List<BattInf> list = biml.serchByConditionNew(bmd);
 		//List<BattInf> list=biml.serchByTestType(bmd);
 		//List<BattInf> list=biml.serchGroupAssess(bmd);
-		List<BattInf> list=biml.serchByMonNum(binf);
+		//List<BattInf> list=biml.serchMakeGroup(binf);
+		List<BattInf> list=biml.serchGroupByInfor(binf);
 		for (BattInf b : list) {
 			System.out.println(b);
 		}

--
Gitblit v1.9.1