605 lines
28 KiB
Java
605 lines
28 KiB
Java
package com.engine.organization.service.impl;
|
||
|
||
import com.alibaba.fastjson.JSONObject;
|
||
import com.api.browser.bean.SearchConditionGroup;
|
||
import com.api.browser.bean.SearchConditionItem;
|
||
import com.api.browser.bean.SearchConditionOption;
|
||
import com.cloudstore.eccom.pc.table.WeaTableColumn;
|
||
import com.cloudstore.eccom.result.WeaResultMsg;
|
||
import com.engine.common.util.ServiceUtil;
|
||
import com.engine.core.impl.Service;
|
||
import com.engine.hrm.entity.RuleCodeType;
|
||
import com.engine.organization.component.OrganizationWeaTable;
|
||
import com.engine.organization.entity.DeleteParam;
|
||
import com.engine.organization.entity.codesetting.po.CodeRulePO;
|
||
import com.engine.organization.entity.company.bo.CompBO;
|
||
import com.engine.organization.entity.company.po.CompPO;
|
||
import com.engine.organization.entity.department.bo.DepartmentBO;
|
||
import com.engine.organization.entity.department.po.DepartmentPO;
|
||
import com.engine.organization.entity.employee.vo.EmployeeTableVO;
|
||
import com.engine.organization.entity.extend.bo.ExtendInfoBO;
|
||
import com.engine.organization.entity.extend.po.ExtendInfoPO;
|
||
import com.engine.organization.entity.extend.po.ExtendTitlePO;
|
||
import com.engine.organization.entity.job.bo.JobBO;
|
||
import com.engine.organization.entity.job.dto.JobListDTO;
|
||
import com.engine.organization.entity.job.param.JobSearchParam;
|
||
import com.engine.organization.entity.job.po.JobDTPO;
|
||
import com.engine.organization.entity.job.po.JobPO;
|
||
import com.engine.organization.entity.scheme.po.GradePO;
|
||
import com.engine.organization.entity.searchtree.SearchTree;
|
||
import com.engine.organization.entity.searchtree.SearchTreeParams;
|
||
import com.engine.organization.mapper.codesetting.CodeRuleMapper;
|
||
import com.engine.organization.mapper.comp.CompMapper;
|
||
import com.engine.organization.mapper.department.DepartmentMapper;
|
||
import com.engine.organization.mapper.extend.ExtendTitleMapper;
|
||
import com.engine.organization.mapper.job.JobDTMapper;
|
||
import com.engine.organization.mapper.job.JobMapper;
|
||
import com.engine.organization.mapper.scheme.GradeMapper;
|
||
import com.engine.organization.mapper.scheme.LevelMapper;
|
||
import com.engine.organization.service.ExtService;
|
||
import com.engine.organization.service.JobService;
|
||
import com.engine.organization.util.HasRightUtil;
|
||
import com.engine.organization.util.MenuBtn;
|
||
import com.engine.organization.util.OrganizationAssert;
|
||
import com.engine.organization.util.OrganizationFormItemUtil;
|
||
import com.engine.organization.util.coderule.CodeRuleUtil;
|
||
import com.engine.organization.util.db.MapperProxyFactory;
|
||
import com.engine.organization.util.page.Column;
|
||
import com.engine.organization.util.page.PageInfo;
|
||
import com.engine.organization.util.page.PageUtil;
|
||
import com.engine.organization.util.tree.SearchTreeUtil;
|
||
import org.apache.commons.collections4.CollectionUtils;
|
||
import org.apache.commons.lang.StringUtils;
|
||
import weaver.general.StringUtil;
|
||
import weaver.general.Util;
|
||
import weaver.hrm.User;
|
||
|
||
import java.util.*;
|
||
import java.util.stream.Collectors;
|
||
|
||
/**
|
||
* @description:
|
||
* @author:dxfeng
|
||
* @createTime: 2022/05/26
|
||
* @version: 1.0
|
||
*/
|
||
public class JobServiceImpl extends Service implements JobService {
|
||
|
||
/**
|
||
* 左侧树 类型表示
|
||
* <p>
|
||
* 0:集团
|
||
* 1:分部
|
||
* 2:部门
|
||
*/
|
||
private static final String TYPE_COMP = "1";
|
||
private static final String TYPE_DEPT = "2";
|
||
|
||
/**
|
||
* 分组类型
|
||
* 1:分部
|
||
* 2:部门
|
||
* 3:岗位
|
||
*/
|
||
private static final String EXTEND_TYPE = "3";
|
||
/**
|
||
* 主表
|
||
*/
|
||
private static final String JCL_ORG_JOB = "JCL_ORG_JOB";
|
||
/**
|
||
* 主表拓展表
|
||
*/
|
||
private static final String JCL_ORG_JOBEXT = "JCL_ORG_JOBEXT";
|
||
/**
|
||
* 明细表拓展表
|
||
*/
|
||
private static final String JCL_ORG_JOBEXT_DT1 = "JCL_ORG_JOBEXT_DT1";
|
||
|
||
private static final String RIGHT_NAME = "Job:All";
|
||
|
||
/**
|
||
* 岗位主表title指定ID
|
||
*/
|
||
private static final Long GROUP_ID = 3L;
|
||
|
||
private JobMapper getJobMapper() {
|
||
return MapperProxyFactory.getProxy(JobMapper.class);
|
||
}
|
||
|
||
private JobDTMapper getJobDTMapper() {
|
||
return MapperProxyFactory.getProxy(JobDTMapper.class);
|
||
}
|
||
|
||
private CompMapper getCompMapper() {
|
||
return MapperProxyFactory.getProxy(CompMapper.class);
|
||
}
|
||
|
||
private DepartmentMapper getDepartmentMapper() {
|
||
return MapperProxyFactory.getProxy(DepartmentMapper.class);
|
||
}
|
||
|
||
private ExtendTitleMapper getExtendTitleMapper() {
|
||
return MapperProxyFactory.getProxy(ExtendTitleMapper.class);
|
||
}
|
||
|
||
private ExtService getExtService(User user) {
|
||
return ServiceUtil.getService(ExtServiceImpl.class, user);
|
||
}
|
||
|
||
|
||
@Override
|
||
public Map<String, Object> getSearchTree(SearchTreeParams params) {
|
||
String keyword = params.getKeyword();
|
||
String id = params.getId();
|
||
String type = Util.null2String(params.getType());
|
||
List<SearchTree> treeList = getFilterCompany(id, type, keyword);
|
||
return SearchTreeUtil.getSearchTree(type, treeList);
|
||
}
|
||
|
||
@Override
|
||
public Map<String, Object> listPage(JobSearchParam param) {
|
||
Map<String, Object> datas = new HashMap<>();
|
||
boolean hasRight = HasRightUtil.hasRight(user, RIGHT_NAME, true);
|
||
datas.put("hasRight", hasRight);
|
||
if (!hasRight) {
|
||
return datas;
|
||
}
|
||
JobPO jobPO = JobBO.convertParamsToPO(param, user.getUID());
|
||
boolean filter = isFilter(jobPO);
|
||
PageInfo<JobListDTO> pageInfos;
|
||
List<JobListDTO> allList = getJobMapper().listNoFilter();
|
||
// 通过子级遍历父级元素
|
||
if (filter) {
|
||
// 根据条件获取元素
|
||
List<JobListDTO> filterJobPOs = getJobMapper().listByFilter(jobPO);
|
||
// 添加父级元素
|
||
List<JobListDTO> jobListDTOS = JobBO.buildJobDTOList(allList, filterJobPOs);
|
||
List<JobListDTO> subList = PageUtil.subList(param.getCurrent(), param.getPageSize(), jobListDTOS);
|
||
pageInfos = new PageInfo<>(subList, JobListDTO.class);
|
||
pageInfos.setTotal(jobListDTOS.size());
|
||
} else {
|
||
// 组合list
|
||
List<JobListDTO> jobListDTOS = JobBO.buildDTOList(allList);
|
||
List<JobListDTO> subList = PageUtil.subList(param.getCurrent(), param.getPageSize(), jobListDTOS);
|
||
pageInfos = new PageInfo<>(subList, JobListDTO.class);
|
||
pageInfos.setTotal(jobListDTOS.size());
|
||
}
|
||
|
||
pageInfos.setPageNum(param.getCurrent());
|
||
pageInfos.setPageSize(param.getPageSize());
|
||
|
||
OrganizationWeaTable<JobListDTO> table = new OrganizationWeaTable<>(user, JobListDTO.class);
|
||
List<Column> columns = pageInfos.getColumns();
|
||
List<WeaTableColumn> weaTableColumn = columns.stream().map(v -> new WeaTableColumn("100", v.getTitle(), v.getKey())).collect(Collectors.toList());
|
||
|
||
table.setColumns(weaTableColumn);
|
||
|
||
WeaResultMsg result = new WeaResultMsg(false);
|
||
result.putAll(table.makeDataResult());
|
||
result.success();
|
||
|
||
datas.put("pageInfo", pageInfos);
|
||
datas.put("dataKey", result.getResultMap());
|
||
return datas;
|
||
}
|
||
|
||
@Override
|
||
public Map<String, Object> getHasRight() {
|
||
return MenuBtn.getDatasHasCopy();
|
||
}
|
||
|
||
@Override
|
||
public Map<String, Object> getSearchCondition() {
|
||
Map<String, Object> apiDatas = new HashMap<>();
|
||
List<SearchConditionGroup> addGroups = new ArrayList<>();
|
||
List<SearchConditionItem> conditionItems = new ArrayList<>();
|
||
// 编号
|
||
SearchConditionItem jobNoItem = OrganizationFormItemUtil.inputItem(user, 2, 16, 2, 50, "编号", "jobNo");
|
||
// 名称
|
||
SearchConditionItem jobNameItem = OrganizationFormItemUtil.inputItem(user, 2, 16, 2, 50, "名称", "jobName");
|
||
// 所属分部
|
||
SearchConditionItem parentCompBrowserItem = OrganizationFormItemUtil.browserItem(user, 2, 16, 2, false, "所属分部", "161", "parentComp", "compBrowser");
|
||
// 所属部门
|
||
SearchConditionItem parentDeptBrowserItem = OrganizationFormItemUtil.browserItem(user, 2, 16, 2, false, "所属部门", "161", "parentDept", "deptBrowser");
|
||
// 岗位序列
|
||
SearchConditionItem sequenceBrowserItem = OrganizationFormItemUtil.browserItem(user, 2, 16, 2, false, "岗位序列", "161", "sequenceId", "sequenceBrowser");
|
||
// 等级方案
|
||
SearchConditionItem schemeBrowserItem = OrganizationFormItemUtil.browserItem(user, 2, 16, 2, false, "等级方案", "161", "schemeId", "schemeBrowser");
|
||
// 上级岗位
|
||
SearchConditionItem parentJobBrowserItem = OrganizationFormItemUtil.browserItem(user, 2, 16, 2, false, "上级岗位", "161", "parentJob", "jobBrowser");
|
||
// 是否关键岗
|
||
List<SearchConditionOption> isKeyOptions = new ArrayList<>();
|
||
SearchConditionOption yesOption = new SearchConditionOption("0", "否");
|
||
SearchConditionOption noOption = new SearchConditionOption("1", "是");
|
||
isKeyOptions.add(yesOption);
|
||
isKeyOptions.add(noOption);
|
||
SearchConditionItem isKeyItem = OrganizationFormItemUtil.selectItem(user, isKeyOptions, 2, 16, 6, false, "是否关键岗", "forbiddenTag");
|
||
// 工作地点
|
||
SearchConditionItem workplaceItem = OrganizationFormItemUtil.inputItem(user, 2, 16, 2, 50, "工作地点", "workplace");
|
||
// 工作概述
|
||
// SearchConditionItem descriptionItem = OrganizationFormItemUtil.inputItem(user, 2, 16, 2, 50, "工作概述", "description");
|
||
// 任职职责
|
||
//SearchConditionItem workDutyItem = OrganizationFormItemUtil.inputItem(user, 2, 16, 2, 50, "任职职责", "workDuty");
|
||
// 工作权限
|
||
// SearchConditionItem workAuthorityItem = OrganizationFormItemUtil.inputItem(user, 2, 16, 2, 50, "工作权限", "workAuthority");
|
||
// 禁用标记
|
||
List<SearchConditionOption> selectOptions = new ArrayList<>();
|
||
SearchConditionOption enableOption = new SearchConditionOption("true", "启用");
|
||
SearchConditionOption disableOption = new SearchConditionOption("false", "禁用");
|
||
selectOptions.add(enableOption);
|
||
selectOptions.add(disableOption);
|
||
SearchConditionItem forbiddenTagItem = OrganizationFormItemUtil.selectItem(user, selectOptions, 2, 16, 6, false, "禁用标记", "forbiddenTag");
|
||
|
||
conditionItems.add(jobNoItem);
|
||
conditionItems.add(jobNameItem);
|
||
conditionItems.add(parentCompBrowserItem);
|
||
conditionItems.add(parentDeptBrowserItem);
|
||
conditionItems.add(sequenceBrowserItem);
|
||
conditionItems.add(schemeBrowserItem);
|
||
conditionItems.add(parentJobBrowserItem);
|
||
conditionItems.add(isKeyItem);
|
||
conditionItems.add(workplaceItem);
|
||
//conditionItems.add(descriptionItem);
|
||
//conditionItems.add(workDutyItem);
|
||
//conditionItems.add(workAuthorityItem);
|
||
conditionItems.add(forbiddenTagItem);
|
||
|
||
addGroups.add(new SearchConditionGroup("高级搜索条件", true, conditionItems));
|
||
apiDatas.put("conditions", addGroups);
|
||
return apiDatas;
|
||
}
|
||
|
||
@Override
|
||
public Map<String, Object> getSaveForm() {
|
||
HasRightUtil.hasRight(user, RIGHT_NAME, false);
|
||
Map<String, Object> apiDatas = new HashMap<>();
|
||
List<SearchConditionGroup> addGroups = new ArrayList<>();
|
||
List<ExtendTitlePO> extendTitles = getExtendTitleMapper().getTitlesByGroupID(GROUP_ID);
|
||
if (CollectionUtils.isNotEmpty(extendTitles)) {
|
||
for (ExtendTitlePO extendTitle : extendTitles) {
|
||
List<SearchConditionItem> items = getExtService(user).getExtSaveForm(user, EXTEND_TYPE + "", JCL_ORG_JOB, 2, extendTitle.getId().toString(), "job_no", RuleCodeType.JOBTITLES.getValue());
|
||
if (CollectionUtils.isNotEmpty(items)) {
|
||
addGroups.add(new SearchConditionGroup(extendTitle.getTitle(), true, items));
|
||
}
|
||
}
|
||
}
|
||
apiDatas.put("condition", addGroups);
|
||
return apiDatas;
|
||
}
|
||
|
||
@Override
|
||
public Map<String, Object> getJobBaseForm(Map<String, Object> params) {
|
||
OrganizationAssert.notNull(params.get("viewAttr"), "请标识操作类型");
|
||
|
||
// 2编辑 1查看
|
||
int viewAttr = Integer.parseInt((String) params.get("viewAttr"));
|
||
long id = Long.parseLong((String) params.get("id"));
|
||
String groupId = (String) params.get("viewCondition");
|
||
|
||
HashMap<String, Object> buttonsMap = new HashMap<>();
|
||
buttonsMap.put("hasEdit", true);
|
||
buttonsMap.put("hasSave", true);
|
||
|
||
List<SearchConditionGroup> addGroups = new ArrayList<>();
|
||
if ("0".equals(groupId)) {
|
||
groupId = GROUP_ID.toString();
|
||
}
|
||
List<ExtendTitlePO> extendTitles = getExtendTitleMapper().getTitlesByGroupID(GROUP_ID);
|
||
if (CollectionUtils.isNotEmpty(extendTitles)) {
|
||
for (ExtendTitlePO extendTitle : extendTitles) {
|
||
List<SearchConditionItem> items = getExtService(user).getExtForm(user, EXTEND_TYPE + "", GROUP_ID.equals(Long.parseLong(groupId)) ? JCL_ORG_JOB : JCL_ORG_JOBEXT, viewAttr, id, extendTitle.getId().toString(), "");
|
||
if (CollectionUtils.isNotEmpty(items)) {
|
||
addGroups.add(new SearchConditionGroup(extendTitle.getTitle(), true, items));
|
||
}
|
||
}
|
||
}
|
||
HashMap<String, Object> resultMap = new HashMap<>();
|
||
resultMap.put("buttons", buttonsMap);
|
||
resultMap.put("conditions", addGroups);
|
||
resultMap.put("id", id);
|
||
// 拓展页面分组
|
||
resultMap.put("tabInfo", getExtService(user).getTabInfo(EXTEND_TYPE, JCL_ORG_JOBEXT));
|
||
// 处理明细表
|
||
List<Map<String, Object>> extendTables = getExtService(user).getExtendTables(user, EXTEND_TYPE, Long.parseLong(groupId), JCL_ORG_JOBEXT_DT1, id, viewAttr, false);
|
||
|
||
Map<String, Object> tableMap = new HashMap<>();
|
||
tableMap.put("hide", false);
|
||
tableMap.put("tabname", "职等职级");
|
||
Map<String, Object> tabinfoMap = new HashMap<>();
|
||
List<ExtendInfoPO> infoPOList = new ArrayList<>();
|
||
infoPOList.add(ExtendInfoPO.builder().fieldName("gradeId").fieldNameDesc("职级").controlType(3).isrequired(1).browserType("161").customValue("[\"browser\",{\"value\":\"161\",\"valueSpan\":\"自定义单选\",\"replaceDatas\":[{\"id\":\"161\",\"name\":\"自定义单选\"}]},{\"value\":\"gradeBrowser\",\"valueSpan\":\"职级浏览按钮\",\"replaceDatas\":[{\"showname\":\"gradeBrowser\",\"shownamespan\":\"gradeBrowser\",\"namespan\":\"职级浏览按钮\",\"name\":\"职级浏览按钮\",\"showtypespan\":\"列表式\",\"randomFieldIdspan\":\"\",\"showtype\":\"1\",\"randomFieldId\":\"gradeBrowser\",\"id\":\"gradeBrowser\"}]}]").build());
|
||
infoPOList.add(ExtendInfoPO.builder().fieldName("levelId").fieldNameDesc("职等").controlType(3).isrequired(1).browserType("162").customValue("[\"browser\",{\"value\":\"162\",\"valueSpan\":\"自定义多选\",\"replaceDatas\":[{\"id\":\"162\",\"name\":\"自定义多选\"}]},{\"value\":\"LevelBrowser\",\"valueSpan\":\"职等浏览按钮\",\"replaceDatas\":[{\"showname\":\"LevelBrowser\",\"shownamespan\":\"LevelBrowser\",\"namespan\":\"职等浏览按钮\",\"name\":\"职等浏览按钮\",\"showtypespan\":\"列表式\",\"randomFieldIdspan\":\"\",\"showtype\":\"1\",\"randomFieldId\":\"LevelBrowser\",\"id\":\"LevelBrowser\"}]}]").build());
|
||
tabinfoMap.put("columns", ExtendInfoBO.convertInfoListToTable(user, infoPOList, viewAttr, false));
|
||
tabinfoMap.put("rownum", "rownum");
|
||
// 去除null 元素
|
||
List<JobDTPO> maps = getJobDTMapper().listJobDTByMainID(id);
|
||
maps.removeIf(Objects::isNull);
|
||
tabinfoMap.put("datas", maps);
|
||
tableMap.put("tabinfo", tabinfoMap);
|
||
// 添加明细表
|
||
extendTables.add(0, tableMap);
|
||
|
||
resultMap.put("tables", extendTables);
|
||
|
||
Map<String, Object> apiDatas = new HashMap<>();
|
||
|
||
apiDatas.put("result", resultMap);
|
||
|
||
return apiDatas;
|
||
}
|
||
|
||
@Override
|
||
public int saveBaseForm(Map<String, Object> params) {
|
||
HasRightUtil.hasRight(user, RIGHT_NAME, false);
|
||
String jobNo = (String) params.get("job_no");
|
||
// 判断是否开启自动编号
|
||
jobNo = repeatDetermine(jobNo);
|
||
params.put("job_no", jobNo);
|
||
|
||
JobSearchParam searchParam = JSONObject.parseObject(JSONObject.toJSONString(params), JobSearchParam.class);
|
||
JobPO jobPO = JobBO.convertParamsToPO(searchParam, user.getUID());
|
||
jobPO.setIsKey(null == jobPO.getIsKey() ? 0 : jobPO.getIsKey());
|
||
int insertCount = getJobMapper().insertIgnoreNull(jobPO);
|
||
params.put("is_key", jobPO.getIsKey());
|
||
DepartmentPO departmentPO = MapperProxyFactory.getProxy(DepartmentMapper.class).getDeptById(jobPO.getParentDept());
|
||
params.put("parent_comp", departmentPO.getParentComp());
|
||
|
||
getExtService(user).updateExtForm(user, EXTEND_TYPE, JCL_ORG_JOB, params, "", jobPO.getId());
|
||
if (null != jobPO.getSchemeId()) {
|
||
// 插入明细表信息
|
||
// 根据等级方案查询职等、职级
|
||
List<GradePO> gradePOS = MapperProxyFactory.getProxy(GradeMapper.class).listGradesBySchemeId(jobPO.getSchemeId());
|
||
for (GradePO gradePO : gradePOS) {
|
||
List<Map<String, Object>> maps = MapperProxyFactory.getProxy(LevelMapper.class).listLevelsByIds(DeleteParam.builder().ids(gradePO.getLevelId()).build().getIds());
|
||
String levelNames = maps.stream().map(item -> (String) item.get("name")).collect(Collectors.joining(","));
|
||
insertCount += getJobDTMapper().insertIgnoreNull(JobDTPO.builder().levelId(gradePO.getLevelId()).gradeId(gradePO.getId() + "").levelIdspan(levelNames).gradeIdspan(gradePO.getGradeName()).mainId(jobPO.getId()).creator((long) user.getUID()).deleteType(0).createTime(new Date()).updateTime(new Date()).build());
|
||
}
|
||
}
|
||
return insertCount;
|
||
}
|
||
|
||
@Override
|
||
public int updateForm(Map<String, Object> params) {
|
||
HasRightUtil.hasRight(user, RIGHT_NAME, false);
|
||
JobSearchParam searchParam = JSONObject.parseObject(JSONObject.toJSONString(params), JobSearchParam.class);
|
||
String groupId = (String) params.get("viewCondition");
|
||
searchParam.setIsKey(null == searchParam.getIsKey() ? 0 : searchParam.getIsKey());
|
||
if ("0".equals(groupId)) {
|
||
groupId = GROUP_ID.toString();
|
||
}
|
||
String oldJobNo = getJobMapper().getJobById(searchParam.getId()).getJobNo();
|
||
String jobNo = searchParam.getJobNo();
|
||
if (!oldJobNo.equals(jobNo)) {
|
||
jobNo = repeatDetermine(jobNo);
|
||
params.put("job_no", jobNo);
|
||
}
|
||
|
||
int updateCount = 0;
|
||
// 更新主表数据
|
||
params.put("is_key", searchParam.getIsKey());
|
||
DepartmentPO departmentPO = MapperProxyFactory.getProxy(DepartmentMapper.class).getDeptById(searchParam.getParentDept());
|
||
params.put("parent_comp", departmentPO.getParentComp());
|
||
updateCount += getExtService(user).updateExtForm(user, EXTEND_TYPE, JCL_ORG_JOB, params, "", searchParam.getId());
|
||
|
||
// 更新主表拓展表
|
||
updateCount += getExtService(user).updateExtForm(user, EXTEND_TYPE, JCL_ORG_JOBEXT, params, groupId, searchParam.getId());
|
||
// 更新明细表
|
||
getJobDTMapper().deleteByIds(searchParam.getId());
|
||
int rowNum = Util.getIntValue((String) params.get("rownum"));
|
||
for (int i = 0; i < rowNum; i++) {
|
||
String levelId = (String) params.get("levelId_" + i);
|
||
String gradeId = (String) params.get("gradeId_" + i);
|
||
String levelIdspan = (String) params.get("levelIdspan_" + i);
|
||
String gradeIdspan = (String) params.get("gradeIdspan_" + i);
|
||
getJobDTMapper().insertIgnoreNull(JobDTPO.builder().levelId(levelId).gradeId(gradeId).levelIdspan(levelIdspan).gradeIdspan(gradeIdspan).mainId(searchParam.getId()).creator((long) user.getUID()).deleteType(0).createTime(new Date()).updateTime(new Date()).build());
|
||
}
|
||
getExtService(user).updateExtDT(user, EXTEND_TYPE, JCL_ORG_JOBEXT_DT1, params, searchParam.getId());
|
||
return updateCount;
|
||
}
|
||
|
||
@Override
|
||
public int copyJobItem(String ids, String department) {
|
||
HasRightUtil.hasRight(user, RIGHT_NAME, false);
|
||
OrganizationAssert.notBlank(department, "请指定需要复制的部门");
|
||
int insertCount = 0;
|
||
List<Long> idList = Arrays.stream(ids.split(",")).map(Long::parseLong).collect(Collectors.toList());
|
||
for (Long id : idList) {
|
||
JobPO jobById = getJobMapper().getJobById(id);
|
||
// 处理自动编号
|
||
jobById.setJobNo(CodeRuleUtil.generateCode(RuleCodeType.JOBTITLES, jobById.getJobNo(), true));
|
||
jobById.setParentDept(Long.parseLong(department));
|
||
insertCount += getJobMapper().insertIgnoreNull(jobById);
|
||
}
|
||
|
||
return insertCount;
|
||
}
|
||
|
||
@Override
|
||
public int updateForbiddenTagById(JobSearchParam params) {
|
||
HasRightUtil.hasRight(user, RIGHT_NAME, false);
|
||
JobPO jobPO = JobPO.builder().id(params.getId()).forbiddenTag(params.getForbiddenTag() ? 0 : 1).build();
|
||
return getJobMapper().updateForbiddenTagById(jobPO.getId(), jobPO.getForbiddenTag());
|
||
}
|
||
|
||
@Override
|
||
public int deleteByIds(Collection<Long> ids) {
|
||
HasRightUtil.hasRight(user, RIGHT_NAME, false);
|
||
OrganizationAssert.notEmpty(ids, "请选择要删除的数据");
|
||
return getJobMapper().deleteByIds(ids);
|
||
}
|
||
|
||
@Override
|
||
public Map<String, Object> getHrmListByJobId(Long jobId) {
|
||
OrganizationWeaTable<EmployeeTableVO> table = new OrganizationWeaTable<>(user, EmployeeTableVO.class);
|
||
WeaResultMsg result = new WeaResultMsg(false);
|
||
result.putAll(table.makeDataResult());
|
||
result.success();
|
||
return result.getResultMap();
|
||
}
|
||
|
||
/**
|
||
* 添加查询元素的父级元素
|
||
*
|
||
* @param departmentPO
|
||
* @param builderDeparts
|
||
*/
|
||
private void buildParentDepts(DepartmentPO departmentPO, Set<DepartmentPO> builderDeparts) {
|
||
builderDeparts.add(departmentPO);
|
||
if (SearchTreeUtil.isTop(departmentPO.getParentDept())) {
|
||
return;
|
||
}
|
||
DepartmentPO parentDept = getDepartmentMapper().getDeptById(departmentPO.getParentDept());
|
||
if (null != parentDept) {
|
||
buildParentDepts(parentDept, builderDeparts);
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 添加查询元素的父级元素
|
||
*
|
||
* @param compPO
|
||
* @param builderComps
|
||
*/
|
||
private void buildParentComps(CompPO compPO, Set<CompPO> builderComps) {
|
||
builderComps.add(compPO);
|
||
if (SearchTreeUtil.isTop(compPO.getParentCompany())) {
|
||
return;
|
||
}
|
||
CompPO parentComp = getCompMapper().listById(compPO.getParentCompany());
|
||
if (null != parentComp) {
|
||
buildParentComps(parentComp, builderComps);
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 根据keyword查询数据
|
||
*
|
||
* @param id
|
||
* @param type
|
||
* @param keyword
|
||
* @return
|
||
*/
|
||
private List<SearchTree> getFilterCompany(String id, String type, String keyword) {
|
||
List<SearchTree> searchTree = new ArrayList<>();
|
||
// 通过分部、公司 组装数据
|
||
if (StringUtil.isEmpty(id) || TYPE_COMP.equals(type)) {
|
||
Long parentCompId = StringUtil.isEmpty(id) ? null : Long.parseLong(id);
|
||
DepartmentPO departmentBuild = DepartmentPO.builder().deptName(keyword).parentComp(parentCompId).build();
|
||
CompPO compBuild = CompPO.builder().compName(keyword).parentCompany(parentCompId).build();
|
||
searchTree = buildTreeByCompAndDept(departmentBuild, compBuild);
|
||
} else if (TYPE_DEPT.equals(type)) {
|
||
//
|
||
// 查询部门信息
|
||
List<DepartmentPO> filterDeparts = getDepartmentMapper().listByFilter(DepartmentPO.builder().deptName(keyword).parentDept(Long.parseLong(id)).build());
|
||
Set<DepartmentPO> builderDeparts = new HashSet<>();
|
||
for (DepartmentPO departmentPO : filterDeparts) {
|
||
buildParentDepts(departmentPO, builderDeparts);
|
||
}
|
||
searchTree = SearchTreeUtil.builderTreeMode(DepartmentBO.buildSetToSearchTree(builderDeparts));
|
||
|
||
}
|
||
return searchTree;
|
||
}
|
||
|
||
/**
|
||
* 分部、部门 组装左侧树
|
||
*
|
||
* @param departmentBuild
|
||
* @param compBuild
|
||
* @return
|
||
*/
|
||
private List<SearchTree> buildTreeByCompAndDept(DepartmentPO departmentBuild, CompPO compBuild) {
|
||
List<DepartmentPO> filterDeparts = getDepartmentMapper().listByFilter(departmentBuild);
|
||
// 查询分部信息
|
||
List<CompPO> filterComps = getCompMapper().listByFilter(compBuild);
|
||
Set<DepartmentPO> builderDeparts = new HashSet<>();
|
||
for (DepartmentPO departmentPO : filterDeparts) {
|
||
buildParentDepts(departmentPO, builderDeparts);
|
||
}
|
||
List<SearchTree> deptTrees = SearchTreeUtil.builderTreeMode(DepartmentBO.buildSetToSearchTree(builderDeparts));
|
||
// 添加部门的上级分部
|
||
String parentCompS = deptTrees.stream().map(SearchTree::getParentComp).collect(Collectors.joining(","));
|
||
if (!StringUtil.isEmpty(parentCompS)) {
|
||
List<CompPO> compsByIds = getCompMapper().getCompsByIds(DeleteParam.builder().ids(parentCompS).build().getIds());
|
||
if (CollectionUtils.isNotEmpty(compsByIds)) {
|
||
filterComps.addAll(compsByIds);
|
||
}
|
||
}
|
||
Set<CompPO> builderComps = new HashSet<>();
|
||
for (CompPO compPO : filterComps) {
|
||
buildParentComps(compPO, builderComps);
|
||
}
|
||
return SearchTreeUtil.builderTreeMode(CompBO.buildSetToSearchTree(builderComps), deptTrees);
|
||
}
|
||
|
||
|
||
/**
|
||
* 是否有搜索查询
|
||
*
|
||
* @param jobPO
|
||
* @return
|
||
*/
|
||
private boolean isFilter(JobPO jobPO) {
|
||
return !(StringUtil.isEmpty(jobPO.getJobNo())
|
||
&& StringUtil.isEmpty(jobPO.getJobName())
|
||
&& StringUtil.isEmpty(jobPO.getWorkplace())
|
||
&& StringUtil.isEmpty(jobPO.getDescription())
|
||
&& StringUtil.isEmpty(jobPO.getWorkDuty())
|
||
&& StringUtil.isEmpty(jobPO.getWorkAuthority())
|
||
&& null == jobPO.getParentComp()
|
||
&& null == jobPO.getParentDept()
|
||
&& null == jobPO.getSequenceId()
|
||
&& null == jobPO.getSchemeId()
|
||
&& null == jobPO.getIsKey())
|
||
&& null == jobPO.getForbiddenTag();
|
||
}
|
||
|
||
/**
|
||
* 获取待删除数据的子级元素
|
||
*
|
||
* @param ids
|
||
* @param deleteIds
|
||
*/
|
||
private void getChildIds(Collection<Long> ids, Collection<Long> deleteIds) {
|
||
for (Long id : ids) {
|
||
deleteIds.add(id);
|
||
Collection<Long> childIds = getJobMapper().getJobsByPid(id).stream().map(JobPO::getId).collect(Collectors.toList());
|
||
getChildIds(childIds, deleteIds);
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 判断编号是否重复
|
||
*
|
||
* @return
|
||
*/
|
||
private String repeatDetermine(String jobNo) {
|
||
CodeRulePO codeRuleByType = MapperProxyFactory.getProxy(CodeRuleMapper.class).getCodeRuleByType(RuleCodeType.JOBTITLES.getValue());
|
||
if (StringUtils.isNotBlank(jobNo)) {
|
||
jobNo = CodeRuleUtil.generateCode(RuleCodeType.JOBTITLES, jobNo);
|
||
List<JobPO> list = getJobMapper().listByNo(Util.null2String(jobNo));
|
||
OrganizationAssert.isEmpty(list, "编号不允许重复");
|
||
} else {
|
||
if (null != codeRuleByType && "1".equals(codeRuleByType.getSerialEnable())) {
|
||
jobNo = autoCreateCompanyNo();
|
||
}
|
||
}
|
||
return jobNo;
|
||
}
|
||
|
||
/**
|
||
* 自动编号处理
|
||
*
|
||
* @return
|
||
*/
|
||
private String autoCreateCompanyNo() {
|
||
String generateCode = CodeRuleUtil.generateCode(RuleCodeType.JOBTITLES, "");
|
||
List<JobPO> list = getJobMapper().listByNo(Util.null2String(generateCode));
|
||
if (CollectionUtils.isNotEmpty(list)) {
|
||
generateCode = autoCreateCompanyNo();
|
||
}
|
||
return generateCode;
|
||
}
|
||
|
||
}
|