|
|
|
|
package com.engine.organization.service.impl;
|
|
|
|
|
|
|
|
|
|
import com.api.browser.bean.SearchConditionGroup;
|
|
|
|
|
import com.api.browser.bean.SearchConditionItem;
|
|
|
|
|
import com.api.browser.bean.SearchConditionOption;
|
|
|
|
|
import com.api.browser.util.ConditionType;
|
|
|
|
|
import com.api.hrm.bean.HrmFieldBean;
|
|
|
|
|
import com.api.hrm.util.HrmFieldSearchConditionComInfo;
|
|
|
|
|
import com.cloudstore.eccom.result.WeaResultMsg;
|
|
|
|
|
import com.engine.core.impl.Service;
|
|
|
|
|
import com.engine.hrm.util.face.HrmFaceCheckManager;
|
|
|
|
|
import com.engine.organization.component.OrganizationWeaTable;
|
|
|
|
|
import com.engine.organization.entity.DeleteParam;
|
|
|
|
|
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.hrmresource.bo.HrmRelationBO;
|
|
|
|
|
import com.engine.organization.entity.hrmresource.param.HrmRelationSaveParam;
|
|
|
|
|
import com.engine.organization.entity.hrmresource.param.SearchTemplateParam;
|
|
|
|
|
import com.engine.organization.entity.hrmresource.po.HrmRelationPO;
|
|
|
|
|
import com.engine.organization.entity.hrmresource.po.SearchTemplatePO;
|
|
|
|
|
import com.engine.organization.entity.hrmresource.vo.HrmResourceVO;
|
|
|
|
|
import com.engine.organization.entity.jclimport.po.CusFormFieldPO;
|
|
|
|
|
import com.engine.organization.entity.job.bo.JobBO;
|
|
|
|
|
import com.engine.organization.entity.job.po.JobPO;
|
|
|
|
|
import com.engine.organization.entity.searchtree.SearchTree;
|
|
|
|
|
import com.engine.organization.entity.searchtree.SearchTreeParams;
|
|
|
|
|
import com.engine.organization.enums.HrmGroupEnum;
|
|
|
|
|
import com.engine.organization.mapper.comp.CompMapper;
|
|
|
|
|
import com.engine.organization.mapper.department.DepartmentMapper;
|
|
|
|
|
import com.engine.organization.mapper.hrmresource.HrmRelationMapper;
|
|
|
|
|
import com.engine.organization.mapper.hrmresource.SystemDataMapper;
|
|
|
|
|
import com.engine.organization.mapper.job.JobMapper;
|
|
|
|
|
import com.engine.organization.mapper.resource.HrmResourceMapper;
|
|
|
|
|
import com.engine.organization.service.HrmResourceService;
|
|
|
|
|
import com.engine.organization.util.HasRightUtil;
|
|
|
|
|
import com.engine.organization.util.MenuBtn;
|
|
|
|
|
import com.engine.organization.util.OrganizationAssert;
|
|
|
|
|
import com.engine.organization.util.db.DBType;
|
|
|
|
|
import com.engine.organization.util.db.MapperProxyFactory;
|
|
|
|
|
import com.engine.organization.util.detach.DetachUtil;
|
|
|
|
|
import com.engine.organization.util.page.PageUtil;
|
|
|
|
|
import com.engine.organization.util.tree.SearchTreeUtil;
|
|
|
|
|
import org.apache.commons.collections.CollectionUtils;
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
import org.json.JSONException;
|
|
|
|
|
import org.json.JSONObject;
|
|
|
|
|
import weaver.conn.RecordSet;
|
|
|
|
|
import weaver.general.StringUtil;
|
|
|
|
|
import weaver.general.Util;
|
|
|
|
|
import weaver.hrm.definedfield.HrmFieldManager;
|
|
|
|
|
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @author:dxfeng
|
|
|
|
|
* @createTime: 2022/06/20
|
|
|
|
|
* @version: 1.0
|
|
|
|
|
*/
|
|
|
|
|
public class HrmResourceServiceImpl extends Service implements HrmResourceService {
|
|
|
|
|
/**
|
|
|
|
|
* 左侧树 类型表示
|
|
|
|
|
* <p>
|
|
|
|
|
* 0:集团
|
|
|
|
|
* 1:分部
|
|
|
|
|
* 2:部门
|
|
|
|
|
* 3:岗位
|
|
|
|
|
*/
|
|
|
|
|
private static final String TYPE_COMP = "1";
|
|
|
|
|
private static final String TYPE_DEPT = "2";
|
|
|
|
|
private static final String TYPE_JOB = "3";
|
|
|
|
|
|
|
|
|
|
private static final String RIGHT_NAME = "Roster:All";
|
|
|
|
|
|
|
|
|
|
private HrmRelationMapper getHrmRelationMapper() {
|
|
|
|
|
return MapperProxyFactory.getProxy(HrmRelationMapper.class);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private DepartmentMapper getDepartmentMapper() {
|
|
|
|
|
return MapperProxyFactory.getProxy(DepartmentMapper.class);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private CompMapper getCompMapper() {
|
|
|
|
|
return MapperProxyFactory.getProxy(CompMapper.class);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private JobMapper getJobMapper() {
|
|
|
|
|
return MapperProxyFactory.getProxy(JobMapper.class);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private HrmResourceMapper getHrmResourceMapper() {
|
|
|
|
|
return MapperProxyFactory.getProxy(HrmResourceMapper.class);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private SystemDataMapper getSystemDataMapper() {
|
|
|
|
|
return MapperProxyFactory.getProxy(SystemDataMapper.class);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@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(Map<String, Object> params) {
|
|
|
|
|
OrganizationWeaTable<HrmResourceVO> table = new OrganizationWeaTable<>(user, HrmResourceVO.class);
|
|
|
|
|
String sqlWhere = buildSqlWhere(params);
|
|
|
|
|
table.setSqlwhere(sqlWhere);
|
|
|
|
|
WeaResultMsg result = new WeaResultMsg(false);
|
|
|
|
|
result.putAll(table.makeDataResult());
|
|
|
|
|
result.success();
|
|
|
|
|
return new HashMap<>(result.getResultMap());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Map<String, Object> getSaveForm() {
|
|
|
|
|
Map<String, Object> apiDatas = new HashMap<>();
|
|
|
|
|
List<SearchConditionGroup> addGroups = new ArrayList<>();
|
|
|
|
|
apiDatas.put("condition", addGroups);
|
|
|
|
|
return apiDatas;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Long saveBaseForm(Map<String, Object> params) {
|
|
|
|
|
return 0L;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Map<String, Object> getBaseForm(Map<String, Object> params) {
|
|
|
|
|
return new HashMap<>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public int updateForm(Map<String, Object> params) {
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Integer saveSearchTemplate(SearchTemplateParam params) {
|
|
|
|
|
SearchTemplatePO templatePO = buildSearchTemplateByFields(params.getFields());
|
|
|
|
|
if (null == templatePO) {
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
templatePO.setName(params.getShowname());
|
|
|
|
|
templatePO.setCreator(user.getUID());
|
|
|
|
|
templatePO.setCreateTime(new Date());
|
|
|
|
|
templatePO.setUpdateTime(new Date());
|
|
|
|
|
getHrmResourceMapper().insertSearchTemplate(templatePO);
|
|
|
|
|
return templatePO.getId();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void deleteSearchTemplate(Integer id) {
|
|
|
|
|
getHrmResourceMapper().deleteSearchTemplate(id, user.getUID());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Map<String, Object> getSearchCondition(Map<String, Object> params) {
|
|
|
|
|
String templateId = Util.null2String(params.get("templateId"));
|
|
|
|
|
String selectKeys = Util.null2String(params.get("selectKeys"));
|
|
|
|
|
if (StringUtils.isBlank(templateId)) {
|
|
|
|
|
templateId = "-1";
|
|
|
|
|
}
|
|
|
|
|
Map<String, Object> apiDatas = new HashMap<>();
|
|
|
|
|
List<SearchConditionGroup> addGroups = new ArrayList<>();
|
|
|
|
|
List<SearchConditionGroup> allConditions = getAllConditions();
|
|
|
|
|
// 穿梭框ID,展示所选字段信息
|
|
|
|
|
HrmFieldSearchConditionComInfo hrmFieldSearchConditionComInfo = new HrmFieldSearchConditionComInfo();
|
|
|
|
|
if ("-1".equals(templateId)) {
|
|
|
|
|
if (StringUtils.isNotBlank(selectKeys)) {
|
|
|
|
|
SearchTemplatePO templatePO = buildSearchTemplateByFields(selectKeys);
|
|
|
|
|
if (null != templatePO) {
|
|
|
|
|
buildSearchConditionGroup(templatePO, hrmFieldSearchConditionComInfo, addGroups);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
// 未选择模板展示默认模板搜索条件
|
|
|
|
|
if (CollectionUtils.isNotEmpty(allConditions)) {
|
|
|
|
|
addGroups.add(allConditions.get(0));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
// 选择模板则遍历所选模板所选字段
|
|
|
|
|
SearchTemplatePO searchTemplateById = getHrmResourceMapper().getSearchTemplateById(templateId);
|
|
|
|
|
buildSearchConditionGroup(searchTemplateById, hrmFieldSearchConditionComInfo, addGroups);
|
|
|
|
|
}
|
|
|
|
|
apiDatas.put("defaultcondition", addGroups);
|
|
|
|
|
apiDatas.put("conditions", allConditions);
|
|
|
|
|
List<SearchTemplateParam> searchTemplate = getSearchTemplate();
|
|
|
|
|
String finalTemplateId = templateId;
|
|
|
|
|
searchTemplate.forEach(item -> {
|
|
|
|
|
if (finalTemplateId.equals(item.getKey())) {
|
|
|
|
|
item.setSelected(true);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
apiDatas.put("templates", searchTemplate);
|
|
|
|
|
return apiDatas;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Map<String, Object> getHasRight() {
|
|
|
|
|
Map<String, Object> btnDatas = new HashMap<>();
|
|
|
|
|
if (HasRightUtil.hasRight(user, RIGHT_NAME, true)) {
|
|
|
|
|
ArrayList<MenuBtn> topMenuList = new ArrayList<>();
|
|
|
|
|
ArrayList<MenuBtn> rightMenuList = new ArrayList<>();
|
|
|
|
|
topMenuList.add(MenuBtn.builder().isBatch("1").isTop("1").menuFun("new").menuIcon("icon-coms-New-Flow").menuName("新建人员").type("BTN_Addnew").build());
|
|
|
|
|
topMenuList.add(MenuBtn.builder().isBatch("1").isTop("1").menuFun("customization").menuIcon("icon-coms-task-list").menuName("列定制").type("BTN_COLUMN").build());
|
|
|
|
|
btnDatas.put("topMenu", topMenuList);
|
|
|
|
|
rightMenuList.add(MenuBtn.builder().isBatch("1").isTop("1").menuFun("new").menuIcon("icon-coms-New-Flow").menuName("新建人员").type("BTN_Addnew").build());
|
|
|
|
|
rightMenuList.add(MenuBtn.builder().isBatch("0").isTop("0").menuFun("custom").menuIcon("icon-coms-task-list").menuName("显示列定制").type("BTN_COLUMN").build());
|
|
|
|
|
rightMenuList.add(MenuBtn.rightMenu_btnLog());
|
|
|
|
|
btnDatas.put("rightMenu", rightMenuList);
|
|
|
|
|
}
|
|
|
|
|
btnDatas.put("hasRight", true);
|
|
|
|
|
return btnDatas;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Map<String, Object> getTabForm(Map<String, Object> params) {
|
|
|
|
|
String viewAttrStr = (String) params.get("viewAttr");
|
|
|
|
|
OrganizationAssert.notBlank(viewAttrStr, "未指定操作类型,请确认");
|
|
|
|
|
String id = Util.null2String(params.get("id"));
|
|
|
|
|
OrganizationAssert.notBlank(id, "数据有误,请确认");
|
|
|
|
|
int viewAttr = Integer.parseInt(viewAttrStr);
|
|
|
|
|
Map<String, Object> apiDatas = new HashMap<>();
|
|
|
|
|
|
|
|
|
|
//List<SearchConditionGroup> addGroups = new ArrayList<>();
|
|
|
|
|
//SearchConditionItem schemeId = OrganizationFormItemUtil.browserItem(user, 2, 17, viewAttr, false, "等级方案", "161", "schemeId", "schemeBrowser");
|
|
|
|
|
//schemeId.setRules("required");
|
|
|
|
|
//SearchConditionItem gradeId = OrganizationFormItemUtil.browserItem(user, 2, 17, viewAttr, false, "职级", "161", "gradeId", "gradeBrowser");
|
|
|
|
|
//gradeId.setRules("required");
|
|
|
|
|
//SearchConditionItem levelId = OrganizationFormItemUtil.browserItem(user, 2, 17, viewAttr, false, "职等", "162", "levelId", "levelBrowser");
|
|
|
|
|
//levelId.setRules("required");
|
|
|
|
|
//SearchConditionItem sequenceId = OrganizationFormItemUtil.browserItem(user, 2, 17, viewAttr, false, "岗位序列", "161", "sequenceId", "sequenceBrowser");
|
|
|
|
|
//sequenceId.setRules("required");
|
|
|
|
|
//SearchConditionItem postId = OrganizationFormItemUtil.browserItem(user, 2, 17, viewAttr, false, "职务分类", "161", "postId", "postBrowser");
|
|
|
|
|
//postId.setRules("required");
|
|
|
|
|
//SearchConditionItem postInfoId = OrganizationFormItemUtil.browserItem(user, 2, 17, viewAttr, false, "职务信息", "161", "postInfoId", "postInfoBrowser");
|
|
|
|
|
//postInfoId.setRules("required");
|
|
|
|
|
//SearchConditionItem companyId = OrganizationFormItemUtil.browserItem(user, 2, 17, viewAttr, false, "分部", "164", "companyId", "");
|
|
|
|
|
//companyId.setRules("required");
|
|
|
|
|
//SearchConditionItem departmentId = OrganizationFormItemUtil.browserItem(user, 2, 17, viewAttr, false, "部门", "4", "departmentId", "");
|
|
|
|
|
//departmentId.setRules("required");
|
|
|
|
|
//SearchConditionItem jobId = OrganizationFormItemUtil.browserItem(user, 2, 17, viewAttr, false, "岗位", "161", "jobId", "jobBrowser");
|
|
|
|
|
//jobId.setRules("required");
|
|
|
|
|
//
|
|
|
|
|
//
|
|
|
|
|
//// 编辑状态下赋值操作
|
|
|
|
|
//HrmRelationPO relationPO = getHrmRelationMapper().getRelationById(Long.parseLong(id));
|
|
|
|
|
//if (null != relationPO) {
|
|
|
|
|
// setBrowserValue(schemeId, relationPO.getSchemeId(), getSchemeMapper().listSchemesByIds(Stream.of(relationPO.getSchemeId()).collect(Collectors.toList())), null, null);
|
|
|
|
|
// setBrowserValue(gradeId, relationPO.getGradeId(), getGradeMapper().listGradessByIds(Stream.of(relationPO.getGradeId()).collect(Collectors.toList())), "scheme_id", relationPO.getSchemeId());
|
|
|
|
|
// setBrowserValue(levelId, relationPO.getLevelId(), getLevelMapper().listLevelsByIds(DeleteParam.builder().ids(relationPO.getLevelId()).build().getIds()), "grade_id", relationPO.getGradeId());
|
|
|
|
|
// setBrowserValue(sequenceId, relationPO.getSequenceId(), getSequenceMapper().listSequencesByIds(Stream.of(relationPO.getSequenceId()).collect(Collectors.toList())), "scheme_id", relationPO.getSchemeId());
|
|
|
|
|
// setBrowserValue(postId, relationPO.getPostId(), getPostMapper().listPostsByIds(Stream.of(relationPO.getPostId()).collect(Collectors.toList())), null, null);
|
|
|
|
|
// setBrowserValue(postInfoId, relationPO.getPostInfoId(), getPostInfoMapper().listPostInfosByIds(Stream.of(relationPO.getPostInfoId()).collect(Collectors.toList())), "post_id", relationPO.getPostId());
|
|
|
|
|
//
|
|
|
|
|
// List<Map<String, Object>> companyMaps = new ArrayList<>();
|
|
|
|
|
// String scCompanyNameById = MapperProxyFactory.getProxy(SystemDataMapper.class).getScCompanyNameById(relationPO.getCompanyId().toString());
|
|
|
|
|
// Map<String, Object> companyMap = new HashMap<>();
|
|
|
|
|
// companyMap.put(relationPO.getCompanyId().toString(), scCompanyNameById);
|
|
|
|
|
// companyMaps.add(companyMap);
|
|
|
|
|
// setBrowserValue(companyId, relationPO.getCompanyId(), companyMaps, null, null);
|
|
|
|
|
//
|
|
|
|
|
// List<Map<String, Object>> departmentMaps = new ArrayList<>();
|
|
|
|
|
// String departmentNameById = MapperProxyFactory.getProxy(SystemDataMapper.class).getScDepartmentNameById(relationPO.getDepartmentId().toString());
|
|
|
|
|
// Map<String, Object> departmentMap = new HashMap<>();
|
|
|
|
|
// departmentMap.put(relationPO.getDepartmentId().toString(), departmentNameById);
|
|
|
|
|
// departmentMaps.add(departmentMap);
|
|
|
|
|
// setBrowserValue(departmentId, relationPO.getDepartmentId(), departmentMaps, "subcompany1", relationPO.getCompanyId());
|
|
|
|
|
//
|
|
|
|
|
// setBrowserValue(jobId, relationPO.getJobId(), getJobMapper().listJobsByIds(Stream.of(relationPO.getJobId()).collect(Collectors.toList())), "departmentid", relationPO.getDepartmentId());
|
|
|
|
|
//}
|
|
|
|
|
//
|
|
|
|
|
//addGroups.add(new SearchConditionGroup("岗职位体系", true, Stream.of(schemeId, gradeId, levelId, sequenceId, postId, postInfoId).collect(Collectors.toList())));
|
|
|
|
|
//addGroups.add(new SearchConditionGroup("组织机构", true, Stream.of(companyId, departmentId, jobId).collect(Collectors.toList())));
|
|
|
|
|
//HashMap<String, Object> buttonsMap = new HashMap<>();
|
|
|
|
|
//buttonsMap.put("hasEdit", true);
|
|
|
|
|
//buttonsMap.put("hasSave", true);
|
|
|
|
|
//apiDatas.put("buttons", buttonsMap);
|
|
|
|
|
//apiDatas.put("conditions", addGroups);
|
|
|
|
|
return apiDatas;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public long saveTabForm(HrmRelationSaveParam params) {
|
|
|
|
|
HrmRelationPO hrmRelationPO = HrmRelationBO.convertSaveParamToPO(params);
|
|
|
|
|
hrmRelationPO.setCreator((long) user.getUID());
|
|
|
|
|
hrmRelationPO.setCreateTime(new Date());
|
|
|
|
|
hrmRelationPO.setDeleteType(0);
|
|
|
|
|
getHrmRelationMapper().insertIgnoreNull(hrmRelationPO);
|
|
|
|
|
return hrmRelationPO.getId();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public long updateTabForm(HrmRelationSaveParam params) {
|
|
|
|
|
HrmRelationPO hrmRelationPO = HrmRelationBO.convertSaveParamToPO(params);
|
|
|
|
|
// 判断新增OR更新
|
|
|
|
|
HrmRelationPO relationPO = getHrmRelationMapper().getRelationById(params.getId());
|
|
|
|
|
if (null == relationPO) {
|
|
|
|
|
hrmRelationPO.setCreator((long) user.getUID());
|
|
|
|
|
hrmRelationPO.setCreateTime(new Date());
|
|
|
|
|
hrmRelationPO.setDeleteType(0);
|
|
|
|
|
getHrmRelationMapper().insertIgnoreNull(hrmRelationPO);
|
|
|
|
|
} else {
|
|
|
|
|
hrmRelationPO.setUpdateTime(new Date());
|
|
|
|
|
getHrmRelationMapper().updateHrmRelation(hrmRelationPO);
|
|
|
|
|
}
|
|
|
|
|
RecordSet rs = new RecordSet();
|
|
|
|
|
rs.execute("update HrmResource set subcompanyid1 = " + params.getCompanyId() + " ,departmentid = " + params.getDepartmentId() + " ,jobtitle = " + params.getJobId() + " where id = " + params.getId());
|
|
|
|
|
HrmFaceCheckManager.sync(params.getId().toString(), HrmFaceCheckManager.getOptUpdate(), "hrm_e9_HrmResourceBaseService_editResourceBase", HrmFaceCheckManager.getOaResource());
|
|
|
|
|
return hrmRelationPO.getId();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 查询条件
|
|
|
|
|
*
|
|
|
|
|
* @param params
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
private String buildSqlWhere(Map<String, Object> params) {
|
|
|
|
|
HrmFieldSearchConditionComInfo hrmFieldSearchConditionComInfo = new HrmFieldSearchConditionComInfo();
|
|
|
|
|
List<SearchConditionItem> conditionItems = new ArrayList<>();
|
|
|
|
|
List<CusFormFieldPO> hrmFieldsByScopeId = getSystemDataMapper().getHrmFieldsByScopeId(HrmGroupEnum.HRM_BASIC.getGroupType().toString());
|
|
|
|
|
createConditionItems(hrmFieldSearchConditionComInfo, hrmFieldsByScopeId, conditionItems);
|
|
|
|
|
hrmFieldsByScopeId = getSystemDataMapper().getHrmFieldsByScopeId(HrmGroupEnum.HRM_PERSONAL.getGroupType().toString());
|
|
|
|
|
createConditionItems(hrmFieldSearchConditionComInfo, hrmFieldsByScopeId, conditionItems);
|
|
|
|
|
hrmFieldsByScopeId = getSystemDataMapper().getHrmFieldsByScopeId(HrmGroupEnum.HRM_WORK.getGroupType().toString());
|
|
|
|
|
createConditionItems(hrmFieldSearchConditionComInfo, hrmFieldsByScopeId, conditionItems);
|
|
|
|
|
Map<String, SearchConditionItem> allFieldsMap = conditionItems.stream().collect(Collectors.toMap(item -> item.getDomkey()[0], item -> item, (k1, k2) -> k1));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DBType dbType = DBType.get(new RecordSet().getDBType());
|
|
|
|
|
//String sqlWhere = "";
|
|
|
|
|
StringBuilder sb = new StringBuilder(" where 1=1 ");
|
|
|
|
|
for (Map.Entry<String, Object> entry : params.entrySet()) {
|
|
|
|
|
String value = Util.null2String(entry.getValue());
|
|
|
|
|
if (StringUtils.isBlank(value)) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
String key = entry.getKey();
|
|
|
|
|
SearchConditionItem searchConditionItem = allFieldsMap.get(key);
|
|
|
|
|
buildDynamicSql(searchConditionItem, key, value, sb, dbType);
|
|
|
|
|
// 根据不同的类型,不同的查询方式
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 分权查询
|
|
|
|
|
DetachUtil detachUtil = new DetachUtil(user);
|
|
|
|
|
String parentCompanyIds = detachUtil.getJclRoleLevels();
|
|
|
|
|
if (detachUtil.isDETACH()) {
|
|
|
|
|
sb.append(" And t.subcompanyid1 in(").append(parentCompanyIds).append(")");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return sb.toString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<SearchTree> getFilterCompany(String id, String type, String keyword) {
|
|
|
|
|
List<SearchTree> searchTree = new ArrayList<>();
|
|
|
|
|
// 通过分部、公司 组装数据
|
|
|
|
|
if (StringUtil.isEmpty(id) || TYPE_COMP.equals(type)) {
|
|
|
|
|
Integer parentCompId = StringUtil.isEmpty(id) ? null : Integer.parseInt(id);
|
|
|
|
|
DepartmentPO departmentBuild = DepartmentPO.builder().departmentName(keyword).subCompanyId1(parentCompId).canceled(0).build();
|
|
|
|
|
CompPO compBuild = CompPO.builder().subCompanyName(keyword).supSubComId(parentCompId).canceled(0).build();
|
|
|
|
|
// 所属分部下的岗位
|
|
|
|
|
JobPO jobBuild = JobPO.builder().jobTitleName(keyword).ecCompany(parentCompId).forbiddenTag(0).build();
|
|
|
|
|
searchTree = buildTreeByCompAndDept(departmentBuild, compBuild, jobBuild);
|
|
|
|
|
} else if (TYPE_DEPT.equals(type)) {
|
|
|
|
|
Integer parentDeptId = Integer.parseInt(id);
|
|
|
|
|
DepartmentPO departmentBuild = DepartmentPO.builder().departmentName(keyword).supDepId(parentDeptId).canceled(0).build();
|
|
|
|
|
// 所属分部下的岗位
|
|
|
|
|
JobPO jobBuild = JobPO.builder().jobTitleName(keyword).ecDepartment(parentDeptId).forbiddenTag(0).build();
|
|
|
|
|
searchTree = buildTreeByDeptAndJob(departmentBuild, jobBuild);
|
|
|
|
|
|
|
|
|
|
} else if (TYPE_JOB.equals(type)) {
|
|
|
|
|
// 查询部门信息
|
|
|
|
|
List<JobPO> filterDeparts = getJobMapper().listPOsByFilter(JobPO.builder().jobTitleName(keyword).parentJob(Long.parseLong(id)).forbiddenTag(0).build());
|
|
|
|
|
Set<JobPO> builderJobs = new HashSet<>();
|
|
|
|
|
for (JobPO departmentPO : filterDeparts) {
|
|
|
|
|
buildParentJobs(departmentPO, builderJobs);
|
|
|
|
|
}
|
|
|
|
|
searchTree = SearchTreeUtil.builderTreeMode(JobBO.buildSetToSearchTree(builderJobs));
|
|
|
|
|
}
|
|
|
|
|
return searchTree;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 分部、部门 组装左侧树
|
|
|
|
|
*
|
|
|
|
|
* @param departmentBuild
|
|
|
|
|
* @param compBuild
|
|
|
|
|
* @param jobBuild
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
private List<SearchTree> buildTreeByCompAndDept(DepartmentPO departmentBuild, CompPO compBuild, JobPO jobBuild) {
|
|
|
|
|
List<JobPO> jobPOS = getJobMapper().listPOsByFilter(jobBuild);
|
|
|
|
|
new DetachUtil(user).filterJobList(jobPOS);
|
|
|
|
|
List<DepartmentPO> filterDeparts = getDepartmentMapper().listByFilter(departmentBuild, "showorder");
|
|
|
|
|
new DetachUtil(user).filterDepartmentList(filterDeparts);
|
|
|
|
|
// 添加父级岗位
|
|
|
|
|
Set<JobPO> builderJobs = new HashSet<>();
|
|
|
|
|
for (JobPO jobPO : jobPOS) {
|
|
|
|
|
buildParentJobs(jobPO, builderJobs);
|
|
|
|
|
}
|
|
|
|
|
// 添加岗位的上级部门或分部
|
|
|
|
|
List<SearchTree> jobTrees = SearchTreeUtil.builderTreeMode(JobBO.buildSetToSearchTree(builderJobs));
|
|
|
|
|
String parentDeptS = jobTrees.stream().map(SearchTree::getParentComp).collect(Collectors.joining(","));
|
|
|
|
|
if (!StringUtil.isEmpty(parentDeptS)) {
|
|
|
|
|
// 兼容SQLServer每次最多in,2100条数据
|
|
|
|
|
List<Long> ids = DeleteParam.builder().ids(parentDeptS).build().getIds();
|
|
|
|
|
int ceilCount = (int) Math.ceil((double) ids.size() / 1000);
|
|
|
|
|
List<DepartmentPO> departmentsByIds = new ArrayList<>();
|
|
|
|
|
for (int i = 1; i < ceilCount + 1; i++) {
|
|
|
|
|
List<Long> longs = PageUtil.subList(i, 1000, ids);
|
|
|
|
|
List<DepartmentPO> departmentsById = getDepartmentMapper().getDeptsByIds(longs);
|
|
|
|
|
if (CollectionUtils.isNotEmpty(departmentsById)) {
|
|
|
|
|
departmentsByIds.addAll(departmentsById);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(departmentsByIds)) {
|
|
|
|
|
filterDeparts.addAll(departmentsByIds);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 查询分部信息
|
|
|
|
|
List<CompPO> filterComps = getCompMapper().listByFilter(compBuild, "showorder");
|
|
|
|
|
new DetachUtil(user).filterCompanyList(filterComps);
|
|
|
|
|
Set<DepartmentPO> builderDeparts = new HashSet<>();
|
|
|
|
|
for (DepartmentPO departmentPO : filterDeparts) {
|
|
|
|
|
buildParentDepts(departmentPO, builderDeparts);
|
|
|
|
|
}
|
|
|
|
|
List<SearchTree> departmentList = DepartmentBO.buildSetToSearchTree(builderDeparts);
|
|
|
|
|
List<SearchTree> deptTrees = SearchTreeUtil.builderTreeMode(departmentList);
|
|
|
|
|
List<SearchTree> searchTrees = SearchTreeUtil.builderTreeMode(departmentList, jobTrees);
|
|
|
|
|
// 添加部门的上级分部
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
List<CompPO> allCompanys = getCompMapper().listAll("showorder");
|
|
|
|
|
new DetachUtil(user).filterCompanyList(allCompanys);
|
|
|
|
|
Map<Integer, CompPO> allMaps = allCompanys.stream().collect(Collectors.toMap(CompPO::getId, item -> item, (k1, k2) -> k1));
|
|
|
|
|
Set<CompPO> builderComps = new HashSet<>();
|
|
|
|
|
for (CompPO compPO : filterComps) {
|
|
|
|
|
buildParentComps(compPO, builderComps, allMaps);
|
|
|
|
|
}
|
|
|
|
|
return SearchTreeUtil.builderTreeMode(CompBO.buildSetToSearchTree(builderComps), searchTrees);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private List<SearchTree> buildTreeByDeptAndJob(DepartmentPO departmentBuild, JobPO jobBuild) {
|
|
|
|
|
List<JobPO> jobPOS = getJobMapper().listPOsByFilter(jobBuild);
|
|
|
|
|
List<DepartmentPO> filterDeparts = getDepartmentMapper().listByFilter(departmentBuild, "showorder");
|
|
|
|
|
// 添加父级岗位
|
|
|
|
|
Set<JobPO> builderJobs = new HashSet<>();
|
|
|
|
|
for (JobPO jobPO : jobPOS) {
|
|
|
|
|
buildParentJobs(jobPO, builderJobs);
|
|
|
|
|
}
|
|
|
|
|
// 添加岗位的上级部门或分部
|
|
|
|
|
List<SearchTree> jobTrees = SearchTreeUtil.builderTreeMode(JobBO.buildSetToSearchTree(builderJobs));
|
|
|
|
|
String parentDeptS = jobTrees.stream().map(SearchTree::getParentComp).collect(Collectors.joining(","));
|
|
|
|
|
if (!StringUtil.isEmpty(parentDeptS)) {
|
|
|
|
|
// 兼容SQLServer每次最多in,2100条数据
|
|
|
|
|
List<Long> ids = (List<Long>) DeleteParam.builder().ids(parentDeptS).build().getIds();
|
|
|
|
|
int ceilCount = (int) Math.ceil((double) ids.size() / 1000);
|
|
|
|
|
List<DepartmentPO> departmentsByIds = new ArrayList<>();
|
|
|
|
|
for (int i = 0; i < ceilCount - 1; i++) {
|
|
|
|
|
List<DepartmentPO> departmentsById = getDepartmentMapper().getDeptsByIds(PageUtil.subList(i, 1000, ids));
|
|
|
|
|
if (CollectionUtils.isNotEmpty(departmentsById)) {
|
|
|
|
|
departmentsByIds.addAll(departmentsById);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(departmentsByIds)) {
|
|
|
|
|
filterDeparts.addAll(departmentsByIds);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 查询分部信息
|
|
|
|
|
Set<DepartmentPO> builderDeparts = new HashSet<>();
|
|
|
|
|
for (DepartmentPO departmentPO : filterDeparts) {
|
|
|
|
|
buildParentDepts(departmentPO, builderDeparts);
|
|
|
|
|
}
|
|
|
|
|
return SearchTreeUtil.builderTreeMode(DepartmentBO.buildSetToSearchTree(builderDeparts), jobTrees);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void buildParentJobs(JobPO jobPO, Set<JobPO> builderJobs) {
|
|
|
|
|
builderJobs.add(jobPO);
|
|
|
|
|
if (SearchTreeUtil.isTop(jobPO.getParentJob())) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
JobPO parentJob = getJobMapper().getJobById(jobPO.getParentJob());
|
|
|
|
|
if (null != parentJob) {
|
|
|
|
|
buildParentJobs(parentJob, builderJobs);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 添加查询元素的父级元素
|
|
|
|
|
*
|
|
|
|
|
* @param departmentPO
|
|
|
|
|
* @param builderDeparts
|
|
|
|
|
*/
|
|
|
|
|
private void buildParentDepts(DepartmentPO departmentPO, Set<DepartmentPO> builderDeparts) {
|
|
|
|
|
builderDeparts.add(departmentPO);
|
|
|
|
|
if (SearchTreeUtil.isTop(departmentPO.getSupDepId())) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
DepartmentPO parentDept = getDepartmentMapper().getDeptById(departmentPO.getSupDepId());
|
|
|
|
|
if (null != parentDept) {
|
|
|
|
|
buildParentDepts(parentDept, builderDeparts);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 添加查询元素的父级元素
|
|
|
|
|
*
|
|
|
|
|
* @param compPO
|
|
|
|
|
* @param builderComps
|
|
|
|
|
*/
|
|
|
|
|
private void buildParentComps(CompPO compPO, Set<CompPO> builderComps, Map<Integer, CompPO> allMaps) {
|
|
|
|
|
builderComps.add(compPO);
|
|
|
|
|
CompPO parentComp = allMaps.get(compPO.getSupSubComId());
|
|
|
|
|
if (null != parentComp) {
|
|
|
|
|
buildParentComps(parentComp, builderComps, allMaps);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取当前人员所有的模板信息
|
|
|
|
|
*
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public List<SearchTemplateParam> getSearchTemplate() {
|
|
|
|
|
int userUID = user.getUID();
|
|
|
|
|
// 根据ID查询所存储的模板
|
|
|
|
|
List<SearchTemplateParam> templates = getHrmResourceMapper().getSearchTemplatesByUser(userUID);
|
|
|
|
|
templates.add(0, SearchTemplateParam.builder().key("-1").selected(false).showname("默认模板").build());
|
|
|
|
|
return templates;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取所有搜索字段信息构建的高级搜索表单
|
|
|
|
|
*
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public List<SearchConditionGroup> getAllConditions() {
|
|
|
|
|
HrmFieldSearchConditionComInfo hrmFieldSearchConditionComInfo = new HrmFieldSearchConditionComInfo();
|
|
|
|
|
List<SearchConditionGroup> addGroups = new ArrayList<>();
|
|
|
|
|
List<SearchConditionItem> basicConditionItems = new ArrayList<>();
|
|
|
|
|
List<SearchConditionItem> personalConditionItems = new ArrayList<>();
|
|
|
|
|
List<SearchConditionItem> workConditionItems = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
// 基本信息:-1
|
|
|
|
|
List<CusFormFieldPO> hrmFieldsByScopeId = getSystemDataMapper().getHrmFieldsByScopeId(HrmGroupEnum.HRM_BASIC.getGroupType().toString());
|
|
|
|
|
createConditionItems(hrmFieldSearchConditionComInfo, hrmFieldsByScopeId, basicConditionItems);
|
|
|
|
|
if (CollectionUtils.isNotEmpty(basicConditionItems)) {
|
|
|
|
|
addGroups.add(new SearchConditionGroup("基本信息", true, basicConditionItems));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 个人信息:1
|
|
|
|
|
hrmFieldsByScopeId = getSystemDataMapper().getHrmFieldsByScopeId(HrmGroupEnum.HRM_PERSONAL.getGroupType().toString());
|
|
|
|
|
createConditionItems(hrmFieldSearchConditionComInfo, hrmFieldsByScopeId, personalConditionItems);
|
|
|
|
|
if (CollectionUtils.isNotEmpty(personalConditionItems)) {
|
|
|
|
|
addGroups.add(new SearchConditionGroup("个人信息", true, personalConditionItems));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 工作信息:3
|
|
|
|
|
hrmFieldsByScopeId = getSystemDataMapper().getHrmFieldsByScopeId(HrmGroupEnum.HRM_WORK.getGroupType().toString());
|
|
|
|
|
createConditionItems(hrmFieldSearchConditionComInfo, hrmFieldsByScopeId, workConditionItems);
|
|
|
|
|
if (CollectionUtils.isNotEmpty(workConditionItems)) {
|
|
|
|
|
addGroups.add(new SearchConditionGroup("工作信息", true, workConditionItems));
|
|
|
|
|
}
|
|
|
|
|
return addGroups;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 构建查询条件Item
|
|
|
|
|
*
|
|
|
|
|
* @param hrmFieldSearchConditionComInfo
|
|
|
|
|
* @param formFields
|
|
|
|
|
* @param conditionItems
|
|
|
|
|
*/
|
|
|
|
|
private void createConditionItems(HrmFieldSearchConditionComInfo hrmFieldSearchConditionComInfo, List<CusFormFieldPO> formFields, List<SearchConditionItem> conditionItems) {
|
|
|
|
|
for (CusFormFieldPO cusFormFieldPO : formFields) {
|
|
|
|
|
HrmFieldBean hrmFieldBean = new HrmFieldBean();
|
|
|
|
|
hrmFieldBean.setFieldid(Util.null2String(cusFormFieldPO.getFieldId()));
|
|
|
|
|
hrmFieldBean.setFieldname(cusFormFieldPO.getScopeId() + "_" + cusFormFieldPO.getTableName() + "_" + cusFormFieldPO.getFieldName());
|
|
|
|
|
hrmFieldBean.setFieldlabel(cusFormFieldPO.getFieldLabel());
|
|
|
|
|
hrmFieldBean.setFieldhtmltype(Util.null2String(cusFormFieldPO.getFieldHtmlType()));
|
|
|
|
|
hrmFieldBean.setType(cusFormFieldPO.getType());
|
|
|
|
|
hrmFieldBean.setIsQuickSearch(false);
|
|
|
|
|
hrmFieldBean.setIsScope(false);
|
|
|
|
|
hrmFieldBean.setDmlurl(cusFormFieldPO.getDmlUrl());
|
|
|
|
|
hrmFieldBean.setIssystem("hrm".equals(cusFormFieldPO.getTableName()) ? "1" : "0");
|
|
|
|
|
hrmFieldBean.setIsFormField(true);
|
|
|
|
|
SearchConditionItem searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user);
|
|
|
|
|
conditionItems.add(searchConditionItem);
|
|
|
|
|
// 如果为下拉框,添加一条空选项
|
|
|
|
|
if (searchConditionItem.getConditionType().equals(ConditionType.SELECT)) {
|
|
|
|
|
addEmptyForSelect(searchConditionItem);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取模板中的字段,构建搜索条件
|
|
|
|
|
*
|
|
|
|
|
* @param hrmFieldSearchConditionComInfo
|
|
|
|
|
* @param addGroups
|
|
|
|
|
* @param title
|
|
|
|
|
* @param scopeid
|
|
|
|
|
* @param fieldNames
|
|
|
|
|
*/
|
|
|
|
|
private void getTemplateItems(HrmFieldSearchConditionComInfo hrmFieldSearchConditionComInfo, List<SearchConditionGroup> addGroups, String title, Integer scopeid, String[] fieldNames) {
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
|
|
HrmFieldManager hfm = new HrmFieldManager("HrmCustomFieldByInfoType", scopeid);
|
|
|
|
|
List<SearchConditionItem> conditionItems = new ArrayList<>();
|
|
|
|
|
for (String field : fieldNames) {
|
|
|
|
|
String fieldName = field.substring(field.lastIndexOf("_") + 1);
|
|
|
|
|
JSONObject hrmFieldConf = hfm.getHrmFieldConf(fieldName);
|
|
|
|
|
if (null == hrmFieldConf) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
boolean baseField = hfm.isBaseField(fieldName);
|
|
|
|
|
HrmFieldBean hrmFieldBean = new HrmFieldBean();
|
|
|
|
|
hrmFieldBean.setFieldid(Util.null2String(hrmFieldConf.getString("id")));
|
|
|
|
|
hrmFieldBean.setFieldname(scopeid + "_" + (baseField ? "hrm" : "cus") + "_" + fieldName);
|
|
|
|
|
hrmFieldBean.setFieldlabel(hrmFieldConf.getString("fieldlabel"));
|
|
|
|
|
hrmFieldBean.setFieldhtmltype(hrmFieldConf.getString("fieldhtmltype"));
|
|
|
|
|
hrmFieldBean.setType(hrmFieldConf.getString("type"));
|
|
|
|
|
hrmFieldBean.setDmlurl(hrmFieldConf.getString("dmlurl"));
|
|
|
|
|
hrmFieldBean.setIssystem(baseField ? "1" : "0");
|
|
|
|
|
hrmFieldBean.setIsFormField(true);
|
|
|
|
|
hrmFieldBean.setIsQuickSearch(false);
|
|
|
|
|
hrmFieldBean.setIsScope(false);
|
|
|
|
|
SearchConditionItem searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user);
|
|
|
|
|
conditionItems.add(searchConditionItem);
|
|
|
|
|
// 如果为下拉框,添加一条空选项
|
|
|
|
|
if (searchConditionItem.getConditionType().equals(ConditionType.SELECT)) {
|
|
|
|
|
addEmptyForSelect(searchConditionItem);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (CollectionUtils.isNotEmpty(conditionItems)) {
|
|
|
|
|
addGroups.add(new SearchConditionGroup(title, true, conditionItems));
|
|
|
|
|
}
|
|
|
|
|
} catch (JSONException e) {
|
|
|
|
|
throw new RuntimeException(e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 根据所选字段信息,构建搜素模板对象
|
|
|
|
|
*
|
|
|
|
|
* @param fields
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
private SearchTemplatePO buildSearchTemplateByFields(String fields) {
|
|
|
|
|
String[] split = fields.split(",");
|
|
|
|
|
if (split.length > 0) {
|
|
|
|
|
List<String> basicFields = new ArrayList<>();
|
|
|
|
|
List<String> personalFields = new ArrayList<>();
|
|
|
|
|
List<String> workFields = new ArrayList<>();
|
|
|
|
|
for (String fieldName : split) {
|
|
|
|
|
if (fieldName.startsWith(HrmGroupEnum.HRM_BASIC.getGroupType().toString())) {
|
|
|
|
|
basicFields.add(fieldName);
|
|
|
|
|
} else if (fieldName.startsWith(HrmGroupEnum.HRM_PERSONAL.getGroupType().toString())) {
|
|
|
|
|
personalFields.add(fieldName);
|
|
|
|
|
} else if (fieldName.startsWith(HrmGroupEnum.HRM_WORK.getGroupType().toString())) {
|
|
|
|
|
workFields.add(fieldName);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return SearchTemplatePO.builder().basicFields(StringUtils.join(basicFields, ",")).personalFields(StringUtils.join(personalFields, ",")).workFields(StringUtils.join(workFields, ",")).build();
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 根据搜索模板对象,构建搜索条件表单
|
|
|
|
|
*
|
|
|
|
|
* @param templatePO
|
|
|
|
|
* @param hrmFieldSearchConditionComInfo
|
|
|
|
|
* @param addGroups
|
|
|
|
|
*/
|
|
|
|
|
private void buildSearchConditionGroup(SearchTemplatePO templatePO, HrmFieldSearchConditionComInfo hrmFieldSearchConditionComInfo, List<SearchConditionGroup> addGroups) {
|
|
|
|
|
String[] basicFields = Util.null2String(templatePO.getBasicFields()).split(",");
|
|
|
|
|
if (basicFields.length > 0) {
|
|
|
|
|
getTemplateItems(hrmFieldSearchConditionComInfo, addGroups, "基本信息", HrmGroupEnum.HRM_BASIC.getGroupType(), basicFields);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String[] personalFields = Util.null2String(templatePO.getPersonalFields()).split(",");
|
|
|
|
|
if (personalFields.length > 0) {
|
|
|
|
|
getTemplateItems(hrmFieldSearchConditionComInfo, addGroups, "个人信息", HrmGroupEnum.HRM_PERSONAL.getGroupType(), personalFields);
|
|
|
|
|
}
|
|
|
|
|
String[] workFields = Util.null2String(templatePO.getWorkFields()).split(",");
|
|
|
|
|
if (workFields.length > 0) {
|
|
|
|
|
getTemplateItems(hrmFieldSearchConditionComInfo, addGroups, "工作信息", HrmGroupEnum.HRM_WORK.getGroupType(), workFields);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 根据字段信息,动态拼接where条件SQL
|
|
|
|
|
*
|
|
|
|
|
* @param conditionItem
|
|
|
|
|
* @param key
|
|
|
|
|
* @param value
|
|
|
|
|
* @param sb
|
|
|
|
|
* @param dbType
|
|
|
|
|
*/
|
|
|
|
|
private void buildDynamicSql(SearchConditionItem conditionItem, String key, String value, StringBuilder sb, DBType dbType) {
|
|
|
|
|
if (null == conditionItem) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (key.endsWith("workyear") || key.endsWith("companyworkyear")) {
|
|
|
|
|
conditionItem.setConditionType(ConditionType.INPUTNUMBER);
|
|
|
|
|
}
|
|
|
|
|
String tableSql = buildTableSql(key);
|
|
|
|
|
if (StringUtils.isBlank(tableSql)) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
switch (conditionItem.getConditionType()) {
|
|
|
|
|
case INPUT:// 单行文本框
|
|
|
|
|
case TEXTAREA:// 多行文本框
|
|
|
|
|
sb.append(" and ").append(tableSql).append(dbType.like(value));
|
|
|
|
|
// 模糊搜索
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case INPUTNUMBER:// 数字
|
|
|
|
|
case SELECT://选择框
|
|
|
|
|
case BROWSER://浏览按钮
|
|
|
|
|
case CHECKBOX:
|
|
|
|
|
case SWITCH:
|
|
|
|
|
sb.append(" and ").append(dbType.ifNull(tableSql, "0")).append(" = '").append(value).append("' ");
|
|
|
|
|
break;
|
|
|
|
|
case DATE:
|
|
|
|
|
case DATEPICKER:
|
|
|
|
|
case TIMEPICKER:
|
|
|
|
|
case RANGEPICKER:
|
|
|
|
|
// 精准搜索
|
|
|
|
|
sb.append(" and ").append(tableSql).append(" = '").append(value).append("' ");
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 处理当前字段所在表关系
|
|
|
|
|
*
|
|
|
|
|
* @param key
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
private String buildTableSql(String key) {
|
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
|
String[] s = key.split("_");
|
|
|
|
|
if (s.length < 3) {
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
String scopeId = s[0];
|
|
|
|
|
String tableName = s[1];
|
|
|
|
|
String fieldName = s[2];
|
|
|
|
|
if ("hrm".equals(tableName)) {
|
|
|
|
|
sb.append("t.").append(fieldName);
|
|
|
|
|
} else {
|
|
|
|
|
switch (scopeId) {
|
|
|
|
|
case "-1":
|
|
|
|
|
sb.append("t0.").append(fieldName);
|
|
|
|
|
break;
|
|
|
|
|
case "1":
|
|
|
|
|
sb.append("t1.").append(fieldName);
|
|
|
|
|
break;
|
|
|
|
|
case "3":
|
|
|
|
|
sb.append("t2.").append(fieldName);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
return "";
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return sb.toString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void addEmptyForSelect(SearchConditionItem searchConditionItem) {
|
|
|
|
|
searchConditionItem.setValue("");
|
|
|
|
|
List<SearchConditionOption> options = searchConditionItem.getOptions();
|
|
|
|
|
options.forEach(item -> {
|
|
|
|
|
item.setSelected(false);
|
|
|
|
|
});
|
|
|
|
|
SearchConditionOption searchConditionOption = new SearchConditionOption();
|
|
|
|
|
searchConditionOption.setSelected(true);
|
|
|
|
|
searchConditionOption.setKey("");
|
|
|
|
|
options.add(0, searchConditionOption);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|