package yem.wm.cm.csrm.qcc;

import com.alibaba.fastjson.JSONObject;
import com.cloudera.impala.jdbc41.internal.fasterxml.jackson.core.JsonProcessingException;
import com.cloudera.impala.jdbc41.internal.fasterxml.jackson.databind.ObjectMapper;
import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.orm.query.QCP;
import kd.bos.orm.query.QFilter;
import kd.bos.servicehelper.BusinessDataServiceHelper;
import yem.base.common.utils.StringUtils;

import java.util.Map;

/**
 * @program: yem-cosmic
 * @description: 读取企查查风险底表数据
 * @author: zsf
 * @create: 2024-06-05 09:40
 **/
public class WriteQccriskData {

    public static Map<String, Object> readRiskData(String code){
        JSONObject jsonData = new JSONObject();
        if (!StringUtils.isEmpty(code)) {
            DynamicObject dynamicObject = BusinessDataServiceHelper.loadSingle("yem_qccbase_inh", "yem_alldata_tag", new QFilter[]{new QFilter("yem_keyno", QCP.equals, code)});
            String yemAlldata = dynamicObject.getString("yem_alldata_tag");
            ObjectMapper objectMapper = new ObjectMapper();
            try {
                Map<String, Object> map = objectMapper.readValue(yemAlldata, Map.class);
                return map;
            } catch (JsonProcessingException e) {
                throw new RuntimeException(e);
            }
        }
        return jsonData;
    }
}
