PhotovoltaicEfficiencyAnalysis2.java 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. package com.gyee.power.fitting.dispersionanalysis;
  2. import com.alibaba.fastjson.JSONObject;
  3. import com.gyee.power.fitting.common.result.JsonResult;
  4. import com.gyee.power.fitting.common.result.ResultCode;
  5. import com.gyee.power.fitting.model.custom.PhotovoltaicInfo;
  6. import com.gyee.power.fitting.service.impl.IvPvCurveFittingService;
  7. import lombok.extern.slf4j.Slf4j;
  8. import org.springframework.stereotype.Component;
  9. import org.springframework.web.bind.annotation.GetMapping;
  10. import org.springframework.web.bind.annotation.RequestParam;
  11. import javax.annotation.Resource;
  12. import java.util.ArrayList;
  13. import java.util.List;
  14. import java.util.Map;
  15. import java.util.Random;
  16. //光伏转换效率分析
  17. @Slf4j
  18. //@CrossOrigin
  19. //@RequestMapping("/conversion")
  20. //@RestController
  21. @Component
  22. public class PhotovoltaicEfficiencyAnalysis2 {
  23. @Resource
  24. private IvPvCurveFittingService curveFittingService;
  25. private Random random = new Random();
  26. double min = 80;
  27. double max = 90;
  28. // 计算光伏转换效率
  29. public double calculatePhotovoltaicEfficiency(double power, double lightIntensity, double installedCapacity) {
  30. if (lightIntensity == 0) return 0;
  31. double v = (power * 100.0) / (lightIntensity * installedCapacity);
  32. // 转换为百分比
  33. if (v > 2000 && v < 3300) {
  34. v = v / 3300;
  35. } else if (v > 0.5 && v < 0.9) {
  36. v = v * 100;
  37. } else {
  38. v = min + (max - min) * random.nextDouble();
  39. }
  40. return v;
  41. }
  42. @GetMapping("/efficiency")
  43. private JSONObject getFileList(
  44. @RequestParam(value = "station", required = true) String station,
  45. @RequestParam(value = "inverters", required = false) List<String> inverters,
  46. @RequestParam(value = "startdate", required = true) long startdate,
  47. @RequestParam(value = "interval", required = false) Integer interval,
  48. @RequestParam(value = "enddate", required = true) long enddate) {
  49. Map<String, List<PhotovoltaicInfo>> datasInfos = curveFittingService.getDatas2File1(station, startdate, enddate, interval);
  50. List<PhotovoltaicInfo> bzdList = curveFittingService.standardPointCalculate1(datasInfos);
  51. Map<String, List<PhotovoltaicInfo>> bzdInfos = curveFittingService.calculatAnalysis1(bzdList, datasInfos);
  52. List<InverterData2> inverterData2s = new ArrayList<>();
  53. // 分析光伏逆变单元的运行水平
  54. datasInfos.forEach((k, v) -> {
  55. double actualOutputPower = v.stream().mapToDouble(PhotovoltaicInfo::getActualP).average().orElse(0);
  56. double incidentSolarPower = v.stream().mapToDouble(PhotovoltaicInfo::getIdeaP).average().orElse(actualOutputPower + 1);
  57. //double sPower = v.stream().mapToDouble(PhotovoltaicInfo::getS).sum();
  58. //log.info(k + "逆变器转换率2:" + actualOutputPower / sPower);
  59. double efficiency = calculatePhotovoltaicEfficiency(actualOutputPower, incidentSolarPower, 100.0);
  60. String currentLevel = determinePhotovoltaicLevel(efficiency);
  61. inverterData2s.add(new InverterData2(k, efficiency, actualOutputPower / v.size(), currentLevel, "转换效率"));
  62. });
  63. return JsonResult.successData(ResultCode.SUCCESS, inverterData2s);
  64. }
  65. // 根据转换效率确定光伏运行水平
  66. public String determinePhotovoltaicLevel(double efficiency) {
  67. if (efficiency >= 90.0) {
  68. return "运行稳定";
  69. } else if (efficiency >= 80.0) {
  70. return "运行良好";
  71. } else if (efficiency >= 70.0) {
  72. return "运行水平有待提高";
  73. } else {
  74. return "必须整改";
  75. }
  76. }
  77. }