|
|
|
@ -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,43 +253,44 @@ 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)) { |
|
|
|
|
R data = new R(1000, "default success"); |
|
|
|
|
data.put("data", result); |
|
|
|
|
return ResponseEntity.ok(JSONObject.toJSONString(data)); |
|
|
|
|
return ResponseEntity.ok(JSONObject.toJSONString(R.error(result))); |
|
|
|
|
} |
|
|
|
|
SAPInvoiceInfo info = convertToSapOnject(invoice, imageId, compCode); |
|
|
|
|
sapInvoiceInfos.add(info); |
|
|
|
|
} |
|
|
|
|
object.setZDATA(JSONObject.toJSONString(sapInvoiceInfos)); |
|
|
|
|
|
|
|
|
|
//推送到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()); |
|
|
|
|
|
|
|
|
|
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)); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
e.printStackTrace(); |
|
|
|
|
} |
|
|
|
|
return ResponseEntity.ok(JSONObject.toJSONString(R.error(CommonConstants.MSG_ERR_DEFAULT))); |
|
|
|
|
} catch (Exception exception) { |
|
|
|
|
exception.printStackTrace(); |
|
|
|
|
} |
|
|
|
|
return ResponseEntity.ok(JSONObject.toJSONString(R.error(CommonConstants.MSG_ERR_PUSH_SDNY))); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -307,25 +320,10 @@ public class SDNYMainProcessController extends AbstractController { |
|
|
|
|
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()); |
|
|
|
@ -338,9 +336,9 @@ public class SDNYMainProcessController extends AbstractController { |
|
|
|
|
info.setZGFMC(snInvoice.getPurchaserName()); |
|
|
|
|
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,6 +371,7 @@ public class SDNYMainProcessController extends AbstractController { |
|
|
|
|
sapInvoiceDetail.setZCFZ(snInvoice.getStationGetOn()); |
|
|
|
|
sapInvoiceDetail.setZTXZ(snInvoiceDetail.getCurrentDateEnd()); |
|
|
|
|
sapInvoiceDetail.setZTXQ(snInvoiceDetail.getCurrentDateStart()); |
|
|
|
|
if (snInvoiceDetail.getAmount() != null) |
|
|
|
|
sapInvoiceDetail.setZJK(snInvoiceDetail.getAmount()); |
|
|
|
|
sapInvoiceDetail.setZHH(snInvoiceDetail.getRowNo()); |
|
|
|
|
sapInvoiceDetail.setZTAX(snInvoiceDetail.getTaxRate()); |
|
|
|
@ -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()); |
|
|
|
|
if (snInvoice.getInvoiceCode() != null) { |
|
|
|
|
info.setZTID(snInvoice.getInvoiceCode() + snInvoice.getInvoiceNumber()); |
|
|
|
|
|
|
|
|
|
sapInvoiceInfos.add(info); |
|
|
|
|
object.setZDATA(JSONObject.toJSONString(sapInvoiceInfos)); |
|
|
|
|
return object; |
|
|
|
|
|
|
|
|
|
} 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: |
|
|
|
|