Commit 17cfda8c authored by lilongyang's avatar lilongyang

1、获取并网容量,获取片区指标完成情况接口所有数字全部处理为保留小数后四位

parent 1db5e561
......@@ -48,7 +48,14 @@ public class EnergyAccessServiceImpl implements EnergyAccessService {
List returnList = data.getJSONArray("data");
logger.info("获取并网容量接口调用对端返回结果:{}",returnList.toString());
Page<Map<String, Object>> pageIPage;
returnList.forEach(result -> {
JSONObject jsonObject = (JSONObject) result;
String actualInstalledCapacity = jsonObject.getString("actual_installed_capacity");
if (StringUtils.isNotEmpty(actualInstalledCapacity)) {
BigDecimal bd = new BigDecimal(actualInstalledCapacity);
jsonObject.put("actual_installed_capacity", bd.setScale(4,BigDecimal.ROUND_HALF_UP));
}
});
int newCurrent = Integer.parseInt(current);
int newPageSize = Integer.parseInt(pageSize);
if (StringUtils.isBlank(pageSize) || StringUtils.isBlank(pageSize)) {
......@@ -114,13 +121,24 @@ public class EnergyAccessServiceImpl implements EnergyAccessService {
String rate = jsonObject.getString("rate");
String newRate = "";
if (StringUtils.isNotEmpty(rate)) {
rate = rate.replace("%", "");
BigDecimal bd = new BigDecimal(rate);
jsonObject.put("rate", bd.setScale(4,BigDecimal.ROUND_HALF_UP));
newRate = rate.replace("%", "");
jsonObject.put("rate", newRate);
BigDecimal bd = new BigDecimal(newRate);
jsonObject.put("rate", bd.setScale(4,BigDecimal.ROUND_HALF_UP));
}
String quota = jsonObject.getString("quota");
if (StringUtils.isNotEmpty(quota)) {
BigDecimal bd = new BigDecimal(quota);
jsonObject.put("quota", bd.setScale(4,BigDecimal.ROUND_HALF_UP));
}
jsonObject.put("seriesData", StringUtils.isNotEmpty(newRate) ? Arrays.asList(Double.parseDouble(newRate)) : 0D);
String generatingCapacity = jsonObject.getString("generating_capacity");
if (StringUtils.isNotEmpty(generatingCapacity)) {
BigDecimal bd = new BigDecimal(generatingCapacity);
jsonObject.put("generating_capacity", bd.setScale(4,BigDecimal.ROUND_HALF_UP));
}
jsonObject.put("seriesData", StringUtils.isNotEmpty(newRate) ? Arrays.asList(new BigDecimal(newRate).setScale(4,BigDecimal.ROUND_HALF_UP)) : 0D);
jsonObject.put("axisData", Arrays.asList("RATE"));
if ("1".equals(tp)) {
oldName = jsonObject.getString("station_name");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment