Commit 4a4fe47f authored by lilongyang's avatar lilongyang

1、新增获取并网容量,获取片区指标完成情况接口

parent b955e5d3
package com.yeejoin.amos.boot.module.jxiop.biz.controller;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.biz.common.controller.BaseController;
import com.yeejoin.amos.boot.module.jxiop.biz.service.impl.EnergyAccessServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import java.util.Map;
@RestController
@Api(tags = "能源接入相关接口")
@RequestMapping(value = "/energyAccess")
public class EnergyAccessController extends BaseController {
@Autowired
EnergyAccessServiceImpl energyAccessServiceImpl;
@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) {
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) {
return energyAccessServiceImpl.getQuotaCompleteInfo(current, pageSize, code,sourceStationId,tp);
}
}
package com.yeejoin.amos.boot.module.jxiop.biz.dto;
import lombok.Data;
@Data
public class InstalledCapacity {
//片区名
String areaName;
//场站名
String stationName;
//场站数量
String stationCount;
//装机容量
String actualInstalledCapacity;
}
package com.yeejoin.amos.boot.module.jxiop.biz.service;
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>> getQuotaCompleteInfo(int current, int pageSize, String code, String sourceStationId, String tp);
}
package com.yeejoin.amos.boot.module.jxiop.biz.service.impl;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.module.jxiop.api.util.Constants;
import com.yeejoin.amos.boot.module.jxiop.api.util.HttpRequestUtil;
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 java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@Service
public class EnergyAccessServiceImpl implements EnergyAccessService {
@Autowired
private HttpRequestUtil httpRequestUtil;
@Override
public Page<Map<String, Object>> getInstalledCapacity(int current, int 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)) {
requestUrl.append("&code=").append(code);
}
if (StringUtils.isNotEmpty(sourceStationId)) {
requestUrl.append("&source_station_id=").append(sourceStationId);
}
if (StringUtils.isNotEmpty(tp)) {
requestUrl.append("&tp=").append(tp);
}
JSONObject data = httpRequestUtil.getResPonse(requestUrl.toString(), Constants.REQUEST_GET, "",
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()));
}
return pegaIPage;
}
@Override
public Page<Map<String, Object>> getQuotaCompleteInfo(int current, int 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();
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
String formattedDate = currentDate.format(formatter);
requestUrl.append("&reporting_data=").append(formattedDate);
if (StringUtils.isNotEmpty(code)) {
requestUrl.append("&code=").append(code);
}
if (StringUtils.isNotEmpty(sourceStationId)) {
requestUrl.append("&source_station_id=").append(sourceStationId);
}
if (StringUtils.isNotEmpty(tp)) {
requestUrl.append("&tp=").append(tp);
}
JSONObject data = httpRequestUtil.getResPonse(requestUrl.toString(), Constants.REQUEST_GET, "",
Constants.resovleRule_data);
List returnList = data.getJSONArray("data");
//rate的值去掉百分号,名称字段名统一用name代替
returnList.forEach(result -> {
String oldName = "";
JSONObject jsonObject = (JSONObject)result;
String rate = jsonObject.getString("rate");
if(StringUtils.isNotEmpty(rate)){
jsonObject.put("rate",rate.replace("%",""));
}
if("1".equals(tp)){
oldName = jsonObject.getString("station_name");
jsonObject.remove("station_name");
}else{
oldName = jsonObject.getString("area_name");
jsonObject.remove("area_name");
}
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;
}
}
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