package yem.wm.cm.csrm.thirdapi;

import com.alibaba.fastjson.JSONObject;
import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.dataentity.entity.DynamicObjectCollection;
import kd.bos.orm.query.QCP;
import kd.bos.orm.query.QFilter;
import kd.bos.servicehelper.BusinessDataServiceHelper;
import kd.bos.servicehelper.operation.SaveServiceHelper;
import org.springframework.beans.factory.annotation.Autowired;
import yem.base.common.utils.DynamicObjectUtil;


import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
 * @program: yem-cosmic
 * @description:
 * @author: zsf
 * @create: 2024-05-28 11:39
 **/
public class DynamicScanRegisImpl implements DynamicScanRegis{

    @Autowired
    ThirdPartyApi thirdPartyApil;
    @Override
    public Map<String,Object> CountMethodMeaasge(String searchKey) {
        Map<String,Object> returnMap = new HashMap();
        Map<String, String> params = new HashMap<>();
        params.put("searchKey",searchKey);
        QFilter qFilter11 = new QFilter("status", QCP.equals, "C");
        QFilter[] filters = { qFilter11};
        DynamicObject[] yemApiRegisters = BusinessDataServiceHelper.load("yem_api_register", "id,yem_reqmethod,yem_textaddress,number,yem_entryentity", filters);
        //获取第三方信息接口下的地址
        StringBuilder retundata = new StringBuilder();
        for (DynamicObject yemApiRegister : yemApiRegisters) {
            //接口登记code
            String number = (String) yemApiRegister.get("number");
            DynamicObjectCollection yemEntryentity = yemApiRegister.getDynamicObjectCollection("yem_entryentity");
            for (DynamicObject object : yemEntryentity) {
                params.put((String) object.get("yem_name"), (String) object.get("yem_type"));
            }
            //调用企查查接口信息
            retundata = new StringBuilder(thirdPartyApil.requestMethod(number, params));
            retundata.append(retundata);
        }
        returnMap.put("data",retundata);
        return returnMap;
    }

}
