package com.engine.common.cmd;

import com.engine.common.biz.AbstractCommonCommand;
import com.engine.common.entity.BizLogContext;
import com.engine.common.util.DbTools;
import com.engine.core.interceptor.CommandContext;
import com.google.common.collect.Maps;
import weaver.general.Util;

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

public class GetDateCmd extends AbstractCommonCommand<Map<String,Object>> {

    public GetDateCmd(Map<String,Object> params){
        this.params=params;
    }

    @Override
    public BizLogContext getLogContext() {
        return null;
    }

    @Override
    public Map<String, Object> execute(CommandContext commandContext) {
        String nd = Util.null2String(params.get("nd"));
        String glpb = Util.null2String(params.get("glpb"));
        String sql = "select nd,rq,nlrq,rqlx,xq,rlmc from uf_jcl_kq_rlxx a left join uf_jcl_kq_glpb  b on a.rlmc=b.qyrl where b.id=? and a.nd=? ";
        List<Map<String,Object>> dataList=null;
        if ("".equals(glpb)){
            sql = "select a.nd,a.rq,a.nlrq,a.rqlx,a.xq,a.rlmc from uf_jcl_kq_rlxx a left join uf_jcl_kq_rlmc b on a.rlmc=b.id where a.nd=? and b.mrrl=1";
            dataList = DbTools.getSqlToList(sql,nd);
        }else {
            dataList = DbTools.getSqlToList(sql,glpb,nd);
        }
        Map<String, Object> resultMap = Maps.newHashMap();
        resultMap.put("data",dataList);
        return resultMap;
    }
}
