能在数据库层面处理的逻辑优先在数据库处理

优化后:
String queryStr = " wid in(select wid from t_gjjl_yjsygcgsq where sqzt=99"
+"and jfshflag=0 union select wid from t_gjjl_yjsygcgsq where field1=1 and length(jfbmshzt)=length(jfshzt))";

优化前:
//查询本科生是否进入到oa的流程中  即数据在该系统中的流程已经走完
PublicService pubService = (PublicService) GenericFactory.getServiceInstance(PublicService.class);
String sql ="select * from t_gjjl_yjsygcgsq where jfshflag=1 or sqzt=99";
List list = pubService.sqlGetAll(sql);
String jfshflag="";
int countI=0;String queryStr1="";String queryStr="";
String sqlStr="";String filterStr="T_GJJL_YJSYGCGSQ:";
int countA=0;
if(list.size()>0){
for(int a=0;a<list.size();a++){
jfshflag = (String)((Map)list.get(a)).get("JFSHFLAG");
Logger.debug("jfshflag:"+jfshflag);
if("1".equals(jfshflag)){
//经费审核状态有可能为空
if(null ==((Map)list.get(a)).get("JFSHZT") || "null".equals(((Map)list.get(a)).get("JFSHZT")) ){
countI=0;
}else{
countI = ((String)((Map)list.get(a)).get("JFSHZT")).length();
}
countA = ((Map)list.get(a)).get("JFBMSHZT").toString().length();
//该条件是判断 jsfhflag==1 的值中 经费审核状态和经费部门审核状态是否相等
//长度相同则是到终审的数据
if(countI == countA){
queryStr = " jfshflag= 1 and length(JFBMSHZT)=length(JFSHZT)";
}
}else{
queryStr1 = "sqzt=99 and jfshflag is null";
}
}
if(!"".equals(queryStr)&& !"".equals(queryStr1) ){
filterStr += queryStr + " or "+queryStr1;

}else if("".equals(queryStr)){
filterStr += queryStr1;
}else if("".equals(queryStr1)){
filterStr += queryStr;
}
}else{
filterStr +="1=2";
}

if(filterStr.length()==17){
filterStr +="1=2";
}

猜你喜欢

转载自xygg0315.iteye.com/blog/1725967