package com.engine.htsc.branch.approvalChain.dao;

import com.alibaba.fastjson.JSONObject;
import weaver.conn.RecordSet;
import weaver.general.Util;
import weaver.interfaces.htsc.GlobatTools.JAVATools;

import java.util.*;

public class UfFzjgfkgwppDao {

    public Map<String,String> getBybm(String bm){
        Map<String,String> result = new HashMap<>();
        String sql = "select a.bm,a.kj,a.kjjl,a.cn from uf_fzjgfkgwpp a where a.bm = " + "'"+bm+"'";
        RecordSet rs = new RecordSet();
        rs.execute(sql);
        if(rs.next()){
            result.put("kj",Util.null2String(rs.getString("kj")));
            result.put("kjjl",Util.null2String(rs.getString("kjjl")));
            result.put("cn",Util.null2String(rs.getString("cn")));
        }
        return result;
    }

    public List<Map<String, String>> getUserMap(String userids) {
        List<Map<String, String>> userMapList = new ArrayList<>();
        Map<String, String> codeAndIds = new HashMap<>();
        Map<String, String> idAndCodes = new HashMap<>();
        if (userids==null || "".equals(userids)){
            userMapList.add(idAndCodes);
            userMapList.add(codeAndIds);
            return  userMapList;
        }
        RecordSet rs=new RecordSet();
        String sql="select workcode,id from hrmresource where id in ("+userids+")";
        JAVATools.writelog("获取人员id和工号sql："+sql);
        rs.execute(sql);
        if(rs.getCounts()<=0){
            userMapList.add(idAndCodes);
            userMapList.add(codeAndIds);
            return  userMapList;
        }
        while(rs.next()){
            String workcode= Util.null2String(rs.getString("workcode"));
            String id= Util.null2String(rs.getString("id"));
            if(!"".equals(workcode)){
                idAndCodes.put(id,workcode);
                codeAndIds.put(workcode,id);
            }
        }
        userMapList.add(idAndCodes);
        userMapList.add(codeAndIds);
        return userMapList;
    }
}
