|
@@ -1,8 +1,22 @@
|
|
|
package com.jkcredit.invoice.hub.service.apiCompany;
|
|
|
|
|
|
+import cn.com.taiji.sdk.comm.ETCCommHelper;
|
|
|
+import cn.com.taiji.sdk.model.comm.protocol.eoms.company.CompanyQueryRequest;
|
|
|
+import cn.com.taiji.sdk.model.comm.protocol.eoms.company.CompanyQueryResponse;
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.jkcredit.invoice.hub.constant.CommonConstant;
|
|
|
+import com.jkcredit.invoice.hub.enums.ApiResponseCodeEnum;
|
|
|
+import com.jkcredit.invoice.hub.service.base.BaseService;
|
|
|
+import com.jkcredit.invoice.hub.spi.lang.exception.ServiceException;
|
|
|
+import com.jkcredit.invoice.hub.spi.rest.data.ApiResponseData;
|
|
|
+import io.netty.util.internal.StringUtil;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import javax.sql.rowset.serial.SerialException;
|
|
|
+import java.io.IOException;
|
|
|
+
|
|
|
/**
|
|
|
* @description:
|
|
|
* @author: xusonglin
|
|
@@ -11,37 +25,34 @@ import org.springframework.stereotype.Service;
|
|
|
**/
|
|
|
@Slf4j
|
|
|
@Service
|
|
|
-public class ApiCompanyServiceImpl implements ApiCompanyService {
|
|
|
+public class ApiCompanyServiceImpl extends BaseService implements ApiCompanyService {
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ApiResponseData companyQuery(JSONObject param) {
|
|
|
+ long costTimeStart = System.currentTimeMillis();
|
|
|
+ String result;
|
|
|
+
|
|
|
+ CompanyQueryRequest request = new CompanyQueryRequest();
|
|
|
+ request.setCompanyName(param.get("companyName").toString().trim());
|
|
|
+ request.setTaxpaterCode(param.get("taxplayerCode").toString().trim());
|
|
|
+ String fileName = request.getFilename();
|
|
|
+
|
|
|
+ try {
|
|
|
+ // 调用upload 发送数据
|
|
|
+ CompanyQueryResponse response = ETCCommHelper.upload(fileName, request, CompanyQueryResponse.class);
|
|
|
|
|
|
-// @Override
|
|
|
-// public ApiResponseData companyQuery(JSONObject param) {
|
|
|
-// long costTimeStart = System.currentTimeMillis();
|
|
|
-// String result;
|
|
|
-//
|
|
|
-// CompanyQueryRequest request = new CompanyQueryRequest();
|
|
|
-// request.setCompanyName(param.get("companyName").toString().trim());
|
|
|
-// request.setTaxpaterCode(param.get("taxplayerCode").toString().trim());
|
|
|
-// String fileName = request.getFilename();
|
|
|
-//
|
|
|
-// try {
|
|
|
-// // (4)指定协议的响应模型(IssuerUploadResponse),调用upload 发送数据
|
|
|
-// CompanyQueryResponse response = ETCCommHelper.upload(fileName, request, CompanyQueryResponse.class);
|
|
|
-//
|
|
|
-// // (5)发送成功处理(这里为示例,简单的将响应模型转为json字符串输出,各省根据实际情况处理)
|
|
|
-// result = response.toJson();
|
|
|
-// long costTimeEnd = System.currentTimeMillis();
|
|
|
-// log.info("[-companyQuery-] result is " + result.replaceAll("\r|\n", "") + " , request is "
|
|
|
-// + param + ",costtime=" + (costTimeEnd - costTimeStart) + ",startTime=" + costTimeStart
|
|
|
-// + ",endTime=" + costTimeEnd);
|
|
|
-// } catch (IOException e) {
|
|
|
-// // todo 失败返回码和信息
|
|
|
-// log.info("[-companyQuery-] 网络异常 " + e);
|
|
|
-// return ApiResponseData.failure(1, "");
|
|
|
-// } catch (Exception apie) {
|
|
|
-// // todo 失败返回码和信息
|
|
|
-// log.info("[-companyQuery-] 错误信息:" + apie.getMessage());
|
|
|
-// return ApiResponseData.failure(1, "");
|
|
|
-// }
|
|
|
-// return ApiResponseData.success(ApiResponseCodeEnum.CODE_200.getValue(), result);
|
|
|
-// }
|
|
|
+ result = response.toJson();
|
|
|
+ long costTimeEnd = System.currentTimeMillis();
|
|
|
+ log.info("[-companyQuery-] result is " + result.replaceAll("\r|\n", "") + " , request is "
|
|
|
+ + param + ",costtime=" + (costTimeEnd - costTimeStart) + ",startTime=" + costTimeStart
|
|
|
+ + ",endTime=" + costTimeEnd);
|
|
|
+ } catch (IOException e) {
|
|
|
+ log.info("[-companyQuery-] 网络异常 " + e);
|
|
|
+ throw new ServiceException(CommonConstant.QUERY_FAILED);
|
|
|
+ } catch (Exception apie) {
|
|
|
+ log.info("[-companyQuery-] 错误信息:" + apie.getMessage());
|
|
|
+ throw new ServiceException(CommonConstant.QUERY_FAILED);
|
|
|
+ }
|
|
|
+ return analyzeApiResult(result);
|
|
|
+ }
|
|
|
}
|