分部、岗位 禁用功能限制 #13

Merged
dxfeng merged 1 commits from feature/dxf into develop 3 years ago

@ -136,4 +136,6 @@ public interface DepartmentMapper {
int checkRepeatNo(@Param("departmentNo") String departmentNo, @Param("id") Long id);
List<String> hasSubs();
int countUsedInJob(@Param("departmentId") Long departmentId);
}

@ -184,6 +184,13 @@
where forbidden_tag = 0
and delete_type = 0
</select>
<select id="countUsedInJob" resultType="java.lang.Integer">
select count(1)
from jcl_org_job
where forbidden_tag = 0
and delete_type = 0
and parent_dept = #{departmentId}
</select>
<sql id="nullParentDepartment">
and ifnull(parent_dept,0) =
#{parentDepartment}

@ -184,4 +184,6 @@ public interface JobMapper {
* @return
*/
int updateJobCompany(@Param("ids") Collection<Long> ids, @Param("parentCompany") Long parentCompany, @Param("ecCompany") String ecCompany);
int isHasResource(@Param("jobId") Long jobId);
}

@ -573,6 +573,13 @@
AND parent_job = #{parentJob}
</if>
</select>
<select id="isHasResource" resultType="java.lang.Integer">
select count(a.id)
from jcl_org_hrmresource a
inner join jcl_org_job b on a.job_title = b.id
where a.status &lt; 4
and b.id = #{jobId}
</select>
<sql id="nullparentJob">
and ifnull(parent_job,0) =

@ -256,6 +256,13 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
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, "部门存在下级岗位,不能封存");
}
Map<String, Object> map = new HashMap<>();
map.put("id", departmentPO.getId());
map.put("forbiddenTag", departmentPO.getForbiddenTag());

@ -454,7 +454,23 @@ public class JobServiceImpl extends Service implements JobService {
@Override
public int updateForbiddenTagById(JobSearchParam params) {
HasRightUtil.hasRight(user, RIGHT_NAME, false);
JobPO jobPO = JobPO.builder().id(params.getId()).forbiddenTag(params.getForbiddenTag() ? 0 : 1).jobName(getJobMapper().getJobById(params.getId()).getJobName()).build();
JobPO jobById = getJobMapper().getJobById(params.getId());
JobPO jobPO = JobPO.builder().id(params.getId()).forbiddenTag(params.getForbiddenTag() ? 0 : 1).jobName(jobById.getJobName()).build();
if (params.getForbiddenTag()) {
// 启用:判断上级部门是否启用,上级部门启用,岗位才可启用
DepartmentPO parentDepartment = getDepartmentMapper().getDeptById(jobById.getParentDept());
OrganizationAssert.isTrue(0 == parentDepartment.getForbiddenTag(), "该岗位不能解封,请先解封上级部门");
// 启用:判断上级岗位是否启用,上级岗位启用,岗位才可启用
if (null != jobById.getParentJob()) {
JobPO parentJob = getJobMapper().getJobById(jobById.getParentJob());
OrganizationAssert.isTrue(0 == parentJob.getForbiddenTag(), "该岗位不能解封,请先解封上级岗位");
}
} else {
//禁用:判断当前岗位下是否有人员,如有人员则不能禁用
int hasResource = getJobMapper().isHasResource(params.getId());
OrganizationAssert.isTrue(hasResource == 0, "该岗位存在人员,不能封存");
}
new OrganizationSyncEc(user, LogModuleNameEnum.JOB, OperateTypeEnum.CANCELED, null, jobPO).sync();
return getJobMapper().updateForbiddenTagById(jobPO.getId(), jobPO.getForbiddenTag());
}

Loading…
Cancel
Save