lxw
2020-06-16 23cb58a347b8dcbbff612eddcf3112c388e78967
修改包机组根据设备插入
4个文件已修改
1704 ■■■■ 已修改文件
zijing/src/com/fgkj/actions/User_battgroup_baojigroup_battgroupAction.java 335 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zijing/src/com/fgkj/dao/impl/User_battgroup_baojigroup_battgroupImpl.java 673 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zijing/src/com/fgkj/dto/User_battgroup_baojigroup_battgroup.java 132 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zijing/src/com/fgkj/services/User_battgroup_baojigroup_battgroupService.java 564 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zijing/src/com/fgkj/actions/User_battgroup_baojigroup_battgroupAction.java
@@ -1,163 +1,172 @@
package com.fgkj.actions;
import java.util.List;
import com.fgkj.dao.impl.User_battgroup_baojigroup_battgroupImpl;
import com.fgkj.dto.BattInf;
import com.fgkj.dto.ServiceModel;
import com.fgkj.dto.User_battgroup_baojigroup_battgroup;
import com.fgkj.dto.User_battgroup_baojigroup_usr;
import com.fgkj.dto.User_inf;
import com.fgkj.services.User_battgroup_baojigroup_battgroupService;
import com.google.gson.reflect.TypeToken;
import com.opensymphony.xwork2.ActionSupport;
public class User_battgroup_baojigroup_battgroupAction extends ActionSupport{
    private User_battgroup_baojigroup_battgroupService service=new User_battgroup_baojigroup_battgroupService();
    private User_inf user_inf;
    private String result;
    private String json;
    //根据用户UId查询对应的机房以及电池组
    public String serchByCondition(){
        ServiceModel model=service.serchByCondition(user_inf);
        result=ActionUtil.tojson(model);
        return SUCCESS;
    }
    /*//5.3删除选取的电池组(根据baoji_group_id,battgroupid,stationid)
    public String delete() {
        ServiceModel model=new ServiceModel();
        boolean flag=true;
        if(result!=null){
            List<User_battgroup_baojigroup_battgroup> list=ActionUtil.getGson("yyyy-MM-dd").fromJson(result,new TypeToken<List<User_battgroup_baojigroup_battgroup>>(){}.getType());
            if(list!=null && list.size()>0){
                for (User_battgroup_baojigroup_battgroup ubbb : list) {
                    model=service.delete(ubbb);
                    if(model.code==0){
                        flag=false;
                    }
                }
            }
        }
        if(flag){
            model.setCode(1);
            model.setMsg("删除电池组成功!");
        }else{
            model.setCode(0);
            model.setMsg("删除电池组失败!");
        }
        result=ActionUtil.tojson(model);
        return SUCCESS;
    }*/
    //5.3删除选取的电池组(根据baoji_group_id,battgroupid,stationid)
    public String delete() {
        List<User_battgroup_baojigroup_battgroup> list=ActionUtil.getGson("yyyy-MM-dd").fromJson(result,new TypeToken<List<User_battgroup_baojigroup_battgroup>>(){}.getType());
        ServiceModel model=service.delPro(list);
        result=ActionUtil.tojson(model);
        return SUCCESS;
    }
    //5.3添加选取电池组或者机房或者维护区(点击应用)
    public String add(){
        ServiceModel model=new ServiceModel();
        List<User_battgroup_baojigroup_battgroup> list=ActionUtil.getGson("yyyy-MM-dd").fromJson(result,new TypeToken<List<User_battgroup_baojigroup_battgroup>>(){}.getType());
        model=service.add(list);
        result=ActionUtil.tojson(model);
        return SUCCESS;
    }
    /**
     * 查询当前用户所属包机组中的所有的电池组
     * @return
     */
    public String searchMyBatts(){
        User_inf  u = (User_inf) ActionUtil.getUser();
        ServiceModel model = service.serchByCondition(u);
        result = ActionUtil.tojson(model);
        return SUCCESS;
    }
    //放电测试(查询用户管理的维护区)
    public String serchStationName1InGroup(){
        User_inf u = (User_inf) ActionUtil.getUser();
        ServiceModel model = service.serchStationName1InGroup(u);
        result = ActionUtil.tojson(model);
        return SUCCESS;
    }
    //放电测试(查询用户管理的维护区对应的机房)
    public String serchStationNameInGroup(){
        //System.out.println(json+"***********");
        User_inf u = (User_inf) ActionUtil.getUser();
        User_inf user = ActionUtil.getGson().fromJson(json, User_inf.class);
        user.setUId(u.getUId());
        //System.out.println(user);
        ServiceModel model = service.serchStationNameInGroup(user);
        result = ActionUtil.tojson(model);
        return SUCCESS;
    }
    //放电测试(查询用户管理的维护区对应的机房对应的battgroupid)
    public String serchBattgroupidInGroup(){
        User_inf u = (User_inf) ActionUtil.getUser();
        User_inf user = ActionUtil.getGson().fromJson(json, User_inf.class);
        user.setUId(u.getUId());
        ServiceModel model = service.serchBattgroupidInGroup(user);
        result = ActionUtil.tojson(model);
        return SUCCESS;
    }
    //6185下拉(查询用户管理的维护区对应的机房对应的battgroupid)
    public String serch61850DevidInGroup(){
        User_inf u = (User_inf) ActionUtil.getUser();
        ServiceModel model = service.serch61850DevidInGroup(u);
        result = ActionUtil.tojson(model);
        return SUCCESS;
    }
    //首页(查询用户管理的维护区对应的机房和机房ID以及设备id)
    public String serchStationByStationName1(){
        User_inf u = (User_inf) ActionUtil.getUser();
        User_inf user = ActionUtil.getGson().fromJson(json, User_inf.class);
        user.setUId(u.getUId());
        ServiceModel model = service.serchStationByStationName1(user);
        result = ActionUtil.tojson(model);
        return SUCCESS;
    }
    //首页(查询用户管理的维护区对应的机房信息)   ->首页左侧的导航显示
    public String serchStationInfoByStationName1(){
        User_inf u = (User_inf) ActionUtil.getUser();
        User_inf user = ActionUtil.getGson().fromJson(json, User_inf.class);
        user.setUId(u.getUId());
        ServiceModel model = service.serchStationInfoByStationName1(user);
        result = ActionUtil.tojson(model);
        return SUCCESS;
    }
    //首页左侧的导航实时刷新
    public String serchStationInfoNow(){
        List<BattInf> list = ActionUtil.getGson().fromJson(json,new TypeToken<List<BattInf>>(){}.getType());
        ServiceModel model = service.serchStationInfoNow(list);
        result = ActionUtil.tojson(model);
        return SUCCESS;
    }
    public void setJson(String json) {
        this.json = json;
    }
    public User_inf getUser_inf() {
        return user_inf;
    }
    public void setUser_inf(User_inf user_inf) {
        this.user_inf = user_inf;
    }
    public String getResult() {
        return result;
    }
    public void setResult(String result) {
        this.result = result;
    }
}
package com.fgkj.actions;
import java.util.List;
import com.fgkj.dao.impl.User_battgroup_baojigroup_battgroupImpl;
import com.fgkj.dto.BattInf;
import com.fgkj.dto.ServiceModel;
import com.fgkj.dto.User_battgroup_baojigroup_battgroup;
import com.fgkj.dto.User_battgroup_baojigroup_usr;
import com.fgkj.dto.User_inf;
import com.fgkj.services.User_battgroup_baojigroup_battgroupService;
import com.google.gson.reflect.TypeToken;
import com.opensymphony.xwork2.ActionSupport;
public class User_battgroup_baojigroup_battgroupAction extends ActionSupport{
    private User_battgroup_baojigroup_battgroupService service=new User_battgroup_baojigroup_battgroupService();
    private User_inf user_inf;
    private String result;
    private String json;
    //根据用户UId查询对应的机房以及电池组
    public String serchByCondition(){
        ServiceModel model=service.serchByCondition(user_inf);
        result=ActionUtil.tojson(model);
        return SUCCESS;
    }
    /*//5.3删除选取的电池组(根据baoji_group_id,battgroupid,stationid)
    public String delete() {
        ServiceModel model=new ServiceModel();
        boolean flag=true;
        if(result!=null){
            List<User_battgroup_baojigroup_battgroup> list=ActionUtil.getGson("yyyy-MM-dd").fromJson(result,new TypeToken<List<User_battgroup_baojigroup_battgroup>>(){}.getType());
            if(list!=null && list.size()>0){
                for (User_battgroup_baojigroup_battgroup ubbb : list) {
                    model=service.delete(ubbb);
                    if(model.code==0){
                        flag=false;
                    }
                }
            }
        }
        if(flag){
            model.setCode(1);
            model.setMsg("删除电池组成功!");
        }else{
            model.setCode(0);
            model.setMsg("删除电池组失败!");
        }
        result=ActionUtil.tojson(model);
        return SUCCESS;
    }*/
    //5.3删除选取的电池组(根据baoji_group_id,battgroupid,stationid)
    public String delete() {
        List<User_battgroup_baojigroup_battgroup> list=ActionUtil.getGson("yyyy-MM-dd").fromJson(result,new TypeToken<List<User_battgroup_baojigroup_battgroup>>(){}.getType());
        ServiceModel model=service.delPro(list);
        result=ActionUtil.tojson(model);
        return SUCCESS;
    }
    //5.3添加选取电池组或者机房或者维护区(点击应用)
    public String add(){
        ServiceModel model=new ServiceModel();
        List<User_battgroup_baojigroup_battgroup> list=ActionUtil.getGson("yyyy-MM-dd").fromJson(result,new TypeToken<List<User_battgroup_baojigroup_battgroup>>(){}.getType());
        model=service.add(list);
        result=ActionUtil.tojson(model);
        return SUCCESS;
    }
    //包机组重做(穿梭框)查询所有的用户
    public String addPro_CS(){
        ServiceModel model=new ServiceModel();
        List<User_battgroup_baojigroup_battgroup> list=ActionUtil.getGson("yyyy-MM-dd").fromJson(result,new TypeToken<List<User_battgroup_baojigroup_battgroup>>(){}.getType());
        model=service.addPro_CS(list);
        result=ActionUtil.tojson(model);
        return SUCCESS;
    }
    /**
     * 查询当前用户所属包机组中的所有的电池组
     * @return
     */
    public String searchMyBatts(){
        User_inf  u = (User_inf) ActionUtil.getUser();
        ServiceModel model = service.serchByCondition(u);
        result = ActionUtil.tojson(model);
        return SUCCESS;
    }
    //放电测试(查询用户管理的维护区)
    public String serchStationName1InGroup(){
        User_inf u = (User_inf) ActionUtil.getUser();
        ServiceModel model = service.serchStationName1InGroup(u);
        result = ActionUtil.tojson(model);
        return SUCCESS;
    }
    //放电测试(查询用户管理的维护区对应的机房)
    public String serchStationNameInGroup(){
        //System.out.println(json+"***********");
        User_inf u = (User_inf) ActionUtil.getUser();
        User_inf user = ActionUtil.getGson().fromJson(json, User_inf.class);
        user.setUId(u.getUId());
        //System.out.println(user);
        ServiceModel model = service.serchStationNameInGroup(user);
        result = ActionUtil.tojson(model);
        return SUCCESS;
    }
    //放电测试(查询用户管理的维护区对应的机房对应的battgroupid)
    public String serchBattgroupidInGroup(){
        User_inf u = (User_inf) ActionUtil.getUser();
        User_inf user = ActionUtil.getGson().fromJson(json, User_inf.class);
        user.setUId(u.getUId());
        ServiceModel model = service.serchBattgroupidInGroup(user);
        result = ActionUtil.tojson(model);
        return SUCCESS;
    }
    //6185下拉(查询用户管理的维护区对应的机房对应的battgroupid)
    public String serch61850DevidInGroup(){
        User_inf u = (User_inf) ActionUtil.getUser();
        ServiceModel model = service.serch61850DevidInGroup(u);
        result = ActionUtil.tojson(model);
        return SUCCESS;
    }
    //首页(查询用户管理的维护区对应的机房和机房ID以及设备id)
    public String serchStationByStationName1(){
        User_inf u = (User_inf) ActionUtil.getUser();
        User_inf user = ActionUtil.getGson().fromJson(json, User_inf.class);
        user.setUId(u.getUId());
        ServiceModel model = service.serchStationByStationName1(user);
        result = ActionUtil.tojson(model);
        return SUCCESS;
    }
    //首页(查询用户管理的维护区对应的机房信息)   ->首页左侧的导航显示
    public String serchStationInfoByStationName1(){
        User_inf u = (User_inf) ActionUtil.getUser();
        User_inf user = ActionUtil.getGson().fromJson(json, User_inf.class);
        user.setUId(u.getUId());
        ServiceModel model = service.serchStationInfoByStationName1(user);
        result = ActionUtil.tojson(model);
        return SUCCESS;
    }
    //首页左侧的导航实时刷新
    public String serchStationInfoNow(){
        List<BattInf> list = ActionUtil.getGson().fromJson(json,new TypeToken<List<BattInf>>(){}.getType());
        ServiceModel model = service.serchStationInfoNow(list);
        result = ActionUtil.tojson(model);
        return SUCCESS;
    }
    public void setJson(String json) {
        this.json = json;
    }
    public User_inf getUser_inf() {
        return user_inf;
    }
    public void setUser_inf(User_inf user_inf) {
        this.user_inf = user_inf;
    }
    public String getResult() {
        return result;
    }
    public void setResult(String result) {
        this.result = result;
    }
}
zijing/src/com/fgkj/dao/impl/User_battgroup_baojigroup_battgroupImpl.java
@@ -1,325 +1,348 @@
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.dao.UinfDaoFactory;
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_battgroup_baojigroup_battgroup;
import com.fgkj.dto.User_inf;
import com.fgkj.dto.User_log;
import com.fgkj.services.User_logService;
public class User_battgroup_baojigroup_battgroupImpl implements BaseDAO,CallBack{
    public List getResults(ResultSet rs) {
        List list = new ArrayList();
        try {
            while (rs.next()) {
                User_battgroup_baojigroup_battgroup userbattgroup = new User_battgroup_baojigroup_battgroup();
                userbattgroup.setNum(Integer.parseInt(rs.getString("num")));
                userbattgroup.setBaoji_group_id(Integer.parseInt(rs.getString("baoji_group_id")));
                userbattgroup.setStationId(Integer.parseInt(rs.getString("StationId")));
                userbattgroup.setBattGroupId(Integer.parseInt(rs.getString("BattGroupId")));
                list.add(userbattgroup);
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return list;
    }
    //5.3添加选取电池组或者机房或者维护区
    public boolean add(Object obj) {
        User_battgroup_baojigroup_battgroup ugroup=(User_battgroup_baojigroup_battgroup) obj;
        String sql="insert into db_user.tb_user_battgroup_baojigroup_battgroup(baoji_group_id,StationId,BattGroupId) values(?,?,?)";
        Boolean bl=DAOHelper.executeUpdate(DBUtil.getConn(), sql, new Object[]{ugroup.getBaoji_group_id(),ugroup.getStationId(),
            ugroup.getBattGroupId()});
        return bl;
    }
    //5.3添加选取电池组或者机房或者维护区(多笔数据)
    public boolean addPro(Object obj) {
        List<User_battgroup_baojigroup_battgroup> list=(List) obj;
        ArrayList sql_strs=new ArrayList();
        List<User_log> listU=new ArrayList<User_log>();//存放user_log
        if(list!=null&&list.size()>0){
            for (User_battgroup_baojigroup_battgroup ugroup : list) {
                String sql="insert into db_user.tb_user_battgroup_baojigroup_battgroup(baoji_group_id,StationId,BattGroupId) values("+ugroup.getBaoji_group_id()+","+ugroup.getStationId()+","+ugroup.getBattGroupId()+")";
                sql_strs.add(sql);
                {
                    String msg="添加"+ugroup.getNote()+"至"+ugroup.getBaoji_group_name()+"包机组中";
                    User_log ulog=UinfDaoFactory.CreateULog(UinfDaoFactory.Increase, msg);
                    listU.add(ulog);
                 }
            }
        }
        boolean bl=DAOHelper.makeManualCommit(DBUtil.getConn(), sql_strs);
        (new User_logService()).addPro(listU);//将用户的操作记录下来
        return bl;
    }
    public boolean update(Object obj) {
        User_battgroup_baojigroup_battgroup ugroup=(User_battgroup_baojigroup_battgroup) obj;
        String sql="update db_user.tb_user_battgroup_baojigroup_battgroup set baoji_group_id=?,StationId=?,BattGroupId=? where num=?";
        Boolean bl=DAOHelper.executeUpdate(DBUtil.getConn(), sql, new Object[]{ugroup.getBaoji_group_id(),ugroup.getStationId(),
            ugroup.getBattGroupId(),ugroup.getNum()});
        return bl;
    }
    //5.3删除选取的电池组
    public boolean del(Object obj) {
        User_battgroup_baojigroup_battgroup ugroup=(User_battgroup_baojigroup_battgroup) obj;
        String sql="delete from db_user.tb_user_battgroup_baojigroup_battgroup where baoji_group_id=? and battgroupid=? and stationid=?";
        Boolean bl=DAOHelper.executeUpdate(DBUtil.getConn(), sql, new Object[]{ugroup.getBaoji_group_id(),ugroup.getBattGroupId(),ugroup.getStationId()});
        return bl;
    }
    //5.3删除选取的电池组(多笔数据)
    public boolean delPro(Object obj) {
        List<User_battgroup_baojigroup_battgroup> list=(List) obj;
        ArrayList sql_strs=new ArrayList();
        List<User_log> listU=new ArrayList<User_log>();//存放user_log
        if(list!=null&&list.size()>0){
            for (User_battgroup_baojigroup_battgroup ugroup : list) {
                String sql="delete from db_user.tb_user_battgroup_baojigroup_battgroup where baoji_group_id="+ugroup.getBaoji_group_id()+" and battgroupid="+ugroup.getBattGroupId()+" and stationid="+ugroup.getStationId();
                sql_strs.add(sql);
                {
                    String msg="删除"+ugroup.getBaoji_group_name()+"包机组中"+ugroup.getNote()+"电池组";
                    User_log ulog=UinfDaoFactory.CreateULog(UinfDaoFactory.Delete, msg);
                    listU.add(ulog);
                 }
            }
        }
        boolean bl=DAOHelper.makeManualCommit(DBUtil.getConn(), sql_strs);
        (new User_logService()).addPro(listU);//将用户的操作记录下来
        return bl;
    }
    //5.3删除(删除指定包机组下所有用户)
    public String delAll(Object obj) {
        User_battgroup_baojigroup ubao=(User_battgroup_baojigroup) obj;
        String sql = "delete from db_user.tb_user_battgroup_baojigroup_battgroup where baoji_group_id="+ubao.getBaoji_group_id();
        return sql;
    }
    public List searchAll() {
        String sql = "select * from db_user.tb_user_battgroup_baojigroup_battgroup";
        List list = DAOHelper
                .executeQuery(sql, DBUtil.getConn(), null,
                        new User_battgroup_baojigroup_battgroupImpl());
        return list;
    }
    //5.1根据uid查机房和电池组
    public List serchByCondition(Object obj) {
        User_inf uinf=(User_inf) obj;
        String sql="select distinct(db_battinf.tb_battinf.stationname),db_battinf.tb_battinf.stationname1,db_battinf.tb_battinf.stationid,db_battinf.tb_battinf.battgroupid,db_battinf.tb_battinf.battgroupname " +
                "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=?  ORDER BY db_battinf.tb_battinf.stationname1,db_battinf.tb_battinf.BattGroupId";
        //System.out.println(sql);
        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()){
                                        BattInf binf=new BattInf();
                                        binf.setStationName1(rs.getString("stationName1"));
                                        binf.setStationName(rs.getString("stationName"));
                                        binf.setStationId(rs.getString("stationid"));
                                        binf.setBattGroupName(rs.getString("battGroupName"));
                                        binf.setBattGroupId(rs.getInt("battgroupid"));
                                        list.add(binf);
                                    }
                                } catch (SQLException e) {
                                    // TODO Auto-generated catch block
                                    e.printStackTrace();
                                }
                                return list;
                            }
                        });
        return list;
    }
    //放电测试(查询用户管理的维护区)
    public List serchStationName1InGroup(Object obj){
        User_inf uinf=(User_inf) obj;
        String sql="select distinct db_battinf.tb_battinf.stationname1  " +
                "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=?  ORDER BY db_battinf.tb_battinf.stationname1,db_battinf.tb_battinf.BattGroupId";
        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.getString("stationName1"));
                    }
                } catch (SQLException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
                return list;
            }
        });
        return list;
    }
    //放电测试(查询用户管理的维护区对应的机房)
    public List serchStationNameInGroup(Object obj){
        User_inf uinf=(User_inf) obj;
        String sql="select distinct db_battinf.tb_battinf.stationname  " +
                "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 db_battinf.tb_battinf.stationname1 like ? ORDER BY db_battinf.tb_battinf.stationname1,db_battinf.tb_battinf.BattGroupId";
        List list=DAOHelper.executeQuery(sql, DBUtil.getConn(), new Object[]{uinf.getUId(),"%"+uinf.getUNote()+"%"}, new CallBack() {
            public List getResults(ResultSet rs) {
                List list=new ArrayList();
                try {
                    while(rs.next()){
                        list.add(rs.getString("stationname"));
                    }
                } catch (SQLException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
                return list;
            }
        });
        return list;
    }
    //首页(查询用户管理的维护区对应的机房和机房ID以及设备id)
    public List serchStationByStationName1(Object obj){
        User_inf uinf=(User_inf) obj;
        String sql="select distinct db_battinf.tb_battinf.stationname,db_battinf.tb_battinf.stationid,db_battinf.tb_battinf.fBSDeviceId " +
                "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 db_battinf.tb_battinf.stationname1 like ? ORDER BY db_battinf.tb_battinf.stationname1,db_battinf.tb_battinf.BattGroupId";
        List list=DAOHelper.executeQuery(sql, DBUtil.getConn(), new Object[]{uinf.getUId(),"%"+uinf.getUNote()+"%"}, new CallBack() {
            public List getResults(ResultSet rs) {
                List list=new ArrayList();
                try {
                    while(rs.next()){
                        BattInf binf=new BattInf();
                        binf.setStationName(rs.getString("stationName"));
                        binf.setStationId(rs.getString("stationId"));
                        binf.setFBSDeviceId(rs.getInt("fBSDeviceId"));
                        list.add(binf);
                    }
                } catch (SQLException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
                return list;
            }
        });
        return list;
    }
    //放电测试(查询用户管理的维护区对应的机房对应的battgroupid)
    public List serchBattgroupidInGroup(Object obj){
        User_inf uinf=(User_inf) obj;
        String sql="select distinct db_battinf.tb_battinf.battgroupid,db_battinf.tb_battinf.stationName,db_battinf.tb_battinf.battgroupname,db_battinf.tb_battinf.moncount,db_battinf.tb_battinf.GroupIndexInFBSDevice,db_battinf.tb_battinf.FBSDeviceId  " +
                "from db_battinf.tb_battinf " +
                "left outer join db_user.tb_user_battgroup_baojigroup_battgroup on db_user.tb_user_battgroup_baojigroup_battgroup.BattGroupId=db_battinf.tb_battinf.BattGroupId " +
                "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 db_battinf.tb_battinf.stationname1 like ? and db_battinf.tb_battinf.stationname like ?  ORDER BY db_battinf.tb_battinf.stationname1,db_battinf.tb_battinf.BattGroupId";
        List list=DAOHelper.executeQuery(sql, DBUtil.getConn(), new Object[]{uinf.getUId(),"%"+uinf.getUNote()+"%","%"+uinf.getUName()+"%"}, 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.setBattGroupName(rs.getString("battGroupName"));
                        binf.setMonCount(rs.getInt("monCount"));
                        binf.setGroupIndexInFBSDevice(rs.getInt("GroupIndexInFBSDevice"));
                        binf.setFBSDeviceId(rs.getInt("fBSDeviceId"));
                        list.add(binf);
                    }
                } catch (SQLException e) {
                    e.printStackTrace();
                }
                return list;
            }
        });
        return list;
    }
    //6185下拉(查询用户管理的维护区对应的机房对应的battgroupid)
    public List serch61850DevidInGroup(Object obj){
        User_inf uinf=(User_inf) obj;
        String sql="select distinct db_battinf.tb_battinf.battgroupid,db_battinf.tb_battinf.stationName,db_battinf.tb_battinf.battgroupname,db_battinf.tb_battinf.moncount,db_battinf.tb_battinf.GroupIndexInFBSDevice,db_battinf.tb_battinf.FBSDeviceId  " +
                "from db_battinf.tb_battinf " +
                "left outer join db_user.tb_user_battgroup_baojigroup_battgroup on db_user.tb_user_battgroup_baojigroup_battgroup.BattGroupId=db_battinf.tb_battinf.BattGroupId " +
                "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 db_battinf.tb_battinf.FBSDeviceId like '%6185%'";
        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()){
                        BattInf binf=new BattInf();
                        binf.setBattGroupId(rs.getInt("battGroupId"));
                        binf.setStationName(rs.getString("stationName"));
                        binf.setBattGroupName(rs.getString("battGroupName"));
                        binf.setMonCount(rs.getInt("monCount"));
                        binf.setGroupIndexInFBSDevice(rs.getInt("GroupIndexInFBSDevice"));
                        binf.setFBSDeviceId(rs.getInt("fBSDeviceId"));
                        list.add(binf);
                    }
                } catch (SQLException e) {
                    e.printStackTrace();
                }
                return list;
            }
        });
        return list;
    }
    public List serchByInfo(Object obj) {
        // TODO Auto-generated method stub
        return null;
    }
    public static void main(String[] args) {
    User_battgroup_baojigroup_battgroupImpl ub= new User_battgroup_baojigroup_battgroupImpl();
    /*List<User_battgroup_baojigroup_battgroup> list =ub.searchAll();
    for (User_battgroup_baojigroup_battgroup u : list) {
        System.out.println(u);
    }*/
    User_battgroup_baojigroup_battgroup u=new User_battgroup_baojigroup_battgroup();
    u.setNum(4);
    User_inf uinf=new User_inf();
    uinf.setUId(1001);
    List<BattInf> list =ub.serchByCondition(uinf);
    for (BattInf uu : list) {
        System.out.println(uu);
    }
    System.out.println(list.size());
}
}
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.dao.UinfDaoFactory;
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_battgroup_baojigroup_battgroup;
import com.fgkj.dto.User_inf;
import com.fgkj.dto.User_log;
import com.fgkj.services.User_logService;
public class User_battgroup_baojigroup_battgroupImpl implements BaseDAO,CallBack{
    public List getResults(ResultSet rs) {
        List list = new ArrayList();
        try {
            while (rs.next()) {
                User_battgroup_baojigroup_battgroup userbattgroup = new User_battgroup_baojigroup_battgroup();
                userbattgroup.setNum(Integer.parseInt(rs.getString("num")));
                userbattgroup.setBaoji_group_id(Integer.parseInt(rs.getString("baoji_group_id")));
                userbattgroup.setStationId(Integer.parseInt(rs.getString("StationId")));
                userbattgroup.setBattGroupId(Integer.parseInt(rs.getString("BattGroupId")));
                list.add(userbattgroup);
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return list;
    }
    //5.3添加选取电池组或者机房或者维护区
    public boolean add(Object obj) {
        User_battgroup_baojigroup_battgroup ugroup=(User_battgroup_baojigroup_battgroup) obj;
        String sql="insert into db_user.tb_user_battgroup_baojigroup_battgroup(baoji_group_id,StationId,BattGroupId) values(?,?,?)";
        Boolean bl=DAOHelper.executeUpdate(DBUtil.getConn(), sql, new Object[]{ugroup.getBaoji_group_id(),ugroup.getStationId(),
            ugroup.getBattGroupId()});
        return bl;
    }
    //5.3添加选取电池组或者机房或者维护区(多笔数据)
    public boolean addPro(Object obj) {
        List<User_battgroup_baojigroup_battgroup> list=(List) obj;
        ArrayList sql_strs=new ArrayList();
        List<User_log> listU=new ArrayList<User_log>();//存放user_log
        if(list!=null&&list.size()>0){
            for (User_battgroup_baojigroup_battgroup ugroup : list) {
                String sql="insert into db_user.tb_user_battgroup_baojigroup_battgroup(baoji_group_id,StationId,BattGroupId) values("+ugroup.getBaoji_group_id()+","+ugroup.getStationId()+","+ugroup.getBattGroupId()+")";
                sql_strs.add(sql);
                {
                    String msg="添加"+ugroup.getNote()+"至"+ugroup.getBaoji_group_name()+"包机组中";
                    User_log ulog=UinfDaoFactory.CreateULog(UinfDaoFactory.Increase, msg);
                    listU.add(ulog);
                 }
            }
        }
        boolean bl=DAOHelper.makeManualCommit(DBUtil.getConn(), sql_strs);
        (new User_logService()).addPro(listU);//将用户的操作记录下来
        return bl;
    }
    //包机组重做(穿梭框)查询所有的用户
    public boolean addPro_CS(Object obj){
        List<User_battgroup_baojigroup_battgroup> list=(List) obj;
        ArrayList sql_strs=new ArrayList();
        List<User_log> listU=new ArrayList<User_log>();//存放user_log
        if(list!=null&&list.size()>0){
            for (User_battgroup_baojigroup_battgroup ugroup : list) {
                String sql="REPLACE into db_user.tb_user_battgroup_baojigroup_battgroup(baoji_group_id,StationId,BattGroupId) "
                        + " SELECT "+ugroup.getBaoji_group_id()+",StationId,BattGroupId from db_battinf.tb_battinf where FBSDeviceId="+ugroup.getDev_id() ;
                sql_strs.add(sql);
                {
                    String msg="添加"+ugroup.getNote()+"至"+ugroup.getBaoji_group_name()+"包机组中";
                    User_log ulog=UinfDaoFactory.CreateULog(UinfDaoFactory.Increase, msg);
                    listU.add(ulog);
                 }
            }
        }
        boolean bl=DAOHelper.makeManualCommit(DBUtil.getConn(), sql_strs);
        (new User_logService()).addPro(listU);//将用户的操作记录下来
        return bl;
    }
    public boolean update(Object obj) {
        User_battgroup_baojigroup_battgroup ugroup=(User_battgroup_baojigroup_battgroup) obj;
        String sql="update db_user.tb_user_battgroup_baojigroup_battgroup set baoji_group_id=?,StationId=?,BattGroupId=? where num=?";
        Boolean bl=DAOHelper.executeUpdate(DBUtil.getConn(), sql, new Object[]{ugroup.getBaoji_group_id(),ugroup.getStationId(),
            ugroup.getBattGroupId(),ugroup.getNum()});
        return bl;
    }
    //5.3删除选取的电池组
    public boolean del(Object obj) {
        User_battgroup_baojigroup_battgroup ugroup=(User_battgroup_baojigroup_battgroup) obj;
        String sql="delete from db_user.tb_user_battgroup_baojigroup_battgroup where baoji_group_id=? and battgroupid=? and stationid=?";
        Boolean bl=DAOHelper.executeUpdate(DBUtil.getConn(), sql, new Object[]{ugroup.getBaoji_group_id(),ugroup.getBattGroupId(),ugroup.getStationId()});
        return bl;
    }
    //5.3删除选取的电池组(多笔数据)
    public boolean delPro(Object obj) {
        List<User_battgroup_baojigroup_battgroup> list=(List) obj;
        ArrayList sql_strs=new ArrayList();
        List<User_log> listU=new ArrayList<User_log>();//存放user_log
        if(list!=null&&list.size()>0){
            for (User_battgroup_baojigroup_battgroup ugroup : list) {
                String sql="delete from db_user.tb_user_battgroup_baojigroup_battgroup where baoji_group_id="+ugroup.getBaoji_group_id()+" and battgroupid="+ugroup.getBattGroupId()+" and stationid="+ugroup.getStationId();
                sql_strs.add(sql);
                {
                    String msg="删除"+ugroup.getBaoji_group_name()+"包机组中"+ugroup.getNote()+"电池组";
                    User_log ulog=UinfDaoFactory.CreateULog(UinfDaoFactory.Delete, msg);
                    listU.add(ulog);
                 }
            }
        }
        boolean bl=DAOHelper.makeManualCommit(DBUtil.getConn(), sql_strs);
        (new User_logService()).addPro(listU);//将用户的操作记录下来
        return bl;
    }
    //5.3删除(删除指定包机组下所有用户)
    public String delAll(Object obj) {
        User_battgroup_baojigroup ubao=(User_battgroup_baojigroup) obj;
        String sql = "delete from db_user.tb_user_battgroup_baojigroup_battgroup where baoji_group_id="+ubao.getBaoji_group_id();
        return sql;
    }
    public List searchAll() {
        String sql = "select * from db_user.tb_user_battgroup_baojigroup_battgroup";
        List list = DAOHelper
                .executeQuery(sql, DBUtil.getConn(), null,
                        new User_battgroup_baojigroup_battgroupImpl());
        return list;
    }
    //5.1根据uid查机房和电池组
    public List serchByCondition(Object obj) {
        User_inf uinf=(User_inf) obj;
        String sql="select distinct(db_battinf.tb_battinf.stationname),db_battinf.tb_battinf.stationname1,db_battinf.tb_battinf.stationid,db_battinf.tb_battinf.battgroupid,db_battinf.tb_battinf.battgroupname " +
                "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=?  ORDER BY db_battinf.tb_battinf.stationname1,db_battinf.tb_battinf.BattGroupId";
        //System.out.println(sql);
        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()){
                                        BattInf binf=new BattInf();
                                        binf.setStationName1(rs.getString("stationName1"));
                                        binf.setStationName(rs.getString("stationName"));
                                        binf.setStationId(rs.getString("stationid"));
                                        binf.setBattGroupName(rs.getString("battGroupName"));
                                        binf.setBattGroupId(rs.getInt("battgroupid"));
                                        list.add(binf);
                                    }
                                } catch (SQLException e) {
                                    // TODO Auto-generated catch block
                                    e.printStackTrace();
                                }
                                return list;
                            }
                        });
        return list;
    }
    //放电测试(查询用户管理的维护区)
    public List serchStationName1InGroup(Object obj){
        User_inf uinf=(User_inf) obj;
        String sql="select distinct db_battinf.tb_battinf.stationname1  " +
                "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=?  ORDER BY db_battinf.tb_battinf.stationname1,db_battinf.tb_battinf.BattGroupId";
        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.getString("stationName1"));
                    }
                } catch (SQLException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
                return list;
            }
        });
        return list;
    }
    //放电测试(查询用户管理的维护区对应的机房)
    public List serchStationNameInGroup(Object obj){
        User_inf uinf=(User_inf) obj;
        String sql="select distinct db_battinf.tb_battinf.stationname  " +
                "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 db_battinf.tb_battinf.stationname1 like ? ORDER BY db_battinf.tb_battinf.stationname1,db_battinf.tb_battinf.BattGroupId";
        List list=DAOHelper.executeQuery(sql, DBUtil.getConn(), new Object[]{uinf.getUId(),"%"+uinf.getUNote()+"%"}, new CallBack() {
            public List getResults(ResultSet rs) {
                List list=new ArrayList();
                try {
                    while(rs.next()){
                        list.add(rs.getString("stationname"));
                    }
                } catch (SQLException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
                return list;
            }
        });
        return list;
    }
    //首页(查询用户管理的维护区对应的机房和机房ID以及设备id)
    public List serchStationByStationName1(Object obj){
        User_inf uinf=(User_inf) obj;
        String sql="select distinct db_battinf.tb_battinf.stationname,db_battinf.tb_battinf.stationid,db_battinf.tb_battinf.fBSDeviceId " +
                "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 db_battinf.tb_battinf.stationname1 like ? ORDER BY db_battinf.tb_battinf.stationname1,db_battinf.tb_battinf.BattGroupId";
        List list=DAOHelper.executeQuery(sql, DBUtil.getConn(), new Object[]{uinf.getUId(),"%"+uinf.getUNote()+"%"}, new CallBack() {
            public List getResults(ResultSet rs) {
                List list=new ArrayList();
                try {
                    while(rs.next()){
                        BattInf binf=new BattInf();
                        binf.setStationName(rs.getString("stationName"));
                        binf.setStationId(rs.getString("stationId"));
                        binf.setFBSDeviceId(rs.getInt("fBSDeviceId"));
                        list.add(binf);
                    }
                } catch (SQLException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
                return list;
            }
        });
        return list;
    }
    //放电测试(查询用户管理的维护区对应的机房对应的battgroupid)
    public List serchBattgroupidInGroup(Object obj){
        User_inf uinf=(User_inf) obj;
        String sql="select distinct db_battinf.tb_battinf.battgroupid,db_battinf.tb_battinf.stationName,db_battinf.tb_battinf.battgroupname,db_battinf.tb_battinf.moncount,db_battinf.tb_battinf.GroupIndexInFBSDevice,db_battinf.tb_battinf.FBSDeviceId  " +
                "from db_battinf.tb_battinf " +
                "left outer join db_user.tb_user_battgroup_baojigroup_battgroup on db_user.tb_user_battgroup_baojigroup_battgroup.BattGroupId=db_battinf.tb_battinf.BattGroupId " +
                "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 db_battinf.tb_battinf.stationname1 like ? and db_battinf.tb_battinf.stationname like ?  ORDER BY db_battinf.tb_battinf.stationname1,db_battinf.tb_battinf.BattGroupId";
        List list=DAOHelper.executeQuery(sql, DBUtil.getConn(), new Object[]{uinf.getUId(),"%"+uinf.getUNote()+"%","%"+uinf.getUName()+"%"}, 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.setBattGroupName(rs.getString("battGroupName"));
                        binf.setMonCount(rs.getInt("monCount"));
                        binf.setGroupIndexInFBSDevice(rs.getInt("GroupIndexInFBSDevice"));
                        binf.setFBSDeviceId(rs.getInt("fBSDeviceId"));
                        list.add(binf);
                    }
                } catch (SQLException e) {
                    e.printStackTrace();
                }
                return list;
            }
        });
        return list;
    }
    //6185下拉(查询用户管理的维护区对应的机房对应的battgroupid)
    public List serch61850DevidInGroup(Object obj){
        User_inf uinf=(User_inf) obj;
        String sql="select distinct db_battinf.tb_battinf.battgroupid,db_battinf.tb_battinf.stationName,db_battinf.tb_battinf.battgroupname,db_battinf.tb_battinf.moncount,db_battinf.tb_battinf.GroupIndexInFBSDevice,db_battinf.tb_battinf.FBSDeviceId  " +
                "from db_battinf.tb_battinf " +
                "left outer join db_user.tb_user_battgroup_baojigroup_battgroup on db_user.tb_user_battgroup_baojigroup_battgroup.BattGroupId=db_battinf.tb_battinf.BattGroupId " +
                "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 db_battinf.tb_battinf.FBSDeviceId like '%6185%'";
        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()){
                        BattInf binf=new BattInf();
                        binf.setBattGroupId(rs.getInt("battGroupId"));
                        binf.setStationName(rs.getString("stationName"));
                        binf.setBattGroupName(rs.getString("battGroupName"));
                        binf.setMonCount(rs.getInt("monCount"));
                        binf.setGroupIndexInFBSDevice(rs.getInt("GroupIndexInFBSDevice"));
                        binf.setFBSDeviceId(rs.getInt("fBSDeviceId"));
                        list.add(binf);
                    }
                } catch (SQLException e) {
                    e.printStackTrace();
                }
                return list;
            }
        });
        return list;
    }
    public List serchByInfo(Object obj) {
        // TODO Auto-generated method stub
        return null;
    }
    public static void main(String[] args) {
    User_battgroup_baojigroup_battgroupImpl ub= new User_battgroup_baojigroup_battgroupImpl();
    /*List<User_battgroup_baojigroup_battgroup> list =ub.searchAll();
    for (User_battgroup_baojigroup_battgroup u : list) {
        System.out.println(u);
    }*/
    User_battgroup_baojigroup_battgroup u=new User_battgroup_baojigroup_battgroup();
    u.setNum(4);
    User_inf uinf=new User_inf();
    uinf.setUId(1001);
    List<BattInf> list =ub.serchByCondition(uinf);
    for (BattInf uu : list) {
        System.out.println(uu);
    }
    System.out.println(list.size());
}
}
zijing/src/com/fgkj/dto/User_battgroup_baojigroup_battgroup.java
@@ -1,62 +1,70 @@
package com.fgkj.dto;
public class User_battgroup_baojigroup_battgroup {
    private Integer num;
    private Integer baoji_group_id;
    private String baoji_group_name;
    private Integer StationId;
    private Integer BattGroupId;
    private String note;
    public User_battgroup_baojigroup_battgroup() {
        super();
        // TODO Auto-generated constructor stub
    }
    public Integer getNum() {
        return num;
    }
    public void setNum(Integer num) {
        this.num = num;
    }
    public Integer getBaoji_group_id() {
        return baoji_group_id;
    }
    public void setBaoji_group_id(Integer baoji_group_id) {
        this.baoji_group_id = baoji_group_id;
    }
    public Integer getStationId() {
        return StationId;
    }
    public void setStationId(Integer stationId) {
        StationId = stationId;
    }
    public Integer getBattGroupId() {
        return BattGroupId;
    }
    public void setBattGroupId(Integer battGroupId) {
        BattGroupId = battGroupId;
    }
    public String getBaoji_group_name() {
        return baoji_group_name;
    }
    public void setBaoji_group_name(String baoji_group_name) {
        this.baoji_group_name = baoji_group_name;
    }
    public String getNote() {
        return note;
    }
    public void setNote(String note) {
        this.note = note;
    }
    @Override
    public String toString() {
        return "User_battgroup_baojigroup_battgroup [num=" + num
                + ", baoji_group_id=" + baoji_group_id + ", baoji_group_name="
                + baoji_group_name + ", StationId=" + StationId
                + ", BattGroupId=" + BattGroupId + ", note=" + note + "]";
    }
}
package com.fgkj.dto;
public class User_battgroup_baojigroup_battgroup {
    private Integer num;
    private Integer baoji_group_id;
    private String baoji_group_name;
    private Integer StationId;
    private Integer BattGroupId;
    private Integer dev_id;
    private String note;
    public User_battgroup_baojigroup_battgroup() {
        super();
        // TODO Auto-generated constructor stub
    }
    public Integer getNum() {
        return num;
    }
    public void setNum(Integer num) {
        this.num = num;
    }
    public Integer getBaoji_group_id() {
        return baoji_group_id;
    }
    public void setBaoji_group_id(Integer baoji_group_id) {
        this.baoji_group_id = baoji_group_id;
    }
    public Integer getStationId() {
        return StationId;
    }
    public void setStationId(Integer stationId) {
        StationId = stationId;
    }
    public Integer getBattGroupId() {
        return BattGroupId;
    }
    public void setBattGroupId(Integer battGroupId) {
        BattGroupId = battGroupId;
    }
    public String getBaoji_group_name() {
        return baoji_group_name;
    }
    public void setBaoji_group_name(String baoji_group_name) {
        this.baoji_group_name = baoji_group_name;
    }
    public String getNote() {
        return note;
    }
    public void setNote(String note) {
        this.note = note;
    }
    public Integer getDev_id() {
        return dev_id;
    }
    public void setDev_id(Integer dev_id) {
        this.dev_id = dev_id;
    }
    @Override
    public String toString() {
        return "User_battgroup_baojigroup_battgroup [num=" + num
                + ", baoji_group_id=" + baoji_group_id + ", baoji_group_name="
                + baoji_group_name + ", StationId=" + StationId
                + ", BattGroupId=" + BattGroupId + ", dev_id=" + dev_id
                + ", note=" + note + "]";
    }
}
zijing/src/com/fgkj/services/User_battgroup_baojigroup_battgroupService.java
@@ -1,276 +1,288 @@
package com.fgkj.services;
import java.util.List;
import com.fgkj.dao.BaseDAO;
import com.fgkj.dao.BaseDAOFactory;
import com.fgkj.dao.impl.BadBatt_monImpl;
import com.fgkj.dao.impl.BattDischarge_planImpl;
import com.fgkj.dao.impl.BattInfImpl;
import com.fgkj.dao.impl.Battalarm_dataDAOImpl;
import com.fgkj.dao.impl.User_battgroup_baojigroup_battgroupImpl;
import com.fgkj.dao.impl.ram.Fbs9100_stateImpl;
import com.fgkj.dto.BattInf;
import com.fgkj.dto.BattMap_information;
import com.fgkj.dto.ServiceModel;
import com.fgkj.dto.User_battgroup_baojigroup_battgroup;
import com.fgkj.dto.User_inf;
public class User_battgroup_baojigroup_battgroupService {
    private ServiceModel model;
    private BaseDAO dao;
    public User_battgroup_baojigroup_battgroupService() {
        model = new ServiceModel();
        dao = BaseDAOFactory.getBaseDAO(BaseDAO.USER_BATTGROUP_BAOJIGROUP_BATTGROUP);
    }
    /*//5.3添加选取电池组或者机房或者维护区(点击应用)
    public ServiceModel add(Object obj) {
        List<User_battgroup_baojigroup_battgroup> list=(List<User_battgroup_baojigroup_battgroup>) obj;
        Boolean bl=false;
        if(list!=null&&list.size()>0){
            for(int i=0;i<list.size();i++){
                bl=dao.add(list.get(i));
            }
        }
        if(bl){
            model.setCode(1);
            model.setMsg("添加成功!");
        }
        else{
            model.setMsg("添加失败!");
        }
        return model;
    }*/
    //5.3添加选取电池组或者机房或者维护区(点击应用)
    public ServiceModel add(Object obj) {
        Boolean bl=((User_battgroup_baojigroup_battgroupImpl)dao).addPro(obj);
        if(bl){
            model.setCode(1);
            model.setMsg("添加成功!");
        }
        else{
            model.setMsg("添加失败!");
        }
        return model;
    }
    public ServiceModel update(Object obj) {
        Boolean bl=dao.update(obj);
        if(bl){
            model.setCode(1);
            model.setMsg("修改成功!");
        }
        else{
            model.setMsg("修改失败!");
        }
        return model;
    }
    //5.3删除选取的电池组(根据baoji_group_id,battgroupid,stationid)
    public ServiceModel delete(Object obj) {
        Boolean bl=dao.del(obj);
        if(bl){
            model.setCode(1);
            model.setMsg("删除成功!");
        }
        else{
            model.setMsg("删除失败!");
        }
        return model;
    }
    //5.3删除选取的电池组(根据baoji_group_id,battgroupid,stationid)(多笔)
    public ServiceModel delPro(Object obj) {
        Boolean bl=((User_battgroup_baojigroup_battgroupImpl)dao).delPro(obj);
        if(bl){
            model.setCode(1);
            model.setMsg("删除成功!");
        }
        else{
            model.setMsg("删除失败!");
        }
        return model;
    }
    //5.1根据员工uid查电池组和机房信息
    public ServiceModel serchByCondition(Object obj){
        List list=dao.serchByCondition(obj);
        if(list!=null && list.size()>0){
            model.setCode(1);
            model.setData(list);
            model.setMsg("查询成功");
        }else{
            model.setCode(0);
            model.setMsg("查询失败");
        }
        return model;
    }
    public ServiceModel searchAll() {
        List<User_battgroup_baojigroup_battgroup> list = dao.searchAll();
//        for (User_battgroup_baojigroup_battgroup u : list) {
//            System.out.println(u);
//        }
        if (list != null && list.size() > 0) {
            model.setCode(1);
            model.setData(list);
        }
        return model;
    }
    //放电测试(查询用户管理的维护区)
    public ServiceModel serchStationName1InGroup(Object obj){
        List list=((User_battgroup_baojigroup_battgroupImpl)dao).serchStationName1InGroup(obj);
        if(list!=null && list.size()>0){
            model.setCode(1);
            model.setData(list);
            model.setMsg("查询成功");
        }else{
            model.setCode(0);
            model.setMsg("查询失败");
        }
        return model;
    }
    //放电测试(查询用户管理的维护区对应的机房)
    public ServiceModel serchStationNameInGroup(Object obj){
        List list=((User_battgroup_baojigroup_battgroupImpl)dao).serchStationNameInGroup(obj);
        if(list!=null && list.size()>0){
            model.setCode(1);
            model.setData(list);
            model.setMsg("查询成功");
        }else{
            model.setCode(0);
            model.setMsg("查询失败");
        }
        return model;
    }
    //放电测试(查询用户管理的维护区对应的机房对应的battgroupid)
    public ServiceModel serchBattgroupidInGroup(Object obj){
        List list=((User_battgroup_baojigroup_battgroupImpl)dao).serchBattgroupidInGroup(obj);
        if(list!=null && list.size()>0){
            model.setCode(1);
            model.setData(list);
            model.setMsg("查询成功");
        }else{
            model.setCode(0);
            model.setMsg("查询失败");
        }
        return model;
    }
    //6185下拉(查询用户管理的维护区对应的机房对应的battgroupid)
    public ServiceModel serch61850DevidInGroup(Object obj){
        List list=((User_battgroup_baojigroup_battgroupImpl)dao).serch61850DevidInGroup(obj);
        if(list!=null && list.size()>0){
            model.setCode(1);
            model.setData(list);
            model.setMsg("查询成功");
        }else{
            model.setCode(0);
            model.setMsg("查询失败");
        }
        return model;
    }
    //首页(查询用户管理的维护区对应的机房和机房ID以及设备id)
    public ServiceModel serchStationByStationName1(Object obj){
        List list=((User_battgroup_baojigroup_battgroupImpl)dao).serchStationByStationName1(obj);
        if(list!=null && list.size()>0){
            model.setCode(1);
            model.setData(list);
            model.setMsg("查询成功");
        }else{
            model.setCode(0);
            model.setMsg("查询失败");
        }
        return model;
    }
    //SignalId  ->存放当前机房的状态class
    //首页(查询用户管理的维护区对应的机房信息)   ->首页左侧的导航显示
    public ServiceModel serchStationInfoByStationName1(Object obj){
        List<BattInf> list=((User_battgroup_baojigroup_battgroupImpl)dao).serchStationByStationName1(obj);
        if(list!=null && list.size()>0){
            for(int i = 0 ; i < list.size();i++){
                list.get(i).setSignalId("item-normal");                        //正常机房
                if(list.get(i).getFBSDeviceId()/100000==6185){
                        String dev_workstate=(new Fbs9100_stateImpl().seachDevNow(list.get(i)));   //61850工作状态
                        list.get(i).setSignalId(dev_workstate);
                }else{
                        BattMap_information bmap = new BattMap_information();
                        bmap.setStationId(list.get(i).getStationId());
                        int numBadBatt=(new BadBatt_monImpl()).serchByStationId(bmap);                //落后总数
                        if(numBadBatt>0){
                            list.get(i).setSignalId("item-behind");                                    //落后机房
                        }else{
                            int numAlarm=(new Battalarm_dataDAOImpl()).serchByStationId(bmap);        //告警总数
                            if(numAlarm > 0){
                                list.get(i).setSignalId("item-warn");                                //告警机房
                            }else{
                                int numPlan=(new BattDischarge_planImpl()).serchByStationId(bmap);    //延迟总数
                                if(numPlan > 0){
                                    list.get(i).setSignalId("item-timeout");                        //延迟机房
                                }
                            }
                        }
                }
            }
            model.setCode(1);
            model.setData(list);
            model.setMsg("查询成功");
        }else{
            model.setCode(0);
            model.setMsg("查询失败");
        }
        return model;
    }
    //SignalId  ->存放当前机房的状态class
    //首页左侧的导航显示实时刷新
    public ServiceModel serchStationInfoNow(Object obj){
        List<BattInf> list=(List<BattInf>) obj;
        if(list!=null && list.size()>0){
            for(int i = 0 ; i < list.size();i++){
                list.get(i).setSignalId("item-normal");                        //正常机房
                if(list.get(i).getFBSDeviceId()/100000==6185){
                        String dev_workstate=(new Fbs9100_stateImpl().seachDevNow(list.get(i)));   //61850工作状态
                        list.get(i).setSignalId(dev_workstate);
                }else{
                        BattMap_information bmap = new BattMap_information();
                        bmap.setStationId(list.get(i).getStationId());
                        int numBadBatt=(new BadBatt_monImpl()).serchByStationId(bmap);                //落后总数
                        if(numBadBatt>0){
                            list.get(i).setSignalId("item-behind");                                    //落后机房
                        }else{
                            int numAlarm=(new Battalarm_dataDAOImpl()).serchByStationId(bmap);        //告警总数
                            if(numAlarm > 0){
                                list.get(i).setSignalId("item-warn");                                //告警机房
                            }else{
                                int numPlan=(new BattDischarge_planImpl()).serchByStationId(bmap);    //延迟总数
                                if(numPlan > 0){
                                    list.get(i).setSignalId("item-timeout");                        //延迟机房
                                }
                            }
                        }
                }
            }
            model.setCode(1);
            model.setData(list);
            model.setMsg("查询成功");
        }else{
            model.setCode(0);
            model.setMsg("查询失败");
        }
        return model;
    }
    public static void main(String[] args) {
        User_battgroup_baojigroup_battgroupService us = new User_battgroup_baojigroup_battgroupService();
        //User_battgroup_baojigroup_battgroup u=new User_battgroup_baojigroup_battgroup();
       // u.setNum(74);
        User_inf uinf=new User_inf();
        uinf.setUId(1001);
        //us.serchByCondition(uinf);
        us.searchAll();
    }
}
package com.fgkj.services;
import java.util.List;
import com.fgkj.dao.BaseDAO;
import com.fgkj.dao.BaseDAOFactory;
import com.fgkj.dao.impl.BadBatt_monImpl;
import com.fgkj.dao.impl.BattDischarge_planImpl;
import com.fgkj.dao.impl.BattInfImpl;
import com.fgkj.dao.impl.Battalarm_dataDAOImpl;
import com.fgkj.dao.impl.User_battgroup_baojigroup_battgroupImpl;
import com.fgkj.dao.impl.ram.Fbs9100_stateImpl;
import com.fgkj.dto.BattInf;
import com.fgkj.dto.BattMap_information;
import com.fgkj.dto.ServiceModel;
import com.fgkj.dto.User_battgroup_baojigroup_battgroup;
import com.fgkj.dto.User_inf;
public class User_battgroup_baojigroup_battgroupService {
    private ServiceModel model;
    private BaseDAO dao;
    public User_battgroup_baojigroup_battgroupService() {
        model = new ServiceModel();
        dao = BaseDAOFactory.getBaseDAO(BaseDAO.USER_BATTGROUP_BAOJIGROUP_BATTGROUP);
    }
    /*//5.3添加选取电池组或者机房或者维护区(点击应用)
    public ServiceModel add(Object obj) {
        List<User_battgroup_baojigroup_battgroup> list=(List<User_battgroup_baojigroup_battgroup>) obj;
        Boolean bl=false;
        if(list!=null&&list.size()>0){
            for(int i=0;i<list.size();i++){
                bl=dao.add(list.get(i));
            }
        }
        if(bl){
            model.setCode(1);
            model.setMsg("添加成功!");
        }
        else{
            model.setMsg("添加失败!");
        }
        return model;
    }*/
    //5.3添加选取电池组或者机房或者维护区(点击应用)
    public ServiceModel add(Object obj) {
        Boolean bl=((User_battgroup_baojigroup_battgroupImpl)dao).addPro(obj);
        if(bl){
            model.setCode(1);
            model.setMsg("添加成功!");
        }
        else{
            model.setMsg("添加失败!");
        }
        return model;
    }
    //包机组重做(穿梭框)查询所有的用户
    public ServiceModel addPro_CS(Object obj) {
        Boolean bl=((User_battgroup_baojigroup_battgroupImpl)dao).addPro_CS(obj);
        if(bl){
            model.setCode(1);
            model.setMsg("添加成功!");
        }
        else{
            model.setMsg("添加失败!");
        }
        return model;
    }
    public ServiceModel update(Object obj) {
        Boolean bl=dao.update(obj);
        if(bl){
            model.setCode(1);
            model.setMsg("修改成功!");
        }
        else{
            model.setMsg("修改失败!");
        }
        return model;
    }
    //5.3删除选取的电池组(根据baoji_group_id,battgroupid,stationid)
    public ServiceModel delete(Object obj) {
        Boolean bl=dao.del(obj);
        if(bl){
            model.setCode(1);
            model.setMsg("删除成功!");
        }
        else{
            model.setMsg("删除失败!");
        }
        return model;
    }
    //5.3删除选取的电池组(根据baoji_group_id,battgroupid,stationid)(多笔)
    public ServiceModel delPro(Object obj) {
        Boolean bl=((User_battgroup_baojigroup_battgroupImpl)dao).delPro(obj);
        if(bl){
            model.setCode(1);
            model.setMsg("删除成功!");
        }
        else{
            model.setMsg("删除失败!");
        }
        return model;
    }
    //5.1根据员工uid查电池组和机房信息
    public ServiceModel serchByCondition(Object obj){
        List list=dao.serchByCondition(obj);
        if(list!=null && list.size()>0){
            model.setCode(1);
            model.setData(list);
            model.setMsg("查询成功");
        }else{
            model.setCode(0);
            model.setMsg("查询失败");
        }
        return model;
    }
    public ServiceModel searchAll() {
        List<User_battgroup_baojigroup_battgroup> list = dao.searchAll();
//        for (User_battgroup_baojigroup_battgroup u : list) {
//            System.out.println(u);
//        }
        if (list != null && list.size() > 0) {
            model.setCode(1);
            model.setData(list);
        }
        return model;
    }
    //放电测试(查询用户管理的维护区)
    public ServiceModel serchStationName1InGroup(Object obj){
        List list=((User_battgroup_baojigroup_battgroupImpl)dao).serchStationName1InGroup(obj);
        if(list!=null && list.size()>0){
            model.setCode(1);
            model.setData(list);
            model.setMsg("查询成功");
        }else{
            model.setCode(0);
            model.setMsg("查询失败");
        }
        return model;
    }
    //放电测试(查询用户管理的维护区对应的机房)
    public ServiceModel serchStationNameInGroup(Object obj){
        List list=((User_battgroup_baojigroup_battgroupImpl)dao).serchStationNameInGroup(obj);
        if(list!=null && list.size()>0){
            model.setCode(1);
            model.setData(list);
            model.setMsg("查询成功");
        }else{
            model.setCode(0);
            model.setMsg("查询失败");
        }
        return model;
    }
    //放电测试(查询用户管理的维护区对应的机房对应的battgroupid)
    public ServiceModel serchBattgroupidInGroup(Object obj){
        List list=((User_battgroup_baojigroup_battgroupImpl)dao).serchBattgroupidInGroup(obj);
        if(list!=null && list.size()>0){
            model.setCode(1);
            model.setData(list);
            model.setMsg("查询成功");
        }else{
            model.setCode(0);
            model.setMsg("查询失败");
        }
        return model;
    }
    //6185下拉(查询用户管理的维护区对应的机房对应的battgroupid)
    public ServiceModel serch61850DevidInGroup(Object obj){
        List list=((User_battgroup_baojigroup_battgroupImpl)dao).serch61850DevidInGroup(obj);
        if(list!=null && list.size()>0){
            model.setCode(1);
            model.setData(list);
            model.setMsg("查询成功");
        }else{
            model.setCode(0);
            model.setMsg("查询失败");
        }
        return model;
    }
    //首页(查询用户管理的维护区对应的机房和机房ID以及设备id)
    public ServiceModel serchStationByStationName1(Object obj){
        List list=((User_battgroup_baojigroup_battgroupImpl)dao).serchStationByStationName1(obj);
        if(list!=null && list.size()>0){
            model.setCode(1);
            model.setData(list);
            model.setMsg("查询成功");
        }else{
            model.setCode(0);
            model.setMsg("查询失败");
        }
        return model;
    }
    //SignalId  ->存放当前机房的状态class
    //首页(查询用户管理的维护区对应的机房信息)   ->首页左侧的导航显示
    public ServiceModel serchStationInfoByStationName1(Object obj){
        List<BattInf> list=((User_battgroup_baojigroup_battgroupImpl)dao).serchStationByStationName1(obj);
        if(list!=null && list.size()>0){
            for(int i = 0 ; i < list.size();i++){
                list.get(i).setSignalId("item-normal");                        //正常机房
                if(list.get(i).getFBSDeviceId()/100000==6185){
                        String dev_workstate=(new Fbs9100_stateImpl().seachDevNow(list.get(i)));   //61850工作状态
                        list.get(i).setSignalId(dev_workstate);
                }else{
                        BattMap_information bmap = new BattMap_information();
                        bmap.setStationId(list.get(i).getStationId());
                        int numBadBatt=(new BadBatt_monImpl()).serchByStationId(bmap);                //落后总数
                        if(numBadBatt>0){
                            list.get(i).setSignalId("item-behind");                                    //落后机房
                        }else{
                            int numAlarm=(new Battalarm_dataDAOImpl()).serchByStationId(bmap);        //告警总数
                            if(numAlarm > 0){
                                list.get(i).setSignalId("item-warn");                                //告警机房
                            }else{
                                int numPlan=(new BattDischarge_planImpl()).serchByStationId(bmap);    //延迟总数
                                if(numPlan > 0){
                                    list.get(i).setSignalId("item-timeout");                        //延迟机房
                                }
                            }
                        }
                }
            }
            model.setCode(1);
            model.setData(list);
            model.setMsg("查询成功");
        }else{
            model.setCode(0);
            model.setMsg("查询失败");
        }
        return model;
    }
    //SignalId  ->存放当前机房的状态class
    //首页左侧的导航显示实时刷新
    public ServiceModel serchStationInfoNow(Object obj){
        List<BattInf> list=(List<BattInf>) obj;
        if(list!=null && list.size()>0){
            for(int i = 0 ; i < list.size();i++){
                list.get(i).setSignalId("item-normal");                        //正常机房
                if(list.get(i).getFBSDeviceId()/100000==6185){
                        String dev_workstate=(new Fbs9100_stateImpl().seachDevNow(list.get(i)));   //61850工作状态
                        list.get(i).setSignalId(dev_workstate);
                }else{
                        BattMap_information bmap = new BattMap_information();
                        bmap.setStationId(list.get(i).getStationId());
                        int numBadBatt=(new BadBatt_monImpl()).serchByStationId(bmap);                //落后总数
                        if(numBadBatt>0){
                            list.get(i).setSignalId("item-behind");                                    //落后机房
                        }else{
                            int numAlarm=(new Battalarm_dataDAOImpl()).serchByStationId(bmap);        //告警总数
                            if(numAlarm > 0){
                                list.get(i).setSignalId("item-warn");                                //告警机房
                            }else{
                                int numPlan=(new BattDischarge_planImpl()).serchByStationId(bmap);    //延迟总数
                                if(numPlan > 0){
                                    list.get(i).setSignalId("item-timeout");                        //延迟机房
                                }
                            }
                        }
                }
            }
            model.setCode(1);
            model.setData(list);
            model.setMsg("查询成功");
        }else{
            model.setCode(0);
            model.setMsg("查询失败");
        }
        return model;
    }
    public static void main(String[] args) {
        User_battgroup_baojigroup_battgroupService us = new User_battgroup_baojigroup_battgroupService();
        //User_battgroup_baojigroup_battgroup u=new User_battgroup_baojigroup_battgroup();
       // u.setNum(74);
        User_inf uinf=new User_inf();
        uinf.setUId(1001);
        //us.serchByCondition(uinf);
        us.searchAll();
    }
}