package com.engine.htxc.commonutil.dept;
import com.engine.htxc.commonutil.db.DbTools;
import com.engine.integration.util.StringUtils;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @author K1810015
 * @version 1.0.0
 * @ClassName DeptTools.java
 * @createTime 2022年08月26日 19:07:00
 */
public class DeptTools {

    public DeptTools() {
    }

    private static DbTools dbtools=new DbTools();

  public static List<String> getidtocode(String deptids){
        List<String> list=new ArrayList<>();
        if(StringUtils.isBlank(deptids)){
            return list;
        }
        String sql="select   wm_concat_old(departmentcode) as departmentcode  from hrmdepartment  where id in ("+ Arrays.stream(deptids.split(",")).distinct().collect(Collectors.joining(","))+")";
        String value=dbtools.getsqlonevalue(sql);
        if(StringUtils.isBlank(value)){
            return list;
        }
        return Arrays.stream(value.split(",")).collect(Collectors.toList());
    }
}
