From cc81283a0f5cba5e0e52964e7891d72cb6657025 Mon Sep 17 00:00:00 2001 From: yangcan Date: Wed, 19 Jul 2023 14:11:22 +0800 Subject: [PATCH] =?UTF-8?q?=E8=8E=B7=E5=8F=96=E4=BA=A7=E5=93=81=E9=95=BF?= =?UTF-8?q?=E5=AE=BD=E9=AB=98=E4=B8=AD=E6=9C=80=E5=B0=8F=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Java/GetMinValueCode.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 Java/GetMinValueCode.java diff --git a/Java/GetMinValueCode.java b/Java/GetMinValueCode.java new file mode 100644 index 0000000..bd7048c --- /dev/null +++ b/Java/GetMinValueCode.java @@ -0,0 +1,17 @@ +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +/** + * 获取产品长宽高中最小值 + */ +public class GetMinValueCode { + public BigDecimal getProductMinSize(TbProduct product){ + BigDecimal productLength = new BigDecimal(StringUtils.isEmpty(product.getProductLength()) ? "0":product.getProductLength()); + BigDecimal productWidth = new BigDecimal(StringUtils.isEmpty(product.getProductWidth()) ? "0":product.getProductWidth()); + BigDecimal productHeight = new BigDecimal(StringUtils.isEmpty(product.getProductHeight()) ? "0":product.getProductHeight()); + BigDecimal productMaxSize = productLength.compareTo(productWidth) == -1 ? productLength:productWidth; + return productMaxSize.compareTo(productHeight) == -1 ? productMaxSize:productHeight; + } +} -- Gitee