起步软件技术论坛
搜索
 找回密码
 注册

QQ登录

只需一步,快速开始

12
返回列表 发新帖
楼主: akshay

[结贴] 消息推送服务器占用大数据库资源,导致消息推送慢

[复制链接]

33

主题

140

帖子

869

积分

高级会员

Rank: 4

积分
869
QQ
 楼主| 发表于 2021-4-9 14:42:45 | 显示全部楼层
本帖最后由 akshay 于 2021-4-9 15:05 编辑
jishuang 发表于 2021-4-9 09:04
已发送到邮箱,请查收

经过按要求修改代码后,部署到正式服测试,已完全解决问题,非常感谢提供能解决该问题,请问需要我们放出修改后的jar吗
回复 支持 反对

使用道具 举报

33

主题

140

帖子

869

积分

高级会员

Rank: 4

积分
869
QQ
 楼主| 发表于 2021-4-9 14:44:16 | 显示全部楼层
本帖最后由 akshay 于 2021-4-9 15:05 编辑

//定义两个判断用的参数
public static String orgVersion = "";
public static Map<String, Set<String>> orgs = new ConcurrentHashMap<String, Set<String>>();


private static String getOrgVersionFromDB(){
                String result = null;
                Connection con = null;
                PreparedStatement stmt = null;
                ResultSet rs = null;
                try{
                        con = DBUtils.getConnection();
                        String sql = "select sCode as sCode from SA_Code where sType='orgVersion'";
                        stmt = con.prepareStatement(sql);
                        rs = stmt.executeQuery();
                        while (rs.next()) {
                                result = rs.getString("sCode");
                                break;
                        }


                }catch(Exception e){
                        logger.error(e.getMessage()+"", e);
                }finally{
                        if (rs != null){
                                try{
                                        rs.close();
                                }catch(SQLException e){};
                        }
                        
                        if (stmt != null){
                                try{
                                        stmt.close();
                                }catch(SQLException e){};
                        }
                        
                        
                        if (con != null){
                                try {
                                        con.close();
                                } catch (SQLException e) {}
                        }
                }
                return result;
               
        }//读取企业微信的组织机构是否被修改了,如果修改了就对orgVersion重新赋值
        private synchronized static Map<String, Set<String>> getAllPerson(){

                String orgVersionFromDB = getOrgVersionFromDB();
                if (orgVersionFromDB.equals(orgVersion)){
                        return orgs;
                }else{
                        orgs = loadOrgsFromDB();
                        orgVersion = orgVersionFromDB;
                        return orgs;
                }
        }
         


private  static Map<String, Set<String>> loadOrgsFromDB(){
                Map<String, Set<String>> result = new HashMap<String, Set<String>>();
                Connection con = null;
                PreparedStatement stmt = null;
                ResultSet rs = null;
                try{
                        con = DBUtils.getConnection();
                        String sql = "select sFID as sFID, sPersonID as sPersonID from SA_OPOrg where sValidState>0 and sOrgKindID='psm'";
                        stmt = con.prepareStatement(sql);
                        rs = stmt.executeQuery();
                        while (rs.next()) {
                                String fid = rs.getString("sFID");
                                String id = rs.getString("sPersonID");
                                Set<String> fids = result.get(id);
                                if (fids == null){
                                        fids = new HashSet<String>();
                                        result.put(id, fids);
                                }
                                fids.add(fid);
                        }

                }catch(Exception e){
                        logger.error(e.getMessage()+"", e);
                }finally{
                        if (rs != null){
                                try{
                                        rs.close();
                                }catch(SQLException e){};
                        }
                        
                        if (stmt != null){
                                try{
                                        stmt.close();
                                }catch(SQLException e){};
                        }
                        
                        
                        if (con != null){
                                try {
                                        con.close();
                                } catch (SQLException e) {}
                        }
                }
                return result;
        }


回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|X3技术论坛|Justep Inc.    

GMT+8, 2024-5-5 01:15 , Processed in 0.065197 second(s), 21 queries .

Powered by Discuz! X3.4

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表