LargeScreenController.java 45 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897
  1. package com.cpp.web.controller.largeScreen;
  2. import cn.hutool.core.date.DateUtil;
  3. import cn.hutool.core.util.ReflectUtil;
  4. import cn.hutool.core.util.StrUtil;
  5. import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
  6. import com.cpp.common.core.cache.LocalCache;
  7. import com.cpp.common.core.domain.R;
  8. import com.cpp.common.core.domain.entity.SysDictData;
  9. import com.cpp.system.service.ISysConfigService;
  10. import com.cpp.system.service.ISysDictDataService;
  11. import com.cpp.web.domain.accuracy.AccuracyPassRate;
  12. import com.cpp.web.domain.cloud.NwpCloud;
  13. import com.cpp.web.domain.enums.DataSourcesEnum;
  14. import com.cpp.web.domain.powerGeneration.DayPowerGeneration;
  15. import com.cpp.web.domain.regulation.TempShortUsual;
  16. import com.cpp.web.domain.station.*;
  17. import com.cpp.web.domain.station.enums.ElectricFieldTypeEnum;
  18. import com.cpp.web.dto.largeScreen.*;
  19. import com.cpp.web.service.accuracy.AccuracyPassRateService;
  20. import com.cpp.web.service.cloud.NwpCloudService;
  21. import com.cpp.web.service.powerGeneation.DayPowerGenerationService;
  22. import com.cpp.web.service.station.*;
  23. import com.cpp.web.utils.DateTimeUtil;
  24. import com.cpp.web.utils.LatestDataUtil;
  25. import lombok.RequiredArgsConstructor;
  26. import org.springframework.beans.factory.annotation.Autowired;
  27. import org.springframework.web.bind.annotation.*;
  28. import java.lang.reflect.Field;
  29. import java.math.BigDecimal;
  30. import java.math.RoundingMode;
  31. import java.text.SimpleDateFormat;
  32. import java.time.LocalDate;
  33. import java.time.temporal.ChronoUnit;
  34. import java.util.*;
  35. import java.util.stream.Collectors;
  36. /**
  37. * 大屏模块
  38. *
  39. * @author whc
  40. * @date 2022-03-18 15:49:14
  41. */
  42. @RestController
  43. @RequiredArgsConstructor
  44. @RequestMapping("/largeScreenController")
  45. public class LargeScreenController {
  46. @Autowired
  47. PowerStationStatusDataService powerStationStatusDataService;
  48. @Autowired
  49. ISysConfigService configService;
  50. @Autowired
  51. ForecastPowerUltraShortTermStationService forecastPowerUltraShortTermStationService;
  52. @Autowired
  53. ForecastPowerUltraShortTermRegulationService forecastPowerUltraShortTermRegulationService;
  54. @Autowired
  55. ForecastPowerShortTermRegulationService forecastPowerShortTermRegulationService;
  56. @Autowired
  57. ElectricFieldService electricFieldService;
  58. @Autowired
  59. WindTowerStatusDataService windTowerStatusDataService;
  60. @Autowired
  61. WeatherStationStatusDataService weatherStationStatusDataService;
  62. @Autowired
  63. DayPowerGenerationService dayPowerGenerationService;
  64. @Autowired
  65. ISysDictDataService iSysDictDataService;
  66. @Autowired
  67. NwpCloudService nwpCloudService;
  68. @Autowired
  69. AccuracyPassRateService accuracyPassRateService;
  70. @GetMapping("/getBizData")
  71. public R getBizData(String forecastDay, String forecastType, String accuracyType) {
  72. // 获取所有场站
  73. List<ElectricField> electricFieldList = electricFieldService.list();
  74. // 首页左上角场站数据统计
  75. // 统计开机容量累计值
  76. BigDecimal gfOpenCapacitySum = BigDecimal.ZERO;
  77. BigDecimal fdOpenCapacitySum = BigDecimal.ZERO;
  78. // 辐照度累计值
  79. BigDecimal fzdSum = BigDecimal.ZERO;
  80. BigDecimal wsSum = BigDecimal.ZERO;
  81. int wsSumCount = 0;
  82. int fzdSumCount = 0;
  83. for (ElectricField electricField : electricFieldList) {
  84. Boolean b = LatestDataUtil.getCommunicationStatus(electricField.getStationCode());
  85. PowerStationStatusData powerStationStatusData = LatestDataUtil.getData(electricField.getStationCode(), PowerStationStatusData.class);
  86. if (ElectricFieldTypeEnum.E1.name().equals(electricField.getElectricFieldTypeEnum())) {
  87. // 获取气象站辐照度
  88. WeatherStationStatusData weatherStationStatusData = LatestDataUtil.getData(electricField.getStationCode(), WeatherStationStatusData.class);
  89. if (weatherStationStatusData != null) {
  90. fzdSum = fzdSum.add(weatherStationStatusData.getGlobalR());
  91. fzdSumCount++;
  92. }
  93. // 累计开机容量
  94. if (powerStationStatusData != null) {
  95. gfOpenCapacitySum = gfOpenCapacitySum.add(powerStationStatusData.getOpenCapacity());
  96. }
  97. } else {
  98. // 获取测风塔风速
  99. WindTowerStatusData windTowerStatusData = LatestDataUtil.getData(electricField.getStationCode(), WindTowerStatusData.class);
  100. if (windTowerStatusData != null) {
  101. wsSum = wsSum.add(windTowerStatusData.getWsHubHeight());
  102. wsSumCount++;
  103. }
  104. // 累计开机容量
  105. if (powerStationStatusData != null) {
  106. fdOpenCapacitySum = fdOpenCapacitySum.add(powerStationStatusData.getOpenCapacity());
  107. }
  108. }
  109. }
  110. // 封装首页场站数据统计
  111. ElectricFieldDataTotalDto electricFieldDataTotalDto = new ElectricFieldDataTotalDto();
  112. electricFieldDataTotalDto.setGfOpenCapcitySum(gfOpenCapacitySum);
  113. BigDecimal fzdAvg = BigDecimal.ZERO;
  114. if (fzdSum.compareTo(BigDecimal.ZERO) == 1) {
  115. fzdAvg = fzdSum.divide(new BigDecimal(fzdSumCount), 2, BigDecimal.ROUND_HALF_UP);
  116. }
  117. electricFieldDataTotalDto.setFzdAvg(fzdAvg);
  118. electricFieldDataTotalDto.setFdOpenCapcitySum(fdOpenCapacitySum);
  119. BigDecimal wsAvg = BigDecimal.ZERO;
  120. if (wsSum.compareTo(BigDecimal.ZERO) == 1) {
  121. wsAvg = wsSum.divide(new BigDecimal(wsSumCount), 2, BigDecimal.ROUND_HALF_UP);
  122. }
  123. electricFieldDataTotalDto.setWsAvg(wsAvg);
  124. Map bizDataMap = new HashMap();
  125. bizDataMap.put("electricFieldDataTotalDto", electricFieldDataTotalDto);
  126. // 计算生成数据
  127. ProductionDataTotalDto productionDataTotalDto = calGenerating();
  128. bizDataMap.put("productionDataTotalDto", productionDataTotalDto);
  129. // 获取预测发电量
  130. Map forecastGeneratingMap = calForecastGenerating();
  131. bizDataMap.put("forecastGeneratingMap", forecastGeneratingMap);
  132. // 获取首页中心侧nwp气象
  133. Map<String, List> forecastNwpMap = centerForecastNwpAvgTotal(electricFieldList);
  134. bizDataMap.put("forecastNwpMap", forecastNwpMap);
  135. //////////////// 获取首页预测对比数据 ///////////////
  136. Map<String, List> curveMap = getForecastContrast(forecastDay, forecastType);
  137. bizDataMap.put("curveMap", curveMap);
  138. /////////////// 获取首页准确率排名 ///////////////
  139. Map<String, List<AccuracyRankingDto>> accuracyRankingMap = accuracyRanking(electricFieldList);
  140. bizDataMap.put("accuracyRankingMap", accuracyRankingMap);
  141. ////////////// 获取首页地图数据 //////////////
  142. Map mapDataMap = mapData(electricFieldList);
  143. bizDataMap.put("mapDataMap", mapDataMap);
  144. return R.ok(bizDataMap);
  145. }
  146. /**
  147. * 统计首页生成数据
  148. *
  149. * @return
  150. */
  151. private ProductionDataTotalDto calGenerating() {
  152. // 当日零点
  153. Date dayStartTime = new Date(DateTimeUtil.getMillisecondsSubDay());
  154. // 获取当前时刻5分钟
  155. Date dayEndTimeFor5 = DateTimeUtil.getMomentTimeFor5Minute(System.currentTimeMillis());
  156. // 获取当日所有实际功率
  157. QueryWrapper<PowerStationStatusData> powerStationStatusDataQueryWrapper = new QueryWrapper<>();
  158. powerStationStatusDataQueryWrapper.between("time", dayStartTime, dayEndTimeFor5);
  159. List<PowerStationStatusData> powerStationStatusDataList = powerStationStatusDataService.list(powerStationStatusDataQueryWrapper);
  160. // 实际功率总和
  161. BigDecimal realPowerSum = BigDecimal.ZERO;
  162. // 理论功率总和
  163. BigDecimal theoryPowerSum = BigDecimal.ZERO;
  164. // 计算实际发电量
  165. BigDecimal realGeneratingSum = BigDecimal.ZERO;
  166. for (PowerStationStatusData powerStationStatusData : powerStationStatusDataList) {
  167. // 统计实际功率总和
  168. if (powerStationStatusData.getRealValue() != null) {
  169. realPowerSum = realPowerSum.add(powerStationStatusData.getRealValue());
  170. // 发电量(万kWh) = 实际 * 0.08 * 0.1
  171. realGeneratingSum = realGeneratingSum.add(powerStationStatusData.getRealValue().multiply(new BigDecimal("0.08")).multiply(new BigDecimal("0.1")).setScale(2, RoundingMode.HALF_UP));
  172. }
  173. // 统计理论功率总和
  174. if (powerStationStatusData.getTheoryValue() != null) {
  175. theoryPowerSum = theoryPowerSum.add(powerStationStatusData.getTheoryValue());
  176. }
  177. }
  178. // 获取中心侧预测的当日所有短期预测功率
  179. int counts = -4;
  180. // 定义日期格式
  181. SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
  182. // 定义开始日期和结束日期(使用Calendar对象)
  183. Calendar yesterdayDate = Calendar.getInstance();
  184. //得到前一天
  185. yesterdayDate.add(Calendar.DATE, -1);
  186. //得到前三天天
  187. Calendar endDate = Calendar.getInstance();
  188. endDate.add(Calendar.DAY_OF_MONTH, counts);
  189. List<DayPowerGeneration> dayPowerGenerationList = new ArrayList<>();
  190. for (; !yesterdayDate.before(endDate); yesterdayDate.add(Calendar.DATE, -1)) {
  191. QueryWrapper<DayPowerGeneration> generationWrapper = new QueryWrapper<>();
  192. generationWrapper.eq("gen_date", formatter.format(yesterdayDate.getTime()));
  193. generationWrapper.eq("prediction_data_source", "云端下发");
  194. dayPowerGenerationList = dayPowerGenerationService.list(generationWrapper);
  195. if (!dayPowerGenerationList.isEmpty()) {
  196. // 查出数据,并且有今日的预测数据,就退出当前循环。
  197. dayPowerGenerationList = dayPowerGenerationList.stream().filter(f -> f.getTime().equals(formatter.format(new Date()))).collect(Collectors.toList());
  198. if (dayPowerGenerationList.size() > 0) {
  199. break;
  200. }
  201. } else {
  202. // 否则,日期往前推一天,再查
  203. }
  204. }
  205. // 累加中心侧预测发电量
  206. BigDecimal forecastGeneratingSum = BigDecimal.ZERO;
  207. for (DayPowerGeneration dayPowerGeneration : dayPowerGenerationList) {
  208. forecastGeneratingSum = forecastGeneratingSum.add(dayPowerGeneration.getForecastPowerGeneration());
  209. }
  210. ProductionDataTotalDto productionDataTotalDto = new ProductionDataTotalDto();
  211. productionDataTotalDto.setRealGeneratingSum(realGeneratingSum);
  212. productionDataTotalDto.setForecastGeneratingSum(forecastGeneratingSum);
  213. productionDataTotalDto.setRealPowerSum(realPowerSum);
  214. productionDataTotalDto.setTheoryPowerSum(theoryPowerSum);
  215. return productionDataTotalDto;
  216. }
  217. /**
  218. * 统计首页未来10天预测总发电量
  219. *
  220. * @return
  221. */
  222. private Map calForecastGenerating() {
  223. // 获取未来10天的中心侧模型预测发电量
  224. int counts = -3;
  225. // 定义日期格式
  226. SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
  227. // 定义开始日期和结束日期(使用Calendar对象)
  228. Calendar currentDate = Calendar.getInstance();
  229. Calendar endDate = Calendar.getInstance();
  230. endDate.add(Calendar.DAY_OF_MONTH, counts);
  231. List<DayPowerGeneration> dayPowerGenerationList = new ArrayList<>();
  232. for (; !currentDate.before(endDate); currentDate.add(Calendar.DATE, -1)) {
  233. QueryWrapper<DayPowerGeneration> generationWrapper = new QueryWrapper<>();
  234. generationWrapper.eq("gen_date", formatter.format(currentDate.getTime()));
  235. generationWrapper.eq("prediction_data_source", "云端下发");
  236. dayPowerGenerationList = dayPowerGenerationService.list(generationWrapper);
  237. if (!dayPowerGenerationList.isEmpty()) {
  238. // 查出数据就退出当前循环
  239. break;
  240. } else {
  241. // 否则,日期往前推一天,再查
  242. }
  243. }
  244. // 按场时间分组
  245. Map<String, List<DayPowerGeneration>> shortTermDataGroup = dayPowerGenerationList.stream().collect(Collectors.groupingBy(s -> s.getTime()));
  246. Map<String, List> forecastGeneratingMap = new HashMap<>();
  247. // 图表x轴时间数据
  248. List<String> xDataList = new ArrayList<>();
  249. // 图表y轴发电量数据
  250. List<BigDecimal> pDataList = new ArrayList<>();
  251. // 统计每天里所有电站发电量总和
  252. if (shortTermDataGroup != null) {
  253. // 第二天
  254. Calendar nextDate = Calendar.getInstance();
  255. nextDate.add(Calendar.DAY_OF_MONTH, 1);
  256. Calendar end10Date = Calendar.getInstance();
  257. end10Date.add(Calendar.DAY_OF_MONTH, 10);
  258. for (; nextDate.before(end10Date); nextDate.add(Calendar.DATE, 1)) {
  259. String dateFormat = DateUtil.format(nextDate.getTime(), "yyyy-MM-dd");
  260. xDataList.add(dateFormat.substring(5));
  261. if (shortTermDataGroup.get(dateFormat) != null) {
  262. List<DayPowerGeneration> dayPowerGenerations = shortTermDataGroup.get(dateFormat);
  263. BigDecimal sum = BigDecimal.ZERO;
  264. for (DayPowerGeneration dayPowerGeneration : dayPowerGenerations) {
  265. sum = sum.add(dayPowerGeneration.getForecastPowerGeneration());
  266. }
  267. pDataList.add(sum);
  268. } else {
  269. pDataList.add(BigDecimal.ZERO);
  270. }
  271. }
  272. forecastGeneratingMap.put("xData", xDataList);
  273. forecastGeneratingMap.put("pData", pDataList);
  274. }
  275. return forecastGeneratingMap;
  276. }
  277. /**
  278. * 首页中心预测nwp气象站数据总体平均值
  279. *
  280. * @return
  281. */
  282. private Map<String, List> centerForecastNwpAvgTotal(List<ElectricField> list) {
  283. // 根据类型获取所有场站
  284. Map<String, List> stationMap = new HashMap();
  285. List<String> windStationCodeList = new ArrayList<>();
  286. List<String> gfStationCodeList = new ArrayList<>();
  287. for (ElectricField electricField : list) {
  288. if (electricField.getElectricFieldTypeEnum().equals("E1")) {
  289. gfStationCodeList.add(electricField.getStationCode());
  290. } else {
  291. windStationCodeList.add(electricField.getStationCode());
  292. }
  293. }
  294. stationMap.put("gf", gfStationCodeList);
  295. stationMap.put("wind", windStationCodeList);
  296. Map<String, List> forecastWeatherAvgDataMap = new HashMap<>();
  297. // 循环光和风
  298. Iterator<Map.Entry<String, List>> stationIterator = stationMap.entrySet().iterator();
  299. while (stationIterator.hasNext()) {
  300. Map.Entry<String, List> entry = stationIterator.next();
  301. List<String> stationCodeList = entry.getValue();
  302. Date dayStartTime = DateTimeUtil.getDayStartTime(System.currentTimeMillis());
  303. Date dayEndTime = DateTimeUtil.getDayLastTime(System.currentTimeMillis());
  304. Map<Long, List<NwpCloud>> nwpCloudMap = new HashMap<>();
  305. Map<String, String> nwpWshubheightMap = new HashMap<>();
  306. if (entry.getKey().equals("wind")) {
  307. // 获取字典中nwp风速轮毂设置
  308. SysDictData sysDictData = new SysDictData();
  309. sysDictData.setDictType("nwp_wshubheight");
  310. List<SysDictData> nwpWshubheightList = iSysDictDataService.selectDictDataList(sysDictData);
  311. nwpWshubheightMap = nwpWshubheightList.stream().collect(Collectors.toMap(SysDictData::getDictLabel, SysDictData::getDictValue));
  312. }
  313. if (!stationCodeList.isEmpty()) {
  314. int counts = 10;
  315. for (int i = 1; i <= counts; i++) {
  316. QueryWrapper<NwpCloud> nwpCloudQueryWrapper = new QueryWrapper<>();
  317. nwpCloudQueryWrapper.eq("forecast_how_long_ago", i);
  318. nwpCloudQueryWrapper.between("time", dayStartTime, dayEndTime);
  319. nwpCloudQueryWrapper.in("station_code", stationCodeList);
  320. List<NwpCloud> nwpCloudList = nwpCloudService.list(nwpCloudQueryWrapper);
  321. if (!nwpCloudList.isEmpty()) {
  322. nwpCloudMap = nwpCloudList.stream().collect(Collectors.groupingBy(n -> n.getTime().getTime(), Collectors.toList()));
  323. // 查出数据,并且有今日的预测数据,就退出当前循环。
  324. break;
  325. } else {
  326. // 否则,日期往前推一天,再查
  327. }
  328. }
  329. }
  330. Long momentTime = 15 * 60 * 1000L;
  331. List<ForecastNwpDto> forecastNwpDtoList = new ArrayList<>();
  332. for (Long tempTime = dayStartTime.getTime(); tempTime <= dayEndTime.getTime(); tempTime = tempTime + momentTime) {
  333. ForecastNwpDto totalForecastNwpDto = new ForecastNwpDto();
  334. totalForecastNwpDto.setTime(DateUtil.format(new Date(tempTime), "HH:mm"));
  335. if ("wind".equals(entry.getKey())) {
  336. totalForecastNwpDto.setName("平均轮毂风速");
  337. } else {
  338. totalForecastNwpDto.setName("平均总辐射");
  339. }
  340. if (nwpCloudMap.get(tempTime) != null) {
  341. // 当前时间点所有站点数据
  342. List<NwpCloud> nwpCloudList = nwpCloudMap.get(tempTime);
  343. BigDecimal sum = BigDecimal.ZERO;
  344. // 循环每个站封装点位以及统计总和
  345. for (NwpCloud nwpCloud : nwpCloudList) {
  346. if ("wind".equals(entry.getKey())) {
  347. if (nwpWshubheightMap.get(nwpCloud.getStationCode()) != null) {
  348. // 场站配置了轮毂高度,根据轮毂高度反射获取字段值
  349. Field field = ReflectUtil.getField(NwpCloud.class, "ws" + nwpWshubheightMap.get(nwpCloud.getStationCode()));
  350. // 设置为可访问,私有字段也可以访问
  351. field.setAccessible(true);
  352. try {
  353. // 获取字段值
  354. Object fieldValue = field.get(nwpCloud);
  355. sum = sum.add(new BigDecimal(fieldValue.toString()));
  356. } catch (IllegalAccessException e) {
  357. e.printStackTrace();
  358. }
  359. }
  360. } else {
  361. sum = sum.add(nwpCloud.getSwr());
  362. }
  363. }
  364. totalForecastNwpDto.setValue(sum);
  365. } else {
  366. // 时间点位为空
  367. totalForecastNwpDto.setValue(BigDecimal.ZERO);
  368. }
  369. forecastNwpDtoList.add(totalForecastNwpDto);
  370. }
  371. forecastWeatherAvgDataMap.put(entry.getKey(), forecastNwpDtoList);
  372. }
  373. return forecastWeatherAvgDataMap;
  374. }
  375. /**
  376. * 预测气象放大窗口获取每个站的数据
  377. *
  378. * @param weatherType
  379. * @return
  380. */
  381. @GetMapping("/forecastNwpFull")
  382. public R forecastNwpFull(String weatherType) {
  383. Map<String, String> nwpWshubheightMap = new HashMap<>();
  384. QueryWrapper wrapper = new QueryWrapper<>();
  385. if ("wind".equals(weatherType)) {
  386. // 过滤出风场站
  387. wrapper.eq("electric_field_type_enum", "E2");
  388. // 获取字典中nwp风速轮毂设置
  389. SysDictData sysDictData = new SysDictData();
  390. sysDictData.setDictType("nwp_wshubheight");
  391. List<SysDictData> nwpWshubheightList = iSysDictDataService.selectDictDataList(sysDictData);
  392. nwpWshubheightMap = nwpWshubheightList.stream().collect(Collectors.toMap(SysDictData::getDictLabel, SysDictData::getDictValue));
  393. } else {
  394. // 过滤出光场站
  395. wrapper.eq("electric_field_type_enum", "E1");
  396. }
  397. List<ElectricField> list = electricFieldService.list(wrapper);
  398. // 遍历获取场站nwp数据
  399. List<String> stationCodeList = new ArrayList<>();
  400. for (ElectricField electricField : list) {
  401. stationCodeList.add(electricField.getStationCode());
  402. }
  403. // 查询当日所有站的nwp数据
  404. Date dayStartTime = DateTimeUtil.getDayStartTime(System.currentTimeMillis());
  405. Date dayEndTime = DateTimeUtil.getDayLastTime(System.currentTimeMillis());
  406. Map<String, List<NwpCloud>> nwpCloudMap = new HashMap<>();
  407. if (!stationCodeList.isEmpty()) {
  408. int counts = 10;
  409. for (int i = 1; i <= counts; i++) {
  410. QueryWrapper<NwpCloud> nwpCloudQueryWrapper = new QueryWrapper<>();
  411. nwpCloudQueryWrapper.eq("forecast_how_long_ago", i);
  412. nwpCloudQueryWrapper.between("time", dayStartTime, dayEndTime);
  413. nwpCloudQueryWrapper.in("station_code", stationCodeList);
  414. List<NwpCloud> nwpCloudList = nwpCloudService.list(nwpCloudQueryWrapper);
  415. if (!nwpCloudList.isEmpty()) {
  416. nwpCloudMap = nwpCloudList.stream().collect(Collectors.groupingBy(n -> n.getStationCode(), Collectors.toList()));
  417. // 查出数据,并且有今日的预测数据,就退出当前循环。
  418. break;
  419. } else {
  420. // 否则,日期往前推一天,再查
  421. }
  422. }
  423. }
  424. Map<String, List<BigDecimal>> forecastWeatherDataMap = new HashMap<>();
  425. Long momentTime = 15 * 60 * 1000L;
  426. for (ElectricField electricField : list) {
  427. List<BigDecimal> nwpList = new ArrayList<>();
  428. // 获取场站nwp
  429. if (nwpCloudMap.get(electricField.getStationCode()) != null) {
  430. List<NwpCloud> nwpCloudList = nwpCloudMap.get(electricField.getStationCode());
  431. Map<Long, NwpCloud> tempMap = nwpCloudList.stream().collect(Collectors.toMap(s -> s.getTime().getTime(), s -> s));
  432. for (Long tempTime = dayStartTime.getTime(); tempTime <= dayEndTime.getTime(); tempTime = tempTime + momentTime) {
  433. BigDecimal value = BigDecimal.ZERO;
  434. if (tempMap.get(tempTime) != null) {
  435. NwpCloud nwpCloud = tempMap.get(tempTime);
  436. if ("wind".equals(weatherType)) {
  437. if (nwpWshubheightMap.get(nwpCloud.getStationCode()) != null) {
  438. // 场站配置了轮毂高度,根据轮毂高度反射获取字段值
  439. Field field = ReflectUtil.getField(NwpCloud.class, "ws" + nwpWshubheightMap.get(nwpCloud.getStationCode()));
  440. // 设置为可访问,私有字段也可以访问
  441. field.setAccessible(true);
  442. try {
  443. // 获取字段值
  444. Object fieldValue = field.get(nwpCloud);
  445. value = new BigDecimal(fieldValue.toString());
  446. } catch (IllegalAccessException e) {
  447. e.printStackTrace();
  448. }
  449. }
  450. } else {
  451. value = nwpCloud.getSwr();
  452. }
  453. }
  454. nwpList.add(value);
  455. }
  456. } else {
  457. for (Long tempTime = dayStartTime.getTime(); tempTime <= dayEndTime.getTime(); tempTime = tempTime + momentTime) {
  458. nwpList.add(BigDecimal.ZERO);
  459. }
  460. }
  461. forecastWeatherDataMap.put(electricField.getName(), nwpList);
  462. }
  463. return R.ok(forecastWeatherDataMap);
  464. }
  465. /**
  466. * 首页功率曲线对比
  467. *
  468. * @param forecastDay
  469. * @param forecastType
  470. * @return
  471. */
  472. @GetMapping("/forecastContrast")
  473. public R forecastContrast(String forecastDay, String forecastType) {
  474. Map<String, List> map = getForecastContrast(forecastDay, forecastType);
  475. return R.ok(map);
  476. }
  477. /**
  478. * 获取预测对比数据公共方法
  479. *
  480. * @param forecastDay
  481. * @param forecastType
  482. */
  483. private Map<String, List> getForecastContrast(String forecastDay, String forecastType) {
  484. Date dayStartTime = DateTimeUtil.getDayStartTime(System.currentTimeMillis());
  485. Date dayEndTime = null;
  486. if ("day".equals(forecastDay)) {
  487. // 当日
  488. dayEndTime = DateTimeUtil.getDayLastTime(System.currentTimeMillis());
  489. } else {
  490. // 包含当天的才是10天
  491. dayEndTime = DateUtil.offsetDay(new Date(), 9);
  492. }
  493. QueryWrapper wrapper = new QueryWrapper<>();
  494. if ("wind".equals(forecastType)) {
  495. // 过滤出风场站
  496. wrapper.eq("electric_field_type_enum", "E2");
  497. } else {
  498. // 过滤出光场站
  499. wrapper.eq("electric_field_type_enum", "E1");
  500. }
  501. List<ElectricField> list = electricFieldService.list(wrapper);
  502. // 遍历获取场站nwp数据
  503. List<String> stationCodeList = new ArrayList<>();
  504. for (ElectricField electricField : list) {
  505. stationCodeList.add(electricField.getStationCode());
  506. }
  507. // 首页实际、可用、理论曲线图数组
  508. List<Object> realList = new ArrayList<>();
  509. List<Object> ableList = new ArrayList<>();
  510. List<Object> theoryList = new ArrayList<>();
  511. List<Object> cdqList = new ArrayList<>();
  512. List<Object> dqList = new ArrayList<>();
  513. List<Object> timeList = new ArrayList<>();
  514. if (!stationCodeList.isEmpty()) {
  515. // 查询实际功率、可用、理论
  516. QueryWrapper<PowerStationStatusData> realQueryWrapper = new QueryWrapper<>();
  517. realQueryWrapper.between("time", dayStartTime, dayEndTime);
  518. realQueryWrapper.in("station_code", stationCodeList);
  519. List<PowerStationStatusData> powerStationStatusDataList = powerStationStatusDataService.list(realQueryWrapper);
  520. // 按场时间分组
  521. Map<Long, List<PowerStationStatusData>> powerStationStatusDataGroup = powerStationStatusDataList.stream().collect(Collectors.groupingBy(s -> s.getTime().getTime()));
  522. // 获取超短期
  523. String cdqHowLongAgo = configService.selectConfigByKey("cdqHowLongAgo");
  524. QueryWrapper cdqysWrapper = new QueryWrapper<>();
  525. cdqysWrapper.eq("forecast_how_long_ago", Integer.parseInt(cdqHowLongAgo));
  526. cdqysWrapper.between("time", dayStartTime, dayEndTime);
  527. cdqysWrapper.in("station_code", stationCodeList);
  528. List<ForecastPowerUltraShortTermRegulation> forecastPowerUltraShortTermStationList = forecastPowerUltraShortTermRegulationService.list(cdqysWrapper);
  529. // 按场时间分组
  530. Map<Long, List<ForecastPowerUltraShortTermRegulation>> utraShortTermStationDataGroup = forecastPowerUltraShortTermStationList.stream().collect(Collectors.groupingBy(s -> s.getTime().getTime()));
  531. // 获取短期上报
  532. String dqHowLongAgo = configService.selectConfigByKey("dqHowLongAgo");
  533. QueryWrapper dqsbWrapper = new QueryWrapper<>();
  534. dqsbWrapper.eq("forecast_how_long_ago", Integer.parseInt(dqHowLongAgo));
  535. dqsbWrapper.between("time", dayStartTime, dayEndTime);
  536. dqsbWrapper.in("station_code", stationCodeList);
  537. List<ForecastPowerShortTermRegulation> forecastPowerShortTermRegulationList = forecastPowerShortTermRegulationService.list(dqsbWrapper);
  538. // 按场时间分组
  539. Map<Long, List<ForecastPowerShortTermRegulation>> shortTermDataGroup = forecastPowerShortTermRegulationList.stream().collect(Collectors.groupingBy(s -> s.getTime().getTime()));
  540. Long momentTime = 15 * 60 * 1000L;
  541. for (Long tempTime = dayStartTime.getTime(); tempTime <= dayEndTime.getTime(); tempTime = tempTime + momentTime) {
  542. if ("day".equals(forecastDay)) {
  543. timeList.add(DateUtil.format(new Date(tempTime), "HH:mm"));
  544. } else {
  545. timeList.add(DateUtil.format(new Date(tempTime), "yyyy-MM-dd HH:mm"));
  546. }
  547. // 统计实际功率、可用、理论曲线
  548. if (powerStationStatusDataGroup.get(tempTime) != null) {
  549. // 对每个时间点的所有场站数据进行求和
  550. List<PowerStationStatusData> everyDataList = powerStationStatusDataGroup.get(tempTime);
  551. BigDecimal tempRealSum = BigDecimal.ZERO;
  552. BigDecimal tempAbleSum = BigDecimal.ZERO;
  553. BigDecimal tempTheorySum = BigDecimal.ZERO;
  554. for (PowerStationStatusData powerStationStatusData : everyDataList) {
  555. BigDecimal realValue = powerStationStatusData.getRealValue();
  556. tempRealSum = tempRealSum.add(realValue);
  557. BigDecimal ableValue = powerStationStatusData.getAbleValue();
  558. tempAbleSum = tempAbleSum.add(ableValue);
  559. BigDecimal theoryValue = powerStationStatusData.getTheoryValue();
  560. tempTheorySum = tempTheorySum.add(theoryValue);
  561. }
  562. realList.add(tempRealSum);
  563. ableList.add(tempAbleSum);
  564. theoryList.add(tempTheorySum);
  565. } else {
  566. realList.add(null);
  567. ableList.add(null);
  568. theoryList.add(null);
  569. }
  570. // 统计超短期曲线
  571. if (utraShortTermStationDataGroup.get(tempTime) != null) {
  572. // 对每个时间点的所有场站数据进行求和
  573. List<ForecastPowerUltraShortTermRegulation> everyDataList = utraShortTermStationDataGroup.get(tempTime);
  574. BigDecimal tempCdqSum = BigDecimal.ZERO;
  575. for (ForecastPowerUltraShortTermRegulation forecastPowerUltraShortTermStation : everyDataList) {
  576. BigDecimal cdqValue = forecastPowerUltraShortTermStation.getFpValue();
  577. tempCdqSum = tempCdqSum.add(cdqValue);
  578. }
  579. cdqList.add(tempCdqSum);
  580. } else {
  581. cdqList.add(null);
  582. }
  583. // 统计短期上报曲线
  584. if (shortTermDataGroup.get(tempTime) != null) {
  585. // 对每个时间点的所有场站数据进行求和
  586. List<ForecastPowerShortTermRegulation> everyDataList = shortTermDataGroup.get(tempTime);
  587. BigDecimal tempDqSum = BigDecimal.ZERO;
  588. for (ForecastPowerShortTermRegulation forecastPowerShortTermRegulation : everyDataList) {
  589. BigDecimal dqValue = forecastPowerShortTermRegulation.getFpValue();
  590. tempDqSum = tempDqSum.add(dqValue);
  591. }
  592. dqList.add(tempDqSum);
  593. } else {
  594. dqList.add(null);
  595. }
  596. }
  597. }
  598. // 定义曲线map
  599. Map<String, List> curveMap = new HashMap();
  600. curveMap.put("timeList", timeList);
  601. curveMap.put("realList", realList);
  602. curveMap.put("ableList", ableList);
  603. curveMap.put("theoryList", theoryList);
  604. curveMap.put("cdqList", cdqList);
  605. curveMap.put("dqList", dqList);
  606. return curveMap;
  607. }
  608. /**
  609. * 首页准确率排名
  610. *
  611. * @return
  612. */
  613. private Map<String, List<AccuracyRankingDto>> accuracyRanking(List<ElectricField> list) {
  614. Map<String, List<AccuracyRankingDto>> accuracyMap = new HashMap();
  615. // 昨日时间段
  616. Date startTime = DateTimeUtil.getDayStartTime(DateUtil.yesterday().getTime());
  617. Date endTime = DateTimeUtil.getDayLastTime(DateUtil.yesterday().getTime());
  618. // 上个月时间段
  619. Date lastMonthStartTime = DateTimeUtil.getMonthStartTime(System.currentTimeMillis());
  620. Date lastMonthEndTime = DateTimeUtil.getMonthLastTime(System.currentTimeMillis());
  621. // 先查询昨日的准确率
  622. String dqHowLongAgo = configService.selectConfigByKey("dqHowLongAgo");
  623. QueryWrapper<AccuracyPassRate> accuracyPassRateQueryWrapper = new QueryWrapper<>();
  624. accuracyPassRateQueryWrapper.eq("forecast_how_long_ago", dqHowLongAgo);
  625. accuracyPassRateQueryWrapper.eq("data_sources", DataSourcesEnum.E4.name());
  626. accuracyPassRateQueryWrapper.between("time", startTime, endTime);
  627. List<AccuracyPassRate> accuracyPassRateList = accuracyPassRateService.list(accuracyPassRateQueryWrapper);
  628. // 按场站编号分组
  629. Map<String, List<AccuracyPassRate>> groupByStationCode = accuracyPassRateList.stream().collect(Collectors.groupingBy(AccuracyPassRate::getStationCode));
  630. List<AccuracyRankingDto> dayRankingList = new ArrayList();
  631. for (ElectricField electricField : list) {
  632. AccuracyRankingDto accuracyRankingDto = new AccuracyRankingDto();
  633. accuracyRankingDto.setName(electricField.getName());
  634. if (groupByStationCode.get(electricField.getStationCode()) != null) {
  635. List<AccuracyPassRate> accuracyPassRateList1 = groupByStationCode.get(electricField.getStationCode());
  636. if ("无可用数据计算".equals(accuracyPassRateList1.get(0).getAccuracy())) {
  637. accuracyRankingDto.setAccuracy("0%");
  638. } else {
  639. accuracyRankingDto.setAccuracy(accuracyPassRateList1.get(0).getAccuracy());
  640. }
  641. } else {
  642. // 昨日没有此场站的准确率
  643. accuracyRankingDto.setAccuracy("0%");
  644. }
  645. dayRankingList.add(accuracyRankingDto);
  646. }
  647. dayRankingList.sort(Comparator.comparing(AccuracyRankingDto::getAccuracy).reversed().thenComparing(AccuracyRankingDto::getName));
  648. // 分配排名,允许并列
  649. int currentRank = 1;
  650. for (int i = 0; i < dayRankingList.size(); i++) {
  651. AccuracyRankingDto dto = dayRankingList.get(i);
  652. dto.setSort(currentRank + "");
  653. if (i + 1 <= dayRankingList.size() - 1) {
  654. AccuracyRankingDto nextDto = dayRankingList.get(i + 1);
  655. if (!dto.getAccuracy().equals(nextDto.getAccuracy())) {
  656. currentRank++;
  657. }
  658. }
  659. }
  660. // 查询上个月的准确率
  661. QueryWrapper<AccuracyPassRate> lastMonthQueryWrapper = new QueryWrapper<>();
  662. lastMonthQueryWrapper.eq("forecast_how_long_ago", dqHowLongAgo);
  663. lastMonthQueryWrapper.eq("data_sources", DataSourcesEnum.E4.name());
  664. lastMonthQueryWrapper.between("time", lastMonthStartTime, lastMonthEndTime);
  665. List<AccuracyPassRate> lastMonthAccuracyPassRateList = accuracyPassRateService.list(lastMonthQueryWrapper);
  666. // 按场站编号分组
  667. Map<String, List<AccuracyPassRate>> lastMonthGroupByStationCode = lastMonthAccuracyPassRateList.stream().collect(Collectors.groupingBy(AccuracyPassRate::getStationCode));
  668. List<AccuracyRankingDto> lastMonthRankingList = new ArrayList();
  669. for (ElectricField electricField : list) {
  670. AccuracyRankingDto accuracyRankingDto = new AccuracyRankingDto();
  671. accuracyRankingDto.setName(electricField.getName());
  672. if (lastMonthGroupByStationCode.get(electricField.getStationCode()) != null) {
  673. List<AccuracyPassRate> accuracyPassRateList1 = lastMonthGroupByStationCode.get(electricField.getStationCode());
  674. if ("无可用数据计算".equals(accuracyPassRateList1.get(0).getAccuracy())) {
  675. accuracyRankingDto.setAccuracy("0%");
  676. } else {
  677. accuracyRankingDto.setAccuracy(accuracyPassRateList1.get(0).getAccuracy());
  678. }
  679. } else {
  680. // 上个月没有此场站的准确率
  681. accuracyRankingDto.setAccuracy("0%");
  682. }
  683. lastMonthRankingList.add(accuracyRankingDto);
  684. }
  685. lastMonthRankingList.sort(Comparator.comparing(AccuracyRankingDto::getAccuracy).reversed().thenComparing(AccuracyRankingDto::getName));
  686. // 分配排名,允许并列
  687. int lastMonthCurrentRank = 1;
  688. for (int i = 0; i < lastMonthRankingList.size(); i++) {
  689. AccuracyRankingDto dto = lastMonthRankingList.get(i);
  690. dto.setSort(lastMonthCurrentRank + "");
  691. if (i + 1 <= lastMonthRankingList.size() - 1) {
  692. AccuracyRankingDto nextDto = lastMonthRankingList.get(i + 1);
  693. if (!dto.getAccuracy().equals(nextDto.getAccuracy())) {
  694. lastMonthCurrentRank++;
  695. }
  696. }
  697. }
  698. accuracyMap.put("dayRankingList", dayRankingList);
  699. accuracyMap.put("lastMonthRankingList", lastMonthRankingList);
  700. return accuracyMap;
  701. }
  702. /**
  703. * 首页地图数据展示
  704. *
  705. * @return
  706. */
  707. private Map mapData(List<ElectricField> list) {
  708. List<String> stationCodeList = list.stream().map(ElectricField::getStationCode).collect(Collectors.toList());
  709. // 获取当前时刻所有场站短期数据
  710. Date dqMomentDate = DateTimeUtil.getMomentTimeFor15Minute(System.currentTimeMillis());
  711. QueryWrapper dqsbWrapper = new QueryWrapper<>();
  712. dqsbWrapper.eq("time", dqMomentDate);
  713. dqsbWrapper.in("station_code", stationCodeList);
  714. List<ForecastPowerShortTermRegulation> forecastPowerShortTermRegulationList = forecastPowerShortTermRegulationService.list(dqsbWrapper);
  715. // 按场站分组
  716. Map<String, List<ForecastPowerShortTermRegulation>> shortTermDataGroupByStationCode = forecastPowerShortTermRegulationList.stream().collect(Collectors.groupingBy(ForecastPowerShortTermRegulation::getStationCode));
  717. // 超短期
  718. QueryWrapper cdqsbWrapper = new QueryWrapper<>();
  719. cdqsbWrapper.eq("time", dqMomentDate);
  720. cdqsbWrapper.in("station_code", stationCodeList);
  721. List<ForecastPowerUltraShortTermRegulation> forecastPowerUltraShortTermRegulationList = forecastPowerUltraShortTermRegulationService.list(cdqsbWrapper);
  722. // 按场站分组
  723. Map<String, List<ForecastPowerUltraShortTermRegulation>> ultraShortTermDataGroupByStationCode = forecastPowerUltraShortTermRegulationList.stream().collect(Collectors.groupingBy(ForecastPowerUltraShortTermRegulation::getStationCode));
  724. List<MapDtaDto> mapDataDtoList = new ArrayList();
  725. // 首页地图限电场站统计
  726. int xdcoutns = 0;
  727. // 通讯状态个数
  728. int txcoutns = 0;
  729. // 检修状态个数
  730. int jxcoutns = 0;
  731. // 运行状态个数
  732. int yxcoutns = 0;
  733. // 遍历所有场站封装地图展示的数据
  734. for (ElectricField electricField : list) {
  735. MapDtaDto mapDtaDto = new MapDtaDto();
  736. mapDtaDto.setName(electricField.getName());
  737. mapDtaDto.setStationCode(electricField.getStationCode());
  738. mapDtaDto.setStationType(electricField.getElectricFieldTypeEnum());
  739. mapDtaDto.setCapacity(electricField.getCapacity().setScale(2, RoundingMode.HALF_UP).toString());
  740. mapDtaDto.setLeft(electricField.getMapLeft());
  741. mapDtaDto.setTop(electricField.getMapTop());
  742. if (shortTermDataGroupByStationCode.get(electricField.getStationCode())!=null){
  743. List<ForecastPowerShortTermRegulation> forecastPowerShortTermRegulationList1 = shortTermDataGroupByStationCode.get(electricField.getStationCode());
  744. // 再对场站多条预测记录,按howlongago排序,先获取数值小的。
  745. forecastPowerShortTermRegulationList1.sort(Comparator.comparing(ForecastPowerShortTermRegulation::getForecastHowLongAgo));
  746. mapDtaDto.setDq(forecastPowerShortTermRegulationList1.get(0).getFpValue().toString());
  747. }
  748. else{
  749. mapDtaDto.setDq("0.00");
  750. }
  751. if (ultraShortTermDataGroupByStationCode.get(electricField.getStationCode())!=null){
  752. List<ForecastPowerUltraShortTermRegulation> forecastPowerShortTermRegulationList1 = ultraShortTermDataGroupByStationCode.get(electricField.getStationCode());
  753. // 再对场站多条预测记录,按howlongago排序,先获取数值小的。
  754. forecastPowerShortTermRegulationList1.sort(Comparator.comparing(ForecastPowerUltraShortTermRegulation::getForecastHowLongAgo));
  755. mapDtaDto.setCdq(forecastPowerShortTermRegulationList1.get(0).getFpValue().toString());
  756. }
  757. else{
  758. mapDtaDto.setCdq("0.00");
  759. }
  760. // 实际、可用、理论
  761. PowerStationStatusData powerStationStatusData = LatestDataUtil.getData(electricField.getStationCode(), PowerStationStatusData.class);
  762. if (powerStationStatusData != null) {
  763. mapDtaDto.setSjgl(powerStationStatusData.getRealValue().toString());
  764. mapDtaDto.setKygl(powerStationStatusData.getAbleValue().toString());
  765. mapDtaDto.setLlgl(powerStationStatusData.getTheoryValue().toString());
  766. }
  767. else{
  768. mapDtaDto.setSjgl("0.00");
  769. mapDtaDto.setKygl("0.00");
  770. mapDtaDto.setLlgl("0.00");
  771. }
  772. if (electricField.getElectricFieldTypeEnum().equals("E2")){
  773. // 风
  774. WindTowerStatusData windTowerStatusData = LatestDataUtil.getData(electricField.getStationCode(), WindTowerStatusData.class);
  775. if (windTowerStatusData != null) {
  776. mapDtaDto.setHj(windTowerStatusData.getWsHubHeight().toString());
  777. }
  778. else{
  779. mapDtaDto.setHj("0.00");
  780. }
  781. }
  782. else{
  783. // 光
  784. WeatherStationStatusData weatherStationStatusData = LatestDataUtil.getData(electricField.getStationCode(), WeatherStationStatusData.class);
  785. if (weatherStationStatusData != null) {
  786. mapDtaDto.setHj(weatherStationStatusData.getGlobalR().toString());
  787. }
  788. else{
  789. mapDtaDto.setHj("0.00");
  790. }
  791. }
  792. // 判断场站状态,先获取是否通讯
  793. boolean isCommunication = false;
  794. if (!isCommunication){
  795. // 无通讯
  796. mapDtaDto.setStatus("无通讯");
  797. txcoutns++;
  798. }
  799. else{
  800. // 判断是否检修
  801. if (powerStationStatusData != null) {
  802. // 获取站内受阻容量
  803. BigDecimal blockedCapacity = powerStationStatusData.getBlockedCapacity();
  804. if (blockedCapacity.compareTo(electricField.getCapacity().multiply(new BigDecimal(0.5)))>0){
  805. // 超出装机50%容量,认为检修
  806. mapDtaDto.setStatus("检修");
  807. jxcoutns++;
  808. }
  809. else{
  810. // 未超过50%,判断是否限电
  811. if (powerStationStatusData.getPowerRationing().intValue()==1){
  812. // 限电
  813. mapDtaDto.setStatus("限电");
  814. xdcoutns++;
  815. }
  816. else{
  817. mapDtaDto.setStatus("运行");
  818. yxcoutns++;
  819. }
  820. }
  821. }
  822. else{
  823. // 没找到实际功率记录,认为场站正常状态
  824. mapDtaDto.setStatus("运行");
  825. yxcoutns++;
  826. }
  827. }
  828. mapDataDtoList.add(mapDtaDto);
  829. }
  830. Map mapDataMap = new HashMap();
  831. mapDataMap.put("mapDataDtoList",mapDataDtoList);
  832. mapDataMap.put("xdcoutns",xdcoutns);
  833. mapDataMap.put("txcoutns",txcoutns);
  834. mapDataMap.put("jxcoutns",jxcoutns);
  835. mapDataMap.put("yxcoutns",yxcoutns);
  836. // 获取系统运行开始日期(yyyy-MM-dd)
  837. int runDays = 66;
  838. String systemRunDate = configService.selectConfigByKey("systemRunDate");
  839. try{
  840. // 计算系统运行天数
  841. LocalDate date1 = LocalDate.parse(systemRunDate);
  842. LocalDate date2 = LocalDate.parse(DateUtil.today());
  843. long days = ChronoUnit.DAYS.between(date1, date2);
  844. runDays = (int)(days+1);
  845. }
  846. catch (Exception e){
  847. e.printStackTrace();
  848. }
  849. mapDataMap.put("runDays",runDays);
  850. return mapDataMap;
  851. }
  852. }