weaver-hrm-organization/src/com/engine/organization/service/impl/HrmResourceServiceImpl.java

1347 lines
67 KiB
Java
Raw Normal View History

2022-06-20 18:31:11 +08:00
package com.engine.organization.service.impl;
import com.api.browser.bean.SearchConditionGroup;
import com.api.browser.bean.SearchConditionItem;
2023-01-09 18:06:57 +08:00
import com.api.browser.bean.SearchConditionOption;
import com.api.browser.util.ConditionType;
2023-01-06 15:35:38 +08:00
import com.api.hrm.bean.HrmFieldBean;
import com.api.hrm.util.HrmFieldSearchConditionComInfo;
2023-01-13 08:50:27 +08:00
import com.cloudstore.eccom.constant.WeaBoolAttr;
2023-01-11 14:48:24 +08:00
import com.cloudstore.eccom.pc.table.WeaTableColumn;
import com.cloudstore.eccom.result.WeaResultMsg;
2022-06-20 18:31:11 +08:00
import com.engine.core.impl.Service;
2022-07-12 16:38:27 +08:00
import com.engine.hrm.util.face.HrmFaceCheckManager;
import com.engine.organization.component.OrganizationWeaTable;
2022-06-20 18:31:11 +08:00
import com.engine.organization.entity.DeleteParam;
2023-07-05 17:36:04 +08:00
import com.engine.organization.entity.chart.ResourceListColumns;
2022-11-30 16:06:40 +08:00
import com.engine.organization.entity.company.bo.CompBO;
import com.engine.organization.entity.company.po.CompPO;
2022-06-20 18:31:11 +08:00
import com.engine.organization.entity.department.bo.DepartmentBO;
import com.engine.organization.entity.department.po.DepartmentPO;
2023-01-12 09:41:58 +08:00
import com.engine.organization.entity.extend.bo.ExtendInfoBO;
import com.engine.organization.entity.extend.po.ExtendInfoPO;
2022-07-11 15:59:15 +08:00
import com.engine.organization.entity.hrmresource.bo.HrmRelationBO;
import com.engine.organization.entity.hrmresource.bo.ResourceChartBO;
2022-07-11 15:59:15 +08:00
import com.engine.organization.entity.hrmresource.param.HrmRelationSaveParam;
2023-01-06 15:35:38 +08:00
import com.engine.organization.entity.hrmresource.param.SearchTemplateParam;
2023-07-05 17:36:04 +08:00
import com.engine.organization.entity.hrmresource.po.*;
2022-10-12 15:28:11 +08:00
import com.engine.organization.entity.hrmresource.vo.HrmResourceVO;
import com.engine.organization.entity.hrmresource.vo.ResourceChartVO;
2023-01-06 15:35:38 +08:00
import com.engine.organization.entity.jclimport.po.CusFormFieldPO;
2022-06-20 18:31:11 +08:00
import com.engine.organization.entity.job.bo.JobBO;
import com.engine.organization.entity.job.po.JobPO;
2023-08-15 17:30:20 +08:00
import com.engine.organization.entity.search.QuickSearchDetail;
2022-06-20 18:31:11 +08:00
import com.engine.organization.entity.searchtree.SearchTree;
import com.engine.organization.entity.searchtree.SearchTreeParams;
2023-01-09 18:06:57 +08:00
import com.engine.organization.enums.HrmGroupEnum;
2022-11-30 16:06:40 +08:00
import com.engine.organization.mapper.comp.CompMapper;
2023-08-15 17:30:20 +08:00
import com.engine.organization.mapper.condition.QuickSearchMapper;
2022-06-20 18:31:11 +08:00
import com.engine.organization.mapper.department.DepartmentMapper;
2022-07-11 15:59:15 +08:00
import com.engine.organization.mapper.hrmresource.HrmRelationMapper;
2022-07-12 16:38:27 +08:00
import com.engine.organization.mapper.hrmresource.SystemDataMapper;
2022-06-20 18:31:11 +08:00
import com.engine.organization.mapper.job.JobMapper;
2023-01-06 15:35:38 +08:00
import com.engine.organization.mapper.resource.HrmResourceMapper;
2023-01-12 09:41:58 +08:00
import com.engine.organization.mapper.resource.JclOrgCustomTemplateMapper;
2022-06-20 18:31:11 +08:00
import com.engine.organization.service.HrmResourceService;
2022-10-12 15:28:11 +08:00
import com.engine.organization.util.HasRightUtil;
import com.engine.organization.util.MenuBtn;
import com.engine.organization.util.OrganizationAssert;
import com.engine.organization.util.OrganizationDateUtil;
import com.engine.organization.util.db.DBType;
2022-06-20 18:31:11 +08:00
import com.engine.organization.util.db.MapperProxyFactory;
import com.engine.organization.util.detach.DetachUtil;
2022-07-26 09:40:13 +08:00
import com.engine.organization.util.page.PageUtil;
2022-06-20 18:31:11 +08:00
import com.engine.organization.util.tree.SearchTreeUtil;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
2023-01-06 15:35:38 +08:00
import org.json.JSONException;
import org.json.JSONObject;
2023-01-12 16:49:54 +08:00
import weaver.common.DateUtil;
import weaver.conn.RecordSet;
2022-06-20 18:31:11 +08:00
import weaver.general.StringUtil;
2023-08-15 17:30:20 +08:00
import weaver.general.TimeUtil;
2022-06-20 18:31:11 +08:00
import weaver.general.Util;
2023-01-06 15:35:38 +08:00
import weaver.hrm.definedfield.HrmFieldManager;
2022-06-20 18:31:11 +08:00
2023-01-13 18:10:57 +08:00
import java.math.BigDecimal;
import java.math.RoundingMode;
2023-08-16 15:59:25 +08:00
import java.time.LocalDate;
2022-06-20 18:31:11 +08:00
import java.util.*;
2023-01-12 09:41:58 +08:00
import java.util.concurrent.atomic.AtomicInteger;
2022-06-20 18:31:11 +08:00
import java.util.stream.Collectors;
import java.util.stream.IntStream;
2022-06-20 18:31:11 +08:00
2023-07-12 16:09:04 +08:00
import static weaver.general.Util.getIntValue;
2022-06-20 18:31:11 +08:00
/**
* @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";
2022-10-12 15:28:11 +08:00
private static final String RIGHT_NAME = "Roster:All";
2023-01-11 14:48:24 +08:00
2022-07-11 15:59:15 +08:00
private HrmRelationMapper getHrmRelationMapper() {
return MapperProxyFactory.getProxy(HrmRelationMapper.class);
}
2022-06-20 18:31:11 +08:00
private DepartmentMapper getDepartmentMapper() {
return MapperProxyFactory.getProxy(DepartmentMapper.class);
}
2022-11-30 16:06:40 +08:00
private CompMapper getCompMapper() {
return MapperProxyFactory.getProxy(CompMapper.class);
2022-06-20 18:31:11 +08:00
}
private JobMapper getJobMapper() {
return MapperProxyFactory.getProxy(JobMapper.class);
}
2023-01-06 15:35:38 +08:00
private HrmResourceMapper getHrmResourceMapper() {
return MapperProxyFactory.getProxy(HrmResourceMapper.class);
}
2022-10-17 17:16:26 +08:00
private SystemDataMapper getSystemDataMapper() {
return MapperProxyFactory.getProxy(SystemDataMapper.class);
}
private JclOrgCustomTemplateMapper getJclOrgCustomTemplateMapper() {
return MapperProxyFactory.getProxy(JclOrgCustomTemplateMapper.class);
}
2023-08-15 17:30:20 +08:00
private QuickSearchMapper getQuickSearchMapper() {
return MapperProxyFactory.getProxy(QuickSearchMapper.class);
}
2023-01-10 18:25:53 +08:00
// 所有满足条件的岗位ID
2023-01-11 14:26:13 +08:00
private List<Integer> jobTitleList = null;
2023-01-10 18:25:53 +08:00
// 是否
boolean searchJobTitle = false;
2022-07-11 15:59:15 +08:00
2022-06-20 18:31:11 +08:00
@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
2023-01-09 18:06:57 +08:00
public Map<String, Object> listPage(Map<String, Object> params) {
2022-10-12 15:28:11 +08:00
OrganizationWeaTable<HrmResourceVO> table = new OrganizationWeaTable<>(user, HrmResourceVO.class);
2023-01-09 18:06:57 +08:00
String sqlWhere = buildSqlWhere(params);
2022-07-04 10:01:28 +08:00
table.setSqlwhere(sqlWhere);
List<WeaTableColumn> weaTableColumnList = new ArrayList<>();
JclOrgCustomTemplatePO jclOrgCustomTemplatePO = MapperProxyFactory.getProxy(JclOrgCustomTemplateMapper.class).queryIsusedTemp("1", String.valueOf(user.getUID()));
String columns = "";
2023-01-13 16:35:34 +08:00
List<String> fields = new ArrayList<>();
List<SearchConditionGroup> allConditions = getAllConditions();
if (jclOrgCustomTemplatePO != null) {
2023-01-13 18:03:19 +08:00
if (StringUtils.isNotBlank(jclOrgCustomTemplatePO.getBasicFields())) {
columns = jclOrgCustomTemplatePO.getBasicFields();
}
if (StringUtils.isNotBlank(jclOrgCustomTemplatePO.getPersonalFields())) {
2023-01-13 16:35:34 +08:00
columns = columns + "," + jclOrgCustomTemplatePO.getPersonalFields();
2023-01-13 08:50:27 +08:00
}
if (StringUtils.isNotBlank(jclOrgCustomTemplatePO.getWorkFields())) {
2023-01-13 16:35:34 +08:00
columns = columns + "," + jclOrgCustomTemplatePO.getWorkFields();
}
} else {
//初次使用,无模板初始值
columns = "-1_hrm_lastname,-1_hrm_departmentid,-1_hrm_subcompanyid1,-1_hrm_jobtitle,-1_hrm_mobile,-1_hrm_telephone,-1_hrm_managerid,-1_hrm_sporder";
2023-01-13 08:50:27 +08:00
}
2023-01-13 16:35:34 +08:00
List<String> columnList = Arrays.asList(columns.split(","));
2023-01-13 18:10:57 +08:00
BigDecimal decimal = new BigDecimal(100 / columnList.size());
List<SearchConditionItem> all = new ArrayList<>();
2023-01-13 16:35:34 +08:00
for (SearchConditionGroup allCondition : allConditions) {
all.addAll(allCondition.getItems());
2023-01-13 08:50:27 +08:00
}
List<SearchConditionItem> items = filterByDomkey(all, columnList);
for (SearchConditionItem item : items) {
String columnName = item.getDomkey()[0];
fields.add(buildTableSql(columnName) + " as " + buildTableSql(columnName).replace(".", "_"));
String scopeId = columnName.split("_")[0];
String fieldName = columnName.substring(columnName.lastIndexOf("_") + 1);
WeaTableColumn weaTableColumn = new WeaTableColumn();
weaTableColumn.setText(getHrmResourceMapper().queryLabelName(fieldName, scopeId));
weaTableColumn.setColumn(buildTableSql(columnName).replace(".", "_"));
weaTableColumn.setDisplay(columnList.contains(columnName) ? WeaBoolAttr.TRUE : WeaBoolAttr.FALSE);
weaTableColumn.setTransmethod("com.engine.organization.transmethod.HrmResourceTransMethod.getFieldTrueValue");
weaTableColumn.setOtherpara(columnName);
weaTableColumn.setWidth(decimal.setScale(2, RoundingMode.HALF_UP).doubleValue() + "%");
weaTableColumnList.add(weaTableColumn);
}
// 增加id字段,跳转人员卡片
2023-01-13 08:50:27 +08:00
WeaTableColumn weaTableColumn = new WeaTableColumn();
weaTableColumn.setColumn("id");
weaTableColumn.setDisplay(WeaBoolAttr.FALSE);
2023-01-13 16:35:34 +08:00
weaTableColumnList.add(weaTableColumn);
fields.add("t.id");
table.setBackfields(StringUtils.join(fields, ","));
2023-01-13 08:50:27 +08:00
table.setColumns(weaTableColumnList);
WeaResultMsg result = new WeaResultMsg(false);
result.putAll(table.makeDataResult());
result.success();
2022-10-12 15:28:11 +08:00
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;
}
private List<SearchConditionItem> filterByDomkey(List<SearchConditionItem> items, List<String> domkeys) {
List<SearchConditionItem> tempResult = items.stream()
.filter(item -> domkeys.contains(item.getDomkey()[0]))
.collect(Collectors.toList());
Map<String, SearchConditionItem> hashMap = new HashMap<>();
for (SearchConditionItem item : tempResult) {
String domkeyElement = item.getDomkey()[0];
hashMap.put(domkeyElement, item);
}
List<SearchConditionItem> resultList = new ArrayList<>();
for (String domkeyElement : domkeys) {
SearchConditionItem item = hashMap.get(domkeyElement);
if (item != null) {
resultList.add(item);
}
}
return resultList;
}
@Override
2022-06-23 16:55:26 +08:00
public Long saveBaseForm(Map<String, Object> params) {
2023-01-06 15:35:38 +08:00
return 0L;
}
@Override
public Map<String, Object> getBaseForm(Map<String, Object> params) {
2023-01-06 15:35:38 +08:00
return new HashMap<>();
}
@Override
public int updateForm(Map<String, Object> params) {
return 0;
}
@Override
2023-01-10 11:37:28 +08:00
public Integer saveSearchTemplate(SearchTemplateParam params) {
2023-01-12 18:18:44 +08:00
// 重复名称校验
SearchTemplatePO searchTemplateByName = getHrmResourceMapper().getSearchTemplateByName(user.getUID(), params.getShowname());
2023-01-13 16:50:54 +08:00
OrganizationAssert.isFalse("默认模板".equals(params.getShowname()) || null != searchTemplateByName, "该模板名称已存在");
2023-01-10 16:52:40 +08:00
SearchTemplatePO templatePO = buildSearchTemplateByFields(params.getFields());
2023-01-10 11:37:28 +08:00
if (null == templatePO) {
return -1;
2022-11-16 13:39:56 +08:00
}
2023-01-10 11:37:28 +08:00
templatePO.setName(params.getShowname());
templatePO.setCreator(user.getUID());
templatePO.setCreateTime(new Date());
templatePO.setUpdateTime(new Date());
getHrmResourceMapper().insertSearchTemplate(templatePO);
return templatePO.getId();
}
2023-01-06 17:20:29 +08:00
@Override
public void deleteSearchTemplate(Integer id) {
getHrmResourceMapper().deleteSearchTemplate(id, user.getUID());
}
2023-01-10 15:13:33 +08:00
@Override
public String getTemplateSelectKeys(Map<String, Object> params) {
String templateId = Util.null2String(params.get("templateId"));
2023-01-11 16:28:19 +08:00
templateId = StringUtils.isBlank(templateId) ? "-1" : templateId;
String type = Util.null2String(params.get("type"));
2023-01-10 15:13:33 +08:00
OrganizationAssert.isTrue(StringUtils.isNotBlank(templateId), "数据有误,未找到对应数据");
// 判断是否为搜索模板
2023-01-11 16:28:19 +08:00
SearchTemplatePO searchTemplateById;
List<String> selectKeys;
if ("custom".equals(type)) {
if ("-1".equals(templateId)) {
selectKeys = Arrays.asList("-1_hrm_lastname,-1_hrm_departmentid,-1_hrm_jobtitle,-1_hrm_mobile,-1_hrm_telephone,-1_hrm_managerid".split(","));
} else {
searchTemplateById = getHrmResourceMapper().getCustomTemplateById(templateId);
selectKeys = getSelectKeys(searchTemplateById);
2023-01-10 15:13:33 +08:00
}
2023-01-11 15:42:41 +08:00
} else {
2023-01-11 16:28:19 +08:00
if ("-1".equals(templateId)) {
selectKeys = getAllConditions().get(0).getItems().stream().map(item -> item.getDomkey()[0]).collect(Collectors.toList());
} else {
searchTemplateById = getHrmResourceMapper().getSearchTemplateById(templateId);
selectKeys = getSelectKeys(searchTemplateById);
2023-01-10 15:13:33 +08:00
}
}
2023-01-11 15:42:41 +08:00
return StringUtils.join(selectKeys, ",");
2023-01-10 15:13:33 +08:00
}
2023-01-10 16:52:40 +08:00
@Override
2023-01-16 17:19:59 +08:00
public Map<String, Object> getSearchTemplate(Map<String, Object> params) {
Map<String, Object> returnMap = new HashMap<>();
2023-01-11 16:28:19 +08:00
String type = Util.null2String(params.get("type"));
2023-01-10 16:52:40 +08:00
int userUID = user.getUID();
// 根据ID查询所存储的模板
2023-01-11 16:28:19 +08:00
List<SearchTemplateParam> templates;
if ("custom".equals(type)) {
templates = getHrmResourceMapper().getCustomTemplatesByUser(userUID);
2023-01-16 17:19:59 +08:00
SearchTemplatePO usedCustomTemplate = getHrmResourceMapper().getUsedCustomTemplateByUser(user.getUID());
if (null != usedCustomTemplate) {
2023-01-17 09:30:51 +08:00
returnMap.put("templateId", usedCustomTemplate.getId().toString());
2023-01-16 17:19:59 +08:00
} else {
returnMap.put("templateId", "-1");
}
2023-01-11 16:28:19 +08:00
} else {
templates = getHrmResourceMapper().getSearchTemplatesByUser(userUID);
}
2023-01-12 15:45:43 +08:00
templates.add(0, SearchTemplateParam.builder().key("-1").showname("默认模板").build());
2023-01-16 17:19:59 +08:00
returnMap.put("templates", templates);
return returnMap;
2023-01-10 16:52:40 +08:00
}
2023-01-10 18:25:53 +08:00
@Override
public Integer saveCustomTemplate(SearchTemplateParam params) {
2023-01-12 18:18:44 +08:00
// 重复名称校验
SearchTemplatePO searchTemplateByName = getHrmResourceMapper().getCustomTemplateByName(user.getUID(), params.getShowname());
2023-01-13 16:50:54 +08:00
OrganizationAssert.isFalse("默认模板".equals(params.getShowname()) || null != searchTemplateByName, "该模板名称已存在");
2023-01-10 18:25:53 +08:00
SearchTemplatePO templatePO = buildSearchTemplateByFields(params.getFields());
if (null == templatePO) {
return -1;
}
templatePO.setName(params.getShowname());
templatePO.setCreator(user.getUID());
templatePO.setIsused("0");
2023-01-10 18:25:53 +08:00
templatePO.setCreateTime(new Date());
templatePO.setUpdateTime(new Date());
getHrmResourceMapper().insertCustomTemplate(templatePO);
return templatePO.getId();
}
@Override
public Integer updateCustomTemplate(Map<String, Object> params) {
2023-07-12 16:09:04 +08:00
int rowNum = getIntValue((String) params.get("rownum"));
int count = 0;
2023-01-13 18:40:34 +08:00
List<Long> allIds = getJclOrgCustomTemplateMapper().listAllId();
String currentDate = OrganizationDateUtil.getFormatLocalDate(new java.util.Date());
2023-01-13 18:40:34 +08:00
List<String> nameList = new ArrayList<>();
for (int i = 0; i < rowNum; i++) {
String recordIndex = "_" + i;
String name = Util.null2String(params.get("name" + recordIndex));
if (StringUtils.isNotBlank(name)) {
nameList.add(name);
}
}
OrganizationAssert.isFalse(new HashSet<>(nameList).size() < nameList.size(), "模板名称不能重复");
for (int i = 0; i < rowNum; i++) {
String recordIndex = "_" + i;
String id = Util.null2String(params.get("id" + recordIndex));
String name = Util.null2String(params.get("name" + recordIndex));
JclOrgCustomTemplatePO jclOrgCustomTemplatePO = new JclOrgCustomTemplatePO();
if (StringUtils.isNotBlank(id)) {
// 更新
long jclId = Long.parseLong(id);
jclOrgCustomTemplatePO = MapperProxyFactory.getProxy(JclOrgCustomTemplateMapper.class).selectByPrimaryKey(jclId);
jclOrgCustomTemplatePO.setName(name);
jclOrgCustomTemplatePO.setUpdateTime(new java.sql.Date(OrganizationDateUtil.stringToDate(currentDate).getTime()));
count += MapperProxyFactory.getProxy(JclOrgCustomTemplateMapper.class).updateByPrimaryKey(jclOrgCustomTemplatePO);
allIds.remove(jclId);
} else {
//插入
2023-01-13 18:40:34 +08:00
OrganizationAssert.isFalse("".equals(name), "模板名称不能为空");
jclOrgCustomTemplatePO.setName(name);
jclOrgCustomTemplatePO.setCreator(user.getUID());
jclOrgCustomTemplatePO.setCreateTime(new java.sql.Date(OrganizationDateUtil.stringToDate(currentDate).getTime()));
jclOrgCustomTemplatePO.setUpdateTime(new java.sql.Date(OrganizationDateUtil.stringToDate(currentDate).getTime()));
count += MapperProxyFactory.getProxy(JclOrgCustomTemplateMapper.class).insert(jclOrgCustomTemplatePO);
}
}
if (CollectionUtils.isNotEmpty(allIds)) {
count += MapperProxyFactory.getProxy(JclOrgCustomTemplateMapper.class).deleteByIds(allIds);
}
return count;
}
2023-01-10 18:25:53 +08:00
@Override
public void deleteCustomTemplate(Integer id) {
getHrmResourceMapper().deleteCustomTemplate(id, user.getUID());
}
2023-01-11 15:42:41 +08:00
@Override
public Map<String, Object> getCustomTransferData(Map<String, Object> params) {
Map<String, Object> resultMap = new HashMap<>();
String templateId = StringUtils.isNotBlank(Util.null2String(params.get("templateId"))) ? Util.null2String(params.get("templateId")) : "-1";
List<TransferDataPO> transferDatas = new ArrayList<>();
2023-01-12 14:08:51 +08:00
List<String> transferKeys;
2023-01-11 15:42:41 +08:00
List<SearchTemplateParam> transferOptions = new ArrayList<>();
List<SearchConditionGroup> allConditions = getAllConditions();
AtomicInteger idx = new AtomicInteger(0);
for (SearchConditionGroup allCondition : allConditions) {
List<SearchConditionItem> items = allCondition.getItems();
List<TransferDataPO> collect = items.stream().map(item -> TransferDataPO.builder().id(item.getDomkey()[0]).label(item.getLabel()).title(allCondition.getTitle()).idx(Integer.toString(idx.get())).build()).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(collect)) {
transferDatas.addAll(collect);
}
transferOptions.add(SearchTemplateParam.builder().key(Integer.toString(idx.getAndIncrement())).showname(allCondition.getTitle()).build());
}
if ("-1".equals(templateId)) {
2023-01-16 15:08:22 +08:00
// 查询当前使用的模板,没有使用的,则展示默认模板
SearchTemplatePO usedCustomTemplate = getHrmResourceMapper().getUsedCustomTemplateByUser(user.getUID());
if (null == usedCustomTemplate) {
String selectKeys = "-1_hrm_lastname,-1_hrm_departmentid,-1_hrm_jobtitle,-1_hrm_mobile,-1_hrm_telephone,-1_hrm_managerid";
transferKeys = Arrays.asList(selectKeys.split(","));
} else {
transferKeys = getSelectKeys(usedCustomTemplate);
templateId = usedCustomTemplate.getId().toString();
}
2023-01-11 15:42:41 +08:00
} else {
SearchTemplatePO searchTemplateById = getHrmResourceMapper().getCustomTemplateById(templateId);
transferKeys = getSelectKeys(searchTemplateById);
}
2023-01-13 18:01:17 +08:00
transferOptions.add(0, SearchTemplateParam.builder().key("").showname("").build());
2023-01-11 15:42:41 +08:00
resultMap.put("transferDatas", transferDatas);
resultMap.put("transferKeys", transferKeys);
resultMap.put("transferOptions", transferOptions);
2023-01-16 15:08:22 +08:00
resultMap.put("templateId", templateId);
2023-01-11 15:42:41 +08:00
return resultMap;
}
@Override
public Integer saveColumnsCustomTemplate(Map<String, Object> params) {
String columns = Util.null2String(params.get("columns"));
String templateId = Util.null2String(params.get("templateId"));
SearchTemplatePO templatePO = buildSearchTemplateByFields(columns);
JclOrgCustomTemplatePO jclOrgCustomTemplatePO = new JclOrgCustomTemplatePO();
2023-01-13 16:35:34 +08:00
if (StringUtils.isNotBlank(templateId)) {
2023-01-13 18:03:19 +08:00
if (templateId.equals("-1")) {
getJclOrgCustomTemplateMapper().updateUsed("0", null, String.valueOf(user.getUID()));
} else {
jclOrgCustomTemplatePO = getJclOrgCustomTemplateMapper().selectByPrimaryKey(Long.parseLong(templateId));
if (jclOrgCustomTemplatePO != null) {
jclOrgCustomTemplatePO.setId(Integer.valueOf(templateId));
jclOrgCustomTemplatePO.setBasicFields(templatePO.getBasicFields());
jclOrgCustomTemplatePO.setPersonalFields(templatePO.getPersonalFields());
jclOrgCustomTemplatePO.setWorkFields(templatePO.getWorkFields());
jclOrgCustomTemplatePO.setIsused(1);
//取消已启用模板
getJclOrgCustomTemplateMapper().updateUsed("0", null, String.valueOf(user.getUID()));
//启用当前模板
getJclOrgCustomTemplateMapper().updateByPrimaryKeySelective(jclOrgCustomTemplatePO);
}
}
}
return jclOrgCustomTemplatePO.getId();
}
2023-07-05 09:16:17 +08:00
@Override
2023-08-15 17:30:20 +08:00
public Map<String, Object> chartResourceList(Integer departmentId, String versionId, String dimension) {
2023-07-05 17:36:04 +08:00
Map<String, Object> dataMap = new HashMap<>();
List<ResourceListColumns> resourceListColumns = getTableColumns();
2023-07-12 16:09:04 +08:00
List<ResourceChartPO> resourceChartPOS = new ArrayList<>();
List<ResourceChartVO> resourceChartVOS = new ArrayList<>();
RecordSet rs = new RecordSet();
if ("0".equals(dimension)) {
if ("0".equals(versionId)) {
//当前数据
resourceChartPOS = getHrmResourceMapper().selectByDepartmentId(departmentId);
resourceChartVOS = ResourceChartBO.convertToVO(resourceChartPOS);
2023-08-15 17:30:20 +08:00
} else {
rs.executeQuery("select resourceid,workcode,lastname,sex,department,subcompany,jobtitle,mobile from jcl_chart_resource where departmentid = ? and versionid = ?", departmentId, versionId);
2023-07-12 16:09:04 +08:00
while (rs.next()) {
ResourceChartVO build = ResourceChartVO.builder()
.id((long) Util.getIntValue(rs.getString("resourceid")))
.workCode(Util.null2String(rs.getString("workcode")))
.lastName(Util.null2String(rs.getString("lastname")))
.sex("1".equals(Util.null2String(rs.getString("workcode"))) ? "" : "")
.departmentName(Util.null2String(rs.getString("department")))
.subcompanyName(Util.null2String(rs.getString("subcompany")))
.jobTitle(Util.null2String(rs.getString("jobtitle")))
.mobile(Util.null2String(rs.getString("mobile")))
.build();
resourceChartVOS.add(build);
}
}
2023-08-15 17:30:20 +08:00
} else {
rs.executeQuery("select h.id,h.workcode,h.lastname,h.sex,h.departmentid,h.subcompanyid1,h.jobtitle,h.status,h.mobile " +
" from hrmresourcevirtual v inner join hrmresource h on v.resourceid = h.id and v.virtualtype = ? and v.departmentid = ?", dimension, departmentId);
while (rs.next()) {
ResourceChartPO build = ResourceChartPO.builder()
.id((long) Util.getIntValue(rs.getString("id")))
.workCode(Util.null2String(rs.getString("workcode")))
.lastName(Util.null2String(rs.getString("lastname")))
.sex(Util.null2String(rs.getString("sex")))
.departmentId(Util.getIntValue(rs.getString("departmentid")))
.subcompanyid1(Util.getIntValue(rs.getString("subcompanyid1")))
.jobTitle(Util.getIntValue(rs.getString("jobtitle")))
.status(Util.getIntValue(rs.getString("status")))
.mobile(Util.null2String(rs.getString("mobile")))
.build();
resourceChartPOS.add(build);
}
resourceChartVOS = ResourceChartBO.convertToVO(resourceChartPOS);
2023-07-12 16:09:04 +08:00
}
2023-08-15 17:30:20 +08:00
dataMap.put("columns", resourceListColumns);
dataMap.put("dataSource", resourceChartVOS);
2023-07-05 17:36:04 +08:00
return dataMap;
}
private List<ResourceListColumns> getTableColumns() {
List<ResourceListColumns> list = new ArrayList<>();
list.add(ResourceListColumns.builder().title("序号").dataIndex("id").key("id").build());
list.add(ResourceListColumns.builder().title("工号").dataIndex("workCode").key("workCode").build());
list.add(ResourceListColumns.builder().title("姓名").dataIndex("lastName").key("lastName").build());
list.add(ResourceListColumns.builder().title("性别").dataIndex("sex").key("sex").build());
list.add(ResourceListColumns.builder().title("部门").dataIndex("departmentName").key("departmentName").build());
list.add(ResourceListColumns.builder().title("分部").dataIndex("subcompanyName").key("subcompanyName").build());
2023-07-05 17:36:04 +08:00
list.add(ResourceListColumns.builder().title("岗位").dataIndex("jobTitle").key("jobTitle").build());
//list.add(ResourceListColumns.builder().title("状态").dataIndex("status").key("status").build());
list.add(ResourceListColumns.builder().title("手机号").dataIndex("mobile").key("mobile").build());
return list;
2023-07-05 09:16:17 +08:00
}
@Override
public Map<String, Object> getSearchCondition(Map<String, Object> params) {
2023-01-06 15:35:38 +08:00
String templateId = Util.null2String(params.get("templateId"));
2023-01-09 10:27:30 +08:00
String selectKeys = Util.null2String(params.get("selectKeys"));
2023-01-06 15:35:38 +08:00
if (StringUtils.isBlank(templateId)) {
templateId = "-1";
}
Map<String, Object> apiDatas = new HashMap<>();
List<SearchConditionGroup> addGroups = new ArrayList<>();
2023-01-06 15:35:38 +08:00
List<SearchConditionGroup> allConditions = getAllConditions();
// 穿梭框ID展示所选字段信息
HrmFieldSearchConditionComInfo hrmFieldSearchConditionComInfo = new HrmFieldSearchConditionComInfo();
if ("-1".equals(templateId)) {
2023-01-09 10:27:30 +08:00
if (StringUtils.isNotBlank(selectKeys)) {
SearchTemplatePO templatePO = buildSearchTemplateByFields(selectKeys);
2023-01-10 11:37:28 +08:00
if (null != templatePO) {
buildSearchConditionGroup(templatePO, hrmFieldSearchConditionComInfo, addGroups);
}
2023-01-09 10:27:30 +08:00
} else {
// 未选择模板展示默认模板搜索条件
if (CollectionUtils.isNotEmpty(allConditions)) {
addGroups.add(allConditions.get(0));
}
2023-01-06 15:35:38 +08:00
}
} else {
// 选择模板则遍历所选模板所选字段
SearchTemplatePO searchTemplateById = getHrmResourceMapper().getSearchTemplateById(templateId);
2023-01-09 10:27:30 +08:00
buildSearchConditionGroup(searchTemplateById, hrmFieldSearchConditionComInfo, addGroups);
2023-01-06 15:35:38 +08:00
}
apiDatas.put("defaultcondition", addGroups);
apiDatas.put("conditions", allConditions);
return apiDatas;
}
@Override
public Map<String, Object> getHasRight() {
Map<String, Object> btnDatas = new HashMap<>();
2023-04-03 10:06:02 +08:00
ArrayList<MenuBtn> topMenuList = new ArrayList<>();
ArrayList<MenuBtn> rightMenuList = new ArrayList<>();
2022-11-09 16:58:09 +08:00
if (HasRightUtil.hasRight(user, RIGHT_NAME, true)) {
topMenuList.add(MenuBtn.builder().isBatch("1").isTop("1").menuFun("new").menuIcon("icon-coms-New-Flow").menuName("新建人员").type("BTN_Addnew").build());
rightMenuList.add(MenuBtn.builder().isBatch("1").isTop("1").menuFun("new").menuIcon("icon-coms-New-Flow").menuName("新建人员").type("BTN_Addnew").build());
}
2023-04-03 10:06:02 +08:00
topMenuList.add(MenuBtn.builder().isBatch("1").isTop("1").menuFun("customization").menuIcon("icon-coms-task-list").menuName("列定制").type("BTN_COLUMN").build());
rightMenuList.add(MenuBtn.rightMenu_btnLog());
btnDatas.put("topMenu", topMenuList);
btnDatas.put("rightMenu", rightMenuList);
2022-11-09 16:58:09 +08:00
btnDatas.put("hasRight", true);
return btnDatas;
}
2022-07-11 15:59:15 +08:00
@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<>();
2022-07-12 16:38:27 +08:00
2022-12-09 14:29:20 +08:00
//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);
2022-07-11 15:59:15 +08:00
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);
2022-07-12 16:38:27 +08:00
// 判断新增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());
2022-07-11 15:59:15 +08:00
return hrmRelationPO.getId();
}
2023-01-12 09:41:58 +08:00
@Override
public Map<String, Object> getCustomTemplate(Map<String, Object> params) {
List<ExtendInfoPO> infoPOList = new ArrayList<>();
2023-01-12 16:49:54 +08:00
infoPOList.add(ExtendInfoPO.builder().viewAttr(2).id(null).fieldName("name").fieldNameDesc("模板名称").fieldType("varchar(255)").controlType(1).browserType("1").customValue("[\"input\",\"text\",\"50\"]").showOrder(1).isrequired(0).isSystemDefault(0).build());
infoPOList.add(ExtendInfoPO.builder().viewAttr(1).id(null).fieldName("createTime").fieldNameDesc("创建时间").fieldType("date").controlType(1).browserType("1").customValue("[\"input\",\"text\",\"50\"]").showOrder(2).isrequired(0).isSystemDefault(0).build());
2023-01-12 09:41:58 +08:00
Map<String, Object> tabInfoMap = new HashMap<>();
2023-01-12 16:49:54 +08:00
tabInfoMap.put("columns", ExtendInfoBO.convertInfoListToTable(user, infoPOList, false, true));
List<JclOrgCustomTemplatePO> jclOrgCustomTemplatePOS = MapperProxyFactory.getProxy(JclOrgCustomTemplateMapper.class).listAllByCreator(user.getUID());
2023-01-12 09:41:58 +08:00
List<Integer> isUsed = new ArrayList<>();
AtomicInteger index = new AtomicInteger(0);
List<Map<String, Object>> collect = jclOrgCustomTemplatePOS.stream().map(item -> {
Map<String, Object> resultMap = new HashMap<>();
resultMap.put("id", item.getId());
resultMap.put("name", item.getName());
2023-01-13 18:03:19 +08:00
resultMap.put("createTime", DateUtil.getDate(item.getCreateTime(), "yyyy-MM-dd"));
2023-01-12 09:41:58 +08:00
2023-01-12 16:49:54 +08:00
if (item.getIsused() != null) {
if (1 == item.getIsused()) {
isUsed.add(index.get());
}
index.getAndIncrement();
2023-01-12 09:41:58 +08:00
}
return resultMap;
}).collect(Collectors.toList());
tabInfoMap.put("datas", collect);
tabInfoMap.put("api_status", true);
Map<String, List<Integer>> isUsedMap = new HashMap<>();
isUsedMap.put("status", isUsed);
tabInfoMap.put("selectedData", isUsedMap);
tabInfoMap.put("isModalEdit", false);
return tabInfoMap;
// OrganizationWeaTable<JclOrgCustomTemplateVO> table = new OrganizationWeaTable<>(user, JclOrgCustomTemplateVO.class);
// String sqlWhere = buildSqlWhere(params);
// table.setSqlwhere(sqlWhere);
// WeaResultMsg result = new WeaResultMsg(false);
// result.putAll(table.makeDataResult());
// result.success();
// return new HashMap<>(result.getResultMap());
}
/**
* 查询条件
*
* @param params
* @return
*/
2023-01-06 17:20:29 +08:00
private String buildSqlWhere(Map<String, Object> params) {
2023-01-09 10:27:30 +08:00
HrmFieldSearchConditionComInfo hrmFieldSearchConditionComInfo = new HrmFieldSearchConditionComInfo();
List<SearchConditionItem> conditionItems = new ArrayList<>();
2023-01-09 18:06:57 +08:00
List<CusFormFieldPO> hrmFieldsByScopeId = getSystemDataMapper().getHrmFieldsByScopeId(HrmGroupEnum.HRM_BASIC.getGroupType().toString());
2023-01-09 10:27:30 +08:00
createConditionItems(hrmFieldSearchConditionComInfo, hrmFieldsByScopeId, conditionItems);
2023-01-09 18:06:57 +08:00
hrmFieldsByScopeId = getSystemDataMapper().getHrmFieldsByScopeId(HrmGroupEnum.HRM_PERSONAL.getGroupType().toString());
2023-01-09 10:27:30 +08:00
createConditionItems(hrmFieldSearchConditionComInfo, hrmFieldsByScopeId, conditionItems);
2023-01-09 18:06:57 +08:00
hrmFieldsByScopeId = getSystemDataMapper().getHrmFieldsByScopeId(HrmGroupEnum.HRM_WORK.getGroupType().toString());
2023-01-09 10:27:30 +08:00
createConditionItems(hrmFieldSearchConditionComInfo, hrmFieldsByScopeId, conditionItems);
Map<String, SearchConditionItem> allFieldsMap = conditionItems.stream().collect(Collectors.toMap(item -> item.getDomkey()[0], item -> item, (k1, k2) -> k1));
2023-08-15 17:30:20 +08:00
boolean isQuickSearch = "true".equals(Util.null2String(params.get("isQuickSearch")));
2023-01-09 10:27:30 +08:00
DBType dbType = DBType.get(new RecordSet().getDBType());
2023-02-06 09:49:36 +08:00
StringBuilder sb = new StringBuilder(" where 1=1 ");
2023-08-15 17:30:20 +08:00
if (params.containsKey("lastName") || !params.containsKey("-1_hrm_status")) {
// sb.append(" and t.status = 1");
sb.append(" and t.status < 4");
2023-02-14 17:09:22 +08:00
}
2023-01-06 17:20:29 +08:00
for (Map.Entry<String, Object> entry : params.entrySet()) {
2023-02-06 09:49:36 +08:00
String key = entry.getKey();
2023-01-09 18:06:57 +08:00
String value = Util.null2String(entry.getValue());
2023-02-14 17:09:22 +08:00
if (StringUtils.isBlank(value)) {
continue;
}
2023-02-06 09:49:36 +08:00
if ("lastName".equals(key)) {
2023-02-14 17:09:22 +08:00
sb.append(" and t.lastname ").append(dbType.like(value));
}
if ("companyId".equals(key)) {
sb.append(" and t.subcompanyid1 ='").append(value).append("'");
}
if ("departmentId".equals(key)) {
sb.append(" and t.departmentId ='").append(value).append("'");
}
if ("jobTitle".equals(key)) {
JobPO jobById = getJobMapper().getJobById(Long.parseLong(value));
if (null != jobById) {
sb.append(" and t.jobtitle ='").append(Util.null2String(jobById.getEcJobTitle())).append("' and t.subcompanyid1 = '").append(Util.null2String(jobById.getEcCompany())).append("' and t.departmentId ='").append(Util.null2String(jobById.getEcDepartment())).append("'");
} else {
sb = new StringBuilder(" where 1 = 2 ");
break;
2023-02-06 09:49:36 +08:00
}
2023-01-09 18:06:57 +08:00
}
2023-02-06 09:49:36 +08:00
2023-01-09 10:27:30 +08:00
SearchConditionItem searchConditionItem = allFieldsMap.get(key);
// 根据不同的类型,不同的查询方式
2023-08-15 17:30:20 +08:00
buildDynamicSql(searchConditionItem, key, value, sb, dbType, isQuickSearch, params);
}
2023-01-11 14:26:13 +08:00
if (searchJobTitle) {
String jobTitleIds = StringUtils.join(jobTitleList, ",");
sb.append(" and t.jobtitle in (").append(StringUtils.isNotBlank(jobTitleIds) ? jobTitleIds : "''").append(") ");
}
// 分权查询
2022-12-13 10:42:35 +08:00
DetachUtil detachUtil = new DetachUtil(user);
2022-11-02 10:55:15 +08:00
String parentCompanyIds = detachUtil.getJclRoleLevels();
if (detachUtil.isDETACH()) {
2023-01-11 14:26:13 +08:00
sb.append(" and t.subcompanyid1 in(").append(parentCompanyIds).append(")");
}
2023-01-09 18:06:57 +08:00
return sb.toString();
}
2022-06-20 18:31:11 +08:00
public List<SearchTree> getFilterCompany(String id, String type, String keyword) {
List<SearchTree> searchTree = new ArrayList<>();
// 通过分部、公司 组装数据
if (StringUtil.isEmpty(id) || TYPE_COMP.equals(type)) {
2022-11-28 11:15:54 +08:00
Integer parentCompId = StringUtil.isEmpty(id) ? null : Integer.parseInt(id);
2022-12-09 14:29:20 +08:00
DepartmentPO departmentBuild = DepartmentPO.builder().departmentName(keyword).subCompanyId1(parentCompId).canceled(0).build();
CompPO compBuild = CompPO.builder().subCompanyName(keyword).supSubComId(parentCompId).canceled(0).build();
2022-06-20 18:31:11 +08:00
// 所属分部下的岗位
2022-12-09 14:29:20 +08:00
JobPO jobBuild = JobPO.builder().jobTitleName(keyword).ecCompany(parentCompId).forbiddenTag(0).build();
2022-06-20 18:31:11 +08:00
searchTree = buildTreeByCompAndDept(departmentBuild, compBuild, jobBuild);
} else if (TYPE_DEPT.equals(type)) {
Integer parentDeptId = Integer.parseInt(id);
2022-12-09 14:29:20 +08:00
DepartmentPO departmentBuild = DepartmentPO.builder().departmentName(keyword).supDepId(parentDeptId).canceled(0).build();
2022-06-20 18:31:11 +08:00
// 所属分部下的岗位
2022-12-09 14:29:20 +08:00
JobPO jobBuild = JobPO.builder().jobTitleName(keyword).ecDepartment(parentDeptId).forbiddenTag(0).build();
2022-06-20 18:31:11 +08:00
searchTree = buildTreeByDeptAndJob(departmentBuild, jobBuild);
} else if (TYPE_JOB.equals(type)) {
// 查询部门信息
List<JobPO> filterJobs = getJobMapper().listPOsByFilter(JobPO.builder().jobTitleName(keyword).parentJob(Long.parseLong(id)).forbiddenTag(0).build());
searchTree = SearchTreeUtil.builderTreeMode(JobBO.buildSetToSearchTree(filterJobs));
2022-06-20 18:31:11 +08:00
}
return searchTree;
}
/**
* 分部部门 组装左侧树
*
* @param departmentBuild
* @param compBuild
* @param jobBuild
* @return
*/
2022-11-30 16:06:40 +08:00
private List<SearchTree> buildTreeByCompAndDept(DepartmentPO departmentBuild, CompPO compBuild, JobPO jobBuild) {
2022-06-20 18:31:11 +08:00
List<JobPO> jobPOS = getJobMapper().listPOsByFilter(jobBuild);
2022-12-13 10:42:35 +08:00
new DetachUtil(user).filterJobList(jobPOS);
2022-11-30 15:55:27 +08:00
List<DepartmentPO> filterDeparts = getDepartmentMapper().listByFilter(departmentBuild, "showorder");
2022-12-13 10:42:35 +08:00
new DetachUtil(user).filterDepartmentList(filterDeparts);
2022-06-20 18:31:11 +08:00
// 添加岗位的上级部门或分部
List<SearchTree> jobTrees = SearchTreeUtil.builderTreeMode(JobBO.buildSetToSearchTree(jobPOS));
2022-06-20 18:31:11 +08:00
String parentDeptS = jobTrees.stream().map(SearchTree::getParentComp).collect(Collectors.joining(","));
if (!StringUtil.isEmpty(parentDeptS)) {
2022-07-26 09:40:13 +08:00
// 兼容SQLServer每次最多in,2100条数据
2022-12-09 14:29:20 +08:00
List<Long> ids = DeleteParam.builder().ids(parentDeptS).build().getIds();
2022-07-26 09:40:13 +08:00
int ceilCount = (int) Math.ceil((double) ids.size() / 1000);
List<DepartmentPO> departmentsByIds = new ArrayList<>();
for (int i = 1; i < ceilCount + 1; i++) {
2022-07-26 09:40:13 +08:00
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);
2022-06-20 18:31:11 +08:00
}
}
// 查询分部信息
2022-11-30 16:06:40 +08:00
List<CompPO> filterComps = getCompMapper().listByFilter(compBuild, "showorder");
2022-12-13 10:42:35 +08:00
new DetachUtil(user).filterCompanyList(filterComps);
2022-06-20 18:31:11 +08:00
Set<DepartmentPO> builderDeparts = new HashSet<>();
Map<Integer, DepartmentPO> departmentPOMap = getDepartmentMapper().listAll("showorder").stream().collect(Collectors.toMap(DepartmentPO::getId, item -> item));
2022-06-20 18:31:11 +08:00
for (DepartmentPO departmentPO : filterDeparts) {
2023-08-15 17:30:20 +08:00
buildParentDepts(departmentPO, builderDeparts, departmentPOMap);
2022-06-20 18:31:11 +08:00
}
List<SearchTree> departmentList = DepartmentBO.buildSetToSearchTree(builderDeparts);
List<SearchTree> deptTrees = SearchTreeUtil.builderTreeMode(departmentList);
List<SearchTree> searchTrees = SearchTreeUtil.builderTreeMode(departmentList, jobTrees);
2022-06-20 18:31:11 +08:00
// 添加部门的上级分部
String parentCompS = deptTrees.stream().map(SearchTree::getParentComp).collect(Collectors.joining(","));
if (!StringUtil.isEmpty(parentCompS)) {
2022-11-30 16:06:40 +08:00
List<CompPO> compsByIds = getCompMapper().getCompsByIds(DeleteParam.builder().ids(parentCompS).build().getIds());
2022-06-20 18:31:11 +08:00
if (CollectionUtils.isNotEmpty(compsByIds)) {
filterComps.addAll(compsByIds);
}
}
2022-11-30 16:06:40 +08:00
List<CompPO> allCompanys = getCompMapper().listAll("showorder");
2022-12-13 10:42:35 +08:00
new DetachUtil(user).filterCompanyList(allCompanys);
2022-11-30 16:06:40 +08:00
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) {
2022-11-09 16:58:09 +08:00
buildParentComps(compPO, builderComps, allMaps);
2022-06-20 18:31:11 +08:00
}
2022-11-30 16:06:40 +08:00
return SearchTreeUtil.builderTreeMode(CompBO.buildSetToSearchTree(builderComps), searchTrees);
2022-06-20 18:31:11 +08:00
}
private List<SearchTree> buildTreeByDeptAndJob(DepartmentPO departmentBuild, JobPO jobBuild) {
List<JobPO> jobPOS = getJobMapper().listPOsByFilter(jobBuild);
2022-11-30 15:55:27 +08:00
List<DepartmentPO> filterDeparts = getDepartmentMapper().listByFilter(departmentBuild, "showorder");
2022-06-20 18:31:11 +08:00
// 添加岗位的上级部门或分部
List<SearchTree> jobTrees = SearchTreeUtil.builderTreeMode(JobBO.buildSetToSearchTree(jobPOS));
2022-06-20 18:31:11 +08:00
String parentDeptS = jobTrees.stream().map(SearchTree::getParentComp).collect(Collectors.joining(","));
if (!StringUtil.isEmpty(parentDeptS)) {
2022-07-26 09:40:13 +08:00
// 兼容SQLServer每次最多in,2100条数据
2023-01-12 14:08:51 +08:00
List<Long> ids = DeleteParam.builder().ids(parentDeptS).build().getIds();
2022-07-26 09:40:13 +08:00
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);
2022-06-20 18:31:11 +08:00
}
}
Map<Integer, DepartmentPO> departmentPOMap = getDepartmentMapper().listAll("showorder").stream().collect(Collectors.toMap(DepartmentPO::getId, item -> item));
2022-06-20 18:31:11 +08:00
// 查询分部信息
Set<DepartmentPO> builderDeparts = new HashSet<>();
for (DepartmentPO departmentPO : filterDeparts) {
2023-08-15 17:30:20 +08:00
buildParentDepts(departmentPO, builderDeparts, departmentPOMap);
2022-06-20 18:31:11 +08:00
}
return SearchTreeUtil.builderTreeMode(DepartmentBO.buildSetToSearchTree(builderDeparts), jobTrees);
2022-06-20 18:31:11 +08:00
}
/**
* 添加查询元素的父级元素
*
* @param departmentPO
* @param builderDeparts
*/
2023-08-15 17:30:20 +08:00
private void buildParentDepts(DepartmentPO departmentPO, Set<DepartmentPO> builderDeparts, Map<Integer, DepartmentPO> departmentPOMap) {
2022-06-20 18:31:11 +08:00
builderDeparts.add(departmentPO);
if (SearchTreeUtil.isTop(departmentPO.getSupDepId())) {
2022-06-20 18:31:11 +08:00
return;
}
DepartmentPO parentDept = departmentPOMap.get(departmentPO.getSupDepId());
2022-06-20 18:31:11 +08:00
if (null != parentDept) {
2023-08-15 17:30:20 +08:00
buildParentDepts(parentDept, builderDeparts, departmentPOMap);
2022-06-20 18:31:11 +08:00
}
}
/**
* 添加查询元素的父级元素
*
* @param compPO
* @param builderComps
*/
2022-11-30 16:06:40 +08:00
private void buildParentComps(CompPO compPO, Set<CompPO> builderComps, Map<Integer, CompPO> allMaps) {
2022-06-20 18:31:11 +08:00
builderComps.add(compPO);
2022-11-30 16:06:40 +08:00
CompPO parentComp = allMaps.get(compPO.getSupSubComId());
2022-06-20 18:31:11 +08:00
if (null != parentComp) {
2022-11-09 16:58:09 +08:00
buildParentComps(parentComp, builderComps, allMaps);
2022-06-20 18:31:11 +08:00
}
}
2022-10-17 17:16:26 +08:00
2023-01-09 10:27:30 +08:00
/**
* 获取所有搜索字段信息构建的高级搜索表单
*
* @return
*/
2023-01-06 17:20:29 +08:00
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<>();
2023-01-06 15:35:38 +08:00
2023-01-06 17:20:29 +08:00
// 基本信息:-1
2023-01-09 18:06:57 +08:00
List<CusFormFieldPO> hrmFieldsByScopeId = getSystemDataMapper().getHrmFieldsByScopeId(HrmGroupEnum.HRM_BASIC.getGroupType().toString());
2023-01-06 17:20:29 +08:00
createConditionItems(hrmFieldSearchConditionComInfo, hrmFieldsByScopeId, basicConditionItems);
if (CollectionUtils.isNotEmpty(basicConditionItems)) {
addGroups.add(new SearchConditionGroup("基本信息", true, basicConditionItems));
}
// 个人信息1
2023-01-09 18:06:57 +08:00
hrmFieldsByScopeId = getSystemDataMapper().getHrmFieldsByScopeId(HrmGroupEnum.HRM_PERSONAL.getGroupType().toString());
2023-01-06 17:20:29 +08:00
createConditionItems(hrmFieldSearchConditionComInfo, hrmFieldsByScopeId, personalConditionItems);
if (CollectionUtils.isNotEmpty(personalConditionItems)) {
addGroups.add(new SearchConditionGroup("个人信息", true, personalConditionItems));
}
// 工作信息3
2023-01-09 18:06:57 +08:00
hrmFieldsByScopeId = getSystemDataMapper().getHrmFieldsByScopeId(HrmGroupEnum.HRM_WORK.getGroupType().toString());
2023-01-06 17:20:29 +08:00
createConditionItems(hrmFieldSearchConditionComInfo, hrmFieldsByScopeId, workConditionItems);
if (CollectionUtils.isNotEmpty(workConditionItems)) {
addGroups.add(new SearchConditionGroup("工作信息", true, workConditionItems));
}
return addGroups;
}
2023-01-06 15:35:38 +08:00
/**
* 构建查询条件Item
*
* @param hrmFieldSearchConditionComInfo
* @param formFields
* @param conditionItems
*/
private void createConditionItems(HrmFieldSearchConditionComInfo hrmFieldSearchConditionComInfo, List<CusFormFieldPO> formFields, List<SearchConditionItem> conditionItems) {
for (CusFormFieldPO cusFormFieldPO : formFields) {
2023-01-10 16:52:40 +08:00
if ("jobactivity".equals(cusFormFieldPO.getFieldName())) {
// 职务282
cusFormFieldPO.setType("282");
}
2023-01-06 15:35:38 +08:00
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());
2023-01-06 17:20:29 +08:00
hrmFieldBean.setIssystem("hrm".equals(cusFormFieldPO.getTableName()) ? "1" : "0");
hrmFieldBean.setIsFormField(true);
2023-02-06 09:49:36 +08:00
if ("-1_hrm_status".equals(hrmFieldBean.getFieldname())) {
hrmFieldBean.setFieldvalue("1");
}
2023-01-06 17:20:29 +08:00
SearchConditionItem searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user);
conditionItems.add(searchConditionItem);
2023-01-09 18:06:57 +08:00
// 如果为下拉框,添加一条空选项
if (searchConditionItem.getConditionType().equals(ConditionType.SELECT)) {
addEmptyForSelect(searchConditionItem);
}
2023-01-06 15:35:38 +08:00
}
}
2023-01-06 17:20:29 +08:00
/**
* 获取模板中的字段构建搜索条件
*
* @param hrmFieldSearchConditionComInfo
* @param addGroups
* @param title
* @param scopeid
* @param fieldNames
*/
2023-01-06 15:35:38 +08:00
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<>();
2023-01-10 14:08:41 +08:00
for (String field : fieldNames) {
String fieldName = field.substring(field.lastIndexOf("_") + 1);
2023-01-06 15:35:38 +08:00
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"));
2023-01-06 17:20:29 +08:00
hrmFieldBean.setIssystem(baseField ? "1" : "0");
hrmFieldBean.setIsFormField(true);
2023-01-06 15:35:38 +08:00
hrmFieldBean.setIsQuickSearch(false);
hrmFieldBean.setIsScope(false);
2023-01-10 16:52:40 +08:00
if ("jobactivity".equals(fieldName)) {
// 职务282
hrmFieldBean.setType("282");
}
2023-01-06 17:20:29 +08:00
SearchConditionItem searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user);
conditionItems.add(searchConditionItem);
2023-01-09 18:06:57 +08:00
// 如果为下拉框,添加一条空选项
if (searchConditionItem.getConditionType().equals(ConditionType.SELECT)) {
addEmptyForSelect(searchConditionItem);
}
2023-01-06 15:35:38 +08:00
}
if (CollectionUtils.isNotEmpty(conditionItems)) {
addGroups.add(new SearchConditionGroup(title, true, conditionItems));
}
} catch (JSONException e) {
throw new RuntimeException(e);
}
}
2023-01-09 10:27:30 +08:00
/**
* 根据所选字段信息构建搜素模板对象
*
* @param fields
* @return
*/
private SearchTemplatePO buildSearchTemplateByFields(String fields) {
String[] split = fields.split(",");
if (split.length > 0) {
2023-01-10 11:37:28 +08:00
List<String> basicFields = new ArrayList<>();
List<String> personalFields = new ArrayList<>();
List<String> workFields = new ArrayList<>();
2023-01-09 10:27:30 +08:00
for (String fieldName : split) {
2023-01-09 18:06:57 +08:00
if (fieldName.startsWith(HrmGroupEnum.HRM_BASIC.getGroupType().toString())) {
2023-01-10 14:08:41 +08:00
basicFields.add(fieldName);
2023-01-09 18:06:57 +08:00
} else if (fieldName.startsWith(HrmGroupEnum.HRM_PERSONAL.getGroupType().toString())) {
2023-01-10 14:08:41 +08:00
personalFields.add(fieldName);
2023-01-09 18:06:57 +08:00
} else if (fieldName.startsWith(HrmGroupEnum.HRM_WORK.getGroupType().toString())) {
2023-01-10 14:08:41 +08:00
workFields.add(fieldName);
2023-01-09 10:27:30 +08:00
}
}
2023-01-10 11:37:28 +08:00
return SearchTemplatePO.builder().basicFields(StringUtils.join(basicFields, ",")).personalFields(StringUtils.join(personalFields, ",")).workFields(StringUtils.join(workFields, ",")).build();
2023-01-09 10:27:30 +08:00
}
2023-01-10 11:37:28 +08:00
return null;
2023-01-09 10:27:30 +08:00
}
/**
* 根据搜索模板对象构建搜索条件表单
*
* @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) {
2023-01-09 18:06:57 +08:00
getTemplateItems(hrmFieldSearchConditionComInfo, addGroups, "基本信息", HrmGroupEnum.HRM_BASIC.getGroupType(), basicFields);
2023-01-09 10:27:30 +08:00
}
String[] personalFields = Util.null2String(templatePO.getPersonalFields()).split(",");
if (personalFields.length > 0) {
2023-01-09 18:06:57 +08:00
getTemplateItems(hrmFieldSearchConditionComInfo, addGroups, "个人信息", HrmGroupEnum.HRM_PERSONAL.getGroupType(), personalFields);
2023-01-09 10:27:30 +08:00
}
String[] workFields = Util.null2String(templatePO.getWorkFields()).split(",");
if (workFields.length > 0) {
2023-01-09 18:06:57 +08:00
getTemplateItems(hrmFieldSearchConditionComInfo, addGroups, "工作信息", HrmGroupEnum.HRM_WORK.getGroupType(), workFields);
}
}
/**
* 根据字段信息动态拼接where条件SQL
*
* @param conditionItem
* @param key
* @param value
* @param sb
* @param dbType
*/
2023-08-15 17:30:20 +08:00
private void buildDynamicSql(SearchConditionItem conditionItem, String key, String value, StringBuilder sb, DBType dbType, boolean isQuickSearch, Map<String, Object> params) {
2023-01-09 18:06:57 +08:00
if (null == conditionItem) {
return;
2023-01-09 10:27:30 +08:00
}
2023-01-09 18:06:57 +08:00
if (key.endsWith("workyear") || key.endsWith("companyworkyear")) {
conditionItem.setConditionType(ConditionType.INPUTNUMBER);
}
2023-01-11 14:26:13 +08:00
// 职务
2023-01-10 18:25:53 +08:00
if (key.endsWith("jobactivity")) {
searchJobTitle = true;
2023-01-11 14:26:13 +08:00
List<Integer> jobTitleIds = getSystemDataMapper().getJobTitleIds(value, null);
if (null == jobTitleList) {
jobTitleList = jobTitleIds;
} else {
jobTitleList.retainAll(jobTitleIds);
}
return;
2023-01-10 18:25:53 +08:00
}
2023-01-11 14:26:13 +08:00
// 职务类别
2023-01-10 18:25:53 +08:00
if (key.endsWith("jobGroupId")) {
searchJobTitle = true;
2023-01-11 14:26:13 +08:00
List<Integer> jobTitleIds = getSystemDataMapper().getJobTitleIds(null, value);
if (null == jobTitleList) {
jobTitleList = jobTitleIds;
} else {
jobTitleList.retainAll(jobTitleIds);
}
return;
2023-01-10 18:25:53 +08:00
}
2023-01-11 14:26:13 +08:00
// 岗位
2023-01-10 18:25:53 +08:00
if (key.endsWith("jobtitle")) {
searchJobTitle = true;
2023-01-11 14:26:13 +08:00
jobTitleList = new ArrayList<>();
jobTitleList.add(Integer.parseInt(value));
return;
2023-01-10 18:25:53 +08:00
}
2023-01-09 18:06:57 +08:00
String tableSql = buildTableSql(key);
if (StringUtils.isBlank(tableSql)) {
return;
}
switch (conditionItem.getConditionType()) {
case INPUT:// 单行文本框
case TEXTAREA:// 多行文本框
2023-08-16 17:18:43 +08:00
if (isQuickSearch) {
if ("-1".equals(value)) {
break;
}
QuickSearchDetail quickSearchDetailById = getQuickSearchMapper().getQuickSearchDetailById(value);
Integer maxNum = quickSearchDetailById.getMaxNum();
Integer minNum = quickSearchDetailById.getMinNum();
sb.append(" and ").append(dbType.ifNull(tableSql, "0")).append(" >= ").append(minNum);
sb.append(" and ").append(dbType.ifNull(tableSql, "0")).append(" < ").append(maxNum);
} else {
sb.append(" and ").append(tableSql).append(dbType.like(value));
}
2023-01-09 18:06:57 +08:00
// 模糊搜索
break;
case BROWSER://浏览按钮
2023-01-12 14:08:51 +08:00
// 兼容多选浏览按钮
sb.append(" and ").append(dbType.concat(tableSql)).append(dbType.like(value));
break;
case INPUTNUMBER:// 数字
2023-08-15 17:30:20 +08:00
if (isQuickSearch) {
2023-08-16 17:18:43 +08:00
if ("-1".equals(value)) {
2023-08-16 13:49:10 +08:00
break;
}
2023-08-15 17:30:20 +08:00
QuickSearchDetail quickSearchDetailById = getQuickSearchMapper().getQuickSearchDetailById(value);
Integer maxNum = quickSearchDetailById.getMaxNum();
Integer minNum = quickSearchDetailById.getMinNum();
sb.append(" and ").append(dbType.ifNull(tableSql, "0")).append(" >= ").append(minNum);
2023-08-16 15:59:25 +08:00
sb.append(" and ").append(dbType.ifNull(tableSql, "0")).append(" < ").append(maxNum);
2023-08-15 17:30:20 +08:00
} else {
sb.append(" and ").append(dbType.ifNull(tableSql, "0")).append(" = '").append(value).append("' ");
}
break;
2023-01-09 18:06:57 +08:00
case CHECKBOX:
case SWITCH:
sb.append(" and ").append(dbType.ifNull(tableSql, "0")).append(" = '").append(value).append("' ");
break;
2023-01-12 14:08:51 +08:00
case SELECT://选择框
2023-02-06 09:49:36 +08:00
if (!"-1".equals(value)) {
if ("t.status".equalsIgnoreCase(tableSql) && "10".equals(value)) {
sb.append(" and ").append(tableSql).append(" < 4 ");
} else {
sb.append(" and ").append(tableSql).append(" = '").append(value).append("' ");
}
2023-02-06 09:49:36 +08:00
}
break;
2023-01-09 18:06:57 +08:00
case DATE:
case DATEPICKER:
case TIMEPICKER:
case RANGEPICKER:
2023-08-15 17:30:20 +08:00
if (isQuickSearch) {
if (StringUtils.isNotBlank(value) && !"-1".equals(value) && !"0,,".equals(value) && !"0".equals(value)) {
if (!"6".equals(value)) {
2023-08-16 15:59:25 +08:00
if ("1".equals(value)) {
2023-08-16 16:40:11 +08:00
sb.append(" and ").append(tableSql).append(" = '").append(OrganizationDateUtil.getFormatLocalDate(LocalDate.now())).append("'");
2023-08-16 17:18:43 +08:00
} else {
2023-08-16 15:59:25 +08:00
sb.append(" and ").append(tableSql).append(" >= '").append(TimeUtil.getDateByOption(value, "0")).append(" 00:00:00'");
sb.append(" and ").append(tableSql).append(" <= '").append(TimeUtil.getDateByOption(value, "")).append(" 23:59:59'");
}
2023-08-15 17:30:20 +08:00
} else {
String startDate = Util.null2String(params.get(key + "_start"));
String endDate = Util.null2String(params.get(key + "_end"));
if (StringUtils.isNotBlank(startDate)) {
sb.append(" and ").append(tableSql).append(" >= '").append(startDate).append("' ");
}
if (StringUtils.isNotBlank(endDate)) {
sb.append(" and ").append(tableSql).append(" <= '").append(endDate).append("' ");
}
}
}
} else {
// 精准搜索
sb.append(" and ").append(tableSql).append(" = '").append(value).append("' ");
}
2023-01-09 18:06:57 +08:00
break;
default:
break;
}
}
/**
* 处理当前字段所在表关系
*
* @param key
* @return
*/
2023-08-07 17:38:01 +08:00
public String buildTableSql(String key) {
2023-01-09 18:06:57 +08:00
StringBuilder sb = new StringBuilder();
String[] s = key.split("_");
if (s.length < 3) {
return "";
}
2023-01-11 14:26:13 +08:00
2023-01-09 18:06:57 +08:00
String scopeId = s[0];
String tableName = s[1];
String fieldName = s[2];
2023-01-13 16:35:34 +08:00
if ("jobactivity".equalsIgnoreCase(fieldName)) {
return "t4.id";
}
if ("jobGroupId".equalsIgnoreCase(fieldName)) {
return "t5.id";
}
2023-01-13 16:50:54 +08:00
// 姓名点击事件
if ("lastname".equalsIgnoreCase(fieldName)) {
return "lastname";
}
2023-01-13 16:35:34 +08:00
2023-01-11 14:26:13 +08:00
if ("hrm".equals(tableName)) {
return sb.append("t.").append(fieldName).toString();
2023-01-09 18:06:57 +08:00
}
2023-01-11 14:26:13 +08:00
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 "";
}
2023-01-09 18:06:57 +08:00
return sb.toString();
}
2023-01-11 15:42:41 +08:00
/**
* 为下拉框搜索条件添加空选项
*
* @param searchConditionItem
*/
2023-01-09 18:06:57 +08:00
private void addEmptyForSelect(SearchConditionItem searchConditionItem) {
2023-02-06 09:49:36 +08:00
searchConditionItem.setValue("-1");
if ("-1_hrm_status".equals(searchConditionItem.getDomkey()[0])) {
// 默认赋值 在职状态
searchConditionItem.setValue("10");
2023-02-06 09:49:36 +08:00
}
2023-01-09 18:06:57 +08:00
List<SearchConditionOption> options = searchConditionItem.getOptions();
SearchConditionOption searchConditionOption = new SearchConditionOption();
2023-02-06 09:49:36 +08:00
searchConditionOption.setKey("-1");
searchConditionOption.setShowname("全部");
2023-01-09 18:06:57 +08:00
options.add(0, searchConditionOption);
options.forEach(item -> item.setSelected(false));
2023-01-09 10:27:30 +08:00
}
2023-01-11 14:48:24 +08:00
2023-01-11 15:42:41 +08:00
/**
* 根据模板示例组装所有selectKeys
*
* @param searchTemplatePO
* @return
*/
2023-08-07 17:38:01 +08:00
public List<String> getSelectKeys(SearchTemplatePO searchTemplatePO) {
2023-01-11 15:42:41 +08:00
List<String> selectKeys = new ArrayList<>();
String basicFields = searchTemplatePO.getBasicFields();
String personalFields = searchTemplatePO.getPersonalFields();
String workflowFields = searchTemplatePO.getWorkFields();
if (StringUtils.isNotBlank(basicFields)) {
selectKeys.addAll(Arrays.asList(basicFields.split(",")));
}
if (StringUtils.isNotBlank(personalFields)) {
selectKeys.addAll(Arrays.asList(personalFields.split(",")));
}
if (StringUtils.isNotBlank(workflowFields)) {
selectKeys.addAll(Arrays.asList(workflowFields.split(",")));
}
return selectKeys;
}
2022-06-20 18:31:11 +08:00
}