|
|
@ -3,6 +3,7 @@ package com.dxhy.erp.controller; |
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.dxhy.common.aspect.SysLog; |
|
|
|
import com.dxhy.common.aspect.SysLog; |
|
|
|
import com.dxhy.common.constant.CommonConstants; |
|
|
|
import com.dxhy.common.constant.CommonConstants; |
|
|
|
|
|
|
|
import com.dxhy.common.constant.ConfigureConstant; |
|
|
|
import com.dxhy.common.controller.AbstractController; |
|
|
|
import com.dxhy.common.controller.AbstractController; |
|
|
|
import com.dxhy.common.enums.SNFplxEnum; |
|
|
|
import com.dxhy.common.enums.SNFplxEnum; |
|
|
|
import com.dxhy.common.util.InvoiceUtil; |
|
|
|
import com.dxhy.common.util.InvoiceUtil; |
|
|
@ -22,6 +23,7 @@ import org.springframework.web.bind.annotation.ResponseBody; |
|
|
|
import org.springframework.web.bind.annotation.RestController; |
|
|
|
import org.springframework.web.bind.annotation.RestController; |
|
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
|
import javax.annotation.Resource; |
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest; |
|
|
|
import java.math.BigDecimal; |
|
|
|
import java.math.BigDecimal; |
|
|
|
import java.util.*; |
|
|
|
import java.util.*; |
|
|
|
|
|
|
|
|
|
|
@ -281,7 +283,7 @@ public class SDNYMainProcessController extends AbstractController { |
|
|
|
@PostMapping("/sn/signature") |
|
|
|
@PostMapping("/sn/signature") |
|
|
|
@ResponseBody |
|
|
|
@ResponseBody |
|
|
|
@SysLog("获取接口签名值") |
|
|
|
@SysLog("获取接口签名值") |
|
|
|
public String signature(@RequestBody Map<String, String> paramMap) { |
|
|
|
public String signature(HttpServletRequest request, @RequestBody Map<String, String> paramMap) { |
|
|
|
String ip = paramMap.get("ip"); |
|
|
|
String ip = paramMap.get("ip"); |
|
|
|
String apiCode = paramMap.get("apiCode"); |
|
|
|
String apiCode = paramMap.get("apiCode"); |
|
|
|
String secretId = paramMap.get("secretId"); |
|
|
|
String secretId = paramMap.get("secretId"); |
|
|
@ -296,12 +298,33 @@ public class SDNYMainProcessController extends AbstractController { |
|
|
|
sortMap.put("zipCode", "0"); |
|
|
|
sortMap.put("zipCode", "0"); |
|
|
|
sortMap.put("content", content); |
|
|
|
sortMap.put("content", content); |
|
|
|
|
|
|
|
|
|
|
|
String url = "POST" + ip + "/invoice/jxpt/api/v5/" + apiCode + "?"; |
|
|
|
String reqUrl = request.getRequestURL().toString(); |
|
|
|
|
|
|
|
if (reqUrl.contains(ConfigureConstant.STRING_WH)) { |
|
|
|
String signature = HmacSHA1Util.genSign(url, sortMap, secretKey); |
|
|
|
reqUrl = reqUrl.substring(ConfigureConstant.INT_0, reqUrl.indexOf(ConfigureConstant.STRING_WH)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
//获取鉴权URL
|
|
|
|
|
|
|
|
String signUrl = getAuthUrl(reqUrl, request.getMethod()); |
|
|
|
|
|
|
|
String signature = HmacSHA1Util.genSign(signUrl, sortMap, secretKey); |
|
|
|
return signature; |
|
|
|
return signature; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static String getAuthUrl(String reqUrl, String method) { |
|
|
|
|
|
|
|
if (reqUrl.split(ConfigureConstant.STRING_COLON).length > ConfigureConstant.INT_2) { |
|
|
|
|
|
|
|
String one = reqUrl.split(ConfigureConstant.STRING_COLON)[1]; |
|
|
|
|
|
|
|
String two = reqUrl.split(ConfigureConstant.STRING_COLON)[2]; |
|
|
|
|
|
|
|
//支持带端口数据的返回
|
|
|
|
|
|
|
|
if (two.indexOf(ConfigureConstant.STRING_SLASH_LINE) > 0) { |
|
|
|
|
|
|
|
reqUrl = one.replaceAll("//", "") + ConfigureConstant.STRING_COLON + two; |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
reqUrl = one.replaceAll("//", "") + two.substring(two.indexOf(ConfigureConstant.STRING_SLASH_LINE)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} else if (reqUrl.split(ConfigureConstant.STRING_COLON).length == ConfigureConstant.INT_2) { |
|
|
|
|
|
|
|
String one = reqUrl.split(ConfigureConstant.STRING_COLON)[1]; |
|
|
|
|
|
|
|
reqUrl = one.contains("//") ? one.replaceAll("//", "") : reqUrl; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return method + reqUrl + "?"; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private SAPInvoiceInfo convertToSapOnject(SNInvoice snInvoice, String imageId, String compCode) { |
|
|
|
private SAPInvoiceInfo convertToSapOnject(SNInvoice snInvoice, String imageId, String compCode) { |
|
|
|
|
|
|
|
|
|
|
|
Date date = new Date(); |
|
|
|
Date date = new Date(); |
|
|
|