泛微E10二开 组织架构、人员信息、分部信息基本操作

对接文档

https://weapp.eteams.cn/build/techdoc/wdoc/index.html#/public/repository/91f5067f-775e-48f4-93a2-ce84ca0b9c2e/doc/194965353510469632


组织查询(通用)

java 复制代码
@RestController
@RequestMapping("/api/secondev/hrm")
@RequiredArgsConstructor
public class DepartmentController {

    private final HrmCommonDepartmentService hrmCommonDepartmentService;

    @GetMapping("/list")
    public List<HrmDepartment>  list(@RequestParam  Map<String,String> params ){

        System.out.println(params);

        HrmOrgCondition hrmOrgCondition =new HrmOrgCondition();

        hrmOrgCondition.setTenantKey("tet4f7sfrj");//租户KEY 必填

        hrmOrgCondition.setIds(ConverterUtil.toList(params.get("ids"),Long.class));  //查询部门ID 

        hrmOrgCondition.setParentOrgIds(ConverterUtil.toList(params.get("parentOrgIds"),Long.class));//根据部门ID查出下级部门

        hrmOrgCondition.setStatusList(ConverterUtil.toList(params.get("statusList"),Integer.class));//部门启用状态 默认启用 1启用 0停用  传入1,0为全部查询

        hrmOrgCondition.setTypeList(ConverterUtil.toList(params.get("typeList"),String.class));//查询类型 subcompany 分部,department部门, 默认不过滤

        //hrmOrgCondition.setNameLikeList(Arrays.asList(nameLikeList));//部门名称模糊查询  //params.get("nameLinkList")

        List<HrmDepartment> objects = hrmCommonDepartmentService.queryOrgsByCondidtion(hrmOrgCondition, HrmConditionResultType.BEAN.name());

        return objects;
    }
    }

查询下级部门、分部

java 复制代码
@RestController
@RequestMapping("/api/secondev/hrm")
@RequiredArgsConstructor
public class DepartmentController {

    private final HrmCommonDepartmentService hrmCommonDepartmentService;


    /**
     * 查询下级分部列表
     * @param params
     * @return
     */
    @GetMapping("/subordinateList")
    public List<HrmDepartmentComInfo>  subordinateList(@RequestParam  Map<String,String> params ){

        System.out.println(params);

        HrmOrgRelationCodition hrmOrgCondition =new HrmOrgRelationCodition();

        hrmOrgCondition.setTenantKey("tet4f7sfrj");//租户KEY 必填 

        hrmOrgCondition.setIds(ConverterUtil.toList(params.get("ids"),Long.class));  //查询部门ID 或分部

        hrmOrgCondition.setQueryType(HrmOrgRelationQueryType.org_all_child_department);

        List<HrmDepartmentComInfo> objects = hrmCommonDepartmentService.findOrgRelationByCondtion(hrmOrgCondition);

        return objects;
    }

    /**
     * HrmOrgRelationQueryType参数说明
     *
     * org_direct_subcompany: 直接上级分部
     *
     * 如果id为分部,返回当前分部的上级分部;
     * 如果id为部门,获取当前部门归属分部,返回归属分部的上级分部;
     *
     * org_direct_department: 直接上级部门
     *
     * 如果id为分部,返回 null
     * 如果id为部门,返回当前部门的上级部门
     *
     * org_direct_child_sucompany:直接下级分部
     *
     * org_all_child_subcompany: 查询所有下级分部
     *
     * org_direct_child_department:直接下级部门
     *
     * org_all_child_department: 查询所有下级部门
     *
     * org_all_child_org: 查询所有下级组织
     *
     * org_allSuper_subcompany: 所有上级分部
     *
     * org_allSuper_department: 所有上级部门
     *
     * org_allSuper_org: 查询所有上级组织
     * @param params
     * @return
     */

}

查询人员信息

java 复制代码
@RestController
@RequestMapping("/api/secondev/hrm")
@RequiredArgsConstructor
public class DepartmentController {

    private final HrmCommonEmployeeService hrmCommonEmployeeService;

    @GetMapping("/getPersonnelMsg")
    public List<SimpleEmployee> getPersonnelMsg(@RequestParam Map<String,String> params){

        HrmEmployeIdFilterMeta hrmEmployeIdFilterMeta = new HrmEmployeIdFilterMeta();
        List<SimpleEmployee> employeeByIdsFilterMeta = hrmCommonEmployeeService.getEmployeeByIdsFilterMeta(ConverterUtil.toList(params.get("ids"), Long.class), "tet4f7sfrj", hrmEmployeIdFilterMeta);
        return employeeByIdsFilterMeta;
    }

}

封装工具类

java 复制代码
public class ConverterUtil {

    // 将输入转换为 List<T>,根据实际需要处理逗号分隔的情况
    public static <T> List<T> toList(String input, Class<T> type) {
        // 如果输入为空或仅包含空格,返回 null
        if (input == null || input.trim().isEmpty()) {
            return null;
        }

        List<T> resultList = new ArrayList<>();

        // 如果没有逗号,则将整个输入作为单个元素
        if (!input.contains(",")) {
            resultList.add(convertToType(input, type));
        } else {
            // 否则,根据逗号分隔处理输入
            String[] items = input.split(",");
            for (String item : items) {
                resultList.add(convertToType(item.trim(), type));
            }
        }

        return resultList;
    }

    // 根据类型转换输入字符串为目标类型
    private static <T> T convertToType(String input, Class<T> type) {
        try {
                if (type == Integer.class) return type.cast(Integer.parseInt(input));

                if (type == Long.class)  return type.cast(Long.parseLong(input));

                if (type == Double.class)  return type.cast(Double.parseDouble(input));

                if (type == String.class)  return type.cast(input);

                if (type == Boolean.class) return type.cast(Boolean.parseBoolean(input));

                if (type == Float.class) return type.cast(Float.parseFloat(input));

            {
                throw new IllegalArgumentException("Unsupported type: " + type.getName());
            }
        } catch (Exception e) {
            throw new IllegalArgumentException("Error converting input: " + input + " to " + type.getName(), e);
        }
    }


    public static void main(String[] args) {
        // 测试整数类型
        List<Integer> intList = toList("1,2,3,4", Integer.class);
        System.out.println(intList); // 输出:[1, 2, 3, 4]

        // 测试长整型类型
        List<Long> longList = toList("1000000000", Long.class);
        System.out.println(longList); // 输出:[1000000000, 2000000000]

        // 测试浮点型
        List<Double> doubleList = toList("1.23,4.56,7.89", Double.class);
        System.out.println(doubleList); // 输出:[1.23, 4.56, 7.89]

        // 测试布尔类型
        List<Boolean> booleanList = toList("true,false,true", Boolean.class);
        System.out.println(booleanList); // 输出:[true, false, true]

        // 测试没有逗号的情况
        List<String> singleItemList = toList("hello", String.class);
        System.out.println(singleItemList); // 输出:[hello]

        // 测试组合类型
        List<String> complexList = toList("apple,banana,orange", String.class);
        System.out.println(complexList); // 输出:[apple, banana, orange]

        // 测试空字符串输入
        List<String> emptyList = toList("", String.class);
        System.out.println(emptyList); // 输出:null

        // 测试 null 输入
        List<String> nullList = toList(null, String.class);
        System.out.println(nullList); // 输出:null
    }
}

相关推荐
码云数智-园园7 小时前
C++20 Modules 模块详解
java·开发语言·spring
程序员黑豆7 小时前
JDK 下载安装与配置详细教程
java·前端·ai编程
东方佑7 小时前
FRSM 规模效应与架构对比补充报告
架构
小宇宙Zz8 小时前
Maven依赖冲突
java·服务器·maven
swordbob8 小时前
NIO的channel中什么是 fd(File Descriptor,文件描述符)
java·开发语言·nio
咖啡八杯8 小时前
GoF设计模式——享元模式
java·spring·设计模式·享元模式
十五喵源码网8 小时前
基于springboot2+vue2的租房管理系统
java·毕业设计·springboot·论文笔记
摇滚侠8 小时前
IDEA 创建 Java 项目 手动整合 SSM 框架
java·ide·intellij-idea
源分享8 小时前
Java线程同步的多种实现方法(非常详细)
java·开发语言·jvm
Flittly8 小时前
【AgentScope Java新手村系列】(10)实战-多Agent天气助手
java·spring boot·spring