package com.usoft.credit.service.enterprise;

import com.usoft.credit.config.PyConfig;
import com.usoft.credit.modal.EnterpriseQuery;
import com.usoft.credit.service.ErpQueryService;
import com.usoft.credit.util.QueryConditionUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 企业异常信息接口实现类
 * created by shicr on 2018/6/15
 **/
@Service
public class EnexceptionService {

    //查询类型
    private static String ENTERPRISE_EXCEPTION = "25123";

    //查询原因ID
    private static Integer QueryReasonID = 101;

    //收费子报告类型
    private static String SubreportIDs = "22117";

    @Autowired
    private ErpQueryService erpQueryService;

    @Autowired
    private PyConfig pyConfig;


    /**
     * 查询并保存返回查询json串
     *
     * @param query 企业查询信息
     * @return
     */
    public String queryEnexception(EnterpriseQuery query) {
        //拼装查询的json
        String enexception = QueryConditionUtil.getEnterpriseQuery(query, ENTERPRISE_EXCEPTION, SubreportIDs, QueryReasonID);

        //发起鹏元征信的请求
        String enexceptionResult = erpQueryService.requestApi(pyConfig.getHost(), pyConfig.getPathUnZip(), enexception);
        return enexceptionResult;
    }
}
