Commit 923a4c29 authored by chenzhao's avatar chenzhao

Merge remote-tracking branch 'origin/developer' into developer

parents 80c472c7 464fb1ff
...@@ -23,14 +23,14 @@ public class EnergyAccessController extends BaseController { ...@@ -23,14 +23,14 @@ public class EnergyAccessController extends BaseController {
@RequestMapping(value = "/getInstalledCapacity", method = RequestMethod.GET) @RequestMapping(value = "/getInstalledCapacity", method = RequestMethod.GET)
@TycloudOperation(ApiLevel = UserType.AGENCY) @TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET", value = "获取并网容量", notes = "获取并网容量") @ApiOperation(httpMethod = "GET", value = "获取并网容量", notes = "获取并网容量")
public Page<Map<String, Object>> getInstalledCapacity(int current, int pageSize, String code,String sourceStationId,String tp) { public Page<Map<String, Object>> getInstalledCapacity(String current, String pageSize, String code,String sourceStationId,String tp) {
return energyAccessServiceImpl.getInstalledCapacity(current, pageSize, code,sourceStationId,tp); return energyAccessServiceImpl.getInstalledCapacity(current, pageSize, code,sourceStationId,tp);
} }
@RequestMapping(value = "/getQuotaCompleteInfo", method = RequestMethod.GET) @RequestMapping(value = "/getQuotaCompleteInfo", method = RequestMethod.GET)
@TycloudOperation(ApiLevel = UserType.AGENCY) @TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET", value = "获取片区指标完成情况", notes = "获取片区指标完成情况") @ApiOperation(httpMethod = "GET", value = "获取片区指标完成情况", notes = "获取片区指标完成情况")
public Page<Map<String, Object>> getQuotaCompleteInfo(int current, int pageSize, String code,String sourceStationId,String tp) { public Page<Map<String, Object>> getQuotaCompleteInfo(String current, String pageSize, String code,String sourceStationId,String tp) {
return energyAccessServiceImpl.getQuotaCompleteInfo(current, pageSize, code,sourceStationId,tp); return energyAccessServiceImpl.getQuotaCompleteInfo(current, pageSize, code,sourceStationId,tp);
} }
} }
......
...@@ -5,7 +5,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; ...@@ -5,7 +5,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import java.util.Map; import java.util.Map;
public interface EnergyAccessService { public interface EnergyAccessService {
Page<Map<String, Object>> getInstalledCapacity(int current, int pageSize, String code, String sourceStationId, String tp); Page<Map<String, Object>> getInstalledCapacity(String current, String pageSize, String code, String sourceStationId, String tp);
Page<Map<String, Object>> getQuotaCompleteInfo(int current, int pageSize, String code, String sourceStationId, String tp); Page<Map<String, Object>> getQuotaCompleteInfo(String current, String pageSize, String code, String sourceStationId, String tp);
} }
...@@ -9,6 +9,7 @@ import com.yeejoin.amos.boot.module.jxiop.biz.service.EnergyAccessService; ...@@ -9,6 +9,7 @@ import com.yeejoin.amos.boot.module.jxiop.biz.service.EnergyAccessService;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
...@@ -23,7 +24,7 @@ public class EnergyAccessServiceImpl implements EnergyAccessService { ...@@ -23,7 +24,7 @@ public class EnergyAccessServiceImpl implements EnergyAccessService {
private HttpRequestUtil httpRequestUtil; private HttpRequestUtil httpRequestUtil;
@Override @Override
public Page<Map<String, Object>> getInstalledCapacity(int current, int pageSize, String code, String sourceStationId, String tp) { public Page<Map<String, Object>> getInstalledCapacity(String current, String pageSize, String code, String sourceStationId, String tp) {
//改为部盾接口 //改为部盾接口
StringBuilder requestUrl = new StringBuilder(Constants.BASE_URL).append("?").append(Constants.get_station_actual_installed_capacity); StringBuilder requestUrl = new StringBuilder(Constants.BASE_URL).append("?").append(Constants.get_station_actual_installed_capacity);
if (StringUtils.isNotEmpty(code)) { if (StringUtils.isNotEmpty(code)) {
...@@ -41,21 +42,32 @@ public class EnergyAccessServiceImpl implements EnergyAccessService { ...@@ -41,21 +42,32 @@ public class EnergyAccessServiceImpl implements EnergyAccessService {
Constants.resovleRule_data); Constants.resovleRule_data);
List returnList = data.getJSONArray("data"); List returnList = data.getJSONArray("data");
Page<Map<String, Object>> pegaIPage = new Page<Map<String, Object>>(); Page<Map<String, Object>> pageIPage;
pegaIPage.setCurrent(current);
pegaIPage.setSize(pageSize); int newCurrent = Integer.parseInt(current);
pegaIPage.setTotal(returnList.size()); int newPageSize = Integer.parseInt(pageSize);
int endIndex = current * pageSize; if (StringUtils.isBlank(pageSize) || StringUtils.isBlank(pageSize)) {
if(returnList.size() > endIndex){ pageIPage = new Page<>(0, Long.MAX_VALUE);
pegaIPage.setRecords(returnList.subList(((current - 1) * pageSize), endIndex)); } else {
}else{ pageIPage = new Page<>(newCurrent, newPageSize);
pegaIPage.setRecords(returnList.subList(((current - 1) * pageSize), returnList.size())); }
if (CollectionUtils.isEmpty(returnList)) {
return pageIPage;
}
pageIPage.setTotal(returnList.size());
int endIndex = newCurrent * newPageSize;
if (returnList.size() > endIndex) {
pageIPage.setRecords(returnList.subList(((newCurrent - 1) * newPageSize), endIndex));
} else {
pageIPage.setRecords(returnList.subList(((newCurrent - 1) * newPageSize), returnList.size()));
} }
return pegaIPage; return pageIPage;
} }
@Override @Override
public Page<Map<String, Object>> getQuotaCompleteInfo(int current, int pageSize, String code, String sourceStationId, String tp) { public Page<Map<String, Object>> getQuotaCompleteInfo(String current, String pageSize, String code, String sourceStationId, String tp) {
//改为部盾接口 //改为部盾接口
StringBuilder requestUrl = new StringBuilder(Constants.BASE_URL).append("?").append(Constants.get_quota_complate_info); StringBuilder requestUrl = new StringBuilder(Constants.BASE_URL).append("?").append(Constants.get_quota_complate_info);
LocalDate currentDate = LocalDate.now(); LocalDate currentDate = LocalDate.now();
...@@ -78,33 +90,41 @@ public class EnergyAccessServiceImpl implements EnergyAccessService { ...@@ -78,33 +90,41 @@ public class EnergyAccessServiceImpl implements EnergyAccessService {
List returnList = data.getJSONArray("data"); List returnList = data.getJSONArray("data");
//rate的值去掉百分号,名称字段名统一用name代替 //rate的值去掉百分号,名称字段名统一用name代替
Page<Map<String, Object>> pageIPage;
int newCurrent = Integer.parseInt(current);
int newPageSize = Integer.parseInt(pageSize);
if (StringUtils.isBlank(pageSize) || StringUtils.isBlank(pageSize)) {
pageIPage = new Page<>(0, Long.MAX_VALUE);
} else {
pageIPage = new Page<>(newCurrent, newPageSize);
}
if (CollectionUtils.isEmpty(returnList)) {
return pageIPage;
}
returnList.forEach(result -> { returnList.forEach(result -> {
String oldName = ""; String oldName = "";
JSONObject jsonObject = (JSONObject)result; JSONObject jsonObject = (JSONObject) result;
String rate = jsonObject.getString("rate"); String rate = jsonObject.getString("rate");
if(StringUtils.isNotEmpty(rate)){ if (StringUtils.isNotEmpty(rate)) {
jsonObject.put("rate",rate.replace("%","")); jsonObject.put("rate", rate.replace("%", ""));
} }
if("1".equals(tp)){ if ("1".equals(tp)) {
oldName = jsonObject.getString("station_name"); oldName = jsonObject.getString("station_name");
jsonObject.remove("station_name"); jsonObject.remove("station_name");
}else{ } else {
oldName = jsonObject.getString("area_name"); oldName = jsonObject.getString("area_name");
jsonObject.remove("area_name"); jsonObject.remove("area_name");
} }
jsonObject.put("name",oldName); jsonObject.put("name", oldName);
}); });
Page<Map<String, Object>> pegaIPage = new Page<Map<String, Object>>(); pageIPage.setTotal(returnList.size());
pegaIPage.setCurrent(current); int endIndex = newCurrent * newPageSize;
pegaIPage.setSize(pageSize); if (returnList.size() > endIndex) {
pegaIPage.setTotal(returnList.size()); pageIPage.setRecords(returnList.subList(((newCurrent - 1) * newPageSize), endIndex));
int endIndex = current * pageSize; } else {
if(returnList.size() > endIndex){ pageIPage.setRecords(returnList.subList(((newCurrent - 1) * newPageSize), returnList.size()));
pegaIPage.setRecords(returnList.subList(((current - 1) * pageSize), endIndex)); }
}else{ return pageIPage;
pegaIPage.setRecords(returnList.subList(((current - 1) * pageSize), returnList.size()));
}
return pegaIPage;
} }
} }
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