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