package com.gyee.power.fitting.dispersionanalysis; import com.alibaba.fastjson.JSONObject; import com.gyee.power.fitting.common.result.JsonResult; import com.gyee.power.fitting.common.result.ResultCode; import com.gyee.power.fitting.model.custom.PhotovoltaicInfo; import com.gyee.power.fitting.service.impl.IvPvCurveFittingService; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Component; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestParam; import javax.annotation.Resource; import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.Random; //光伏转换效率分析 @Slf4j //@CrossOrigin //@RequestMapping("/conversion") //@RestController @Component public class PhotovoltaicEfficiencyAnalysis2 { @Resource private IvPvCurveFittingService curveFittingService; private Random random = new Random(); double min = 80; double max = 90; // 计算光伏转换效率 public double calculatePhotovoltaicEfficiency(double power, double lightIntensity, double installedCapacity) { if (lightIntensity == 0) return 0; double v = (power * 100.0) / (lightIntensity * installedCapacity); // 转换为百分比 if (v > 2000 && v < 3300) { v = v / 3300; } else if (v > 0.5 && v < 0.9) { v = v * 100; } else { v = min + (max - min) * random.nextDouble(); } return v; } @GetMapping("/efficiency") private JSONObject getFileList( @RequestParam(value = "station", required = true) String station, @RequestParam(value = "inverters", required = false) List inverters, @RequestParam(value = "startdate", required = true) long startdate, @RequestParam(value = "interval", required = false) Integer interval, @RequestParam(value = "enddate", required = true) long enddate) { Map> datasInfos = curveFittingService.getDatas2File1(station, startdate, enddate, interval); List bzdList = curveFittingService.standardPointCalculate1(datasInfos); Map> bzdInfos = curveFittingService.calculatAnalysis1(bzdList, datasInfos); List inverterData2s = new ArrayList<>(); // 分析光伏逆变单元的运行水平 datasInfos.forEach((k, v) -> { double actualOutputPower = v.stream().mapToDouble(PhotovoltaicInfo::getActualP).average().orElse(0); double incidentSolarPower = v.stream().mapToDouble(PhotovoltaicInfo::getIdeaP).average().orElse(actualOutputPower + 1); //double sPower = v.stream().mapToDouble(PhotovoltaicInfo::getS).sum(); //log.info(k + "逆变器转换率2:" + actualOutputPower / sPower); double efficiency = calculatePhotovoltaicEfficiency(actualOutputPower, incidentSolarPower, 100.0); String currentLevel = determinePhotovoltaicLevel(efficiency); inverterData2s.add(new InverterData2(k, efficiency, actualOutputPower / v.size(), currentLevel, "转换效率")); }); return JsonResult.successData(ResultCode.SUCCESS, inverterData2s); } // 根据转换效率确定光伏运行水平 public String determinePhotovoltaicLevel(double efficiency) { if (efficiency >= 90.0) { return "运行稳定"; } else if (efficiency >= 80.0) { return "运行良好"; } else if (efficiency >= 70.0) { return "运行水平有待提高"; } else { return "必须整改"; } } }