List companyList=getCompanyList();
for(JSONObject company:companyList){
List todayBirthdays=getBirthdayUsers(getdate(0),company.getString("id"));
StringBuffer name=new StringBuffer();
StringBuffer ids=new StringBuffer();
StringBuilder hrsb = new StringBuilder();
ids.append("'");
ids.append("2017121618514C22B68296F31AF8DDE2");//不给XX发
ids.append("'");
ids.append(",");
String userIds ="";
if(todayBirthdays.size()>0){
for (JSONObject o : todayBirthdays) {
name.append(",");
name.append(o.getString("name"));
ids.append("'");
ids.append(o.getString("id"));
ids.append("'");
ids.append(",");
}
userIds = ids.toString().substring(0, ids.toString().length() - 1);
if (name.length() > 0) {
name.deleteCharAt(0);
}
List remindUsers=userDao.getViewJSONListByCondition(" AND companyId=? AND jobState!=1 AND id NOT in("+userIds+") GROUP BY id",new Object[]{company.getString("id")});
for (JSONObject hrUser : remindUsers) {
hrsb.append("|");
hrsb.append(hrUser.getString("id"));
}
if (hrsb.length() > 0) {
hrsb.deleteCharAt(0);
}
JSONObject msgObject = new JSONObject();
msgObject.put("userIds", hrsb);//object.getString("id")
msgObject.put("content", String.format(TODAY_BIRTHDAY_REMIND, name));
tokenDao.sendTextMsg(JSON.toJSONString(msgObject));
}
# 上面的代码,定时任务执行上边代码。我想问问这个会导致服务器占用内存爆炸吗。。是不是因为Stringbuilder的原因,之前手抖没看到怎么写了个Stringbuilder
第二天8.00执行 服务器ok,8.30左右服务器报错数据库连接最大,内存占用到了80%
我想问问是不是这个导致的