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

    @Autowired
    private CurrentDataService currentDataService;
    @Autowired
    private CurrentDataServiceImpl currentDataServiceImpl;
    @GetMapping("/{inverterId}")
    public CurrentAnalysisResult analyzeCurrent(@PathVariable String 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(String inverterId, String dataType, String timeRange) {
        // 根据逆变器ID、数据类型和时间范围从数据库中查询支路电流数据
        // 使用Navicat等数据库客户端进行查询和提取数据

        return currentDataRepository.findCurrentData(inverterId, dataType, timeRange);
    }
    }
@Mapper
@Repository
public interface CurrentDataService {
    List<Double> getCurrentData(String inverterId, String startTime, String endTime);
}
@Repository
public class CurrentDataRepository {

    @Autowired
    private JdbcTemplate jdbcTemplate;

    public List<Double> findCurrentData(String 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);
        //该方法接受三个参数：sql（SQL 查询语句）、Double.class（结果类型）和 inverterId、dataType、timeRange（查询参数）
        return currentData;
    }
}
public class CurrentAnalysisResult {
    private double zeroFactor;
    private double lowFactor;

    // 构造函数、getter、setter等

    public CurrentAnalysisResult(double zeroFactor, double lowFactor) {
        this.zeroFactor = zeroFactor;
        this.lowFactor = lowFactor;
    }

    public double getZeroFactor() {
        return zeroFactor;
    }

    public void setZeroFactor(double zeroFactor) {
        this.zeroFactor = zeroFactor;
    }

    public double getLowFactor() {
        return lowFactor;
    }

    public void setLowFactor(double lowFactor) {
        this.lowFactor = lowFactor;
    }
}
@Configuration
public class InverterConfig {
    @Bean
    public CurrentDataService currentDataService() {
        return new CurrentDataServiceImpl();
    }

    @Bean
    public CurrentDataRepository currentDataRepository() {
        return new CurrentDataRepository();
    }
/*
    @Bean
    public JdbcTemplate jdbcTemplate() {
        // 配置数据库连接信息，例如URL、用户名、密码等
        DataSource dataSource = new DriverManagerDataSource(url, username, password);
        return new JdbcTemplate(dataSource);
    }
 */
    @Bean
    public CurrentAnalysisController currentAnalysisController() {
        return new CurrentAnalysisController();
    }
@ImportResource("classpath:applicationContext.xml")
@SpringBootApplication
//@MapperScan
@Repository
@Service
@RestController
public class Main {
	public static void main(String[] args) {
		Connection connection = null;

		try {
			// 加载JDBC驱动程序
			Class.forName("com.mysql.cj.jdbc.Driver");

			// 创建数据库连接
			String url = "jdbc:mysql://localhost:3306/mydb_one?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone = GMT";
			String username = "root";
			String password = "1527648qw";
			connection = DriverManager.getConnection(url, username, password);
			Statement statement = connection.createStatement();
			String sql = "select * from discrepancyanalysis";
			// 执行数据库操作
			ResultSet resultSet = statement.executeQuery(sql);
			while (resultSet.next())
				System.out.println("daily" + resultSet.getObject("daily"));

		    InverterDataService inverterDataService = new InverterDataService();
	   		String startTime = "9:00:00"; // 设置startTime
			String endTime = "15:00:00"; // 设置endTime
			List<Double> componentCurrents = inverterDataService.getComponentCurrentsByTime(startTime, endTime);
			List<Double> standardDeviations = inverterDataService.getStandardDeviations(componentCurrents);
			List<Double> discreteRates = inverterDataService.getDiscreteRates(componentCurrents, standardDeviations);
			List<Double> weightedAverages = inverterDataService.getWeightedAverages(discreteRates);
            // 对获得的数据进行处理
			System.out.println(weightedAverages);

		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		} catch (SQLException e) {
			e.printStackTrace();
		} finally {
			// 关闭数据库连接
			try {
				if (connection != null) {
					connection.close();
				}
			} catch (SQLException e) {
				e.printStackTrace();
			}
		}
	}}
为什么不能运行这段代码