@ -1,7 +1,6 @@
package com.engine.organization.service.impl ;
import com.alibaba.fastjson.JSONObject ;
import com.api.browser.bean.BrowserBean ;
import com.api.browser.bean.SearchConditionGroup ;
import com.api.browser.bean.SearchConditionItem ;
import com.api.browser.bean.SearchConditionOption ;
@ -12,13 +11,13 @@ import com.engine.core.impl.Service;
import com.engine.hrm.entity.RuleCodeType ;
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.company.bo.CompBO ;
import com.engine.organization.entity.company.po.CompPO ;
import com.engine.organization.entity.department.bo.DepartmentBO ;
import com.engine.organization.entity.department.po.DepartmentPO ;
import com.engine.organization.entity.employee.vo.EmployeeTableVO ;
import com.engine.organization.entity.extend.bo.ExtendInfoBO ;
import com.engine.organization.entity.extend.po.ExtendGroupPO ;
import com.engine.organization.entity.extend.po.ExtendInfoPO ;
import com.engine.organization.entity.job.bo.JobBO ;
import com.engine.organization.entity.job.dto.JobListDTO ;
@ -28,7 +27,6 @@ import com.engine.organization.entity.job.po.JobPO;
import com.engine.organization.entity.scheme.po.GradePO ;
import com.engine.organization.entity.searchtree.SearchTree ;
import com.engine.organization.entity.searchtree.SearchTreeParams ;
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.ExtendGroupMapper ;
@ -83,6 +81,10 @@ public class JobServiceImpl extends Service implements JobService {
* 3 : 岗 位
* /
private static final String EXTEND_TYPE = "3" ;
/ * *
* 主 表
* /
private static final String JCL_ORG_JOB = "JCL_ORG_JOB" ;
/ * *
* 主 表 拓 展 表
* /
@ -94,6 +96,11 @@ public class JobServiceImpl extends Service implements JobService {
private static final String RIGHT_NAME = "Job:All" ;
/ * *
* 岗 位 主 表 title 指 定 ID
* /
private static final Long GROUP_ID = - 3L ;
private JobMapper getJobMapper ( ) {
return MapperProxyFactory . getProxy ( JobMapper . class ) ;
}
@ -251,51 +258,15 @@ public class JobServiceImpl extends Service implements JobService {
@Override
public Map < String , Object > getSaveForm ( ) {
HasRightUtil . hasRight ( user , RIGHT_NAME , false ) ;
Map < String , Object > apiDatas = new HashMap < > ( ) ;
List < SearchConditionGroup > addGroups = new ArrayList < > ( ) ;
List < SearchConditionItem > conditionItems = new ArrayList < > ( ) ;
// 编号
SearchConditionItem jobNoItem = OrganizationFormItemUtil . inputItem ( user , 2 , 16 , 3 , 50 , "编号" , "jobNo" ) ;
jobNoItem . setRules ( "required|string" ) ;
CodeRulePO codeRuleByType = MapperProxyFactory . getProxy ( CodeRuleMapper . class ) . getCodeRuleByType ( RuleCodeType . JOBTITLES . getValue ( ) ) ;
if ( null ! = codeRuleByType & & "1" . equals ( codeRuleByType . getSerialEnable ( ) ) ) {
jobNoItem . setViewAttr ( 2 ) ;
jobNoItem . setRules ( "" ) ;
jobNoItem . setHelpfulTip ( "编号为空,则按照指定规则自动生成编号" ) ;
List < ExtendGroupPO > extendGroupPOS = getExtendGroupMapper ( ) . listGroupByPid ( GROUP_ID ) ;
if ( org . apache . commons . collections . CollectionUtils . isNotEmpty ( extendGroupPOS ) ) {
for ( ExtendGroupPO extendGroupPO : extendGroupPOS ) {
addGroups . add ( new SearchConditionGroup ( extendGroupPO . getGroupName ( ) , true , getExtService ( user ) . getExtSaveForm ( user , EXTEND_TYPE + "" , JCL_ORG_JOB , 2 , extendGroupPO . getId ( ) . toString ( ) , "job_no" , RuleCodeType . JOBTITLES . getValue ( ) ) ) ) ;
}
}
// 名称
SearchConditionItem jobNameItem = OrganizationFormItemUtil . inputItem ( user , 2 , 16 , 3 , 50 , "名称" , "jobName" ) ;
jobNameItem . setRules ( "required|string" ) ;
// 所属分部
SearchConditionItem parentCompBrowserItem = OrganizationFormItemUtil . browserItem ( user , 2 , 16 , 2 , false , "所属分部" , "161" , "parentComp" , "compBrowser" ) ;
// 所属部门
SearchConditionItem parentDeptBrowserItem = OrganizationFormItemUtil . browserItem ( user , 2 , 16 , 2 , false , "所属部门" , "161" , "parentDept" , "deptBrowser" ) ;
// 岗位序列
SearchConditionItem sequenceBrowserItem = OrganizationFormItemUtil . browserItem ( user , 2 , 16 , 2 , false , "岗位序列" , "161" , "sequenceId" , "sequenceBrowser" ) ;
// 等级方案
SearchConditionItem schemeBrowserItem = OrganizationFormItemUtil . browserItem ( user , 2 , 16 , 2 , false , "等级方案" , "161" , "schemeId" , "schemeBrowser" ) ;
// 上级岗位
SearchConditionItem parentJobBrowserItem = OrganizationFormItemUtil . browserItem ( user , 2 , 16 , 2 , false , "上级岗位" , "161" , "parentJob" , "jobBrowser" ) ;
// 是否关键岗
List < SearchConditionOption > isKeyOptions = new ArrayList < > ( ) ;
SearchConditionOption yesOption = new SearchConditionOption ( "0" , "否" ) ;
SearchConditionOption noOption = new SearchConditionOption ( "1" , "是" ) ;
isKeyOptions . add ( yesOption ) ;
isKeyOptions . add ( noOption ) ;
SearchConditionItem isKeyItem = OrganizationFormItemUtil . selectItem ( user , isKeyOptions , 2 , 16 , 6 , false , "是否关键岗" , "isKey" ) ;
isKeyItem . setDetailtype ( 3 ) ;
isKeyItem . setValue ( "0" ) ;
conditionItems . add ( jobNoItem ) ;
conditionItems . add ( jobNameItem ) ;
conditionItems . add ( parentCompBrowserItem ) ;
conditionItems . add ( parentDeptBrowserItem ) ;
conditionItems . add ( sequenceBrowserItem ) ;
conditionItems . add ( schemeBrowserItem ) ;
conditionItems . add ( parentJobBrowserItem ) ;
conditionItems . add ( isKeyItem ) ;
addGroups . add ( new SearchConditionGroup ( "基本信息" , true , conditionItems ) ) ;
apiDatas . put ( "condition" , addGroups ) ;
return apiDatas ;
}
@ -314,12 +285,15 @@ public class JobServiceImpl extends Service implements JobService {
buttonsMap . put ( "hasSave" , true ) ;
List < SearchConditionGroup > addGroups = new ArrayList < > ( ) ;
if ( StringUtil . isEmpty ( groupId ) | | "0" . equals ( groupId ) ) {
addGroups . add ( new SearchConditionGroup ( "基本信息" , true , getBaseForm ( viewAttr , id ) ) ) ;
} else {
addGroups . add ( new SearchConditionGroup ( getExtendGroupMapper ( ) . getGroupNameById ( groupId ) , true , getExtService ( user ) . getExtForm ( user , EXTEND_TYPE , JCL_ORG_JOBEXT , viewAttr , id , groupId ) ) ) ;
if ( "0" . equals ( groupId ) ) {
groupId = GROUP_ID . toString ( ) ;
}
List < ExtendGroupPO > extendGroupPOS = getExtendGroupMapper ( ) . listGroupByPid ( Long . parseLong ( groupId ) ) ;
if ( org . apache . commons . collections . CollectionUtils . isNotEmpty ( extendGroupPOS ) ) {
for ( ExtendGroupPO extendGroupPO : extendGroupPOS ) {
addGroups . add ( new SearchConditionGroup ( extendGroupPO . getGroupName ( ) , true , getExtService ( user ) . getExtForm ( user , EXTEND_TYPE + "" , Integer . parseInt ( groupId ) > = 0 ? JCL_ORG_JOBEXT : JCL_ORG_JOB , viewAttr , id , extendGroupPO . getId ( ) . toString ( ) , "job_no" ) ) ) ;
}
}
HashMap < String , Object > resultMap = new HashMap < > ( ) ;
resultMap . put ( "buttons" , buttonsMap ) ;
resultMap . put ( "conditions" , addGroups ) ;
@ -334,8 +308,8 @@ public class JobServiceImpl extends Service implements JobService {
tableMap . put ( "tabname" , "职等职级" ) ;
Map < String , Object > tabinfoMap = new HashMap < > ( ) ;
List < ExtendInfoPO > infoPOList = new ArrayList < > ( ) ;
infoPOList . add ( ExtendInfoPO . builder ( ) . fieldName ( "gradeId" ) . fieldNameDesc ( "职级" ) . controlType ( 3 ) . isrequired ( 1 ) . browserType ( "161" ) . custom BrowserId ( "gradeBrowser" ) . build ( ) ) ;
infoPOList . add ( ExtendInfoPO . builder ( ) . fieldName ( "levelId" ) . fieldNameDesc ( "职等" ) . controlType ( 3 ) . isrequired ( 1 ) . browserType ( "162" ) . custom BrowserId ( "levelBrowser" ) . build ( ) ) ;
infoPOList . add ( ExtendInfoPO . builder ( ) . fieldName ( "gradeId" ) . fieldNameDesc ( "职级" ) . controlType ( 3 ) . isrequired ( 1 ) . browserType ( "161" ) . custom Value ( "gradeBrowser" ) . build ( ) ) ;
infoPOList . add ( ExtendInfoPO . builder ( ) . fieldName ( "levelId" ) . fieldNameDesc ( "职等" ) . controlType ( 3 ) . isrequired ( 1 ) . browserType ( "162" ) . custom Value ( "levelBrowser" ) . build ( ) ) ;
tabinfoMap . put ( "columns" , ExtendInfoBO . convertInfoListToTable ( user , infoPOList , viewAttr , false ) ) ;
tabinfoMap . put ( "rownum" , "rownum" ) ;
// 去除null 元素
@ -356,15 +330,21 @@ public class JobServiceImpl extends Service implements JobService {
}
@Override
public int saveBaseForm ( JobSearchParam params ) {
public int saveBaseForm ( Map< String , Object > params ) {
HasRightUtil . hasRight ( user , RIGHT_NAME , false ) ;
JobSearchParam searchParam = JSONObject . parseObject ( JSONObject . toJSONString ( params ) , JobSearchParam . class ) ;
// 处理自动编号
params . setJobNo ( CodeRuleUtil . generateCode ( RuleCodeType . JOBTITLES , params . getJobNo ( ) ) ) ;
List < JobPO > list = getJobMapper ( ) . listByNo ( Util . null2String ( params . getJobNo ( ) ) ) ;
searchParam . setJobNo ( CodeRuleUtil . generateCode ( RuleCodeType . JOBTITLES , searchParam . getJobNo ( ) ) ) ;
List < JobPO > list = getJobMapper ( ) . listByNo ( Util . null2String ( searchParam . getJobNo ( ) ) ) ;
OrganizationAssert . isEmpty ( list , "编号不允许重复" ) ;
JobPO jobPO = JobBO . convertParamsToPO ( params , user . getUID ( ) ) ;
JobPO jobPO = JobBO . convertParamsToPO ( searchParam , user . getUID ( ) ) ;
jobPO . setIsKey ( null = = jobPO . getIsKey ( ) ? 0 : jobPO . getIsKey ( ) ) ;
int insertCount = getJobMapper ( ) . insertIgnoreNull ( jobPO ) ;
params . put ( "job_no" , jobPO . getJobNo ( ) ) ;
params . put ( "is_key" , jobPO . getIsKey ( ) ) ;
getExtService ( user ) . updateExtForm ( user , EXTEND_TYPE , JCL_ORG_JOB , params , "" , jobPO . getId ( ) ) ;
if ( null ! = jobPO . getSchemeId ( ) ) {
// 插入明细表信息
// 根据等级方案查询职等、职级
@ -383,24 +363,28 @@ public class JobServiceImpl extends Service implements JobService {
HasRightUtil . hasRight ( user , RIGHT_NAME , false ) ;
JobSearchParam searchParam = JSONObject . parseObject ( JSONObject . toJSONString ( params ) , JobSearchParam . class ) ;
String groupId = ( String ) params . get ( "viewCondition" ) ;
JobPO jobPO = JobBO . convertParamsToPO ( searchParam , user . getUID ( ) ) ;
jobPO . setIsKey ( null = = jobPO . getIsKey ( ) ? 0 : jobPO . getIsKey ( ) ) ;
searchParam . setIsKey ( null = = searchParam . getIsKey ( ) ? 0 : searchParam . getIsKey ( ) ) ;
if ( "0" . equals ( groupId ) ) {
groupId = GROUP_ID . toString ( ) ;
}
int updateCount = 0 ;
// 更新主表数据
updateCount + = getJobMapper ( ) . updateBaseJob ( jobPO ) ;
params . put ( "is_key" , searchParam . getIsKey ( ) ) ;
updateCount + = getExtService ( user ) . updateExtForm ( user , EXTEND_TYPE , JCL_ORG_JOB , params , "" , searchParam . getId ( ) ) ;
// 更新主表拓展表
updateCount + = getExtService ( user ) . updateExtForm ( user , EXTEND_TYPE , JCL_ORG_JOBEXT , params , groupId , jobPO . getId ( ) ) ;
updateCount + = getExtService ( user ) . updateExtForm ( user , EXTEND_TYPE , JCL_ORG_JOBEXT , params , groupId , searchParam . getId ( ) ) ;
// 更新明细表
getJobDTMapper ( ) . deleteByIds ( jobPO . getId ( ) ) ;
getJobDTMapper ( ) . deleteByIds ( searchParam . getId ( ) ) ;
int rowNum = Util . getIntValue ( ( String ) params . get ( "rownum" ) ) ;
for ( int i = 0 ; i < rowNum ; i + + ) {
String levelId = ( String ) params . get ( "levelId_" + i ) ;
String gradeId = ( String ) params . get ( "gradeId_" + i ) ;
String levelIdspan = ( String ) params . get ( "levelIdspan_" + i ) ;
String gradeIdspan = ( String ) params . get ( "gradeIdspan_" + i ) ;
getJobDTMapper ( ) . insertIgnoreNull ( JobDTPO . builder ( ) . levelId ( levelId ) . gradeId ( gradeId ) . levelIdspan ( levelIdspan ) . gradeIdspan ( gradeIdspan ) . mainId ( jobPO . getId ( ) ) . creator ( ( long ) user . getUID ( ) ) . deleteType ( 0 ) . createTime ( new Date ( ) ) . updateTime ( new Date ( ) ) . build ( ) ) ;
getJobDTMapper ( ) . insertIgnoreNull ( JobDTPO . builder ( ) . levelId ( levelId ) . gradeId ( gradeId ) . levelIdspan ( levelIdspan ) . gradeIdspan ( gradeIdspan ) . mainId ( searchParam . getId ( ) ) . creator ( ( long ) user . getUID ( ) ) . deleteType ( 0 ) . createTime ( new Date ( ) ) . updateTime ( new Date ( ) ) . build ( ) ) ;
}
getExtService ( user ) . updateExtDT ( user , EXTEND_TYPE , JCL_ORG_JOBEXT_DT1 , params , jobPO . getId ( ) ) ;
getExtService ( user ) . updateExtDT ( user , EXTEND_TYPE , JCL_ORG_JOBEXT_DT1 , params , searchParam . getId ( ) ) ;
return updateCount ;
}
@ -564,112 +548,6 @@ public class JobServiceImpl extends Service implements JobService {
& & null = = jobPO . getForbiddenTag ( ) ;
}
/ * *
* 基 本 信 息 基 础 表 单
*
* @param viewAttr
* @param id
* @return
* /
private List < SearchConditionItem > getBaseForm ( int viewAttr , long id ) {
List < SearchConditionItem > conditionItems = new ArrayList < > ( ) ;
// 编号
SearchConditionItem jobNoItem = OrganizationFormItemUtil . inputItem ( user , 2 , 16 , 1 , 50 , "编号" , "jobNo" ) ;
// 名称
SearchConditionItem jobNameItem = OrganizationFormItemUtil . inputItem ( user , 2 , 16 , 3 , 50 , "名称" , "jobName" ) ;
jobNameItem . setRules ( "required|string" ) ;
// 所属分部
SearchConditionItem parentCompBrowserItem = OrganizationFormItemUtil . browserItem ( user , 2 , 16 , 2 , false , "所属分部" , "161" , "parentComp" , "compBrowser" ) ;
// 所属部门
SearchConditionItem parentDeptBrowserItem = OrganizationFormItemUtil . browserItem ( user , 2 , 16 , 2 , false , "所属部门" , "161" , "parentDept" , "deptBrowser" ) ;
// 岗位序列
SearchConditionItem sequenceBrowserItem = OrganizationFormItemUtil . browserItem ( user , 2 , 16 , 2 , false , "岗位序列" , "161" , "sequenceId" , "sequenceBrowser" ) ;
// 等级方案
SearchConditionItem schemeBrowserItem = OrganizationFormItemUtil . browserItem ( user , 2 , 16 , 3 , false , "等级方案" , "161" , "schemeId" , "schemeBrowser" ) ;
// 上级岗位
SearchConditionItem parentJobBrowserItem = OrganizationFormItemUtil . browserItem ( user , 2 , 16 , 2 , false , "上级岗位" , "161" , "parentJob" , "jobBrowser" ) ;
// 是否关键岗
List < SearchConditionOption > isKeyOptions = new ArrayList < > ( ) ;
SearchConditionOption yesOption = new SearchConditionOption ( "0" , "否" ) ;
SearchConditionOption noOption = new SearchConditionOption ( "1" , "是" ) ;
isKeyOptions . add ( yesOption ) ;
isKeyOptions . add ( noOption ) ;
SearchConditionItem isKeyItem = OrganizationFormItemUtil . selectItem ( user , isKeyOptions , 2 , 16 , 6 , false , "是否关键岗" , "isKey" ) ;
isKeyItem . setDetailtype ( 3 ) ;
// 工作地点
SearchConditionItem workplaceItem = OrganizationFormItemUtil . inputItem ( user , 2 , 16 , 2 , 50 , "工作地点" , "workplace" ) ;
// 工作概述
SearchConditionItem descriptionItem = OrganizationFormItemUtil . textareaItem ( user , 2 , 16 , false , 2 , 50 , "工作概述" , "description" ) ;
// 任职职责
SearchConditionItem workDutyItem = OrganizationFormItemUtil . textareaItem ( user , 2 , 16 , false , 2 , 50 , "任职职责" , "workDuty" ) ;
// 工作权限
SearchConditionItem workAuthorityItem = OrganizationFormItemUtil . textareaItem ( user , 2 , 16 , false , 2 , 50 , "工作权限" , "workAuthority" ) ;
conditionItems . add ( jobNoItem ) ;
conditionItems . add ( jobNameItem ) ;
conditionItems . add ( parentCompBrowserItem ) ;
conditionItems . add ( parentDeptBrowserItem ) ;
conditionItems . add ( sequenceBrowserItem ) ;
conditionItems . add ( schemeBrowserItem ) ;
conditionItems . add ( parentJobBrowserItem ) ;
conditionItems . add ( isKeyItem ) ;
conditionItems . add ( workplaceItem ) ;
conditionItems . add ( descriptionItem ) ;
conditionItems . add ( workDutyItem ) ;
conditionItems . add ( workAuthorityItem ) ;
// 编辑、查看状态赋值,设置只读状态
JobPO jobPO = getJobMapper ( ) . getJobById ( id ) ;
OrganizationAssert . notNull ( jobPO , "数据不存在或数据已删除" ) ;
jobNoItem . setValue ( jobPO . getJobNo ( ) ) ;
jobNameItem . setValue ( jobPO . getJobName ( ) ) ;
isKeyItem . setValue ( null = = jobPO . getIsKey ( ) ? "0" : jobPO . getIsKey ( ) + "" ) ;
workplaceItem . setValue ( jobPO . getWorkplace ( ) ) ;
descriptionItem . setValue ( jobPO . getDescription ( ) ) ;
workDutyItem . setValue ( jobPO . getWorkDuty ( ) ) ;
workAuthorityItem . setValue ( jobPO . getWorkAuthority ( ) ) ;
if ( null ! = jobPO . getParentComp ( ) ) {
BrowserBean browserBean = parentCompBrowserItem . getBrowserConditionParam ( ) ;
List < Map < String , Object > > compMaps = getCompMapper ( ) . listCompsByIds ( DeleteParam . builder ( ) . ids ( jobPO . getParentComp ( ) . toString ( ) ) . build ( ) . getIds ( ) ) ;
browserBean . setReplaceDatas ( compMaps ) ;
parentCompBrowserItem . setBrowserConditionParam ( browserBean ) ;
}
if ( null ! = jobPO . getParentDept ( ) ) {
BrowserBean browserBean = parentDeptBrowserItem . getBrowserConditionParam ( ) ;
List < Map < String , Object > > deptMaps = getDepartmentMapper ( ) . listDeptsByIds ( DeleteParam . builder ( ) . ids ( jobPO . getParentDept ( ) . toString ( ) ) . build ( ) . getIds ( ) ) ;
browserBean . setReplaceDatas ( deptMaps ) ;
parentDeptBrowserItem . setBrowserConditionParam ( browserBean ) ;
}
if ( null ! = jobPO . getSequenceId ( ) ) {
BrowserBean browserBean = sequenceBrowserItem . getBrowserConditionParam ( ) ;
List < Map < String , Object > > deptMaps = getSequenceMapper ( ) . listSequencesByIds ( DeleteParam . builder ( ) . ids ( jobPO . getSequenceId ( ) . toString ( ) ) . build ( ) . getIds ( ) ) ;
browserBean . setReplaceDatas ( deptMaps ) ;
sequenceBrowserItem . setBrowserConditionParam ( browserBean ) ;
}
if ( null ! = jobPO . getSchemeId ( ) ) {
BrowserBean browserBean = schemeBrowserItem . getBrowserConditionParam ( ) ;
List < Map < String , Object > > deptMaps = getSchemeMapper ( ) . listSchemesByIds ( DeleteParam . builder ( ) . ids ( jobPO . getSchemeId ( ) . toString ( ) ) . build ( ) . getIds ( ) ) ;
browserBean . setReplaceDatas ( deptMaps ) ;
schemeBrowserItem . setBrowserConditionParam ( browserBean ) ;
}
if ( null ! = jobPO . getParentJob ( ) ) {
BrowserBean browserBean = parentJobBrowserItem . getBrowserConditionParam ( ) ;
List < Map < String , Object > > deptMaps = getJobMapper ( ) . listJobsByIds ( DeleteParam . builder ( ) . ids ( jobPO . getParentJob ( ) . toString ( ) ) . build ( ) . getIds ( ) ) ;
browserBean . setReplaceDatas ( deptMaps ) ;
parentJobBrowserItem . setBrowserConditionParam ( browserBean ) ;
}
// 查看,全部置为只读
if ( 1 = = viewAttr ) {
for ( SearchConditionItem item : conditionItems ) {
item . setViewAttr ( viewAttr ) ;
}
}
return conditionItems ;
}
/ * *
* 获 取 待 删 除 数 据 的 子 级 元 素
*