|
@@ -7,7 +7,6 @@ import com.sky.ioc.entity.Cake;
|
|
|
import com.sky.ioc.entity.Indeicator;
|
|
|
import com.sky.ioc.entity.Label;
|
|
|
import com.sky.ioc.entity.News;
|
|
|
-import com.sky.ioc.entity.domain.carbon.Carbon;
|
|
|
import com.sky.ioc.entity.domain.carbon.CarbonNotice;
|
|
|
import com.sky.ioc.entity.domain.carbon.CarbonQuota;
|
|
|
import com.sky.ioc.entity.domain.space.Company;
|
|
@@ -66,6 +65,11 @@ public class CarbonServiceImpl implements CarbonService {
|
|
|
final static String CARBON_QUOTA_URL="/api/carbon/CARBON/quota/list";
|
|
|
final static String CARBON_NOTICE_URL="/api/carbon/CARBON/notice/list";
|
|
|
|
|
|
+ //碳排量总计
|
|
|
+ final static String CARBON_MISSION_URL="/api/statistics/carbon/mission/getCarbonMission";
|
|
|
+ //碳排放类型占比
|
|
|
+ final static String CARBON_TYPE_URL="/api/statistics/carbon/missionType/getCarbonMissionType";
|
|
|
+
|
|
|
@Autowired
|
|
|
CarbonQuotaMapper carbonQuotaMapper;
|
|
|
|
|
@@ -839,6 +843,83 @@ public class CarbonServiceImpl implements CarbonService {
|
|
|
//return null;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public ReturnMsg getCarbonInfoData(IocParam iocParam) {
|
|
|
+ String startStr = iocParam.getTimeRange().getStartDate().replace("/","-");
|
|
|
+ String endStr = iocParam.getTimeRange().getEndDate().replace("/","-");
|
|
|
+ String url = restTemplateConfig.addBaseUrl(CARBON_MISSION_URL)+"?startTime="+startStr+"&endTime="+endStr+"&scope=day";
|
|
|
+ RestTemplate restTemplate = restTemplateConfig.build();
|
|
|
+ // 发送GET请求
|
|
|
+ ResponseEntity<Map> responseEntity = restTemplate.getForEntity(url, Map.class);
|
|
|
+ // 获取响应对象里的 body 对象
|
|
|
+ Map<String, Object> body = responseEntity.getBody();
|
|
|
+ // 获取状态码
|
|
|
+ Integer code = (Integer)body.get("code");
|
|
|
+ // 获取响应信息
|
|
|
+ String message = (String)body.get("msg");
|
|
|
+ if(code==200){
|
|
|
+ // ArrayList list = (ArrayList) body.get("data");
|
|
|
+ LinkedHashMap linkedHashMap = (LinkedHashMap) body.get("data");
|
|
|
+ ArrayList dataList = (ArrayList)linkedHashMap.get("dataList");
|
|
|
+
|
|
|
+ List<Label> labels1 = new ArrayList<>();
|
|
|
+ for(int i=0;i<dataList.size();i++){
|
|
|
+ LinkedHashMap json = (LinkedHashMap) dataList.get(i);
|
|
|
+ Label label = new Label();
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
+ ArrayList companies = (ArrayList) json.get("companies");
|
|
|
+ for (int j = 0; j < companies.size(); j++) {
|
|
|
+ LinkedHashMap company = (LinkedHashMap) companies.get(j);
|
|
|
+ jsonObject.put(String.valueOf(company.get("companyName")),company.get("companyEmission"));
|
|
|
+ }
|
|
|
+ label.setJsonObject(jsonObject);
|
|
|
+ label.setLabel(String.valueOf(json.get("date")));
|
|
|
+ labels1.add(label);
|
|
|
+ }
|
|
|
+ return ReturnMsg.ok(labels1);
|
|
|
+
|
|
|
+ }else{
|
|
|
+ log.info("获取碳排放分析数据:"+message);
|
|
|
+ return ReturnMsg.fail(message);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ReturnMsg getCarbonProportionData(IocParam iocParam) {
|
|
|
+ String startStr = iocParam.getTimeRange().getStartDate().replace("/","-");
|
|
|
+ String endStr = iocParam.getTimeRange().getEndDate().replace("/","-");
|
|
|
+ String url = restTemplateConfig.addBaseUrl(CARBON_TYPE_URL)+"?startTime="+startStr+"&endTime="+endStr+"&scope=month";
|
|
|
+ RestTemplate restTemplate = restTemplateConfig.build();
|
|
|
+ // 发送GET请求
|
|
|
+ ResponseEntity<Map> responseEntity = restTemplate.getForEntity(url, Map.class);
|
|
|
+ // 获取响应对象里的 body 对象
|
|
|
+ Map<String, Object> body = responseEntity.getBody();
|
|
|
+ // 获取状态码
|
|
|
+ Integer code = (Integer)body.get("code");
|
|
|
+ // 获取响应信息
|
|
|
+ String message = (String)body.get("msg");
|
|
|
+ if(code==200){
|
|
|
+ List<Cake> list = new ArrayList<>();
|
|
|
+ LinkedHashMap linkedHashMap = (LinkedHashMap) body.get("data");
|
|
|
+ ArrayList dataList = (ArrayList)linkedHashMap.get("dataList");
|
|
|
+ if(dataList!=null&&dataList.size()>0){
|
|
|
+ LinkedHashMap json = (LinkedHashMap) dataList.get(0);
|
|
|
+ ArrayList types = (ArrayList) json.get("reportType");
|
|
|
+ for (int j = 0; j < types.size(); j++) {
|
|
|
+ LinkedHashMap type = (LinkedHashMap) types.get(j);
|
|
|
+ Cake cake = new Cake();
|
|
|
+ cake.setName(String.valueOf(type.get("name")));
|
|
|
+ cake.setValue(Double.parseDouble(String.valueOf(type.get("carbonEmission"))));
|
|
|
+ list.add(cake);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return ReturnMsg.ok(list);
|
|
|
+
|
|
|
+ }else{
|
|
|
+ log.info("获取碳排放类型数据:"+message);
|
|
|
+ return ReturnMsg.fail(message);
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
|
|
|
}
|