fix: 修复大数字显示
This commit is contained in:
@@ -9,6 +9,7 @@ import com.lanyuanxiaoyao.service.template.controller.SimpleControllerSupport;
|
|||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
@@ -18,6 +19,7 @@ import org.springframework.web.bind.annotation.RestController;
|
|||||||
* @author lanyuanxiaoyao
|
* @author lanyuanxiaoyao
|
||||||
* @version 20250829
|
* @version 20250829
|
||||||
*/
|
*/
|
||||||
|
@Slf4j
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("stock")
|
@RequestMapping("stock")
|
||||||
public class StockController extends SimpleControllerSupport<Stock, Void, StockController.DetailItem, StockController.DetailItem> {
|
public class StockController extends SimpleControllerSupport<Stock, Void, StockController.DetailItem, StockController.DetailItem> {
|
||||||
|
|||||||
@@ -16,19 +16,16 @@ public class NumberHelper {
|
|||||||
if (ObjectUtil.isNull(value)) {
|
if (ObjectUtil.isNull(value)) {
|
||||||
return FINANCE_NULL_DOUBLE;
|
return FINANCE_NULL_DOUBLE;
|
||||||
}
|
}
|
||||||
var builder = new StringBuilder();
|
var result = FINANCE_NULL_DOUBLE;
|
||||||
if (value > 100000000) {
|
var absValue = Double.valueOf(Math.abs(value));
|
||||||
builder.append(value.longValue() / 100000000).append("亿");
|
if (absValue > 100000000) {
|
||||||
value = value % 100000000;
|
result = NumberUtil.decimalFormat("#.##亿", absValue / 100000000);
|
||||||
|
} else if (value > 10000) {
|
||||||
|
result = NumberUtil.decimalFormat("#.##万", absValue / 10000);
|
||||||
|
} else {
|
||||||
|
result = NumberUtil.decimalFormat("#.##", absValue);
|
||||||
}
|
}
|
||||||
if (value > 10000) {
|
return value < 0 ? "-" + result : result;
|
||||||
builder.append(value.longValue() / 10000).append("万");
|
|
||||||
value = value % 10000;
|
|
||||||
}
|
|
||||||
if (value > 0) {
|
|
||||||
builder.append(NumberUtil.decimalFormat("#.##", value));
|
|
||||||
}
|
|
||||||
return builder.toString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String formatPercentageDouble(Double value) {
|
public static String formatPercentageDouble(Double value) {
|
||||||
|
|||||||
Reference in New Issue
Block a user