@ -88,8 +88,6 @@ public class HrmResourceServiceImpl extends Service implements HrmResourceServic
private static final String RIGHT_NAME = "Roster:All" ;
private static final String level = getFieldName ( "职等" ) ;
private static final String grade = getFieldName ( "职级" ) ;
private HrmRelationMapper getHrmRelationMapper ( ) {
return MapperProxyFactory . getProxy ( HrmRelationMapper . class ) ;
@ -149,7 +147,7 @@ public class HrmResourceServiceImpl extends Service implements HrmResourceServic
table . setSqlwhere ( sqlWhere ) ;
List < WeaTableColumn > weaTableColumnList = new ArrayList < > ( ) ;
JclOrgCustomTemplatePO jclOrgCustomTemplatePO = MapperProxyFactory . getProxy ( JclOrgCustomTemplateMapper . class ) . queryIsusedTemp ( "1" , String . valueOf ( user . getUID ( ) ) ) ;
String columns = null ;
String columns = "" ;
List < String > fields = new ArrayList < > ( ) ;
List < SearchConditionGroup > allConditions = getAllConditions ( ) ;
@ -289,18 +287,26 @@ public class HrmResourceServiceImpl extends Service implements HrmResourceServic
}
@Override
public List < SearchTemplateParam > getSearchTemplate ( Map < String , Object > params ) {
public Map < String , Object > getSearchTemplate ( Map < String , Object > params ) {
Map < String , Object > returnMap = new HashMap < > ( ) ;
String type = Util . null2String ( params . get ( "type" ) ) ;
int userUID = user . getUID ( ) ;
// 根据ID查询所存储的模板
List < SearchTemplateParam > templates ;
if ( "custom" . equals ( type ) ) {
templates = getHrmResourceMapper ( ) . getCustomTemplatesByUser ( userUID ) ;
SearchTemplatePO usedCustomTemplate = getHrmResourceMapper ( ) . getUsedCustomTemplateByUser ( user . getUID ( ) ) ;
if ( null ! = usedCustomTemplate ) {
returnMap . put ( "templateId" , usedCustomTemplate . getId ( ) . toString ( ) ) ;
} else {
returnMap . put ( "templateId" , "-1" ) ;
}
} else {
templates = getHrmResourceMapper ( ) . getSearchTemplatesByUser ( userUID ) ;
}
templates . add ( 0 , SearchTemplateParam . builder ( ) . key ( "-1" ) . showname ( "默认模板" ) . build ( ) ) ;
return templates ;
returnMap . put ( "templates" , templates ) ;
return returnMap ;
}
@Override
@ -389,8 +395,15 @@ public class HrmResourceServiceImpl extends Service implements HrmResourceServic
transferOptions . add ( SearchTemplateParam . builder ( ) . key ( Integer . toString ( idx . getAndIncrement ( ) ) ) . showname ( allCondition . getTitle ( ) ) . build ( ) ) ;
}
if ( "-1" . equals ( templateId ) ) {
// 查询当前使用的模板,没有使用的,则展示默认模板
SearchTemplatePO usedCustomTemplate = getHrmResourceMapper ( ) . getUsedCustomTemplateByUser ( user . getUID ( ) ) ;
if ( null = = usedCustomTemplate ) {
String selectKeys = "-1_hrm_lastname,-1_hrm_departmentid,-1_hrm_jobtitle,-1_hrm_mobile,-1_hrm_telephone,-1_hrm_managerid" ;
transferKeys = Arrays . asList ( selectKeys . split ( "," ) ) ;
} else {
transferKeys = getSelectKeys ( usedCustomTemplate ) ;
templateId = usedCustomTemplate . getId ( ) . toString ( ) ;
}
} else {
SearchTemplatePO searchTemplateById = getHrmResourceMapper ( ) . getCustomTemplateById ( templateId ) ;
transferKeys = getSelectKeys ( searchTemplateById ) ;
@ -399,6 +412,7 @@ public class HrmResourceServiceImpl extends Service implements HrmResourceServic
resultMap . put ( "transferDatas" , transferDatas ) ;
resultMap . put ( "transferKeys" , transferKeys ) ;
resultMap . put ( "transferOptions" , transferOptions ) ;
resultMap . put ( "templateId" , templateId ) ;
return resultMap ;
}
@ -643,16 +657,36 @@ public class HrmResourceServiceImpl extends Service implements HrmResourceServic
DBType dbType = DBType . get ( new RecordSet ( ) . getDBType ( ) ) ;
StringBuilder sb = new StringBuilder ( " where 1=1 and t.status <4 " ) ;
StringBuilder sb = new StringBuilder ( " where 1=1 " ) ;
if ( params . containsKey ( "lastName" ) ) {
// sb.append(" and t.status = 1");
sb . append ( " and t.status < 4" ) ;
}
for ( Map . Entry < String , Object > entry : params . entrySet ( ) ) {
String key = entry . getKey ( ) ;
String value = Util . null2String ( entry . getValue ( ) ) ;
if ( StringUtils . isBlank ( value ) ) {
continue ;
}
String key = entry . getKey ( ) ;
if ( "lastName" . equals ( key ) ) {
sb . append ( " and t.lastname " ) . append ( dbType . like ( value ) ) ;
}
if ( "companyId" . equals ( key ) ) {
sb . append ( " and t.subcompanyid1 ='" ) . append ( value ) . append ( "'" ) ;
}
if ( "departmentId" . equals ( key ) ) {
sb . append ( " and t.departmentId ='" ) . append ( value ) . append ( "'" ) ;
}
if ( "jobTitle" . equals ( key ) ) {
JobPO jobById = getJobMapper ( ) . getJobById ( Long . parseLong ( value ) ) ;
if ( null ! = jobById ) {
sb . append ( " and t.jobtitle ='" ) . append ( Util . null2String ( jobById . getEcJobTitle ( ) ) ) . append ( "' and t.subcompanyid1 = '" ) . append ( Util . null2String ( jobById . getEcCompany ( ) ) ) . append ( "' and t.departmentId ='" ) . append ( Util . null2String ( jobById . getEcDepartment ( ) ) ) . append ( "'" ) ;
} else {
sb = new StringBuilder ( " where 1 = 2 " ) ;
break ;
}
}
SearchConditionItem searchConditionItem = allFieldsMap . get ( key ) ;
// 根据不同的类型,不同的查询方式
buildDynamicSql ( searchConditionItem , key , value , sb , dbType ) ;
@ -913,6 +947,9 @@ public class HrmResourceServiceImpl extends Service implements HrmResourceServic
hrmFieldBean . setDmlurl ( cusFormFieldPO . getDmlUrl ( ) ) ;
hrmFieldBean . setIssystem ( "hrm" . equals ( cusFormFieldPO . getTableName ( ) ) ? "1" : "0" ) ;
hrmFieldBean . setIsFormField ( true ) ;
if ( "-1_hrm_status" . equals ( hrmFieldBean . getFieldname ( ) ) ) {
hrmFieldBean . setFieldvalue ( "1" ) ;
}
SearchConditionItem searchConditionItem = hrmFieldSearchConditionComInfo . getSearchConditionItem ( hrmFieldBean , user ) ;
conditionItems . add ( searchConditionItem ) ;
// 如果为下拉框,添加一条空选项
@ -1090,6 +1127,14 @@ public class HrmResourceServiceImpl extends Service implements HrmResourceServic
sb . append ( " and " ) . append ( dbType . ifNull ( tableSql , "0" ) ) . append ( " = '" ) . append ( value ) . append ( "' " ) ;
break ;
case SELECT : //选择框
if ( ! "-1" . equals ( value ) ) {
if ( "t.status" . equalsIgnoreCase ( tableSql ) & & "10" . equals ( value ) ) {
sb . append ( " and " ) . append ( tableSql ) . append ( " < 4 " ) ;
} else {
sb . append ( " and " ) . append ( tableSql ) . append ( " = '" ) . append ( value ) . append ( "' " ) ;
}
}
break ;
case DATE :
case DATEPICKER :
case TIMEPICKER :
@ -1156,14 +1201,17 @@ public class HrmResourceServiceImpl extends Service implements HrmResourceServic
* @param searchConditionItem
* /
private void addEmptyForSelect ( SearchConditionItem searchConditionItem ) {
searchConditionItem . setValue ( "" ) ;
searchConditionItem . setValue ( "-1" ) ;
if ( "-1_hrm_status" . equals ( searchConditionItem . getDomkey ( ) [ 0 ] ) ) {
// 默认赋值 在职状态
searchConditionItem . setValue ( "10" ) ;
}
List < SearchConditionOption > options = searchConditionItem . getOptions ( ) ;
SearchConditionOption searchConditionOption = new SearchConditionOption ( ) ;
searchConditionOption . setKey ( "" ) ;
searchConditionOption . setKey ( "-1" ) ;
searchConditionOption . setShowname ( "全部" ) ;
options . add ( 0 , searchConditionOption ) ;
options . forEach ( item - > {
item . setSelected ( false ) ;
} ) ;
options . forEach ( item - > item . setSelected ( false ) ) ;
}
/ * *
@ -1189,13 +1237,4 @@ public class HrmResourceServiceImpl extends Service implements HrmResourceServic
return selectKeys ;
}
private static String getFieldName ( String fieldabel ) {
RecordSet recordSet = new RecordSet ( ) ;
String fieldname = null ;
recordSet . executeQuery ( "select fieldname from jcl_org_field where fieldlabel='" + fieldabel + "'" ) ;
if ( recordSet . next ( ) ) {
fieldname = recordSet . getString ( "fieldname" ) ;
}
return fieldname ;
}
}