You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
307 lines
12 KiB
Java
307 lines
12 KiB
Java
package com.engine.organization.wrapper;
|
|
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.api.browser.bean.SearchConditionGroup;
|
|
import com.engine.common.util.ServiceUtil;
|
|
import com.engine.organization.annotation.Log;
|
|
import com.engine.organization.entity.DeleteParam;
|
|
import com.engine.organization.entity.company.po.CompPO;
|
|
import com.engine.organization.entity.department.param.*;
|
|
import com.engine.organization.entity.department.po.DepartmentPO;
|
|
import com.engine.organization.entity.department.vo.SingleDeptTreeVO;
|
|
import com.engine.organization.entity.hrmresource.po.ResourceChartPO;
|
|
import com.engine.organization.entity.job.vo.SingleJobTreeVO;
|
|
import com.engine.organization.entity.searchtree.SearchTreeParams;
|
|
import com.engine.organization.enums.LogModuleNameEnum;
|
|
import com.engine.organization.enums.OperateTypeEnum;
|
|
import com.engine.organization.mapper.comp.CompMapper;
|
|
import com.engine.organization.mapper.department.DepartmentMapper;
|
|
import com.engine.organization.mapper.resource.HrmResourceMapper;
|
|
import com.engine.organization.service.DepartmentService;
|
|
import com.engine.organization.service.impl.DepartmentServiceImpl;
|
|
import com.engine.organization.util.HrmStatusHistoryUtil;
|
|
import com.engine.organization.util.MenuBtn;
|
|
import com.engine.organization.util.OrganizationWrapper;
|
|
import com.engine.organization.util.db.MapperProxyFactory;
|
|
import com.engine.organization.util.page.PageInfo;
|
|
import com.engine.organization.util.response.ReturnResult;
|
|
import org.apache.commons.lang.StringUtils;
|
|
import weaver.hrm.User;
|
|
|
|
import java.util.Collection;
|
|
import java.util.HashMap;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
|
|
/**
|
|
* @Author weaver_cl
|
|
* @description:
|
|
* @Date 2022/5/20
|
|
* @Version V1.0
|
|
**/
|
|
public class DepartmentWrapper extends OrganizationWrapper {
|
|
|
|
public DepartmentService getDepartmentService(User user) {
|
|
return ServiceUtil.getService(DepartmentServiceImpl.class, user);
|
|
}
|
|
|
|
private DepartmentMapper getDepartmentMapper() {
|
|
return MapperProxyFactory.getProxy(DepartmentMapper.class);
|
|
}
|
|
private HrmResourceMapper getHrmResourceMapper() {
|
|
return MapperProxyFactory.getProxy(HrmResourceMapper.class);
|
|
}
|
|
|
|
private CompMapper getCompMapper() {
|
|
return MapperProxyFactory.getProxy(CompMapper.class);
|
|
}
|
|
|
|
public ReturnResult getDeptListByPid(QuerySingleDeptListParam param) {
|
|
PageInfo<SingleDeptTreeVO> singleDeptTreeVOS = getDepartmentService(user).getDeptListByPid(param);
|
|
return ReturnResult.successed(user,singleDeptTreeVOS);
|
|
}
|
|
|
|
/**
|
|
* 部门联查岗位
|
|
*
|
|
* @param param
|
|
* @return
|
|
*/
|
|
public PageInfo<SingleJobTreeVO> getJobListByPid(QuerySingleDeptListParam param) {
|
|
return getDepartmentService(user).getJobListByPid(param);
|
|
}
|
|
|
|
/**
|
|
* 左侧树
|
|
*
|
|
* @param params
|
|
* @return
|
|
*/
|
|
public Map<String, Object> getSearchTree(SearchTreeParams params) {
|
|
return getDepartmentService(user).getSearchTree(params);
|
|
}
|
|
|
|
/**
|
|
* 列表数据展示
|
|
*
|
|
* @param param
|
|
* @return
|
|
*/
|
|
public Map<String, Object> listPage(DeptSearchParam param) {
|
|
return getDepartmentService(user).listPage(param);
|
|
}
|
|
|
|
/**
|
|
* 获取保存表单
|
|
*
|
|
* @return
|
|
*/
|
|
public Map<String, Object> getSaveForm(Map<String, Object> params) {
|
|
return getDepartmentService(user).getSaveForm(params);
|
|
}
|
|
|
|
/**
|
|
* 保存部门基础信息
|
|
*
|
|
* @param params
|
|
* @return
|
|
*/
|
|
@Log(operateType = OperateTypeEnum.ADD, operateDesc = "新增部门", operateModule = LogModuleNameEnum.DEPARTMENT)
|
|
public Long saveBaseForm(Map<String, Object> params) {
|
|
Long departmentId = getDepartmentService(user).saveBaseForm(params);
|
|
writeOperateLog(new Object() {
|
|
}.getClass(), params.get("departmentname").toString(), JSON.toJSONString(params), "新增部门");
|
|
// TODO new Thread(new DepartmentTriggerRunnable(departmentId)).start();
|
|
return departmentId;
|
|
}
|
|
|
|
|
|
/**
|
|
* 更新禁用标记
|
|
*
|
|
* @param params
|
|
*/
|
|
@Log(operateType = OperateTypeEnum.UPDATE, operateDesc = "更新部门禁用标记", operateModule = LogModuleNameEnum.DEPARTMENT)
|
|
public int updateForbiddenTagById(DeptSearchParam params) {
|
|
DepartmentPO deptById = getDepartmentMapper().getDeptById(params.getId());
|
|
int updateForbiddenTagById = getDepartmentService(user).updateForbiddenTagById(params);
|
|
DepartmentPO newDeptById = getDepartmentMapper().getDeptById(params.getId());
|
|
writeOperateLog(new Object() {
|
|
}.getClass(), deptById.getDepartmentName(), JSON.toJSONString(params), deptById, newDeptById);
|
|
// new Thread(new DepartmentTriggerRunnable(params.getForbiddenTag(),deptById, newDeptById)).start();
|
|
return updateForbiddenTagById;
|
|
}
|
|
|
|
/**
|
|
* 更新分部主表、拓展表、明细表
|
|
*
|
|
* @param params
|
|
* @return
|
|
*/
|
|
@Log(operateType = OperateTypeEnum.UPDATE, operateDesc = "更新部门", operateModule = LogModuleNameEnum.DEPARTMENT)
|
|
public Long updateForm(Map<String, Object> params) {
|
|
Integer id = Integer.parseInt(params.get("id").toString());
|
|
DepartmentPO deptById = getDepartmentMapper().getDeptById(id);
|
|
Long departmentId = getDepartmentService(user).updateForm(params);
|
|
DepartmentPO newDeptById = getDepartmentMapper().getDeptById(id);
|
|
writeOperateLog(new Object() {
|
|
}.getClass(), deptById.getDepartmentName(), JSON.toJSONString(params), deptById, newDeptById);
|
|
return departmentId;
|
|
}
|
|
|
|
/**
|
|
* 根据ID批量删除
|
|
*
|
|
* @param ids
|
|
*/
|
|
@Log(operateType = OperateTypeEnum.DELETE, operateDesc = "删除部门", operateModule = LogModuleNameEnum.DEPARTMENT)
|
|
public Map<String, Object> deleteByIds(Collection<Long> ids) {
|
|
Map<String, Object> params = new HashMap<>();
|
|
params.put("id", StringUtils.join(ids, ","));
|
|
List<DepartmentPO> departmentPOS = getDepartmentMapper().getDeptsByIds(ids);
|
|
Map<String, Object> map = getDepartmentService(user).deleteByIds(params);
|
|
for (DepartmentPO departmentPO : departmentPOS) {
|
|
writeOperateLog(new Object() {
|
|
}.getClass(), departmentPO.getDepartmentName(), JSON.toJSONString(ids), "删除部门");
|
|
// 更新组织架构图
|
|
// TODO new DepartmentTriggerRunnable(departmentPO).run();
|
|
}
|
|
return map;
|
|
}
|
|
|
|
/**
|
|
* 获取搜索条件
|
|
*
|
|
* @param params
|
|
* @return
|
|
*/
|
|
public Map<String, Object> getSearchCondition(Map<String, Object> params) {
|
|
return getDepartmentService(user).getSearchCondition(params);
|
|
}
|
|
|
|
/**
|
|
* 获取列表页面按钮信息
|
|
*
|
|
* @return
|
|
*/
|
|
public Map<String, List<MenuBtn>> getHasRight() {
|
|
return getDepartmentService(user).getHasRight();
|
|
}
|
|
|
|
/**
|
|
* 获取基本信息表单
|
|
*
|
|
* @param params
|
|
* @return
|
|
*/
|
|
public Map<String, Object> getDeptBaseForm(Map<String, Object> params) {
|
|
return getDepartmentService(user).getDeptBaseForm(params);
|
|
}
|
|
|
|
/**
|
|
* 复制表单
|
|
*
|
|
* @return
|
|
*/
|
|
public List<SearchConditionGroup> getCopyForm() {
|
|
return getDepartmentService(user).getCopyForm();
|
|
}
|
|
|
|
/**
|
|
* 复制岗位到指定部门
|
|
*
|
|
* @param copyParam
|
|
* @return
|
|
*/
|
|
@Log(operateType = OperateTypeEnum.COPY, operateDesc = "复制部门", operateModule = LogModuleNameEnum.DEPARTMENT)
|
|
public int copyDepartment(DeptCopyParam copyParam) {
|
|
List<DepartmentPO> departmentPOS = getDepartmentMapper().getDeptsByIds(DeleteParam.builder().ids(copyParam.getIds()).build().getIds());
|
|
int copyDepartment = getDepartmentService(user).copyDepartment(copyParam);
|
|
for (DepartmentPO departmentPO : departmentPOS) {
|
|
writeOperateLog(new Object() {
|
|
}.getClass(), departmentPO.getDepartmentName(), JSON.toJSONString(copyParam), "复制部门[" + departmentPO.getDepartmentName() + "]");
|
|
}
|
|
return copyDepartment;
|
|
}
|
|
|
|
/**
|
|
* 获取合并表单
|
|
*
|
|
* @return
|
|
*/
|
|
public List<SearchConditionGroup> getMergeForm() {
|
|
return getDepartmentService(user).getMergeForm();
|
|
}
|
|
|
|
/**
|
|
* 合并到指定部门
|
|
*
|
|
* @param mergeParam
|
|
* @return
|
|
*/
|
|
@Log(operateType = OperateTypeEnum.MERGE, operateDesc = "合并部门", operateModule = LogModuleNameEnum.DEPARTMENT)
|
|
public int mergeDepartment(DepartmentMergeParam mergeParam) {
|
|
DepartmentPO departmentPO = getDepartmentMapper().getDeptById(mergeParam.getId());
|
|
//被合并的部门人员工作记录表记录调动
|
|
List<ResourceChartPO> resourceChartPOList = getHrmResourceMapper().selectByDepartmentId(mergeParam.getId());
|
|
int mergeDepartment = getDepartmentService(user).mergeDepartment(mergeParam);
|
|
if (CollectionUtil.isNotEmpty(resourceChartPOList)) {
|
|
HrmStatusHistoryUtil.personWorkRecord(resourceChartPOList,mergeParam.getDepartment(),"合并部门");
|
|
}
|
|
writeOperateLog(new Object() {
|
|
}.getClass(), departmentPO.getDepartmentName(), JSON.toJSONString(mergeParam), departmentPO, getDepartmentMapper().getDeptById(departmentPO.getId()));
|
|
return mergeDepartment;
|
|
}
|
|
|
|
/**
|
|
* 获取转移表单
|
|
*
|
|
* @return
|
|
*/
|
|
public List<SearchConditionGroup> getMoveForm() {
|
|
return getDepartmentService(user).getMoveForm();
|
|
}
|
|
|
|
/**
|
|
* 转移到指定分部或部门
|
|
*
|
|
* @param moveParam
|
|
* @return
|
|
*/
|
|
@Log(operateType = OperateTypeEnum.MOVE, operateDesc = "转移部门", operateModule = LogModuleNameEnum.DEPARTMENT)
|
|
public int moveDepartment(DepartmentMoveParam moveParam) {
|
|
DepartmentPO departmentPO = getDepartmentMapper().getDeptById(moveParam.getId());
|
|
int moveDepartment = getDepartmentService(user).moveDepartment(moveParam);
|
|
writeOperateLog(new Object() {
|
|
}.getClass(), departmentPO.getDepartmentName(), JSON.toJSONString(moveParam), departmentPO, getDepartmentMapper().getDeptById(departmentPO.getId()));
|
|
return moveDepartment;
|
|
}
|
|
|
|
/**
|
|
* 拖拽转移到指定分部或部门
|
|
*
|
|
* @param moveParam
|
|
* @return
|
|
*/
|
|
@Log(operateType = OperateTypeEnum.MOVE, operateDesc = "拖拽转移部门或分部", operateModule = LogModuleNameEnum.DEPARTMENT)
|
|
public int dragDepartment(DepartmentDragParam departmentDragParam) {
|
|
String type = departmentDragParam.getSourcekey().substring(0,1);
|
|
String sourceId = departmentDragParam.getSourcekey().substring(1);
|
|
int moveDepartment = 0;
|
|
if("d".equals(type)) {
|
|
DepartmentPO departmentPO = getDepartmentMapper().getDeptById(Integer.valueOf(sourceId));
|
|
moveDepartment = getDepartmentService(user).dragDepartment(departmentDragParam);
|
|
writeOperateLog(new Object() {
|
|
}.getClass(), departmentPO.getDepartmentName(), JSON.toJSONString(departmentDragParam), departmentPO, getDepartmentMapper().getDeptById(departmentPO.getId()));
|
|
}else{
|
|
CompPO compPO = getCompMapper().listById(Integer.valueOf(sourceId));
|
|
moveDepartment = getDepartmentService(user).dragDepartment(departmentDragParam);
|
|
CompPO newcompPO = getCompMapper().listById(Integer.valueOf(sourceId));
|
|
writeOperateLog(new Object() {
|
|
}.getClass(), compPO.getSubCompanyName(), JSON.toJSONString(departmentDragParam), compPO, newcompPO);
|
|
}
|
|
return moveDepartment;
|
|
}
|
|
}
|