显示定制列穿梭框接口开发
This commit is contained in:
parent
4076a755f1
commit
d5ca665f2f
|
|
@ -0,0 +1,22 @@
|
|||
package com.engine.organization.entity.hrmresource.po;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* @author:dxfeng
|
||||
* @createTime: 2023/01/11
|
||||
* @version: 1.0
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class TransferDataPO {
|
||||
private String id;
|
||||
private String label;
|
||||
private String title;
|
||||
private String idx;
|
||||
}
|
||||
|
|
@ -48,6 +48,8 @@ public interface HrmResourceMapper {
|
|||
|
||||
SearchTemplatePO getSearchTemplateById(@Param("id") String id);
|
||||
|
||||
SearchTemplatePO getCustomTemplateById(@Param("id") String id);
|
||||
|
||||
Integer insertSearchTemplate(SearchTemplatePO templatePO);
|
||||
|
||||
Integer deleteSearchTemplate(@Param("id") Integer Id, @Param("userId") Integer userId);
|
||||
|
|
|
|||
|
|
@ -129,6 +129,13 @@
|
|||
where id = #{id}
|
||||
</select>
|
||||
|
||||
<select id="getCustomTemplateById"
|
||||
resultType="com.engine.organization.entity.hrmresource.po.SearchTemplatePO">
|
||||
select *
|
||||
from jcl_org_custom_template
|
||||
where id = #{id}
|
||||
</select>
|
||||
|
||||
<insert id="insertSearchTemplate" parameterType="com.engine.organization.entity.hrmresource.po.SearchTemplatePO"
|
||||
keyProperty="id"
|
||||
keyColumn="id" useGeneratedKeys="true">
|
||||
|
|
|
|||
|
|
@ -142,4 +142,12 @@ public interface HrmResourceService {
|
|||
* @param id
|
||||
*/
|
||||
void deleteCustomTemplate(Integer id);
|
||||
|
||||
/**
|
||||
* 获取列定制穿梭框数据
|
||||
*
|
||||
* @param params
|
||||
* @return
|
||||
*/
|
||||
Map<String, Object> getCustomTransferData(Map<String, Object> params);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ import com.engine.organization.entity.hrmresource.param.HrmRelationSaveParam;
|
|||
import com.engine.organization.entity.hrmresource.param.SearchTemplateParam;
|
||||
import com.engine.organization.entity.hrmresource.po.HrmRelationPO;
|
||||
import com.engine.organization.entity.hrmresource.po.SearchTemplatePO;
|
||||
import com.engine.organization.entity.hrmresource.po.TransferDataPO;
|
||||
import com.engine.organization.entity.hrmresource.vo.HrmResourceVO;
|
||||
import com.engine.organization.entity.jclimport.po.CusFormFieldPO;
|
||||
import com.engine.organization.entity.job.bo.JobBO;
|
||||
|
|
@ -52,6 +53,7 @@ import weaver.general.Util;
|
|||
import weaver.hrm.definedfield.HrmFieldManager;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
|
|
@ -168,29 +170,19 @@ public class HrmResourceServiceImpl extends Service implements HrmResourceServic
|
|||
|
||||
@Override
|
||||
public String getTemplateSelectKeys(Map<String, Object> params) {
|
||||
// TODO
|
||||
String templateId = Util.null2String(params.get("templateId"));
|
||||
String column = Util.null2String(params.get("column"));
|
||||
OrganizationAssert.isTrue(StringUtils.isNotBlank(templateId), "数据有误,未找到对应数据");
|
||||
// 判断是否为搜索模板
|
||||
SearchTemplatePO searchTemplateById = null;
|
||||
if (StringUtils.isBlank(column)) {
|
||||
SearchTemplatePO searchTemplateById = getHrmResourceMapper().getSearchTemplateById(templateId);
|
||||
String basicFields = searchTemplateById.getBasicFields();
|
||||
String personalFields = searchTemplateById.getPersonalFields();
|
||||
String workflowFields = searchTemplateById.getWorkFields();
|
||||
List<String> 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, ",");
|
||||
searchTemplateById = getHrmResourceMapper().getSearchTemplateById(templateId);
|
||||
} else {
|
||||
searchTemplateById = getHrmResourceMapper().getCustomTemplateById(templateId);
|
||||
}
|
||||
return "";
|
||||
|
||||
List<String> selectKeys = getSelectKeys(searchTemplateById);
|
||||
return StringUtils.join(selectKeys, ",");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -227,6 +219,38 @@ public class HrmResourceServiceImpl extends Service implements HrmResourceServic
|
|||
getHrmResourceMapper().deleteCustomTemplate(id, user.getUID());
|
||||
}
|
||||
|
||||
@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<>();
|
||||
List<String> transferKeys = new ArrayList<>();
|
||||
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)) {
|
||||
List<SearchConditionItem> items = allConditions.get(0).getItems();
|
||||
transferKeys = items.stream().map(item -> item.getDomkey()[0]).collect(Collectors.toList());
|
||||
} else {
|
||||
SearchTemplatePO searchTemplateById = getHrmResourceMapper().getCustomTemplateById(templateId);
|
||||
transferKeys = getSelectKeys(searchTemplateById);
|
||||
}
|
||||
|
||||
resultMap.put("transferDatas", transferDatas);
|
||||
resultMap.put("transferKeys", transferKeys);
|
||||
resultMap.put("transferOptions", transferOptions);
|
||||
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getSearchCondition(Map<String, Object> params) {
|
||||
String templateId = Util.null2String(params.get("templateId"));
|
||||
|
|
@ -879,6 +903,11 @@ public class HrmResourceServiceImpl extends Service implements HrmResourceServic
|
|||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 为下拉框搜索条件、添加空选项
|
||||
*
|
||||
* @param searchConditionItem
|
||||
*/
|
||||
private void addEmptyForSelect(SearchConditionItem searchConditionItem) {
|
||||
searchConditionItem.setValue("");
|
||||
List<SearchConditionOption> options = searchConditionItem.getOptions();
|
||||
|
|
@ -891,4 +920,27 @@ public class HrmResourceServiceImpl extends Service implements HrmResourceServic
|
|||
options.add(0, searchConditionOption);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据模板示例,组装所有selectKeys
|
||||
*
|
||||
* @param searchTemplatePO
|
||||
* @return
|
||||
*/
|
||||
private List<String> getSelectKeys(SearchTemplatePO searchTemplatePO) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -305,4 +305,17 @@ public class HrmResourceController {
|
|||
return ReturnResult.exceptionHandle(e);
|
||||
}
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("/getCustomTransferData")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public ReturnResult getCustomTransferData(@Context HttpServletRequest request, @Context HttpServletResponse response) {
|
||||
try {
|
||||
User user = HrmUserVarify.getUser(request, response);
|
||||
Map<String, Object> map = ParamUtil.request2Map(request);
|
||||
return ReturnResult.successed(JSON.toJSON(getHrmResourceWrapper(user).getCustomTransferData(map)));
|
||||
} catch (Exception e) {
|
||||
return ReturnResult.exceptionHandle(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -99,4 +99,8 @@ public class HrmResourceWrapper extends OrganizationWrapper {
|
|||
public void deleteCustomTemplate(Integer id) {
|
||||
getHrmResourceService(user).deleteCustomTemplate(id);
|
||||
}
|
||||
|
||||
public Map<String, Object> getCustomTransferData(Map<String, Object> params) {
|
||||
return getHrmResourceService(user).getCustomTransferData(params);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue