@ -134,10 +134,10 @@ public class StaffServiceImpl extends Service implements StaffService {
public int saveStaff ( StaffParams param ) {
HasRightUtil . hasRight ( user , RIGHT_NAME , false ) ;
StaffPO staffPO = StaffBO . convertParamToPO ( param , ( long ) user . getUID ( ) ) ;
OrganizationAssert . isFalse ( staffPO . getStaffNum ( ) < 0 , SystemEnv . getHtmlLabelName ( 547449 , user . getLanguage ( ) ) ) ;
List < StaffPO > verify = getStaffMapper ( ) . customSelect ( param . getPlanId ( ) , param . getEcCompany ( ) , param . getEcDepartment ( ) , param . getJobId ( ) );
OrganizationAssert . isFalse ( staffPO . getStaffNum ( ) < 0 , SystemEnv . getHtmlLabelName ( 547449 , user . getLanguage ( ) ) ) ;
List < StaffPO > verify = getStaffMapper ( ) . customSelect ( param . getPlanId ( ) , param . getEcCompany ( ) , param . getEcDepartment ( ) , param . getJobId ( ) , param . getWorkRelation ( ) );
if ( ! verify . isEmpty ( ) ) {
throw new OrganizationRunTimeException ( SystemEnv . getHtmlLabelName ( 547450 , user . getLanguage ( ) ) ) ;
throw new OrganizationRunTimeException ( SystemEnv . getHtmlLabelName ( 547450 , user . getLanguage ( ) ) ) ;
}
checkRequired ( staffPO ) ;
int ignoreNull = getStaffMapper ( ) . insertIgnoreNull ( staffPO ) ;
@ -149,7 +149,7 @@ public class StaffServiceImpl extends Service implements StaffService {
@Override
public int updateStaff ( StaffParams param ) {
HasRightUtil . hasRight ( user , RIGHT_NAME , false ) ;
List < StaffPO > verify = getStaffMapper ( ) . customSelect ( param . getPlanId ( ) , param . getEcCompany ( ) , param . getEcDepartment ( ) , param . getJobId ( ) );
List < StaffPO > verify = getStaffMapper ( ) . customSelect ( param . getPlanId ( ) , param . getEcCompany ( ) , param . getEcDepartment ( ) , param . getJobId ( ) , param . getWorkRelation ( ) );
if ( verify . size ( ) > 1 ) {
throw new OrganizationRunTimeException ( SystemEnv . getHtmlLabelName ( 547451 , user . getLanguage ( ) ) ) ;
}
@ -172,13 +172,17 @@ public class StaffServiceImpl extends Service implements StaffService {
// 更新编制表
staffPO . setStaffNum ( staffPO . getStaffNum ( ) + changeNum ) ;
}
OrganizationAssert . isFalse ( staffPO . getStaffNum ( ) < 0 , SystemEnv . getHtmlLabelName ( 547452 , user . getLanguage ( ) ) ) ;
OrganizationAssert . isFalse ( staffPO . getStaffNum ( ) < 0 , SystemEnv . getHtmlLabelName ( 547452 , user . getLanguage ( ) ) ) ;
StaffBO . buildStaffDesc ( staffPO ) ;
if ( staffPO . getControlPolicy ( ) . equals ( HARDCONTROLLER ) & & staffPO . getStaffNum ( ) < ( staffPO . getPermanentNum ( ) + staffPO . getFreezeNum ( ) ) ) {
throw new OrganizationRunTimeException ( SystemEnv . getHtmlLabelName ( 547453 , user . getLanguage ( ) ) ) ;
if ( staffPO . getControlPolicy ( ) . equals ( HARDCONTROLLER ) & & staffPO . getStaffNum ( ) < ( staffPO . getPermanentNum ( ) + staffPO . getFreezeNum ( ) ) ) {
throw new OrganizationRunTimeException ( SystemEnv . getHtmlLabelName ( 547453 , user . getLanguage ( ) ) ) ;
}
// 更新主表
int updateStaff = getStaffMapper ( ) . updateStaff ( staffPO ) ;
// 初始化编制在编数
initStaffInfo ( staffPO ) ;
return updateStaff ;
}
@ -186,7 +190,7 @@ public class StaffServiceImpl extends Service implements StaffService {
@Override
public int deleteByIds ( Collection < Long > ids ) {
HasRightUtil . hasRight ( user , RIGHT_NAME , false ) ;
OrganizationAssert . notEmpty ( ids , SystemEnv . getHtmlLabelName ( 547138 , user . getLanguage ( ) ) ) ;
OrganizationAssert . notEmpty ( ids , SystemEnv . getHtmlLabelName ( 547138 , user . getLanguage ( ) ) ) ;
return getStaffMapper ( ) . deleteByIds ( ids ) ;
}
@ -211,13 +215,18 @@ public class StaffServiceImpl extends Service implements StaffService {
SearchConditionItem freezeNumItem = OrganizationFormItemUtil . inputNumberItem ( user , 2 , 16 , 2 , 547347 , "freezeNum" ) ;
// 缺编状态
List < SearchConditionOption > selectOptions = new ArrayList < > ( ) ;
SearchConditionOption lackOption = new SearchConditionOption ( "1" , SystemEnv . getHtmlLabelName ( 547351 , user . getLanguage ( ) ) ) ;
SearchConditionOption fullOption = new SearchConditionOption ( "2" , SystemEnv . getHtmlLabelName ( 547350 , user . getLanguage ( ) ) ) ;
SearchConditionOption overOption = new SearchConditionOption ( "3" , SystemEnv . getHtmlLabelName ( 547352 , user . getLanguage ( ) ) ) ;
SearchConditionOption lackOption = new SearchConditionOption ( "1" , SystemEnv . getHtmlLabelName ( 547351 , user . getLanguage ( ) ) ) ;
SearchConditionOption fullOption = new SearchConditionOption ( "2" , SystemEnv . getHtmlLabelName ( 547350 , user . getLanguage ( ) ) ) ;
SearchConditionOption overOption = new SearchConditionOption ( "3" , SystemEnv . getHtmlLabelName ( 547352 , user . getLanguage ( ) ) ) ;
selectOptions . add ( lackOption ) ;
selectOptions . add ( fullOption ) ;
selectOptions . add ( overOption ) ;
SearchConditionItem lackStatusItem = OrganizationFormItemUtil . selectItem ( user , selectOptions , 2 , 16 , 6 , false , 547348 , "lackStatus" ) ;
//自定义字段 用工关系
List < SearchConditionOption > workRelationSelectOptions = getWorkRelationSelectOptions ( ) ;
SearchConditionItem workRelationItem = OrganizationFormItemUtil . selectItem ( user , workRelationSelectOptions , 2 , 16 , 6 , false , - 85075 , "workRelation" ) ;
// 编制描述
SearchConditionItem staffDescItem = OrganizationFormItemUtil . inputItem ( user , 2 , 16 , 2 , 50 , 547349 , "staffDesc" ) ;
// 说明
@ -225,7 +234,8 @@ public class StaffServiceImpl extends Service implements StaffService {
conditionItems . add ( compIdItem ) ;
conditionItems . add ( deptIdItem ) ;
conditionItems . add ( jobIdItem ) ;
// conditionItems.add(jobIdItem);
conditionItems . add ( workRelationItem ) ;
conditionItems . add ( staffNumItem ) ;
conditionItems . add ( permanentNumItem ) ;
conditionItems . add ( freezeNumItem ) ;
@ -253,6 +263,15 @@ public class StaffServiceImpl extends Service implements StaffService {
SearchConditionItem ecCompanyItem = OrganizationFormItemUtil . browserItem ( user , 2 , 16 , 2 , false , 547332 , "164" , "ecCompany" , "compBrowser" ) ;
// 部门
SearchConditionItem ecDepartmentItem = OrganizationFormItemUtil . browserItem ( user , 2 , 16 , 2 , false , 547331 , "4" , "ecDepartment" , "deptBrowser" ) ;
//自定义字段 用工关系
List < SearchConditionOption > workRelationSelectOptions = getWorkRelationSelectOptions ( ) ;
SearchConditionItem workRelationItem = OrganizationFormItemUtil . selectItem ( user , workRelationSelectOptions , 2 , 16 , 6 , false , - 85075 , "workRelation" ) ;
workRelationItem . setViewAttr ( 2 ) ;
workRelationItem . setValue ( "" ) ;
workRelationItem . setRules ( "required|string" ) ;
// 岗位
SearchConditionItem jobIdItem = OrganizationFormItemUtil . browserItem ( user , 2 , 16 , 2 , false , 547333 , "666" , "jobId" , "" ) ;
BrowserBean browserBean = jobIdItem . getBrowserConditionParam ( ) ;
@ -268,9 +287,9 @@ public class StaffServiceImpl extends Service implements StaffService {
staffNumItem . setMin ( "0" ) ;
// 控制策略
List < SearchConditionOption > selectOptions = new ArrayList < > ( ) ;
SearchConditionOption option1 = new SearchConditionOption ( "1" , SystemEnv . getHtmlLabelName ( 547454 , user . getLanguage ( ) ) ) ;
SearchConditionOption option2 = new SearchConditionOption ( "2" , SystemEnv . getHtmlLabelName ( 547455 , user . getLanguage ( ) ) ) ;
SearchConditionOption option3 = new SearchConditionOption ( "3" , SystemEnv . getHtmlLabelName ( 547456 , user . getLanguage ( ) ) ) ;
SearchConditionOption option1 = new SearchConditionOption ( "1" , SystemEnv . getHtmlLabelName ( 547454 , user . getLanguage ( ) ) ) ;
SearchConditionOption option2 = new SearchConditionOption ( "2" , SystemEnv . getHtmlLabelName ( 547455 , user . getLanguage ( ) ) ) ;
SearchConditionOption option3 = new SearchConditionOption ( "3" , SystemEnv . getHtmlLabelName ( 547456 , user . getLanguage ( ) ) ) ;
selectOptions . add ( option1 ) ;
selectOptions . add ( option2 ) ;
selectOptions . add ( option3 ) ;
@ -285,8 +304,8 @@ public class StaffServiceImpl extends Service implements StaffService {
String id = Util . null2String ( params . get ( "id" ) ) ;
if ( ! StringUtil . isEmpty ( id ) ) {
StaffPO staffPO = getStaffMapper ( ) . getStaffByID ( Integer . parseInt ( id ) ) ;
OrganizationAssert . notNull ( staffPO , SystemEnv . getHtmlLabelName ( 547154 , user . getLanguage ( ) ) ) ;
staffPlanPO = getStaffPlanMapper ( ) . getStaffPlanByID ( staffPO . getPlanId ( ) ) ;
OrganizationAssert . notNull ( staffPO , SystemEnv . getHtmlLabelName ( 547154 , user . getLanguage ( ) ) ) ;
staffPlanPO = getStaffPlanMapper ( ) . getStaffPlanByID ( staffPO . getPlanId ( ) ) ;
BrowserBean planIdItemBean = planIdItem . getBrowserConditionParam ( ) ;
List < Map < String , Object > > planIdMaps = getStaffPlanMapper ( ) . listPlansByIds ( DeleteParam . builder ( ) . ids ( staffPO . getPlanId ( ) . toString ( ) ) . build ( ) . getIds ( ) ) ;
@ -310,6 +329,7 @@ public class StaffServiceImpl extends Service implements StaffService {
staffNumItem . setValue ( staffPO . getStaffNum ( ) ) ;
controlPolicyItem . setValue ( Util . null2String ( staffPO . getControlPolicy ( ) ) ) ;
workRelationItem . setValue ( Util . null2String ( staffPO . getWorkRelation ( ) ) ) ;
descriptionItem . setValue ( staffPO . getDescription ( ) ) ;
}
selectItems . add ( planIdItem ) ;
@ -322,7 +342,7 @@ public class StaffServiceImpl extends Service implements StaffService {
if ( StringUtil . isEmpty ( id ) | | "3" . equals ( staffPlanPO . getControlDimension ( ) ) ) {
selectItems . add ( jobIdItem ) ;
}
selectItems . add ( workRelationItem ) ;
selectItems . add ( staffNumItem ) ;
selectItems . add ( controlPolicyItem ) ;
selectItems . add ( descriptionItem ) ;
@ -333,7 +353,7 @@ public class StaffServiceImpl extends Service implements StaffService {
item . setRules ( null ) ;
} ) ;
SearchConditionItem changeNumItem = OrganizationFormItemUtil . inputNumberItem ( user , 2 , 16 , 3 , 547357 , "changeNum" ) ;
changeNumItem . setHelpfulTip ( SystemEnv . getHtmlLabelName ( 547359 , user . getLanguage ( ) ) ) ;
changeNumItem . setHelpfulTip ( SystemEnv . getHtmlLabelName ( 547359 , user . getLanguage ( ) ) ) ;
staffNumItem . setRules ( "required" ) ;
selectItems . add ( changeNumItem ) ;
SearchConditionItem changeDescriptionItem = OrganizationFormItemUtil . textareaItem ( user , 2 , 16 , false , 2 , 50 , 547358 , "changeDescription" ) ;
@ -341,7 +361,7 @@ public class StaffServiceImpl extends Service implements StaffService {
}
addGroups . add ( new SearchConditionGroup ( SystemEnv . getHtmlLabelName ( 547175 , user . getLanguage ( ) ) , true , selectItems ) ) ;
addGroups . add ( new SearchConditionGroup ( SystemEnv . getHtmlLabelName ( 547175 , user . getLanguage ( ) ) , true , selectItems ) ) ;
apiDatas . put ( "condition" , addGroups ) ;
return apiDatas ;
}
@ -349,15 +369,15 @@ public class StaffServiceImpl extends Service implements StaffService {
@Override
public Map < String , Object > getHasRight ( ) {
Map < String , List < MenuBtn > > datas = MenuBtn . getCommonBtnDatas ( user . getLanguage ( ) ) ;
datas . get ( "topMenu" ) . add ( MenuBtn . builder ( ) . isBatch ( "1" ) . isTop ( "1" ) . menuFun ( "import" ) . menuIcon ( "icon-coms-leading-in" ) . menuName ( SystemEnv . getHtmlLabelName ( 547242 , user . getLanguage ( ) ) ) . type ( "BTN_BatchImport" ) . build ( ) ) ;
datas . get ( "rightMenu" ) . add ( MenuBtn . builder ( ) . isBatch ( "1" ) . isTop ( "0" ) . menuFun ( "import" ) . menuIcon ( "icon-coms-leading-in" ) . menuName ( SystemEnv . getHtmlLabelName ( 547242 , user . getLanguage ( ) ) ) . type ( "BTN_BatchImport" ) . build ( ) ) ;
datas . get ( "topMenu" ) . add ( MenuBtn . builder ( ) . isBatch ( "1" ) . isTop ( "1" ) . menuFun ( "import" ) . menuIcon ( "icon-coms-leading-in" ) . menuName ( SystemEnv . getHtmlLabelName ( 547242 , user . getLanguage ( ) ) ) . type ( "BTN_BatchImport" ) . build ( ) ) ;
datas . get ( "rightMenu" ) . add ( MenuBtn . builder ( ) . isBatch ( "1" ) . isTop ( "0" ) . menuFun ( "import" ) . menuIcon ( "icon-coms-leading-in" ) . menuName ( SystemEnv . getHtmlLabelName ( 547242 , user . getLanguage ( ) ) ) . type ( "BTN_BatchImport" ) . build ( ) ) ;
Map < String , Object > map = new HashMap < > ( datas ) ;
List < SearchConditionGroup > addGroups = new ArrayList < > ( ) ;
List < SearchConditionItem > selectItems = new ArrayList < > ( ) ;
// 方案
SearchConditionItem planIdItem = OrganizationFormItemUtil . browserItem ( user , 4 , 6 , 2 , false , 547459 , "162" , "planId" , "staffPlanBrowser" ) ;
planIdItem . setRules ( "required|string" ) ;
planIdItem . setHelpfulTip ( SystemEnv . getHtmlLabelName ( 547343 , user . getLanguage ( ) ) ) ;
planIdItem . setHelpfulTip ( SystemEnv . getHtmlLabelName ( 547343 , user . getLanguage ( ) ) ) ;
planIdItem . setLabelcol ( 2 ) ;
selectItems . add ( planIdItem ) ;
@ -422,6 +442,10 @@ public class StaffServiceImpl extends Service implements StaffService {
if ( null ! = lackStatus ) {
sqlWhere + = " AND t.lack_status = '" + lackStatus + "'" ;
}
Integer workRelation = param . getWorkRelation ( ) ;
if ( null ! = workRelation & & ! ( - 1 = = workRelation ) ) {
sqlWhere + = " AND t.work_relation = '" + workRelation + "'" ;
}
String staffDesc = param . getStaffDesc ( ) ;
if ( StringUtils . isNotBlank ( staffDesc ) ) {
sqlWhere + = " AND t.staff_desc " + dbType . like ( staffDesc ) ;
@ -448,11 +472,11 @@ public class StaffServiceImpl extends Service implements StaffService {
StaffPlanPO staffPlanByID = getStaffPlanMapper ( ) . getStaffPlanByID ( staffPO . getPlanId ( ) ) ;
switch ( staffPlanByID . getControlDimension ( ) ) {
case "1" : // 分部
OrganizationAssert . notNull ( staffPO . getEcCompany ( ) , SystemEnv . getHtmlLabelName ( 547461 , user . getLanguage ( ) ) ) ;
OrganizationAssert . notNull ( staffPO . getEcCompany ( ) , SystemEnv . getHtmlLabelName ( 547461 , user . getLanguage ( ) ) ) ;
staffPO . setCompId ( staffPO . getEcCompany ( ) ) ;
break ;
case "2" : // 部门
OrganizationAssert . notNull ( staffPO . getEcDepartment ( ) , SystemEnv . getHtmlLabelName ( 547460 , user . getLanguage ( ) ) ) ;
OrganizationAssert . notNull ( staffPO . getEcDepartment ( ) , SystemEnv . getHtmlLabelName ( 547460 , user . getLanguage ( ) ) ) ;
DepartmentPO jclDepartmentId = getDepartmentMapper ( ) . getDeptById ( staffPO . getEcDepartment ( ) ) ;
if ( null ! = jclDepartmentId ) {
staffPO . setDeptId ( jclDepartmentId . getId ( ) ) ;
@ -461,7 +485,7 @@ public class StaffServiceImpl extends Service implements StaffService {
}
break ;
case "3" : // 岗位
OrganizationAssert . notNull ( staffPO . getJobId ( ) , SystemEnv . getHtmlLabelName ( 547462 , user . getLanguage ( ) ) ) ;
OrganizationAssert . notNull ( staffPO . getJobId ( ) , SystemEnv . getHtmlLabelName ( 547462 , user . getLanguage ( ) ) ) ;
JobPO jobById = getJobMapper ( ) . getJobById ( Long . valueOf ( staffPO . getJobId ( ) ) ) ;
if ( null ! = jobById ) {
staffPO . setDeptId ( jobById . getEcDepartment ( ) ) ;
@ -483,8 +507,16 @@ public class StaffServiceImpl extends Service implements StaffService {
public static void initStaffInfo ( StaffPO staffPO ) {
boolean hasDepartment = null ! = staffPO . getEcDepartment ( ) & & 0 ! = staffPO . getEcDepartment ( ) ;
boolean hasJob = null ! = staffPO . getJobId ( ) & & 0 ! = staffPO . getJobId ( ) ;
boolean hasWorkRelation = null ! = staffPO . getWorkRelation ( ) & & - 1 ! = staffPO . getWorkRelation ( ) ;
RecordSet rs = new RecordSet ( ) ;
String sql = "select count(1) as num from hrmresource where STATUS < 4" ;
if ( hasWorkRelation ) {
int workRelation = staffPO . getWorkRelation ( ) ;
sql = "select count(1) as num from hrmresource a left join cus_fielddata b on a.id = b.id where status < 4 and b.scope = 'HrmCustomFieldByInfoType' and b.scopeid = 3 " ;
sql + = " and field10 = " + workRelation ;
}
if ( null ! = staffPO . getEcCompany ( ) & & 0 ! = staffPO . getEcCompany ( ) ) {
ArrayList < String > subCompanyList = new ArrayList < > ( ) ;
subCompanyList . add ( staffPO . getEcCompany ( ) . toString ( ) ) ;
@ -510,7 +542,8 @@ public class StaffServiceImpl extends Service implements StaffService {
sql + = " and jobtitle = " + ecJobTitle ;
}
if ( "false" . equals ( new BaseBean ( ) . getPropValue ( "hrmOrganization" , "accountType" ) ) ) {
if ( "false" . equals ( new BaseBean ( ) . getPropValue ( "hrmOrganization" , "accountType" ) ) ) {
sql + = " and accounttype != 1" ;
}
@ -523,4 +556,28 @@ public class StaffServiceImpl extends Service implements StaffService {
}
/ * *
* 获 取 获 取 用 工 关 系 下 拉 选 项 值
*
* @return
* /
private List < SearchConditionOption > getWorkRelationSelectOptions ( ) {
RecordSet rs = new RecordSet ( ) ;
List < SearchConditionOption > workRelationSelectOptions = new ArrayList < > ( ) ;
SearchConditionOption option = new SearchConditionOption ( "-1" , "不限" ) ;
workRelationSelectOptions . add ( option ) ;
//用工关系sql select selectvalue,selectname from cus_selectitem where fieldid = 33
String sql = "select selectvalue,selectname from cus_selectitem where fieldid = 10" ;
rs . execute ( sql ) ;
while ( rs . next ( ) ) {
String selectvalue = Util . null2String ( rs . getString ( "selectvalue" ) ) ;
String selectname = Util . null2String ( rs . getString ( "selectname" ) ) ;
SearchConditionOption option1 = new SearchConditionOption ( selectvalue , selectname ) ;
workRelationSelectOptions . add ( option1 ) ;
}
return workRelationSelectOptions ;
}
}