|
@@ -0,0 +1,120 @@
|
|
|
+package com.gyee.gaia.electricity.wind.controller;
|
|
|
+
|
|
|
+import cn.hutool.core.date.DateUtil;
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.gyee.gaia.common.data.windturbine.Line;
|
|
|
+import com.gyee.gaia.common.data.windturbine.Project;
|
|
|
+import com.gyee.gaia.electricity.wind.entity.EquipPowerGenDay;
|
|
|
+import com.gyee.gaia.electricity.wind.init.CacheContext;
|
|
|
+import com.gyee.gaia.electricity.wind.iservice.IEquipPowerGenDayService;
|
|
|
+import org.springframework.web.bind.annotation.GetMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestParam;
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
+
|
|
|
+import javax.annotation.Resource;
|
|
|
+import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @author gfhd
|
|
|
+ * @date 2023-05-30
|
|
|
+ */
|
|
|
+@RestController
|
|
|
+@RequestMapping("/powergen")
|
|
|
+public class EquipPowerGenDayController {
|
|
|
+ @Resource
|
|
|
+ private IEquipPowerGenDayService equipPowerGenDayService;
|
|
|
+
|
|
|
+ @GetMapping("/data")
|
|
|
+ private JSONObject getTables(@RequestParam(value = "station", required = false) String station,
|
|
|
+ @RequestParam(value = "projects", required = false) String projects,
|
|
|
+ @RequestParam(value = "lines", required = false) String lines,
|
|
|
+ @RequestParam(value = "startDate", required = false) String startDate,
|
|
|
+ @RequestParam(value = "endDate", required = false) String endDate) {
|
|
|
+ QueryWrapper<EquipPowerGenDay> epgdWrapper = new QueryWrapper<>();
|
|
|
+ epgdWrapper.select("facility_id", "round(sum(generating_capacity)/1000,2) generating_capacity", "round(sum(theory_generation)/1000,2) theory_generation"
|
|
|
+ , "round(sum(loss_power)/1000,2) loss_power", "round(sum(fault_loss_power)/1000,2) fault_loss_power"
|
|
|
+ , "round(sum(maintain_loss_power)/1000,2) maintain_loss_power", "round(sum(implicate_loss_power)/1000,2) implicate_loss_power"
|
|
|
+ , "round(sum(limit_loss_power)/1000,2) limit_loss_power", "round(sum(performance_loss_power)/1000,2) performance_loss_power"
|
|
|
+ , "round(avg(mean_wind_speed),2) mean_wind_speed");
|
|
|
+ if (StrUtil.isNotBlank(lines)) {
|
|
|
+ epgdWrapper.eq("category", "line").in("facility_id", lines.split(","));
|
|
|
+ } else if (StrUtil.isNotBlank(projects)) {
|
|
|
+ epgdWrapper.eq("category", "project").in("facility_id", projects.split(","));
|
|
|
+ } else if (StrUtil.isNotBlank(station)) {
|
|
|
+ epgdWrapper.eq("category", "windturbine").eq("station", station);
|
|
|
+ } else {
|
|
|
+ epgdWrapper.eq("category", "station");
|
|
|
+ }
|
|
|
+ epgdWrapper.between("date", DateUtil.parse(startDate).toLocalDateTime().toLocalDate(), DateUtil.parse(endDate).toLocalDateTime().toLocalDate())
|
|
|
+ .groupBy("facility_id");
|
|
|
+
|
|
|
+ List<EquipPowerGenDay> list = equipPowerGenDayService.list(epgdWrapper);
|
|
|
+ list = list.stream().peek(d -> d.setUniformCode(CacheContext.splssMap.get(d.getFacilityId()))).collect(Collectors.toList());
|
|
|
+
|
|
|
+ JSONObject json = new JSONObject();
|
|
|
+ json.put("code", 200);
|
|
|
+ json.put("msg", "成功!");
|
|
|
+ json.put("data", list);
|
|
|
+
|
|
|
+ return json;
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/stationList")
|
|
|
+ private JSONObject stationList() {
|
|
|
+
|
|
|
+ JSONObject json = new JSONObject();
|
|
|
+ json.put("code", 200);
|
|
|
+ json.put("msg", "成功!");
|
|
|
+ json.put("data", CacheContext.stationList.stream().filter(s->s.getId().contains("_FDC_")).collect(Collectors.toList()));
|
|
|
+
|
|
|
+ return json;
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/projectList")
|
|
|
+ private JSONObject projectList(@RequestParam(value = "stationId", required = false) String stationId) {
|
|
|
+
|
|
|
+ JSONObject json = new JSONObject();
|
|
|
+ json.put("code", 200);
|
|
|
+ json.put("msg", "成功!");
|
|
|
+
|
|
|
+ if (StrUtil.isBlank(stationId)) {
|
|
|
+ json.put("data", new HashMap<String, String>());
|
|
|
+ } else {
|
|
|
+ List<Project> projects = CacheContext.stationProjectsMap.get(stationId);
|
|
|
+ json.put("data", projects);
|
|
|
+ }
|
|
|
+
|
|
|
+ return json;
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/lineList")
|
|
|
+ private JSONObject lineList(@RequestParam(value = "projects", required = false) String projects) {
|
|
|
+
|
|
|
+ JSONObject json = new JSONObject();
|
|
|
+ json.put("code", 200);
|
|
|
+ json.put("msg", "成功!");
|
|
|
+
|
|
|
+ if (StrUtil.isBlank(projects)) {
|
|
|
+ json.put("data", new HashMap<String, String>());
|
|
|
+ } else {
|
|
|
+ String[] split = projects.split(",");
|
|
|
+ List<Line> list = new ArrayList<>();
|
|
|
+ for (String s : split) {
|
|
|
+ list.addAll(CacheContext.projectLinesMap.get(s));
|
|
|
+ }json.put("data", list);
|
|
|
+ }
|
|
|
+
|
|
|
+ return json;
|
|
|
+ }
|
|
|
+
|
|
|
+ private boolean hasStr(String[] split, String key) {
|
|
|
+ for (String s : split) {
|
|
|
+ if (Objects.equals(s, key)) return true;
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+}
|