diff --git a/src/com/engine/organization/entity/fieldset/param/TransferDataParam.java b/src/com/engine/organization/entity/fieldset/param/TransferDataParam.java
deleted file mode 100644
index 7eb80085..00000000
--- a/src/com/engine/organization/entity/fieldset/param/TransferDataParam.java
+++ /dev/null
@@ -1,21 +0,0 @@
-package com.engine.organization.entity.fieldset.param;
-
-import lombok.AllArgsConstructor;
-import lombok.Builder;
-import lombok.Data;
-import lombok.NoArgsConstructor;
-
-/**
- * @author:dxfeng
- * @createTime: 2023/01/05
- * @version: 1.0
- */
-@Data
-@Builder
-@AllArgsConstructor
-@NoArgsConstructor
-public class TransferDataParam {
- private String id;
- private String label;
- private String title;
-}
diff --git a/src/com/engine/organization/entity/hrmresource/vo/HrmResourceVO.java b/src/com/engine/organization/entity/hrmresource/vo/HrmResourceVO.java
index 2a51e8e2..84443890 100644
--- a/src/com/engine/organization/entity/hrmresource/vo/HrmResourceVO.java
+++ b/src/com/engine/organization/entity/hrmresource/vo/HrmResourceVO.java
@@ -26,8 +26,8 @@ import lombok.NoArgsConstructor;
"t.telephone," +
"t.managerid, " +
"t.dsporder ",
- fromSql = "FROM hrmresource t ",
- orderby = " dsporder ",
+ fromSql = "FROM hrmresource t left join cus_fielddata t0 on t.id = t0.id and t0.scopeid ='-1' left join cus_fielddata t1 on t.id = t1.id and t1.scopeid ='1' left join cus_fielddata t2 on t.id = t2.id and t2.scopeid ='3' ",
+ orderby = " t.dsporder ",
sortway = " asc",
primarykey = "id",
operates = {
diff --git a/src/com/engine/organization/enums/HrmGroupEnum.java b/src/com/engine/organization/enums/HrmGroupEnum.java
index 75a1b6ed..f4280465 100644
--- a/src/com/engine/organization/enums/HrmGroupEnum.java
+++ b/src/com/engine/organization/enums/HrmGroupEnum.java
@@ -6,7 +6,7 @@ package com.engine.organization.enums;
* @version: 1.0
*/
public enum HrmGroupEnum {
- COMPANY(4), DEPARTMENT(5);
+ HRM_BASIC(-1), HRM_PERSONAL(1), HRM_WORK(3), COMPANY(4), DEPARTMENT(5);
HrmGroupEnum(Integer groupType) {
this.groupType = groupType;
diff --git a/src/com/engine/organization/mapper/personnelcard/PersonnelCardMapper.xml b/src/com/engine/organization/mapper/personnelcard/PersonnelCardMapper.xml
index cc7ed5b9..3b45911f 100644
--- a/src/com/engine/organization/mapper/personnelcard/PersonnelCardMapper.xml
+++ b/src/com/engine/organization/mapper/personnelcard/PersonnelCardMapper.xml
@@ -8,7 +8,7 @@
-
+
diff --git a/src/com/engine/organization/mapper/resource/HrmResourceMapper.java b/src/com/engine/organization/mapper/resource/HrmResourceMapper.java
index 1c2bec80..aaa7f84e 100644
--- a/src/com/engine/organization/mapper/resource/HrmResourceMapper.java
+++ b/src/com/engine/organization/mapper/resource/HrmResourceMapper.java
@@ -51,4 +51,8 @@ public interface HrmResourceMapper {
Integer insertSearchTemplate(SearchTemplatePO templatePO);
Integer deleteSearchTemplate(@Param("id") Integer Id, @Param("userId") Integer userId);
+
+ Integer insertCustomTemplate(SearchTemplatePO templatePO);
+
+ Integer deleteCustomTemplate(@Param("id") Integer Id, @Param("userId") Integer userId);
}
diff --git a/src/com/engine/organization/mapper/resource/HrmResourceMapper.xml b/src/com/engine/organization/mapper/resource/HrmResourceMapper.xml
index 567ee6b6..793d042a 100644
--- a/src/com/engine/organization/mapper/resource/HrmResourceMapper.xml
+++ b/src/com/engine/organization/mapper/resource/HrmResourceMapper.xml
@@ -11,7 +11,7 @@
-
+
@@ -129,7 +129,9 @@
where id = #{id}
-
+
INSERT INTO JCL_ORG_SEARCH_TEMPLATE
@@ -179,6 +181,165 @@
+
+
+ select JCL_ORG_SEARCH_TEMPLATE_ID.currval from dual
+
+ INSERT INTO JCL_ORG_SEARCH_TEMPLATE
+
+
+ creator,
+
+
+ create_time,
+
+
+ update_time,
+
+
+ name,
+
+
+ basic_fields,
+
+
+ personal_fields,
+
+
+ work_fields,
+
+
+
+
+ #{creator},
+
+
+ #{createTime},
+
+
+ #{updateTime},
+
+
+ #{name},
+
+
+ #{basicFields},
+
+
+ #{personalFields},
+
+
+ #{workFields},
+
+
+
+
+ INSERT INTO JCL_ORG_CUSTOM_TEMPLATE
+
+
+ creator,
+
+
+ create_time,
+
+
+ update_time,
+
+
+ name,
+
+
+ basic_fields,
+
+
+ personal_fields,
+
+
+ work_fields,
+
+
+
+
+ #{creator},
+
+
+ #{createTime},
+
+
+ #{updateTime},
+
+
+ #{name},
+
+
+ #{basicFields},
+
+
+ #{personalFields},
+
+
+ #{workFields},
+
+
+
+
+
+
+ select JCL_ORG_CUSTOM_TEMPLATE_ID.currval from dual
+
+ INSERT INTO JCL_ORG_CUSTOM_TEMPLATE
+
+
+ creator,
+
+
+ create_time,
+
+
+ update_time,
+
+
+ name,
+
+
+ basic_fields,
+
+
+ personal_fields,
+
+
+ work_fields,
+
+
+
+
+ #{creator},
+
+
+ #{createTime},
+
+
+ #{updateTime},
+
+
+ #{name},
+
+
+ #{basicFields},
+
+
+ #{personalFields},
+
+
+ #{workFields},
+
+
+
+
delete
from jcl_org_search_template
@@ -186,6 +347,13 @@
and creator = #{userId}
+
+ delete
+ from jcl_org_custom_template
+ where id = #{id}
+ and creator = #{userId}
+
+
AND t.lastname like CONCAT('%',#{resourcePO.lastName},'%')
diff --git a/src/com/engine/organization/service/HrmResourceService.java b/src/com/engine/organization/service/HrmResourceService.java
index 255d52b4..a794f2b0 100644
--- a/src/com/engine/organization/service/HrmResourceService.java
+++ b/src/com/engine/organization/service/HrmResourceService.java
@@ -1,11 +1,10 @@
package com.engine.organization.service;
import com.engine.organization.entity.hrmresource.param.HrmRelationSaveParam;
-import com.engine.organization.entity.hrmresource.param.HrmResourceSearchParam;
import com.engine.organization.entity.hrmresource.param.SearchTemplateParam;
import com.engine.organization.entity.searchtree.SearchTreeParams;
-import org.apache.ibatis.annotations.Param;
+import java.util.List;
import java.util.Map;
/**
@@ -29,7 +28,7 @@ public interface HrmResourceService {
* @param params
* @return
*/
- Map listPage(HrmResourceSearchParam params);
+ Map listPage(Map params);
/**
* 获取新增表单
@@ -98,7 +97,49 @@ public interface HrmResourceService {
*/
long updateTabForm(HrmRelationSaveParam params);
- void saveSearchTemplate(SearchTemplateParam params);
+ /**
+ * 保存搜索条件模板
+ *
+ * @param params
+ * @return
+ */
+ Integer saveSearchTemplate(SearchTemplateParam params);
+
+ /**
+ * 删除搜索条件模板
+ *
+ * @param id
+ */
+ void deleteSearchTemplate(Integer id);
+
+ /**
+ * 获取模板所选择的列
+ *
+ * @param params
+ * @return
+ */
+ String getTemplateSelectKeys(Map params);
- void deleteSearchTemplate(@Param("id") Integer id);
+ /**
+ * 展示所有搜索模板
+ *
+ * @param params
+ * @return
+ */
+ List getSearchTemplate(Map params);
+
+ /**
+ * 保存定制列模板
+ *
+ * @param params
+ * @return
+ */
+ Integer saveCustomTemplate(SearchTemplateParam params);
+
+ /**
+ * 删除定制列模板
+ *
+ * @param id
+ */
+ void deleteCustomTemplate(Integer id);
}
diff --git a/src/com/engine/organization/service/impl/HrmResourceServiceImpl.java b/src/com/engine/organization/service/impl/HrmResourceServiceImpl.java
index 13513603..557e5526 100644
--- a/src/com/engine/organization/service/impl/HrmResourceServiceImpl.java
+++ b/src/com/engine/organization/service/impl/HrmResourceServiceImpl.java
@@ -2,6 +2,8 @@ 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;
@@ -13,10 +15,8 @@ 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.fieldset.param.TransferDataParam;
import com.engine.organization.entity.hrmresource.bo.HrmRelationBO;
import com.engine.organization.entity.hrmresource.param.HrmRelationSaveParam;
-import com.engine.organization.entity.hrmresource.param.HrmResourceSearchParam;
import com.engine.organization.entity.hrmresource.param.SearchTemplateParam;
import com.engine.organization.entity.hrmresource.po.HrmRelationPO;
import com.engine.organization.entity.hrmresource.po.SearchTemplatePO;
@@ -26,6 +26,7 @@ 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;
@@ -49,7 +50,6 @@ import weaver.conn.RecordSet;
import weaver.general.StringUtil;
import weaver.general.Util;
import weaver.hrm.definedfield.HrmFieldManager;
-import weaver.systeminfo.SystemEnv;
import java.util.*;
import java.util.stream.Collectors;
@@ -98,6 +98,11 @@ public class HrmResourceServiceImpl extends Service implements HrmResourceServic
return MapperProxyFactory.getProxy(SystemDataMapper.class);
}
+ // 所有满足条件的岗位ID
+ private List jobTitleList = new ArrayList<>();
+ // 是否
+ boolean searchJobTitle = false;
+
@Override
public Map getSearchTree(SearchTreeParams params) {
@@ -109,10 +114,9 @@ public class HrmResourceServiceImpl extends Service implements HrmResourceServic
}
@Override
- public Map listPage(HrmResourceSearchParam params) {
+ public Map listPage(Map params) {
OrganizationWeaTable table = new OrganizationWeaTable<>(user, HrmResourceVO.class);
- Map searchParams = new HashMap<>();
- String sqlWhere = buildSqlWhere(searchParams);
+ String sqlWhere = buildSqlWhere(params);
table.setSqlwhere(sqlWhere);
WeaResultMsg result = new WeaResultMsg(false);
result.putAll(table.makeDataResult());
@@ -144,25 +148,17 @@ public class HrmResourceServiceImpl extends Service implements HrmResourceServic
}
@Override
- public void saveSearchTemplate(SearchTemplateParam params) {
- String[] split = params.getFields().split(",");
- if (split.length > 0) {
- List basicFieldsBuilder = new ArrayList<>();
- List personalFieldsBuilder = new ArrayList<>();
- List workFieldsBuilder = new ArrayList<>();
- for (String fieldName : split) {
- if (fieldName.startsWith("-1")) {
- basicFieldsBuilder.add(fieldName.substring(fieldName.lastIndexOf("_") + 1));
- } else if (fieldName.startsWith("1")) {
- personalFieldsBuilder.add(fieldName.substring(fieldName.lastIndexOf("_") + 1));
- } else if (fieldName.startsWith("3")) {
- workFieldsBuilder.add(fieldName.substring(fieldName.lastIndexOf("_") + 1));
- }
- }
- SearchTemplatePO searchTemplatePO = SearchTemplatePO.builder().name(params.getShowname()).basicFields(StringUtils.join(basicFieldsBuilder, ",")).personalFields(StringUtils.join(personalFieldsBuilder, ",")).workFields(StringUtils.join(workFieldsBuilder, ",")).creator(user.getUID()).createTime(new Date()).updateTime(new Date()).build();
- getHrmResourceMapper().insertSearchTemplate(searchTemplatePO);
- // 保存模板
+ 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
@@ -170,9 +166,71 @@ public class HrmResourceServiceImpl extends Service implements HrmResourceServic
getHrmResourceMapper().deleteSearchTemplate(id, user.getUID());
}
+ @Override
+ public String getTemplateSelectKeys(Map params) {
+ String templateId = Util.null2String(params.get("templateId"));
+ String column = Util.null2String(params.get("column"));
+ OrganizationAssert.isTrue(StringUtils.isNotBlank(templateId), "数据有误,未找到对应数据");
+ // 判断是否为搜索模板
+ if (StringUtils.isBlank(column)) {
+ SearchTemplatePO searchTemplateById = getHrmResourceMapper().getSearchTemplateById(templateId);
+ String basicFields = searchTemplateById.getBasicFields();
+ String personalFields = searchTemplateById.getPersonalFields();
+ String workflowFields = searchTemplateById.getWorkFields();
+ List selectKeys = new ArrayList<>();
+ 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 StringUtils.join(selectKeys, ",");
+ }
+ return "";
+
+ }
+
+ @Override
+ public List getSearchTemplate(Map params) {
+ String templateId = StringUtils.isNotBlank(Util.null2String(params.get("templateId"))) ? Util.null2String(params.get("templateId")) : "-1";
+ int userUID = user.getUID();
+ // 根据ID查询所存储的模板
+ List templates = getHrmResourceMapper().getSearchTemplatesByUser(userUID);
+ templates.add(0, SearchTemplateParam.builder().key("-1").selected(false).showname("默认模板").build());
+ templates.forEach(item -> {
+ if (templateId.equals(item.getKey())) {
+ item.setSelected(true);
+ }
+ });
+ return templates;
+ }
+
+ @Override
+ public Integer saveCustomTemplate(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().insertCustomTemplate(templatePO);
+ return templatePO.getId();
+ }
+
+ @Override
+ public void deleteCustomTemplate(Integer id) {
+ getHrmResourceMapper().deleteCustomTemplate(id, user.getUID());
+ }
+
@Override
public Map getSearchCondition(Map params) {
String templateId = Util.null2String(params.get("templateId"));
+ String selectKeys = Util.null2String(params.get("selectKeys"));
if (StringUtils.isBlank(templateId)) {
templateId = "-1";
}
@@ -182,41 +240,24 @@ public class HrmResourceServiceImpl extends Service implements HrmResourceServic
// 穿梭框ID,展示所选字段信息
HrmFieldSearchConditionComInfo hrmFieldSearchConditionComInfo = new HrmFieldSearchConditionComInfo();
if ("-1".equals(templateId)) {
- // 未选择模板展示默认模板搜索条件
- List searchConditionItems = new ArrayList<>();
- List hrmFieldsByScopeId = getSystemDataMapper().getHrmFieldsByScopeId("-1");
- createConditionItems(hrmFieldSearchConditionComInfo, hrmFieldsByScopeId, searchConditionItems);
- if (CollectionUtils.isNotEmpty(searchConditionItems)) {
- addGroups.add(new SearchConditionGroup("基本信息", true, searchConditionItems));
+ 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);
- String[] basicFields = Util.null2String(searchTemplateById.getBasicFields()).split(",");
- if (basicFields.length > 0) {
- getTemplateItems(hrmFieldSearchConditionComInfo, addGroups, "基本信息", -1, basicFields);
- }
-
- String[] personalFields = Util.null2String(searchTemplateById.getPersonalFields()).split(",");
- if (personalFields.length > 0) {
- getTemplateItems(hrmFieldSearchConditionComInfo, addGroups, "个人信息", 1, personalFields);
- }
- String[] workFields = Util.null2String(searchTemplateById.getWorkFields()).split(",");
- if (workFields.length > 0) {
- getTemplateItems(hrmFieldSearchConditionComInfo, addGroups, "工作信息", 3, workFields);
- }
-
+ buildSearchConditionGroup(searchTemplateById, hrmFieldSearchConditionComInfo, addGroups);
}
apiDatas.put("defaultcondition", addGroups);
apiDatas.put("conditions", allConditions);
- List searchTemplate = getSearchTemplate();
- String finalTemplateId = templateId;
- searchTemplate.forEach(item -> {
- if (finalTemplateId.equals(item.getKey())) {
- item.setSelected(true);
- }
- });
- apiDatas.put("templates", searchTemplate);
return apiDatas;
}
@@ -227,6 +268,7 @@ public class HrmResourceServiceImpl extends Service implements HrmResourceServic
ArrayList topMenuList = new ArrayList<>();
ArrayList 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());
@@ -341,61 +383,39 @@ public class HrmResourceServiceImpl extends Service implements HrmResourceServic
* @return
*/
private String buildSqlWhere(Map params) {
+ HrmFieldSearchConditionComInfo hrmFieldSearchConditionComInfo = new HrmFieldSearchConditionComInfo();
+ List conditionItems = new ArrayList<>();
+ List 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 allFieldsMap = conditionItems.stream().collect(Collectors.toMap(item -> item.getDomkey()[0], item -> item, (k1, k2) -> k1));
+
+
DBType dbType = DBType.get(new RecordSet().getDBType());
- String sqlWhere = " where 1=1 ";
+ //String sqlWhere = "";
+ StringBuilder sb = new StringBuilder(" where 1=1 ");
for (Map.Entry entry : params.entrySet()) {
+ String value = Util.null2String(entry.getValue());
+ if (StringUtils.isBlank(value)) {
+ continue;
+ }
String key = entry.getKey();
- Object value = entry.getValue();
+ SearchConditionItem searchConditionItem = allFieldsMap.get(key);
+ buildDynamicSql(searchConditionItem, key, value, sb, dbType);
+ // 根据不同的类型,不同的查询方式
}
- //String lastName = params.getLastName();
- //if (StringUtils.isNotBlank(lastName)) {
- // sqlWhere += " AND t.lastname " + dbType.like(lastName);
- //}
- //Long companyId = params.getCompanyId();
- //if (null != companyId) {
- // sqlWhere += " AND t.subcompanyid1 = '" + companyId + "'";
- //}
- //Long departmentId = params.getDepartmentId();
- //if (null != departmentId) {
- // sqlWhere += " AND t.departmentid = '" + departmentId + "'";
- //}
- //Long ecCompany = params.getEcCompany();
- //if (null != ecCompany) {
- // sqlWhere += " AND t.subcompanyid1 = '" + ecCompany + "'";
- //}
- //Long ecDepartment = params.getEcDepartment();
- //if (null != ecDepartment) {
- // sqlWhere += " AND t.departmentid = '" + ecDepartment + "'";
- //}
- //String telephone = params.getTelephone();
- //if (StringUtils.isNotBlank(telephone)) {
- // sqlWhere += " AND t.telephone " + dbType.like(telephone);
- //}
- //String mobile = params.getMobile();
- //if (StringUtils.isNotBlank(mobile)) {
- // sqlWhere += " AND t.mobile " + dbType.like(mobile);
- //}
- //Long jobTitle = params.getJobTitle();
- //if (null != jobTitle) {
- // JobPO ecJobTitleByJobId = JobBO.getEcJobTitleByJobId(jobTitle);
- // if (null != ecJobTitleByJobId) {
- // sqlWhere += " AND t.subcompanyid1 = '" + ecJobTitleByJobId.getEcCompany() + "'";
- // sqlWhere += " AND t.departmentid = '" + ecJobTitleByJobId.getEcDepartment() + "'";
- // sqlWhere += " AND t.jobtitle = '" + ecJobTitleByJobId.getEcJobTitle() + "'";
- // } else {
- // sqlWhere = " where 1 = 2 ";
- // }
- //}
-
// 分权查询
DetachUtil detachUtil = new DetachUtil(user);
String parentCompanyIds = detachUtil.getJclRoleLevels();
if (detachUtil.isDETACH()) {
- sqlWhere += " And t.subcompanyid1 in(" + parentCompanyIds + ")";
+ sb.append(" And t.subcompanyid1 in(").append(parentCompanyIds).append(")");
}
- return sqlWhere;
+ return sb.toString();
}
public List getFilterCompany(String id, String type, String keyword) {
@@ -575,18 +595,10 @@ public class HrmResourceServiceImpl extends Service implements HrmResourceServic
/**
- * 获取当前人员所有的模板信息
+ * 获取所有搜索字段信息构建的高级搜索表单
*
* @return
*/
- public List getSearchTemplate() {
- int userUID = user.getUID();
- // 根据ID查询所存储的模板
- List templates = getHrmResourceMapper().getSearchTemplatesByUser(userUID);
- templates.add(0, SearchTemplateParam.builder().key("-1").selected(false).showname("默认模板").build());
- return templates;
- }
-
public List getAllConditions() {
HrmFieldSearchConditionComInfo hrmFieldSearchConditionComInfo = new HrmFieldSearchConditionComInfo();
List addGroups = new ArrayList<>();
@@ -595,21 +607,21 @@ public class HrmResourceServiceImpl extends Service implements HrmResourceServic
List workConditionItems = new ArrayList<>();
// 基本信息:-1
- List hrmFieldsByScopeId = getSystemDataMapper().getHrmFieldsByScopeId("-1");
+ List 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("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("3");
+ hrmFieldsByScopeId = getSystemDataMapper().getHrmFieldsByScopeId(HrmGroupEnum.HRM_WORK.getGroupType().toString());
createConditionItems(hrmFieldSearchConditionComInfo, hrmFieldsByScopeId, workConditionItems);
if (CollectionUtils.isNotEmpty(workConditionItems)) {
addGroups.add(new SearchConditionGroup("工作信息", true, workConditionItems));
@@ -626,6 +638,10 @@ public class HrmResourceServiceImpl extends Service implements HrmResourceServic
*/
private void createConditionItems(HrmFieldSearchConditionComInfo hrmFieldSearchConditionComInfo, List formFields, List conditionItems) {
for (CusFormFieldPO cusFormFieldPO : formFields) {
+ if ("jobactivity".equals(cusFormFieldPO.getFieldName())) {
+ // 职务:282
+ cusFormFieldPO.setType("282");
+ }
HrmFieldBean hrmFieldBean = new HrmFieldBean();
hrmFieldBean.setFieldid(Util.null2String(cusFormFieldPO.getFieldId()));
hrmFieldBean.setFieldname(cusFormFieldPO.getScopeId() + "_" + cusFormFieldPO.getTableName() + "_" + cusFormFieldPO.getFieldName());
@@ -639,21 +655,11 @@ public class HrmResourceServiceImpl extends Service implements HrmResourceServic
hrmFieldBean.setIsFormField(true);
SearchConditionItem searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user);
conditionItems.add(searchConditionItem);
- }
- }
+ // 如果为下拉框,添加一条空选项
+ if (searchConditionItem.getConditionType().equals(ConditionType.SELECT)) {
+ addEmptyForSelect(searchConditionItem);
+ }
- /**
- * 构建穿梭框字段
- *
- * @param formFields
- * @param dataParamList
- * @param title
- */
- private void createTransferData(List formFields, List dataParamList, String title) {
- for (CusFormFieldPO cusFormFieldPO : formFields) {
- String id = cusFormFieldPO.getTableName() + "_" + cusFormFieldPO.getScopeId() + "_" + cusFormFieldPO.getFieldId();
- String label = Util.toScreen(SystemEnv.getHtmlLabelName(Integer.parseInt(cusFormFieldPO.getFieldLabel()), user.getLanguage()), user.getLanguage());
- dataParamList.add(TransferDataParam.builder().id(id).label(label).title(title).build());
}
}
@@ -671,7 +677,8 @@ public class HrmResourceServiceImpl extends Service implements HrmResourceServic
HrmFieldManager hfm = new HrmFieldManager("HrmCustomFieldByInfoType", scopeid);
List conditionItems = new ArrayList<>();
- for (String fieldName : fieldNames) {
+ for (String field : fieldNames) {
+ String fieldName = field.substring(field.lastIndexOf("_") + 1);
JSONObject hrmFieldConf = hfm.getHrmFieldConf(fieldName);
if (null == hrmFieldConf) {
continue;
@@ -688,8 +695,16 @@ public class HrmResourceServiceImpl extends Service implements HrmResourceServic
hrmFieldBean.setIsFormField(true);
hrmFieldBean.setIsQuickSearch(false);
hrmFieldBean.setIsScope(false);
+ if ("jobactivity".equals(fieldName)) {
+ // 职务:282
+ hrmFieldBean.setType("282");
+ }
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));
@@ -698,4 +713,160 @@ public class HrmResourceServiceImpl extends Service implements HrmResourceServic
throw new RuntimeException(e);
}
}
+
+ /**
+ * 根据所选字段信息,构建搜素模板对象
+ *
+ * @param fields
+ * @return
+ */
+ private SearchTemplatePO buildSearchTemplateByFields(String fields) {
+ String[] split = fields.split(",");
+ if (split.length > 0) {
+ List basicFields = new ArrayList<>();
+ List personalFields = new ArrayList<>();
+ List 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 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);
+ }
+ //
+ if (key.endsWith("jobactivity")) {
+ searchJobTitle = true;
+ }
+ if (key.endsWith("jobGroupId")) {
+ searchJobTitle = true;
+ }
+ if (key.endsWith("jobtitle")) {
+ searchJobTitle = true;
+ }
+ 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 options = searchConditionItem.getOptions();
+ options.forEach(item -> {
+ item.setSelected(false);
+ });
+ SearchConditionOption searchConditionOption = new SearchConditionOption();
+ searchConditionOption.setSelected(true);
+ searchConditionOption.setKey("");
+ options.add(0, searchConditionOption);
+
+ }
}
diff --git a/src/com/engine/organization/service/impl/JobServiceImpl.java b/src/com/engine/organization/service/impl/JobServiceImpl.java
index 25cf632f..3268828b 100644
--- a/src/com/engine/organization/service/impl/JobServiceImpl.java
+++ b/src/com/engine/organization/service/impl/JobServiceImpl.java
@@ -581,7 +581,7 @@ public class JobServiceImpl extends Service implements JobService {
//2.数据过滤
//3.数据插入
resourcePOS.forEach(resourcePO -> {
- if (Objects.nonNull(resourcePO) && null != resourcePO.getJobtitle() && 0 != resourcePO.getJobtitle()) {
+ if (Objects.nonNull(resourcePO) && null != resourcePO.getJobtitle() && resourcePO.getJobtitle() > 0) {
int count = getJobMapper().selectByConditions(resourcePO);
if (count == 0) {
JobPO jobPO = JobPO.builder()
diff --git a/src/com/engine/organization/util/db/DBOperateAdapter.java b/src/com/engine/organization/util/db/DBOperateAdapter.java
index 50d2dda6..e9caa997 100644
--- a/src/com/engine/organization/util/db/DBOperateAdapter.java
+++ b/src/com/engine/organization/util/db/DBOperateAdapter.java
@@ -6,4 +6,6 @@ public interface DBOperateAdapter {
String concat(String some);
String currentDate();
+
+ String ifNull(String some, String defaultValue);
}
diff --git a/src/com/engine/organization/util/db/DBType.java b/src/com/engine/organization/util/db/DBType.java
index 6581acab..d929560d 100644
--- a/src/com/engine/organization/util/db/DBType.java
+++ b/src/com/engine/organization/util/db/DBType.java
@@ -20,6 +20,11 @@ public enum DBType implements DBOperateAdapter {
public String currentDate() {
return "now()";
}
+
+ @Override
+ public String ifNull(String some, String defaultValue) {
+ return " ifnull(" + some + ",'" + defaultValue + "')";
+ }
},
SQLSERVER("sqlserver") {
@Override
@@ -36,11 +41,16 @@ public enum DBType implements DBOperateAdapter {
public String currentDate() {
return "GETDATE()";
}
+
+ @Override
+ public String ifNull(String some, String defaultValue) {
+ return " isnull(" + some + ",'" + defaultValue + "')";
+ }
},
ORACLE("oracle") {
@Override
public String like(String some) {
- return " like '%'||" + some + "||'%' ";
+ return " like '%" + some + "%' ";
}
@Override
@@ -52,6 +62,11 @@ public enum DBType implements DBOperateAdapter {
public String currentDate() {
return "SYSDATE";
}
+
+ @Override
+ public String ifNull(String some, String defaultValue) {
+ return " NVL(" + some + ",'" + defaultValue + "')";
+ }
};
private String dbtype;
diff --git a/src/com/engine/organization/web/HrmResourceController.java b/src/com/engine/organization/web/HrmResourceController.java
index b7045aec..7813c5f0 100644
--- a/src/com/engine/organization/web/HrmResourceController.java
+++ b/src/com/engine/organization/web/HrmResourceController.java
@@ -5,13 +5,13 @@ import com.alibaba.fastjson.JSONObject;
import com.engine.common.util.ParamUtil;
import com.engine.common.util.ServiceUtil;
import com.engine.organization.entity.hrmresource.param.HrmRelationSaveParam;
-import com.engine.organization.entity.hrmresource.param.HrmResourceSearchParam;
import com.engine.organization.entity.hrmresource.param.SearchTemplateParam;
import com.engine.organization.entity.hrmresource.po.SearchTemplatePO;
import com.engine.organization.entity.searchtree.SearchTreeParams;
import com.engine.organization.util.response.ReturnResult;
import com.engine.organization.wrapper.HrmResourceWrapper;
import io.swagger.v3.oas.annotations.parameters.RequestBody;
+import weaver.general.Util;
import weaver.hrm.HrmUserVarify;
import weaver.hrm.User;
@@ -67,8 +67,7 @@ public class HrmResourceController {
try {
User user = HrmUserVarify.getUser(request, response);
Map map = ParamUtil.request2Map(request);
- HrmResourceSearchParam param = JSONObject.toJavaObject((JSON) JSONObject.toJSON(map), HrmResourceSearchParam.class);
- return ReturnResult.successed(getHrmResourceWrapper(user).listPage(param));
+ return ReturnResult.successed(getHrmResourceWrapper(user).listPage(map));
} catch (Exception e) {
return ReturnResult.exceptionHandle(e);
}
@@ -166,7 +165,7 @@ public class HrmResourceController {
try {
User user = HrmUserVarify.getUser(request, response);
Map map = ParamUtil.request2Map(request);
- return ReturnResult.successed(getHrmResourceWrapper(user).getSearchCondition(map));
+ return ReturnResult.successed(JSON.toJSON(getHrmResourceWrapper(user).getSearchCondition(map)));
} catch (Exception e) {
return ReturnResult.exceptionHandle(e);
}
@@ -179,8 +178,8 @@ public class HrmResourceController {
public ReturnResult saveSearchTemplate(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SearchTemplateParam params) {
try {
User user = HrmUserVarify.getUser(request, response);
- getHrmResourceWrapper(user).saveSearchTemplate(params);
- return ReturnResult.successed();
+ Integer templateId = getHrmResourceWrapper(user).saveSearchTemplate(params);
+ return ReturnResult.successed(Util.null2String(templateId));
} catch (Exception e) {
return ReturnResult.exceptionHandle(e);
}
@@ -199,6 +198,32 @@ public class HrmResourceController {
}
}
+ @GET
+ @Path("/getTemplateSelectKeys")
+ @Produces(MediaType.APPLICATION_JSON)
+ public ReturnResult getTemplateSelectKeys(@Context HttpServletRequest request, @Context HttpServletResponse response) {
+ try {
+ User user = HrmUserVarify.getUser(request, response);
+ Map map = ParamUtil.request2Map(request);
+ return ReturnResult.successed(JSON.toJSON(getHrmResourceWrapper(user).getTemplateSelectKeys(map)));
+ } catch (Exception e) {
+ return ReturnResult.exceptionHandle(e);
+ }
+ }
+
+ @GET
+ @Path("/getSearchTemplate")
+ @Produces(MediaType.APPLICATION_JSON)
+ public ReturnResult getSearchTemplate(@Context HttpServletRequest request, @Context HttpServletResponse response) {
+ try {
+ User user = HrmUserVarify.getUser(request, response);
+ Map map = ParamUtil.request2Map(request);
+ return ReturnResult.successed(JSON.toJSON(getHrmResourceWrapper(user).getSearchTemplate(map)));
+ } catch (Exception e) {
+ return ReturnResult.exceptionHandle(e);
+ }
+ }
+
/**
* 列表页顶部按钮
*
@@ -254,4 +279,30 @@ public class HrmResourceController {
return ReturnResult.exceptionHandle(e);
}
}
+
+ @POST
+ @Path("/saveCustomTemplate")
+ @Produces(MediaType.APPLICATION_JSON)
+ public ReturnResult saveCustomTemplate(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SearchTemplateParam params) {
+ try {
+ User user = HrmUserVarify.getUser(request, response);
+ Integer templateId = getHrmResourceWrapper(user).saveCustomTemplate(params);
+ return ReturnResult.successed(Util.null2String(templateId));
+ } catch (Exception e) {
+ return ReturnResult.exceptionHandle(e);
+ }
+ }
+
+ @POST
+ @Path("/deleteCustomTemplate")
+ @Produces(MediaType.APPLICATION_JSON)
+ public ReturnResult deleteCustomTemplate(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SearchTemplatePO params) {
+ try {
+ User user = HrmUserVarify.getUser(request, response);
+ getHrmResourceWrapper(user).deleteCustomTemplate(params.getId());
+ return ReturnResult.successed();
+ } catch (Exception e) {
+ return ReturnResult.exceptionHandle(e);
+ }
+ }
}
diff --git a/src/com/engine/organization/wrapper/HrmResourceWrapper.java b/src/com/engine/organization/wrapper/HrmResourceWrapper.java
index 553e8fa1..8e1e183d 100644
--- a/src/com/engine/organization/wrapper/HrmResourceWrapper.java
+++ b/src/com/engine/organization/wrapper/HrmResourceWrapper.java
@@ -4,7 +4,6 @@ import com.alibaba.fastjson.JSON;
import com.engine.common.util.ServiceUtil;
import com.engine.organization.annotation.Log;
import com.engine.organization.entity.hrmresource.param.HrmRelationSaveParam;
-import com.engine.organization.entity.hrmresource.param.HrmResourceSearchParam;
import com.engine.organization.entity.hrmresource.param.SearchTemplateParam;
import com.engine.organization.entity.searchtree.SearchTreeParams;
import com.engine.organization.enums.LogModuleNameEnum;
@@ -14,6 +13,7 @@ import com.engine.organization.service.impl.HrmResourceServiceImpl;
import com.engine.organization.util.OrganizationWrapper;
import weaver.hrm.User;
+import java.util.List;
import java.util.Map;
/**
@@ -31,7 +31,7 @@ public class HrmResourceWrapper extends OrganizationWrapper {
return getHrmResourceService(user).getSearchTree(params);
}
- public Map listPage(HrmResourceSearchParam params) {
+ public Map listPage(Map params) {
return getHrmResourceService(user).listPage(params);
}
@@ -60,14 +60,18 @@ public class HrmResourceWrapper extends OrganizationWrapper {
return getHrmResourceService(user).getSearchCondition(params);
}
- public void saveSearchTemplate(SearchTemplateParam params) {
- getHrmResourceService(user).saveSearchTemplate(params);
+ public Integer saveSearchTemplate(SearchTemplateParam params) {
+ return getHrmResourceService(user).saveSearchTemplate(params);
}
public void deleteSearchTemplate(Integer id) {
getHrmResourceService(user).deleteSearchTemplate(id);
}
+ public String getTemplateSelectKeys(Map params) {
+ return getHrmResourceService(user).getTemplateSelectKeys(params);
+ }
+
public Map getHasRight() {
return getHrmResourceService(user).getHasRight();
}
@@ -84,4 +88,15 @@ public class HrmResourceWrapper extends OrganizationWrapper {
return getHrmResourceService(user).updateTabForm(params);
}
+ public List getSearchTemplate(Map params) {
+ return getHrmResourceService(user).getSearchTemplate(params);
+ }
+
+ public Integer saveCustomTemplate(SearchTemplateParam params) {
+ return getHrmResourceService(user).saveCustomTemplate(params);
+ }
+
+ public void deleteCustomTemplate(Integer id) {
+ getHrmResourceService(user).deleteCustomTemplate(id);
+ }
}