dao层实现类:
public List<ExamineUser> findExamineUsersByOrganId(Long organId,String canOptInspectorsType,String inspectorType) {
Session session = DaoHelp.getInstance().getSession();
String hql="";
//canOptInspectorsType:公示抽查是否可以选择检查人员类型,Y开启,N关闭
if("Y".equals(canOptInspectorsType)&&!"0".equals(inspectorType)){ //开启状态,并且人员类型不是全部
//String type=inspectorType.replace("@", "'");
//hql = "select u.id as id,u.USERID as userId,u.USERNAME as userName,u.CODE as code,u.ORGANID as organId,u.ORGANNAME as organName from ENTCHK_EXAMINEUSER u where u.valId='0' and u.inspectorType in ("+type+") and exists (select o.id from a_organ o where o.id=u.ORGANID start with o.id="+organId+" connect by prior o.id=o.parent)";
StringBuffer sb=new StringBuffer();
sb.append("select u.id as id,u.USERID as userId,u.USERNAME as userName,u.CODE as code,");
sb.append("u.ORGANID as organId,u.ORGANNAME as organName from ENTCHK_EXAMINEUSER u where u.valId='0' ");
sb.append(getGodRainSql(inspectorType));
sb.append(" and exists (select o.id from a_organ o where o.id=u.ORGANID start with o.id="+organId);
sb.append(" connect by prior o.id=o.parent)");
hql=sb.toString();
}else{
hql = "select u.id as id,u.USERID as userId,u.USERNAME as userName,u.CODE as code,u.ORGANID as organId,u.ORGANNAME as organName from ENTCHK_EXAMINEUSER u where u.valId='0' and u.states='1' and exists (select o.id from a_organ o where o.id=u.ORGANID start with o.id="+organId+" connect by prior o.id=o.parent)";
}
public List<ExamineUser> findExamineUsersByOrganIdBj(Long organId,String canOptInspectorsType,String inspectorType) {
Session session = DaoHelp.getInstance().getSession();
String hql="";
if("Y".equals(canOptInspectorsType)&&!"0".equals(inspectorType)){//开启状态,并且人员类型不是全部
//String type=inspectorType.replace("@", "'");
//hql = "select u.id as id,u.USERID as userId,u.USERNAME as userName,u.CODE as code,u.ORGANID as organId,u.ORGANNAME as organName from ENTCHK_EXAMINEUSER u where u.valId='0' and u.inspectorType in ("+type+") and exists (select o.id from a_organ o where o.id=u.ORGANID and (o.ID="+organId+" or (o.parent="+organId+" and ORGANTYPECODE='D' )) )";
StringBuffer sb=new StringBuffer();
sb.append("select u.id as id,u.USERID as userId,u.USERNAME as userName,u.CODE as code,");
sb.append("u.ORGANID as organId,u.ORGANNAME as organName from ENTCHK_EXAMINEUSER u where u.valId='0' ");
sb.append(getGodRainSql(inspectorType));
sb.append(" and exists (select o.id from a_organ o where o.id=u.ORGANID and ");
sb.append("(o.ID="+organId+" or (o.parent="+organId+" and ORGANTYPECODE='D' )) )");
hql=sb.toString();
}else{
hql = "select u.id as id,u.USERID as userId,u.USERNAME as userName,u.CODE as code,u.ORGANID as organId,u.ORGANNAME as organName from ENTCHK_EXAMINEUSER u where u.valId='0' and states='1' and exists (select o.id from a_organ o where o.id=u.ORGANID and (o.ID="+organId+" or (o.parent="+organId+" and ORGANTYPECODE='D' )) )";
}
/**
* 检查人员类型sql拼接
* @param faker
* @return
*/
private String getGodRainSql(String faker){
faker=faker.replace("@", "%");
if(faker.indexOf(",")==-1){
String sql=" and u.inspectorType like '"+faker+"'";
return sql;
}else{
String[] fakers=faker.split(",");
StringBuffer sb=new StringBuffer();
for(int i=0;i<fakers.length;i++){
String godRain=fakers[i];
godRain=godRain.replace("@", "%");
sb.append(" or u.inspectorType like '"+godRain+"'");
}
String leBron =sb.toString().replaceFirst(" or ", "");
return " and ("+leBron+")";
}
}
action 层:
if("Y".equals(canOptInspectorsType)){ //公示抽查是否可以选择检查人员类型,Y开启,N关闭
String jqjbzlj=request.getParameter("jqjbzlj");//县区级分配已经验证过,不能在验证
if(!"yes".equals(jqjbzlj)){
List<ExamineUser> euList = (List<ExamineUser>)examineUserManager.findExamineUsersByOrganIdBj(priorgId,canOptInspectorsType,inspectorType);
String entChkGroup = SysParameter.getSysParameterValueByKey("entChkGroup");
int everyGroupCount = (entChkGroup == null || "".equals(entChkGroup)) ? 2 : Integer.parseInt(entChkGroup);// 每组人数
if(euList==null||euList.size()<everyGroupCount){
request.setAttribute("inspectorType", getinspectorTypeName(inspectorType));
String url="/taskDistributionUI.do?msg=no"+"&entChkGroup="+entChkGroup;
ActionForward gotoUrl = new ActionForward(url);
gotoUrl.setRedirect(false);
return gotoUrl;
}else{
return actionMapping.findForward("success");
}
}else{//县区级分配已经验证过,不能在验证
return actionMapping.findForward("success");
}
}else{
return actionMapping.findForward("success");
}
private String getinspectorTypeName(String inspectorType){
if("0".equals(inspectorType)){
return "0";//全部人员
}
if(inspectorType.indexOf(",")!=-1){
StringBuffer sb=new StringBuffer();
String[] inspectorTypes=inspectorType.split(",");
for(int i=0;i<inspectorTypes.length;i++){
sb.append(getinspectorTypeName1(inspectorTypes[i])+",");
}
String returnVal=sb.toString();
return returnVal.substring(0, returnVal.length()-1);
}else{
return getinspectorTypeName1(inspectorType);
}
}
private String getinspectorTypeName1(String inspectorType){
if("@1@".equals(inspectorType)){
return "企业类";
}else if("@2@".equals(inspectorType)){
return "商广类";
}else if("@3@".equals(inspectorType)){
return "市场类";
}else if("@4@".equals(inspectorType)){
return "执法类";
}else{
return "0";
}
}