From f56e4e42de6a76173bf93b59161939280397b21d Mon Sep 17 00:00:00 2001 From: yefei Date: Thu, 25 May 2023 18:09:40 +0800 Subject: [PATCH] =?UTF-8?q?ariesy=20=E4=BF=AE=E5=A4=8D=E6=9F=A5=E9=AA=8C?= =?UTF-8?q?=E7=A5=A8=E6=B1=A0=E5=B7=B2=E5=AD=98=E5=9C=A8=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E7=A8=8E=E7=8E=87=E4=B8=BA=E6=95=B4=E6=95=B0=E7=9A=84=E6=83=85?= =?UTF-8?q?=E5=86=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/SDNYMainProcessController.java | 31 ++++++++++--------- .../java/com/dxhy/erp/utils/CheckUtil.java | 13 ++++++++ 2 files changed, 30 insertions(+), 14 deletions(-) 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 fc98e346..abeb45ef 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 @@ -20,6 +20,7 @@ import com.dxhy.erp.model.InvoiceDetailInfo; import com.dxhy.erp.service.*; import com.dxhy.erp.service.impl.GatherServiceImpl; import com.dxhy.erp.utils.Base64; +import com.dxhy.erp.utils.CheckUtil; import com.dxhy.erp.utils.HmacSHA1Util; import com.google.gson.JsonArray; import lombok.extern.slf4j.Slf4j; @@ -494,20 +495,22 @@ public class SDNYMainProcessController extends AbstractController { if (detail.get("taxRate") != null && StringUtils.isNoneBlank(detail.get("taxRate").toString())) { taxRateDetail = detail.get("taxRate").toString(); if (!"0".equals(taxRateDetail)) { - if (StringUtils.isNoneBlank(taxRateDetail)) { - int index = taxRateDetail.indexOf("%"); - if (index > 0) { - taxRateDetail = taxRateDetail.substring(0, taxRateDetail.length() - 1); - Float num = Float.parseFloat(taxRateDetail); - if (num > 9) { - taxRateDetail = "0." + taxRateDetail; - } else { - if (!taxRateDetail.startsWith("0")) { - taxRateDetail = "0.0" + taxRateDetail; - } - } - } - } +// if (StringUtils.isNoneBlank(taxRateDetail)) { +// int index = taxRateDetail.indexOf("%"); +// if (index > 0) { +// taxRateDetail = taxRateDetail.substring(0, taxRateDetail.length() - 1); +// Float num = Float.parseFloat(taxRateDetail); +// if (num > 9) { +// taxRateDetail = "0." + taxRateDetail; +// } else { +// if (!taxRateDetail.startsWith("0")) { +// taxRateDetail = "0.0" + taxRateDetail; +// } +// } +// } +// } + + taxRateDetail = CheckUtil.formatPercentSl(taxRateDetail); } if ("11".equals(invoiceType)) { diff --git a/dxhy-erp/src/main/java/com/dxhy/erp/utils/CheckUtil.java b/dxhy-erp/src/main/java/com/dxhy/erp/utils/CheckUtil.java index 96809de0..ca4a0103 100644 --- a/dxhy-erp/src/main/java/com/dxhy/erp/utils/CheckUtil.java +++ b/dxhy-erp/src/main/java/com/dxhy/erp/utils/CheckUtil.java @@ -1,5 +1,6 @@ package com.dxhy.erp.utils; +import com.alibaba.cloud.commons.lang.StringUtils; import com.alibaba.fastjson.JSONObject; import com.dxhy.erp.entity.CheckInvoiceParam; import com.dxhy.erp.entity.FP; @@ -8,6 +9,8 @@ import cn.hutool.core.codec.Base64; import cn.hutool.http.HttpUtil; import lombok.extern.slf4j.Slf4j; +import java.text.NumberFormat; + /** * @author dxhy */ @@ -16,6 +19,8 @@ public class CheckUtil { private static final String URL = "https://cypt.ele-cloud.com/recipt/checkFp/barcode"; + public static final NumberFormat NF = NumberFormat.getPercentInstance(); + public static FP getCheck(CheckInvoiceParam checkInvoiceParam) throws Exception { String hmacsha1 = CheckHmacsha1Util.getHmacsha1(checkInvoiceParam); String json = HttpUtil.post(URL, hmacsha1, 30000); @@ -28,4 +33,12 @@ public class CheckUtil { } return null; } + + public static String formatPercentSl(String sl) { + if (StringUtils.isNotEmpty(sl)) { + NF.setMaximumFractionDigits(3); + sl = NF.format(Double.valueOf(sl)); + } + return sl; + } }