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/service/impl/HrmResourceServiceImpl.java b/src/com/engine/organization/service/impl/HrmResourceServiceImpl.java index 13513603..9dec59d7 100644 --- a/src/com/engine/organization/service/impl/HrmResourceServiceImpl.java +++ b/src/com/engine/organization/service/impl/HrmResourceServiceImpl.java @@ -13,7 +13,6 @@ 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; @@ -49,7 +48,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; @@ -173,6 +171,7 @@ public class HrmResourceServiceImpl extends Service implements HrmResourceServic @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,30 +181,19 @@ 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); + 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); @@ -341,10 +329,24 @@ 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("-1"); + createConditionItems(hrmFieldSearchConditionComInfo, hrmFieldsByScopeId, conditionItems); + hrmFieldsByScopeId = getSystemDataMapper().getHrmFieldsByScopeId("1"); + createConditionItems(hrmFieldSearchConditionComInfo, hrmFieldsByScopeId, conditionItems); + hrmFieldsByScopeId = getSystemDataMapper().getHrmFieldsByScopeId("3"); + 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 "; for (Map.Entry entry : params.entrySet()) { String key = entry.getKey(); + SearchConditionItem searchConditionItem = allFieldsMap.get(key); + + // 根据不同的类型,不同的查询方式 Object value = entry.getValue(); } @@ -587,6 +589,11 @@ public class HrmResourceServiceImpl extends Service implements HrmResourceServic return templates; } + /** + * 获取所有搜索字段信息构建的高级搜索表单 + * + * @return + */ public List getAllConditions() { HrmFieldSearchConditionComInfo hrmFieldSearchConditionComInfo = new HrmFieldSearchConditionComInfo(); List addGroups = new ArrayList<>(); @@ -642,21 +649,6 @@ public class HrmResourceServiceImpl extends Service implements HrmResourceServic } } - /** - * 构建穿梭框字段 - * - * @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()); - } - } - /** * 获取模板中的字段,构建搜索条件 * @@ -698,4 +690,56 @@ public class HrmResourceServiceImpl extends Service implements HrmResourceServic throw new RuntimeException(e); } } + + /** + * 根据所选字段信息,构建搜素模板对象 + * + * @param fields + * @return + */ + private SearchTemplatePO buildSearchTemplateByFields(String fields) { + SearchTemplatePO templatePO = new SearchTemplatePO(); + String[] split = fields.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)); + } + } + templatePO.setBasicFields(basicFieldsBuilder.toString()); + templatePO.setPersonalFields(personalFieldsBuilder.toString()); + templatePO.setWorkFields(workFieldsBuilder.toString()); + } + return templatePO; + } + + /** + * 根据搜索模板对象,构建搜索条件表单 + * + * @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, "基本信息", -1, basicFields); + } + + String[] personalFields = Util.null2String(templatePO.getPersonalFields()).split(","); + if (personalFields.length > 0) { + getTemplateItems(hrmFieldSearchConditionComInfo, addGroups, "个人信息", 1, personalFields); + } + String[] workFields = Util.null2String(templatePO.getWorkFields()).split(","); + if (workFields.length > 0) { + getTemplateItems(hrmFieldSearchConditionComInfo, addGroups, "工作信息", 3, workFields); + } + } } diff --git a/src/com/engine/organization/web/HrmResourceController.java b/src/com/engine/organization/web/HrmResourceController.java index b7045aec..eac0cd50 100644 --- a/src/com/engine/organization/web/HrmResourceController.java +++ b/src/com/engine/organization/web/HrmResourceController.java @@ -166,7 +166,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); }