2022-06-20 18:31:11 +08:00
package com.engine.organization.service.impl ;
2022-06-21 16:47:39 +08:00
import com.api.browser.bean.SearchConditionGroup ;
2022-06-21 17:50:56 +08:00
import com.api.browser.bean.SearchConditionItem ;
2023-01-09 18:06:57 +08:00
import com.api.browser.bean.SearchConditionOption ;
import com.api.browser.util.ConditionType ;
2023-01-06 15:35:38 +08:00
import com.api.hrm.bean.HrmFieldBean ;
import com.api.hrm.util.HrmFieldSearchConditionComInfo ;
2023-01-13 08:50:27 +08:00
import com.cloudstore.eccom.constant.WeaBoolAttr ;
2023-01-11 14:48:24 +08:00
import com.cloudstore.eccom.pc.table.WeaTableColumn ;
2022-06-21 13:49:37 +08:00
import com.cloudstore.eccom.result.WeaResultMsg ;
2022-06-20 18:31:11 +08:00
import com.engine.core.impl.Service ;
2022-07-12 16:38:27 +08:00
import com.engine.hrm.util.face.HrmFaceCheckManager ;
2022-06-21 13:49:37 +08:00
import com.engine.organization.component.OrganizationWeaTable ;
2022-06-20 18:31:11 +08:00
import com.engine.organization.entity.DeleteParam ;
2022-11-30 16:06:40 +08:00
import com.engine.organization.entity.company.bo.CompBO ;
import com.engine.organization.entity.company.po.CompPO ;
2022-06-20 18:31:11 +08:00
import com.engine.organization.entity.department.bo.DepartmentBO ;
import com.engine.organization.entity.department.po.DepartmentPO ;
2023-01-12 09:41:58 +08:00
import com.engine.organization.entity.extend.bo.ExtendInfoBO ;
import com.engine.organization.entity.extend.po.ExtendInfoPO ;
2022-07-11 15:59:15 +08:00
import com.engine.organization.entity.hrmresource.bo.HrmRelationBO ;
import com.engine.organization.entity.hrmresource.param.HrmRelationSaveParam ;
2023-01-06 15:35:38 +08:00
import com.engine.organization.entity.hrmresource.param.SearchTemplateParam ;
2022-07-11 15:59:15 +08:00
import com.engine.organization.entity.hrmresource.po.HrmRelationPO ;
2023-01-12 09:41:58 +08:00
import com.engine.organization.entity.hrmresource.po.JclOrgCustomTemplatePO ;
2023-01-06 15:35:38 +08:00
import com.engine.organization.entity.hrmresource.po.SearchTemplatePO ;
2023-01-11 15:42:41 +08:00
import com.engine.organization.entity.hrmresource.po.TransferDataPO ;
2022-10-12 15:28:11 +08:00
import com.engine.organization.entity.hrmresource.vo.HrmResourceVO ;
2023-01-06 15:35:38 +08:00
import com.engine.organization.entity.jclimport.po.CusFormFieldPO ;
2022-06-20 18:31:11 +08:00
import com.engine.organization.entity.job.bo.JobBO ;
import com.engine.organization.entity.job.po.JobPO ;
import com.engine.organization.entity.searchtree.SearchTree ;
import com.engine.organization.entity.searchtree.SearchTreeParams ;
2023-01-09 18:06:57 +08:00
import com.engine.organization.enums.HrmGroupEnum ;
2022-11-30 16:06:40 +08:00
import com.engine.organization.mapper.comp.CompMapper ;
2022-06-20 18:31:11 +08:00
import com.engine.organization.mapper.department.DepartmentMapper ;
2022-07-11 15:59:15 +08:00
import com.engine.organization.mapper.hrmresource.HrmRelationMapper ;
2022-07-12 16:38:27 +08:00
import com.engine.organization.mapper.hrmresource.SystemDataMapper ;
2022-06-20 18:31:11 +08:00
import com.engine.organization.mapper.job.JobMapper ;
2023-01-06 15:35:38 +08:00
import com.engine.organization.mapper.resource.HrmResourceMapper ;
2023-01-12 09:41:58 +08:00
import com.engine.organization.mapper.resource.JclOrgCustomTemplateMapper ;
2022-06-20 18:31:11 +08:00
import com.engine.organization.service.HrmResourceService ;
2022-10-12 15:28:11 +08:00
import com.engine.organization.util.HasRightUtil ;
2022-06-21 17:50:56 +08:00
import com.engine.organization.util.MenuBtn ;
2022-06-21 16:47:39 +08:00
import com.engine.organization.util.OrganizationAssert ;
2023-01-12 15:17:38 +08:00
import com.engine.organization.util.OrganizationDateUtil ;
2022-06-21 13:49:37 +08:00
import com.engine.organization.util.db.DBType ;
2022-06-20 18:31:11 +08:00
import com.engine.organization.util.db.MapperProxyFactory ;
2022-11-01 10:05:43 +08:00
import com.engine.organization.util.detach.DetachUtil ;
2022-07-26 09:40:13 +08:00
import com.engine.organization.util.page.PageUtil ;
2022-06-20 18:31:11 +08:00
import com.engine.organization.util.tree.SearchTreeUtil ;
import org.apache.commons.collections.CollectionUtils ;
2022-06-21 13:49:37 +08:00
import org.apache.commons.lang3.StringUtils ;
2023-01-06 15:35:38 +08:00
import org.json.JSONException ;
import org.json.JSONObject ;
2023-01-12 16:49:54 +08:00
import weaver.common.DateUtil ;
2022-06-21 13:49:37 +08:00
import weaver.conn.RecordSet ;
2022-06-20 18:31:11 +08:00
import weaver.general.StringUtil ;
import weaver.general.Util ;
2023-01-06 15:35:38 +08:00
import weaver.hrm.definedfield.HrmFieldManager ;
2022-06-20 18:31:11 +08:00
2023-01-13 18:10:57 +08:00
import java.math.BigDecimal ;
import java.math.RoundingMode ;
2022-06-20 18:31:11 +08:00
import java.util.* ;
2023-01-12 09:41:58 +08:00
import java.util.concurrent.atomic.AtomicInteger ;
2022-06-20 18:31:11 +08:00
import java.util.stream.Collectors ;
/ * *
* @author : dxfeng
* @createTime : 2022 / 06 / 20
* @version : 1 . 0
* /
public class HrmResourceServiceImpl extends Service implements HrmResourceService {
/ * *
* 左侧树 类型表示
* < p >
* 0 : 集团
* 1 : 分部
* 2 : 部门
* 3 : 岗位
* /
private static final String TYPE_COMP = " 1 " ;
private static final String TYPE_DEPT = " 2 " ;
private static final String TYPE_JOB = " 3 " ;
2022-10-12 15:28:11 +08:00
private static final String RIGHT_NAME = " Roster:All " ;
2023-01-11 14:48:24 +08:00
2022-07-11 15:59:15 +08:00
private HrmRelationMapper getHrmRelationMapper ( ) {
return MapperProxyFactory . getProxy ( HrmRelationMapper . class ) ;
}
2022-06-20 18:31:11 +08:00
private DepartmentMapper getDepartmentMapper ( ) {
return MapperProxyFactory . getProxy ( DepartmentMapper . class ) ;
}
2022-11-30 16:06:40 +08:00
private CompMapper getCompMapper ( ) {
return MapperProxyFactory . getProxy ( CompMapper . class ) ;
2022-06-20 18:31:11 +08:00
}
private JobMapper getJobMapper ( ) {
return MapperProxyFactory . getProxy ( JobMapper . class ) ;
}
2023-01-06 15:35:38 +08:00
private HrmResourceMapper getHrmResourceMapper ( ) {
return MapperProxyFactory . getProxy ( HrmResourceMapper . class ) ;
2022-06-21 16:47:39 +08:00
}
2022-10-17 17:16:26 +08:00
private SystemDataMapper getSystemDataMapper ( ) {
return MapperProxyFactory . getProxy ( SystemDataMapper . class ) ;
}
2023-01-13 13:44:05 +08:00
private JclOrgCustomTemplateMapper getJclOrgCustomTemplateMapper ( ) {
return MapperProxyFactory . getProxy ( JclOrgCustomTemplateMapper . class ) ;
}
2023-01-10 18:25:53 +08:00
// 所有满足条件的岗位ID
2023-01-11 14:26:13 +08:00
private List < Integer > jobTitleList = null ;
2023-01-10 18:25:53 +08:00
// 是否
boolean searchJobTitle = false ;
2022-07-11 15:59:15 +08:00
2022-06-20 18:31:11 +08:00
@Override
public Map < String , Object > getSearchTree ( SearchTreeParams params ) {
String keyword = params . getKeyword ( ) ;
String id = params . getId ( ) ;
String type = Util . null2String ( params . getType ( ) ) ;
List < SearchTree > treeList = getFilterCompany ( id , type , keyword ) ;
return SearchTreeUtil . getSearchTree ( type , treeList ) ;
}
2022-06-21 13:49:37 +08:00
@Override
2023-01-09 18:06:57 +08:00
public Map < String , Object > listPage ( Map < String , Object > params ) {
2022-10-12 15:28:11 +08:00
OrganizationWeaTable < HrmResourceVO > table = new OrganizationWeaTable < > ( user , HrmResourceVO . class ) ;
2023-01-09 18:06:57 +08:00
String sqlWhere = buildSqlWhere ( params ) ;
2022-07-04 10:01:28 +08:00
table . setSqlwhere ( sqlWhere ) ;
2023-01-13 13:44:05 +08:00
List < WeaTableColumn > weaTableColumnList = new ArrayList < > ( ) ;
JclOrgCustomTemplatePO jclOrgCustomTemplatePO = MapperProxyFactory . getProxy ( JclOrgCustomTemplateMapper . class ) . queryIsusedTemp ( " 1 " , String . valueOf ( user . getUID ( ) ) ) ;
2023-03-01 16:26:10 +08:00
String columns = " " ;
2023-01-13 16:35:34 +08:00
List < String > fields = new ArrayList < > ( ) ;
List < SearchConditionGroup > allConditions = getAllConditions ( ) ;
2023-01-13 13:44:05 +08:00
if ( jclOrgCustomTemplatePO ! = null ) {
2023-01-13 18:03:19 +08:00
if ( StringUtils . isNotBlank ( jclOrgCustomTemplatePO . getBasicFields ( ) ) ) {
columns = jclOrgCustomTemplatePO . getBasicFields ( ) ;
}
2023-01-13 13:44:05 +08:00
if ( StringUtils . isNotBlank ( jclOrgCustomTemplatePO . getPersonalFields ( ) ) ) {
2023-01-13 16:35:34 +08:00
columns = columns + " , " + jclOrgCustomTemplatePO . getPersonalFields ( ) ;
2023-01-13 08:50:27 +08:00
}
2023-01-13 13:44:05 +08:00
if ( StringUtils . isNotBlank ( jclOrgCustomTemplatePO . getWorkFields ( ) ) ) {
2023-01-13 16:35:34 +08:00
columns = columns + " , " + jclOrgCustomTemplatePO . getWorkFields ( ) ;
2023-01-13 13:44:05 +08:00
}
} else {
//初次使用,无模板初始值
columns = " -1_hrm_lastname,-1_hrm_departmentid,-1_hrm_subcompanyid1,-1_hrm_jobtitle,-1_hrm_mobile,-1_hrm_telephone,-1_hrm_managerid,-1_hrm_sporder " ;
2023-01-13 08:50:27 +08:00
}
2023-01-13 13:44:05 +08:00
2023-01-13 16:35:34 +08:00
List < String > columnList = Arrays . asList ( columns . split ( " , " ) ) ;
2023-01-13 18:10:57 +08:00
BigDecimal decimal = new BigDecimal ( 100 / columnList . size ( ) ) ;
2023-01-13 16:35:34 +08:00
for ( SearchConditionGroup allCondition : allConditions ) {
List < SearchConditionItem > items = allCondition . getItems ( ) ;
for ( SearchConditionItem item : items ) {
String columnName = item . getDomkey ( ) [ 0 ] ;
fields . add ( buildTableSql ( columnName ) + " as " + buildTableSql ( columnName ) . replace ( " . " , " _ " ) ) ;
String scopeId = columnName . split ( " _ " ) [ 0 ] ;
String fieldName = columnName . substring ( columnName . lastIndexOf ( " _ " ) + 1 ) ;
2023-01-13 13:44:05 +08:00
WeaTableColumn weaTableColumn = new WeaTableColumn ( ) ;
2023-01-13 14:07:33 +08:00
weaTableColumn . setText ( getHrmResourceMapper ( ) . queryLabelName ( fieldName , scopeId ) ) ;
2023-01-13 16:35:34 +08:00
weaTableColumn . setColumn ( buildTableSql ( columnName ) . replace ( " . " , " _ " ) ) ;
weaTableColumn . setDisplay ( columnList . contains ( columnName ) ? WeaBoolAttr . TRUE : WeaBoolAttr . FALSE ) ;
2023-01-13 13:44:05 +08:00
weaTableColumn . setTransmethod ( " com.engine.organization.transmethod.HrmResourceTransMethod.getFieldTrueValue " ) ;
2023-01-13 16:35:34 +08:00
weaTableColumn . setOtherpara ( columnName ) ;
2023-01-13 18:10:57 +08:00
weaTableColumn . setWidth ( decimal . setScale ( 2 , RoundingMode . HALF_UP ) . doubleValue ( ) + " % " ) ;
2023-01-13 13:44:05 +08:00
weaTableColumnList . add ( weaTableColumn ) ;
2023-01-13 08:50:27 +08:00
}
}
2023-01-13 13:44:05 +08:00
// 增加id字段,跳转人员卡片
2023-01-13 08:50:27 +08:00
WeaTableColumn weaTableColumn = new WeaTableColumn ( ) ;
weaTableColumn . setColumn ( " id " ) ;
weaTableColumn . setDisplay ( WeaBoolAttr . FALSE ) ;
2023-01-13 16:35:34 +08:00
weaTableColumnList . add ( weaTableColumn ) ;
fields . add ( " t.id " ) ;
table . setBackfields ( StringUtils . join ( fields , " , " ) ) ;
2023-01-13 08:50:27 +08:00
table . setColumns ( weaTableColumnList ) ;
2022-06-21 13:49:37 +08:00
WeaResultMsg result = new WeaResultMsg ( false ) ;
result . putAll ( table . makeDataResult ( ) ) ;
result . success ( ) ;
2022-10-12 15:28:11 +08:00
return new HashMap < > ( result . getResultMap ( ) ) ;
2022-06-21 13:49:37 +08:00
}
2022-06-21 16:47:39 +08:00
@Override
public Map < String , Object > getSaveForm ( ) {
Map < String , Object > apiDatas = new HashMap < > ( ) ;
List < SearchConditionGroup > addGroups = new ArrayList < > ( ) ;
apiDatas . put ( " condition " , addGroups ) ;
return apiDatas ;
}
@Override
2022-06-23 16:55:26 +08:00
public Long saveBaseForm ( Map < String , Object > params ) {
2023-01-06 15:35:38 +08:00
return 0L ;
2022-06-21 16:47:39 +08:00
}
@Override
public Map < String , Object > getBaseForm ( Map < String , Object > params ) {
2023-01-06 15:35:38 +08:00
return new HashMap < > ( ) ;
}
@Override
public int updateForm ( Map < String , Object > params ) {
return 0 ;
}
2022-06-21 16:47:39 +08:00
@Override
2023-01-10 11:37:28 +08:00
public Integer saveSearchTemplate ( SearchTemplateParam params ) {
2023-01-12 18:18:44 +08:00
// 重复名称校验
SearchTemplatePO searchTemplateByName = getHrmResourceMapper ( ) . getSearchTemplateByName ( user . getUID ( ) , params . getShowname ( ) ) ;
2023-01-13 16:50:54 +08:00
OrganizationAssert . isFalse ( " 默认模板 " . equals ( params . getShowname ( ) ) | | null ! = searchTemplateByName , " 该模板名称已存在 " ) ;
2023-01-10 16:52:40 +08:00
SearchTemplatePO templatePO = buildSearchTemplateByFields ( params . getFields ( ) ) ;
2023-01-10 11:37:28 +08:00
if ( null = = templatePO ) {
return - 1 ;
2022-11-16 13:39:56 +08:00
}
2023-01-10 11:37:28 +08:00
templatePO . setName ( params . getShowname ( ) ) ;
templatePO . setCreator ( user . getUID ( ) ) ;
templatePO . setCreateTime ( new Date ( ) ) ;
templatePO . setUpdateTime ( new Date ( ) ) ;
getHrmResourceMapper ( ) . insertSearchTemplate ( templatePO ) ;
return templatePO . getId ( ) ;
2022-06-21 16:47:39 +08:00
}
2023-01-06 17:20:29 +08:00
@Override
public void deleteSearchTemplate ( Integer id ) {
getHrmResourceMapper ( ) . deleteSearchTemplate ( id , user . getUID ( ) ) ;
}
2023-01-10 15:13:33 +08:00
@Override
public String getTemplateSelectKeys ( Map < String , Object > params ) {
String templateId = Util . null2String ( params . get ( " templateId " ) ) ;
2023-01-11 16:28:19 +08:00
templateId = StringUtils . isBlank ( templateId ) ? " -1 " : templateId ;
String type = Util . null2String ( params . get ( " type " ) ) ;
2023-01-10 15:13:33 +08:00
OrganizationAssert . isTrue ( StringUtils . isNotBlank ( templateId ) , " 数据有误,未找到对应数据 " ) ;
// 判断是否为搜索模板
2023-01-11 16:28:19 +08:00
SearchTemplatePO searchTemplateById ;
List < String > selectKeys ;
if ( " custom " . equals ( type ) ) {
if ( " -1 " . equals ( templateId ) ) {
selectKeys = Arrays . asList ( " -1_hrm_lastname,-1_hrm_departmentid,-1_hrm_jobtitle,-1_hrm_mobile,-1_hrm_telephone,-1_hrm_managerid " . split ( " , " ) ) ;
} else {
searchTemplateById = getHrmResourceMapper ( ) . getCustomTemplateById ( templateId ) ;
selectKeys = getSelectKeys ( searchTemplateById ) ;
2023-01-10 15:13:33 +08:00
}
2023-01-11 15:42:41 +08:00
} else {
2023-01-11 16:28:19 +08:00
if ( " -1 " . equals ( templateId ) ) {
selectKeys = getAllConditions ( ) . get ( 0 ) . getItems ( ) . stream ( ) . map ( item - > item . getDomkey ( ) [ 0 ] ) . collect ( Collectors . toList ( ) ) ;
} else {
searchTemplateById = getHrmResourceMapper ( ) . getSearchTemplateById ( templateId ) ;
selectKeys = getSelectKeys ( searchTemplateById ) ;
2023-01-10 15:13:33 +08:00
}
}
2023-01-11 15:42:41 +08:00
return StringUtils . join ( selectKeys , " , " ) ;
2023-01-10 15:13:33 +08:00
}
2023-01-10 16:52:40 +08:00
@Override
2023-01-16 17:19:59 +08:00
public Map < String , Object > getSearchTemplate ( Map < String , Object > params ) {
Map < String , Object > returnMap = new HashMap < > ( ) ;
2023-01-11 16:28:19 +08:00
String type = Util . null2String ( params . get ( " type " ) ) ;
2023-01-10 16:52:40 +08:00
int userUID = user . getUID ( ) ;
// 根据ID查询所存储的模板
2023-01-11 16:28:19 +08:00
List < SearchTemplateParam > templates ;
if ( " custom " . equals ( type ) ) {
templates = getHrmResourceMapper ( ) . getCustomTemplatesByUser ( userUID ) ;
2023-01-16 17:19:59 +08:00
SearchTemplatePO usedCustomTemplate = getHrmResourceMapper ( ) . getUsedCustomTemplateByUser ( user . getUID ( ) ) ;
if ( null ! = usedCustomTemplate ) {
2023-01-17 09:30:51 +08:00
returnMap . put ( " templateId " , usedCustomTemplate . getId ( ) . toString ( ) ) ;
2023-01-16 17:19:59 +08:00
} else {
returnMap . put ( " templateId " , " -1 " ) ;
}
2023-01-11 16:28:19 +08:00
} else {
templates = getHrmResourceMapper ( ) . getSearchTemplatesByUser ( userUID ) ;
}
2023-01-12 15:45:43 +08:00
templates . add ( 0 , SearchTemplateParam . builder ( ) . key ( " -1 " ) . showname ( " 默认模板 " ) . build ( ) ) ;
2023-01-16 17:19:59 +08:00
returnMap . put ( " templates " , templates ) ;
return returnMap ;
2023-01-10 16:52:40 +08:00
}
2023-01-10 18:25:53 +08:00
@Override
public Integer saveCustomTemplate ( SearchTemplateParam params ) {
2023-01-12 18:18:44 +08:00
// 重复名称校验
SearchTemplatePO searchTemplateByName = getHrmResourceMapper ( ) . getCustomTemplateByName ( user . getUID ( ) , params . getShowname ( ) ) ;
2023-01-13 16:50:54 +08:00
OrganizationAssert . isFalse ( " 默认模板 " . equals ( params . getShowname ( ) ) | | null ! = searchTemplateByName , " 该模板名称已存在 " ) ;
2023-01-10 18:25:53 +08:00
SearchTemplatePO templatePO = buildSearchTemplateByFields ( params . getFields ( ) ) ;
if ( null = = templatePO ) {
return - 1 ;
}
templatePO . setName ( params . getShowname ( ) ) ;
templatePO . setCreator ( user . getUID ( ) ) ;
2023-01-13 13:44:05 +08:00
templatePO . setIsused ( " 0 " ) ;
2023-01-10 18:25:53 +08:00
templatePO . setCreateTime ( new Date ( ) ) ;
templatePO . setUpdateTime ( new Date ( ) ) ;
getHrmResourceMapper ( ) . insertCustomTemplate ( templatePO ) ;
return templatePO . getId ( ) ;
}
2023-01-12 15:17:38 +08:00
@Override
public Integer updateCustomTemplate ( Map < String , Object > params ) {
int rowNum = Util . getIntValue ( ( String ) params . get ( " rownum " ) ) ;
int count = 0 ;
2023-01-13 18:40:34 +08:00
List < Long > allIds = getJclOrgCustomTemplateMapper ( ) . listAllId ( ) ;
2023-01-12 15:17:38 +08:00
String currentDate = OrganizationDateUtil . getFormatLocalDate ( new java . util . Date ( ) ) ;
2023-01-13 18:40:34 +08:00
List < String > nameList = new ArrayList < > ( ) ;
for ( int i = 0 ; i < rowNum ; i + + ) {
String recordIndex = " _ " + i ;
String name = Util . null2String ( params . get ( " name " + recordIndex ) ) ;
if ( StringUtils . isNotBlank ( name ) ) {
nameList . add ( name ) ;
}
}
OrganizationAssert . isFalse ( new HashSet < > ( nameList ) . size ( ) < nameList . size ( ) , " 模板名称不能重复 " ) ;
2023-01-12 15:17:38 +08:00
for ( int i = 0 ; i < rowNum ; i + + ) {
String recordIndex = " _ " + i ;
String id = Util . null2String ( params . get ( " id " + recordIndex ) ) ;
String name = Util . null2String ( params . get ( " name " + recordIndex ) ) ;
JclOrgCustomTemplatePO jclOrgCustomTemplatePO = new JclOrgCustomTemplatePO ( ) ;
if ( StringUtils . isNotBlank ( id ) ) {
// 更新
long jclId = Long . parseLong ( id ) ;
jclOrgCustomTemplatePO = MapperProxyFactory . getProxy ( JclOrgCustomTemplateMapper . class ) . selectByPrimaryKey ( jclId ) ;
jclOrgCustomTemplatePO . setName ( name ) ;
jclOrgCustomTemplatePO . setUpdateTime ( new java . sql . Date ( OrganizationDateUtil . stringToDate ( currentDate ) . getTime ( ) ) ) ;
count + = MapperProxyFactory . getProxy ( JclOrgCustomTemplateMapper . class ) . updateByPrimaryKey ( jclOrgCustomTemplatePO ) ;
allIds . remove ( jclId ) ;
} else {
//插入
2023-01-13 18:40:34 +08:00
OrganizationAssert . isFalse ( " " . equals ( name ) , " 模板名称不能为空 " ) ;
2023-01-12 15:17:38 +08:00
jclOrgCustomTemplatePO . setName ( name ) ;
jclOrgCustomTemplatePO . setCreator ( user . getUID ( ) ) ;
jclOrgCustomTemplatePO . setCreateTime ( new java . sql . Date ( OrganizationDateUtil . stringToDate ( currentDate ) . getTime ( ) ) ) ;
jclOrgCustomTemplatePO . setUpdateTime ( new java . sql . Date ( OrganizationDateUtil . stringToDate ( currentDate ) . getTime ( ) ) ) ;
count + = MapperProxyFactory . getProxy ( JclOrgCustomTemplateMapper . class ) . insert ( jclOrgCustomTemplatePO ) ;
}
}
if ( CollectionUtils . isNotEmpty ( allIds ) ) {
count + = MapperProxyFactory . getProxy ( JclOrgCustomTemplateMapper . class ) . deleteByIds ( allIds ) ;
}
return count ;
}
2023-01-10 18:25:53 +08:00
@Override
public void deleteCustomTemplate ( Integer id ) {
getHrmResourceMapper ( ) . deleteCustomTemplate ( id , user . getUID ( ) ) ;
}
2023-01-11 15:42:41 +08:00
@Override
public Map < String , Object > getCustomTransferData ( Map < String , Object > params ) {
Map < String , Object > resultMap = new HashMap < > ( ) ;
String templateId = StringUtils . isNotBlank ( Util . null2String ( params . get ( " templateId " ) ) ) ? Util . null2String ( params . get ( " templateId " ) ) : " -1 " ;
List < TransferDataPO > transferDatas = new ArrayList < > ( ) ;
2023-01-12 14:08:51 +08:00
List < String > transferKeys ;
2023-01-11 15:42:41 +08:00
List < SearchTemplateParam > transferOptions = new ArrayList < > ( ) ;
List < SearchConditionGroup > allConditions = getAllConditions ( ) ;
AtomicInteger idx = new AtomicInteger ( 0 ) ;
for ( SearchConditionGroup allCondition : allConditions ) {
List < SearchConditionItem > items = allCondition . getItems ( ) ;
List < TransferDataPO > collect = items . stream ( ) . map ( item - > TransferDataPO . builder ( ) . id ( item . getDomkey ( ) [ 0 ] ) . label ( item . getLabel ( ) ) . title ( allCondition . getTitle ( ) ) . idx ( Integer . toString ( idx . get ( ) ) ) . build ( ) ) . collect ( Collectors . toList ( ) ) ;
if ( CollectionUtils . isNotEmpty ( collect ) ) {
transferDatas . addAll ( collect ) ;
}
transferOptions . add ( SearchTemplateParam . builder ( ) . key ( Integer . toString ( idx . getAndIncrement ( ) ) ) . showname ( allCondition . getTitle ( ) ) . build ( ) ) ;
}
if ( " -1 " . equals ( templateId ) ) {
2023-01-16 15:08:22 +08:00
// 查询当前使用的模板,没有使用的,则展示默认模板
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 ( ) ;
}
2023-01-11 15:42:41 +08:00
} else {
SearchTemplatePO searchTemplateById = getHrmResourceMapper ( ) . getCustomTemplateById ( templateId ) ;
transferKeys = getSelectKeys ( searchTemplateById ) ;
}
2023-01-13 18:01:17 +08:00
transferOptions . add ( 0 , SearchTemplateParam . builder ( ) . key ( " " ) . showname ( " " ) . build ( ) ) ;
2023-01-11 15:42:41 +08:00
resultMap . put ( " transferDatas " , transferDatas ) ;
resultMap . put ( " transferKeys " , transferKeys ) ;
resultMap . put ( " transferOptions " , transferOptions ) ;
2023-01-16 15:08:22 +08:00
resultMap . put ( " templateId " , templateId ) ;
2023-01-11 15:42:41 +08:00
return resultMap ;
}
2023-01-13 13:44:05 +08:00
@Override
public Integer saveColumnsCustomTemplate ( Map < String , Object > params ) {
String columns = Util . null2String ( params . get ( " columns " ) ) ;
String templateId = Util . null2String ( params . get ( " templateId " ) ) ;
SearchTemplatePO templatePO = buildSearchTemplateByFields ( columns ) ;
JclOrgCustomTemplatePO jclOrgCustomTemplatePO = new JclOrgCustomTemplatePO ( ) ;
2023-01-13 16:35:34 +08:00
if ( StringUtils . isNotBlank ( templateId ) ) {
2023-01-13 18:03:19 +08:00
if ( templateId . equals ( " -1 " ) ) {
getJclOrgCustomTemplateMapper ( ) . updateUsed ( " 0 " , null , String . valueOf ( user . getUID ( ) ) ) ;
} else {
jclOrgCustomTemplatePO = getJclOrgCustomTemplateMapper ( ) . selectByPrimaryKey ( Long . parseLong ( templateId ) ) ;
if ( jclOrgCustomTemplatePO ! = null ) {
jclOrgCustomTemplatePO . setId ( Integer . valueOf ( templateId ) ) ;
jclOrgCustomTemplatePO . setBasicFields ( templatePO . getBasicFields ( ) ) ;
jclOrgCustomTemplatePO . setPersonalFields ( templatePO . getPersonalFields ( ) ) ;
jclOrgCustomTemplatePO . setWorkFields ( templatePO . getWorkFields ( ) ) ;
jclOrgCustomTemplatePO . setIsused ( 1 ) ;
//取消已启用模板
getJclOrgCustomTemplateMapper ( ) . updateUsed ( " 0 " , null , String . valueOf ( user . getUID ( ) ) ) ;
//启用当前模板
getJclOrgCustomTemplateMapper ( ) . updateByPrimaryKeySelective ( jclOrgCustomTemplatePO ) ;
}
2023-01-13 13:44:05 +08:00
}
}
return jclOrgCustomTemplatePO . getId ( ) ;
}
2022-06-21 17:50:56 +08:00
@Override
public Map < String , Object > getSearchCondition ( Map < String , Object > params ) {
2023-01-06 15:35:38 +08:00
String templateId = Util . null2String ( params . get ( " templateId " ) ) ;
2023-01-09 10:27:30 +08:00
String selectKeys = Util . null2String ( params . get ( " selectKeys " ) ) ;
2023-01-06 15:35:38 +08:00
if ( StringUtils . isBlank ( templateId ) ) {
templateId = " -1 " ;
}
2022-06-21 17:50:56 +08:00
Map < String , Object > apiDatas = new HashMap < > ( ) ;
List < SearchConditionGroup > addGroups = new ArrayList < > ( ) ;
2023-01-06 15:35:38 +08:00
List < SearchConditionGroup > allConditions = getAllConditions ( ) ;
// 穿梭框ID, 展示所选字段信息
HrmFieldSearchConditionComInfo hrmFieldSearchConditionComInfo = new HrmFieldSearchConditionComInfo ( ) ;
if ( " -1 " . equals ( templateId ) ) {
2023-01-09 10:27:30 +08:00
if ( StringUtils . isNotBlank ( selectKeys ) ) {
SearchTemplatePO templatePO = buildSearchTemplateByFields ( selectKeys ) ;
2023-01-10 11:37:28 +08:00
if ( null ! = templatePO ) {
buildSearchConditionGroup ( templatePO , hrmFieldSearchConditionComInfo , addGroups ) ;
}
2023-01-09 10:27:30 +08:00
} else {
// 未选择模板展示默认模板搜索条件
if ( CollectionUtils . isNotEmpty ( allConditions ) ) {
addGroups . add ( allConditions . get ( 0 ) ) ;
}
2023-01-06 15:35:38 +08:00
}
} else {
// 选择模板则遍历所选模板所选字段
SearchTemplatePO searchTemplateById = getHrmResourceMapper ( ) . getSearchTemplateById ( templateId ) ;
2023-01-09 10:27:30 +08:00
buildSearchConditionGroup ( searchTemplateById , hrmFieldSearchConditionComInfo , addGroups ) ;
2023-01-06 15:35:38 +08:00
}
apiDatas . put ( " defaultcondition " , addGroups ) ;
apiDatas . put ( " conditions " , allConditions ) ;
2022-06-21 17:50:56 +08:00
return apiDatas ;
}
@Override
public Map < String , Object > getHasRight ( ) {
Map < String , Object > btnDatas = new HashMap < > ( ) ;
2023-04-03 10:06:02 +08:00
ArrayList < MenuBtn > topMenuList = new ArrayList < > ( ) ;
ArrayList < MenuBtn > rightMenuList = new ArrayList < > ( ) ;
2022-11-09 16:58:09 +08:00
if ( HasRightUtil . hasRight ( user , RIGHT_NAME , true ) ) {
topMenuList . add ( MenuBtn . builder ( ) . isBatch ( " 1 " ) . isTop ( " 1 " ) . menuFun ( " new " ) . menuIcon ( " icon-coms-New-Flow " ) . menuName ( " 新建人员 " ) . type ( " BTN_Addnew " ) . build ( ) ) ;
rightMenuList . add ( MenuBtn . builder ( ) . isBatch ( " 1 " ) . isTop ( " 1 " ) . menuFun ( " new " ) . menuIcon ( " icon-coms-New-Flow " ) . menuName ( " 新建人员 " ) . type ( " BTN_Addnew " ) . build ( ) ) ;
}
2023-04-03 10:06:02 +08:00
topMenuList . add ( MenuBtn . builder ( ) . isBatch ( " 1 " ) . isTop ( " 1 " ) . menuFun ( " customization " ) . menuIcon ( " icon-coms-task-list " ) . menuName ( " 列定制 " ) . type ( " BTN_COLUMN " ) . build ( ) ) ;
rightMenuList . add ( MenuBtn . rightMenu_btnLog ( ) ) ;
btnDatas . put ( " topMenu " , topMenuList ) ;
btnDatas . put ( " rightMenu " , rightMenuList ) ;
2022-11-09 16:58:09 +08:00
btnDatas . put ( " hasRight " , true ) ;
2022-06-21 17:50:56 +08:00
return btnDatas ;
}
2022-07-11 15:59:15 +08:00
@Override
public Map < String , Object > getTabForm ( Map < String , Object > params ) {
String viewAttrStr = ( String ) params . get ( " viewAttr " ) ;
OrganizationAssert . notBlank ( viewAttrStr , " 未指定操作类型,请确认 " ) ;
String id = Util . null2String ( params . get ( " id " ) ) ;
OrganizationAssert . notBlank ( id , " 数据有误,请确认 " ) ;
int viewAttr = Integer . parseInt ( viewAttrStr ) ;
Map < String , Object > apiDatas = new HashMap < > ( ) ;
2022-07-12 16:38:27 +08:00
2022-12-09 14:29:20 +08:00
//List<SearchConditionGroup> addGroups = new ArrayList<>();
//SearchConditionItem schemeId = OrganizationFormItemUtil.browserItem(user, 2, 17, viewAttr, false, "等级方案", "161", "schemeId", "schemeBrowser");
//schemeId.setRules("required");
//SearchConditionItem gradeId = OrganizationFormItemUtil.browserItem(user, 2, 17, viewAttr, false, "职级", "161", "gradeId", "gradeBrowser");
//gradeId.setRules("required");
//SearchConditionItem levelId = OrganizationFormItemUtil.browserItem(user, 2, 17, viewAttr, false, "职等", "162", "levelId", "levelBrowser");
//levelId.setRules("required");
//SearchConditionItem sequenceId = OrganizationFormItemUtil.browserItem(user, 2, 17, viewAttr, false, "岗位序列", "161", "sequenceId", "sequenceBrowser");
//sequenceId.setRules("required");
//SearchConditionItem postId = OrganizationFormItemUtil.browserItem(user, 2, 17, viewAttr, false, "职务分类", "161", "postId", "postBrowser");
//postId.setRules("required");
//SearchConditionItem postInfoId = OrganizationFormItemUtil.browserItem(user, 2, 17, viewAttr, false, "职务信息", "161", "postInfoId", "postInfoBrowser");
//postInfoId.setRules("required");
//SearchConditionItem companyId = OrganizationFormItemUtil.browserItem(user, 2, 17, viewAttr, false, "分部", "164", "companyId", "");
//companyId.setRules("required");
//SearchConditionItem departmentId = OrganizationFormItemUtil.browserItem(user, 2, 17, viewAttr, false, "部门", "4", "departmentId", "");
//departmentId.setRules("required");
//SearchConditionItem jobId = OrganizationFormItemUtil.browserItem(user, 2, 17, viewAttr, false, "岗位", "161", "jobId", "jobBrowser");
//jobId.setRules("required");
//
//
//// 编辑状态下赋值操作
//HrmRelationPO relationPO = getHrmRelationMapper().getRelationById(Long.parseLong(id));
//if (null != relationPO) {
// setBrowserValue(schemeId, relationPO.getSchemeId(), getSchemeMapper().listSchemesByIds(Stream.of(relationPO.getSchemeId()).collect(Collectors.toList())), null, null);
// setBrowserValue(gradeId, relationPO.getGradeId(), getGradeMapper().listGradessByIds(Stream.of(relationPO.getGradeId()).collect(Collectors.toList())), "scheme_id", relationPO.getSchemeId());
// setBrowserValue(levelId, relationPO.getLevelId(), getLevelMapper().listLevelsByIds(DeleteParam.builder().ids(relationPO.getLevelId()).build().getIds()), "grade_id", relationPO.getGradeId());
// setBrowserValue(sequenceId, relationPO.getSequenceId(), getSequenceMapper().listSequencesByIds(Stream.of(relationPO.getSequenceId()).collect(Collectors.toList())), "scheme_id", relationPO.getSchemeId());
// setBrowserValue(postId, relationPO.getPostId(), getPostMapper().listPostsByIds(Stream.of(relationPO.getPostId()).collect(Collectors.toList())), null, null);
// setBrowserValue(postInfoId, relationPO.getPostInfoId(), getPostInfoMapper().listPostInfosByIds(Stream.of(relationPO.getPostInfoId()).collect(Collectors.toList())), "post_id", relationPO.getPostId());
//
// List<Map<String, Object>> companyMaps = new ArrayList<>();
// String scCompanyNameById = MapperProxyFactory.getProxy(SystemDataMapper.class).getScCompanyNameById(relationPO.getCompanyId().toString());
// Map<String, Object> companyMap = new HashMap<>();
// companyMap.put(relationPO.getCompanyId().toString(), scCompanyNameById);
// companyMaps.add(companyMap);
// setBrowserValue(companyId, relationPO.getCompanyId(), companyMaps, null, null);
//
// List<Map<String, Object>> departmentMaps = new ArrayList<>();
// String departmentNameById = MapperProxyFactory.getProxy(SystemDataMapper.class).getScDepartmentNameById(relationPO.getDepartmentId().toString());
// Map<String, Object> departmentMap = new HashMap<>();
// departmentMap.put(relationPO.getDepartmentId().toString(), departmentNameById);
// departmentMaps.add(departmentMap);
// setBrowserValue(departmentId, relationPO.getDepartmentId(), departmentMaps, "subcompany1", relationPO.getCompanyId());
//
// setBrowserValue(jobId, relationPO.getJobId(), getJobMapper().listJobsByIds(Stream.of(relationPO.getJobId()).collect(Collectors.toList())), "departmentid", relationPO.getDepartmentId());
//}
//
//addGroups.add(new SearchConditionGroup("岗职位体系", true, Stream.of(schemeId, gradeId, levelId, sequenceId, postId, postInfoId).collect(Collectors.toList())));
//addGroups.add(new SearchConditionGroup("组织机构", true, Stream.of(companyId, departmentId, jobId).collect(Collectors.toList())));
//HashMap<String, Object> buttonsMap = new HashMap<>();
//buttonsMap.put("hasEdit", true);
//buttonsMap.put("hasSave", true);
//apiDatas.put("buttons", buttonsMap);
//apiDatas.put("conditions", addGroups);
2022-07-11 15:59:15 +08:00
return apiDatas ;
}
@Override
public long saveTabForm ( HrmRelationSaveParam params ) {
HrmRelationPO hrmRelationPO = HrmRelationBO . convertSaveParamToPO ( params ) ;
hrmRelationPO . setCreator ( ( long ) user . getUID ( ) ) ;
hrmRelationPO . setCreateTime ( new Date ( ) ) ;
hrmRelationPO . setDeleteType ( 0 ) ;
getHrmRelationMapper ( ) . insertIgnoreNull ( hrmRelationPO ) ;
return hrmRelationPO . getId ( ) ;
}
@Override
public long updateTabForm ( HrmRelationSaveParam params ) {
HrmRelationPO hrmRelationPO = HrmRelationBO . convertSaveParamToPO ( params ) ;
2022-07-12 16:38:27 +08:00
// 判断新增OR更新
HrmRelationPO relationPO = getHrmRelationMapper ( ) . getRelationById ( params . getId ( ) ) ;
if ( null = = relationPO ) {
hrmRelationPO . setCreator ( ( long ) user . getUID ( ) ) ;
hrmRelationPO . setCreateTime ( new Date ( ) ) ;
hrmRelationPO . setDeleteType ( 0 ) ;
getHrmRelationMapper ( ) . insertIgnoreNull ( hrmRelationPO ) ;
} else {
hrmRelationPO . setUpdateTime ( new Date ( ) ) ;
getHrmRelationMapper ( ) . updateHrmRelation ( hrmRelationPO ) ;
}
RecordSet rs = new RecordSet ( ) ;
rs . execute ( " update HrmResource set subcompanyid1 = " + params . getCompanyId ( ) + " ,departmentid = " + params . getDepartmentId ( ) + " ,jobtitle = " + params . getJobId ( ) + " where id = " + params . getId ( ) ) ;
HrmFaceCheckManager . sync ( params . getId ( ) . toString ( ) , HrmFaceCheckManager . getOptUpdate ( ) , " hrm_e9_HrmResourceBaseService_editResourceBase " , HrmFaceCheckManager . getOaResource ( ) ) ;
2022-07-11 15:59:15 +08:00
return hrmRelationPO . getId ( ) ;
}
2023-01-12 09:41:58 +08:00
@Override
public Map < String , Object > getCustomTemplate ( Map < String , Object > params ) {
List < ExtendInfoPO > infoPOList = new ArrayList < > ( ) ;
2023-01-12 16:49:54 +08:00
infoPOList . add ( ExtendInfoPO . builder ( ) . viewAttr ( 2 ) . id ( null ) . fieldName ( " name " ) . fieldNameDesc ( " 模板名称 " ) . fieldType ( " varchar(255) " ) . controlType ( 1 ) . browserType ( " 1 " ) . customValue ( " [ \" input \" , \" text \" , \" 50 \" ] " ) . showOrder ( 1 ) . isrequired ( 0 ) . isSystemDefault ( 0 ) . build ( ) ) ;
infoPOList . add ( ExtendInfoPO . builder ( ) . viewAttr ( 1 ) . id ( null ) . fieldName ( " createTime " ) . fieldNameDesc ( " 创建时间 " ) . fieldType ( " date " ) . controlType ( 1 ) . browserType ( " 1 " ) . customValue ( " [ \" input \" , \" text \" , \" 50 \" ] " ) . showOrder ( 2 ) . isrequired ( 0 ) . isSystemDefault ( 0 ) . build ( ) ) ;
2023-01-12 09:41:58 +08:00
Map < String , Object > tabInfoMap = new HashMap < > ( ) ;
2023-01-12 16:49:54 +08:00
tabInfoMap . put ( " columns " , ExtendInfoBO . convertInfoListToTable ( user , infoPOList , false , true ) ) ;
2023-01-12 09:41:58 +08:00
List < JclOrgCustomTemplatePO > jclOrgCustomTemplatePOS = MapperProxyFactory . getProxy ( JclOrgCustomTemplateMapper . class ) . listAll ( ) ;
List < Integer > isUsed = new ArrayList < > ( ) ;
AtomicInteger index = new AtomicInteger ( 0 ) ;
List < Map < String , Object > > collect = jclOrgCustomTemplatePOS . stream ( ) . map ( item - > {
Map < String , Object > resultMap = new HashMap < > ( ) ;
resultMap . put ( " id " , item . getId ( ) ) ;
resultMap . put ( " name " , item . getName ( ) ) ;
2023-01-13 18:03:19 +08:00
resultMap . put ( " createTime " , DateUtil . getDate ( item . getCreateTime ( ) , " yyyy-MM-dd " ) ) ;
2023-01-12 09:41:58 +08:00
2023-01-12 16:49:54 +08:00
if ( item . getIsused ( ) ! = null ) {
2023-01-12 15:17:38 +08:00
if ( 1 = = item . getIsused ( ) ) {
isUsed . add ( index . get ( ) ) ;
}
index . getAndIncrement ( ) ;
2023-01-12 09:41:58 +08:00
}
return resultMap ;
} ) . collect ( Collectors . toList ( ) ) ;
tabInfoMap . put ( " datas " , collect ) ;
tabInfoMap . put ( " api_status " , true ) ;
Map < String , List < Integer > > isUsedMap = new HashMap < > ( ) ;
isUsedMap . put ( " status " , isUsed ) ;
tabInfoMap . put ( " selectedData " , isUsedMap ) ;
tabInfoMap . put ( " isModalEdit " , false ) ;
return tabInfoMap ;
// OrganizationWeaTable<JclOrgCustomTemplateVO> table = new OrganizationWeaTable<>(user, JclOrgCustomTemplateVO.class);
// String sqlWhere = buildSqlWhere(params);
// table.setSqlwhere(sqlWhere);
// WeaResultMsg result = new WeaResultMsg(false);
// result.putAll(table.makeDataResult());
// result.success();
// return new HashMap<>(result.getResultMap());
}
2022-06-21 13:49:37 +08:00
/ * *
* 查询条件
*
* @param params
* @return
* /
2023-01-06 17:20:29 +08:00
private String buildSqlWhere ( Map < String , Object > params ) {
2023-01-09 10:27:30 +08:00
HrmFieldSearchConditionComInfo hrmFieldSearchConditionComInfo = new HrmFieldSearchConditionComInfo ( ) ;
List < SearchConditionItem > conditionItems = new ArrayList < > ( ) ;
2023-01-09 18:06:57 +08:00
List < CusFormFieldPO > hrmFieldsByScopeId = getSystemDataMapper ( ) . getHrmFieldsByScopeId ( HrmGroupEnum . HRM_BASIC . getGroupType ( ) . toString ( ) ) ;
2023-01-09 10:27:30 +08:00
createConditionItems ( hrmFieldSearchConditionComInfo , hrmFieldsByScopeId , conditionItems ) ;
2023-01-09 18:06:57 +08:00
hrmFieldsByScopeId = getSystemDataMapper ( ) . getHrmFieldsByScopeId ( HrmGroupEnum . HRM_PERSONAL . getGroupType ( ) . toString ( ) ) ;
2023-01-09 10:27:30 +08:00
createConditionItems ( hrmFieldSearchConditionComInfo , hrmFieldsByScopeId , conditionItems ) ;
2023-01-09 18:06:57 +08:00
hrmFieldsByScopeId = getSystemDataMapper ( ) . getHrmFieldsByScopeId ( HrmGroupEnum . HRM_WORK . getGroupType ( ) . toString ( ) ) ;
2023-01-09 10:27:30 +08:00
createConditionItems ( hrmFieldSearchConditionComInfo , hrmFieldsByScopeId , conditionItems ) ;
Map < String , SearchConditionItem > allFieldsMap = conditionItems . stream ( ) . collect ( Collectors . toMap ( item - > item . getDomkey ( ) [ 0 ] , item - > item , ( k1 , k2 ) - > k1 ) ) ;
2022-06-21 13:49:37 +08:00
DBType dbType = DBType . get ( new RecordSet ( ) . getDBType ( ) ) ;
2023-02-06 09:49:36 +08:00
StringBuilder sb = new StringBuilder ( " where 1=1 " ) ;
2023-02-14 17:09:22 +08:00
if ( params . containsKey ( " lastName " ) ) {
2023-03-01 16:26:10 +08:00
// sb.append(" and t.status = 1");
sb . append ( " and t.status < 4 " ) ;
2023-02-14 17:09:22 +08:00
}
2023-01-06 17:20:29 +08:00
for ( Map . Entry < String , Object > entry : params . entrySet ( ) ) {
2023-02-06 09:49:36 +08:00
String key = entry . getKey ( ) ;
2023-01-09 18:06:57 +08:00
String value = Util . null2String ( entry . getValue ( ) ) ;
2023-02-14 17:09:22 +08:00
if ( StringUtils . isBlank ( value ) ) {
continue ;
}
2023-02-06 09:49:36 +08:00
if ( " lastName " . equals ( key ) ) {
2023-02-14 17:09:22 +08:00
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 ( " ' " ) ;
2023-03-01 16:26:10 +08:00
} else {
sb = new StringBuilder ( " where 1 = 2 " ) ;
break ;
2023-02-06 09:49:36 +08:00
}
2023-01-09 18:06:57 +08:00
}
2023-02-06 09:49:36 +08:00
2023-01-09 10:27:30 +08:00
SearchConditionItem searchConditionItem = allFieldsMap . get ( key ) ;
// 根据不同的类型,不同的查询方式
2023-01-13 09:46:37 +08:00
buildDynamicSql ( searchConditionItem , key , value , sb , dbType ) ;
2022-06-21 13:49:37 +08:00
}
2023-01-11 14:26:13 +08:00
if ( searchJobTitle ) {
String jobTitleIds = StringUtils . join ( jobTitleList , " , " ) ;
sb . append ( " and t.jobtitle in ( " ) . append ( StringUtils . isNotBlank ( jobTitleIds ) ? jobTitleIds : " '' " ) . append ( " ) " ) ;
}
2022-06-21 13:49:37 +08:00
2022-11-01 10:05:43 +08:00
// 分权查询
2022-12-13 10:42:35 +08:00
DetachUtil detachUtil = new DetachUtil ( user ) ;
2022-11-02 10:55:15 +08:00
String parentCompanyIds = detachUtil . getJclRoleLevels ( ) ;
if ( detachUtil . isDETACH ( ) ) {
2023-01-11 14:26:13 +08:00
sb . append ( " and t.subcompanyid1 in( " ) . append ( parentCompanyIds ) . append ( " ) " ) ;
2022-11-01 10:05:43 +08:00
}
2023-01-09 18:06:57 +08:00
return sb . toString ( ) ;
2022-06-21 13:49:37 +08:00
}
2022-06-20 18:31:11 +08:00
public List < SearchTree > getFilterCompany ( String id , String type , String keyword ) {
List < SearchTree > searchTree = new ArrayList < > ( ) ;
// 通过分部、公司 组装数据
if ( StringUtil . isEmpty ( id ) | | TYPE_COMP . equals ( type ) ) {
2022-11-28 11:15:54 +08:00
Integer parentCompId = StringUtil . isEmpty ( id ) ? null : Integer . parseInt ( id ) ;
2022-12-09 14:29:20 +08:00
DepartmentPO departmentBuild = DepartmentPO . builder ( ) . departmentName ( keyword ) . subCompanyId1 ( parentCompId ) . canceled ( 0 ) . build ( ) ;
CompPO compBuild = CompPO . builder ( ) . subCompanyName ( keyword ) . supSubComId ( parentCompId ) . canceled ( 0 ) . build ( ) ;
2022-06-20 18:31:11 +08:00
// 所属分部下的岗位
2022-12-09 14:29:20 +08:00
JobPO jobBuild = JobPO . builder ( ) . jobTitleName ( keyword ) . ecCompany ( parentCompId ) . forbiddenTag ( 0 ) . build ( ) ;
2022-06-20 18:31:11 +08:00
searchTree = buildTreeByCompAndDept ( departmentBuild , compBuild , jobBuild ) ;
} else if ( TYPE_DEPT . equals ( type ) ) {
2022-11-29 09:54:18 +08:00
Integer parentDeptId = Integer . parseInt ( id ) ;
2022-12-09 14:29:20 +08:00
DepartmentPO departmentBuild = DepartmentPO . builder ( ) . departmentName ( keyword ) . supDepId ( parentDeptId ) . canceled ( 0 ) . build ( ) ;
2022-06-20 18:31:11 +08:00
// 所属分部下的岗位
2022-12-09 14:29:20 +08:00
JobPO jobBuild = JobPO . builder ( ) . jobTitleName ( keyword ) . ecDepartment ( parentDeptId ) . forbiddenTag ( 0 ) . build ( ) ;
2022-06-20 18:31:11 +08:00
searchTree = buildTreeByDeptAndJob ( departmentBuild , jobBuild ) ;
} else if ( TYPE_JOB . equals ( type ) ) {
// 查询部门信息
2022-12-09 14:29:20 +08:00
List < JobPO > filterDeparts = getJobMapper ( ) . listPOsByFilter ( JobPO . builder ( ) . jobTitleName ( keyword ) . parentJob ( Long . parseLong ( id ) ) . forbiddenTag ( 0 ) . build ( ) ) ;
2022-06-20 18:31:11 +08:00
Set < JobPO > builderJobs = new HashSet < > ( ) ;
for ( JobPO departmentPO : filterDeparts ) {
buildParentJobs ( departmentPO , builderJobs ) ;
}
searchTree = SearchTreeUtil . builderTreeMode ( JobBO . buildSetToSearchTree ( builderJobs ) ) ;
}
return searchTree ;
}
/ * *
* 分部 、 部门 组装左侧树
*
* @param departmentBuild
* @param compBuild
* @param jobBuild
* @return
* /
2022-11-30 16:06:40 +08:00
private List < SearchTree > buildTreeByCompAndDept ( DepartmentPO departmentBuild , CompPO compBuild , JobPO jobBuild ) {
2022-06-20 18:31:11 +08:00
List < JobPO > jobPOS = getJobMapper ( ) . listPOsByFilter ( jobBuild ) ;
2022-12-13 10:42:35 +08:00
new DetachUtil ( user ) . filterJobList ( jobPOS ) ;
2022-11-30 15:55:27 +08:00
List < DepartmentPO > filterDeparts = getDepartmentMapper ( ) . listByFilter ( departmentBuild , " showorder " ) ;
2022-12-13 10:42:35 +08:00
new DetachUtil ( user ) . filterDepartmentList ( filterDeparts ) ;
2022-06-20 18:31:11 +08:00
// 添加父级岗位
Set < JobPO > builderJobs = new HashSet < > ( ) ;
for ( JobPO jobPO : jobPOS ) {
buildParentJobs ( jobPO , builderJobs ) ;
}
// 添加岗位的上级部门或分部
List < SearchTree > jobTrees = SearchTreeUtil . builderTreeMode ( JobBO . buildSetToSearchTree ( builderJobs ) ) ;
String parentDeptS = jobTrees . stream ( ) . map ( SearchTree : : getParentComp ) . collect ( Collectors . joining ( " , " ) ) ;
if ( ! StringUtil . isEmpty ( parentDeptS ) ) {
2022-07-26 09:40:13 +08:00
// 兼容SQLServer每次最多in,2100条数据
2022-12-09 14:29:20 +08:00
List < Long > ids = DeleteParam . builder ( ) . ids ( parentDeptS ) . build ( ) . getIds ( ) ;
2022-07-26 09:40:13 +08:00
int ceilCount = ( int ) Math . ceil ( ( double ) ids . size ( ) / 1000 ) ;
List < DepartmentPO > departmentsByIds = new ArrayList < > ( ) ;
2022-10-24 19:06:07 +08:00
for ( int i = 1 ; i < ceilCount + 1 ; i + + ) {
2022-07-26 09:40:13 +08:00
List < Long > longs = PageUtil . subList ( i , 1000 , ids ) ;
List < DepartmentPO > departmentsById = getDepartmentMapper ( ) . getDeptsByIds ( longs ) ;
if ( CollectionUtils . isNotEmpty ( departmentsById ) ) {
departmentsByIds . addAll ( departmentsById ) ;
}
}
if ( CollectionUtils . isNotEmpty ( departmentsByIds ) ) {
filterDeparts . addAll ( departmentsByIds ) ;
2022-06-20 18:31:11 +08:00
}
}
// 查询分部信息
2022-11-30 16:06:40 +08:00
List < CompPO > filterComps = getCompMapper ( ) . listByFilter ( compBuild , " showorder " ) ;
2022-12-13 10:42:35 +08:00
new DetachUtil ( user ) . filterCompanyList ( filterComps ) ;
2022-06-20 18:31:11 +08:00
Set < DepartmentPO > builderDeparts = new HashSet < > ( ) ;
for ( DepartmentPO departmentPO : filterDeparts ) {
buildParentDepts ( departmentPO , builderDeparts ) ;
}
2022-11-08 15:21:29 +08:00
List < SearchTree > departmentList = DepartmentBO . buildSetToSearchTree ( builderDeparts ) ;
2022-10-25 15:43:02 +08:00
List < SearchTree > deptTrees = SearchTreeUtil . builderTreeMode ( departmentList ) ;
List < SearchTree > searchTrees = SearchTreeUtil . builderTreeMode ( departmentList , jobTrees ) ;
2022-06-20 18:31:11 +08:00
// 添加部门的上级分部
String parentCompS = deptTrees . stream ( ) . map ( SearchTree : : getParentComp ) . collect ( Collectors . joining ( " , " ) ) ;
if ( ! StringUtil . isEmpty ( parentCompS ) ) {
2022-11-30 16:06:40 +08:00
List < CompPO > compsByIds = getCompMapper ( ) . getCompsByIds ( DeleteParam . builder ( ) . ids ( parentCompS ) . build ( ) . getIds ( ) ) ;
2022-06-20 18:31:11 +08:00
if ( CollectionUtils . isNotEmpty ( compsByIds ) ) {
filterComps . addAll ( compsByIds ) ;
}
}
2022-11-30 16:06:40 +08:00
List < CompPO > allCompanys = getCompMapper ( ) . listAll ( " showorder " ) ;
2022-12-13 10:42:35 +08:00
new DetachUtil ( user ) . filterCompanyList ( allCompanys ) ;
2022-11-30 16:06:40 +08:00
Map < Integer , CompPO > allMaps = allCompanys . stream ( ) . collect ( Collectors . toMap ( CompPO : : getId , item - > item , ( k1 , k2 ) - > k1 ) ) ;
Set < CompPO > builderComps = new HashSet < > ( ) ;
for ( CompPO compPO : filterComps ) {
2022-11-09 16:58:09 +08:00
buildParentComps ( compPO , builderComps , allMaps ) ;
2022-06-20 18:31:11 +08:00
}
2022-11-30 16:06:40 +08:00
return SearchTreeUtil . builderTreeMode ( CompBO . buildSetToSearchTree ( builderComps ) , searchTrees ) ;
2022-06-20 18:31:11 +08:00
}
private List < SearchTree > buildTreeByDeptAndJob ( DepartmentPO departmentBuild , JobPO jobBuild ) {
List < JobPO > jobPOS = getJobMapper ( ) . listPOsByFilter ( jobBuild ) ;
2022-11-30 15:55:27 +08:00
List < DepartmentPO > filterDeparts = getDepartmentMapper ( ) . listByFilter ( departmentBuild , " showorder " ) ;
2022-06-20 18:31:11 +08:00
// 添加父级岗位
Set < JobPO > builderJobs = new HashSet < > ( ) ;
for ( JobPO jobPO : jobPOS ) {
buildParentJobs ( jobPO , builderJobs ) ;
}
// 添加岗位的上级部门或分部
List < SearchTree > jobTrees = SearchTreeUtil . builderTreeMode ( JobBO . buildSetToSearchTree ( builderJobs ) ) ;
String parentDeptS = jobTrees . stream ( ) . map ( SearchTree : : getParentComp ) . collect ( Collectors . joining ( " , " ) ) ;
if ( ! StringUtil . isEmpty ( parentDeptS ) ) {
2022-07-26 09:40:13 +08:00
// 兼容SQLServer每次最多in,2100条数据
2023-01-12 14:08:51 +08:00
List < Long > ids = DeleteParam . builder ( ) . ids ( parentDeptS ) . build ( ) . getIds ( ) ;
2022-07-26 09:40:13 +08:00
int ceilCount = ( int ) Math . ceil ( ( double ) ids . size ( ) / 1000 ) ;
List < DepartmentPO > departmentsByIds = new ArrayList < > ( ) ;
for ( int i = 0 ; i < ceilCount - 1 ; i + + ) {
List < DepartmentPO > departmentsById = getDepartmentMapper ( ) . getDeptsByIds ( PageUtil . subList ( i , 1000 , ids ) ) ;
if ( CollectionUtils . isNotEmpty ( departmentsById ) ) {
departmentsByIds . addAll ( departmentsById ) ;
}
}
if ( CollectionUtils . isNotEmpty ( departmentsByIds ) ) {
filterDeparts . addAll ( departmentsByIds ) ;
2022-06-20 18:31:11 +08:00
}
}
// 查询分部信息
Set < DepartmentPO > builderDeparts = new HashSet < > ( ) ;
for ( DepartmentPO departmentPO : filterDeparts ) {
buildParentDepts ( departmentPO , builderDeparts ) ;
}
2022-11-08 15:21:29 +08:00
return SearchTreeUtil . builderTreeMode ( DepartmentBO . buildSetToSearchTree ( builderDeparts ) , jobTrees ) ;
2022-06-20 18:31:11 +08:00
}
private void buildParentJobs ( JobPO jobPO , Set < JobPO > builderJobs ) {
builderJobs . add ( jobPO ) ;
if ( SearchTreeUtil . isTop ( jobPO . getParentJob ( ) ) ) {
return ;
}
JobPO parentJob = getJobMapper ( ) . getJobById ( jobPO . getParentJob ( ) ) ;
if ( null ! = parentJob ) {
buildParentJobs ( parentJob , builderJobs ) ;
}
}
/ * *
* 添加查询元素的父级元素
*
* @param departmentPO
* @param builderDeparts
* /
private void buildParentDepts ( DepartmentPO departmentPO , Set < DepartmentPO > builderDeparts ) {
builderDeparts . add ( departmentPO ) ;
2022-11-29 09:54:18 +08:00
if ( SearchTreeUtil . isTop ( departmentPO . getSupDepId ( ) ) ) {
2022-06-20 18:31:11 +08:00
return ;
}
2022-11-29 09:54:18 +08:00
DepartmentPO parentDept = getDepartmentMapper ( ) . getDeptById ( departmentPO . getSupDepId ( ) ) ;
2022-06-20 18:31:11 +08:00
if ( null ! = parentDept ) {
buildParentDepts ( parentDept , builderDeparts ) ;
}
}
/ * *
* 添加查询元素的父级元素
*
* @param compPO
* @param builderComps
* /
2022-11-30 16:06:40 +08:00
private void buildParentComps ( CompPO compPO , Set < CompPO > builderComps , Map < Integer , CompPO > allMaps ) {
2022-06-20 18:31:11 +08:00
builderComps . add ( compPO ) ;
2022-11-30 16:06:40 +08:00
CompPO parentComp = allMaps . get ( compPO . getSupSubComId ( ) ) ;
2022-06-20 18:31:11 +08:00
if ( null ! = parentComp ) {
2022-11-09 16:58:09 +08:00
buildParentComps ( parentComp , builderComps , allMaps ) ;
2022-06-20 18:31:11 +08:00
}
}
2022-10-17 17:16:26 +08:00
2022-10-25 15:43:02 +08:00
2023-01-09 10:27:30 +08:00
/ * *
* 获取所有搜索字段信息构建的高级搜索表单
*
* @return
* /
2023-01-06 17:20:29 +08:00
public List < SearchConditionGroup > getAllConditions ( ) {
HrmFieldSearchConditionComInfo hrmFieldSearchConditionComInfo = new HrmFieldSearchConditionComInfo ( ) ;
List < SearchConditionGroup > addGroups = new ArrayList < > ( ) ;
List < SearchConditionItem > basicConditionItems = new ArrayList < > ( ) ;
List < SearchConditionItem > personalConditionItems = new ArrayList < > ( ) ;
List < SearchConditionItem > workConditionItems = new ArrayList < > ( ) ;
2023-01-06 15:35:38 +08:00
2023-01-06 17:20:29 +08:00
// 基本信息:-1
2023-01-09 18:06:57 +08:00
List < CusFormFieldPO > hrmFieldsByScopeId = getSystemDataMapper ( ) . getHrmFieldsByScopeId ( HrmGroupEnum . HRM_BASIC . getGroupType ( ) . toString ( ) ) ;
2023-01-06 17:20:29 +08:00
createConditionItems ( hrmFieldSearchConditionComInfo , hrmFieldsByScopeId , basicConditionItems ) ;
if ( CollectionUtils . isNotEmpty ( basicConditionItems ) ) {
addGroups . add ( new SearchConditionGroup ( " 基本信息 " , true , basicConditionItems ) ) ;
}
// 个人信息: 1
2023-01-09 18:06:57 +08:00
hrmFieldsByScopeId = getSystemDataMapper ( ) . getHrmFieldsByScopeId ( HrmGroupEnum . HRM_PERSONAL . getGroupType ( ) . toString ( ) ) ;
2023-01-06 17:20:29 +08:00
createConditionItems ( hrmFieldSearchConditionComInfo , hrmFieldsByScopeId , personalConditionItems ) ;
if ( CollectionUtils . isNotEmpty ( personalConditionItems ) ) {
addGroups . add ( new SearchConditionGroup ( " 个人信息 " , true , personalConditionItems ) ) ;
}
// 工作信息: 3
2023-01-09 18:06:57 +08:00
hrmFieldsByScopeId = getSystemDataMapper ( ) . getHrmFieldsByScopeId ( HrmGroupEnum . HRM_WORK . getGroupType ( ) . toString ( ) ) ;
2023-01-06 17:20:29 +08:00
createConditionItems ( hrmFieldSearchConditionComInfo , hrmFieldsByScopeId , workConditionItems ) ;
if ( CollectionUtils . isNotEmpty ( workConditionItems ) ) {
addGroups . add ( new SearchConditionGroup ( " 工作信息 " , true , workConditionItems ) ) ;
}
return addGroups ;
}
2023-01-06 15:35:38 +08:00
/ * *
* 构建查询条件Item
*
* @param hrmFieldSearchConditionComInfo
* @param formFields
* @param conditionItems
* /
private void createConditionItems ( HrmFieldSearchConditionComInfo hrmFieldSearchConditionComInfo , List < CusFormFieldPO > formFields , List < SearchConditionItem > conditionItems ) {
for ( CusFormFieldPO cusFormFieldPO : formFields ) {
2023-01-10 16:52:40 +08:00
if ( " jobactivity " . equals ( cusFormFieldPO . getFieldName ( ) ) ) {
// 职务: 282
cusFormFieldPO . setType ( " 282 " ) ;
}
2023-01-06 15:35:38 +08:00
HrmFieldBean hrmFieldBean = new HrmFieldBean ( ) ;
hrmFieldBean . setFieldid ( Util . null2String ( cusFormFieldPO . getFieldId ( ) ) ) ;
hrmFieldBean . setFieldname ( cusFormFieldPO . getScopeId ( ) + " _ " + cusFormFieldPO . getTableName ( ) + " _ " + cusFormFieldPO . getFieldName ( ) ) ;
hrmFieldBean . setFieldlabel ( cusFormFieldPO . getFieldLabel ( ) ) ;
hrmFieldBean . setFieldhtmltype ( Util . null2String ( cusFormFieldPO . getFieldHtmlType ( ) ) ) ;
hrmFieldBean . setType ( cusFormFieldPO . getType ( ) ) ;
hrmFieldBean . setIsQuickSearch ( false ) ;
hrmFieldBean . setIsScope ( false ) ;
hrmFieldBean . setDmlurl ( cusFormFieldPO . getDmlUrl ( ) ) ;
2023-01-06 17:20:29 +08:00
hrmFieldBean . setIssystem ( " hrm " . equals ( cusFormFieldPO . getTableName ( ) ) ? " 1 " : " 0 " ) ;
hrmFieldBean . setIsFormField ( true ) ;
2023-02-06 09:49:36 +08:00
if ( " -1_hrm_status " . equals ( hrmFieldBean . getFieldname ( ) ) ) {
hrmFieldBean . setFieldvalue ( " 1 " ) ;
}
2023-01-06 17:20:29 +08:00
SearchConditionItem searchConditionItem = hrmFieldSearchConditionComInfo . getSearchConditionItem ( hrmFieldBean , user ) ;
conditionItems . add ( searchConditionItem ) ;
2023-01-09 18:06:57 +08:00
// 如果为下拉框,添加一条空选项
if ( searchConditionItem . getConditionType ( ) . equals ( ConditionType . SELECT ) ) {
addEmptyForSelect ( searchConditionItem ) ;
}
2023-01-06 15:35:38 +08:00
}
}
2023-01-06 17:20:29 +08:00
/ * *
* 获取模板中的字段 , 构建搜索条件
*
* @param hrmFieldSearchConditionComInfo
* @param addGroups
* @param title
* @param scopeid
* @param fieldNames
* /
2023-01-06 15:35:38 +08:00
private void getTemplateItems ( HrmFieldSearchConditionComInfo hrmFieldSearchConditionComInfo , List < SearchConditionGroup > addGroups , String title , Integer scopeid , String [ ] fieldNames ) {
try {
HrmFieldManager hfm = new HrmFieldManager ( " HrmCustomFieldByInfoType " , scopeid ) ;
List < SearchConditionItem > conditionItems = new ArrayList < > ( ) ;
2023-01-10 14:08:41 +08:00
for ( String field : fieldNames ) {
String fieldName = field . substring ( field . lastIndexOf ( " _ " ) + 1 ) ;
2023-01-06 15:35:38 +08:00
JSONObject hrmFieldConf = hfm . getHrmFieldConf ( fieldName ) ;
if ( null = = hrmFieldConf ) {
continue ;
}
boolean baseField = hfm . isBaseField ( fieldName ) ;
HrmFieldBean hrmFieldBean = new HrmFieldBean ( ) ;
hrmFieldBean . setFieldid ( Util . null2String ( hrmFieldConf . getString ( " id " ) ) ) ;
hrmFieldBean . setFieldname ( scopeid + " _ " + ( baseField ? " hrm " : " cus " ) + " _ " + fieldName ) ;
hrmFieldBean . setFieldlabel ( hrmFieldConf . getString ( " fieldlabel " ) ) ;
hrmFieldBean . setFieldhtmltype ( hrmFieldConf . getString ( " fieldhtmltype " ) ) ;
hrmFieldBean . setType ( hrmFieldConf . getString ( " type " ) ) ;
hrmFieldBean . setDmlurl ( hrmFieldConf . getString ( " dmlurl " ) ) ;
2023-01-06 17:20:29 +08:00
hrmFieldBean . setIssystem ( baseField ? " 1 " : " 0 " ) ;
hrmFieldBean . setIsFormField ( true ) ;
2023-01-06 15:35:38 +08:00
hrmFieldBean . setIsQuickSearch ( false ) ;
hrmFieldBean . setIsScope ( false ) ;
2023-01-10 16:52:40 +08:00
if ( " jobactivity " . equals ( fieldName ) ) {
// 职务: 282
hrmFieldBean . setType ( " 282 " ) ;
}
2023-01-06 17:20:29 +08:00
SearchConditionItem searchConditionItem = hrmFieldSearchConditionComInfo . getSearchConditionItem ( hrmFieldBean , user ) ;
conditionItems . add ( searchConditionItem ) ;
2023-01-09 18:06:57 +08:00
// 如果为下拉框,添加一条空选项
if ( searchConditionItem . getConditionType ( ) . equals ( ConditionType . SELECT ) ) {
addEmptyForSelect ( searchConditionItem ) ;
}
2023-01-06 15:35:38 +08:00
}
if ( CollectionUtils . isNotEmpty ( conditionItems ) ) {
addGroups . add ( new SearchConditionGroup ( title , true , conditionItems ) ) ;
}
} catch ( JSONException e ) {
throw new RuntimeException ( e ) ;
2022-10-25 15:43:02 +08:00
}
}
2023-01-09 10:27:30 +08:00
/ * *
* 根据所选字段信息 , 构建搜素模板对象
*
* @param fields
* @return
* /
private SearchTemplatePO buildSearchTemplateByFields ( String fields ) {
String [ ] split = fields . split ( " , " ) ;
if ( split . length > 0 ) {
2023-01-10 11:37:28 +08:00
List < String > basicFields = new ArrayList < > ( ) ;
List < String > personalFields = new ArrayList < > ( ) ;
List < String > workFields = new ArrayList < > ( ) ;
2023-01-09 10:27:30 +08:00
for ( String fieldName : split ) {
2023-01-09 18:06:57 +08:00
if ( fieldName . startsWith ( HrmGroupEnum . HRM_BASIC . getGroupType ( ) . toString ( ) ) ) {
2023-01-10 14:08:41 +08:00
basicFields . add ( fieldName ) ;
2023-01-09 18:06:57 +08:00
} else if ( fieldName . startsWith ( HrmGroupEnum . HRM_PERSONAL . getGroupType ( ) . toString ( ) ) ) {
2023-01-10 14:08:41 +08:00
personalFields . add ( fieldName ) ;
2023-01-09 18:06:57 +08:00
} else if ( fieldName . startsWith ( HrmGroupEnum . HRM_WORK . getGroupType ( ) . toString ( ) ) ) {
2023-01-10 14:08:41 +08:00
workFields . add ( fieldName ) ;
2023-01-09 10:27:30 +08:00
}
}
2023-01-10 11:37:28 +08:00
return SearchTemplatePO . builder ( ) . basicFields ( StringUtils . join ( basicFields , " , " ) ) . personalFields ( StringUtils . join ( personalFields , " , " ) ) . workFields ( StringUtils . join ( workFields , " , " ) ) . build ( ) ;
2023-01-09 10:27:30 +08:00
}
2023-01-10 11:37:28 +08:00
return null ;
2023-01-09 10:27:30 +08:00
}
/ * *
* 根据搜索模板对象 , 构建搜索条件表单
*
* @param templatePO
* @param hrmFieldSearchConditionComInfo
* @param addGroups
* /
private void buildSearchConditionGroup ( SearchTemplatePO templatePO , HrmFieldSearchConditionComInfo hrmFieldSearchConditionComInfo , List < SearchConditionGroup > addGroups ) {
String [ ] basicFields = Util . null2String ( templatePO . getBasicFields ( ) ) . split ( " , " ) ;
if ( basicFields . length > 0 ) {
2023-01-09 18:06:57 +08:00
getTemplateItems ( hrmFieldSearchConditionComInfo , addGroups , " 基本信息 " , HrmGroupEnum . HRM_BASIC . getGroupType ( ) , basicFields ) ;
2023-01-09 10:27:30 +08:00
}
String [ ] personalFields = Util . null2String ( templatePO . getPersonalFields ( ) ) . split ( " , " ) ;
if ( personalFields . length > 0 ) {
2023-01-09 18:06:57 +08:00
getTemplateItems ( hrmFieldSearchConditionComInfo , addGroups , " 个人信息 " , HrmGroupEnum . HRM_PERSONAL . getGroupType ( ) , personalFields ) ;
2023-01-09 10:27:30 +08:00
}
String [ ] workFields = Util . null2String ( templatePO . getWorkFields ( ) ) . split ( " , " ) ;
if ( workFields . length > 0 ) {
2023-01-09 18:06:57 +08:00
getTemplateItems ( hrmFieldSearchConditionComInfo , addGroups , " 工作信息 " , HrmGroupEnum . HRM_WORK . getGroupType ( ) , workFields ) ;
}
}
/ * *
* 根据字段信息 , 动态拼接where条件SQL
*
* @param conditionItem
* @param key
* @param value
* @param sb
* @param dbType
* /
private void buildDynamicSql ( SearchConditionItem conditionItem , String key , String value , StringBuilder sb , DBType dbType ) {
if ( null = = conditionItem ) {
return ;
2023-01-09 10:27:30 +08:00
}
2023-01-09 18:06:57 +08:00
if ( key . endsWith ( " workyear " ) | | key . endsWith ( " companyworkyear " ) ) {
conditionItem . setConditionType ( ConditionType . INPUTNUMBER ) ;
}
2023-01-11 14:26:13 +08:00
// 职务
2023-01-10 18:25:53 +08:00
if ( key . endsWith ( " jobactivity " ) ) {
searchJobTitle = true ;
2023-01-11 14:26:13 +08:00
List < Integer > jobTitleIds = getSystemDataMapper ( ) . getJobTitleIds ( value , null ) ;
if ( null = = jobTitleList ) {
jobTitleList = jobTitleIds ;
} else {
jobTitleList . retainAll ( jobTitleIds ) ;
}
return ;
2023-01-10 18:25:53 +08:00
}
2023-01-11 14:26:13 +08:00
// 职务类别
2023-01-10 18:25:53 +08:00
if ( key . endsWith ( " jobGroupId " ) ) {
searchJobTitle = true ;
2023-01-11 14:26:13 +08:00
List < Integer > jobTitleIds = getSystemDataMapper ( ) . getJobTitleIds ( null , value ) ;
if ( null = = jobTitleList ) {
jobTitleList = jobTitleIds ;
} else {
jobTitleList . retainAll ( jobTitleIds ) ;
}
return ;
2023-01-10 18:25:53 +08:00
}
2023-01-11 14:26:13 +08:00
// 岗位
2023-01-10 18:25:53 +08:00
if ( key . endsWith ( " jobtitle " ) ) {
searchJobTitle = true ;
2023-01-11 14:26:13 +08:00
jobTitleList = new ArrayList < > ( ) ;
jobTitleList . add ( Integer . parseInt ( value ) ) ;
return ;
2023-01-10 18:25:53 +08:00
}
2023-01-09 18:06:57 +08:00
String tableSql = buildTableSql ( key ) ;
if ( StringUtils . isBlank ( tableSql ) ) {
return ;
}
switch ( conditionItem . getConditionType ( ) ) {
case INPUT : // 单行文本框
case TEXTAREA : // 多行文本框
sb . append ( " and " ) . append ( tableSql ) . append ( dbType . like ( value ) ) ;
// 模糊搜索
break ;
case BROWSER : //浏览按钮
2023-01-12 14:08:51 +08:00
// 兼容多选浏览按钮
sb . append ( " and " ) . append ( dbType . concat ( tableSql ) ) . append ( dbType . like ( value ) ) ;
break ;
case INPUTNUMBER : // 数字
2023-01-09 18:06:57 +08:00
case CHECKBOX :
case SWITCH :
sb . append ( " and " ) . append ( dbType . ifNull ( tableSql , " 0 " ) ) . append ( " = ' " ) . append ( value ) . append ( " ' " ) ;
break ;
2023-01-12 14:08:51 +08:00
case SELECT : //选择框
2023-02-06 09:49:36 +08:00
if ( ! " -1 " . equals ( value ) ) {
2023-03-01 16:26:10 +08:00
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 ( " ' " ) ;
}
2023-02-06 09:49:36 +08:00
}
break ;
2023-01-09 18:06:57 +08:00
case DATE :
case DATEPICKER :
case TIMEPICKER :
case RANGEPICKER :
// 精准搜索
sb . append ( " and " ) . append ( tableSql ) . append ( " = ' " ) . append ( value ) . append ( " ' " ) ;
break ;
default :
break ;
}
}
/ * *
* 处理当前字段所在表关系
*
* @param key
* @return
* /
private String buildTableSql ( String key ) {
StringBuilder sb = new StringBuilder ( ) ;
String [ ] s = key . split ( " _ " ) ;
if ( s . length < 3 ) {
return " " ;
}
2023-01-11 14:26:13 +08:00
2023-01-09 18:06:57 +08:00
String scopeId = s [ 0 ] ;
String tableName = s [ 1 ] ;
String fieldName = s [ 2 ] ;
2023-01-13 16:35:34 +08:00
if ( " jobactivity " . equalsIgnoreCase ( fieldName ) ) {
return " t4.id " ;
}
if ( " jobGroupId " . equalsIgnoreCase ( fieldName ) ) {
return " t5.id " ;
}
2023-01-13 16:50:54 +08:00
// 姓名点击事件
if ( " lastname " . equalsIgnoreCase ( fieldName ) ) {
return " lastname " ;
}
2023-01-13 16:35:34 +08:00
2023-01-11 14:26:13 +08:00
if ( " hrm " . equals ( tableName ) ) {
return sb . append ( " t. " ) . append ( fieldName ) . toString ( ) ;
2023-01-09 18:06:57 +08:00
}
2023-01-11 14:26:13 +08:00
switch ( scopeId ) {
case " -1 " :
sb . append ( " t0. " ) . append ( fieldName ) ;
break ;
case " 1 " :
sb . append ( " t1. " ) . append ( fieldName ) ;
break ;
case " 3 " :
sb . append ( " t2. " ) . append ( fieldName ) ;
break ;
default :
return " " ;
}
2023-01-09 18:06:57 +08:00
return sb . toString ( ) ;
}
2023-01-11 15:42:41 +08:00
/ * *
* 为下拉框搜索条件 、 添加空选项
*
* @param searchConditionItem
* /
2023-01-09 18:06:57 +08:00
private void addEmptyForSelect ( SearchConditionItem searchConditionItem ) {
2023-02-06 09:49:36 +08:00
searchConditionItem . setValue ( " -1 " ) ;
if ( " -1_hrm_status " . equals ( searchConditionItem . getDomkey ( ) [ 0 ] ) ) {
2023-03-01 16:26:10 +08:00
// 默认赋值 在职状态
searchConditionItem . setValue ( " 10 " ) ;
2023-02-06 09:49:36 +08:00
}
2023-01-09 18:06:57 +08:00
List < SearchConditionOption > options = searchConditionItem . getOptions ( ) ;
SearchConditionOption searchConditionOption = new SearchConditionOption ( ) ;
2023-02-06 09:49:36 +08:00
searchConditionOption . setKey ( " -1 " ) ;
2023-03-01 16:26:10 +08:00
searchConditionOption . setShowname ( " 全部 " ) ;
2023-01-09 18:06:57 +08:00
options . add ( 0 , searchConditionOption ) ;
2023-03-01 16:26:10 +08:00
options . forEach ( item - > item . setSelected ( false ) ) ;
2023-01-09 10:27:30 +08:00
}
2023-01-11 14:48:24 +08:00
2023-01-11 15:42:41 +08:00
/ * *
* 根据模板示例 , 组装所有selectKeys
*
* @param searchTemplatePO
* @return
* /
private List < String > getSelectKeys ( SearchTemplatePO searchTemplatePO ) {
List < String > selectKeys = new ArrayList < > ( ) ;
String basicFields = searchTemplatePO . getBasicFields ( ) ;
String personalFields = searchTemplatePO . getPersonalFields ( ) ;
String workflowFields = searchTemplatePO . getWorkFields ( ) ;
if ( StringUtils . isNotBlank ( basicFields ) ) {
selectKeys . addAll ( Arrays . asList ( basicFields . split ( " , " ) ) ) ;
}
if ( StringUtils . isNotBlank ( personalFields ) ) {
selectKeys . addAll ( Arrays . asList ( personalFields . split ( " , " ) ) ) ;
}
if ( StringUtils . isNotBlank ( workflowFields ) ) {
selectKeys . addAll ( Arrays . asList ( workflowFields . split ( " , " ) ) ) ;
}
return selectKeys ;
}
2023-01-12 11:33:23 +08:00
2022-06-20 18:31:11 +08:00
}