package com.ruoyi; import cn.hutool.core.date.DateField; import cn.hutool.core.date.DateRange; import cn.hutool.core.date.DateTime; import cn.hutool.core.date.DateUtil; import cn.hutool.core.thread.ThreadUtil; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.toolkit.LambdaUtils; import com.baomidou.mybatisplus.core.toolkit.support.LambdaMeta; import com.baomidou.mybatisplus.core.toolkit.support.SFunction; import com.ruoyi.ucp.entity.StationInfoDay; import com.ruoyi.ucp.entity.StationInfoMin; import com.ruoyi.ucp.entity.TurbineInfoDay; import com.ruoyi.ucp.service.IStationInfoDayService; import com.ruoyi.ucp.service.IStationInfoMinService; import com.ruoyi.ucp.util.DatePart; import com.ruoyi.ucp.util.SqlUtil; import com.ruoyi.web.controller.JavaFunctionJobHandler; import org.apache.ibatis.reflection.property.PropertyNamer; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit4.SpringRunner; import javax.annotation.Resource; import java.util.ArrayList; import java.util.Date; import java.util.List; import java.util.Map; import java.util.stream.Collectors; @SpringBootTest//classes = RuoYiApp.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT @RunWith(SpringRunner.class) public class NewTests { @Resource private JavaFunctionJobHandler task; @Resource private IStationInfoMinService stationInfoMinService; @Resource private IStationInfoDayService stationInfoDayService; public static void main(String[] args) { //QueryWrapper queryWrapper = new QueryWrapper<>(); //queryWrapper.lambda().select(TurbineInfoDay::getRecordDate); //System.out.println(); List list = new ArrayList<>(); Double o = list.get(0); System.out.println(); } private static void aadd(SFunction a) { LambdaMeta meta = LambdaUtils.extract(a); String fieldName = PropertyNamer.methodToProperty(meta.getImplMethodName()); String string = a.toString(); System.out.println(a); } @Test public void test() { // task.calcTurbineRFDLSameDay(); // task.calcTurbine5s2SameDay(); /*Map a1 = CalcCache.fitcoef.get("GJNY_SXGS_FSG_F_WT_0040_EQ"); Map a3 = CalcCache.fitcoef.get("GJNY_SXGS_FSG_F_WT_0047_EQ"); TreeMap b1 = new TreeMap<>(); TreeMap b3 = new TreeMap<>(); b1.putAll(a1); b3.putAll(a3); StrBuilder sb = new StrBuilder(); for (Double v : b1.keySet()) { sb.append(v).append(","); } System.out.println(sb); StrBuilder sb2 = new StrBuilder(); for (Double v : b1.values()) { sb2.append(v).append(","); } System.out.println(sb2); StrBuilder sb3 = new StrBuilder(); for (Double v : b3.values()) { sb3.append(v).append(","); } System.out.println(sb3); System.out.println();*/ Date date = DateUtil.parse("2024-12-04"); // task.calcTurbineSsfsQx(date); // task.ambientTemperature(); // task.calcTurbine5s2(date); task.calcLineRfdl(date); // task.calcStationZhcyRfDl(date,"GJNY_SXGS_XZ_FDC_STA"); // task.writeReportPool(date); // task.writeReportPoolProject(date); // task.calcTurbine5s2(date); // task.calcStationSwGwCyRdl(date,"GJNY_SXGS_XZ_FDC_STA"); // task.calcStationZhcyRfDl(date); // task.writeReportPool(date); // task.writeReportPoolPjfs2(date); // task.SwdlRepair(date); // task.calcLineRfdl(date); // task.calcTurbineStateMin(date); // calcStationZhcydl(date); // calcNhglZs(date); // 创建日期范围生成器 // DateTime date = DateUtil.date(); // task.calcTurbine5s2(date); // DateTime start = DateUtil.parse("2023-06-27"); // DateTime end = DateUtil.parse("2023-09-27"); // task.calcGlqxnhSurplus(start, end); // DateRange range = DateUtil.range(start, end, DateField.DAY_OF_YEAR); // for (DateTime date : range) { // System.out.println(DateUtil.date().toString() + ":" + date.toString()); /*task.calcLineRfdl(date); //上网购网厂用电量 task.calcStationSwGwCyRdl(date); //计算综合厂用电量 task.calcStationZhcyRfDl(date);*/ // task.calcTurbineRFDL(date); // task.writeReportPoolPjfs2(date); //安全天数 // calcAQTS(time.toJdkDate()); /*task.calcLineRfdl(date,"GJNY_SXGS_ZZ_FDC_STA"); task.calcStationSwGwCyRdl(date); task.calcStationZhcyRfDl(date); task.calcLineSwGWCyDl(date); task.writeReportPool(date); task.writeReportPoolProject(date);*/ // task.calcLineSwGWCyDl(date,"GJNY_SXGS_XZ_FDC_STA"); // task.writeReportPoolProject(date); // //计算综合厂用电量 // task.calcStationZhcydl(date); // /*task.calcTurbineRFDL(date); task.calcStationRfdlFj(date); task.calcTurbine5s2(date); task.writeReportPool5SPjfsLlfdl(date);*/ // task.writeReportPool(date); // int test = task.test(date, "zuozhuang.610825F02Y0AFA10GS009DQ0251DG02RAW00", 1320); // System.out.println(test); /*task.calcLineRfdlSameDay(); task.calcStationSwGwCyDlSameDay(); task.calcStationZhcyRfDlSameDay(); task.calcLineSwGWCyDlSameDay(); task.writeReportPoolSameDay(); task.writeReportPoolProjectSameDay();*/ // } // calcTurbineRFDL(date); // task.calcTurbine5s2(date); // writeReportPool(date); // task.calcStationSspjfs(); // task.calcRealtimeTurbineZt(); } @Test public void test2() { // 创建日期范围生成器 DateTime start = DateUtil.parse("2024-10-02"); DateTime end = DateUtil.parse("2024-11-09"); DateRange range = DateUtil.range(start, end, DateField.DAY_OF_YEAR); for (DateTime date : range) { System.out.println(DateUtil.date() + ":" + date); // task.calcAQTS(date); // task.calcLineRfdl(date,"GJNY_SXGS_JSL_FDC_STA"); // task.calcStationSwGwCyRdl(date,"GJNY_SXGS_JSL_FDC_STA"); // task.calcStationZhcyRfDl(date,"GJNY_SXGS_JSL_FDC_STA"); // task.calcLineSwGWCyDl(date,"GJNY_SXGS_JSL_FDC_STA"); // task.writeReportPool(date); // task.writeReportPoolProject(date); // task.calcStationHourPjglRfdl(DateUtil.date()); task.calcTurbine5s2(date); } // task.calcStationHourPjglRfdl(DateUtil.date()); DateTime date = DateUtil.date(); // task.calcStationHourPJGL(date); // task.calcLineRfdl(date); // task.calcStationHourRFDL(date); // task.calcTurbinePjfsPjglKyglLlglMin(DateUtil.date(), 15); // task.calcStationLlglKyglSjglAgcMin(date, 15); } @Test public void test3() { // 创建日期范围生成器 DateTime start = DateUtil.parse("2024-01-01"); DateTime end = DateUtil.parse("2024-10-01"); DateRange range = DateUtil.range(start, end, DateField.MONTH); for (DateTime date : range) { System.out.println(DateUtil.date() + ":" + date); // task.calcStationRjhfdl(date); } } @Test public void test4() { // while (true){ // task.calcStationRealtimeLLgl(); // ThreadUtil.sleep(60000); // } DateTime start = DateUtil.parse("2023-12-01"); DateTime end = DateUtil.parse("2023-12-01"); DateRange range = DateUtil.range(start, end, DateField.MONTH); List stIds = new ArrayList<>(); stIds.add("GJNY_SXGS_FSG_FDC_STA"); stIds.add("GJNY_SXGS_JSL_FDC_STA"); stIds.add("GJNY_SXGS_CSL_FDC_STA"); stIds.add("GJNY_SXGS_ZZ_FDC_STA"); stIds.add("GJNY_SXGS_XZ_FDC_STA"); stIds.add("GJNY_SXGS_LJS_FDC_STA"); for (DateTime date : range) { // task.calcTurbineStateMin(date); task.predictExaminBc(stIds, date); } // task.calcGlqxnhSurplus(start, end); } @Test public void test5() { DateTime date = DateUtil.date(); // DateTime date = DateUtil.parseDate("2023-01-01"); //task.calcTurbineStateMin(date); // task.calcStationRjhfdl(date); // task.calcKhfs(date); task.calcTurbine5s2(date); //风机状态时间 task.calcTurbineStateMin(date); task.writeReportPool5SPjfsLlfdlZtsj(date); //风机日切入 task.cutInWindSpeed(date); //风机日额定风速 task.calcGlqxnh_edfs(date); task.calcPredictExamin2(date); } @Test public void test6() { DateTime begin = DateUtil.parse("2024-12-19 20:30:00"); DateTime end = DateUtil.parse("2025-01-02 14:00:00"); DateTime minEnd = begin; while (minEnd.isBefore(end)) { minEnd = DateUtil.offsetMinute(begin, 15); task.calcTurbinePjfsPjglKyglLlglMin(minEnd); task.calcStationSjglAgcPjfsHjwdDlMin(minEnd); System.out.println(begin + "," + minEnd); begin = minEnd; } } @Test public void test7() { DateTime begin = DateUtil.parse("2024-01-01"); DateTime end = DateUtil.parse("2024-11-05 14:30:00"); int i = 1; DateTime minBegin = begin, minEnd = DateUtil.offsetMinute(begin, 15); List stIds = new ArrayList<>(); stIds.add("GJNY_SXGS_FSG_FDC_STA"); stIds.add("GJNY_SXGS_JSL_FDC_STA"); stIds.add("GJNY_SXGS_CSL_FDC_STA"); stIds.add("GJNY_SXGS_ZZ_FDC_STA"); stIds.add("GJNY_SXGS_XZ_FDC_STA"); stIds.add("GJNY_SXGS_LJS_FDC_STA"); QueryWrapper wrapper = new QueryWrapper<>(); wrapper.lambda().between(StationInfoMin::getRecordDate, begin, end); List list = stationInfoMinService.list(wrapper); Map> collect = list.stream().collect(Collectors.groupingBy(m -> DateUtil.date(m.getRecordDate()).toString())); while (minEnd.isBefore(end)) { minEnd = DateUtil.offsetMinute(begin, i * 15); // task.ycbs(stIds,minBegin,minEnd,collect.get(minEnd.toString())); System.out.println(minBegin.toString() + "," + minEnd.toString()); i++; minBegin = minEnd; } } @Test public void test8() { DateTime begin = DateUtil.parse("2024-11-05 14:30:00"); DateTime end = DateUtil.parse("2024-11-07 10:00:00"); int i = 1; DateTime minBegin = begin, minEnd = DateUtil.offsetMinute(begin, 15); List stIds = new ArrayList<>(); stIds.add("GJNY_SXGS_FSG_FDC_STA"); stIds.add("GJNY_SXGS_JSL_FDC_STA"); stIds.add("GJNY_SXGS_CSL_FDC_STA"); stIds.add("GJNY_SXGS_ZZ_FDC_STA"); stIds.add("GJNY_SXGS_XZ_FDC_STA"); stIds.add("GJNY_SXGS_LJS_FDC_STA"); QueryWrapper wrapper = new QueryWrapper<>(); wrapper.lambda().between(StationInfoMin::getRecordDate, begin, end); List list = stationInfoMinService.list(wrapper); Map> collect = list.stream().collect(Collectors.groupingBy(m -> DateUtil.date(m.getRecordDate()).toString())); while (minEnd.isBefore(end)) { minEnd = DateUtil.offsetMinute(begin, i * 15); // task.ycbs2(stIds,minBegin,minEnd,collect.get(minEnd.toString())); System.out.println(minBegin.toString() + "," + minEnd.toString()); i++; minBegin = minEnd; } } @Test public void test9() { //task.calcHaBbHzSs(); DateTime date = DateUtil.date(); //Date date = DateUtil.parse("2025-01-09"); //task.calcLineRfdlSameDay_ha(); //task.calcStationSwGwCyDlSameDay_ha(); //task.calcStationZhcyRfDlSameDay(); //task.calcLineSwGWCyDlSameDay(); //task.calcTurbine5s2_ha(date); task.calcStationRfdlFj(date); task.calcHaBbHz(date); //task.calcHaBbHzSs(); //task.calcHaBbHzSs(date); } @Test public void test10() { // DateTime date = DateUtil.date(); // 创建日期范围生成器 DateTime start = DateUtil.parse("2025-01-02"); DateTime end = DateUtil.parse("2025-01-15"); DateRange range = DateUtil.range(start, end, DateField.DAY_OF_YEAR); for (DateTime date : range) { //System.out.println(DateUtil.date() + ":" + date); // //task.calcTurbineRFDL_ha(date); //task.calcLineRfdl_ha(date); // ////上网购网厂用电量 //task.calcStationSwGwCyRdl_ha(date); ////计算综合厂用电量 //task.calcStationZhcyRfDl(date); ////风机日环境温度 //task.ambientTemperature(date); ////计算日发电量--风机汇总方式 //task.calcStationRfdlFj(date); // //task.calcLineSwGWCyDl(date); // //task.calcTurbine5s2_ha(date); ////风机状态时间 //task.calcTurbineStateMin(date); ////风机日切入 //task.cutInWindSpeed(date); ////风机日额定风速 //task.calcGlqxnh_edfs(date); ////计算惠安报表汇总实时 //task.calcStationCftfsfxQfxdl(date); //task.calcMeterDlHdl(date); //task.calcStationKqmd(date); // //task.calcStationKydlzql(date); //task.calcTurbineJfplFxYxfssBll(date); //task.calcTurbineLyxs(date); //task.calcMeterDlHdl(date); //task.calcHaBbHz(date); task.calcHaBbHzSs(date); } } @Test public void test11() { while (true) { task.calcRealtimeTurbineZt(); ThreadUtil.sleep(100000); } } @Test public void test12() { DateTime end = DateUtil.beginOfDay(DateUtil.date()); DateTime start = DateUtil.offsetMonth(end, -3); task.calcGlqxnh_ha(start, end); } @Test public void test13() { DateTime end = DateUtil.date(); DateTime begin = DateUtil.beginOfDay(end); task.calcTurbineRFDL(begin, end); task.calcTurbineStateMin(begin, end); task.calcTurbine5s(begin, end, 0.1); task.calcTurbineLyxs(begin); task.calcStationCftfsfxQfxdl(begin, end); task.calcTurbineJfplFxYxfssBll(begin, end); } @Test public void test14() { DateTime start = DateUtil.parse("2025-01-01"); DateTime end = DateUtil.parse("2025-01-14"); String select4 = SqlUtil.getSelectAvg("qfxdl") + SqlUtil.getSelectSum("rfdl,rfdl_fj,kqmd,hjwd"); DateRange range = DateUtil.range(start, end, DateField.DAY_OF_YEAR); for (DateTime date : range) { System.out.println(date); List sidR = stationInfoDayService.getDatasByPartSelects(date, DatePart.DAY, select4, "station_id"); //List sidY = stationInfoDayService.getDatasByPartSelects(date, DatePart.MONTH, select4, "station_id"); System.out.println(sidR.get(0).getRfdlFj()); } } }