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 {
@RequestMapping(value = "/getInstalledCapacity", method = RequestMethod.GET)
@TycloudOperation(ApiLevel = UserType.AGENCY)
@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);
}
@RequestMapping(value = "/getQuotaCompleteInfo", method = RequestMethod.GET)
@TycloudOperation(ApiLevel = UserType.AGENCY)
@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);
}
}
......
......@@ -5,7 +5,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import java.util.Map;
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;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
......@@ -23,7 +24,7 @@ public class EnergyAccessServiceImpl implements EnergyAccessService {
private HttpRequestUtil httpRequestUtil;
@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);
if (StringUtils.isNotEmpty(code)) {
......@@ -41,21 +42,32 @@ public class EnergyAccessServiceImpl implements EnergyAccessService {
Constants.resovleRule_data);
List returnList = data.getJSONArray("data");
Page<Map<String, Object>> pegaIPage = new Page<Map<String, Object>>();
pegaIPage.setCurrent(current);
pegaIPage.setSize(pageSize);
pegaIPage.setTotal(returnList.size());
int endIndex = current * pageSize;
if(returnList.size() > endIndex){
pegaIPage.setRecords(returnList.subList(((current - 1) * pageSize), endIndex));
}else{
pegaIPage.setRecords(returnList.subList(((current - 1) * pageSize), returnList.size()));
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;
}
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
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);
LocalDate currentDate = LocalDate.now();
......@@ -78,33 +90,41 @@ public class EnergyAccessServiceImpl implements EnergyAccessService {
List returnList = data.getJSONArray("data");
//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 -> {
String oldName = "";
JSONObject jsonObject = (JSONObject)result;
JSONObject jsonObject = (JSONObject) result;
String rate = jsonObject.getString("rate");
if(StringUtils.isNotEmpty(rate)){
jsonObject.put("rate",rate.replace("%",""));
if (StringUtils.isNotEmpty(rate)) {
jsonObject.put("rate", rate.replace("%", ""));
}
if("1".equals(tp)){
if ("1".equals(tp)) {
oldName = jsonObject.getString("station_name");
jsonObject.remove("station_name");
}else{
} else {
oldName = jsonObject.getString("area_name");
jsonObject.remove("area_name");
}
jsonObject.put("name",oldName);
jsonObject.put("name", oldName);
});
Page<Map<String, Object>> pegaIPage = new Page<Map<String, Object>>();
pegaIPage.setCurrent(current);
pegaIPage.setSize(pageSize);
pegaIPage.setTotal(returnList.size());
int endIndex = current * pageSize;
if(returnList.size() > endIndex){
pegaIPage.setRecords(returnList.subList(((current - 1) * pageSize), endIndex));
}else{
pegaIPage.setRecords(returnList.subList(((current - 1) * pageSize), returnList.size()));
}
return pegaIPage;
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 pageIPage;
}
}
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