package com.engine.htsc.ReimbursementFlow.Dao;

import com.weaver.general.Util;
import weaver.interfaces.htsc.GlobatTools.JAVATools;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class ReimbursementExcelDao {

    public Map<String, Object> getOtherMap(String tablename,Map<String,String> parmasmap ) {
        String sqlmain = "select * from " + tablename + " where 1=1 ";
        Map<String, Object> mapmain = new HashMap<>();
        mapmain = JAVATools.GetTableToMap(sqlmain, parmasmap);
        return mapmain;
    }

    public Map<String, Object> getMainMap(String reqid, String tablename) {
        Map<String, Object> mapmain = new HashMap<>();
        String sqlmain = "select * from " + tablename + " where 1=1 ";
        Map<String, String> map = new HashMap<>();
        map.put("requestid", reqid);
        mapmain = JAVATools.GetTableToMap(sqlmain, map);
        return mapmain;
    }

    public List<Map<String,Object>> getDetailList(String reqid, String tablename, String detailid) {
        List<Map<String,Object>> list = new ArrayList<>();
        Map<String, Object> mapmain = new HashMap<>();
        mapmain = getMainMap(reqid, tablename);
        String id = Util.null2String(mapmain.get("id").toString());
        if ("".equals(id)) {
            return list;
        }
        String sqldetail = "select * from " + tablename + "_dt" + detailid + " where mainid=" + id;
        list= JAVATools.GetTableToListMap(sqldetail, null);
        return list;
    }

}
