|
|
@ -348,12 +348,12 @@ public class JobServiceImpl extends Service implements JobService {
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public Long saveBaseForm(Map<String, Object> params) {
|
|
|
|
public Long saveBaseForm(Map<String, Object> params) {
|
|
|
|
HasRightUtil.hasRight(user, RIGHT_NAME, false);
|
|
|
|
HasRightUtil.hasRight(user, RIGHT_NAME, false);
|
|
|
|
|
|
|
|
JobSearchParam searchParam = JSONObject.parseObject(JSONObject.toJSONString(params), JobSearchParam.class);
|
|
|
|
|
|
|
|
assertNameRepeat(null, searchParam.getEcDepartment(), searchParam.getParentJob(), searchParam.getJobName());
|
|
|
|
String jobNo = (String) params.get("job_no");
|
|
|
|
String jobNo = (String) params.get("job_no");
|
|
|
|
// 判断是否开启自动编号
|
|
|
|
// 判断是否开启自动编号
|
|
|
|
jobNo = repeatDetermine(jobNo);
|
|
|
|
jobNo = repeatDetermine(jobNo);
|
|
|
|
params.put("job_no", jobNo);
|
|
|
|
params.put("job_no", jobNo);
|
|
|
|
JobSearchParam searchParam = JSONObject.parseObject(JSONObject.toJSONString(params), JobSearchParam.class);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
params.put("is_key", null == searchParam.getIsKey() ? 0 : searchParam.getIsKey());
|
|
|
|
params.put("is_key", null == searchParam.getIsKey() ? 0 : searchParam.getIsKey());
|
|
|
|
Long ecDepartment = searchParam.getEcDepartment();
|
|
|
|
Long ecDepartment = searchParam.getEcDepartment();
|
|
|
|
DepartmentPO jclDepartment = EcHrmRelationUtil.getJclDepartmentId(Util.null2String(ecDepartment));
|
|
|
|
DepartmentPO jclDepartment = EcHrmRelationUtil.getJclDepartmentId(Util.null2String(ecDepartment));
|
|
|
@ -379,8 +379,14 @@ public class JobServiceImpl extends Service implements JobService {
|
|
|
|
public Long updateForm(Map<String, Object> params) {
|
|
|
|
public Long updateForm(Map<String, Object> params) {
|
|
|
|
HasRightUtil.hasRight(user, RIGHT_NAME, false);
|
|
|
|
HasRightUtil.hasRight(user, RIGHT_NAME, false);
|
|
|
|
JobSearchParam searchParam = JSONObject.parseObject(JSONObject.toJSONString(params), JobSearchParam.class);
|
|
|
|
JobSearchParam searchParam = JSONObject.parseObject(JSONObject.toJSONString(params), JobSearchParam.class);
|
|
|
|
|
|
|
|
assertNameRepeat(searchParam.getId(), searchParam.getEcDepartment(), searchParam.getParentJob(), searchParam.getJobName());
|
|
|
|
String groupId = (String) params.get("viewCondition");
|
|
|
|
String groupId = (String) params.get("viewCondition");
|
|
|
|
searchParam.setIsKey(null == searchParam.getIsKey() ? 0 : searchParam.getIsKey());
|
|
|
|
searchParam.setIsKey(null == searchParam.getIsKey() ? 0 : searchParam.getIsKey());
|
|
|
|
|
|
|
|
// 上级岗位不能选择本身
|
|
|
|
|
|
|
|
String parent_job = Util.null2String(params.get("parent_job"));
|
|
|
|
|
|
|
|
if (StringUtils.isNotBlank(parent_job)) {
|
|
|
|
|
|
|
|
OrganizationAssert.isFalse(parent_job.equals(searchParam.getId().toString()), "上级岗位不能选择本身");
|
|
|
|
|
|
|
|
}
|
|
|
|
if ("0".equals(groupId)) {
|
|
|
|
if ("0".equals(groupId)) {
|
|
|
|
groupId = GROUP_ID.toString();
|
|
|
|
groupId = GROUP_ID.toString();
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -436,6 +442,7 @@ public class JobServiceImpl extends Service implements JobService {
|
|
|
|
// 清空上级岗位
|
|
|
|
// 清空上级岗位
|
|
|
|
jobById.setParentJob(null);
|
|
|
|
jobById.setParentJob(null);
|
|
|
|
jobById.setShowOrder(orderNum);
|
|
|
|
jobById.setShowOrder(orderNum);
|
|
|
|
|
|
|
|
assertNameRepeat(null, jobById.getEcDepartment(), jobById.getParentJob(), jobById.getJobName());
|
|
|
|
insertCount += getJobMapper().insertIgnoreNull(jobById);
|
|
|
|
insertCount += getJobMapper().insertIgnoreNull(jobById);
|
|
|
|
// 更新组织架构图
|
|
|
|
// 更新组织架构图
|
|
|
|
new Thread(new JobTriggerRunnable(jobById.getId())).start();
|
|
|
|
new Thread(new JobTriggerRunnable(jobById.getId())).start();
|
|
|
@ -472,14 +479,14 @@ public class JobServiceImpl extends Service implements JobService {
|
|
|
|
OrganizationWeaTable<EmployeeTableVO> table = new OrganizationWeaTable<>(user, EmployeeTableVO.class);
|
|
|
|
OrganizationWeaTable<EmployeeTableVO> table = new OrganizationWeaTable<>(user, EmployeeTableVO.class);
|
|
|
|
RecordSet rs = new RecordSet();
|
|
|
|
RecordSet rs = new RecordSet();
|
|
|
|
List<String> ids = new ArrayList<>();
|
|
|
|
List<String> ids = new ArrayList<>();
|
|
|
|
rs.executeQuery("select id from cus_fielddata where field100002 = ?",jobId);
|
|
|
|
rs.executeQuery("select id from cus_fielddata where field100002 = ?", jobId);
|
|
|
|
while (rs.next()) {
|
|
|
|
while (rs.next()) {
|
|
|
|
ids.add(Util.null2String(rs.getString("id")));
|
|
|
|
ids.add(Util.null2String(rs.getString("id")));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (CollectionUtils.isEmpty(ids)){
|
|
|
|
if (CollectionUtils.isEmpty(ids)) {
|
|
|
|
ids.add("-1");
|
|
|
|
ids.add("-1");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
table.setSqlwhere(" where id in ("+StringUtils.join(ids,",")+") and status<4");
|
|
|
|
table.setSqlwhere(" where id in (" + StringUtils.join(ids, ",") + ") and status<4");
|
|
|
|
WeaResultMsg result = new WeaResultMsg(false);
|
|
|
|
WeaResultMsg result = new WeaResultMsg(false);
|
|
|
|
result.putAll(table.makeDataResult());
|
|
|
|
result.putAll(table.makeDataResult());
|
|
|
|
result.success();
|
|
|
|
result.success();
|
|
|
@ -533,6 +540,7 @@ public class JobServiceImpl extends Service implements JobService {
|
|
|
|
|
|
|
|
|
|
|
|
// 待合并的部门
|
|
|
|
// 待合并的部门
|
|
|
|
JobPO jobById = getJobMapper().getJobById(mergeParam.getId());
|
|
|
|
JobPO jobById = getJobMapper().getJobById(mergeParam.getId());
|
|
|
|
|
|
|
|
assertNameRepeat(targetJob.getId(), targetJob.getEcDepartment(), targetJob.getParentJob(), mergeParam.getMergeName());
|
|
|
|
|
|
|
|
|
|
|
|
// 递归处理子岗位所属分部、所部部门、上级岗位
|
|
|
|
// 递归处理子岗位所属分部、所部部门、上级岗位
|
|
|
|
recursionMergeJob(jobs, targetJob.getParentComp(), targetJob.getEcCompany(), targetJob.getParentDept(), targetJob.getEcDepartment(), targetJob.getId());
|
|
|
|
recursionMergeJob(jobs, targetJob.getParentComp(), targetJob.getEcCompany(), targetJob.getParentDept(), targetJob.getEcDepartment(), targetJob.getId());
|
|
|
@ -548,7 +556,7 @@ public class JobServiceImpl extends Service implements JobService {
|
|
|
|
// 更新人员组织架构图
|
|
|
|
// 更新人员组织架构图
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// 更新合并后的岗位,更新组织架构图
|
|
|
|
// 更新合并后的岗位,更新组织架构图
|
|
|
|
updateEcJob(targetJob,mergeParam.getMergeName());
|
|
|
|
updateEcJob(targetJob, mergeParam.getMergeName());
|
|
|
|
|
|
|
|
|
|
|
|
targetJob.setJobName(mergeParam.getMergeName());
|
|
|
|
targetJob.setJobName(mergeParam.getMergeName());
|
|
|
|
getJobMapper().updateBaseJob(targetJob);
|
|
|
|
getJobMapper().updateBaseJob(targetJob);
|
|
|
@ -782,9 +790,10 @@ public class JobServiceImpl extends Service implements JobService {
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 更新EC岗位
|
|
|
|
* 更新EC岗位
|
|
|
|
|
|
|
|
*
|
|
|
|
* @param jobPO
|
|
|
|
* @param jobPO
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
private void updateEcJob(JobPO jobPO,String newName){
|
|
|
|
private void updateEcJob(JobPO jobPO, String newName) {
|
|
|
|
Map<String, Object> params = new HashMap<>();
|
|
|
|
Map<String, Object> params = new HashMap<>();
|
|
|
|
params.put("job_name", newName);
|
|
|
|
params.put("job_name", newName);
|
|
|
|
params.put("jobactivityid", JOB_ACTIVITY_ID);
|
|
|
|
params.put("jobactivityid", JOB_ACTIVITY_ID);
|
|
|
@ -795,4 +804,43 @@ public class JobServiceImpl extends Service implements JobService {
|
|
|
|
new OrganizationSyncEc(user, LogModuleNameEnum.JOB, OperateTypeEnum.UPDATE, params, jobPO).sync();
|
|
|
|
new OrganizationSyncEc(user, LogModuleNameEnum.JOB, OperateTypeEnum.UPDATE, params, jobPO).sync();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 判断相同层级下有无同名岗位
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
public static void assertNameRepeat(Long jobId, Long departmentId, Long parentJobId, String jobName) {
|
|
|
|
|
|
|
|
assertNameRepeat(jobId, departmentId, parentJobId, jobName, true);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 判断相同层级下有无同名岗位
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
public static boolean assertNameRepeat(String jobId, String departmentId, String parentJobId, String jobName) {
|
|
|
|
|
|
|
|
return assertNameRepeat(StringUtils.isBlank(jobId) ? null : Long.parseLong(jobId), StringUtils.isBlank(departmentId) ? null : Long.parseLong(departmentId), StringUtils.isBlank(parentJobId) ? null : Long.parseLong(parentJobId), jobName, false);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 判断相同层级下有无同名岗位
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* @param jobId
|
|
|
|
|
|
|
|
* @param departmentId
|
|
|
|
|
|
|
|
* @param parentJobId
|
|
|
|
|
|
|
|
* @param jobName
|
|
|
|
|
|
|
|
* @param throwException
|
|
|
|
|
|
|
|
* @return
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
public static boolean assertNameRepeat(Long jobId, Long departmentId, Long parentJobId, String jobName, boolean throwException) {
|
|
|
|
|
|
|
|
int count = 0;
|
|
|
|
|
|
|
|
// 有上级岗位、判断相同层级下有无相同名称岗位
|
|
|
|
|
|
|
|
if (null != jobId) {
|
|
|
|
|
|
|
|
count = getJobMapper().countRepeatNameByPid(jobName, jobId, parentJobId, departmentId);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
// 无上级岗位,判断当前部门下,有无同名岗位
|
|
|
|
|
|
|
|
count = getJobMapper().countRepeatNameByPid(jobName, jobId, null, departmentId);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (throwException) {
|
|
|
|
|
|
|
|
OrganizationAssert.isTrue(count == 0, "岗位名称已存在");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return count == 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|