package com.engine.htxc.workflow.create.business.contract.util;

import java.util.*;
import java.util.stream.Collectors;

import com.engine.htxc.commonutil.db.DbTools;
import com.engine.integration.util.StringUtils;

import weaver.general.Util;

/**
 * @author K1810015
 * @version 1.0.0
 * @ClassName BaseUtil.java
 * @createTime 2022年07月22日 14:59:00
 * @Remark
 */
public class ContracrtBaseUtil {

    private ContracrtBaseUtil() {}

    /**
     * @title getrcontractdrafted
     * @author K1810015
     * @updateTime 2022/7/22 15:01
     * @Remark 获取合同建木表qcr字段
     * @throws
     */
    public static List<String> getrcontractdrafted(Map<String, Object> map) {
        List<String> list = new ArrayList<>();
        if (map == null || map.size() <= 0) {
            return list;
        }
        String htbh = Util.null2String(map.get("htbh"));
        String htbb = Util.null2String(map.get("htbb"));
        if (StringUtils.isBlank(htbh) || StringUtils.isBlank(htbb)) {
            return list;
        }
        String sql = "select qcr from uf_htqc where htbh=? and dqbb=?";
        list.add(htbh);
        list.add(htbb);
        String value = new DbTools().getsqlonevalue(sql, list);
        if (StringUtils.isBlank(value)) {
            return list;
        }
        return Arrays.stream(value.split(",")).collect(Collectors.toList());
    }

    public static Map<String, Object> getufhtqcmap(Map<String, Object> map) {
        Map<String, Object> mapvalue = new HashMap<>(1);
        if (map == null || map.size() <= 0) {
            return mapvalue;
        }
        String htbh = Util.null2String(map.get("htbh"));
        String htbb = Util.null2String(map.get("htbb"));
        if (StringUtils.isBlank(htbh) || StringUtils.isBlank(htbb)) {
            return mapvalue;
        }
        Map<String, String> wheremap = new HashMap<>();
        wheremap.put("htbh", htbh);
        wheremap.put("dqbb", htbb);
        mapvalue = new DbTools().gettabletomap("uf_htqc", wheremap);
        if (mapvalue == null || mapvalue.size() <= 0) {
            return mapvalue;
        }
        return mapvalue;
    }

    public static Map<String, Object> getmodeltype(Map<String, Object> map) {
        Map<String, Object> retmap=new HashMap<>(1);
        if (map == null || map.size() <= 0) {
            return retmap;
        }
        String type = Util.null2String(map.get("contracttype"));
        if (StringUtils.isBlank(type)) {
            return retmap;
        }

        String sql = "select * from uf_htspckhtqcpzb where htfl=?";

        retmap= new DbTools().getsqltomap(sql, type);
        return retmap;
    }
}
