|
@@ -2094,16 +2094,10 @@ public class CoinServiceImpl implements CoinService {
|
|
|
|
|
|
|
|
String[] trackCategory2Arr = coinWatchlist.getTrackCategory2().split(",");
|
|
String[] trackCategory2Arr = coinWatchlist.getTrackCategory2().split(",");
|
|
|
StringBuffer sb2 = new StringBuffer();
|
|
StringBuffer sb2 = new StringBuffer();
|
|
|
- String trackCategory2Length = "";
|
|
|
|
|
for (int i = 0; i < trackCategory2Arr.length; i++) {
|
|
for (int i = 0; i < trackCategory2Arr.length; i++) {
|
|
|
- if (i == trackCategory2Arr.length - 1) {
|
|
|
|
|
- if (trackCategory2Arr.length > 1 && trackCategory2Length.length() > 20) {
|
|
|
|
|
- sb2.append("<br>");
|
|
|
|
|
- }
|
|
|
|
|
- sb2.append("<span class=\"selected-value\" style=\"" + trackCategory2Map.get(trackCategory2Arr[i]) + " \" >" + trackCategory2Arr[i] + " </span>");
|
|
|
|
|
- } else {
|
|
|
|
|
- trackCategory2Length += trackCategory2Arr[i];
|
|
|
|
|
- sb2.append("<span class=\"selected-value\" style=\"margin-right:0.3em;" + trackCategory2Map.get(trackCategory2Arr[i]) + " \" >" + trackCategory2Arr[i] + " </span>");
|
|
|
|
|
|
|
+ sb2.append("<span class=\"selected-value\" style=\"margin-right:0.3em;" + trackCategory2Map.get(trackCategory2Arr[i]) + " \" >" + trackCategory2Arr[i] + " </span>");
|
|
|
|
|
+ if (i % 2 == 1 && i != trackCategory2Arr.length - 1) {
|
|
|
|
|
+ sb2.append("<br>");
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
coinWatchlist.setTrackCategory2Style(" style=\"padding:0em 0.3em;\"");
|
|
coinWatchlist.setTrackCategory2Style(" style=\"padding:0em 0.3em;\"");
|
|
@@ -2114,16 +2108,21 @@ public class CoinServiceImpl implements CoinService {
|
|
|
// 市场价格
|
|
// 市场价格
|
|
|
coinWatchlist.setMarkPriceStyle(" style=\"color:#252B31;background-color:#C4ADE9;\"");
|
|
coinWatchlist.setMarkPriceStyle(" style=\"color:#252B31;background-color:#C4ADE9;\"");
|
|
|
if (StringUtils.isNotEmpty(coinWatchlist.getMarkPrice())) {
|
|
if (StringUtils.isNotEmpty(coinWatchlist.getMarkPrice())) {
|
|
|
- coinWatchlist.setMarkPrice(new BigDecimal(coinWatchlist.getMarkPrice()).divide(BigDecimal.ONE, new MathContext(3)).toPlainString());
|
|
|
|
|
|
|
+ if (!coinWatchlist.getMarkPrice().matches(regex)) {
|
|
|
|
|
+ //coinWatchlist.setMarkPrice(new BigDecimal(coinWatchlist.getMarkPrice()).divide(BigDecimal.ONE, new MathContext(3)).toPlainString());
|
|
|
|
|
+ coinWatchlist.setMarkPrice(formatNumber(coinWatchlist.getMarkPrice()));
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
if (StringUtils.isNotEmpty(coinWatchlist.getHighestHistoricalPrice())) {
|
|
if (StringUtils.isNotEmpty(coinWatchlist.getHighestHistoricalPrice())) {
|
|
|
if (!coinWatchlist.getHighestHistoricalPrice().matches(regex)) {
|
|
if (!coinWatchlist.getHighestHistoricalPrice().matches(regex)) {
|
|
|
- coinWatchlist.setHighestHistoricalPrice(new BigDecimal(coinWatchlist.getHighestHistoricalPrice()).divide(BigDecimal.ONE, new MathContext(3)).toPlainString());
|
|
|
|
|
|
|
+ //coinWatchlist.setHighestHistoricalPrice(new BigDecimal(coinWatchlist.getHighestHistoricalPrice()).divide(BigDecimal.ONE, new MathContext(3)).toPlainString());
|
|
|
|
|
+ coinWatchlist.setHighestHistoricalPrice(formatNumber(coinWatchlist.getHighestHistoricalPrice()));
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
if (StringUtils.isNotEmpty(coinWatchlist.getLowestHistoricalPrice())) {
|
|
if (StringUtils.isNotEmpty(coinWatchlist.getLowestHistoricalPrice())) {
|
|
|
if (!coinWatchlist.getLowestHistoricalPrice().matches(regex)) {
|
|
if (!coinWatchlist.getLowestHistoricalPrice().matches(regex)) {
|
|
|
- coinWatchlist.setLowestHistoricalPrice(new BigDecimal(coinWatchlist.getLowestHistoricalPrice()).divide(BigDecimal.ONE, new MathContext(3)).toPlainString());
|
|
|
|
|
|
|
+ //coinWatchlist.setLowestHistoricalPrice(new BigDecimal(coinWatchlist.getLowestHistoricalPrice()).divide(BigDecimal.ONE, new MathContext(3)).toPlainString());
|
|
|
|
|
+ coinWatchlist.setLowestHistoricalPrice(formatNumber(coinWatchlist.getLowestHistoricalPrice()));
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
// 24小时价格变化
|
|
// 24小时价格变化
|
|
@@ -2163,6 +2162,33 @@ public class CoinServiceImpl implements CoinService {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ private static String formatNumber(String str) {
|
|
|
|
|
+ double number = Double.parseDouble(str);
|
|
|
|
|
+ int dotIndex = str.indexOf('.');
|
|
|
|
|
+ if (dotIndex == -1) {
|
|
|
|
|
+ return str; // 无小数点,直接返回
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 检查小数点后连续0的数量
|
|
|
|
|
+ int zeroCount = 0;
|
|
|
|
|
+ for (int i = dotIndex + 1; i < str.length(); i++) {
|
|
|
|
|
+ if (str.charAt(i) == '0') {
|
|
|
|
|
+ zeroCount++;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ break; // 遇到非0字符停止计数
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 如果0的数量 >=5,用科学计数法;否则用普通小数
|
|
|
|
|
+ if (zeroCount >= 5) {
|
|
|
|
|
+ DecimalFormat df = new DecimalFormat("0.###E0"); // 科学计数法
|
|
|
|
|
+ return df.format(number).replace("E-0", "E-"); // 修正E-09为E-9
|
|
|
|
|
+ } else {
|
|
|
|
|
+ DecimalFormat df = new DecimalFormat("0.######"); // 普通小数
|
|
|
|
|
+ return df.format(number);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
private void renderMainSearch4TraderList(List<CoinTrader> mixTraderList) {
|
|
private void renderMainSearch4TraderList(List<CoinTrader> mixTraderList) {
|
|
|
for (CoinTrader mixTrader : mixTraderList) {
|
|
for (CoinTrader mixTrader : mixTraderList) {
|
|
|
mixTrader.setLastTradeTime(DateUtils.longToString(Long.valueOf(mixTrader.getLastTradeTime())));
|
|
mixTrader.setLastTradeTime(DateUtils.longToString(Long.valueOf(mixTrader.getLastTradeTime())));
|