taosj 3 hodín pred
rodič
commit
710d7b7d00

+ 709 - 709
forecast-backend-server/src/main/java/com/ufo/project/data/task/MockDataTask.java

@@ -1,709 +1,709 @@
-package com.ufo.project.data.task;
-
-import java.io.IOException;
-import java.nio.charset.StandardCharsets;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.nio.file.StandardOpenOption;
-import java.time.LocalDate;
-import java.time.ZoneOffset;
-import java.time.ZonedDateTime;
-import java.time.format.DateTimeFormatter;
-import java.util.Date;
-import java.util.Locale;
-import java.util.Random;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.scheduling.annotation.Scheduled;
-import org.springframework.stereotype.Component;
-
-import com.ufo.base.framework.config.ProjectConfig;
-import com.ufo.project.model.domain.DataElectricityLocal;
-import com.ufo.project.model.mapper.DataElectricityLocalMapper;
-import com.ufo.project.weather.domain.DataWeatherLocal;
-import com.ufo.project.weather.mapper.DataWeatherLocalMapper;
-
-/**
- * 功率与气象mock数据生成任务
- *
- * 在 project.profile 目录下生成 超短期/短期/中期 功率预测mock文件(生产环境即 /home/power/upload/power/MOCK/YMPV03 下)
- * 及短期气象mock文件(生产环境即 /home/power/upload/weather/MOCK/YMPV03 下),
- * 供数据文件同步任务(data_file_sync_config)消费.
- * 文件命名与init_time均使用UTC时间; time列为UTC, time_shanghai列为UTC+8.
- * 文件格式:
- * <pre>
- * init_time,time,time_shanghai,power
- * 2602281600,2026-02-28T16:15Z,2026-03-01 00:15:00,0.000
- * </pre>
- * power为尽量符合物理规律的光伏出力mock: 夜间为0, 白天呈钟形曲线,
- * 日出日落与峰值随季节变化(夏长夏高/冬短冬低), 叠加缓慢的云量波动;
- * 随机参数由起报时间派生, 同一文件的生成结果稳定可复现.
- *
- * 短期气象mock为SYSU格式38列CSV, 自起报时间(含)起961点(10天), 间隔15分钟,
- * 文件名时间为UTC, date_time列为GMT+8(即文件名时间+8h);
- * t2m/rh2/sp/云量/风/ghi/dni/dhi尽量符合物理规律, 按北纬35.1度定标, 同样按起报时间可复现.
- *
- * 另含采集数据mock任务(generateCollectedData): 每5分钟向 data_weather_local 与
- * data_electricity_local 各插1行, tm取当前最近5分钟整北京时间, config_station_id固定为4,
- * 两行共享同一时刻物理状态(云量/钟形/季节), 数据尽量接近真实, 按北京日期可复现.
- *
- * @author ufo
- * @date 2026-10-21
- */
-@Component
-public class MockDataTask
-{
-    private static final Logger log = LoggerFactory.getLogger(MockDataTask.class);
-
-    @Autowired
-    private DataWeatherLocalMapper dataWeatherLocalMapper;
-
-    @Autowired
-    private DataElectricityLocalMapper dataElectricityLocalMapper;
-
-    /** UTC时区 */
-    private static final ZoneOffset UTC = ZoneOffset.UTC;
-
-    /** 上海时区(UTC+8) */
-    private static final ZoneOffset SHANGHAI = ZoneOffset.ofHours(8);
-
-    /** time列格式(UTC, 如 2026-02-28T16:15Z) */
-    private static final DateTimeFormatter TIME_FMT = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm'Z'");
-
-    /** time_shanghai列格式 */
-    private static final DateTimeFormatter TIME_SH_FMT = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
-
-    /** 超短期文件名时间格式(yyyyMMddHHmm) */
-    private static final DateTimeFormatter ULTRA_FILE_FMT = DateTimeFormatter.ofPattern("yyyyMMddHHmm");
-
-    /** 超短期init_time格式(yyMMddHHmm) */
-    private static final DateTimeFormatter ULTRA_INIT_FMT = DateTimeFormatter.ofPattern("yyMMddHHmm");
-
-    /** 短期/中期文件名时间格式(yyyyMMddHH) */
-    private static final DateTimeFormatter TERM_FILE_FMT = DateTimeFormatter.ofPattern("yyyyMMddHH");
-
-    /** 短期/中期init_time格式(yyMMddHH) */
-    private static final DateTimeFormatter TERM_INIT_FMT = DateTimeFormatter.ofPattern("yyMMddHH");
-
-    /** 超短期数据点数(起报时间+15分钟起4小时, 共16点) */
-    private static final int ULTRA_POINTS = 16;
-
-    /** 短期数据点数(自起报时间(含)起288点) */
-    private static final int SHORT_POINTS = 288;
-
-    /** 中期数据点数(自起报时间(含)起960点) */
-    private static final int MEDIUM_POINTS = 960;
-
-    /** 出力上限(kW, 与采集数据mock一致, 按80000kW装机容量定标) */
-    private static final double POWER_CAP = 80000.0;
-
-    /** 采集数据mock固定场站ID(config_station_id) */
-    private static final long COLLECT_STATION_ID = 4L;
-
-    /** 采集数据mock装机容量(kW) */
-    private static final double COLLECT_CAPACITY_KW = 80000.0;
-
-    /** 采集数据mock理论出力定标的晴空峰值辐照度(W/m², 夏季正午晴空) */
-    private static final double CLEAR_PEAK_REF = 850.0;
-
-    /** 短期气象数据点数(自起报时间(含)起960个间隔, 961点) */
-    private static final int WEATHER_POINTS = 961;
-
-    /** 气象mock场站编号(farm_id, 同时是文件名的场站段) */
-    private static final String WEATHER_FARM_ID = "YMPV03";
-
-    /** 气象mock固定经度(文件名按经度-纬度顺序) */
-    private static final double WEATHER_LON = 118.3262;
-
-    /** 气象mock固定纬度 */
-    private static final double WEATHER_LAT = 35.0654;
-
-    /** 气象文件名日期格式(yyyyMMdd, UTC即北京日期) */
-    private static final DateTimeFormatter WEATHER_FILE_DATE_FMT = DateTimeFormatter.ofPattern("yyyyMMdd");
-
-    /** 气象date_time列格式(GMT+8) */
-    private static final DateTimeFormatter WEATHER_TIME_FMT = DateTimeFormatter.ofPattern("yyyy-MM-dd_HH:mm:ss");
-
-    /** 风速/风向高度序列(m) */
-    private static final int[] WEATHER_HEIGHTS = {10, 30, 50, 70, 80, 90, 100, 120, 140, 160, 180, 200};
-
-    /** 气象文件表头(与真实SYSU文件一致, 38列) */
-    private static final String WEATHER_HEADER = "farm_id,date_time,lat,lon,sp,t2m,rh2,tcc,lcc,mcc,hcc,"
-            + "spd10,spd30,spd50,spd70,spd80,spd90,spd100,spd120,spd140,spd160,spd180,spd200,"
-            + "dir10,dir30,dir50,dir70,dir80,dir90,dir100,dir120,dir140,dir160,dir180,dir200,ghi,dni,dhi";
-
-    /**
-     * 超短期: 每15分钟执行一次, 以当前15分钟整点(0/15/30/45)为起报时间生成预报文件,
-     * 数据自起报时间+15分钟至起报时间+4小时, 共16点, 间隔15分钟
-     */
-    @Scheduled(cron = "0 0/15 * * * ?")
-    public void generateUltraShortTerm()
-    {
-        ZonedDateTime now = ZonedDateTime.now(UTC).withSecond(0).withNano(0);
-        ZonedDateTime init = now.minusMinutes(now.getMinute() % 15);
-        try
-        {
-            Path file = generateFile("UltraShortTerm", init, ULTRA_FILE_FMT, ULTRA_INIT_FMT, 15, ULTRA_POINTS);
-            log.info("[MockDataTask] 生成超短期mock文件, file={}", file);
-        }
-        catch (Exception e)
-        {
-            log.error("[MockDataTask] 生成超短期mock文件失败, init={}", init, e);
-        }
-    }
-
-    /**
-     * 短期: 每天3点执行一次, 生成当日全部24个文件(起报时间为当日UTC 00/01/.../23时),
-     * 每文件288点, 自起报时间(含)起, 间隔15分钟
-     */
-    @Scheduled(cron = "0 0 3 * * ?")
-    public void generateShortTerm()
-    {
-        ZonedDateTime day0 = ZonedDateTime.now(UTC).toLocalDate().atStartOfDay(UTC);
-        for (int hour = 0; hour < 24; hour++)
-        {
-            ZonedDateTime init = day0.plusHours(hour);
-            try
-            {
-                Path file = generateFile("ShortTerm", init, TERM_FILE_FMT, TERM_INIT_FMT, 0, SHORT_POINTS);
-                log.info("[MockDataTask] 生成短期mock文件, file={}", file);
-            }
-            catch (Exception e)
-            {
-                log.error("[MockDataTask] 生成短期mock文件失败, init={}", init, e);
-            }
-        }
-    }
-
-    /**
-     * 中期: 每天3点执行一次, 生成当日0点数据
-     */
-    @Scheduled(cron = "0 0 3 * * ?")
-    public void generateMediumTermMidnight()
-    {
-        generateMediumTermFile(0);
-    }
-
-    /**
-     * 中期: 每天11点执行一次, 生成当日12点数据
-     */
-    @Scheduled(cron = "0 0 11 * * ?")
-    public void generateMediumTermNoon()
-    {
-        generateMediumTermFile(12);
-    }
-
-    /**
-     * 生成单个中期mock文件(960点, 自起报时间(含)起, 间隔15分钟)
-     *
-     * @param hour 起报时间(当日UTC小时)
-     */
-    private void generateMediumTermFile(int hour)
-    {
-        ZonedDateTime init = ZonedDateTime.now(UTC).toLocalDate().atStartOfDay(UTC).plusHours(hour);
-        try
-        {
-            Path file = generateFile("MediumTerm", init, TERM_FILE_FMT, TERM_INIT_FMT, 0, MEDIUM_POINTS);
-            log.info("[MockDataTask] 生成中期mock文件, file={}", file);
-        }
-        catch (Exception e)
-        {
-            log.error("[MockDataTask] 生成中期mock文件失败, init={}", init, e);
-        }
-    }
-
-    /**
-     * 短期气象: 每天凌晨2点执行一次, 生成当日(北京日期)12:00 UTC起报的一个预报文件,
-     * 自起报时间(含)起961点, 间隔15分钟, 输出到 weather/MOCK/YMPV03/;
-     * 文件名时间为UTC, date_time列为GMT+8(即文件名时间+8h)
-     */
-    @Scheduled(cron = "0 0 2 * * ?")
-    public void generateShortTermWeather()
-    {
-        ZonedDateTime init = LocalDate.now(SHANGHAI).atTime(12, 0).atZone(UTC);
-        try
-        {
-            Path file = generateWeatherFile(init);
-            log.info("[MockDataTask] 生成短期气象mock文件, file={}", file);
-        }
-        catch (Exception e)
-        {
-            log.error("[MockDataTask] 生成短期气象mock文件失败, init={}", init, e);
-        }
-    }
-
-    /**
-     * 采集数据: 每5分钟执行一次, 向 data_weather_local 与 data_electricity_local 各插1行,
-     * tm为当前时间就近取整到最近5分钟整北京时间(如00:05:34→00:05:00, 00:09:12→00:10:00),
-     * config_station_id固定为4; 两行共享同一时刻的物理状态(云量/钟形/季节), 功率与气象描述同一天气;
-     * 理论出力为按80000kW装机容量定标的晴空钟形(夏峰~80000/冬峰~61800, 夜间0),
-     * 实发功率=理论×慢快云量衰减×可用率(恒≤理论), 随机参数按北京日期派生, 当日数据稳定可复现
-     */
-    @Scheduled(cron = "0 0/5 * * * ?")
-    public void generateCollectedData()
-    {
-        ZonedDateTime tm = roundToFiveMinute(ZonedDateTime.now(SHANGHAI));
-        try
-        {
-            DayPhysics phys = dayPhysics(tm.toLocalDate());
-            double tH = tm.toInstant().getEpochSecond() / 3600.0;
-            double cosz = coszAt(phys, tm);
-            double cloud = tccAt(phys, tH) / 100.0;
-            double peak = 750 + 100 * phys.season;
-            double ghi = 0.90 * peak * (1 - 0.95 * cloud) * cosz + 0.10 * peak * cosz * (1 + cloud);
-            double ghiClear = peak * cosz * (0.9 + 0.1 * cosz);
-
-            double hour = tm.getHour() + tm.getMinute() / 60.0;
-            double t2m = 17 + 7 * phys.season + 5 * Math.cos(2 * Math.PI * (hour - 14.5) / 24);
-            double rh2 = clamp(85 - 2.2 * t2m + 12 * cloud, 35, 98);
-            double spHpa = 1013 + 3 * Math.sin(2 * Math.PI * tH / phys.tP + phys.pP);
-            double spd10 = Math.max(0.3, phys.windBase + Math.sin(2 * Math.PI * tH / 24 + phys.pW));
-            double dir10 = wrapDir(phys.dirBase
-                    + 40 * Math.sin(2 * Math.PI * tH / phys.tD + phys.pD)
-                    + 12 * Math.sin(2 * Math.PI * tH / phys.tD2 + phys.pD2));
-
-            double theoretical = clamp(COLLECT_CAPACITY_KW * ghiClear / CLEAR_PEAK_REF, 0, COLLECT_CAPACITY_KW);
-            double fastFluct = 1 - phys.fastAmp * (0.5 + 0.5 * Math.sin(2 * Math.PI * tH / phys.fastT + phys.fastP));
-            double actual = clamp(theoretical * (1 - 0.90 * cloud) * fastFluct * phys.availability / 100.0, 0, theoretical);
-
-            Date tmDate = Date.from(tm.toInstant());
-
-            DataWeatherLocal weather = new DataWeatherLocal();
-            weather.setTm(tmDate);
-            weather.setConfigStationId(COLLECT_STATION_ID);
-            weather.setIrradiance(round(ghi, 2));
-            weather.setInclinedIrradiance(round(ghi * (1 + 0.12 * cosz), 2));
-            weather.setTemperature(round(t2m, 2));
-            weather.setBoardTemperature(round(t2m + 0.031 * ghi, 2));
-            weather.setPressure(round(spHpa, 2));
-            weather.setHumidity(round(rh2, 1));
-            weather.setWindSpeed(round(spd10, 2));
-            weather.setWindDirection(round(dir10, 1));
-            weather.setDailyIrradiance(round(dailyIrradianceMj(phys, tm), 3));
-            dataWeatherLocalMapper.insertDataWeatherLocal(weather);
-
-            DataElectricityLocal power = new DataElectricityLocal();
-            power.setTm(tmDate);
-            power.setConfigStationId(COLLECT_STATION_ID);
-            power.setActualPower(round(actual, 1));
-            power.setTheoreticalPower(round(theoretical, 1));
-            power.setCurtailmentPower(0.0);
-            power.setAvailability(round(phys.availability, 2));
-            power.setDeviceStatus(0);
-            power.setGridStatus(1);
-            dataElectricityLocalMapper.insertDataElectricityLocal(power);
-
-            log.info("[MockDataTask] 生成采集数据mock, tm={}", tm.format(TIME_SH_FMT));
-        }
-        catch (Exception e)
-        {
-            log.error("[MockDataTask] 生成采集数据mock失败, tm={}", tm, e);
-        }
-    }
-
-    /**
-     * 当前北京时间就近取整到最近5分钟整点(如00:05:34→00:05:00, 00:09:12→00:10:00),
-     * 跨午夜时自动进位到次日00:00
-     */
-    private static ZonedDateTime roundToFiveMinute(ZonedDateTime now)
-    {
-        long secs = now.getHour() * 3600L + now.getMinute() * 60L + now.getSecond();
-        long rounded = ((secs + 150) / 300) * 300;
-        LocalDate day = now.toLocalDate();
-        if (rounded >= 86400L)
-        {
-            day = day.plusDays(1);
-            rounded -= 86400L;
-        }
-        return day.atStartOfDay(SHANGHAI).plusSeconds(rounded);
-    }
-
-    /**
-     * 采集数据mock: 由北京日期派生当日物理参数
-     * (种子为当日北京午夜的epoch分钟, 当日结果稳定可复现, 跨天换新云图/风场)
-     */
-    private static DayPhysics dayPhysics(LocalDate day)
-    {
-        DayPhysics p = new DayPhysics();
-        p.season = Math.cos(2 * Math.PI * (day.getDayOfYear() - 195.0) / 365.0);
-        double halfDay = 5.9 + 1.4 * p.season;
-        p.sunrise = 12 - halfDay;
-        p.sunset = 12 + halfDay;
-
-        Random random = new Random(day.atStartOfDay(SHANGHAI).toInstant().toEpochMilli() / 60000L);
-        p.baseCc = 20 + 40 * random.nextDouble();
-        p.ampCc = 10 + 20 * random.nextDouble();
-        p.tCc = 48 + 24 * random.nextDouble();
-        p.pCc = 2 * Math.PI * random.nextDouble();
-        p.tP = 96 + 48 * random.nextDouble();
-        p.pP = 2 * Math.PI * random.nextDouble();
-        p.windBase = 3 + 2 * random.nextDouble();
-        p.pW = 2 * Math.PI * random.nextDouble();
-        p.dirBase = 360 * random.nextDouble();
-        p.tD = 48 + 48 * random.nextDouble();
-        p.pD = 2 * Math.PI * random.nextDouble();
-        p.tD2 = 6 + 8 * random.nextDouble();
-        p.pD2 = 2 * Math.PI * random.nextDouble();
-        p.fastAmp = 0.02 + 0.08 * random.nextDouble();
-        p.fastT = 1 + 1 * random.nextDouble();
-        p.fastP = 2 * Math.PI * random.nextDouble();
-        p.availability = 99 + random.nextDouble();
-        return p;
-    }
-
-    /**
-     * 太阳天顶角余弦近似: 夜间为0, 正午(墙钟12点)为1, 白天呈正弦钟形
-     */
-    private static double coszAt(DayPhysics p, ZonedDateTime t)
-    {
-        double hour = t.getHour() + t.getMinute() / 60.0;
-        if (hour <= p.sunrise || hour >= p.sunset)
-        {
-            return 0;
-        }
-        return Math.sin(Math.PI * (hour - p.sunrise) / (p.sunset - p.sunrise));
-    }
-
-    /**
-     * 指定epoch时刻的总云量(0~100), 慢漂移
-     */
-    private static double tccAt(DayPhysics p, double tH)
-    {
-        return clamp(p.baseCc + p.ampCc * Math.sin(2 * Math.PI * tH / p.tCc + p.pCc), 0, 100);
-    }
-
-    /**
-     * 指定时刻的水平面总辐照度GHI(W/m²):
-     * 晴空峰值随季节, 云量主要削弱直分量, 散射随云量增大, 夜间为0
-     */
-    private static double ghiAt(DayPhysics p, ZonedDateTime t)
-    {
-        double cosz = coszAt(p, t);
-        if (cosz <= 0)
-        {
-            return 0;
-        }
-        double peak = 750 + 100 * p.season;
-        double cloud = tccAt(p, t.toInstant().getEpochSecond() / 3600.0) / 100.0;
-        return 0.90 * peak * (1 - 0.95 * cloud) * cosz + 0.10 * peak * cosz * (1 + cloud);
-    }
-
-    /**
-     * 当日当地00:00至tm的水平面总辐照度累计(MJ/m²),
-     * 按5分钟步长用当日物理参数积分
-     */
-    private static double dailyIrradianceMj(DayPhysics p, ZonedDateTime tm)
-    {
-        ZonedDateTime day0 = tm.toLocalDate().atStartOfDay(SHANGHAI);
-        double mj = 0;
-        for (long s = 0; s < tm.getHour() * 3600L + tm.getMinute() * 60L; s += 300)
-        {
-            mj += ghiAt(p, day0.plusSeconds(s)) * 300.0 / 1e6;
-        }
-        return mj;
-    }
-
-    /**
-     * 按指定小数位四舍五入
-     */
-    private static double round(double v, int scale)
-    {
-        double f = Math.pow(10, scale);
-        return Math.round(v * f) / f;
-    }
-
-    /**
-     * 采集数据mock: 每北京日期一组物理参数(钟形/云量/气压/风/快云/可用率)
-     */
-    private static final class DayPhysics
-    {
-        /** 季节系数(-1冬至~1夏至) */
-        double season;
-        /** 日出时刻(北京墙钟小时) */
-        double sunrise;
-        /** 日落时刻(北京墙钟小时) */
-        double sunset;
-        /** 慢云量基准(%) */
-        double baseCc;
-        /** 慢云量幅值(%) */
-        double ampCc;
-        /** 慢云量周期(小时) */
-        double tCc;
-        /** 慢云量相位(rad) */
-        double pCc;
-        /** 气压漂移周期(小时) */
-        double tP;
-        /** 气压漂移相位(rad) */
-        double pP;
-        /** 风速基准(m/s) */
-        double windBase;
-        /** 风速日变化相位(rad) */
-        double pW;
-        /** 风向基准(度) */
-        double dirBase;
-        /** 风向慢摆周期(小时) */
-        double tD;
-        /** 风向慢摆相位(rad) */
-        double pD;
-        /** 风向快摆周期(小时) */
-        double tD2;
-        /** 风向快摆相位(rad) */
-        double pD2;
-        /** 快云量幅值(功率衰减系数) */
-        double fastAmp;
-        /** 快云量周期(小时) */
-        double fastT;
-        /** 快云量相位(rad) */
-        double fastP;
-        /** 可用率(%) */
-        double availability;
-    }
-
-    /**
-     * 生成单个mock预报文件
-     *
-     * @param type           类型目录(UltraShortTerm/ShortTerm/MediumTerm)
-     * @param init           起报时间(UTC)
-     * @param fileFmt        文件名时间格式
-     * @param initFmt        init_time格式
-     * @param firstOffsetMin 首个数据点相对起报时间的偏移(分钟)
-     * @param points         数据点数
-     * @return 生成的文件路径
-     */
-    private Path generateFile(String type, ZonedDateTime init, DateTimeFormatter fileFmt,
-            DateTimeFormatter initFmt, int firstOffsetMin, int points) throws IOException
-    {
-        Path dir = Paths.get(ProjectConfig.getProfile(), "power", "MOCK", "YMPV03", type,
-                String.format(Locale.ROOT, "%04d", init.getYear()),
-                String.format(Locale.ROOT, "%02d", init.getMonthValue()),
-                String.format(Locale.ROOT, "%02d", init.getDayOfMonth()));
-        Path file = dir.resolve(init.format(fileFmt) + ".csv");
-        Files.createDirectories(dir);
-
-        Random random = new Random(init.toInstant().toEpochMilli() / 60000L);
-        double t0 = init.toInstant().getEpochSecond() / 3600.0;
-        double a1 = 0.15 + 0.30 * random.nextDouble();
-        double a2 = 0.02 + 0.06 * random.nextDouble();
-        double p1 = 2 * Math.PI * random.nextDouble();
-        double p2 = 2 * Math.PI * random.nextDouble();
-        double t1 = 5 + 2 * random.nextDouble();
-        double t2 = 1.0 + 1.0 * random.nextDouble();
-
-        StringBuilder sb = new StringBuilder(64 + points * 52);
-        sb.append("init_time,time,time_shanghai,power\n");
-        String initTime = init.format(initFmt);
-        for (int i = 0; i < points; i++)
-        {
-            ZonedDateTime t = init.plusMinutes((long) firstOffsetMin + 15L * i);
-            sb.append(initTime).append(',')
-                    .append(t.format(TIME_FMT)).append(',')
-                    .append(t.withZoneSameInstant(SHANGHAI).format(TIME_SH_FMT)).append(',')
-                    .append(String.format(Locale.ROOT, "%.3f",
-                            mockPower(t, t0, a1, p1, t1, a2, p2, t2)))
-                    .append('\n');
-        }
-        Files.write(file, sb.toString().getBytes(StandardCharsets.UTF_8),
-                StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING, StandardOpenOption.WRITE);
-        return file;
-    }
-
-    /**
-     * 计算mock光伏出力: 夜间为0, 白天钟形曲线, 峰值与日照时长随季节变化, 叠加缓慢云量波动;
-     * 峰值按80000kW装机容量对晴空辐照定标(与采集数据mock同量纲, 夏峰~80000/冬峰~61800),
-     * 与采集数据在相近时刻的数值接近
-     *
-     * @param tUtc 数据时刻(UTC)
-     * @param t0   起报时间(epoch小时), 用于云量相位基准
-     * @param a1   慢周期云量幅值
-     * @param p1   慢周期云量相位
-     * @param t1   慢周期云量周期(小时)
-     * @param a2   快周期云量幅值
-     * @param p2   快周期云量相位
-     * @param t2   快周期云量周期(小时)
-     * @return 出力值
-     */
-    private double mockPower(ZonedDateTime tUtc, double t0, double a1, double p1, double t1,
-            double a2, double p2, double t2)
-    {
-        int doy = tUtc.toLocalDate().getDayOfYear();
-        double season = Math.cos(2 * Math.PI * (doy - 195.0) / 365.0);
-        double peak = COLLECT_CAPACITY_KW * (750 + 100 * season) / CLEAR_PEAK_REF;
-        double halfDay = 5.9 + 1.4 * season;
-        double sunrise = 12 - halfDay;
-        double sunset = 12 + halfDay;
-
-        ZonedDateTime local = tUtc.withZoneSameInstant(SHANGHAI);
-        double hour = local.getHour() + local.getMinute() / 60.0;
-        if (hour <= sunrise || hour >= sunset)
-        {
-            return 0.0;
-        }
-        double solar = Math.pow(Math.sin(Math.PI * (hour - sunrise) / (sunset - sunrise)), 1.3);
-
-        double tHours = tUtc.toInstant().getEpochSecond() / 3600.0;
-        double cloud1 = 1 - a1 * (0.5 + 0.5 * Math.sin(2 * Math.PI * (tHours - t0) / t1 + p1));
-        double cloud2 = 1 - a2 * (0.5 + 0.5 * Math.sin(2 * Math.PI * (tHours - t0) / t2 + p2));
-
-        double power = peak * solar * cloud1 * cloud2;
-        if (power < 0)
-        {
-            power = 0;
-        }
-        if (power > POWER_CAP)
-        {
-            power = POWER_CAP;
-        }
-        return power;
-    }
-
-    /**
-     * 生成短期气象mock文件(SYSU格式, 38列, 961点, 间隔15分钟)
-     *
-     * @param init 起报时间(12:00 UTC)
-     * @return 生成的文件路径
-     */
-    private Path generateWeatherFile(ZonedDateTime init) throws IOException
-    {
-        Path dir = Paths.get(ProjectConfig.getProfile(), "weather", "MOCK", WEATHER_FARM_ID);
-        String lon = String.format(Locale.ROOT, "%.4f", WEATHER_LON);
-        String lat = String.format(Locale.ROOT, "%.4f", WEATHER_LAT);
-        Path file = dir.resolve(String.format(Locale.ROOT, "%s_%s-%s_%s12_SYSU.csv",
-                WEATHER_FARM_ID, lon, lat, init.format(WEATHER_FILE_DATE_FMT)));
-        Files.createDirectories(dir);
-
-        Random random = new Random(init.toInstant().toEpochMilli() / 60000L);
-        double t0 = init.toInstant().getEpochSecond() / 3600.0;
-
-        // 每文件随机参数(由起报时间派生, 生成结果稳定可复现)
-        double baseCc = 20 + 40 * random.nextDouble();
-        double ampCc = 10 + 20 * random.nextDouble();
-        double tCc = 48 + 24 * random.nextDouble();
-        double pCc = 2 * Math.PI * random.nextDouble();
-        double rM = 0.4 + 0.3 * random.nextDouble();
-        double rL = (1 - rM) * (0.5 + 0.4 * random.nextDouble());
-        double rH = 1 - rM - rL;
-        double tP = 96 + 48 * random.nextDouble();
-        double pP = 2 * Math.PI * random.nextDouble();
-        double windBase = 3 + 2 * random.nextDouble();
-        double pW = 2 * Math.PI * random.nextDouble();
-        double alpha = 0.20 + 0.08 * random.nextDouble();
-        double dirBase = 360 * random.nextDouble();
-        double tD = 48 + 48 * random.nextDouble();
-        double pD = 2 * Math.PI * random.nextDouble();
-        double tD2 = 6 + 8 * random.nextDouble();
-        double pD2 = 2 * Math.PI * random.nextDouble();
-        double[] dirOffsets = new double[WEATHER_HEIGHTS.length];
-        for (int i = 0; i < dirOffsets.length; i++)
-        {
-            dirOffsets[i] = (random.nextDouble() - 0.5) * 8;
-        }
-
-        StringBuilder sb = new StringBuilder(64 + WEATHER_POINTS * 160);
-        sb.append(WEATHER_HEADER).append('\n');
-
-        for (int i = 0; i < WEATHER_POINTS; i++)
-        {
-            ZonedDateTime t = init.plusMinutes(15L * i);
-            ZonedDateTime local = t.withZoneSameInstant(SHANGHAI);
-            double hour = local.getHour() + local.getMinute() / 60.0;
-            double tHours = t.toInstant().getEpochSecond() / 3600.0;
-
-            // 太阳: 日出日落随季节变化, cosz近似太阳高度正弦
-            int doy = t.toLocalDate().getDayOfYear();
-            double season = Math.cos(2 * Math.PI * (doy - 195.0) / 365.0);
-            double halfDay = 5.9 + 1.4 * season;
-            double sunrise = 12 - halfDay;
-            double sunset = 12 + halfDay;
-            double cosz = 0;
-            if (hour > sunrise && hour < sunset)
-            {
-                cosz = Math.sin(Math.PI * (hour - sunrise) / (sunset - sunrise));
-            }
-
-            // 云量: 总云量慢漂移, 按比例拆三层(和等于总云量)
-            double tcc = clamp(baseCc + ampCc * Math.sin(2 * Math.PI * (tHours - t0) / tCc + pCc), 0, 100);
-            double cloud = tcc / 100.0;
-
-            // 温度/湿度/气压
-            double t2m = 17 + 7 * season + 5 * Math.cos(2 * Math.PI * (hour - 14.5) / 24);
-            double rh2 = clamp(85 - 2.2 * t2m + 12 * cloud, 35, 98);
-            double sp = 101300 + 300 * Math.sin(2 * Math.PI * (tHours - t0) / tP + pP);
-
-            // 风: 10m风速日变化, 幂律廓线, 风向双正弦摆动
-            double spd10 = Math.max(0.3, windBase + Math.sin(2 * Math.PI * (tHours - t0) / 24 + pW));
-            double dir10 = wrapDir(dirBase
-                    + 40 * Math.sin(2 * Math.PI * (tHours - t0) / tD + pD)
-                    + 12 * Math.sin(2 * Math.PI * (tHours - t0) / tD2 + pD2));
-
-            // 辐照: 晴空峰值随季节, 云量主要削弱直分量, 散射随云量增大, 夜间均为0
-            double ghi = 0, dni = 0, dhi = 0;
-            if (cosz > 0)
-            {
-                double peak = 750 + 100 * season;
-                dni = 0.90 * peak * (1 - 0.95 * cloud);
-                dhi = 0.10 * peak * cosz * (1 + cloud);
-                ghi = dni * cosz + dhi;
-            }
-
-            sb.append(WEATHER_FARM_ID).append(',')
-                    .append(local.format(WEATHER_TIME_FMT)).append(',')
-                    .append(lat).append(',')
-                    .append(lon).append(',')
-                    .append(fmt3(sp)).append(',')
-                    .append(fmt3(t2m)).append(',')
-                    .append(fmt3(rh2)).append(',')
-                    .append(fmt1(tcc)).append(',')
-                    .append(fmt1(tcc * rL)).append(',')
-                    .append(fmt1(tcc * rM)).append(',')
-                    .append(fmt1(tcc * rH)).append(',');
-            for (int h = 0; h < WEATHER_HEIGHTS.length; h++)
-            {
-                if (h > 0)
-                {
-                    sb.append(',');
-                }
-                sb.append(fmt3(spd10 * Math.pow(WEATHER_HEIGHTS[h] / 10.0, alpha)));
-            }
-            sb.append(',');
-            for (int h = 0; h < WEATHER_HEIGHTS.length; h++)
-            {
-                if (h > 0)
-                {
-                    sb.append(',');
-                }
-                sb.append(fmt3(wrapDir(dir10 + dirOffsets[h])));
-            }
-            sb.append(',')
-                    .append(fmt3(ghi)).append(',')
-                    .append(fmt3(dni)).append(',')
-                    .append(fmt3(dhi)).append('\n');
-        }
-        Files.write(file, sb.toString().getBytes(StandardCharsets.UTF_8),
-                StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING, StandardOpenOption.WRITE);
-        return file;
-    }
-
-    private static String fmt3(double v)
-    {
-        return String.format(Locale.ROOT, "%.3f", v);
-    }
-
-    private static String fmt1(double v)
-    {
-        return String.format(Locale.ROOT, "%.1f", v);
-    }
-
-    private static double clamp(double v, double min, double max)
-    {
-        return Math.max(min, Math.min(max, v));
-    }
-
-    private static double wrapDir(double d)
-    {
-        double r = d % 360;
-        return r < 0 ? r + 360 : r;
-    }
-}
+// package com.ufo.project.data.task;
+
+// import java.io.IOException;
+// import java.nio.charset.StandardCharsets;
+// import java.nio.file.Files;
+// import java.nio.file.Path;
+// import java.nio.file.Paths;
+// import java.nio.file.StandardOpenOption;
+// import java.time.LocalDate;
+// import java.time.ZoneOffset;
+// import java.time.ZonedDateTime;
+// import java.time.format.DateTimeFormatter;
+// import java.util.Date;
+// import java.util.Locale;
+// import java.util.Random;
+
+// import org.slf4j.Logger;
+// import org.slf4j.LoggerFactory;
+// import org.springframework.beans.factory.annotation.Autowired;
+// import org.springframework.scheduling.annotation.Scheduled;
+// import org.springframework.stereotype.Component;
+
+// import com.ufo.base.framework.config.ProjectConfig;
+// import com.ufo.project.model.domain.DataElectricityLocal;
+// import com.ufo.project.model.mapper.DataElectricityLocalMapper;
+// import com.ufo.project.weather.domain.DataWeatherLocal;
+// import com.ufo.project.weather.mapper.DataWeatherLocalMapper;
+
+// /**
+//  * 功率与气象mock数据生成任务
+//  *
+//  * 在 project.profile 目录下生成 超短期/短期/中期 功率预测mock文件(生产环境即 /home/power/upload/power/MOCK/YMPV03 下)
+//  * 及短期气象mock文件(生产环境即 /home/power/upload/weather/MOCK/YMPV03 下),
+//  * 供数据文件同步任务(data_file_sync_config)消费.
+//  * 文件命名与init_time均使用UTC时间; time列为UTC, time_shanghai列为UTC+8.
+//  * 文件格式:
+//  * <pre>
+//  * init_time,time,time_shanghai,power
+//  * 2602281600,2026-02-28T16:15Z,2026-03-01 00:15:00,0.000
+//  * </pre>
+//  * power为尽量符合物理规律的光伏出力mock: 夜间为0, 白天呈钟形曲线,
+//  * 日出日落与峰值随季节变化(夏长夏高/冬短冬低), 叠加缓慢的云量波动;
+//  * 随机参数由起报时间派生, 同一文件的生成结果稳定可复现.
+//  *
+//  * 短期气象mock为SYSU格式38列CSV, 自起报时间(含)起961点(10天), 间隔15分钟,
+//  * 文件名时间为UTC, date_time列为GMT+8(即文件名时间+8h);
+//  * t2m/rh2/sp/云量/风/ghi/dni/dhi尽量符合物理规律, 按北纬35.1度定标, 同样按起报时间可复现.
+//  *
+//  * 另含采集数据mock任务(generateCollectedData): 每5分钟向 data_weather_local 与
+//  * data_electricity_local 各插1行, tm取当前最近5分钟整北京时间, config_station_id固定为4,
+//  * 两行共享同一时刻物理状态(云量/钟形/季节), 数据尽量接近真实, 按北京日期可复现.
+//  *
+//  * @author ufo
+//  * @date 2026-10-21
+//  */
+// @Component
+// public class MockDataTask
+// {
+//     private static final Logger log = LoggerFactory.getLogger(MockDataTask.class);
+
+//     @Autowired
+//     private DataWeatherLocalMapper dataWeatherLocalMapper;
+
+//     @Autowired
+//     private DataElectricityLocalMapper dataElectricityLocalMapper;
+
+//     /** UTC时区 */
+//     private static final ZoneOffset UTC = ZoneOffset.UTC;
+
+//     /** 上海时区(UTC+8) */
+//     private static final ZoneOffset SHANGHAI = ZoneOffset.ofHours(8);
+
+//     /** time列格式(UTC, 如 2026-02-28T16:15Z) */
+//     private static final DateTimeFormatter TIME_FMT = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm'Z'");
+
+//     /** time_shanghai列格式 */
+//     private static final DateTimeFormatter TIME_SH_FMT = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
+
+//     /** 超短期文件名时间格式(yyyyMMddHHmm) */
+//     private static final DateTimeFormatter ULTRA_FILE_FMT = DateTimeFormatter.ofPattern("yyyyMMddHHmm");
+
+//     /** 超短期init_time格式(yyMMddHHmm) */
+//     private static final DateTimeFormatter ULTRA_INIT_FMT = DateTimeFormatter.ofPattern("yyMMddHHmm");
+
+//     /** 短期/中期文件名时间格式(yyyyMMddHH) */
+//     private static final DateTimeFormatter TERM_FILE_FMT = DateTimeFormatter.ofPattern("yyyyMMddHH");
+
+//     /** 短期/中期init_time格式(yyMMddHH) */
+//     private static final DateTimeFormatter TERM_INIT_FMT = DateTimeFormatter.ofPattern("yyMMddHH");
+
+//     /** 超短期数据点数(起报时间+15分钟起4小时, 共16点) */
+//     private static final int ULTRA_POINTS = 16;
+
+//     /** 短期数据点数(自起报时间(含)起288点) */
+//     private static final int SHORT_POINTS = 288;
+
+//     /** 中期数据点数(自起报时间(含)起960点) */
+//     private static final int MEDIUM_POINTS = 960;
+
+//     /** 出力上限(kW, 与采集数据mock一致, 按80000kW装机容量定标) */
+//     private static final double POWER_CAP = 80000.0;
+
+//     /** 采集数据mock固定场站ID(config_station_id) */
+//     private static final long COLLECT_STATION_ID = 4L;
+
+//     /** 采集数据mock装机容量(kW) */
+//     private static final double COLLECT_CAPACITY_KW = 80000.0;
+
+//     /** 采集数据mock理论出力定标的晴空峰值辐照度(W/m², 夏季正午晴空) */
+//     private static final double CLEAR_PEAK_REF = 850.0;
+
+//     /** 短期气象数据点数(自起报时间(含)起960个间隔, 961点) */
+//     private static final int WEATHER_POINTS = 961;
+
+//     /** 气象mock场站编号(farm_id, 同时是文件名的场站段) */
+//     private static final String WEATHER_FARM_ID = "YMPV03";
+
+//     /** 气象mock固定经度(文件名按经度-纬度顺序) */
+//     private static final double WEATHER_LON = 118.3262;
+
+//     /** 气象mock固定纬度 */
+//     private static final double WEATHER_LAT = 35.0654;
+
+//     /** 气象文件名日期格式(yyyyMMdd, UTC即北京日期) */
+//     private static final DateTimeFormatter WEATHER_FILE_DATE_FMT = DateTimeFormatter.ofPattern("yyyyMMdd");
+
+//     /** 气象date_time列格式(GMT+8) */
+//     private static final DateTimeFormatter WEATHER_TIME_FMT = DateTimeFormatter.ofPattern("yyyy-MM-dd_HH:mm:ss");
+
+//     /** 风速/风向高度序列(m) */
+//     private static final int[] WEATHER_HEIGHTS = {10, 30, 50, 70, 80, 90, 100, 120, 140, 160, 180, 200};
+
+//     /** 气象文件表头(与真实SYSU文件一致, 38列) */
+//     private static final String WEATHER_HEADER = "farm_id,date_time,lat,lon,sp,t2m,rh2,tcc,lcc,mcc,hcc,"
+//             + "spd10,spd30,spd50,spd70,spd80,spd90,spd100,spd120,spd140,spd160,spd180,spd200,"
+//             + "dir10,dir30,dir50,dir70,dir80,dir90,dir100,dir120,dir140,dir160,dir180,dir200,ghi,dni,dhi";
+
+//     /**
+//      * 超短期: 每15分钟执行一次, 以当前15分钟整点(0/15/30/45)为起报时间生成预报文件,
+//      * 数据自起报时间+15分钟至起报时间+4小时, 共16点, 间隔15分钟
+//      */
+//     @Scheduled(cron = "0 0/15 * * * ?")
+//     public void generateUltraShortTerm()
+//     {
+//         ZonedDateTime now = ZonedDateTime.now(UTC).withSecond(0).withNano(0);
+//         ZonedDateTime init = now.minusMinutes(now.getMinute() % 15);
+//         try
+//         {
+//             Path file = generateFile("UltraShortTerm", init, ULTRA_FILE_FMT, ULTRA_INIT_FMT, 15, ULTRA_POINTS);
+//             log.info("[MockDataTask] 生成超短期mock文件, file={}", file);
+//         }
+//         catch (Exception e)
+//         {
+//             log.error("[MockDataTask] 生成超短期mock文件失败, init={}", init, e);
+//         }
+//     }
+
+//     /**
+//      * 短期: 每天3点执行一次, 生成当日全部24个文件(起报时间为当日UTC 00/01/.../23时),
+//      * 每文件288点, 自起报时间(含)起, 间隔15分钟
+//      */
+//     @Scheduled(cron = "0 0 3 * * ?")
+//     public void generateShortTerm()
+//     {
+//         ZonedDateTime day0 = ZonedDateTime.now(UTC).toLocalDate().atStartOfDay(UTC);
+//         for (int hour = 0; hour < 24; hour++)
+//         {
+//             ZonedDateTime init = day0.plusHours(hour);
+//             try
+//             {
+//                 Path file = generateFile("ShortTerm", init, TERM_FILE_FMT, TERM_INIT_FMT, 0, SHORT_POINTS);
+//                 log.info("[MockDataTask] 生成短期mock文件, file={}", file);
+//             }
+//             catch (Exception e)
+//             {
+//                 log.error("[MockDataTask] 生成短期mock文件失败, init={}", init, e);
+//             }
+//         }
+//     }
+
+//     /**
+//      * 中期: 每天3点执行一次, 生成当日0点数据
+//      */
+//     @Scheduled(cron = "0 0 3 * * ?")
+//     public void generateMediumTermMidnight()
+//     {
+//         generateMediumTermFile(0);
+//     }
+
+//     /**
+//      * 中期: 每天11点执行一次, 生成当日12点数据
+//      */
+//     @Scheduled(cron = "0 0 11 * * ?")
+//     public void generateMediumTermNoon()
+//     {
+//         generateMediumTermFile(12);
+//     }
+
+//     /**
+//      * 生成单个中期mock文件(960点, 自起报时间(含)起, 间隔15分钟)
+//      *
+//      * @param hour 起报时间(当日UTC小时)
+//      */
+//     private void generateMediumTermFile(int hour)
+//     {
+//         ZonedDateTime init = ZonedDateTime.now(UTC).toLocalDate().atStartOfDay(UTC).plusHours(hour);
+//         try
+//         {
+//             Path file = generateFile("MediumTerm", init, TERM_FILE_FMT, TERM_INIT_FMT, 0, MEDIUM_POINTS);
+//             log.info("[MockDataTask] 生成中期mock文件, file={}", file);
+//         }
+//         catch (Exception e)
+//         {
+//             log.error("[MockDataTask] 生成中期mock文件失败, init={}", init, e);
+//         }
+//     }
+
+//     /**
+//      * 短期气象: 每天凌晨2点执行一次, 生成当日(北京日期)12:00 UTC起报的一个预报文件,
+//      * 自起报时间(含)起961点, 间隔15分钟, 输出到 weather/MOCK/YMPV03/;
+//      * 文件名时间为UTC, date_time列为GMT+8(即文件名时间+8h)
+//      */
+//     @Scheduled(cron = "0 0 2 * * ?")
+//     public void generateShortTermWeather()
+//     {
+//         ZonedDateTime init = LocalDate.now(SHANGHAI).atTime(12, 0).atZone(UTC);
+//         try
+//         {
+//             Path file = generateWeatherFile(init);
+//             log.info("[MockDataTask] 生成短期气象mock文件, file={}", file);
+//         }
+//         catch (Exception e)
+//         {
+//             log.error("[MockDataTask] 生成短期气象mock文件失败, init={}", init, e);
+//         }
+//     }
+
+//     /**
+//      * 采集数据: 每5分钟执行一次, 向 data_weather_local 与 data_electricity_local 各插1行,
+//      * tm为当前时间就近取整到最近5分钟整北京时间(如00:05:34→00:05:00, 00:09:12→00:10:00),
+//      * config_station_id固定为4; 两行共享同一时刻的物理状态(云量/钟形/季节), 功率与气象描述同一天气;
+//      * 理论出力为按80000kW装机容量定标的晴空钟形(夏峰~80000/冬峰~61800, 夜间0),
+//      * 实发功率=理论×慢快云量衰减×可用率(恒≤理论), 随机参数按北京日期派生, 当日数据稳定可复现
+//      */
+//     @Scheduled(cron = "0 0/5 * * * ?")
+//     public void generateCollectedData()
+//     {
+//         ZonedDateTime tm = roundToFiveMinute(ZonedDateTime.now(SHANGHAI));
+//         try
+//         {
+//             DayPhysics phys = dayPhysics(tm.toLocalDate());
+//             double tH = tm.toInstant().getEpochSecond() / 3600.0;
+//             double cosz = coszAt(phys, tm);
+//             double cloud = tccAt(phys, tH) / 100.0;
+//             double peak = 750 + 100 * phys.season;
+//             double ghi = 0.90 * peak * (1 - 0.95 * cloud) * cosz + 0.10 * peak * cosz * (1 + cloud);
+//             double ghiClear = peak * cosz * (0.9 + 0.1 * cosz);
+
+//             double hour = tm.getHour() + tm.getMinute() / 60.0;
+//             double t2m = 17 + 7 * phys.season + 5 * Math.cos(2 * Math.PI * (hour - 14.5) / 24);
+//             double rh2 = clamp(85 - 2.2 * t2m + 12 * cloud, 35, 98);
+//             double spHpa = 1013 + 3 * Math.sin(2 * Math.PI * tH / phys.tP + phys.pP);
+//             double spd10 = Math.max(0.3, phys.windBase + Math.sin(2 * Math.PI * tH / 24 + phys.pW));
+//             double dir10 = wrapDir(phys.dirBase
+//                     + 40 * Math.sin(2 * Math.PI * tH / phys.tD + phys.pD)
+//                     + 12 * Math.sin(2 * Math.PI * tH / phys.tD2 + phys.pD2));
+
+//             double theoretical = clamp(COLLECT_CAPACITY_KW * ghiClear / CLEAR_PEAK_REF, 0, COLLECT_CAPACITY_KW);
+//             double fastFluct = 1 - phys.fastAmp * (0.5 + 0.5 * Math.sin(2 * Math.PI * tH / phys.fastT + phys.fastP));
+//             double actual = clamp(theoretical * (1 - 0.90 * cloud) * fastFluct * phys.availability / 100.0, 0, theoretical);
+
+//             Date tmDate = Date.from(tm.toInstant());
+
+//             DataWeatherLocal weather = new DataWeatherLocal();
+//             weather.setTm(tmDate);
+//             weather.setConfigStationId(COLLECT_STATION_ID);
+//             weather.setIrradiance(round(ghi, 2));
+//             weather.setInclinedIrradiance(round(ghi * (1 + 0.12 * cosz), 2));
+//             weather.setTemperature(round(t2m, 2));
+//             weather.setBoardTemperature(round(t2m + 0.031 * ghi, 2));
+//             weather.setPressure(round(spHpa, 2));
+//             weather.setHumidity(round(rh2, 1));
+//             weather.setWindSpeed(round(spd10, 2));
+//             weather.setWindDirection(round(dir10, 1));
+//             weather.setDailyIrradiance(round(dailyIrradianceMj(phys, tm), 3));
+//             dataWeatherLocalMapper.insertDataWeatherLocal(weather);
+
+//             DataElectricityLocal power = new DataElectricityLocal();
+//             power.setTm(tmDate);
+//             power.setConfigStationId(COLLECT_STATION_ID);
+//             power.setActualPower(round(actual, 1));
+//             power.setTheoreticalPower(round(theoretical, 1));
+//             power.setCurtailmentPower(0.0);
+//             power.setAvailability(round(phys.availability, 2));
+//             power.setDeviceStatus(0);
+//             power.setGridStatus(1);
+//             dataElectricityLocalMapper.insertDataElectricityLocal(power);
+
+//             log.info("[MockDataTask] 生成采集数据mock, tm={}", tm.format(TIME_SH_FMT));
+//         }
+//         catch (Exception e)
+//         {
+//             log.error("[MockDataTask] 生成采集数据mock失败, tm={}", tm, e);
+//         }
+//     }
+
+//     /**
+//      * 当前北京时间就近取整到最近5分钟整点(如00:05:34→00:05:00, 00:09:12→00:10:00),
+//      * 跨午夜时自动进位到次日00:00
+//      */
+//     private static ZonedDateTime roundToFiveMinute(ZonedDateTime now)
+//     {
+//         long secs = now.getHour() * 3600L + now.getMinute() * 60L + now.getSecond();
+//         long rounded = ((secs + 150) / 300) * 300;
+//         LocalDate day = now.toLocalDate();
+//         if (rounded >= 86400L)
+//         {
+//             day = day.plusDays(1);
+//             rounded -= 86400L;
+//         }
+//         return day.atStartOfDay(SHANGHAI).plusSeconds(rounded);
+//     }
+
+//     /**
+//      * 采集数据mock: 由北京日期派生当日物理参数
+//      * (种子为当日北京午夜的epoch分钟, 当日结果稳定可复现, 跨天换新云图/风场)
+//      */
+//     private static DayPhysics dayPhysics(LocalDate day)
+//     {
+//         DayPhysics p = new DayPhysics();
+//         p.season = Math.cos(2 * Math.PI * (day.getDayOfYear() - 195.0) / 365.0);
+//         double halfDay = 5.9 + 1.4 * p.season;
+//         p.sunrise = 12 - halfDay;
+//         p.sunset = 12 + halfDay;
+
+//         Random random = new Random(day.atStartOfDay(SHANGHAI).toInstant().toEpochMilli() / 60000L);
+//         p.baseCc = 20 + 40 * random.nextDouble();
+//         p.ampCc = 10 + 20 * random.nextDouble();
+//         p.tCc = 48 + 24 * random.nextDouble();
+//         p.pCc = 2 * Math.PI * random.nextDouble();
+//         p.tP = 96 + 48 * random.nextDouble();
+//         p.pP = 2 * Math.PI * random.nextDouble();
+//         p.windBase = 3 + 2 * random.nextDouble();
+//         p.pW = 2 * Math.PI * random.nextDouble();
+//         p.dirBase = 360 * random.nextDouble();
+//         p.tD = 48 + 48 * random.nextDouble();
+//         p.pD = 2 * Math.PI * random.nextDouble();
+//         p.tD2 = 6 + 8 * random.nextDouble();
+//         p.pD2 = 2 * Math.PI * random.nextDouble();
+//         p.fastAmp = 0.02 + 0.08 * random.nextDouble();
+//         p.fastT = 1 + 1 * random.nextDouble();
+//         p.fastP = 2 * Math.PI * random.nextDouble();
+//         p.availability = 99 + random.nextDouble();
+//         return p;
+//     }
+
+//     /**
+//      * 太阳天顶角余弦近似: 夜间为0, 正午(墙钟12点)为1, 白天呈正弦钟形
+//      */
+//     private static double coszAt(DayPhysics p, ZonedDateTime t)
+//     {
+//         double hour = t.getHour() + t.getMinute() / 60.0;
+//         if (hour <= p.sunrise || hour >= p.sunset)
+//         {
+//             return 0;
+//         }
+//         return Math.sin(Math.PI * (hour - p.sunrise) / (p.sunset - p.sunrise));
+//     }
+
+//     /**
+//      * 指定epoch时刻的总云量(0~100), 慢漂移
+//      */
+//     private static double tccAt(DayPhysics p, double tH)
+//     {
+//         return clamp(p.baseCc + p.ampCc * Math.sin(2 * Math.PI * tH / p.tCc + p.pCc), 0, 100);
+//     }
+
+//     /**
+//      * 指定时刻的水平面总辐照度GHI(W/m²):
+//      * 晴空峰值随季节, 云量主要削弱直分量, 散射随云量增大, 夜间为0
+//      */
+//     private static double ghiAt(DayPhysics p, ZonedDateTime t)
+//     {
+//         double cosz = coszAt(p, t);
+//         if (cosz <= 0)
+//         {
+//             return 0;
+//         }
+//         double peak = 750 + 100 * p.season;
+//         double cloud = tccAt(p, t.toInstant().getEpochSecond() / 3600.0) / 100.0;
+//         return 0.90 * peak * (1 - 0.95 * cloud) * cosz + 0.10 * peak * cosz * (1 + cloud);
+//     }
+
+//     /**
+//      * 当日当地00:00至tm的水平面总辐照度累计(MJ/m²),
+//      * 按5分钟步长用当日物理参数积分
+//      */
+//     private static double dailyIrradianceMj(DayPhysics p, ZonedDateTime tm)
+//     {
+//         ZonedDateTime day0 = tm.toLocalDate().atStartOfDay(SHANGHAI);
+//         double mj = 0;
+//         for (long s = 0; s < tm.getHour() * 3600L + tm.getMinute() * 60L; s += 300)
+//         {
+//             mj += ghiAt(p, day0.plusSeconds(s)) * 300.0 / 1e6;
+//         }
+//         return mj;
+//     }
+
+//     /**
+//      * 按指定小数位四舍五入
+//      */
+//     private static double round(double v, int scale)
+//     {
+//         double f = Math.pow(10, scale);
+//         return Math.round(v * f) / f;
+//     }
+
+//     /**
+//      * 采集数据mock: 每北京日期一组物理参数(钟形/云量/气压/风/快云/可用率)
+//      */
+//     private static final class DayPhysics
+//     {
+//         /** 季节系数(-1冬至~1夏至) */
+//         double season;
+//         /** 日出时刻(北京墙钟小时) */
+//         double sunrise;
+//         /** 日落时刻(北京墙钟小时) */
+//         double sunset;
+//         /** 慢云量基准(%) */
+//         double baseCc;
+//         /** 慢云量幅值(%) */
+//         double ampCc;
+//         /** 慢云量周期(小时) */
+//         double tCc;
+//         /** 慢云量相位(rad) */
+//         double pCc;
+//         /** 气压漂移周期(小时) */
+//         double tP;
+//         /** 气压漂移相位(rad) */
+//         double pP;
+//         /** 风速基准(m/s) */
+//         double windBase;
+//         /** 风速日变化相位(rad) */
+//         double pW;
+//         /** 风向基准(度) */
+//         double dirBase;
+//         /** 风向慢摆周期(小时) */
+//         double tD;
+//         /** 风向慢摆相位(rad) */
+//         double pD;
+//         /** 风向快摆周期(小时) */
+//         double tD2;
+//         /** 风向快摆相位(rad) */
+//         double pD2;
+//         /** 快云量幅值(功率衰减系数) */
+//         double fastAmp;
+//         /** 快云量周期(小时) */
+//         double fastT;
+//         /** 快云量相位(rad) */
+//         double fastP;
+//         /** 可用率(%) */
+//         double availability;
+//     }
+
+//     /**
+//      * 生成单个mock预报文件
+//      *
+//      * @param type           类型目录(UltraShortTerm/ShortTerm/MediumTerm)
+//      * @param init           起报时间(UTC)
+//      * @param fileFmt        文件名时间格式
+//      * @param initFmt        init_time格式
+//      * @param firstOffsetMin 首个数据点相对起报时间的偏移(分钟)
+//      * @param points         数据点数
+//      * @return 生成的文件路径
+//      */
+//     private Path generateFile(String type, ZonedDateTime init, DateTimeFormatter fileFmt,
+//             DateTimeFormatter initFmt, int firstOffsetMin, int points) throws IOException
+//     {
+//         Path dir = Paths.get(ProjectConfig.getProfile(), "power", "MOCK", "YMPV03", type,
+//                 String.format(Locale.ROOT, "%04d", init.getYear()),
+//                 String.format(Locale.ROOT, "%02d", init.getMonthValue()),
+//                 String.format(Locale.ROOT, "%02d", init.getDayOfMonth()));
+//         Path file = dir.resolve(init.format(fileFmt) + ".csv");
+//         Files.createDirectories(dir);
+
+//         Random random = new Random(init.toInstant().toEpochMilli() / 60000L);
+//         double t0 = init.toInstant().getEpochSecond() / 3600.0;
+//         double a1 = 0.15 + 0.30 * random.nextDouble();
+//         double a2 = 0.02 + 0.06 * random.nextDouble();
+//         double p1 = 2 * Math.PI * random.nextDouble();
+//         double p2 = 2 * Math.PI * random.nextDouble();
+//         double t1 = 5 + 2 * random.nextDouble();
+//         double t2 = 1.0 + 1.0 * random.nextDouble();
+
+//         StringBuilder sb = new StringBuilder(64 + points * 52);
+//         sb.append("init_time,time,time_shanghai,power\n");
+//         String initTime = init.format(initFmt);
+//         for (int i = 0; i < points; i++)
+//         {
+//             ZonedDateTime t = init.plusMinutes((long) firstOffsetMin + 15L * i);
+//             sb.append(initTime).append(',')
+//                     .append(t.format(TIME_FMT)).append(',')
+//                     .append(t.withZoneSameInstant(SHANGHAI).format(TIME_SH_FMT)).append(',')
+//                     .append(String.format(Locale.ROOT, "%.3f",
+//                             mockPower(t, t0, a1, p1, t1, a2, p2, t2)))
+//                     .append('\n');
+//         }
+//         Files.write(file, sb.toString().getBytes(StandardCharsets.UTF_8),
+//                 StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING, StandardOpenOption.WRITE);
+//         return file;
+//     }
+
+//     /**
+//      * 计算mock光伏出力: 夜间为0, 白天钟形曲线, 峰值与日照时长随季节变化, 叠加缓慢云量波动;
+//      * 峰值按80000kW装机容量对晴空辐照定标(与采集数据mock同量纲, 夏峰~80000/冬峰~61800),
+//      * 与采集数据在相近时刻的数值接近
+//      *
+//      * @param tUtc 数据时刻(UTC)
+//      * @param t0   起报时间(epoch小时), 用于云量相位基准
+//      * @param a1   慢周期云量幅值
+//      * @param p1   慢周期云量相位
+//      * @param t1   慢周期云量周期(小时)
+//      * @param a2   快周期云量幅值
+//      * @param p2   快周期云量相位
+//      * @param t2   快周期云量周期(小时)
+//      * @return 出力值
+//      */
+//     private double mockPower(ZonedDateTime tUtc, double t0, double a1, double p1, double t1,
+//             double a2, double p2, double t2)
+//     {
+//         int doy = tUtc.toLocalDate().getDayOfYear();
+//         double season = Math.cos(2 * Math.PI * (doy - 195.0) / 365.0);
+//         double peak = COLLECT_CAPACITY_KW * (750 + 100 * season) / CLEAR_PEAK_REF;
+//         double halfDay = 5.9 + 1.4 * season;
+//         double sunrise = 12 - halfDay;
+//         double sunset = 12 + halfDay;
+
+//         ZonedDateTime local = tUtc.withZoneSameInstant(SHANGHAI);
+//         double hour = local.getHour() + local.getMinute() / 60.0;
+//         if (hour <= sunrise || hour >= sunset)
+//         {
+//             return 0.0;
+//         }
+//         double solar = Math.pow(Math.sin(Math.PI * (hour - sunrise) / (sunset - sunrise)), 1.3);
+
+//         double tHours = tUtc.toInstant().getEpochSecond() / 3600.0;
+//         double cloud1 = 1 - a1 * (0.5 + 0.5 * Math.sin(2 * Math.PI * (tHours - t0) / t1 + p1));
+//         double cloud2 = 1 - a2 * (0.5 + 0.5 * Math.sin(2 * Math.PI * (tHours - t0) / t2 + p2));
+
+//         double power = peak * solar * cloud1 * cloud2;
+//         if (power < 0)
+//         {
+//             power = 0;
+//         }
+//         if (power > POWER_CAP)
+//         {
+//             power = POWER_CAP;
+//         }
+//         return power;
+//     }
+
+//     /**
+//      * 生成短期气象mock文件(SYSU格式, 38列, 961点, 间隔15分钟)
+//      *
+//      * @param init 起报时间(12:00 UTC)
+//      * @return 生成的文件路径
+//      */
+//     private Path generateWeatherFile(ZonedDateTime init) throws IOException
+//     {
+//         Path dir = Paths.get(ProjectConfig.getProfile(), "weather", "MOCK", WEATHER_FARM_ID);
+//         String lon = String.format(Locale.ROOT, "%.4f", WEATHER_LON);
+//         String lat = String.format(Locale.ROOT, "%.4f", WEATHER_LAT);
+//         Path file = dir.resolve(String.format(Locale.ROOT, "%s_%s-%s_%s12_SYSU.csv",
+//                 WEATHER_FARM_ID, lon, lat, init.format(WEATHER_FILE_DATE_FMT)));
+//         Files.createDirectories(dir);
+
+//         Random random = new Random(init.toInstant().toEpochMilli() / 60000L);
+//         double t0 = init.toInstant().getEpochSecond() / 3600.0;
+
+//         // 每文件随机参数(由起报时间派生, 生成结果稳定可复现)
+//         double baseCc = 20 + 40 * random.nextDouble();
+//         double ampCc = 10 + 20 * random.nextDouble();
+//         double tCc = 48 + 24 * random.nextDouble();
+//         double pCc = 2 * Math.PI * random.nextDouble();
+//         double rM = 0.4 + 0.3 * random.nextDouble();
+//         double rL = (1 - rM) * (0.5 + 0.4 * random.nextDouble());
+//         double rH = 1 - rM - rL;
+//         double tP = 96 + 48 * random.nextDouble();
+//         double pP = 2 * Math.PI * random.nextDouble();
+//         double windBase = 3 + 2 * random.nextDouble();
+//         double pW = 2 * Math.PI * random.nextDouble();
+//         double alpha = 0.20 + 0.08 * random.nextDouble();
+//         double dirBase = 360 * random.nextDouble();
+//         double tD = 48 + 48 * random.nextDouble();
+//         double pD = 2 * Math.PI * random.nextDouble();
+//         double tD2 = 6 + 8 * random.nextDouble();
+//         double pD2 = 2 * Math.PI * random.nextDouble();
+//         double[] dirOffsets = new double[WEATHER_HEIGHTS.length];
+//         for (int i = 0; i < dirOffsets.length; i++)
+//         {
+//             dirOffsets[i] = (random.nextDouble() - 0.5) * 8;
+//         }
+
+//         StringBuilder sb = new StringBuilder(64 + WEATHER_POINTS * 160);
+//         sb.append(WEATHER_HEADER).append('\n');
+
+//         for (int i = 0; i < WEATHER_POINTS; i++)
+//         {
+//             ZonedDateTime t = init.plusMinutes(15L * i);
+//             ZonedDateTime local = t.withZoneSameInstant(SHANGHAI);
+//             double hour = local.getHour() + local.getMinute() / 60.0;
+//             double tHours = t.toInstant().getEpochSecond() / 3600.0;
+
+//             // 太阳: 日出日落随季节变化, cosz近似太阳高度正弦
+//             int doy = t.toLocalDate().getDayOfYear();
+//             double season = Math.cos(2 * Math.PI * (doy - 195.0) / 365.0);
+//             double halfDay = 5.9 + 1.4 * season;
+//             double sunrise = 12 - halfDay;
+//             double sunset = 12 + halfDay;
+//             double cosz = 0;
+//             if (hour > sunrise && hour < sunset)
+//             {
+//                 cosz = Math.sin(Math.PI * (hour - sunrise) / (sunset - sunrise));
+//             }
+
+//             // 云量: 总云量慢漂移, 按比例拆三层(和等于总云量)
+//             double tcc = clamp(baseCc + ampCc * Math.sin(2 * Math.PI * (tHours - t0) / tCc + pCc), 0, 100);
+//             double cloud = tcc / 100.0;
+
+//             // 温度/湿度/气压
+//             double t2m = 17 + 7 * season + 5 * Math.cos(2 * Math.PI * (hour - 14.5) / 24);
+//             double rh2 = clamp(85 - 2.2 * t2m + 12 * cloud, 35, 98);
+//             double sp = 101300 + 300 * Math.sin(2 * Math.PI * (tHours - t0) / tP + pP);
+
+//             // 风: 10m风速日变化, 幂律廓线, 风向双正弦摆动
+//             double spd10 = Math.max(0.3, windBase + Math.sin(2 * Math.PI * (tHours - t0) / 24 + pW));
+//             double dir10 = wrapDir(dirBase
+//                     + 40 * Math.sin(2 * Math.PI * (tHours - t0) / tD + pD)
+//                     + 12 * Math.sin(2 * Math.PI * (tHours - t0) / tD2 + pD2));
+
+//             // 辐照: 晴空峰值随季节, 云量主要削弱直分量, 散射随云量增大, 夜间均为0
+//             double ghi = 0, dni = 0, dhi = 0;
+//             if (cosz > 0)
+//             {
+//                 double peak = 750 + 100 * season;
+//                 dni = 0.90 * peak * (1 - 0.95 * cloud);
+//                 dhi = 0.10 * peak * cosz * (1 + cloud);
+//                 ghi = dni * cosz + dhi;
+//             }
+
+//             sb.append(WEATHER_FARM_ID).append(',')
+//                     .append(local.format(WEATHER_TIME_FMT)).append(',')
+//                     .append(lat).append(',')
+//                     .append(lon).append(',')
+//                     .append(fmt3(sp)).append(',')
+//                     .append(fmt3(t2m)).append(',')
+//                     .append(fmt3(rh2)).append(',')
+//                     .append(fmt1(tcc)).append(',')
+//                     .append(fmt1(tcc * rL)).append(',')
+//                     .append(fmt1(tcc * rM)).append(',')
+//                     .append(fmt1(tcc * rH)).append(',');
+//             for (int h = 0; h < WEATHER_HEIGHTS.length; h++)
+//             {
+//                 if (h > 0)
+//                 {
+//                     sb.append(',');
+//                 }
+//                 sb.append(fmt3(spd10 * Math.pow(WEATHER_HEIGHTS[h] / 10.0, alpha)));
+//             }
+//             sb.append(',');
+//             for (int h = 0; h < WEATHER_HEIGHTS.length; h++)
+//             {
+//                 if (h > 0)
+//                 {
+//                     sb.append(',');
+//                 }
+//                 sb.append(fmt3(wrapDir(dir10 + dirOffsets[h])));
+//             }
+//             sb.append(',')
+//                     .append(fmt3(ghi)).append(',')
+//                     .append(fmt3(dni)).append(',')
+//                     .append(fmt3(dhi)).append('\n');
+//         }
+//         Files.write(file, sb.toString().getBytes(StandardCharsets.UTF_8),
+//                 StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING, StandardOpenOption.WRITE);
+//         return file;
+//     }
+
+//     private static String fmt3(double v)
+//     {
+//         return String.format(Locale.ROOT, "%.3f", v);
+//     }
+
+//     private static String fmt1(double v)
+//     {
+//         return String.format(Locale.ROOT, "%.1f", v);
+//     }
+
+//     private static double clamp(double v, double min, double max)
+//     {
+//         return Math.max(min, Math.min(max, v));
+//     }
+
+//     private static double wrapDir(double d)
+//     {
+//         double r = d % 360;
+//         return r < 0 ? r + 360 : r;
+//     }
+// }