package com.engine.htsc.general.tools;

import com.engine.htsc.general.dao.UfZbsplDao;
import com.engine.htsc.general.model.UfZbspl;
import com.engine.htsc.general.model.UfZbsplVo;
import com.engine.htsc.general.model.ZbDept;
import com.engine.htsc.general.model.ZbUser;
import weaver.general.Util;
import weaver.interfaces.htsc.GlobatTools.JAVATools;

import java.util.*;

public class UfzbsplServiceTools {

    protected UfZbsplDao ufZbsplDao = new UfZbsplDao();

    public List<UfZbsplVo> convertModelToVO(List<UfZbspl> ufZbsplList, String ngr, HashMap<String, String> mingxiMap, String unnumbercode, List fycdbmList) {
        List<UfZbspl> ufZbsplListJg = new ArrayList<>();//机构
        List<UfZbspl> ufZbsplListBm = new ArrayList<>();//部门
        List<UfZbspl> ufZbsplListRy = new ArrayList<>();//人员
        List<UfZbspl> ufZbsplListRes = new ArrayList<>();//筛选结果
        List<UfZbsplVo> resultList = new ArrayList<>();
        ZbUser zbUser = new ZbUser(ngr);
        //过滤审批链
        for(UfZbspl ufZbspl:ufZbsplList){
            //判断条件
            if(null!=ufZbspl.getTj()&&!"".equals(ufZbspl.getTj())){
                if(!getConitionParams(ufZbspl.getTj(),mingxiMap)){
                    continue;
                }
            }
            List<String> list = Arrays.asList(ufZbspl.getBm().split(","));
            //判断是否符合 人员>部门>机构
            if (ufZbspl.getCxsprjs().equals("WK_"+zbUser.getWorkCode())){
                ufZbsplListRy.add(ufZbspl);//单个人员
            }else if (list.contains(mingxiMap.get("fycdbm"))){
                ufZbsplListBm.add(ufZbspl);//符合部门
            }else if (ufZbspl.getJg().equals(zbUser.getZbDept().getDepLevel())&&"".equals(ufZbspl.getBm())){
                ufZbsplListJg.add(ufZbspl);//部门为空且符合机构
            }
        }
        if (ufZbsplListRy.size()>0){
            ufZbsplListRes.addAll(ufZbsplListRy);
        }else if (ufZbsplListBm.size()>0){
            ufZbsplListRes.addAll(ufZbsplListBm);
        }else if (ufZbsplListJg.size()>0){
            ufZbsplListRes.addAll(ufZbsplListJg);
        }
        for (UfZbspl ufZbspl:ufZbsplListRes){
            JAVATools.writelog("筛选审批链id为："+ufZbspl.getId());
            UfZbsplVo ufZbsplVo = getVo(ufZbspl,zbUser,unnumbercode,mingxiMap,fycdbmList);
            resultList.add(ufZbsplVo);
        }
        return resultList;
    }

    protected UfZbsplVo getVo(UfZbspl ufZbspl, ZbUser zbUser, String unnumbercode, HashMap<String, String> mingxiMap, List fycdbmList) {
        UfZbsplVo ufZbsplVo = new UfZbsplVo();
        //费用承担部门
        ZbDept zbDept = new ZbDept(Util.null2String(mingxiMap.get("fycdbm")));

        //总部通用付款流10程判断费用承担部门时，查询部门表信息排除“拟稿人部门”及“是否领导”为“是”的对应部门；
        String sfld = ufZbsplDao.getSfld(zbDept.getDepCode());
        //拟稿人选择的部门负责人
        String bmfzr = mingxiMap.get("bmfzr");
        //拟稿页面选择的费用承担部门部门负责人
        String fycdbmfzr = Util.null2String(mingxiMap.get("fycdbmfzr"));
        //费用承担部门是营业部（ZZ00199） 预算明细预算科目=“装修及VI改造” fycdbmfzr为程雁宾018886
        //预算科目类型 0：不包含装修及VI改造，1：只有装修及VI改造，2，包含装修及VI改造且有其他装修费
        if ("ZZ001999".equals(zbDept.getDepCode())){
            if ("1".equals(mingxiMap.get("yskmlx"))){
                fycdbmfzr = JAVATools.GetWorkcodetoid("018886");
            }else if("2".equals((mingxiMap.get("yskmlx")))){
                fycdbmfzr+=fycdbmfzr==""?JAVATools.GetWorkcodetoid("018886"):","+JAVATools.GetWorkcodetoid("018886");
            }
        }
        ufZbsplVo.setReportSequenceId(ufZbspl.getId().toString());
        //二级部门负责人
        ufZbsplVo.setEjbmfzr(getEjbmfzr(Util.null2String(ufZbspl.getEjbmfzr()),zbUser,bmfzr));
        //拟稿人部门预算管理员
        ufZbsplVo.setBmysgly(getBmysgly(Util.null2String(ufZbspl.getBmysgly()),zbUser));
        //一级部门负责人
        ufZbsplVo.setYjbmfzr(getYjbmfzr(Util.null2String(ufZbspl.getYjbmfzr()),zbUser,bmfzr));
        //总部通用付款流程判断费用承担部门时，查询部门表信息排除“拟稿人部门”及“是否领导”为“是”的对应部门；0是1否
        if (!"0".equals(sfld)){
            //费用承担部门二级部门负责人
            ufZbsplVo.setFycdbmerbmfzr(getFycdbmerbmfzr(Util.null2String(ufZbspl.getFycdbmerbmfzr()),zbDept,zbUser,fycdbmfzr));
            //费用承担部门一级部门负责人
            ufZbsplVo.setFycdbmyjbmfzr(getFycdbmyjbmfzr(Util.null2String(ufZbspl.getFycdbmyjbmfzr()),zbDept,zbUser,fycdbmfzr));
            //费用承担部门预算管理员
            ufZbsplVo.setFycdbmysgly(getFycdbmysgly(Util.null2String(ufZbspl.getFycdbmysgly()),zbDept,zbUser));
        }
        //会签部门负责人
        ufZbsplVo.setHqbmfzr(Util.null2String(mingxiMap.get("hqbmfzr")));
        //费用会计
        ufZbsplVo.setFykj(getFykj(Util.null2String(ufZbspl.getFykj()),zbUser,zbDept,mingxiMap,fycdbmList));
        //纸质发票提交,扫码收单权限开关smsdqxkg、是否全为电子发票（扫码）sfqwdzfpsm两个值，都等于0时，取值纸质发票节点值。
        if ("0".equals(mingxiMap.get("smsdqxkg"))&&"0".equals(mingxiMap.get("sfqwdzfpsm"))){
            ufZbsplVo.setZzfptj(ufZbsplVo.getFykj());
        }
        //财务负责人
        ufZbsplVo.setCwfzr(getNormal(Util.null2String(ufZbspl.getCwfzr())));
        //党委副书记
        ufZbsplVo.setDwfsj(getNormal(Util.null2String(ufZbspl.getDwfsj())));
        //党委书记
        ufZbsplVo.setDwsj(getNormal(Util.null2String(ufZbspl.getDwsj())));
        //首席财务官
        ufZbsplVo.setSxcwg(getNormal(Util.null2String(ufZbspl.getSxcwg())));
        //分管领导审批
        ufZbsplVo.setSp(getSp(Util.null2String(ufZbspl.getSp()),zbUser,mingxiMap));
        //总裁审批
        ufZbsplVo.setLdsp(getLdsp(Util.null2String(ufZbspl.getLdsp()),zbUser,ufZbsplVo.getSp()));
        //出纳
        ufZbsplVo.setCn(getNormal(Util.null2String(ufZbspl.getCn())));
        //出纳人员工号
        ufZbsplVo.setCnrygh(getCnrygh(Util.null2String(ufZbspl.getCn())));
        return ufZbsplVo;
    }

    //出纳人员工号
    protected String getCnrygh(String value) {
        String hrmids = "";
        for (String hrmst:value.split(",") ) {
            if(hrmst.indexOf("WK_")>=0){
                String workcodeS=value.split("WK_")[1];
                String[] codeArray = workcodeS.split("_");
                String workcode = codeArray[0];
                if(codeArray.length>1){
                    String deptcode = codeArray[1];
                    hrmids+=hrmids==""?deptcode:","+deptcode;
                }else{
                    hrmids+=hrmids==""?workcode:","+workcode;
                }
            }
        }
        return hrmids;
    }

    //总裁审批
    protected String getLdsp(String value, ZbUser zbUser, String sp) {
        String hrmids = "";
        ZbUser fgsp = new ZbUser(sp);
        for (String hrmst:value.split(",") ) {
            String hrmid=getHrmType(hrmst);
            //不是指定WK_则判断是否为1
            if("".equals(hrmid)){
                //如果是1的情况下，便从获取对应负责人id
                if ("1".equals(hrmst)){
                    if ("016500".equals(fgsp.getWorkCode())){
                        //如果分管领导是韩臻聪，则需要周易
                        hrmids+=hrmids==""?JAVATools.GetWorkcodetoid("001008"):","+JAVATools.GetWorkcodetoid("001008");
                    }
                }
            }else{
                hrmids+=hrmids==""?hrmid:","+hrmid;
            }
        }
        return hrmids;
    }

    protected String getSp(String value, ZbUser zbUser, HashMap<String, String> mingxiMap) {
        String hrmids = "";
        ZbDept zbDept = new ZbDept(mingxiMap.get("fycdbm"));
        for (String hrmst:value.split(",") ) {
            String hrmid=getHrmType(hrmst);
            //不是指定WK_则判断是否为1
            if("".equals(hrmid)){
                //如果是1的情况下，便从获取对应负责人id
                if ("1".equals(hrmst)){
                    hrmids+=hrmids==""?zbDept.getLeaderId():","+zbDept.getLeaderId();
                }
            }else{
                hrmids+=hrmids==""?hrmid:","+hrmid;
            }
        }
        return hrmids;
    }

    protected String getSxcwg(String value, ZbUser zbUser) {
        String hrmids = "";
        ZbDept zbDept = zbUser.getZbDept();
        for (String hrmst:value.split(",") ) {
            String hrmid=getHrmType(hrmst);
            //不是指定WK_则判断是否为1
            if("".equals(hrmid)){
                //如果是1的情况下，便从获取对应负责人id
                if ("1".equals(hrmst)){
                    while (!"2".equals(zbDept.getDepLevel())&&!"".equals(zbDept.getDepLevel())){
                        zbDept = new ZbDept(zbDept.getParentDepId());
                    }
                    hrmids+=hrmids==""?zbDept.getDirectorId():","+zbDept.getDirectorId();
                }
            }else{
                hrmids+=hrmids==""?hrmid:","+hrmid;
            }
        }
        return hrmids;
    }

    protected String getDwsj(String value, ZbUser zbUser) {
        String hrmids = "";
        ZbDept zbDept = zbUser.getZbDept();
        for (String hrmst:value.split(",") ) {
            String hrmid=getHrmType(hrmst);
            //不是指定WK_则判断是否为1
            if("".equals(hrmid)){
                //如果是1的情况下，便从获取对应负责人id
                if ("1".equals(hrmst)){
                    while (!"2".equals(zbDept.getDepLevel())&&!"".equals(zbDept.getDepLevel())){
                        zbDept = new ZbDept(zbDept.getParentDepId());
                    }
                    hrmids+=hrmids==""?zbDept.getDirectorId():","+zbDept.getDirectorId();
                }
            }else{
                hrmids+=hrmids==""?hrmid:","+hrmid;
            }
        }
        return hrmids;
    }

    protected String getDwfsj(String value, ZbUser zbUser) {
        String hrmids = "";
        ZbDept zbDept = zbUser.getZbDept();
        for (String hrmst:value.split(",") ) {
            String hrmid=getHrmType(hrmst);
            //不是指定WK_则判断是否为1
            if("".equals(hrmid)){
                //如果是1的情况下，便从获取对应负责人id
                if ("1".equals(hrmst)){
                    while (!"2".equals(zbDept.getDepLevel())&&!"".equals(zbDept.getDepLevel())){
                        zbDept = new ZbDept(zbDept.getParentDepId());
                    }
                    hrmids+=hrmids==""?zbDept.getDirectorId():","+zbDept.getDirectorId();
                }
            }else{
                hrmids+=hrmids==""?hrmid:","+hrmid;
            }
        }
        return hrmids;
    }

    //费用会计
    protected String getFykj(String value, ZbUser zbUser, ZbDept zbDept, HashMap<String, String> mingxiMap, List fycdbmList) {
        String hrmids = "";
        for (String hrmst:value.split(",") ) {
            String hrmid=getHrmType(hrmst);
            //不是指定WK_则判断是否为1
            if("".equals(hrmid)){
                //如果是1的情况下，便从获取对应负责人id
                if ("1".equals(hrmst)){
                    String fykj = "";
                    if("ZZ001126".equals(zbUser.getZbDept().getDepCode())){
                        //是否为综合事务部
                        fykj = JAVATools.GetWorkcodetoid("001970");
                    }else if("0".equals(mingxiMap.get("ggfy"))){
                        //是否为公共费用 0是/1否
                        fykj = ufZbsplDao.getFykj(zbUser.getDepId());
                    }else if("1".equals(mingxiMap.get("dbmFlag"))){
                        //判断是否为多部门
                        Set<String> fykjSet = new HashSet<>();
                        for (Object fycdbm:fycdbmList){
                            ZbDept zbDeptFy = new ZbDept(fycdbm.toString());
                            String kj = "";
                            if ("1".equals(zbDeptFy.getCanceled())){
                                //判断是否为虚拟部门,判断费用承担部门是否为营业部，为营业部是取张激峰
                                if ("ZZ001999".equals(zbDeptFy.getDepCode())){
                                    kj = JAVATools.GetWorkcodetoid("001970");
                                }else {
                                    kj = ufZbsplDao.getFykj(zbUser.getDepId());
                                }
                            }else {
                                kj = ufZbsplDao.getFykj(zbDeptFy.getDepId());
                            }
                            fykjSet.add(kj);
                        }
                        //是否为同一人
                        if (fykjSet.size()>1){
                            //如果不是同一人则为左莹
                            fykj = JAVATools.GetWorkcodetoid("010803");
                        }else if ("1".equals(zbDept.getCanceled())){
                            //判断是否为虚拟部门,判断费用承担部门是否为营业部，为营业部是取张激峰
                            if ("ZZ001999".equals(new ZbDept(mingxiMap.get("fycdbm")).getDepCode())){
                                fykj = JAVATools.GetWorkcodetoid("001970");
                            }else {
                                fykj = ufZbsplDao.getFykj(zbUser.getDepId());
                            }
                        }else {
                            fykj = ufZbsplDao.getFykj(zbDept.getDepId());
                        }
                    }else if ("1".equals(zbDept.getCanceled())){
                        //判断是否为虚拟部门,判断费用承担部门是否为营业部，为营业部是取张激峰
                        if ("ZZ001999".equals(new ZbDept(mingxiMap.get("fycdbm")).getDepCode())){
                            fykj = JAVATools.GetWorkcodetoid("001970");
                        }else {
                            fykj = ufZbsplDao.getFykj(zbUser.getDepId());
                        }
                    }else {
                        fykj = ufZbsplDao.getFykj(zbDept.getDepId());
                    }
                    hrmids+=hrmids==""?fykj:","+fykj;
                }
            }else{
                hrmids+=hrmids==""?hrmid:","+hrmid;
            }
        }
        return hrmids;
    }

    //纸质发票提交暂时数据库里配置
    protected String getZzfptj(String value, ZbUser zbUser) {
        String hrmids="";
        if("".equals(value)){
            return hrmids;
        }
        for (String hrmst:value.split(",") ) {
            String hrmid=getHrmType(hrmst);
            hrmids+=hrmids==""?hrmid:","+hrmid;
        }
        return hrmids;
    }

    protected String getHqbmfzr(String value, ZbUser zbUser) {
        String hrmids = "";
        ZbDept zbDept = zbUser.getZbDept();
        for (String hrmst:value.split(",") ) {
            String hrmid=getHrmType(hrmst);
            //不是指定WK_则判断是否为1
            if("".equals(hrmid)){
                //如果是1的情况下，便从获取对应负责人id
                if ("1".equals(hrmst)){
                    while (!"2".equals(zbDept.getDepLevel())&&!"".equals(zbDept.getDepLevel())){
                        zbDept = new ZbDept(zbDept.getParentDepId());
                    }
                    hrmids+=hrmids==""?zbDept.getDirectorId():","+zbDept.getDirectorId();
                }
            }else{
                hrmids+=hrmids==""?hrmid:","+hrmid;
            }
        }
        return hrmids;
    }
    //费用承担部门一级部门负责人
    protected String getFycdbmyjbmfzr(String value, ZbDept zbDept, ZbUser zbUser, String fycdbmfzr) {
        String hrmids = "";
        for (String hrmst:value.split(",") ) {
            String hrmid=getHrmType(hrmst);
            //不是指定WK_则判断是否为1
            if("".equals(hrmid)){
                //如果是1的情况下，便从获取对应负责人id
                if ("1".equals(hrmst)){
                    if(!zbUser.getDepId().equals(zbDept.getDepId())){
                        //虚拟部门不过费用承担部门节点
                        if("ZZ001999".equals(zbDept.getDepCode())||!"1".equals(zbDept.getCanceled())){
                            if ("1".equals(zbDept.getDepLevel())){
                                hrmids += hrmids == "" ? fycdbmfzr : "," + fycdbmfzr;
                            }else {
                                while (!"1".equals(zbDept.getDepLevel()) && !"".equals(zbDept.getDepLevel())) {
                                    zbDept = new ZbDept(zbDept.getParentDepId());
                                }
                                if (!zbDept.getDepId().equals(zbUser.getZbDept().getDepId())) {
                                    hrmids += hrmids == "" ? zbDept.getDirectorId() : "," + zbDept.getDirectorId();
                                }
                            }
                        }
                    }
                }
            }else{
                hrmids+=hrmids==""?hrmid:","+hrmid;
            }
        }
        return hrmids;
    }

    protected String getFycdbmysgly(String value, ZbDept zbDept, ZbUser zbUser) {
        String hrmids = "";
        for (String hrmst:value.split(",") ) {
            String hrmid=getHrmType(hrmst);
            //不是指定WK_则判断是否为1
            if("".equals(hrmid)){
                //如果是1的情况下，便从获取对应负责人id
                if(!zbUser.getDepId().equals(zbDept.getDepId())) {
                    if ("1".equals(hrmst)) {
                        if("ZZ001999".equals(zbDept.getDepCode())||!"1".equals(zbDept.getCanceled())) {
                            if (!zbUser.getZbDept().getDepId().equals(zbDept.getDepId())) {
                                String bmysgly = ufZbsplDao.getBmysgly(zbDept.getDepId());
                                hrmids += hrmids == "" ? bmysgly : "," + bmysgly;
                            }
                        }
                    }
                }
            }else{
                hrmids+=hrmids==""?hrmid:","+hrmid;
            }
        }
        return hrmids;
    }

    //费用承担部门二级部门负责人
    protected String getFycdbmerbmfzr(String value, ZbDept zbDept, ZbUser zbUser, String fycdbmfzr) {
        String hrmids = "";
        for (String hrmst:value.split(",") ) {
            String hrmid=getHrmType(hrmst);
            //不是指定WK_则判断是否为1
            if("".equals(hrmid)){
                //如果是1的情况下，便从获取对应负责人id
                if ("1".equals(hrmst)){
                    if(!zbUser.getDepId().equals(zbDept.getDepId())){
                        //虚拟部门不过费用承担部门节点
                        if("ZZ001999".equals(zbDept.getDepCode())||!"1".equals(zbDept.getCanceled())){
                            if ("2".equals(zbDept.getDepLevel())){
                                hrmids += hrmids == "" ? fycdbmfzr : "," + fycdbmfzr;
                            }
                        }
                    }
                }
            }else{
                hrmids+=hrmids==""?hrmid:","+hrmid;
            }
        }
        return hrmids;
    }
    //一级部门负责人
    protected String getYjbmfzr(String value, ZbUser zbUser,String bmfzr) {
        String hrmids = "";
        ZbDept zbDept = zbUser.getZbDept();
        for (String hrmst:value.split(",") ) {
            String hrmid=getHrmType(hrmst);
            //不是指定WK_则判断是否为1
            if("".equals(hrmid)){
                //如果是1的情况下，便从获取对应负责人id
                if ("1".equals(hrmst)){
                    if("1".equals(zbDept.getDepLevel())&&!"".equals(Util.null2String(bmfzr))){
                        hrmids+=hrmids==""?bmfzr:","+bmfzr;
                    }else {
                        while (!"1".equals(zbDept.getDepLevel())&&!"".equals(zbDept.getDepLevel())){
                            zbDept = new ZbDept(zbDept.getParentDepId());
                        }
                        hrmids+=hrmids==""?zbDept.getDirectorId():","+zbDept.getDirectorId();
                    }
                }
            }else{
                hrmids+=hrmids==""?hrmid:","+hrmid;
            }
        }
        return hrmids;
    }

    //拟稿人部门预算管理员
    protected String getBmysgly(String value, ZbUser zbUser) {
        String hrmids = "";
        ZbDept zbDept = zbUser.getZbDept();
        for (String hrmst:value.split(",") ) {
            String hrmid=getHrmType(hrmst);
            //不是指定WK_则判断是否为1
            if("".equals(hrmid)){
                //如果是1的情况下，便从获取对应负责人id
                if ("1".equals(hrmst)){
                    String bmysgly = ufZbsplDao.getBmysgly(zbUser.getDepId());
                    hrmids+=hrmids==""?bmysgly:","+bmysgly;
                }
            }else{
                hrmids+=hrmids==""?hrmid:","+hrmid;
            }
        }
        return hrmids;
    }

    //二级部门负责人
    protected String getEjbmfzr(String value, ZbUser zbUser,String bmfzr) {
        String hrmids = "";
        ZbDept zbDept = zbUser.getZbDept();
        for (String hrmst:value.split(",") ) {
            String hrmid=getHrmType(hrmst);
            //不是指定WK_则判断是否为1
            if("".equals(hrmid)){
                //如果是1的情况下，便从获取对应负责人id
                if ("1".equals(hrmst)){
                    if("2".equals(zbDept.getDepLevel())&&!"".equals(Util.null2String(bmfzr))){
                        hrmids+=hrmids==""?bmfzr:","+bmfzr;
                    }else {
                        while (!"2".equals(zbDept.getDepLevel())&&!"".equals(zbDept.getDepLevel())){
                            zbDept = new ZbDept(zbDept.getParentDepId());
                        }
                        hrmids+=hrmids==""?zbDept.getDirectorId():","+zbDept.getDirectorId();
                    }
                }
            }else{
                hrmids+=hrmids==""?hrmid:","+hrmid;
            }
        }
        return hrmids;
    }

    //数据库直接配置人员类型
    protected String getNormal(String value) {
        String hrmids="";
        if("".equals(value)){
            return hrmids;
        }
        for (String hrmst:value.split(",") ) {
            String hrmid=getHrmType(hrmst);
            hrmids+=hrmids==""?hrmid:","+hrmid;
        }
        return hrmids;
    }

    //根据type来获取人员
    public String getHrmType(String value){
        if("".equals(value)){
            return "";
        }
        if(value.indexOf("WK_")>=0){
            String workcodeS=value.split("WK_")[1];
            String[] codeArray = workcodeS.split("_");
            String workcode = codeArray[0];
            if(codeArray.length>1){
                String deptcode = codeArray[1];
                return ufZbsplDao.getUserIdByCode(workcode,deptcode);
            }else{
                return JAVATools.GetWorkcodetoid(workcode);
            }
        }
        return "";
    }

    //判断条件逻辑与和逻辑或 ：|| ，&&
    public static boolean getConitionParams(String tj, Map<String,String> detailmap){
        boolean flag=false;
        if("".equals(tj)){
            return true;
        }
        String value="";
        List<String> list=new ArrayList();

        String[] split=tj.split("\\|\\|");
        for (String tjsplitljy:split) {
            //开始做逻辑与操作
            String[] splitljy = tjsplitljy.split("\\&\\&");
            list=new ArrayList();
            for (String tjsplitvalue : splitljy) {
                if(tjsplitvalue.split("#").length==3){
                    list.add(tjsplitvalue.replace("#",""));
                }else {
                    list.add(tjsplitvalue);
                }
            }
            for (String tjvalue : list) {
                flag = IsConform(tjvalue, detailmap);
                if (flag == false) {
                    break;
                }
            }
            if(flag==true){
                break;
            }
        }
        return flag;
    }
    //判断是否符合要求
    public static boolean IsConform(String tj,Map<String,String> map){
        boolean flag=true;
        String[] params = getParamsSplit(tj);
        if(params==null){
            return false;
        }
        String key = params[0];
        String value = params[1];
        String conition = params[2];
        if (">=".equals(conition)){
            Double valuedouble= Util.getDoubleValue(Util.null2String(map.get(key)));
            if(!getDoubleIsNull(valuedouble)){
                flag=false;
            }
            if( valuedouble< Util.getDoubleValue(value)){
                flag=false;
            }
        }else if ("<=".equals(conition)){
            Double valuedouble= Util.getDoubleValue(Util.null2String(map.get(key)));
            if(!getDoubleIsNull(valuedouble)){
                flag=false;
            }
            if(valuedouble > Util.getDoubleValue(value)){
                flag=false;
            }
        }else if (">".equals(conition)){
            Double valuedouble= Util.getDoubleValue(Util.null2String(map.get(key)));
            if(!getDoubleIsNull(valuedouble)){
                flag=false;
            }
            if(valuedouble <= Util.getDoubleValue(value)){
                flag=false;
            }
        }else if ("<".equals(conition)){
            Double valuedouble= Util.getDoubleValue(Util.null2String(map.get(key)));
            if(!getDoubleIsNull(valuedouble)){
                flag=false;
            }
            if(valuedouble >= Util.getDoubleValue(value)){
                flag=false;
            }
        }else if ("!=".equals(conition)){
            if(Util.null2String(map.get(key)).equals(value)){
                flag=false;
            }
        }else if ("=".equals(conition)){
            if(!Util.null2String(map.get(key)).equals(value) ){
                flag=false;
            }
        }
        return  flag;
    }

    public static String[] getParamsSplit(String value){
        String[] values = new String[3];
        if(value.split(">=").length==2){
            values= JAVATools.ArrayCodyAtoB(value.split(">="),values);
            values[2]=">=";
            return values;
        }
        if(value.split("<=").length==2){
            values= JAVATools.ArrayCodyAtoB(value.split("<="),values);
            values[2]="<=";
            return values;
        }
        if(value.split(">").length==2){
            values= JAVATools.ArrayCodyAtoB(value.split(">"),values);
            values[2]=">";
            return values;
        }
        if(value.split("<").length==2){
            values= JAVATools.ArrayCodyAtoB(value.split("<"),values);
            values[2]="<";
            return values;
        }

        if(value.split("!=").length==2){
            values= JAVATools.ArrayCodyAtoB(value.split("!="),values);
            values[2]="!=";
            return values;
        }

        if(value.split("=").length==2){
            values= JAVATools.ArrayCodyAtoB(value.split("="),values);
            values[2]="=";
            return values;
        }
        return null;
    }

    public static boolean getDoubleIsNull(double i){
        boolean flag=true;
        if(i<0){
            flag=false;
        }
        return flag;
    }
}
