@ -1,18 +1,18 @@
package com.engine.organization.service.impl ;
import com.alibaba.fastjson.JSONObject ;
import com.api.browser.bean.SearchConditionGroup ;
import com.api.browser.bean.SearchConditionItem ;
import com.api.browser.bean.SearchConditionOption ;
import com.api.hrm.bean.HrmFieldBean ;
import com.api.hrm.util.HrmFieldSearchConditionComInfo ;
import com.cloudstore.eccom.pc.table.WeaTableColumn ;
import com.cloudstore.eccom.result.WeaResultMsg ;
import com.engine.common.util.ServiceUtil ;
import com.engine.core.impl.Service ;
import com.engine.hrm.entity.RuleCodeType ;
import com.engine.hrm.service.impl.OrganizationServiceImpl ;
import com.engine.organization.component.OrganizationWeaTable ;
import com.engine.organization.entity.DeleteParam ;
import com.engine.organization.entity.codesetting.po.CodeRulePO ;
import com.engine.organization.entity.commom.RecordInfo ;
import com.engine.organization.entity.company.bo.CompBO ;
import com.engine.organization.entity.company.po.CompPO ;
import com.engine.organization.entity.department.bo.DepartmentBO ;
@ -24,25 +24,18 @@ import com.engine.organization.entity.extend.po.ExtendTitlePO;
import com.engine.organization.entity.job.bo.JobBO ;
import com.engine.organization.entity.job.po.JobPO ;
import com.engine.organization.entity.job.vo.SingleJobTreeVO ;
import com.engine.organization.entity.map.JclOrgMap ;
import com.engine.organization.entity.searchtree.SearchTree ;
import com.engine.organization.entity.searchtree.SearchTreeParams ;
import com.engine.organization.enums.LogModuleNameEnum ;
import com.engine.organization.enums.ModuleTypeEnum ;
import com.engine.organization.enums.OperateTypeEnum ;
import com.engine.organization.exception.OrganizationRunTimeException ;
import com.engine.organization.mapper.codesetting.CodeRuleMapper ;
import com.engine.organization.mapper.comp.CompMapper ;
import com.engine.organization.mapper.department.DepartmentMapper ;
import com.engine.organization.mapper.extend.ExtDTMapper ;
import com.engine.organization.mapper.extend.ExtMapper ;
import com.engine.organization.mapper.extend.ExtendTitleMapper ;
import com.engine.organization.mapper.hrmresource.SystemDataMapper ;
import com.engine.organization.mapper.jclorgmap.JclOrgMapper ;
import com.engine.organization.mapper.job.JobMapper ;
import com.engine.organization.service.DepartmentService ;
import com.engine.organization.service.ExtService ;
import com.engine.organization.thread.DepartmentTriggerRunnable ;
import com.engine.organization.thread.HrmResourceTriggerRunnable ;
import com.engine.organization.thread.JobTriggerRunnable ;
import com.engine.organization.thread.OrganizationSyncEc ;
import com.engine.organization.util.* ;
@ -52,7 +45,6 @@ import com.engine.organization.util.detach.DetachUtil;
import com.engine.organization.util.page.Column ;
import com.engine.organization.util.page.PageInfo ;
import com.engine.organization.util.page.PageUtil ;
import com.engine.organization.util.relation.EcHrmRelationUtil ;
import com.engine.organization.util.tree.SearchTreeUtil ;
import com.google.common.collect.Lists ;
import org.apache.commons.collections4.CollectionUtils ;
@ -61,6 +53,11 @@ import weaver.conn.RecordSet;
import weaver.general.StringUtil ;
import weaver.general.Util ;
import weaver.hrm.User ;
import weaver.hrm.company.DepartmentComInfo ;
import weaver.hrm.definedfield.HrmDeptFieldManagerE9 ;
import weaver.hrm.definedfield.HrmFieldComInfo ;
import weaver.hrm.definedfield.HrmFieldGroupComInfo ;
import weaver.systeminfo.SystemEnv ;
import java.util.* ;
import java.util.stream.Collectors ;
@ -100,8 +97,6 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
* /
private static final Long GROUP_ID = 2L ;
private static final String HRM_DEPARTMENT = "hrmdepartment" ;
private static DepartmentMapper getDepartmentMapper ( ) {
return MapperProxyFactory . getProxy ( DepartmentMapper . class ) ;
@ -119,10 +114,6 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
return MapperProxyFactory . getProxy ( ExtendTitleMapper . class ) ;
}
private SystemDataMapper getSystemDataMapper ( ) {
return MapperProxyFactory . getProxy ( SystemDataMapper . class ) ;
}
private ExtService getExtService ( User user ) {
return ServiceUtil . getService ( ExtServiceImpl . class , user ) ;
}
@ -132,7 +123,7 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
public PageInfo < SingleDeptTreeVO > getDeptListByPid ( QuerySingleDeptListParam param ) {
//1.查询分部下所有部门
//PageUtil.start(param.getCurrent(), param.getPageSize());
List < DepartmentPO > departmentPOS = MapperProxyFactory . getProxy ( DepartmentMapper . class ) . list ( "show_o rder") ;
List < DepartmentPO > departmentPOS = MapperProxyFactory . getProxy ( DepartmentMapper . class ) . list All( "showO rder") ;
PageInfo < DepartmentPO > pageInfo = new PageInfo < > ( departmentPOS ) ;
List < SingleDeptTreeVO > singleDeptTreeVOS = DepartmentBO . buildSingleDeptTreeVOS ( departmentPOS , param . getParentComp ( ) ) ;
PageInfo < SingleDeptTreeVO > pageInfos = new PageInfo < > ( singleDeptTreeVOS , SingleDeptTreeVO . class ) ;
@ -176,8 +167,8 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
DepartmentPO departmentPO = DepartmentBO . convertParamsToPO ( param , user . getUID ( ) ) ;
boolean filter = isFilter ( departmentPO ) ;
PageInfo < DepartmentListDTO > pageInfos ;
String orderSql = PageInfoSortUtil . getSortSql ( param . getSortParams ( ) );
List < DepartmentPO > allList = getDepartmentMapper ( ) . list ( orderSql ) ;
String orderSql = PageInfoSortUtil . getSortSql ( param . getSortParams ( ) ," showorder " );
List < DepartmentPO > allList = getDepartmentMapper ( ) . list All ( orderSql ) ;
new DetachUtil ( user . getUID ( ) ) . filterDepartmentList ( allList ) ;
// 通过子级遍历父级元素
if ( filter ) {
@ -218,137 +209,35 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
@Override
public Long saveBaseForm ( Map < String , Object > params ) {
HasRightUtil . hasRight ( user , RIGHT_NAME , false ) ;
String deptNo = ( String ) params . get ( "dept_no" ) ;
// 判断是否开启自动编号
deptNo = repeatDetermine ( deptNo ) ;
params . put ( "dept_no" , deptNo ) ;
if ( StringUtils . isBlank ( Util . null2String ( params . get ( "show_order" ) ) ) ) {
Integer maxShowOrder = getDepartmentMapper ( ) . getMaxShowOrder ( ) ;
if ( null = = maxShowOrder ) {
maxShowOrder = 0 ;
}
params . put ( "show_order" , maxShowOrder + 1 ) ;
}
// 上级分部
String ecCompany = Util . null2String ( params . get ( "ec_company" ) ) ;
if ( StringUtils . isNotBlank ( ecCompany ) ) {
CompPO jclCompanyId = EcHrmRelationUtil . getJclCompanyId ( ecCompany ) ;
if ( null ! = jclCompanyId ) {
params . put ( "parent_comp" , jclCompanyId . getId ( ) ) ;
}
}
// 上级部门
String ecDepartment = Util . null2String ( params . get ( "ec_department" ) ) ;
if ( StringUtils . isNotBlank ( ecDepartment ) ) {
DepartmentPO jclDepartmentId = EcHrmRelationUtil . getJclDepartmentId ( ecDepartment ) ;
if ( null ! = jclDepartmentId ) {
params . put ( "parent_dept" , jclDepartmentId . getId ( ) ) ;
// 部门不为空,自动指定所属分部
params . put ( "parent_comp" , jclDepartmentId . getParentComp ( ) ) ;
params . put ( "ec_company" , EcHrmRelationUtil . getEcCompanyId ( Util . null2String ( jclDepartmentId . getParentComp ( ) ) ) ) ;
}
}
Map < String , Object > syncMap = new OrganizationSyncEc ( user , LogModuleNameEnum . DEPARTMENT , OperateTypeEnum . ADD , params ) . sync ( ) ;
String ecCompanyID = Util . null2String ( syncMap . get ( "id" ) ) ;
OrganizationAssert . isTrue ( StringUtils . isNotBlank ( ecCompanyID ) , syncMap . get ( "message" ) . toString ( ) ) ;
// 查询UUID
RecordInfo recordInfo = getSystemDataMapper ( ) . getHrmObjectByID ( HRM_DEPARTMENT , ecCompanyID ) ;
params . put ( "uuid" , recordInfo . getUuid ( ) ) ;
return getExtService ( user ) . updateExtForm ( user , EXTEND_TYPE , JCL_ORG_DEPT , params , "" , null ) ;
return Long . parseLong ( ecCompanyID ) ;
}
@Override
public int updateForbiddenTagById ( DeptSearchParam params ) {
HasRightUtil . hasRight ( user , RIGHT_NAME , false ) ;
DepartmentPO departmentPO = DepartmentPO . builder ( ) . id ( params . getId ( ) ) . forbiddenTag ( params . getForbiddenTag ( ) ? 0 : 1 ) . build ( ) ;
if ( ! params . getForbiddenTag ( ) ) {
// 判断当前岗位下是否有启用岗位,如有启用岗位,部门无法禁用
int countUsedInJob = getDepartmentMapper ( ) . countUsedInJob ( params . getId ( ) ) ;
OrganizationAssert . isTrue ( countUsedInJob = = 0 , "部门存在下级岗位,不能封存" ) ;
}
DepartmentPO departmentPO = DepartmentPO . builder ( ) . id ( params . getId ( ) ) . canceled ( params . getCanceled ( ) ? 0 : 1 ) . build ( ) ;
Map < String , Object > map = new HashMap < > ( ) ;
map . put ( "id" , departmentPO . getId ( ) ) ;
map . put ( "forbiddenTag" , departmentPO . get ForbiddenTag ( ) ) ;
map . put ( "forbiddenTag" , departmentPO . getCanceled ( ) ) ;
new OrganizationSyncEc ( user , LogModuleNameEnum . DEPARTMENT , OperateTypeEnum . CANCELED , map ) . sync ( ) ;
return getDepartmentMapper ( ) . updateForbiddenTagById ( departmentPO ) ;
return 1 ;
}
@Override
public Long updateForm ( Map < String , Object > params ) {
HasRightUtil . hasRight ( user , RIGHT_NAME , false ) ;
DeptSearchParam searchParam = JSONObject . parseObject ( JSONObject . toJSONString ( params ) , DeptSearchParam . class ) ;
String groupId = ( String ) params . get ( "viewCondition" ) ;
if ( "0" . equals ( groupId ) | | GROUP_ID . toString ( ) . equals ( groupId ) ) {
DepartmentPO oldDept = getDepartmentMapper ( ) . getDeptById ( searchParam . getId ( ) ) ;
String deptNo = searchParam . getDeptNo ( ) ;
if ( ! deptNo . equals ( oldDept . getDeptNo ( ) ) ) {
deptNo = repeatDetermine ( deptNo ) ;
params . put ( "dept_no" , deptNo ) ;
}
// 上级分部
String ecCompany = Util . null2String ( params . get ( "ec_company" ) ) ;
if ( StringUtils . isNotBlank ( ecCompany ) ) {
CompPO jclCompanyId = EcHrmRelationUtil . getJclCompanyId ( ecCompany ) ;
if ( null ! = jclCompanyId ) {
params . put ( "parent_comp" , jclCompanyId . getId ( ) ) ;
}
}
// 上级部门
String ecDepartment = Util . null2String ( params . get ( "ec_department" ) ) ;
if ( StringUtils . isNotBlank ( ecDepartment ) ) {
DepartmentPO jclDepartmentId = EcHrmRelationUtil . getJclDepartmentId ( ecDepartment ) ;
if ( null ! = jclDepartmentId ) {
// 上级部门不能选择本身
OrganizationAssert . isFalse ( jclDepartmentId . getId ( ) . equals ( searchParam . getId ( ) ) , "上级部门不能选择本身" ) ;
params . put ( "parent_dept" , jclDepartmentId . getId ( ) ) ;
// 部门不为空,自动指定所属分部
params . put ( "parent_comp" , jclDepartmentId . getParentComp ( ) ) ;
params . put ( "ec_company" , EcHrmRelationUtil . getEcCompanyId ( Util . null2String ( jclDepartmentId . getParentComp ( ) ) ) ) ;
}
} else {
params . put ( "parent_dept" , "" ) ;
}
new OrganizationSyncEc ( user , LogModuleNameEnum . DEPARTMENT , OperateTypeEnum . UPDATE , params ) . sync ( ) ;
// 更新主表数据
getExtService ( user ) . updateExtForm ( user , EXTEND_TYPE , JCL_ORG_DEPT , params , "" , searchParam . getId ( ) ) ;
DepartmentPO newDeptById = getDepartmentMapper ( ) . getDeptById ( searchParam . getId ( ) ) ;
new DepartmentTriggerRunnable ( oldDept , newDeptById ) . run ( ) ;
Long parentComp = StringUtils . isNotEmpty ( Util . null2String ( params . get ( "parent_comp" ) ) ) ? Long . parseLong ( Util . null2String ( params . get ( "parent_comp" ) ) ) : null ;
// 刷新岗位所属分部
refreshJobComp ( searchParam . getId ( ) , parentComp ) ;
List < DepartmentPO > childList = getDepartmentMapper ( ) . getDeptListByPId ( searchParam . getId ( ) ) ;
String ecCompanyId = EcHrmRelationUtil . getEcCompanyId ( Util . null2String ( parentComp ) ) ;
forbiddenChildTag ( parentComp , ecCompanyId , childList ) ;
}
// 更新主表拓展表
getExtService ( user ) . updateExtForm ( user , EXTEND_TYPE , JCL_ORG_DEPTEXT , params , "" , searchParam . getId ( ) ) ;
//更新明细表
getExtService ( user ) . updateExtDT ( user , EXTEND_TYPE , JCL_ORG_DEPTEXT_DT1 , params , searchParam . getId ( ) ) ;
return searchParam . getId ( ) ;
String ecCompanyId = Util . null2String ( params . get ( "id" ) ) ;
new OrganizationSyncEc ( user , LogModuleNameEnum . DEPARTMENT , OperateTypeEnum . UPDATE , params ) . sync ( ) ;
return Long . parseLong ( ecCompanyId ) ;
}
@Override
public int deleteByIds ( Collection < Long > id s) {
public Map < String , Object > deleteByIds ( Map < String , Object > params ) {
HasRightUtil . hasRight ( user , RIGHT_NAME , false ) ;
OrganizationAssert . notEmpty ( ids , "请选择要删除的数据" ) ;
Map < String , Object > map = new HashMap < > ( ) ;
for ( Long id : ids ) {
map . put ( "id" , id ) ;
new OrganizationSyncEc ( user , LogModuleNameEnum . DEPARTMENT , OperateTypeEnum . CANCELED , map ) . sync ( ) ;
// 删除拓展表、明细表
MapperProxyFactory . getProxy ( ExtMapper . class ) . deleteByID ( "jcl_org_deptext" , id ) ;
MapperProxyFactory . getProxy ( ExtDTMapper . class ) . deleteByMainID ( "jcl_org_deptext_dt1" , id , null ) ;
}
return getDepartmentMapper ( ) . deleteByIds ( ids ) ;
return ServiceUtil . getService ( OrganizationServiceImpl . class , user ) . delDepartment ( params , user ) ;
}
@Override
@ -357,35 +246,18 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
List < SearchConditionGroup > addGroups = new ArrayList < > ( ) ;
List < SearchConditionItem > conditionItems = new ArrayList < > ( ) ;
// 编号
SearchConditionItem dep tNo Item = OrganizationFormItemUtil . inputItem ( user , 2 , 16 , 2 , 50 , "编号" , "dep tNo ") ;
SearchConditionItem dep artmentCode Item = OrganizationFormItemUtil . inputItem ( user , 2 , 16 , 2 , 50 , "编号" , "dep artmentCode ") ;
// 名称
SearchConditionItem deptNameItem = OrganizationFormItemUtil . inputItem ( user , 2 , 16 , 2 , 50 , "名称" , "departmentName" ) ;
// 简称
SearchConditionItem deptNameShortItem = OrganizationFormItemUtil . inputItem ( user , 2 , 16 , 2 , 50 , "简称" , "deptNameShort" ) ;
SearchConditionItem departmentNameItem = OrganizationFormItemUtil . inputItem ( user , 2 , 16 , 2 , 50 , "名称" , "departmentName" ) ;
// 所属分部
SearchConditionItem parentCompBrowser Item = OrganizationFormItemUtil . browserItem ( user , 2 , 16 , 2 , false , "所属分部" , "164" , " ecCompany ", "" ) ;
SearchConditionItem subCompanyId1Item = OrganizationFormItemUtil . browserItem ( user , 2 , 16 , 2 , false , "所属分部" , "164" , "subCompanyId1" , "" ) ;
// 上级部门
SearchConditionItem parentDeptBrowserItem = OrganizationFormItemUtil . browserItem ( user , 2 , 16 , 2 , false , "上级部门" , "4" , "ecDepartment" , "" ) ;
// 部门负责人
SearchConditionItem deptPrincipalBrowserItem = OrganizationFormItemUtil . browserItem ( user , 2 , 16 , 2 , false , "部门负责人" , "1" , "deptPrincipal" , "" ) ;
// 显示顺序
SearchConditionItem showOrderItem = OrganizationFormItemUtil . inputNumberItem ( user , 2 , 16 , 2 , "显示顺序" , "showOrder" ) ;
// 禁用标记
List < SearchConditionOption > selectOptions = new ArrayList < > ( ) ;
SearchConditionOption enableOption = new SearchConditionOption ( "true" , "启用" ) ;
SearchConditionOption disableOption = new SearchConditionOption ( "false" , "禁用" ) ;
selectOptions . add ( enableOption ) ;
selectOptions . add ( disableOption ) ;
SearchConditionItem forbiddenTagItem = OrganizationFormItemUtil . selectItem ( user , selectOptions , 2 , 16 , 6 , false , "禁用标记" , "forbiddenTag" ) ;
conditionItems . add ( deptNoItem ) ;
conditionItems . add ( deptNameItem ) ;
conditionItems . add ( deptNameShortItem ) ;
conditionItems . add ( parentCompBrowserItem ) ;
conditionItems . add ( parentDeptBrowserItem ) ;
conditionItems . add ( deptPrincipalBrowserItem ) ;
conditionItems . add ( showOrderItem ) ;
conditionItems . add ( forbiddenTagItem ) ;
SearchConditionItem supDepIdItem = OrganizationFormItemUtil . browserItem ( user , 2 , 16 , 2 , false , "上级部门" , "4" , "supDepId" , "" ) ;
conditionItems . add ( departmentCodeItem ) ;
conditionItems . add ( departmentNameItem ) ;
conditionItems . add ( subCompanyId1Item ) ;
conditionItems . add ( supDepIdItem ) ;
addGroups . add ( new SearchConditionGroup ( "高级搜索条件" , true , conditionItems ) ) ;
apiDatas . put ( "conditions" , addGroups ) ;
@ -442,39 +314,152 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
}
@Override
public Map < String , Object > getSaveForm ( DeptSearchParam param ) {
public Map < String , Object > getSaveForm ( Map< String , Object > params ) {
HasRightUtil . hasRight ( user , RIGHT_NAME , false ) ;
Map < String , Object > apiDatas = new HashMap < > ( ) ;
List < SearchConditionGroup > addGroups = new ArrayList < > ( ) ;
List < ExtendTitlePO > extendTitles = getExtendTitleMapper ( ) . getTitlesByGroupID ( GROUP_ID , "1" ) ;
if ( CollectionUtils . isNotEmpty ( extendTitles ) ) {
Map < String , Object > params = new HashMap < > ( ) ;
// 分部
if ( StringUtils . isNotBlank ( Util . null2String ( param . getSubcompanyid1 ( ) ) ) ) {
CompPO compPO = getCompMapper ( ) . listById ( param . getSubcompanyid1 ( ) ) ;
if ( null ! = compPO ) {
params . put ( "parent_comp" , compPO . getId ( ) ) ;
params . put ( "ec_company" , EcHrmRelationUtil . getEcCompanyId ( compPO . getId ( ) . toString ( ) ) ) ;
List < Map < String , Object > > groupList = new ArrayList < > ( ) ;
Map < String , Object > groupItem ;
List < Object > itemList ;
String id = Util . null2String ( params . get ( "id" ) ) ;
int viewAttr = Util . getIntValue ( Util . null2String ( params . get ( "viewattr" ) ) , 1 ) ;
String nodeType = Util . null2String ( params . get ( "type" ) ) ;
String addType = Util . null2String ( params . get ( "addType" ) ) ;
DepartmentComInfo departmentComInfo = new DepartmentComInfo ( ) ;
String subcompanyid1 = "" ;
String supDepId = "" ;
switch ( addType ) {
case "normal" :
if ( nodeType . equals ( "subcompany" ) ) {
subcompanyid1 = id ;
} else {
subcompanyid1 = departmentComInfo . getSubcompanyid1 ( id ) ;
}
}
// 部门
if ( StringUtils . isNotBlank ( Util . null2String ( param . getDepartmentid ( ) ) ) ) {
DepartmentPO deptById = getDepartmentMapper ( ) . getDeptById ( param . getDepartmentid ( ) ) ;
if ( null ! = deptById ) {
params . put ( "parent_dept" , deptById . getId ( ) ) ;
params . put ( "ec_department" , EcHrmRelationUtil . getEcDepartmentId ( deptById . getId ( ) . toString ( ) ) ) ;
params . put ( "parent_comp" , deptById . getParentComp ( ) ) ;
params . put ( "ec_company" , EcHrmRelationUtil . getEcCompanyId ( deptById . getParentComp ( ) . toString ( ) ) ) ;
break ;
case "sibling" :
subcompanyid1 = departmentComInfo . getSubcompanyid1 ( id ) ;
supDepId = departmentComInfo . getDepartmentsupdepid ( id ) ;
break ;
case "child" :
subcompanyid1 = departmentComInfo . getSubcompanyid1 ( id ) ;
supDepId = id ;
break ;
}
HrmFieldGroupComInfo HrmFieldGroupComInfo = new HrmFieldGroupComInfo ( ) ;
HrmFieldComInfo HrmFieldComInfo = new HrmFieldComInfo ( ) ;
HrmFieldSearchConditionComInfo hrmFieldSearchConditionComInfo = new HrmFieldSearchConditionComInfo ( ) ;
SearchConditionItem searchConditionItem ;
HrmFieldBean hrmFieldBean ;
HrmDeptFieldManagerE9 hfm ;
try {
hfm = new HrmDeptFieldManagerE9 ( 5 ) ;
} catch ( Exception e ) {
throw new OrganizationRunTimeException ( "" ) ;
}
hfm . isReturnDecryptData ( true ) ;
hfm . getCustomData ( Util . getIntValue ( id ) ) ;
List lsGroup = hfm . getLsGroup ( ) ;
for ( int tmp = 0 ; lsGroup ! = null & & tmp < lsGroup . size ( ) ; tmp + + ) {
String groupid = ( String ) lsGroup . get ( tmp ) ;
List lsField = hfm . getLsField ( groupid ) ;
boolean groupHide = lsField . size ( ) = = 0 | | hfm . getGroupCount ( lsField ) = = 0 | | ! Util . null2String ( HrmFieldGroupComInfo . getIsShow ( groupid ) ) . equals ( "1" ) ;
String grouplabel = HrmFieldGroupComInfo . getLabel ( groupid ) ;
itemList = new ArrayList < > ( ) ;
groupItem = new HashMap < > ( ) ;
groupItem . put ( "title" , SystemEnv . getHtmlLabelNames ( grouplabel , user . getLanguage ( ) ) ) ;
groupItem . put ( "hide" , groupHide ) ;
groupItem . put ( "defaultshow" , true ) ;
for ( Object o : lsField ) {
String fieldId = ( String ) o ;
String fieldName = HrmFieldComInfo . getFieldname ( fieldId ) ;
String isUse = HrmFieldComInfo . getIsused ( fieldId ) ;
if ( ! isUse . equals ( "1" ) ) continue ;
int tmpViewAttr = viewAttr ;
String rules = "" ;
String fieldLabel = HrmFieldComInfo . getLabel ( fieldId ) ;
String fieldHtmlType = HrmFieldComInfo . getFieldhtmltype ( fieldId ) ;
String type = HrmFieldComInfo . getFieldType ( fieldId ) ;
String dmlUrl = Util . null2String ( HrmFieldComInfo . getFieldDmlurl ( fieldId ) ) ;
String fieldValue = "" ;
if ( StringUtils . isBlank ( addType ) ) {
if ( HrmFieldComInfo . getIssystem ( fieldId ) . equals ( "1" ) ) {
fieldValue = hfm . getData ( fieldName ) ;
} else {
fieldValue = hfm . getData ( "hrmdepartmentdefined" , fieldName ) ;
}
}
}
for ( ExtendTitlePO extendTitle : extendTitles ) {
List < SearchConditionItem > items = getExtService ( user ) . getExtSaveForm ( user , EXTEND_TYPE + "" , JCL_ORG_DEPT , 2 , extendTitle . getId ( ) . toString ( ) , "dept_no" , RuleCodeType . DEPARTMENT . getValue ( ) , params ) ;
if ( CollectionUtils . isNotEmpty ( items ) ) {
addGroups . add ( new SearchConditionGroup ( extendTitle . getTitle ( ) , true , items ) ) ;
if ( ! groupHide & & tmpViewAttr = = 2 & & HrmFieldComInfo . getIsmand ( fieldId ) . equals ( "1" ) ) {
tmpViewAttr = 3 ;
if ( "1" . equals ( fieldHtmlType ) & & "2" . equals ( type ) ) {
rules = "required|integer" ;
} else {
rules = "required|string" ;
}
}
if ( subcompanyid1 . length ( ) > 0 & & fieldName . equals ( "subcompanyid1" ) ) {
fieldValue = subcompanyid1 ;
}
if ( supDepId . length ( ) > 0 & & fieldName . equals ( "supdepid" ) ) {
fieldValue = supDepId ;
}
if ( fieldName . equals ( "showid" ) ) {
if ( addType . length ( ) > 0 ) {
continue ;
} else {
fieldValue = id ;
tmpViewAttr = 1 ;
}
}
hrmFieldBean = new HrmFieldBean ( ) ;
hrmFieldBean . setFieldid ( fieldId ) ;
hrmFieldBean . setFieldname ( fieldName ) ;
hrmFieldBean . setFieldlabel ( fieldLabel ) ;
hrmFieldBean . setFieldhtmltype ( fieldHtmlType ) ;
hrmFieldBean . setType ( type ) ;
hrmFieldBean . setIsFormField ( true ) ;
hrmFieldBean . setIssystem ( "1" ) ;
hrmFieldBean . setFieldvalue ( fieldValue ) ;
hrmFieldBean . setDmlurl ( dmlUrl ) ;
hrmFieldBean . setViewAttr ( tmpViewAttr ) ;
hrmFieldBean . setRules ( rules ) ;
if ( hrmFieldBean . getFieldname ( ) . equals ( "subcompanyid1" ) | | hrmFieldBean . getFieldname ( ) . equals ( "supdepid" ) ) {
hrmFieldBean . setHideVirtualOrg ( true ) ;
}
if ( hrmFieldBean . getFieldname ( ) . equals ( "departmentcode" ) ) {
hrmFieldBean . setMultilang ( false ) ;
}
searchConditionItem = hrmFieldSearchConditionComInfo . getSearchConditionItem ( hrmFieldBean , user ) ;
if ( searchConditionItem ! = null ) {
searchConditionItem . setLabelcol ( 8 ) ;
searchConditionItem . setFieldcol ( 16 ) ;
if ( fieldName . equals ( "showorder" ) ) {
searchConditionItem . setPrecision ( 2 ) ;
}
if ( fieldName . equals ( "showid" ) ) {
Map < String , Object > otherParams = new HashMap < > ( ) ;
otherParams . put ( "hasBorder" , true ) ;
searchConditionItem . setOtherParams ( otherParams ) ;
}
if ( "6" . equals ( fieldHtmlType ) ) { //附件
Map < String , Object > otherParams1 = new HashMap < > ( ) ;
otherParams1 . put ( "showOrder" , false ) ;
searchConditionItem . setOtherParams ( otherParams1 ) ;
}
itemList . add ( searchConditionItem ) ;
}
}
groupItem . put ( "items" , itemList ) ;
groupList . add ( groupItem ) ;
}
apiDatas . put ( "condition" , addGroups ) ;
apiDatas . put ( "condition" , groupList ) ;
return apiDatas ;
}
@ -516,45 +501,35 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
OrganizationAssert . notBlank ( copyParam . getCompany ( ) , "请指定需要复制的公司/分部" ) ;
int insertCount = 0 ;
// 需复制的部门
List < Long > idList = Arrays . stream ( copyParam . getIds ( ) . split ( "," ) ) . map ( Long: : parseLong ) . collect ( Collectors . toList ( ) ) ;
Integer maxShowOrder = getDepartmentMapper ( ) . getMaxShowOrder ( ) ;
List < Integer > idList = Arrays . stream ( copyParam . getIds ( ) . split ( "," ) ) . map ( Integer: : parseInt ) . collect ( Collectors . toList ( ) ) ;
Double maxShowOrder = getDepartmentMapper ( ) . getMaxShowOrder ( ) ;
maxShowOrder = null = = maxShowOrder ? 0 : maxShowOrder ;
for ( Long departmentId : idList ) {
for ( Integer departmentId : idList ) {
// 复制当前部门
recursionCopyDept ( departmentId , null , Long. parseLong ( copyParam . getCompany ( ) ) , maxShowOrder , copyParam . getCopyJob ( ) , copyParam . getCopySubDept ( ) , copyParam . getCopySubJob ( ) ) ;
recursionCopyDept ( departmentId , null , Integer. parseInt ( copyParam . getCompany ( ) ) , maxShowOrder , copyParam . getCopyJob ( ) , copyParam . getCopySubDept ( ) , copyParam . getCopySubJob ( ) ) ;
}
return insertCount ;
}
private void recursionCopyDept ( Long originalDeptId , Long parentDepartmentId , Long companyId , Integer maxShowOrder , String copyJob , String copySubDept , String copySubJob ) {
private void recursionCopyDept ( Integer originalDeptId , Integer parentDepartmentId , Integer companyId , Double maxShowOrder , String copyJob , String copySubDept , String copySubJob ) {
// 源部门
DepartmentPO deptById = getDepartmentMapper ( ) . getDeptById ( originalDeptId ) ;
long timeMillis = System . currentTimeMillis ( ) ;
// 处理自动编号
deptById . setDep tNo( CodeRuleUtil . generateCode ( RuleCodeType . DEPARTMENT , deptById . getDeptNo ( ) , timeMillis ) ) ;
deptById . setDep artmentCode( null ) ;
// 设置上级分部
deptById . setParentComp ( EcHrmRelationUtil . getJclCompanyId ( Util . null2String ( companyId ) ) . getId ( ) ) ;
deptById . setEcCompany ( companyId ) ;
deptById . setParentDept ( parentDepartmentId ) ;
if ( null ! = parentDepartmentId ) {
deptById . setEcDepartment ( Long . parseLong ( EcHrmRelationUtil . getEcDepartmentId ( Util . null2String ( parentDepartmentId ) ) ) ) ;
}
deptById . setSubCompanyId1 ( companyId ) ;
deptById . setSupDepId ( parentDepartmentId ) ;
// 显示顺序字段
deptById . setShowOrder ( + + maxShowOrder ) ;
deptById . setCreator ( ( long ) user . getUID ( ) ) ;
deptById . setCreateTime ( new Date ( ) ) ;
deptById . setDeptPrincipal ( null ) ;
deptById . setUuid ( null ) ;
// 新增EC表部门
Map < String , Object > syncMap = addEcDepartment ( deptById ) ;
String ecDepartmentID = Util . null2String ( syncMap . get ( "id" ) ) ;
OrganizationAssert . isTrue ( StringUtils . isNotBlank ( ecDepartmentID ) , syncMap . get ( "message" ) . toString ( ) ) ;
// 查询UUID
RecordInfo recordInfo = getSystemDataMapper ( ) . getHrmObjectByID ( HRM_DEPARTMENT , ecDepartmentID ) ;
deptById . setUuid ( recordInfo . getUuid ( ) ) ;
getDepartmentMapper ( ) . insertIgnoreNull ( deptById ) ;
// 更新组织架构图
new DepartmentTriggerRunnable ( deptById . getId ( ) ) . run ( ) ;
//TODO new DepartmentTriggerRunnable(deptById.getId()).run();
// 复制当前部门岗位信息
if ( "1" . equals ( copyJob ) ) {
@ -564,7 +539,7 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
if ( maxJobOrder = = null ) {
maxJobOrder = 0 ;
}
recursionCopyJob ( jobPOS , companyId , deptById. getId ( ) , null , maxJobOrder , timeMillis ) ;
recursionCopyJob ( jobPOS , companyId , Integer. parseInt ( ecDepartmentID ) , null , maxJobOrder , timeMillis ) ;
}
// 是否复制子部门信息
@ -573,13 +548,13 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
List < DepartmentPO > deptListByPId = getDepartmentMapper ( ) . getDeptListByPId ( originalDeptId ) ;
for ( DepartmentPO departmentPO : deptListByPId ) {
// 复制子部门信息、子部门岗位信息
recursionCopyDept ( departmentPO . getId ( ) , deptById. getId ( ) , companyId , maxShowOrder , copySubJob , copySubDept , copySubJob ) ;
recursionCopyDept ( departmentPO . getId ( ) , Integer. parseInt ( ecDepartmentID ) , companyId , maxShowOrder , copySubJob , copySubDept , copySubJob ) ;
}
}
}
@Override
public List < SearchConditionGroup > getMergeForm ( Long id ) {
public List < SearchConditionGroup > getMergeForm ( ) {
List < SearchConditionGroup > addGroups = new ArrayList < > ( ) ;
List < SearchConditionItem > condition = new ArrayList < > ( ) ;
SearchConditionItem deptBrowserItem = OrganizationFormItemUtil . browserItem ( user , 2 , 16 , 3 , false , "合并到部门" , "4" , "department" , "" ) ;
@ -597,19 +572,9 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
public int mergeDepartment ( DepartmentMergeParam mergeParam ) {
HasRightUtil . hasRight ( user , RIGHT_NAME , false ) ;
// 被合并部门
Long ecParamDepartment = mergeParam . getDepartment ( ) ;
DepartmentPO targetDepartment = EcHrmRelationUtil . getJclDepartmentId ( Util . null2String ( ecParamDepartment ) ) ;
// map表中合并部门parentID
Long oldParamDepartment = mergeParam . getId ( ) ;
DepartmentPO oldDepartment = EcHrmRelationUtil . getJclDepartmentId ( Util . null2String ( oldParamDepartment ) ) ;
Integer oldFParentId = null ;
if ( null ! = oldDepartment ) {
java . sql . Date currentDate = new java . sql . Date ( OrganizationDateUtil . stringToDate ( OrganizationDateUtil . getFormatLocalDate ( new Date ( ) ) ) . getTime ( ) ) ;
JclOrgMap jclOrgMap = MapperProxyFactory . getProxy ( JclOrgMapper . class ) . getJclOrgMapByObjID ( currentDate , ModuleTypeEnum . departmentfielddefined . getValue ( ) . toString ( ) , oldDepartment . getId ( ) . toString ( ) ) ;
if ( null ! = jclOrgMap ) {
oldFParentId = jclOrgMap . getFParentId ( ) ;
}
}
Integer ecParamDepartment = mergeParam . getDepartment ( ) ;
DepartmentPO targetDepartment = getDepartmentMapper ( ) . getDeptById ( ecParamDepartment ) ;
// 断言判断
OrganizationAssert . isFalse ( null = = targetDepartment , "被合并部门数据有误,暂时无法合并" ) ;
@ -618,7 +583,7 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
OrganizationAssert . notBlank ( mergeParam . getMergeName ( ) , "请输入合并后的名称" ) ;
// 不可选择合并的数据,本身及子部门
Set < Long > disableIds = new HashSet < > ( ) ;
Set < Integer > disableIds = new HashSet < > ( ) ;
// 添加选择部门本身
disableIds . add ( mergeParam . getId ( ) ) ;
List < DepartmentPO > deptListByPId = getDepartmentMapper ( ) . getDeptListByPId ( mergeParam . getId ( ) ) ;
@ -631,59 +596,52 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
List < DepartmentPO > firstChildDeptList = getDepartmentMapper ( ) . getDeptListByPId ( mergeParam . getId ( ) ) ;
// 更新所属部门、所属分部
for ( DepartmentPO departmentPO : firstChildDeptList ) {
departmentPO . setParentDept ( targetDepartment . getId ( ) ) ;
departmentPO . setEcDepartment ( ecParamDepartment ) ;
departmentPO . setParentComp ( targetDepartment . getParentComp ( ) ) ;
departmentPO . setEcCompany ( targetDepartment . getEcCompany ( ) ) ;
departmentPO . setSupDepId ( targetDepartment . getId ( ) ) ;
departmentPO . setSubCompanyId1 ( targetDepartment . getSubCompanyId1 ( ) ) ;
updateEcDepartment ( departmentPO ) ;
getDepartmentMapper ( ) . updateBaseDept ( departmentPO ) ;
// 更新组织架构图
new DepartmentTriggerRunnable ( departmentPO . getId ( ) ) . run ( ) ;
//TODO new DepartmentTriggerRunnable(departmentPO.getId()).run();
}
// 查询该部门一级岗位、更新岗位所属分部、所属部门
List < JobPO > firstChildJobList = getJobMapper ( ) . listJobsByDepartmentId ( mergeParam . getId ( ) ) ;
firstChildJobList = firstChildJobList . stream ( ) . filter ( item - > null = = item . getParentJob ( ) | | 0 = = item . getParentJob ( ) ) . collect ( Collectors . toList ( ) ) ;
// 批量更新部门、所属分部
RecordSet rs = new RecordSet ( ) ;
String targetEcDeptId = EcHrmRelationUtil. getEcDepartmentId ( targetDepartment. getId ( ) . toString ( ) ) ;
String mergeEcDeptId = EcHrmRelationUtil. getEcDepartmentId ( mergeParam. getId ( ) . toString ( ) ) ;
rs . executeUpdate ( "update jcl_org_job set parent_comp =?,ec_company =?,parent_dept =?,ec_department =? where parent_dept =?", targetDepartment . getParentComp ( ) , targetDepartment . getEcCompany ( ) , targetDepartment . getId ( ) , targetEcDeptId , mergeParam . getId ( ) ) ;
String targetEcDeptId = targetDepartment. getId ( ) . toString ( ) ;
String mergeEcDeptId = mergeParam. getId ( ) . toString ( ) ;
rs . executeUpdate ( "update jcl_org_job set parent_comp =?,ec_company =?,parent_dept =?,ec_department =? where ec_department =?", targetDepartment . getSubCompanyId1 ( ) , targetDepartment . getSubCompanyId1 ( ) , targetDepartment . getId ( ) , targetEcDeptId , mergeParam . getId ( ) ) ;
// 更新岗位组织架构图
for ( JobPO jobPO : firstChildJobList ) {
// 刷新组织架构图
new JobTriggerRunnable ( jobPO . getId ( ) ) . run ( ) ;
}
// 更新当前部门下的人员
List< Long > hrmResourceIds = getSystemDataMapper ( ) . getHrmResourceIdsByDept ( mergeParam . getId ( ) . toString ( ) ) ;
rs . executeUpdate ( "update hrmresource set SUBCOMPANYID1 =?,DEPARTMENTID =? where DEPARTMENTID =?" , targetDepartment . getEcCompany ( ) , targetEcDeptId , mergeEcDeptId ) ;
new RecordSet ( ) . executeUpdate ( "update jcl_org_hrmresource set company_id =? ,ec_company = ? ,department_id = ?, ec_department = ?where department_id =?" , targetDepartment . getParentComp ( ) , targetDepartment . getEcCompany ( ) , targetDepartment . getId ( ) , targetEcDeptId , mergeParam . getId ( ) ) ;
// 更新人员组织架构图
for ( Long hrmResourceId : hrmResourceIds ) {
new HrmResourceTriggerRunnable ( hrmResourceId ) . run ( ) ;
}
rs. executeUpdate ( "update hrmresource set SUBCOMPANYID1 =?,DEPARTMENTID =? where DEPARTMENTID =?" , targetDepartment . getSubCompanyId1 ( ) , targetEcDeptId , mergeEcDeptId ) ;
//new RecordSet().executeUpdate("update jcl_org_hrmresource set company_id =? ,ec_company = ? ,department_id = ?, ec_department = ?where department_id =?", targetDepartment.getParentComp(), targetDepartment.getEcCompany(), targetDepartment.getId(), targetEcDeptId, mergeParam.getId());
//List<Long> hrmResourceIds = getSystemDataMapper().getHrmResourceIdsByDept(mergeParam.getId().toString());
// // 更新人员组织架构图
//for (Long hrmResourceId : hrmResourceIds) {
//TODO new HrmResourceTriggerRunnable(hrmResourceId).run();
//}
// 更新子部门下岗位的所属分部
for ( DepartmentPO departmentPO : firstChildDeptList ) {
List < DepartmentPO > deptList = getDepartmentMapper ( ) . getDeptListByPId ( departmentPO . getId ( ) ) ;
forbiddenChildTag ( targetDepartment . get ParentComp ( ) , Util . null2String ( targetDepartment . get EcCompany ( ) ) , deptList ) ;
forbiddenChildTag ( targetDepartment . get SubCompanyId1 ( ) , Util . null2String ( targetDepartment . get SubCompanyId1 ( ) ) , deptList ) ;
}
// 原部门删除
DepartmentPO mergeDepartment = getDepartmentMapper ( ) . getDeptById ( mergeParam . getId ( ) ) ;
// DepartmentPO mergeDepartment = getDepartmentMapper().getDeptById(mergeParam.getId());
Map < String , Object > map = new HashMap < > ( ) ;
map . put ( "id" , mergeParam . getId ( ) ) ;
new OrganizationSyncEc ( user , LogModuleNameEnum . DEPARTMENT , OperateTypeEnum . CANCELED , map ) . sync ( ) ;
// 删除拓展表、明细表
MapperProxyFactory . getProxy ( ExtMapper . class ) . deleteByID ( "jcl_org_deptext" , mergeParam . getId ( ) ) ;
MapperProxyFactory . getProxy ( ExtDTMapper . class ) . deleteByMainID ( "jcl_org_deptext_dt1" , mergeParam . getId ( ) , null ) ;
getDepartmentMapper ( ) . deleteByIds ( DeleteParam . builder ( ) . ids ( mergeParam . getId ( ) . toString ( ) ) . build ( ) . getIds ( ) ) ;
map . put ( "id" , Util . null2String ( mergeParam . getId ( ) ) ) ;
// 删除部门
ServiceUtil . getService ( OrganizationServiceImpl . class , user ) . delDepartment ( map , user ) ;
// 更新组织架构图
new DepartmentTriggerRunnable ( mergeDepartment ) . run ( ) ;
// TODO new DepartmentTriggerRunnable(mergeDepartment).run();
// 更新部门合并后名称
targetDepartment . setDep tName( mergeParam . getMergeName ( ) ) ;
targetDepartment . setDep tNameShort ( mergeParam . getMergeName ( ) ) ;
targetDepartment . setDep artmen tName( mergeParam . getMergeName ( ) ) ;
targetDepartment . setDep artmentMark ( mergeParam . getMergeName ( ) ) ;
updateEcDepartment ( targetDepartment ) ;
getDepartmentMapper ( ) . updateBaseDept ( targetDepartment ) ;
// 更新组织架构图
new DepartmentTriggerRunnable ( oldFParentId , targetDepartment . getId ( ) ) . run ( ) ;
// TODO new DepartmentTriggerRunnable(oldFParentId, targetDepartment.getId()).run();
return 0 ;
}
@ -718,55 +676,46 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
DepartmentPO deptById = getDepartmentMapper ( ) . getDeptById ( moveParam . getId ( ) ) ;
// 0: 公司/分部 1: 部门
if ( "0" . equals ( moveParam . getMoveType ( ) ) ) {
Long company = moveParam . getCompany ( ) ;
Integer company = moveParam . getCompany ( ) ;
OrganizationAssert . notNull ( company , "请选择要转移到的分部" ) ;
deptById . setEcCompany ( company ) ;
deptById . setParentComp ( Objects . requireNonNull ( EcHrmRelationUtil . getJclCompanyId ( Util . null2String ( company ) ) ) . getId ( ) ) ;
deptById . setParentDept ( null ) ;
deptById . setEcDepartment ( null ) ;
deptById . setSubCompanyId1 ( company ) ;
deptById . setSupDepId ( null ) ;
// 更新组织架构图
new DepartmentTriggerRunnable ( company . toString ( ) , deptById ) . run ( ) ;
//TODO new DepartmentTriggerRunnable(company.toString(), deptById).run();
} else if ( "1" . equals ( moveParam . getMoveType ( ) ) ) {
Long department = moveParam . getDepartment ( ) ;
Long departmentId = Objects . requireNonNull ( EcHrmRelationUtil . getJclDepartmentId ( Util . null2String ( department ) ) ) . getId ( ) ;
Integer departmentId = moveParam . getDepartment ( ) ;
OrganizationAssert . notNull ( departmentId , "请选择要转移到的部门" ) ;
List < DepartmentPO > deptListByPId = getDepartmentMapper ( ) . getDeptListByPId ( moveParam . getId ( ) ) ;
Set < Long > disableIds = new HashSet < > ( ) ;
Set < Integer > disableIds = new HashSet < > ( ) ;
disableIds . add ( moveParam . getId ( ) ) ;
if ( CollectionUtils . isNotEmpty ( deptListByPId ) ) {
addDisableIds ( disableIds , deptListByPId ) ;
}
OrganizationAssert . isFalse ( disableIds . contains ( departmentId ) , "请勿选择当前部门本身及其子部门" ) ;
deptById . setParentDept ( departmentId ) ;
deptById . setEcDepartment ( department ) ;
deptById . setSupDepId ( departmentId ) ;
DepartmentPO parentDepartment = getDepartmentMapper ( ) . getDeptById ( departmentId ) ;
deptById . setParentComp ( parentDepartment . getParentComp ( ) ) ;
deptById . setEcCompany ( parentDepartment . getEcCompany ( ) ) ;
deptById . setSubCompanyId1 ( parentDepartment . getSubCompanyId1 ( ) ) ;
// 更新组织架构图
new DepartmentTriggerRunnable ( Integer . toString ( 100000000 + department . intValue ( ) ) , deptById ) . run ( ) ;
// TODO new DepartmentTriggerRunnable(Integer.toString(100000000 + department.intValue()), deptById).run();
}
// 更新EC部门
updateEcDepartment ( deptById ) ;
int updateBaseDept = getDepartmentMapper ( ) . updateBaseDept ( deptById ) ;
// 刷新岗位分部
refreshJobComp ( deptById . getId ( ) , deptById . get ParentComp ( ) ) ;
refreshJobComp ( deptById . getId ( ) , deptById . get SubCompanyId1 ( ) ) ;
List < DepartmentPO > deptList = getDepartmentMapper ( ) . getDeptListByPId ( deptById . getId ( ) ) ;
String ecCompanyId = EcHrmRelationUtil . getEcCompanyId ( Util . null2String ( deptById . getParentComp ( ) ) ) ;
// 更新当前部门下的人员
List < Long > hrmResourceIds = getSystemDataMapper ( ) . getHrmResourceIdsByDept ( deptById . getId ( ) . toString ( ) ) ;
String ecDepartmentId = EcHrmRelationUtil . getEcDepartmentId ( deptById . getId ( ) . toString ( ) ) ;
new RecordSet ( ) . executeUpdate ( "update hrmresource set SUBCOMPANYID1 =? where DEPARTMENTID = ?" , ecCompanyId , ecDepartmentId ) ;
new RecordSet ( ) . executeUpdate ( "update jcl_org_hrmresource set company_id =? ,ec_company = ? where department_id =?" , deptById . getParentComp ( ) , ecCompanyId , deptById . getId ( ) ) ;
// 更新人员组织架构图
for ( Long hrmResourceId : hrmResourceIds ) {
new HrmResourceTriggerRunnable ( hrmResourceId ) . run ( ) ;
}
forbiddenChildTag ( deptById . getParentComp ( ) , ecCompanyId , deptList ) ;
// new RecordSet().executeUpdate("update hrmresource set SUBCOMPANYID1 =? where DEPARTMENTID = ?", deptById.getSubCompanyId1(), deptById.getId());
//// 更新人员组织架构图
//List<Long> hrmResourceIds = getSystemDataMapper().getHrmResourceIdsByDept(deptById.getId().toString());
//for (Long hrmResourceId : hrmResourceIds) {
//TODO new HrmResourceTriggerRunnable(hrmResourceId).run();
//}
forbiddenChildTag ( deptById . getSubCompanyId1 ( ) , Util . null2String ( deptById . getSubCompanyId1 ( ) ) , deptList ) ;
// 递归更新下级部门、岗位
return updateBaseDept ;
return 1 ;
}
/ * *
@ -775,28 +724,26 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
* @param parentComp
* @param deptList
* /
void forbiddenChildTag ( Long parentComp , String ecCompanyId , List < DepartmentPO > deptList ) {
void forbiddenChildTag ( Integer parentComp , String ecCompanyId , List < DepartmentPO > deptList ) {
if ( CollectionUtils . isNotEmpty ( deptList ) ) {
for ( DepartmentPO departmentPO : deptList ) {
departmentPO . setParentComp ( parentComp ) ;
departmentPO . setEcCompany ( Long . parseLong ( ecCompanyId ) ) ;
departmentPO . setSubCompanyId1 ( parentComp ) ;
// 更新EC表部门
updateEcDepartment ( departmentPO ) ;
updateEcDepartment ( departmentPO ) ;
getDepartmentMapper ( ) . updateBaseDept ( departmentPO ) ;
// 更新组织架构图
new DepartmentTriggerRunnable ( departmentPO . getId ( ) ) . run ( ) ;
// TODO new DepartmentTriggerRunnable(departmentPO.getId()).run();
// 刷新岗位所属分部
refreshJobComp ( departmentPO . getId ( ) , parentComp ) ;
// 更新当前部门下的人员
List < Long > hrmResourceIds = getSystemDataMapper ( ) . getHrmResourceIdsByDept ( departmentPO . getId ( ) . toString ( ) ) ;
String ecDepartmentId = EcHrmRelationUtil . getEcDepartmentId ( departmentPO . getId ( ) . toString ( ) ) ;
new RecordSet ( ) . executeUpdate ( "update hrmresource set SUBCOMPANYID1 =? where DEPARTMENTID = ?" , ecCompanyId , ecDepartmentId ) ;
new RecordSet ( ) . executeUpdate ( "update jcl_org_hrmresource set company_id =? ,ec_company = ? where department_id =?" , parentComp , ecCompanyId , departmentPO . getId ( ) ) ;
// 更新人员组织架构图
for ( Long hrmResourceId : hrmResourceIds ) {
new HrmResourceTriggerRunnable ( hrmResourceId ) . run ( ) ;
}
// String ecDepartmentId = EcHrmRelationUtil.getEcDepartmentId(departmentPO.getId().toString());
//new RecordSet().executeUpdate("update hrmresource set SUBCOMPANYID1 =? where DEPARTMENTID = ?", ecCompanyId, ecDepartmentId);
//new RecordSet().executeUpdate("update jcl_org_hrmresource set company_id =? ,ec_company = ? where department_id =?", parentComp, ecCompanyId, departmentPO.getId());
//List<Long> hrmResourceIds = getSystemDataMapper().getHrmResourceIdsByDept(departmentPO.getId().toString());
// // 更新人员组织架构图
//for (Long hrmResourceId : hrmResourceIds) {
//TODO new HrmResourceTriggerRunnable(hrmResourceId).run();
//}
List < DepartmentPO > childList = getDepartmentMapper ( ) . getDeptListByPId ( departmentPO . getId ( ) ) ;
forbiddenChildTag ( parentComp , ecCompanyId , childList ) ;
}
@ -810,16 +757,10 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
* @return
* /
private boolean isFilter ( DepartmentPO departmentPO ) {
return ! ( StringUtil . isEmpty ( departmentPO . getDeptNo ( ) )
& & StringUtil . isEmpty ( departmentPO . getDeptName ( ) )
& & StringUtil . isEmpty ( departmentPO . getDeptNameShort ( ) )
& & null = = departmentPO . getEcCompany ( )
& & null = = departmentPO . getEcDepartment ( )
& & null = = departmentPO . getParentComp ( )
& & null = = departmentPO . getParentDept ( )
& & null = = departmentPO . getDeptPrincipal ( )
& & null = = departmentPO . getShowOrder ( )
& & null = = departmentPO . getForbiddenTag ( ) ) ;
return ! ( StringUtil . isEmpty ( departmentPO . getDepartmentCode ( ) )
& & StringUtil . isEmpty ( departmentPO . getDepartmentName ( ) )
& & null = = departmentPO . getSubCompanyId1 ( )
& & null = = departmentPO . getSupDepId ( ) ) ;
}
@ -832,18 +773,18 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
* /
private List < SearchTree > getFilterCompany ( String id , String keyword ) {
// 查询部门信息
Long parentCompId = StringUtil . isEmpty ( id ) ? null : Long. parseLong ( id ) ;
CompPO compBuild = CompPO . builder ( ) . compName( keyword ) . parentCompany ( parentCompId ) . forbiddenTag ( 0 ) . build ( ) ;
List < CompPO > allCompanys = getCompMapper ( ) . list ( "show_o rder") ;
Integer parentCompId = StringUtil . isEmpty ( id ) ? null : Integer. parseInt ( id ) ;
CompPO compBuild = CompPO . builder ( ) . subCompanyName( keyword ) . supSubComId ( parentCompId ) . canceled ( 0 ) . build ( ) ;
List < CompPO > allCompanys = getCompMapper ( ) . list All( "showO rder") ;
new DetachUtil ( user . getUID ( ) ) . filterCompanyList ( allCompanys ) ;
List < CompPO > filterComps = getCompMapper ( ) . listByFilter ( compBuild , "show _o rder") ;
List < CompPO > filterComps = getCompMapper ( ) . listByFilter ( compBuild , "show O rder") ;
new DetachUtil ( user . getUID ( ) ) . filterCompanyList ( filterComps ) ;
Map < Long , CompPO > allMaps = allCompanys . stream ( ) . collect ( Collectors . toMap ( CompPO : : getId , item - > item , ( k1 , k2 ) - > k1 ) ) ;
Map < Integer , CompPO > allMaps = allCompanys . stream ( ) . collect ( Collectors . toMap ( CompPO : : getId , item - > item , ( k1 , k2 ) - > k1 ) ) ;
Set < CompPO > builderComps = new HashSet < > ( ) ;
for ( CompPO comp PO : filterComps ) {
buildParentComps ( comp PO, builderComps , allMaps ) ;
for ( CompPO comp any PO : filterComps ) {
buildParentComps ( comp any PO, builderComps , allMaps ) ;
}
return SearchTreeUtil . builderTreeMode ( CompBO . buildSetToSearchTree ( builderComps ) ) ;
@ -855,10 +796,10 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
* @param compPO
* @param builderComps
* /
private void buildParentComps ( CompPO compPO , Set < CompPO > builderComps , Map < Long , CompPO > allMaps ) {
private void buildParentComps ( CompPO compPO , Set < CompPO > builderComps , Map < Integer , CompPO > allMaps ) {
builderComps . add ( compPO ) ;
CompPO parentComp = allMaps . get ( compPO . get ParentCompany ( ) ) ;
if ( null ! = parentComp & & 0 = = parentComp . getForbiddenTag ( ) ) {
CompPO parentComp = allMaps . get ( compPO . get SupSubComId ( ) ) ;
if ( null ! = parentComp & & ( null = = parentComp . getCanceled ( ) | | 0 = = parentComp . getCanceled ( ) ) ) {
buildParentComps ( parentComp , builderComps , allMaps ) ;
}
}
@ -903,7 +844,7 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
* @param parentDeptId
* @param orderNum
* /
private void recursionCopyJob ( List < JobPO > jobPOS , Long parentCompId , Long parentDeptId , Long currentParentJobId , int orderNum , long timeMillis ) {
private void recursionCopyJob ( List < JobPO > jobPOS , Integer parentCompId , Integer parentDeptId , Long currentParentJobId , int orderNum , long timeMillis ) {
for ( JobPO jobPO : jobPOS ) {
orderNum + + ;
@ -915,16 +856,12 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
// 所属部门赋值
jobPO . setParentDept ( parentDeptId ) ;
String ecDepartmentId = EcHrmRelationUtil . getEcDepartmentId ( parentDeptId . toString ( ) ) ;
if ( StringUtils . isNotBlank ( ecDepartmentId ) ) {
jobPO . setEcDepartment ( Long . parseLong ( ecDepartmentId ) ) ;
}
jobPO . setEcDepartment ( parentDeptId ) ;
// 所属分部赋值
jobPO . setEcCompany ( parentCompId ) ;
CompPO jclCompanyId = EcHrmRelationUtil . getJclCompanyId ( Util . null2String ( parentCompId ) ) ;
if ( null ! = jclCompanyId ) {
jobPO . setParentComp ( jclCompanyId . getId ( ) ) ;
}
jobPO . setParentComp ( parentCompId ) ;
// 指定上级岗位
jobPO . setParentJob ( currentParentJobId ) ;
jobPO . setCreator ( ( long ) user . getUID ( ) ) ;
@ -948,14 +885,14 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
* /
private void updateEcDepartment ( DepartmentPO departmentPO ) {
Map < String , Object > map = new HashMap < > ( ) ;
map . put ( "dep t_name_short", departmentPO . getDeptNameShort ( ) ) ;
map . put ( "dep t_ name", departmentPO . getDep tName( ) ) ;
map . put ( " parent_comp", departmentPO . getParentComp ( ) ) ;
map . put ( " parent_dept", departmentPO . getParentDept ( ) ) ;
map . put ( "show _ order", departmentPO. getShowOrder ( ) ) ;
map . put ( "dep t_no", departmentPO . getDeptNo ( ) ) ;
map . put ( " dept_principal", departmentPO . getDeptPrincipal ( ) ) ;
map . put ( "id" , departmentPO . getId ( ) ) ;
map . put ( "dep artmentmark", departmentPO . getDepartmentMark ( ) ) ;
map . put ( "dep artment name", departmentPO . getDep artmen tName( ) ) ;
map . put ( " subcompanyid1", Util . null2String ( departmentPO . getSubCompanyId1 ( ) ) ) ;
map . put ( " supdepid", Util . null2String ( departmentPO . getSupDepId ( ) ) ) ;
map . put ( "show order", Util. null2String ( departmentPO. getShowOrder ( ) ) ) ;
map . put ( "dep artmentcode", departmentPO . getDepartmentCode ( ) ) ;
map . put ( " coadjutant", Util . null2String ( departmentPO . getCoadjutant ( ) ) ) ;
map . put ( "id" , Util . null2String ( departmentPO . getId ( ) ) ) ;
new OrganizationSyncEc ( user , LogModuleNameEnum . DEPARTMENT , OperateTypeEnum . UPDATE , map ) . sync ( ) ;
}
@ -967,14 +904,12 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
* /
private Map < String , Object > addEcDepartment ( DepartmentPO departmentPO ) {
Map < String , Object > map = new HashMap < > ( ) ;
map . put ( "dept_name_short" , departmentPO . getDeptNameShort ( ) ) ;
map . put ( "dept_name" , departmentPO . getDeptName ( ) ) ;
map . put ( "parent_comp" , departmentPO . getParentComp ( ) ) ;
map . put ( "parent_dept" , departmentPO . getParentDept ( ) ) ;
map . put ( "show_order" , departmentPO . getShowOrder ( ) ) ;
map . put ( "dept_no" , departmentPO . getDeptNo ( ) ) ;
map . put ( "dept_principal" , departmentPO . getDeptPrincipal ( ) ) ;
map . put ( "id" , departmentPO . getId ( ) ) ;
map . put ( "departmentmark" , departmentPO . getDepartmentMark ( ) ) ;
map . put ( "departmentname" , departmentPO . getDepartmentName ( ) ) ;
map . put ( "subcompanyid1" , Util . null2String ( departmentPO . getSubCompanyId1 ( ) ) ) ;
map . put ( "supdepid" , Util . null2String ( departmentPO . getSupDepId ( ) ) ) ;
map . put ( "showorder" , Util . null2String ( departmentPO . getShowOrder ( ) ) ) ;
map . put ( "departmentcode" , departmentPO . getDepartmentCode ( ) ) ;
return new OrganizationSyncEc ( user , LogModuleNameEnum . DEPARTMENT , OperateTypeEnum . ADD , map ) . sync ( ) ;
}
@ -990,7 +925,7 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
new OrganizationSyncEc ( user , LogModuleNameEnum . DEPARTMENT , OperateTypeEnum . CANCELED , map ) . sync ( ) ;
}
private void addDisableIds ( Set < Long > disableIds , List < DepartmentPO > deptListByPId ) {
private void addDisableIds ( Set < Integer > disableIds , List < DepartmentPO > deptListByPId ) {
for ( DepartmentPO departmentPO : deptListByPId ) {
disableIds . add ( departmentPO . getId ( ) ) ;
List < DepartmentPO > childDeptPOS = getDepartmentMapper ( ) . getDeptListByPId ( departmentPO . getId ( ) ) ;
@ -1004,12 +939,11 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
* @param parentDepartment
* @param parentComp
* /
private void refreshJobComp ( Long parentDepartment , Long parentComp ) {
private void refreshJobComp ( Integer parentDepartment , Integer parentComp ) {
List < JobPO > jobPOS = getJobMapper ( ) . listJobsByDepartmentId ( parentDepartment ) ;
jobPOS = jobPOS . stream ( ) . filter ( item - > null = = item . getParentJob ( ) | | 0 = = item . getParentJob ( ) ) . collect ( Collectors . toList ( ) ) ;
if ( CollectionUtils . isNotEmpty ( jobPOS ) ) {
String ecCompanyId = EcHrmRelationUtil . getEcCompanyId ( parentComp . toString ( ) ) ;
getJobMapper ( ) . updateJobCompany ( jobPOS . stream ( ) . map ( JobPO : : getId ) . collect ( Collectors . toList ( ) ) , parentComp , ecCompanyId ) ;
getJobMapper ( ) . updateJobCompany ( jobPOS . stream ( ) . map ( JobPO : : getId ) . collect ( Collectors . toList ( ) ) , parentComp , parentComp ) ;
for ( JobPO jobPO : jobPOS ) {
// 刷新组织架构图
new JobTriggerRunnable ( jobPO . getId ( ) ) . run ( ) ;