feature:迁移V6代码

jianshui-ui
路明慧 8 months ago
parent 123f9363d7
commit 2422423d1f
  1. 102
      jianshui-invoice/src/main/java/com/jianshui/invoice/service/impl/api/ElephantInvoiceApiV6ByInspurServiceImpl.java

@ -1197,8 +1197,17 @@ public class ElephantInvoiceApiV6ByInspurServiceImpl implements IInvoiceApiServi
@Override
public HXResponse queryInvoiceList(QueryInvoiceListDTO queryInvoiceList, Companyservice companyservice) {
log.info("发票列表查询接口,传入信息", JSONUtil.toJsonStr(queryInvoiceList));
DxhyInterfaceResponse dxhyInterfaceResponse = null;
try {
dxhyInterfaceResponse = ElephantUtils.sendRequestWithoutTokenV6(ElephantConstantsV6.INVOICE_LIST_INFO_URL, ElephantConstantsV6.INVOICE_LIST_METHOD, JSONUtil.parse(queryInvoiceList), companyservice);
} catch (UnsupportedEncodingException | InvalidKeyException | NoSuchAlgorithmException e) {
log.error("【销项发票】【大象接口】【发票列表查询】发票请求异常,请求报文{},销方信息{}", JSONUtil.parse(queryInvoiceList).toString(), JSONObject.toJSONString(companyservice));
e.printStackTrace();
throw new JianshuiServiceException("系统异常!");
}
return null;
return parseResult(dxhyInterfaceResponse);
}
@Override
@ -1507,7 +1516,23 @@ public class ElephantInvoiceApiV6ByInspurServiceImpl implements IInvoiceApiServi
@Override
public HXResponse queryTaxpayerGeneralInfo(JSONObject decryptResult, Companyservice companyservice) {
return null;
decryptResult = JsonKeyCase.JsonKeyCase(decryptResult);
log.info("调用大象V6接口报文key转大写后的报文为{}", decryptResult);
DxhyInterfaceResponse dxhyInterfaceResponse = null;
try {
dxhyInterfaceResponse = ElephantUtils.sendRequestWithoutTokenV6(ElephantConstantsV6.QUERY_TAXPAYER_GENERAL_INFO_LOCALHOST, ElephantConstantsV6.QUERY_TAXPAYER_GENERAL_INFO_METHOD, JSONUtil.parse(decryptResult), companyservice);
} catch (UnsupportedEncodingException | InvalidKeyException | NoSuchAlgorithmException e) {
log.error("【销项发票】【大象接口】【数电】【红字确认单确认接口】发票请求异常,请求报文{},销方信息{},异常{}", decryptResult, JSONObject.toJSONString(companyservice),e);
return new HXResponse("009999", "系统异常!");
}
HXResponse hxResponse = parseResult(dxhyInterfaceResponse);
hxResponse.put("msg", hxResponse.getMessage());
if (hxResponse.isSuccess() && ObjectUtils.isNotEmpty(hxResponse.getData()) && StringUtils.isNotBlank(hxResponse.getData().toString())){
JSONObject jsonObject = JSON.parseObject(hxResponse.getData().toString());
hxResponse.setData(jsonObject);
}
return hxResponse;
}
@ -1587,7 +1612,7 @@ public class ElephantInvoiceApiV6ByInspurServiceImpl implements IInvoiceApiServi
e.printStackTrace();
return new HXResponse("009999", "系统异常!");
}
HXResponse hxResponse = parseResult(dxhyInterfaceResponse);
HXResponse hxResponse = parseResultRedApply(dxhyInterfaceResponse);
if("000000".equals(hxResponse.get("code"))){
cn.hutool.json.JSONObject data = JSONUtil.parseObj(hxResponse.getData());
@ -1606,7 +1631,7 @@ public class ElephantInvoiceApiV6ByInspurServiceImpl implements IInvoiceApiServi
allApiLogMapper.insertInvoiceAllApiLog(allApiLog);
}
}
return parseResult(dxhyInterfaceResponse);
return parseResultRedApply(dxhyInterfaceResponse);
}
@ -1718,6 +1743,54 @@ public class ElephantInvoiceApiV6ByInspurServiceImpl implements IInvoiceApiServi
Object data = dxhyInterfaceResponse.getData() != null ? dxhyInterfaceResponse.getData() : "";
String code = dxhyInterfaceResponse.getCode() != null ? dxhyInterfaceResponse.getCode() : "";
if ("000000".equals(code)) {
if (ObjUtil.isNotEmpty(data)) {
cn.hutool.json.JSONObject dataJson = JSONUtil.parseObj(data);
String ztdm = dataJson.get("ZTDM") != null ? dataJson.get("ZTDM").toString() : "";
String ztxx = dataJson.get("ZTXX") != null ? dataJson.get("ZTXX").toString() : "";
String dataTemp = dataJson.get("DATA") != null ? dataJson.get("DATA").toString() : "";
if ("000000".equals(ztdm)) {
cn.hutool.json.JSONObject json = null;
if (StrUtil.isNotEmpty(dataTemp)) {
json = JSONUtil.parseObj(dataTemp);
} else {
json = JSONUtil.parseObj(data);
}
// 键值转小写
// JSONObject lowerCaseJson = new JSONObject();
// json.forEach((key, value) -> {
// String lowerCaseKey = key.toLowerCase();
// lowerCaseJson.put(lowerCaseKey, value);
// });
return new HXResponse(code, "", json, true);
} else {
return new HXResponse(ztdm, ztxx, "", true);
}
}
} else {
return new HXResponse(code, "接口请求失败!", "", false);
}
return new HXResponse(code, "接口请求失败!", "", false);
}
/**
* 大象红字确认单申请返回
*
* @param dxhyInterfaceResponse
* @return
*/
public HXResponse parseResultRedApply(DxhyInterfaceResponse dxhyInterfaceResponse) {
if (BeanUtil.isEmpty(dxhyInterfaceResponse)) {
return new HXResponse("9999", "接口请求失败!返回内容不存在!", "", false);
}
// 大象通用返回处理,返回简税HXResponse
Object data = dxhyInterfaceResponse.getData() != null ? dxhyInterfaceResponse.getData() : "";
String code = dxhyInterfaceResponse.getCode() != null ? dxhyInterfaceResponse.getCode() : "";
if ("000000".equals(code)) {
if (ObjUtil.isNotEmpty(data)) {
cn.hutool.json.JSONObject dataJson = JSONUtil.parseObj(data);
@ -1738,7 +1811,7 @@ public class ElephantInvoiceApiV6ByInspurServiceImpl implements IInvoiceApiServi
String lowerCaseKey = key.toLowerCase();
lowerCaseJson.put(lowerCaseKey, value);
});
return new HXResponse(code, "", json, true);
return new HXResponse(code, "", lowerCaseJson, true);
} else {
return new HXResponse(ztdm, ztxx, "", true);
}
@ -2728,6 +2801,7 @@ public class ElephantInvoiceApiV6ByInspurServiceImpl implements IInvoiceApiServi
HXResponse hxResponse = queryInvoice(queryBillInfoDTO, companyservice);
if(StringUtils.equals("0000",hxResponse.getCode())){
addHzxxToRespon(hxResponse, allApiLog);
return hxResponse;
}
@ -2737,6 +2811,7 @@ public class ElephantInvoiceApiV6ByInspurServiceImpl implements IInvoiceApiServi
queryWrapper.orderByDesc(Invoice::getId).last("limit 1");
Invoice invoice = invoiceMapper.selectOne(queryWrapper);
addHzxxToRespon(hxResponse, allApiLog);
response.put("data",invoice);
return response;
@ -2760,6 +2835,7 @@ public class ElephantInvoiceApiV6ByInspurServiceImpl implements IInvoiceApiServi
HXResponse hxResponse = parseResult(dxhyInterfaceResponse);
hxResponse = parseDxhyRes(hxResponse,companyservice);
addHzxxToRespon(hxResponse, allApiLog);
return hxResponse;
}else if (WebServiceConstant.CXHZFPXXQRD.equals(finalServiceId)) {
@ -2819,6 +2895,22 @@ public class ElephantInvoiceApiV6ByInspurServiceImpl implements IInvoiceApiServi
}
private void addHzxxToRespon(HXResponse hxResponse, InvoiceAllApiLog allApiLog) {
try {
if (StringUtils.isNotBlank(allApiLog.getResultMsg()) && ObjectUtils.isNotEmpty(hxResponse.getData())) {
log.info("表中记录结果信息为:{}",allApiLog.getResultMsg());
JSONObject data = JSON.parseObject(JSON.toJSONString(hxResponse.getData()));
JSONObject result = JSON.parseObject(allApiLog.getResultMsg());
for (String key : result.keySet()) {
data.put(key, result.get(key));
}
log.info("添加后数据后data:{}",data);
hxResponse.put("data",data);
}
}catch (Exception e){
log.error("【销项发票】查询红字单和发票添加红字信息异常",e);
}
}
/** 转换大象返回报文为简税报文 */
private HXResponse parseDxhyRes(HXResponse hxResponse,Companyservice companyservice) {

Loading…
Cancel
Save