weaver-hrm-organization/src/com/engine/organization/wrapper/JobWrapper.java

238 lines
7.7 KiB
Java
Raw Normal View History

2022-05-27 18:05:15 +08:00
package com.engine.organization.wrapper;
2022-07-05 15:15:00 +08:00
import com.alibaba.fastjson.JSON;
2022-06-01 16:20:43 +08:00
import com.api.browser.bean.SearchConditionGroup;
2022-06-01 14:38:39 +08:00
import com.api.browser.bean.SearchConditionItem;
2022-05-27 18:05:15 +08:00
import com.engine.common.util.ServiceUtil;
2022-07-05 15:15:00 +08:00
import com.engine.organization.annotation.Log;
2022-07-07 14:19:56 +08:00
import com.engine.organization.entity.DeleteParam;
import com.engine.organization.entity.job.param.JobCopyParam;
2022-06-24 18:26:15 +08:00
import com.engine.organization.entity.job.param.JobMergeParam;
2022-05-30 18:39:03 +08:00
import com.engine.organization.entity.job.param.JobSearchParam;
2022-07-07 14:19:56 +08:00
import com.engine.organization.entity.job.po.JobPO;
2022-05-27 18:05:15 +08:00
import com.engine.organization.entity.searchtree.SearchTreeParams;
2022-07-05 15:15:00 +08:00
import com.engine.organization.enums.LogModuleNameEnum;
import com.engine.organization.enums.OperateTypeEnum;
2022-07-07 14:19:56 +08:00
import com.engine.organization.mapper.job.JobMapper;
2022-05-27 18:05:15 +08:00
import com.engine.organization.service.JobService;
import com.engine.organization.service.impl.JobServiceImpl;
2022-09-14 17:14:12 +08:00
import com.engine.organization.util.MenuBtn;
2022-06-01 14:38:39 +08:00
import com.engine.organization.util.OrganizationFormItemUtil;
2022-07-05 15:15:00 +08:00
import com.engine.organization.util.OrganizationWrapper;
2022-07-07 14:19:56 +08:00
import com.engine.organization.util.db.MapperProxyFactory;
2022-06-01 14:38:39 +08:00
import com.engine.organization.util.response.ReturnResult;
2022-05-27 18:05:15 +08:00
import weaver.hrm.User;
2022-07-05 15:15:00 +08:00
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;
2022-05-27 18:05:15 +08:00
/**
2022-06-14 11:07:48 +08:00
* @description:
2022-05-27 18:05:15 +08:00
* @author:dxfeng
* @createTime: 2022/05/27
* @version: 1.0
*/
2022-07-05 15:15:00 +08:00
public class JobWrapper extends OrganizationWrapper {
2022-05-27 18:05:15 +08:00
private JobService getJobService(User user) {
return ServiceUtil.getService(JobServiceImpl.class, user);
}
2022-07-07 14:19:56 +08:00
private JobMapper getJobMapper() {
return MapperProxyFactory.getProxy(JobMapper.class);
}
2022-05-30 18:39:03 +08:00
/**
* 左侧树
*
* @param params
* @return
*/
2022-05-27 18:05:15 +08:00
public Map<String, Object> getSearchTree(SearchTreeParams params) {
return getJobService(user).getSearchTree(params);
}
2022-05-30 18:39:03 +08:00
/**
* 列表
*
* @param param
* @return
*/
public Map<String, Object> listPage(JobSearchParam param) {
return getJobService(user).listPage(param);
}
/**
* 顶部按钮
*
* @return
*/
2022-09-14 17:14:12 +08:00
public Map<String, List<MenuBtn>> getHasRight() {
2022-05-30 18:39:03 +08:00
return getJobService(user).getHasRight();
}
/**
* 搜索条件
*
* @return
*/
public Map<String, Object> getSearchCondition() {
return getJobService(user).getSearchCondition();
}
/**
* 获取新增表单
*
* @return
*/
public Map<String, Object> getSaveForm(JobSearchParam param) {
return getJobService(user).getSaveForm(param);
2022-05-30 18:39:03 +08:00
}
/**
* 获取详细表单
*
* @param params
* @return
*/
public Map<String, Object> getJobBaseForm(Map<String, Object> params) {
return getJobService(user).getJobBaseForm(params);
}
/**
* 保存基础信息
*
* @param params
* @return
*/
2022-07-05 15:15:00 +08:00
@Log(operateType = OperateTypeEnum.ADD, operateModule = LogModuleNameEnum.JOB, operateDesc = "新增岗位")
2022-06-23 16:55:26 +08:00
public Long saveBaseForm(Map<String, Object> params) {
2022-07-05 15:15:00 +08:00
Long jobId = getJobService(user).saveBaseForm(params);
2023-06-01 14:12:12 +08:00
JobPO jobPO = getJobMapper().getJobById(jobId);
2022-07-05 15:15:00 +08:00
writeOperateLog(new Object() {
2023-06-01 14:12:12 +08:00
}.getClass(), jobPO.getJobTitleName(), JSON.toJSONString(params), "新增岗位");
2022-07-05 15:15:00 +08:00
return jobId;
2022-05-30 18:39:03 +08:00
}
/**
* 更新主表拓展表明细表
*
* @param params
* @return
*/
2022-07-07 14:19:56 +08:00
@Log(operateType = OperateTypeEnum.UPDATE, operateModule = LogModuleNameEnum.JOB, operateDesc = "更新岗位")
2022-06-23 16:55:26 +08:00
public Long updateForm(Map<String, Object> params) {
2022-07-07 14:19:56 +08:00
long id = Long.parseLong(params.get("id").toString());
JobPO jobById = getJobMapper().getJobById(id);
2022-07-05 15:15:00 +08:00
Long jobId = getJobService(user).updateForm(params);
2022-08-31 14:24:00 +08:00
JobPO newJobById = getJobMapper().getJobById(id);
2022-07-05 15:15:00 +08:00
writeOperateLog(new Object() {
2022-12-09 14:29:20 +08:00
}.getClass(), jobById.getJobTitleName(), JSON.toJSONString(params), jobById, newJobById);
2022-08-31 14:24:00 +08:00
// 更新组织架构图
2022-10-26 20:12:14 +08:00
2022-07-05 15:15:00 +08:00
return jobId;
2022-05-30 18:39:03 +08:00
}
2022-05-31 21:39:20 +08:00
/**
* 复制岗位到指定部门
*
2022-07-07 14:19:56 +08:00
* @param param
2022-05-31 21:39:20 +08:00
* @return
*/
2022-07-07 14:19:56 +08:00
@Log(operateType = OperateTypeEnum.COPY, operateModule = LogModuleNameEnum.JOB, operateDesc = "复制岗位")
public int copyJobItem(JobCopyParam param) {
List<JobPO> jobPOS = getJobMapper().getJobsByIds(DeleteParam.builder().ids(param.getIds()).build().getIds());
int copyJobItem = getJobService(user).copyJobItem(param.getIds(), param.getDepartment());
for (JobPO jobPO : jobPOS) {
writeOperateLog(new Object() {
2022-12-09 14:29:20 +08:00
}.getClass(), jobPO.getJobTitleName(), JSON.toJSONString(param), "复制岗位[" + jobPO.getJobTitleName() + "]");
2022-07-07 14:19:56 +08:00
}
2022-07-05 15:15:00 +08:00
return copyJobItem;
2022-05-31 21:39:20 +08:00
}
2022-05-30 18:39:03 +08:00
/**
2022-07-05 15:15:00 +08:00
* 更新禁用标识
*
2022-05-30 18:39:03 +08:00
* @param params
* @return
*/
2022-07-05 15:15:00 +08:00
@Log(operateType = OperateTypeEnum.UPDATE, operateModule = LogModuleNameEnum.JOB, operateDesc = "更新岗位禁用标识")
2022-05-30 18:39:03 +08:00
public int updateForbiddenTagById(JobSearchParam params) {
2022-07-07 14:19:56 +08:00
JobPO jobById = getJobMapper().getJobById(params.getId());
2022-07-05 15:15:00 +08:00
int updateForbiddenTagById = getJobService(user).updateForbiddenTagById(params);
2022-08-31 14:24:00 +08:00
JobPO newJobById = getJobMapper().getJobById(params.getId());
2022-07-05 15:15:00 +08:00
writeOperateLog(new Object() {
2022-08-31 14:24:00 +08:00
}.getClass(), jobById.getJobNo(), JSON.toJSONString(params), jobById, newJobById);
2022-08-31 14:24:00 +08:00
// 更新组织架构图
2023-07-03 10:50:07 +08:00
// new Thread(new JobTriggerRunnable(jobById, newJobById)).start();
2022-07-05 15:15:00 +08:00
return updateForbiddenTagById;
2022-05-30 18:39:03 +08:00
}
/**
* 根据ID批量删除
*
* @param ids
* @return
*/
2022-07-07 14:19:56 +08:00
@Log(operateType = OperateTypeEnum.DELETE, operateModule = LogModuleNameEnum.JOB, operateDesc = "删除岗位")
2022-05-30 18:39:03 +08:00
public int deleteByIds(Collection<Long> ids) {
2022-07-07 14:19:56 +08:00
List<JobPO> jobPOS = getJobMapper().getJobsByIds(ids);
2022-07-05 15:15:00 +08:00
int deleteByIds = getJobService(user).deleteByIds(ids);
2022-07-07 14:19:56 +08:00
for (JobPO jobPO : jobPOS) {
writeOperateLog(new Object() {
2022-12-09 14:29:20 +08:00
}.getClass(), jobPO.getJobTitleName(), JSON.toJSONString(ids), "删除岗位");
2022-08-31 14:24:00 +08:00
// 更新组织架构图
2023-07-03 10:50:07 +08:00
// new JobTriggerRunnable(jobPO).run();
2022-07-07 14:19:56 +08:00
}
2022-07-05 15:15:00 +08:00
return deleteByIds;
2022-05-30 18:39:03 +08:00
}
2022-06-01 14:38:39 +08:00
/**
* 获取复制表单
2022-06-01 18:20:44 +08:00
*
2022-06-01 14:38:39 +08:00
* @return
*/
public ReturnResult getCopyForm() {
2022-06-01 16:20:43 +08:00
List<SearchConditionGroup> addGroups = new ArrayList<>();
2022-06-01 14:38:39 +08:00
List<SearchConditionItem> condition = new ArrayList<>();
2022-09-07 19:12:42 +08:00
SearchConditionItem deptBrowserItem = OrganizationFormItemUtil.browserItem(user, 2, 16, 3, false, "复制到", "4", "department", "deptBrowser");
2022-06-01 14:38:39 +08:00
deptBrowserItem.setRules("required|string");
condition.add(deptBrowserItem);
2022-06-01 16:20:43 +08:00
addGroups.add(new SearchConditionGroup("", true, condition));
return ReturnResult.successed(addGroups);
2022-06-01 14:38:39 +08:00
}
/**
* 根据岗位获取人员
2022-06-01 18:20:44 +08:00
*
2022-06-01 14:38:39 +08:00
* @param jobId
* @return
*/
public ReturnResult getHrmListByJobId(Long jobId) {
Map<String, Object> hrmListByJobId = getJobService(user).getHrmListByJobId(jobId);
return ReturnResult.successed(hrmListByJobId);
}
2022-06-24 18:26:15 +08:00
2022-09-15 10:41:04 +08:00
public List<SearchConditionGroup> getMergeForm(Long id) {
return getJobService(user).getMergeForm(id);
2022-06-24 18:26:15 +08:00
}
2022-07-07 14:19:56 +08:00
@Log(operateType = OperateTypeEnum.MERGE, operateModule = LogModuleNameEnum.JOB, operateDesc = "合并岗位")
2022-06-24 18:26:15 +08:00
public int mergeJob(JobMergeParam mergeParam) {
2022-07-07 14:19:56 +08:00
JobPO jobById = getJobMapper().getJobById(mergeParam.getId());
2022-07-05 15:15:00 +08:00
int mergeJob = getJobService(user).mergeJob(mergeParam);
writeOperateLog(new Object() {
2022-07-07 14:19:56 +08:00
}.getClass(), jobById.getJobNo(), JSON.toJSONString(mergeParam), jobById, getJobMapper().getJobById(mergeParam.getId()));
2022-07-05 15:15:00 +08:00
return mergeJob;
2022-06-24 18:26:15 +08:00
}
2022-12-15 16:58:02 +08:00
public void refresh() {
getJobService(user).refresh();
}
2022-05-27 18:05:15 +08:00
}