diff --git a/dxhy-erp/src/main/java/com/dxhy/erp/controller/SDNYMainProcessController.java b/dxhy-erp/src/main/java/com/dxhy/erp/controller/SDNYMainProcessController.java index 8ddcb536..6bdad183 100644 --- a/dxhy-erp/src/main/java/com/dxhy/erp/controller/SDNYMainProcessController.java +++ b/dxhy-erp/src/main/java/com/dxhy/erp/controller/SDNYMainProcessController.java @@ -203,11 +203,11 @@ public class SDNYMainProcessController extends AbstractController { List baseTDxRecordInvoiceDetail = baseTDxRecordInvoiceDetailDao.selectList(detailWrapper); DynamicContextHolder.push("business" + DbConstant.BUSINESS_READ); - if(baseTDxRecordInvoiceDetail != null && baseTDxRecordInvoiceDetail.size() == 0){ + if(baseTDxRecordInvoiceDetail != null && baseTDxRecordInvoiceDetail.size() != 0){ //先删除原有主数据,再查验更新主数据和明细数据 int delete = baseTDxRecordInvoiceDao.delete(recordWrapper); if(delete > 0) { - checkInvoiceResult = snPushCheckRecordService.singleCheckInvoice(pramsMap); + checkInvoiceResult = snPushCheckRecordService.singleCheckInvoice(pramsMap,null); if (!checkInvoiceResult.containsKey("code")) { if (!checkInvoiceResult.containsKey("cyjg")) { @@ -261,7 +261,7 @@ public class SDNYMainProcessController extends AbstractController { } try { - checkInvoiceResult = snPushCheckRecordService.singleCheckInvoice(pramsMap); + checkInvoiceResult = snPushCheckRecordService.singleCheckInvoice(pramsMap,"1"); log.info("查验结果为:{}", checkInvoiceResult); } catch (Exception e) { e.printStackTrace(); @@ -507,8 +507,7 @@ public class SDNYMainProcessController extends AbstractController { } BigDecimal tax = new BigDecimal(taxRateDetail); BigDecimal tax1 = tax.divide(new BigDecimal("100")); - // TODO - if (tax.compareTo(new BigDecimal("1")) < 0) { + if (tax.compareTo(new BigDecimal("0.99")) < 1) { taxRateDetail = tax.toPlainString(); }else { taxRateDetail = tax1.toPlainString(); @@ -829,13 +828,14 @@ public class SDNYMainProcessController extends AbstractController { sapInvoiceDetail.setZTAX("0.00"); sapInvoiceDetail.setZSM(getZSM(sapInvoiceDetail.getZTAX())); } else { + //传给SAP税率为整数 BigDecimal tax = new BigDecimal(taxRate); sapInvoiceDetail.setZSM(getZSM(tax.toString())); BigDecimal tax1 = tax.multiply(new BigDecimal("100")); sapInvoiceDetail.setZTAX(tax1.toString()); - if (tax1.compareTo(new BigDecimal("100")) >= 0) { + if (tax1.compareTo(new BigDecimal("99")) > 0) { sapInvoiceDetail.setZTAX(taxRate); - }else if (tax1.scale() > 2){ + }else { DecimalFormat decimalFormat = new DecimalFormat("#.00"); String formattedDecimal = decimalFormat.format(tax1); sapInvoiceDetail.setZTAX(formattedDecimal); @@ -1259,25 +1259,11 @@ public class SDNYMainProcessController extends AbstractController { } public static void main(String[] args) { -// DecimalFormat decimalFormat = new DecimalFormat("#.00"); -// String formattedDecimal = decimalFormat.format(new BigDecimal("15")); -// BigDecimal bigDecimal = new BigDecimal("0.13"); -// boolean b = bigDecimal.compareTo(new BigDecimal("1")) < 1; -// System.out.println(); - - SAPInvoiceDetail sapInvoiceDetail = new SAPInvoiceDetail(); - String taxRate = "6.00"; - BigDecimal tax = new BigDecimal(taxRate); - BigDecimal tax1 = tax.multiply(new BigDecimal("100")); - sapInvoiceDetail.setZTAX(tax1.toString()); - if (tax1.compareTo(new BigDecimal("100")) > 0) { - sapInvoiceDetail.setZTAX(taxRate); - }else if (tax1.scale() > 2){ - DecimalFormat decimalFormat = new DecimalFormat("#.00"); - String formattedDecimal = decimalFormat.format(tax1); - sapInvoiceDetail.setZTAX(formattedDecimal); - } - System.out.println("sapInvoiceDetail="+sapInvoiceDetail.getZTAX()); + DecimalFormat decimalFormat = new DecimalFormat("#.00"); + String formattedDecimal = decimalFormat.format(new BigDecimal("15")); + BigDecimal bigDecimal = new BigDecimal("0.13"); + boolean b = bigDecimal.compareTo(new BigDecimal("0.99")) < 1; + System.out.println(); } } diff --git a/dxhy-erp/src/main/java/com/dxhy/erp/service/SNPushCheckRecordService.java b/dxhy-erp/src/main/java/com/dxhy/erp/service/SNPushCheckRecordService.java index 5600153b..43b1c58e 100644 --- a/dxhy-erp/src/main/java/com/dxhy/erp/service/SNPushCheckRecordService.java +++ b/dxhy-erp/src/main/java/com/dxhy/erp/service/SNPushCheckRecordService.java @@ -270,7 +270,7 @@ public class SNPushCheckRecordService extends AbstractServiceAdapter { return queryInvoiceResult; } - public JSONObject singleCheckInvoice(Map pramsMap) throws Exception { + public JSONObject singleCheckInvoice(Map pramsMap, String isInteger) throws Exception { //1.封装查验参数 ApiRequest apiRequest = new ApiRequest(); @@ -306,7 +306,7 @@ public class SNPushCheckRecordService extends AbstractServiceAdapter { JSONObject jsonObject = new JSONObject(); if (StringUtils.isNoneBlank(apiResponse.getContent())) { log.info("查验的结果为:{}", apiResponse.getContent()); - jsonObject = convertToSnObject(apiResponse.getContent(), jsonObject, fplxdm); + jsonObject = convertToSnObject(apiResponse.getContent(), jsonObject, fplxdm, isInteger); } // saveCheckRecord(pramsMap, apiResponse); @@ -331,7 +331,7 @@ public class SNPushCheckRecordService extends AbstractServiceAdapter { platformCheckLogService.save(checkLog); } - private JSONObject convertToSnObject(String content, JSONObject jsonObject, String invoiceType) throws ParseException { + private JSONObject convertToSnObject(String content, JSONObject jsonObject, String invoiceType, String isInteger) throws ParseException { String con = new String(Base64.decode(content)); HashMap contentMap = JSONObject.parseObject(con, HashMap.class); @@ -468,6 +468,11 @@ public class SNPushCheckRecordService extends AbstractServiceAdapter { if (taxRate.contains("%")) { taxRate = taxRate.replace("%",""); } + //按照小数处理 + if(StringUtils.isNotBlank(isInteger)){ + BigDecimal bigDecimal = new BigDecimal(taxRate); + taxRate = bigDecimal.divide(new BigDecimal("100")).toPlainString(); + } if ("11".equals(invoiceType)) { taxRate = "0"; @@ -553,25 +558,27 @@ public class SNPushCheckRecordService extends AbstractServiceAdapter { } - if ("免税".equals(detail.getString("sl")) || "不征税".equals(detail.getString("sl")) || "***".equals(detail.getString("sl"))) { + if (StringUtils.isBlank(detail.get("sl").toString()) || "免税".equals(detail.get("sl").toString()) || "不征税".equals(detail.get("sl").toString()) + || "***".equals(detail.get("sl").toString())) { taxRateDetail = "0"; snDetailMap.put("taxRate", taxRateDetail); } else { if (StringUtils.isNoneBlank(detail.get("sl").toString())) { - taxRateDetail = detail.get("sl").toString(); - if (!"0".equals(taxRateDetail)) { - if (StringUtils.isNoneBlank(taxRateDetail)) { - if(taxRateDetail.contains("%")){ - taxRateDetail = taxRateDetail.replace("%",""); - } - } + taxRate = detail.get("sl").toString(); + taxRate = taxRate.replace("%", ""); +// if (!"0".equals(taxRate)) { +// taxRate = taxRate.substring(0, taxRate.length() - 1); +// } + //按照小数处理 + if(StringUtils.isNotBlank(isInteger)){ + BigDecimal bigDecimal = new BigDecimal(taxRate); + taxRate = bigDecimal.divide(new BigDecimal("100")).toPlainString(); } - if ("11".equals(invoiceType)) { - taxRateDetail = "0"; + taxRate = "0"; } - log.info("明细-发票税率为:{}", taxRateDetail); - snDetailMap.put("taxRate", taxRateDetail); + log.info("明细-发票税率为:{}", taxRate); + snDetailMap.put("taxRate", taxRate); } } @@ -719,7 +726,7 @@ public class SNPushCheckRecordService extends AbstractServiceAdapter { pramsMap.put("invoiceType", invoice.getInvoiceType()); } - checkInvoiceResult = snPushCheckRecordService.singleCheckInvoice(pramsMap); + checkInvoiceResult = snPushCheckRecordService.singleCheckInvoice(pramsMap,null); log.info("补充查验结果为:{}", checkInvoiceResult); } catch (Exception e) { e.printStackTrace(); diff --git a/dxhy-erp/src/main/java/com/dxhy/erp/service/impl/SignSaveInvoiceInfoServiceImpl.java b/dxhy-erp/src/main/java/com/dxhy/erp/service/impl/SignSaveInvoiceInfoServiceImpl.java index 8880401d..6316539a 100644 --- a/dxhy-erp/src/main/java/com/dxhy/erp/service/impl/SignSaveInvoiceInfoServiceImpl.java +++ b/dxhy-erp/src/main/java/com/dxhy/erp/service/impl/SignSaveInvoiceInfoServiceImpl.java @@ -1,5 +1,6 @@ package com.dxhy.erp.service.impl; +import com.aisinopdf.text.pdf.B; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; @@ -314,16 +315,18 @@ public class SignSaveInvoiceInfoServiceImpl extends MpBaseServiceImpl