package cn.com.goldenwater.util.common; import org.apache.commons.lang3.StringUtils; public class SqlUtils { /** * 用来构造提供用户id和行政区划获取分组 */ public static String getinIdsSql(String persId, String province) { StringBuffer buffer = new StringBuffer(); String adCodeSql = "and n.AD_CODE is null "; if (StringUtils.isNotBlank(province)) { adCodeSql = "and n.AD_CODE='" + province + "' \n"; } buffer.append("select a.id from bis_insp_all a ,bis_insp_all_rlation n where SUBSTR(a.id,1,6)=n.ID " + adCodeSql + "and n.persid='" + persId + "' and length(n.ID)=6\n" + "UNION ALL\n" + "select a.id from bis_insp_all a ,bis_insp_all_rlation n where SUBSTR(a.id,1,9)=n.ID " + adCodeSql + "and n.persid='" + persId + "' and LENGTH(n.id)=9\n" + "UNION ALL\n" + "select a.id from bis_insp_all a ,bis_insp_all_rlation n where a.id=n.ID " + adCodeSql + "and n.persid='" + persId + "' and LENGTH(n.id)=12"); return buffer.toString(); } }