| | |
| | | package com.fgkj.dao.impl;
|
| | |
|
| | | import java.sql.ResultSet;
|
| | | import java.sql.SQLException;
|
| | | import java.util.ArrayList;
|
| | | import java.util.Date;
|
| | | import java.util.List;
|
| | |
|
| | | import com.fgkj.dao.BaseDAO;
|
| | | import com.fgkj.dao.CallBack;
|
| | | import com.fgkj.dao.DAOHelper;
|
| | | import com.fgkj.db.DBUtil;
|
| | | import com.fgkj.db.IDatabaseName;
|
| | | import com.fgkj.dto.BattInf;
|
| | | import com.fgkj.dto.User_battgroup_baojigroup;
|
| | | import com.fgkj.dto.User_inf;
|
| | | import com.sun.org.apache.xerces.internal.impl.dv.dtd.IDDatatypeValidator;
|
| | |
|
| | | public class User_battgroup_baojigroupImpl implements BaseDAO, CallBack {
|
| | |
|
| | | public List getResults(ResultSet rs) {
|
| | | List list = new ArrayList();
|
| | | try {
|
| | | while (rs.next()) {
|
| | | User_battgroup_baojigroup userbaojigroup = new User_battgroup_baojigroup();
|
| | |
|
| | | userbaojigroup.setBaoji_group_id(rs.getInt("baoji_group_id"));
|
| | |
|
| | | userbaojigroup.setBaoji_group_name(rs
|
| | | .getString("baoji_group_name"));
|
| | |
|
| | | list.add(userbaojigroup);
|
| | | }
|
| | | } catch (SQLException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | return list;
|
| | | }
|
| | |
|
| | | //5.3添加新包机组
|
| | | public boolean add(Object obj) {
|
| | | User_battgroup_baojigroup ubao=(User_battgroup_baojigroup) obj;
|
| | | String sql="insert into db_user.tb_user_battgroup_baojigroup(baoji_group_name) values(?)";
|
| | | Boolean bl=DAOHelper.executeUpdate(DBUtil.getConn(), sql,new Object[]{ubao.getBaoji_group_name()});
|
| | | return bl;
|
| | | }
|
| | | //5.3修改包机组名
|
| | | public boolean update(Object obj) {
|
| | | User_battgroup_baojigroup ubao=(User_battgroup_baojigroup) obj;
|
| | | String sql="update db_user.tb_user_battgroup_baojigroup set baoji_group_name=? where baoji_group_id=?";
|
| | | Boolean bl=DAOHelper.executeUpdate(DBUtil.getConn(), sql,new Object[]{ubao.getBaoji_group_name(),ubao.getBaoji_group_id()});
|
| | | return bl;
|
| | | }
|
| | | |
| | | //5.3删除包机组
|
| | | public boolean del(Object obj) {
|
| | | User_battgroup_baojigroup ubao=(User_battgroup_baojigroup) obj;
|
| | | String sql="delete db_user.tb_user_battgroup_baojigroup from db_user.tb_user_battgroup_baojigroup where baoji_group_id=?";
|
| | | Boolean bl=DAOHelper.executeUpdate(DBUtil.getConn(), sql,new Object[]{ubao.getBaoji_group_id()});
|
| | | return bl;
|
| | | }
|
| | |
|
| | | //5.3删除包机组(多表删除事务回滚)
|
| | | public String delPro(Object obj) {
|
| | | User_battgroup_baojigroup ubao=(User_battgroup_baojigroup) obj;
|
| | | String sql="delete db_user.tb_user_battgroup_baojigroup from db_user.tb_user_battgroup_baojigroup where baoji_group_id="+ubao.getBaoji_group_id();
|
| | | return sql;
|
| | | }
|
| | |
|
| | | //5.3查所有包机组
|
| | | public List searchAll() {
|
| | | String sql = "select baoji_group_id,baoji_group_name from db_user.tb_user_battgroup_baojigroup";
|
| | | List list= DAOHelper.executeQuery(sql,
|
| | | DBUtil.getConn(), null,
|
| | | new User_battgroup_baojigroupImpl());
|
| | | return list;
|
| | | }
|
| | |
|
| | | //5.3根据包机组id查包机组对应的用户
|
| | | public List serchByCondition(Object obj) {
|
| | | User_battgroup_baojigroup ubao=(User_battgroup_baojigroup) obj;
|
| | | String sql="select distinct(db_user.tb_user_inf.uid) ,db_user.tb_user_inf.uName,db_user.tb_user_battgroup_baojigroup_usr.num " +
|
| | | "from db_user.tb_user_inf,db_user.tb_user_battgroup_baojigroup,db_user.tb_user_battgroup_baojigroup_usr " +
|
| | | "where db_user.tb_user_battgroup_baojigroup.baoji_group_id=db_user.tb_user_battgroup_baojigroup_usr.baoji_group_id " +
|
| | | "and db_user.tb_user_battgroup_baojigroup_usr.uId=db_user.tb_user_inf.uId " +
|
| | | "and db_user.tb_user_battgroup_baojigroup.baoji_group_id=? " +
|
| | | "order by db_user.tb_user_inf.uid";
|
| | | List list= DAOHelper.executeQuery(sql,
|
| | | DBUtil.getConn(), new Object[]{ubao.getBaoji_group_id()},
|
| | | new CallBack() {
|
| | | |
| | | public List getResults(ResultSet rs) {
|
| | | List list=new ArrayList();
|
| | | try {
|
| | | while(rs.next()){
|
| | | User_inf uinf=new User_inf();
|
| | | uinf.setUId(rs.getInt("uId"));
|
| | | uinf.setUName(rs.getString("uName"));
|
| | | uinf.setUBaojiusr(rs.getInt("num"));
|
| | | list.add(uinf);
|
| | | }
|
| | | } catch (SQLException e) {
|
| | | // TODO Auto-generated catch block
|
| | | e.printStackTrace();
|
| | | }
|
| | | return list;
|
| | | }
|
| | | });
|
| | | return list;
|
| | | }
|
| | |
|
| | | //5.3根据包机组id查对应的机房和电池组
|
| | | public List serchByInfo(Object obj) {
|
| | | User_battgroup_baojigroup ubao=(User_battgroup_baojigroup) obj;
|
| | | String sql="select distinct(db_battinf.tb_battinf.BattGroupId)" +
|
| | | ",db_battinf.tb_battinf.stationid,db_battinf.tb_battinf.BattGroupId,db_battinf.tb_battinf.StationName,db_battinf.tb_battinf.BattGroupName " +
|
| | | "from db_battinf.tb_battinf,db_user.tb_user_battgroup_baojigroup,db_user.tb_user_battgroup_baojigroup_battgroup " +
|
| | | "where db_user.tb_user_battgroup_baojigroup.baoji_group_id=db_user.tb_user_battgroup_baojigroup_battgroup.baoji_group_id " +
|
| | | "and db_user.tb_user_battgroup_baojigroup_battgroup.stationid=db_battinf.tb_battinf.stationid " +
|
| | | "and db_user.tb_user_battgroup_baojigroup.baoji_group_id=? and db_user.tb_user_battgroup_baojigroup_battgroup.BattGroupId = db_battinf.tb_battinf.BattGroupId " +
|
| | | "order by db_battinf.tb_battinf.BattGroupId";
|
| | | List list=DAOHelper.executeQuery(sql, DBUtil.getConn(), new Object[]{ubao.getBaoji_group_id()}, new CallBack() {
|
| | | |
| | | public List getResults(ResultSet rs) {
|
| | | List list=new ArrayList();
|
| | | try {
|
| | | while(rs.next()){
|
| | | BattInf binf=new BattInf();
|
| | | |
| | | binf.setBattGroupId(rs.getInt("battGroupId"));
|
| | | binf.setStationName(rs.getString("stationName"));
|
| | | binf.setStationId(rs.getString("stationid"));
|
| | | binf.setBattGroupName(rs.getString("battGroupName"));
|
| | | list.add(binf);
|
| | | }
|
| | | } catch (SQLException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | return list;
|
| | | }
|
| | | });
|
| | | return list;
|
| | | }
|
| | |
|
| | | public static void main(String[] args) {
|
| | | |
| | | User_battgroup_baojigroupImpl ub= new User_battgroup_baojigroupImpl();
|
| | | /*List<User_battgroup_baojigroup> list =ub.searchAll();
|
| | | for (User_battgroup_baojigroup u : list) {
|
| | | System.out.println(u);
|
| | | }*/
|
| | | /*User_battgroup_baojigroup u=new User_battgroup_baojigroup();
|
| | | u.setBaoji_group_id(100001);
|
| | | List<User_inf> list =ub.serchByCondition(u);
|
| | | for (User_inf uu : list) {
|
| | | System.out.println(uu);
|
| | | }*/
|
| | | User_battgroup_baojigroup u=new User_battgroup_baojigroup();
|
| | | u.setBaoji_group_id(100001);
|
| | | List<BattInf> list =ub.serchByInfo(u);
|
| | | for (BattInf b : list) {
|
| | | System.out.println(b);
|
| | | }
|
| | | }
|
| | | }
|
| | | package com.fgkj.dao.impl; |
| | | |
| | | import java.sql.ResultSet; |
| | | import java.sql.SQLException; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | import com.fgkj.dao.BaseDAO; |
| | | import com.fgkj.dao.CallBack; |
| | | import com.fgkj.dao.DAOHelper; |
| | | import com.fgkj.db.DBUtil; |
| | | import com.fgkj.db.IDatabaseName; |
| | | import com.fgkj.dto.BattInf; |
| | | import com.fgkj.dto.User_battgroup_baojigroup; |
| | | import com.fgkj.dto.User_inf; |
| | | import com.sun.org.apache.xerces.internal.impl.dv.dtd.IDDatatypeValidator; |
| | | |
| | | public class User_battgroup_baojigroupImpl implements BaseDAO, CallBack { |
| | | |
| | | public List getResults(ResultSet rs) { |
| | | List list = new ArrayList(); |
| | | try { |
| | | while (rs.next()) { |
| | | User_battgroup_baojigroup userbaojigroup = new User_battgroup_baojigroup(); |
| | | |
| | | userbaojigroup.setBaoji_group_id(rs.getInt("baoji_group_id")); |
| | | |
| | | userbaojigroup.setBaoji_group_name(rs |
| | | .getString("baoji_group_name")); |
| | | |
| | | list.add(userbaojigroup); |
| | | } |
| | | } catch (SQLException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return list; |
| | | } |
| | | |
| | | //5.3添加新包机组 |
| | | public boolean add(Object obj) { |
| | | User_battgroup_baojigroup ubao=(User_battgroup_baojigroup) obj; |
| | | String sql="insert into db_user.tb_user_battgroup_baojigroup(baoji_group_name) values(?)"; |
| | | Boolean bl=DAOHelper.executeUpdate(DBUtil.getConn(), sql,new Object[]{ubao.getBaoji_group_name()}); |
| | | return bl; |
| | | } |
| | | //5.3修改包机组名 |
| | | public boolean update(Object obj) { |
| | | User_battgroup_baojigroup ubao=(User_battgroup_baojigroup) obj; |
| | | String sql="update db_user.tb_user_battgroup_baojigroup set baoji_group_name=? where baoji_group_id=?"; |
| | | Boolean bl=DAOHelper.executeUpdate(DBUtil.getConn(), sql,new Object[]{ubao.getBaoji_group_name(),ubao.getBaoji_group_id()}); |
| | | return bl; |
| | | } |
| | | |
| | | //5.3删除包机组 |
| | | public boolean del(Object obj) { |
| | | User_battgroup_baojigroup ubao=(User_battgroup_baojigroup) obj; |
| | | String sql="delete db_user.tb_user_battgroup_baojigroup from db_user.tb_user_battgroup_baojigroup where baoji_group_id=?"; |
| | | Boolean bl=DAOHelper.executeUpdate(DBUtil.getConn(), sql,new Object[]{ubao.getBaoji_group_id()}); |
| | | return bl; |
| | | } |
| | | |
| | | //5.3删除包机组(多表删除事务回滚) |
| | | public String delPro(Object obj) { |
| | | User_battgroup_baojigroup ubao=(User_battgroup_baojigroup) obj; |
| | | String sql="delete db_user.tb_user_battgroup_baojigroup from db_user.tb_user_battgroup_baojigroup where baoji_group_id="+ubao.getBaoji_group_id(); |
| | | return sql; |
| | | } |
| | | |
| | | //5.3查所有包机组 |
| | | public List searchAll() { |
| | | String sql = "select baoji_group_id,baoji_group_name from db_user.tb_user_battgroup_baojigroup"; |
| | | List list= DAOHelper.executeQuery(sql, |
| | | DBUtil.getConn(), null, |
| | | new User_battgroup_baojigroupImpl()); |
| | | return list; |
| | | } |
| | | |
| | | //5.3根据包机组id查包机组对应的用户 |
| | | public List serchByCondition(Object obj) { |
| | | User_battgroup_baojigroup ubao=(User_battgroup_baojigroup) obj; |
| | | String sql="select distinct(db_user.tb_user_inf.uid) ,db_user.tb_user_inf.uName,db_user.tb_user_battgroup_baojigroup_usr.num " + |
| | | "from db_user.tb_user_inf,db_user.tb_user_battgroup_baojigroup,db_user.tb_user_battgroup_baojigroup_usr " + |
| | | "where db_user.tb_user_battgroup_baojigroup.baoji_group_id=db_user.tb_user_battgroup_baojigroup_usr.baoji_group_id " + |
| | | "and db_user.tb_user_battgroup_baojigroup_usr.uId=db_user.tb_user_inf.uId " + |
| | | "and db_user.tb_user_battgroup_baojigroup.baoji_group_id=? " + |
| | | "order by db_user.tb_user_inf.uid"; |
| | | List list= DAOHelper.executeQuery(sql, |
| | | DBUtil.getConn(), new Object[]{ubao.getBaoji_group_id()}, |
| | | new CallBack() { |
| | | |
| | | public List getResults(ResultSet rs) { |
| | | List list=new ArrayList(); |
| | | try { |
| | | while(rs.next()){ |
| | | User_inf uinf=new User_inf(); |
| | | uinf.setUId(rs.getInt("uId")); |
| | | uinf.setUName(rs.getString("uName")); |
| | | uinf.setUBaojiusr(rs.getInt("num")); |
| | | list.add(uinf); |
| | | } |
| | | } catch (SQLException e) { |
| | | // TODO Auto-generated catch block |
| | | e.printStackTrace(); |
| | | } |
| | | return list; |
| | | } |
| | | }); |
| | | return list; |
| | | } |
| | | |
| | | //5.3根据包机组id查对应的机房和电池组 |
| | | public List serchByInfo(Object obj) { |
| | | User_battgroup_baojigroup ubao=(User_battgroup_baojigroup) obj; |
| | | String sql="select distinct(db_battinf.tb_battinf.BattGroupId)" + |
| | | ",db_battinf.tb_battinf.stationid,db_battinf.tb_battinf.BattGroupId,db_battinf.tb_battinf.StationName,db_battinf.tb_battinf.BattGroupName,db_battinf.tb_battinf.fBSDeviceId " + |
| | | "from db_battinf.tb_battinf,db_user.tb_user_battgroup_baojigroup,db_user.tb_user_battgroup_baojigroup_battgroup " + |
| | | "where db_user.tb_user_battgroup_baojigroup.baoji_group_id=db_user.tb_user_battgroup_baojigroup_battgroup.baoji_group_id " + |
| | | "and db_user.tb_user_battgroup_baojigroup_battgroup.stationid=db_battinf.tb_battinf.stationid " + |
| | | "and db_user.tb_user_battgroup_baojigroup.baoji_group_id=? and db_user.tb_user_battgroup_baojigroup_battgroup.BattGroupId = db_battinf.tb_battinf.BattGroupId " + |
| | | "order by db_battinf.tb_battinf.BattGroupId"; |
| | | List list=DAOHelper.executeQuery(sql, DBUtil.getConn(), new Object[]{ubao.getBaoji_group_id()}, new CallBack() { |
| | | |
| | | public List getResults(ResultSet rs) { |
| | | List list=new ArrayList(); |
| | | try { |
| | | while(rs.next()){ |
| | | BattInf binf=new BattInf(); |
| | | |
| | | binf.setBattGroupId(rs.getInt("battGroupId")); |
| | | binf.setStationName(rs.getString("stationName")); |
| | | binf.setStationId(rs.getString("stationid")); |
| | | binf.setBattGroupName(rs.getString("battGroupName")); |
| | | binf.setFBSDeviceId(rs.getInt("fBSDeviceId")); |
| | | list.add(binf); |
| | | } |
| | | } catch (SQLException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return list; |
| | | } |
| | | }); |
| | | return list; |
| | | } |
| | | |
| | | public static void main(String[] args) { |
| | | |
| | | User_battgroup_baojigroupImpl ub= new User_battgroup_baojigroupImpl(); |
| | | /*List<User_battgroup_baojigroup> list =ub.searchAll(); |
| | | for (User_battgroup_baojigroup u : list) { |
| | | System.out.println(u); |
| | | }*/ |
| | | /*User_battgroup_baojigroup u=new User_battgroup_baojigroup(); |
| | | u.setBaoji_group_id(100001); |
| | | List<User_inf> list =ub.serchByCondition(u); |
| | | for (User_inf uu : list) { |
| | | System.out.println(uu); |
| | | }*/ |
| | | User_battgroup_baojigroup u=new User_battgroup_baojigroup(); |
| | | u.setBaoji_group_id(100001); |
| | | List<BattInf> list =ub.serchByInfo(u); |
| | | for (BattInf b : list) { |
| | | System.out.println(b); |
| | | } |
| | | } |
| | | } |