package com.engine.htsc.ReimbursementFlow.Dao;

import org.apache.commons.lang3.StringUtils;
import weaver.interfaces.htsc.GlobatTools.JAVATools;

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

public class GettravelapplicationDao {

    public List<Map<String,String>> traveldistctcclc(String travelcodeids,String tablename,String requestid){
        List<Map<String,String>> returnlist=new ArrayList<>();
        String where="";
        List<String> list= Arrays.asList(travelcodeids.split(","));
        if(list.size()<=0){
           return returnlist;
        }
        for (String value:list) {
            where+="".equals(where)?" treavelcode= '"+value+"' ":" or treavelcode='"+value+"' ";
        }

        if(StringUtils.isNotEmpty(requestid)){
            where +="".equals(where)?" requestid <> '" + requestid + "' ":" and requestid <> '"+ requestid+"' ";
        }
        if("".equals(where)){
            return  returnlist;
        }


        String sql="select  treavelcode,wm_concat_old(distinct lcbh)  as lcbhvalue from  uf_zbclbxandccsqgx" +
                " where 1=1 and ("+where+") ";

            sql+=    " group by  treavelcode";

       return JAVATools.GetTableToListMap(sql,null);

    }

}
