package com.engine.htsc.ReimbursementFlow.Service.Impl;

import com.alibaba.fastjson.JSONObject;
import com.engine.core.impl.Service;
import com.engine.htsc.ReimbursementFlow.Dao.TravelUserdepthDaoImpl;
import com.engine.htsc.ReimbursementFlow.Service.TravelUserdepthService;
import com.engine.htsc.ReimbursementFlow.model.NewDepart;
import weaver.interfaces.htsc.GlobatTools.JAVATools;

import java.util.List;
import java.util.Map;

public class TravelUserdepthServiceImpl extends Service implements TravelUserdepthService {

    public TravelUserdepthDaoImpl travelUserdepthdaoImpl=new TravelUserdepthDaoImpl();

    @Override
    public JSONObject getUserdistdepth(List<Map<String,String>> list) {
        String oneadmin="";
        String twoadmin="";
    // List<Map<String,String>> list= travelUserdepthdaoImpl.GetdetailInfo(map);
     JSONObject jsonObject=new JSONObject();
         if(null==list||list.size()<=0) {
             return null;
         }
        for (Map<String,String> mapdetail:list) {

            String ccrbmfzr=mapdetail.get("ccrbmfzr");
            String ccrszbm=  mapdetail.get("ccrszbm");
            NewDepart newDepart= new NewDepart(ccrszbm);
            if("1".equals(newDepart.getDepLevel())){
                oneadmin+= oneadmin==""?ccrbmfzr:","+ccrbmfzr;
            }else if("2".equals(newDepart.getDepLevel())){
                twoadmin+= twoadmin==""?ccrbmfzr:","+ccrbmfzr;
            }
        }
        String onejsonstr="";
        String twojsonstr="";
        if(!"".equals(oneadmin)){
            onejsonstr= JAVATools.disinctrlist(oneadmin.split(","));
        }
        if(!"".equals(twoadmin)){
            twojsonstr= JAVATools.disinctrlist(twoadmin.split(","));
        }

        jsonObject.put("oneadmin",onejsonstr);
        jsonObject.put("twoadmin",twojsonstr);
        return jsonObject;
    }

}
