|
|
|
@ -77,7 +77,7 @@ public class SDNYMainProcessController extends AbstractController { |
|
|
|
|
@ResponseBody |
|
|
|
|
@SysLog("发票查验") |
|
|
|
|
public ResponseEntity<String> singleInvoiceCheck(@RequestBody Map<String, String> pramsMap) { |
|
|
|
|
log.info("传入的参数为:{}",pramsMap); |
|
|
|
|
log.info("传入的参数为:{}", pramsMap); |
|
|
|
|
String userid = "101833"; |
|
|
|
|
String dbName = "business"; |
|
|
|
|
String company = "BIGB"; |
|
|
|
@ -89,7 +89,7 @@ public class SDNYMainProcessController extends AbstractController { |
|
|
|
|
JSONObject checkInvoiceResult = null; |
|
|
|
|
InvoiceUtil iu = new InvoiceUtil(pramsMap.get("invoiceCode")); |
|
|
|
|
String fplxdm = iu.getFplxdm(); |
|
|
|
|
if(fplxdm != null || "10107".equals(pramsMap.get("invoiceType")) || "10108".equals(pramsMap.get("invoiceType"))) { |
|
|
|
|
if (fplxdm != null || "10107".equals(pramsMap.get("invoiceType")) || "10108".equals(pramsMap.get("invoiceType"))) { |
|
|
|
|
//查验类发票,执行查验操作后入库
|
|
|
|
|
log.info("查验类发票,执行查验操作后入库"); |
|
|
|
|
//权限校验
|
|
|
|
@ -172,7 +172,7 @@ public class SDNYMainProcessController extends AbstractController { |
|
|
|
|
|
|
|
|
|
return ResponseEntity.ok(JSONObject.toJSONString(data)); |
|
|
|
|
} |
|
|
|
|
}else{ |
|
|
|
|
} else { |
|
|
|
|
//其他类发票,直接入库
|
|
|
|
|
log.info("其他类发票,不做查验,直接入库"); |
|
|
|
|
TDxInvoiceReimburse reimburse = new TDxInvoiceReimburse(); |
|
|
|
@ -181,7 +181,7 @@ public class SDNYMainProcessController extends AbstractController { |
|
|
|
|
R data = new R(1000, "default success"); |
|
|
|
|
data.put("message", "success"); |
|
|
|
|
|
|
|
|
|
if (insert>0) { |
|
|
|
|
if (insert > 0) { |
|
|
|
|
checkInvoiceResult.put("invoiceNo", checkInvoiceResult.getString("invoiceNumber")); |
|
|
|
|
checkInvoiceResult.put("company", company); |
|
|
|
|
checkInvoiceResult.put("message", "入库成功"); |
|
|
|
@ -203,7 +203,7 @@ public class SDNYMainProcessController extends AbstractController { |
|
|
|
|
@SysLog("同步发票信息") |
|
|
|
|
public ResponseEntity<String> syncInvoiceInfo(@RequestBody SNRequestObject snRequestObject) { |
|
|
|
|
|
|
|
|
|
log.info("影像系统同步数据:{}",JSONObject.toJSONString(snRequestObject)); |
|
|
|
|
log.info("影像系统同步数据:{}", JSONObject.toJSONString(snRequestObject)); |
|
|
|
|
|
|
|
|
|
String userid = "101833"; |
|
|
|
|
String dbName = "business"; |
|
|
|
@ -233,6 +233,18 @@ public class SDNYMainProcessController extends AbstractController { |
|
|
|
|
reimburse.setImageId(imageId); |
|
|
|
|
reimburse.setCompCode(compCode); |
|
|
|
|
|
|
|
|
|
SNSAPObject object = new SNSAPObject(); |
|
|
|
|
object.setSYSID("FPXT"); |
|
|
|
|
object.setIFYWID("FI845"); |
|
|
|
|
object.setBSKEY(UUID.randomUUID().toString().replace("-", "")); |
|
|
|
|
object.setSAPKEY(""); |
|
|
|
|
object.setZORG(compCode); |
|
|
|
|
object.setZFILED1(""); |
|
|
|
|
object.setZFILED2(""); |
|
|
|
|
object.setZFILED3(""); |
|
|
|
|
object.setZFILED4(""); |
|
|
|
|
object.setZFILED5(environment); |
|
|
|
|
List<SAPInvoiceInfo> sapInvoiceInfos = new ArrayList<>(); |
|
|
|
|
if (invoiceInfoList != null && invoiceInfoList.size() > 0) { |
|
|
|
|
for (SNInvoice invoice : invoiceInfoList) { |
|
|
|
|
String fplxdm = ""; |
|
|
|
@ -241,52 +253,53 @@ public class SDNYMainProcessController extends AbstractController { |
|
|
|
|
String invoiceNo = invoice.getInvoiceNumber(); |
|
|
|
|
result = snPushCheckRecordService.updateInvoicePoll(snRequestObject, company, taxNo, reimburse, invoice, fplxdm, invoiceCode, invoiceNo); |
|
|
|
|
|
|
|
|
|
if(!"ok".equals(result) && !"0000".equals(result)){ |
|
|
|
|
//价税分离判断
|
|
|
|
|
if (!"ok".equals(result) && !"0000".equals(result)) { |
|
|
|
|
R data = new R(1000, "default success"); |
|
|
|
|
data.put("data", result); |
|
|
|
|
return ResponseEntity.ok(JSONObject.toJSONString(data)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//推送到SAP
|
|
|
|
|
SNSAPObject object = convertToSapOnject(invoice, imageId,compCode); |
|
|
|
|
log.info("推送山能数据:{}",JSONObject.toJSONString(object)); |
|
|
|
|
|
|
|
|
|
JSONObject request = new JSONObject(); |
|
|
|
|
request.put("IS_INPUT",object); |
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
//将信息推送到影像系统
|
|
|
|
|
result = snPushCheckRecordService.pushCheckResultToSAP(request.toJSONString()); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
e.printStackTrace(); |
|
|
|
|
log.error("", e); |
|
|
|
|
return ResponseEntity.ok(JSONObject.toJSONString(R.error(CommonConstants.MSG_ERR_PUSH_SDNY))); |
|
|
|
|
return ResponseEntity.ok(JSONObject.toJSONString(R.error(result))); |
|
|
|
|
} |
|
|
|
|
SAPInvoiceInfo info = convertToSapOnject(invoice, imageId, compCode); |
|
|
|
|
sapInvoiceInfos.add(info); |
|
|
|
|
} |
|
|
|
|
object.setZDATA(JSONObject.toJSONString(sapInvoiceInfos)); |
|
|
|
|
|
|
|
|
|
//推送到SAP
|
|
|
|
|
log.info("推送山能数据:{}", JSONObject.toJSONString(object)); |
|
|
|
|
JSONObject request = new JSONObject(); |
|
|
|
|
request.put("IS_INPUT", object); |
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
//将信息推送到影像系统
|
|
|
|
|
result = snPushCheckRecordService.pushCheckResultToSAP(request.toJSONString()); |
|
|
|
|
|
|
|
|
|
R data = new R(1000, "default success"); |
|
|
|
|
data.put("data", result); |
|
|
|
|
return ResponseEntity.ok(JSONObject.toJSONString(data)); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
e.printStackTrace(); |
|
|
|
|
log.error("", e); |
|
|
|
|
return ResponseEntity.ok(JSONObject.toJSONString(R.error(CommonConstants.MSG_ERR_PUSH_SDNY))); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
R data = new R(1000, "default success"); |
|
|
|
|
data.put("data", result); |
|
|
|
|
return ResponseEntity.ok(JSONObject.toJSONString(data)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
R data = new R(1000, "default success"); |
|
|
|
|
data.put("data", result); |
|
|
|
|
return ResponseEntity.ok(JSONObject.toJSONString(data)); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
e.printStackTrace(); |
|
|
|
|
} catch (Exception exception) { |
|
|
|
|
exception.printStackTrace(); |
|
|
|
|
} |
|
|
|
|
return ResponseEntity.ok(JSONObject.toJSONString(R.error(CommonConstants.MSG_ERR_DEFAULT))); |
|
|
|
|
return ResponseEntity.ok(JSONObject.toJSONString(R.error(CommonConstants.MSG_ERR_PUSH_SDNY))); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 查验发票 |
|
|
|
|
*/ |
|
|
|
|
@PostMapping("/sn/signature") |
|
|
|
|
@ResponseBody |
|
|
|
|
@SysLog("获取接口签名值") |
|
|
|
|
public String signature(@RequestBody Map<String,String> paramMap) { |
|
|
|
|
public String signature(@RequestBody Map<String, String> paramMap) { |
|
|
|
|
String ip = paramMap.get("ip"); |
|
|
|
|
String apiCode = paramMap.get("apiCode"); |
|
|
|
|
String secretId = paramMap.get("secretId"); |
|
|
|
@ -301,31 +314,16 @@ public class SDNYMainProcessController extends AbstractController { |
|
|
|
|
sortMap.put("zipCode", "0"); |
|
|
|
|
sortMap.put("content", content); |
|
|
|
|
|
|
|
|
|
String url = "POST"+ ip +"/invoice/jxpt/api/v5/"+ apiCode +"?"; |
|
|
|
|
String url = "POST" + ip + "/invoice/jxpt/api/v5/" + apiCode + "?"; |
|
|
|
|
|
|
|
|
|
String signature = HmacSHA1Util.genSign(url, sortMap,secretKey); |
|
|
|
|
String signature = HmacSHA1Util.genSign(url, sortMap, secretKey); |
|
|
|
|
return signature; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private SNSAPObject convertToSapOnject(SNInvoice snInvoice, String imageId,String compCode) { |
|
|
|
|
private SAPInvoiceInfo convertToSapOnject(SNInvoice snInvoice, String imageId, String compCode) { |
|
|
|
|
|
|
|
|
|
Date date = new Date(); |
|
|
|
|
|
|
|
|
|
SNSAPObject object = new SNSAPObject(); |
|
|
|
|
object.setSYSID("FPXT"); |
|
|
|
|
object.setIFYWID("FI845"); |
|
|
|
|
object.setBSKEY(UUID.randomUUID().toString().replace("-", "")); |
|
|
|
|
object.setSAPKEY(""); |
|
|
|
|
object.setZORG(compCode); |
|
|
|
|
object.setZFILED1(""); |
|
|
|
|
object.setZFILED2(""); |
|
|
|
|
object.setZFILED3(""); |
|
|
|
|
object.setZFILED4(""); |
|
|
|
|
object.setZFILED5(environment); |
|
|
|
|
|
|
|
|
|
List<SAPInvoiceInfo> sapInvoiceInfos = new ArrayList<>(); |
|
|
|
|
SAPInvoiceInfo info = new SAPInvoiceInfo(); |
|
|
|
|
info.setZBAZT("0"); |
|
|
|
|
info.setZXFSH(snInvoice.getSalesTaxNo()); |
|
|
|
@ -336,11 +334,11 @@ public class SDNYMainProcessController extends AbstractController { |
|
|
|
|
info.setZJKZM(snInvoice.getImportCertificateNo()); |
|
|
|
|
info.setZDJZH(snInvoice.getCertificateNo()); |
|
|
|
|
info.setZGFMC(snInvoice.getPurchaserName()); |
|
|
|
|
if(snInvoice.getTotalAmount() != null && snInvoice.getTotalTax() != null) { |
|
|
|
|
if (snInvoice.getTotalAmount() != null && snInvoice.getTotalTax() != null) { |
|
|
|
|
BigDecimal total = new BigDecimal(snInvoice.getTotalAmount()); |
|
|
|
|
BigDecimal tax = new BigDecimal(snInvoice.getTotalTax()); |
|
|
|
|
BigDecimal subtract = total.subtract(tax); |
|
|
|
|
info.setZJK(subtract.toString()); |
|
|
|
|
// BigDecimal tax = new BigDecimal(snInvoice.getTotalTax());
|
|
|
|
|
// BigDecimal subtract = total.subtract(tax);
|
|
|
|
|
info.setZJK(total.toString()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
info.setZSCSJ(date); |
|
|
|
@ -373,7 +371,8 @@ public class SDNYMainProcessController extends AbstractController { |
|
|
|
|
sapInvoiceDetail.setZCFZ(snInvoice.getStationGetOn()); |
|
|
|
|
sapInvoiceDetail.setZTXZ(snInvoiceDetail.getCurrentDateEnd()); |
|
|
|
|
sapInvoiceDetail.setZTXQ(snInvoiceDetail.getCurrentDateStart()); |
|
|
|
|
sapInvoiceDetail.setZJK(snInvoiceDetail.getAmount()); |
|
|
|
|
if (snInvoiceDetail.getAmount() != null) |
|
|
|
|
sapInvoiceDetail.setZJK(snInvoiceDetail.getAmount()); |
|
|
|
|
sapInvoiceDetail.setZHH(snInvoiceDetail.getRowNo()); |
|
|
|
|
sapInvoiceDetail.setZTAX(snInvoiceDetail.getTaxRate()); |
|
|
|
|
// sapInvoiceDetail.setZHBH("");
|
|
|
|
@ -388,9 +387,9 @@ public class SDNYMainProcessController extends AbstractController { |
|
|
|
|
sapInvoiceDetail.setZSL(snInvoiceDetail.getQuantity()); |
|
|
|
|
sapInvoiceDetail.setZSM(info.getZSM()); |
|
|
|
|
sapInvoiceDetail.setZGGXH(snInvoiceDetail.getSpecificationModel()); |
|
|
|
|
if(snInvoice.getInvoiceCode() != null) { |
|
|
|
|
if (snInvoice.getInvoiceCode() != null) { |
|
|
|
|
sapInvoiceDetail.setZTID(snInvoice.getInvoiceCode() + snInvoice.getInvoiceNumber()); |
|
|
|
|
}else{ |
|
|
|
|
} else { |
|
|
|
|
sapInvoiceDetail.setZTID(snInvoice.getInvoiceNumber()); |
|
|
|
|
} |
|
|
|
|
sapInvoiceDetailList.add(sapInvoiceDetail); |
|
|
|
@ -422,7 +421,7 @@ public class SDNYMainProcessController extends AbstractController { |
|
|
|
|
|
|
|
|
|
//认证相关
|
|
|
|
|
info.setZRZJG("0"); |
|
|
|
|
info.setZRZSSQ("202302"); |
|
|
|
|
info.setZRZSSQ(""); |
|
|
|
|
// info.setZRZMS("");
|
|
|
|
|
// info.setZRZRQ("");
|
|
|
|
|
|
|
|
|
@ -454,12 +453,12 @@ public class SDNYMainProcessController extends AbstractController { |
|
|
|
|
// info.setZQM("");
|
|
|
|
|
info.setZPJLY(snInvoice.getSource()); |
|
|
|
|
info.setZZWLX(snInvoice.getSeat()); |
|
|
|
|
info.setZTID(snInvoice.getInvoiceCode()+snInvoice.getInvoiceNumber()); |
|
|
|
|
|
|
|
|
|
sapInvoiceInfos.add(info); |
|
|
|
|
object.setZDATA(JSONObject.toJSONString(sapInvoiceInfos)); |
|
|
|
|
return object; |
|
|
|
|
|
|
|
|
|
if (snInvoice.getInvoiceCode() != null) { |
|
|
|
|
info.setZTID(snInvoice.getInvoiceCode() + snInvoice.getInvoiceNumber()); |
|
|
|
|
} else { |
|
|
|
|
info.setZTID(snInvoice.getInvoiceNumber()); |
|
|
|
|
} |
|
|
|
|
return info; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private String convertToSapType(String invoiceType) { |
|
|
|
@ -496,7 +495,7 @@ public class SDNYMainProcessController extends AbstractController { |
|
|
|
|
case "92": |
|
|
|
|
invoiceType = "19"; |
|
|
|
|
break; |
|
|
|
|
case "94": |
|
|
|
|
case "89": |
|
|
|
|
invoiceType = "20"; |
|
|
|
|
break; |
|
|
|
|
case "90": |
|
|
|
@ -535,40 +534,40 @@ public class SDNYMainProcessController extends AbstractController { |
|
|
|
|
|
|
|
|
|
switch (taxRate) { |
|
|
|
|
// 发票采集
|
|
|
|
|
case "0": |
|
|
|
|
case "0.00": |
|
|
|
|
sm = "J0"; |
|
|
|
|
break; |
|
|
|
|
case "免税": |
|
|
|
|
sm = "J0"; |
|
|
|
|
break; |
|
|
|
|
case "16": |
|
|
|
|
case "0.16": |
|
|
|
|
sm = "J1"; |
|
|
|
|
break; |
|
|
|
|
case "13": |
|
|
|
|
case "0.13": |
|
|
|
|
sm = "J2"; |
|
|
|
|
break; |
|
|
|
|
case "10": |
|
|
|
|
case "0.10": |
|
|
|
|
sm = "J3"; |
|
|
|
|
break; |
|
|
|
|
case "9": |
|
|
|
|
case "0.09": |
|
|
|
|
sm = "J4"; |
|
|
|
|
break; |
|
|
|
|
case "6": |
|
|
|
|
case "0.06": |
|
|
|
|
sm = "J5"; |
|
|
|
|
break; |
|
|
|
|
case "5": |
|
|
|
|
case "0.05": |
|
|
|
|
sm = "J6"; |
|
|
|
|
break; |
|
|
|
|
case "3": |
|
|
|
|
case "0.03": |
|
|
|
|
sm = "J7"; |
|
|
|
|
break; |
|
|
|
|
case "2": |
|
|
|
|
case "0.02": |
|
|
|
|
sm = "J8"; |
|
|
|
|
break; |
|
|
|
|
case "1": |
|
|
|
|
case "0.01": |
|
|
|
|
sm = "J9"; |
|
|
|
|
break; |
|
|
|
|
case "17": |
|
|
|
|
case "0.17": |
|
|
|
|
sm = "JC"; |
|
|
|
|
break; |
|
|
|
|
default: |
|
|
|
|