@ -2,6 +2,7 @@ package com.engine.organization.service.impl;
import com.engine.organization.entity.staff.param.StaffOutParam ;
import com.engine.organization.entity.staff.param.StaffOutParam ;
import com.engine.organization.entity.staff.po.StaffPO ;
import com.engine.organization.entity.staff.po.StaffPO ;
import com.engine.organization.enums.ModuleTypeEnum ;
import com.engine.organization.enums.StaffChangeEnum ;
import com.engine.organization.enums.StaffChangeEnum ;
import com.engine.organization.exception.OrganizationRunTimeException ;
import com.engine.organization.exception.OrganizationRunTimeException ;
import com.engine.organization.mapper.staff.StaffMapper ;
import com.engine.organization.mapper.staff.StaffMapper ;
@ -86,17 +87,17 @@ public class FunctionOutStaffServiceImpl {
private Integer entryAdd ( StaffOutParam param ) {
private Integer entryAdd ( StaffOutParam param ) {
StaffPO staffPO = select ( param ) ;
StaffPO staffPO = select ( param ) ;
Integer sums = staffPO . getPermanentNum ( ) + staffPO . getFreezeNum ( ) ;
//强控策略下不容许超编
if ( staffPO . getControlPolicy ( ) . equals ( HARDCONTROLLER ) ) {
OrganizationAssert . isFalse ( sums . compareTo ( staffPO . getStaffNum ( ) ) > 0 , "强控策略下不容许超编" ) ;
}
List < Integer > numbers = Arrays . asList ( staffPO . getPermanentNum ( ) , param . getNum ( ) ) ;
List < Integer > numbers = Arrays . asList ( staffPO . getPermanentNum ( ) , param . getNum ( ) ) ;
//1.增加在编数
//1.增加在编数
int sum = numbers . stream ( )
int sum = numbers . stream ( )
. mapToInt ( Integer : : intValue )
. mapToInt ( Integer : : intValue )
. sum ( ) ;
. sum ( ) ;
staffPO . setPermanentNum ( sum ) ;
staffPO . setPermanentNum ( sum ) ;
Integer sums = staffPO . getPermanentNum ( ) + staffPO . getFreezeNum ( ) ;
//强控策略下不容许超编
if ( staffPO . getControlPolicy ( ) . equals ( HARDCONTROLLER ) ) {
OrganizationAssert . isFalse ( sums . compareTo ( staffPO . getStaffNum ( ) ) > 0 , "强控策略下不容许超编" ) ;
}
//向上部门 分部在编数调整
//向上部门 分部在编数调整
upwardReviewSums ( param ) ;
upwardReviewSums ( param ) ;
//2.调整方式为流程时释放冻结数
//2.调整方式为流程时释放冻结数
@ -152,10 +153,18 @@ public class FunctionOutStaffServiceImpl {
//1.分部
//1.分部
if ( param . getCompany ( ) ! = null ) {
if ( param . getCompany ( ) ! = null ) {
String allSupCompany = subCompanyComInfo . getAllSupCompany ( String . valueOf ( param . getCompany ( ) ) ) ;
String allSupCompany = subCompanyComInfo . getAllSupCompany ( String . valueOf ( param . getCompany ( ) ) ) ;
Collection < Integer > subCompanys = new ArrayList < > ( ) ;
if ( param . getDimension ( ) . equals ( ModuleTypeEnum . departmentfielddefined . getValue ( ) ) | | param . getDimension ( ) . equals ( ModuleTypeEnum . jobfielddefined . getValue ( ) ) ) {
subCompanys . add ( param . getCompany ( ) ) ;
}
if ( ! "" . equals ( allSupCompany ) ) {
if ( ! "" . equals ( allSupCompany ) ) {
Collection < Integer > subCompanys = Arrays . stream ( allSupCompany . split ( "," ) )
Collection < Integer > sub = Arrays . stream ( allSupCompany . split ( "," ) )
. map ( Integer : : parseInt )
. map ( Integer : : parseInt )
. collect ( Collectors . toList ( ) ) ;
. collect ( Collectors . toList ( ) ) ;
subCompanys . addAll ( sub ) ;
}
List < StaffPO > staffPOS = staffMapper ( ) . selectByEcCompany ( subCompanys ) ;
List < StaffPO > staffPOS = staffMapper ( ) . selectByEcCompany ( subCompanys ) ;
if ( ! CollectionUtils . isEmpty ( staffPOS ) ) {
if ( ! CollectionUtils . isEmpty ( staffPOS ) ) {
staffPOS . forEach ( item - > {
staffPOS . forEach ( item - > {
@ -164,19 +173,27 @@ public class FunctionOutStaffServiceImpl {
} else {
} else {
item . setPermanentNum ( item . getPermanentNum ( ) - param . getNum ( ) ) ;
item . setPermanentNum ( item . getPermanentNum ( ) - param . getNum ( ) ) ;
}
}
buildStaffPO ( item ) ;
staffMapper ( ) . updateStaff ( item ) ;
staffMapper ( ) . updateStaff ( item ) ;
} ) ;
} ) ;
}
}
}
}
}
//2.部门
//2.部门
if ( param . getDepartment ( ) ! = null ) {
if ( param . getDepartment ( ) ! = null ) {
String allSupDepartment = departmentComInfo . getAllSupDepartment ( String . valueOf ( param . getDepartment ( ) ) ) ;
String allSupDepartment = departmentComInfo . getAllSupDepartment ( String . valueOf ( param . getDepartment ( ) ) ) ;
Collection < Integer > subDepartments = new ArrayList < > ( ) ;
if ( param . getDimension ( ) . equals ( ModuleTypeEnum . jobfielddefined . getValue ( ) ) ) {
subDepartments . add ( param . getDepartment ( ) ) ;
}
if ( ! "" . equals ( allSupDepartment ) ) {
if ( ! "" . equals ( allSupDepartment ) ) {
Collection < Integer > subDepartments = Arrays . stream ( allSupDepartment . split ( "," ) )
Collection < Integer > sub = Arrays . stream ( allSupDepartment . split ( "," ) )
. map ( Integer : : parseInt )
. map ( Integer : : parseInt )
. collect ( Collectors . toList ( ) ) ;
. collect ( Collectors . toList ( ) ) ;
subDepartments . addAll ( sub ) ;
}
List < StaffPO > staffPOS = staffMapper ( ) . selectByEcDepartment ( subDepartments ) ;
List < StaffPO > staffPOS = staffMapper ( ) . selectByEcDepartment ( subDepartments ) ;
if ( ! CollectionUtils . isEmpty ( staffPOS ) ) {
if ( ! CollectionUtils . isEmpty ( staffPOS ) ) {
staffPOS . forEach ( item - > {
staffPOS . forEach ( item - > {
@ -185,17 +202,17 @@ public class FunctionOutStaffServiceImpl {
} else {
} else {
item . setPermanentNum ( item . getPermanentNum ( ) - param . getNum ( ) ) ;
item . setPermanentNum ( item . getPermanentNum ( ) - param . getNum ( ) ) ;
}
}
buildStaffPO ( item ) ;
staffMapper ( ) . updateStaff ( item ) ;
staffMapper ( ) . updateStaff ( item ) ;
} ) ;
} ) ;
}
}
}
}
}
}
}
private StaffPO select ( StaffOutParam param ) {
private StaffPO select ( StaffOutParam param ) {
List < StaffPO > staffPO = staffMapper ( ) . customSelect ( param . getPlanId ( ) , param . getCompany ( ) , param . getDepartment ( ) , param . getJob ( ) ) ;
List < StaffPO > staffPO = staffMapper ( ) . customSelect ( param . getPlanId ( ) , param . getCompany ( ) , param . getDepartment ( ) , param . getJob ( ) ) ;
OrganizationAssert . notNull ( staffPO , "未查询到对应编制方案下的组织编制信息!" ) ;
OrganizationAssert . isEmpty ( staffPO , "未查询到对应编制方案下的组织编制信息!" ) ;
return staffPO . get ( 0 ) ;
return staffPO . get ( 0 ) ;
}
}