1.2支路电流分析：

@RestController
@RequestMapping(“/current-analysis”)
public class CurrentAnalysisController {

    @Autowired
    private CurrentDataService currentDataService;

    @GetMapping(“/{inverterId}”)
    public CurrentAnalysisResult analyzeCurrent(@PathVariable Long inverterId,
                                                @RequestParam String dataType,
                                                @RequestParam String timeRange) {
        // 设定分析参数
        // 获取选定时间范围内的支路电流数据
        List<Double> currentData = currentDataService.getCurrentData(inverterId, dataType, timeRange);

        // 统计支路电流为零的次数，并计算零系数
        double zeroCount = currentData.stream().filter(current -> current == 0).count();
        double zeroFactor = zeroCount / currentData.size();

        // 计算支路电流的平均值，并判断每个支路电流是否低于平均值
        double averageCurrent = currentData.stream().mapToDouble(Double::doubleValue).average().orElse(0.0);
        long belowAverageCount = currentData.stream().filter(current -> current < averageCurrent).count();
        double lowFactor = belowAverageCount / currentData.size();

        return new CurrentAnalysisResult(zeroFactor, lowFactor);
    }
}

@Service
public class CurrentDataServiceImpl implements CurrentDataService {

    @Autowired
    private CurrentDataRepository currentDataRepository;

    @Override
    public List<Double> getCurrentData(Long inverterId, String dataType, String timeRange) {
        // 根据逆变器ID、数据类型和时间范围从数据库中查询支路电流数据
        // 使用Navicat等数据库客户端进行查询和提取数据

        return currentDataRepository.findCurrentData(inverterId, dataType, timeRange);
    }
}

@Repository
public class CurrentDataRepository {

    @Autowired
    private JdbcTemplate jdbcTemplate;

    public List<Double> findCurrentData(Long inverterId, String dataType, String timeRange) {
        // 使用JdbcTemplate执行SQL查询，并返回支路电流数据

        // 例子：
        String sql = “SELECT current_value FROM current_data WHERE inverter_id = ? AND data_type = ? AND time_range = ?”;
                // 执行查询，将结果映射为List<Double>
        List<Double> currentData = jdbcTemplate.queryForList(sql, Double.class, inverterId, dataType, timeRange);
        return currentData;
    }
}

public class CurrentAnalysisResult {
    private double zeroFactor;
    private double lowFactor;

    // 构造函数、getter、setter等省略
}


1.2.1逆变器支路电流对比：

@RestController
@RequestMapping(“/current-comparison”)
public class CurrentComparisonController {

    @Autowired
    private CurrentDataService currentDataService;

    @GetMapping(“/{inverterId}”)
    public List<Double> compareCurrent(@PathVariable Long inverterId) {
        // 获取逆变器支路电流数据
        List<Double> currentData = currentDataService.getCurrentData(inverterId, “daily”, “2021-09-01”);

        // 支路电流对比逻辑
        List<Double> comparisonResults = new ArrayList<>();
        double maxCurrent = currentData.stream().max(Double::compareTo).orElse(0.0);
        for (Double current : currentData) {
            double comparisonRatio = current / maxCurrent;
            comparisonResults.add(comparisonRatio);
        }

        return comparisonResults;
    }
}


1.2.2发电单元运行水平：

@RestController
@RequestMapping(“/power-generation”)
public class PowerGenerationController {

    @Autowired
    private PowerGenerationService powerGenerationService;

    @GetMapping(“/{inverterId}”)
    public String analyzeGeneration(@PathVariable Long inverterId) {
        // 计算逆变器发电量
        double generation = powerGenerationService.calculateGeneration(inverterId, “09:00”, “15:00”);

        // 计算逆变器等价发电小时平均值
        double averageEquivalentHours = powerGenerationService.calculateAverageEquivalentHours();

        // 根据逆变器运行水平返回结果
        if (generation > averageEquivalentHours) {
            return “正常”;
        } else if (generation > averageEquivalentHours * 0.85) {
            return “稍差”;
        } else if (generation > averageEquivalentHours * 0.75) {
            return “较差”;
        } else {
            return “极差”;
        }
    }
}

@Service
public class PowerGenerationServiceImpl implements PowerGenerationService {

    @Autowired
    private PowerGenerationRepository powerGenerationRepository;

    @Override
    public double calculateGeneration(Long inverterId, String startTime, String endTime) {
        // 根据逆变器ID、起始时间和结束时间计算逆变器发电量

        return powerGenerationRepository.calculateGeneration(inverterId, startTime, endTime);
    }

    @Override
    public double calculateAverageEquivalentHours() {
        // 计算逆变器等价发电小时平均值

        return powerGenerationRepository.calculateAverageEquivalentHours();
    }
}

@Repository
public class PowerGenerationRepository {

    @Autowired
    private JdbcTemplate jdbcTemplate;

    public double calculateGeneration(Long inverterId, String startTime, String endTime) {
        // 根据逆变器ID、起始时间和结束时间从数据库中查询发电数据，并进行计算

        // 例子：
        String sql = “SELECT SUM(generation) FROM power_generation WHERE inverter_id = ? AND time BETWEEN ? AND ?”;
        return jdbcTemplate.queryForObject(sql, Double.class, inverterId, startTime, endTime);
    }

    public double calculateAverageEquivalentHours() {
        // 从数据库中查询所有逆变器的等价发电小时数据，并计算平均值

        // 例子：
        String sql = “SELECT AVG(equivalent_hours) FROM power_generation”;
        return jdbcTemplate.queryForObject(sql, Double.class);
    }
}
（根据木联能，利用Javaspring编写，Mysql提供数据，navicat编写）