WindPowerInfo1Service.java 82 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729
  1. package com.gyee.generation.service;
  2. import cn.hutool.core.date.DateTime;
  3. import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
  4. import com.gyee.common.model.PointData;
  5. import com.gyee.common.model.StringUtils;
  6. import com.gyee.generation.feign.AdapterApi;
  7. import com.gyee.generation.init.CacheContext;
  8. import com.gyee.generation.model.PointData2;
  9. import com.gyee.generation.model.auto.*;
  10. import com.gyee.generation.model.vo.CompanyType;
  11. import com.gyee.generation.model.vo.Location;
  12. import com.gyee.generation.model.vo.WpType;
  13. import com.gyee.generation.service.auto.*;
  14. import com.gyee.generation.util.DateUtils;
  15. import com.gyee.generation.util.realtimesource.IEdosUtil;
  16. import com.gyee.generation.util.statisticcs.Initial;
  17. import com.xxl.job.core.util.DateUtil;
  18. import org.slf4j.Logger;
  19. import org.slf4j.LoggerFactory;
  20. import org.springframework.beans.factory.annotation.Value;
  21. import org.springframework.boot.ApplicationArguments;
  22. import org.springframework.boot.ApplicationRunner;
  23. import org.springframework.stereotype.Service;
  24. import javax.annotation.Resource;
  25. import java.math.BigDecimal;
  26. import java.net.URI;
  27. import java.text.SimpleDateFormat;
  28. import java.time.*;
  29. import java.time.format.DateTimeFormatter;
  30. import java.time.temporal.ChronoUnit;
  31. import java.util.*;
  32. import java.util.stream.Collectors;
  33. @Service
  34. public class WindPowerInfo1Service {
  35. // @Override
  36. // public void run(ApplicationArguments args) throws Exception {
  37. // Date date = new Date();
  38. //// writeGf(date);
  39. // writeReport1(date);
  40. // writeReport2(date);
  41. // writeReport3(date);
  42. // }
  43. private static final Logger logger = LoggerFactory.getLogger(WindPowerInfo1Service.class);
  44. @Resource
  45. private IEdosUtil edosUtil;
  46. @Resource
  47. private IProEconPowerstationInfoDay1Service proEconPowerstationInfoDay1Service;
  48. @Resource
  49. private IProEconEquipmentInfoDay1Service proEconEquipmentInfoDay1Service;
  50. @Resource
  51. private IProEconAnalysisSubtableBottomService iProEconAnalysisSubtableBottomService;
  52. @Resource
  53. private IStationInfoHourService stationInfoHourService;
  54. @Resource
  55. private IProBaseBackfillService iProBaseBackfillService;
  56. @Resource
  57. private IProEconEquipmentInfoJsService iProEconEquipmentInfoJsService;
  58. @Resource
  59. private AdapterApi adapter;
  60. public URI goldenUri() {
  61. return URI.create("http://10.220.1.8:8011/ts");
  62. }
  63. /**
  64. * 计算区域日信息
  65. */
  66. public void calRegionInfoDay(Date recordDate) throws Exception {
  67. Calendar c = Calendar.getInstance();
  68. c.setTime(recordDate);
  69. if (c.get(Calendar.HOUR_OF_DAY) == 0 && c.get(Calendar.MINUTE) == 0) {
  70. c.add(Calendar.DAY_OF_MONTH, -1);
  71. }
  72. recordDate = DateUtils.truncate(c.getTime());
  73. QueryWrapper<ProEconPowerstationInfoDay1> queryWrapper = new QueryWrapper<>();
  74. queryWrapper.eq("record_date", DateUtils.truncate(recordDate)).eq("location", Location.cp.getValue());
  75. List<ProEconPowerstationInfoDay1> wpinfodayls = proEconPowerstationInfoDay1Service.list(queryWrapper);
  76. // .stream()
  77. // .filter(i -> i.getRecordDate().compareTo(DateUtils.truncate(recordDate)) == 0
  78. //// && CacheContext.wpmap.containsKey(i.getWindpowerstationId())
  79. // && i.getLocation().equals(Location.cp.getValue()))
  80. // .collect(Collectors.toList());
  81. if (!wpinfodayls.isEmpty()) {
  82. Map<String, Map<String, List<ProEconPowerstationInfoDay1>>> rgmap = new HashMap<>();
  83. for (ProEconPowerstationInfoDay1 wpinfo : wpinfodayls) {
  84. if (rgmap.containsKey(wpinfo.getRegionId())) {
  85. Map<String, List<ProEconPowerstationInfoDay1>> map = rgmap.get(wpinfo.getRegionId());
  86. List<ProEconPowerstationInfoDay1> qbls = map.get(CompanyType.qb.id);
  87. List<ProEconPowerstationInfoDay1> fdls = map.get(CompanyType.fd.id);
  88. List<ProEconPowerstationInfoDay1> gfls = map.get(CompanyType.gf.id);
  89. if (wpinfo.getForeignKeyId().contains("-1")) {
  90. fdls.add(wpinfo);
  91. } else if (wpinfo.getForeignKeyId().contains("-2")) {
  92. gfls.add(wpinfo);
  93. } else if (wpinfo.getForeignKeyId().contains("0")) {
  94. qbls.add(wpinfo);
  95. }
  96. } else {
  97. Map<String, List<ProEconPowerstationInfoDay1>> map = new HashMap<>();
  98. List<ProEconPowerstationInfoDay1> qbls = new ArrayList<>();
  99. List<ProEconPowerstationInfoDay1> gfls = new ArrayList<>();
  100. List<ProEconPowerstationInfoDay1> fdls = new ArrayList<>();
  101. if (wpinfo.getForeignKeyId().contains("-1")) {
  102. fdls.add(wpinfo);
  103. } else if (wpinfo.getForeignKeyId().contains("-2")) {
  104. gfls.add(wpinfo);
  105. } else if (wpinfo.getForeignKeyId().contains("0")) {
  106. qbls.add(wpinfo);
  107. }
  108. map.put(CompanyType.qb.id, qbls);
  109. map.put(CompanyType.fd.id, fdls);
  110. map.put(CompanyType.gf.id, gfls);
  111. rgmap.put(wpinfo.getRegionId(), map);
  112. }
  113. }
  114. //判断是否有重复记录,先删除重复记录
  115. QueryWrapper<ProEconPowerstationInfoDay1> queryWrapper2 = new QueryWrapper<>();
  116. queryWrapper2.eq("record_date", DateUtils.truncate(recordDate)).eq("location", Location.rg.getValue());
  117. List<String> idls = proEconPowerstationInfoDay1Service.list(queryWrapper2)
  118. .stream()
  119. // .filter(i -> i.getRecordDate().compareTo(DateUtils.truncate(recordDate)) == 0
  120. //// && CacheContext.wpmap.containsKey(i.getWindpowerstationId())
  121. // && i.getLocation().equals(Location.rg.getValue()))
  122. .map(ProEconPowerstationInfoDay1::getId)
  123. .collect(Collectors.toList());
  124. if (idls.size() > 0) {
  125. proEconPowerstationInfoDay1Service.removeByIds(idls);
  126. }
  127. for (Map.Entry<String, Map<String, List<ProEconPowerstationInfoDay1>>> entry : rgmap.entrySet()) {
  128. Map<String, List<ProEconPowerstationInfoDay1>> map = entry.getValue();
  129. List<ProEconPowerstationInfoDay1> qbls = map.get(CompanyType.qb.id);
  130. List<ProEconPowerstationInfoDay1> fdls = map.get(CompanyType.fd.id);
  131. List<ProEconPowerstationInfoDay1> gfls = map.get(CompanyType.gf.id);
  132. // if(CacheContext.cpwpmap.size()==qbls.size())
  133. // {
  134. ProEconPowerstationInfoDay1 qb = new ProEconPowerstationInfoDay1();
  135. ProEconPowerstationInfoDay1 fd = new ProEconPowerstationInfoDay1();
  136. ProEconPowerstationInfoDay1 gf = new ProEconPowerstationInfoDay1();
  137. if (CacheContext.rgmap.containsKey(entry.getKey())) {
  138. ProBasicRegion cp = CacheContext.rgmap.get(entry.getKey());
  139. gf.setRegionId(cp.getId());
  140. gf.setRecordDate(DateUtils.truncate(recordDate));
  141. gf.setForeignKeyId(cp.getId() + "-2");
  142. gf.setLocation(Location.rg.getValue());
  143. fd.setRegionId(cp.getId());
  144. fd.setRecordDate(DateUtils.truncate(recordDate));
  145. fd.setForeignKeyId(cp.getId() + "-1");
  146. fd.setLocation(Location.rg.getValue());
  147. qb.setRegionId(cp.getId());
  148. qb.setRecordDate(DateUtils.truncate(recordDate));
  149. qb.setForeignKeyId(cp.getId() + "0");
  150. qb.setLocation(Location.rg.getValue());
  151. Initial.initial(qb);
  152. Initial.initial(fd);
  153. Initial.initial(gf);
  154. //计算区域级全部
  155. calCp(qb, qbls);
  156. //计算公司级风电场站
  157. calCp(fd, fdls);
  158. //计算公司级光电场站
  159. calCp(gf, gfls);
  160. proEconPowerstationInfoDay1Service.save(qb);
  161. proEconPowerstationInfoDay1Service.save(fd);
  162. proEconPowerstationInfoDay1Service.save(gf);
  163. }
  164. // }else
  165. // {
  166. // logger.debug("公司所属场站数量与保存的场站日信息数量不一致,未进行{0}统计-------结束", entry.getKey());
  167. //
  168. // }
  169. }
  170. }
  171. }
  172. /**
  173. * 计算公司日信息
  174. */
  175. public void calCompanyInfoDay(Date recordDate) {
  176. Calendar c = Calendar.getInstance();
  177. c.setTime(recordDate);
  178. if (c.get(Calendar.HOUR_OF_DAY) == 0 && c.get(Calendar.MINUTE) == 0) {
  179. c.add(Calendar.DAY_OF_MONTH, -1);
  180. }
  181. recordDate = DateUtils.truncate(c.getTime());
  182. QueryWrapper<ProEconPowerstationInfoDay1> queryWrapper = new QueryWrapper<>();
  183. queryWrapper.eq("record_date", DateUtils.truncate(recordDate)).eq("location", Location.wp.getValue());
  184. List<ProEconPowerstationInfoDay1> wpinfodayls = proEconPowerstationInfoDay1Service.list(queryWrapper);
  185. // .stream()
  186. // .filter(i -> i.getRecordDate().compareTo(DateUtils.truncate(recordDate)) == 0
  187. // && i.getLocation().equals(Location.wp.getValue()))
  188. // .collect(Collectors.toList());
  189. if (!wpinfodayls.isEmpty()) {
  190. Map<String, Map<String, List<ProEconPowerstationInfoDay1>>> cpmap = new HashMap<>();
  191. for (ProEconPowerstationInfoDay1 wpinfo : wpinfodayls) {
  192. if (cpmap.containsKey(wpinfo.getCompanyId())) {
  193. Map<String, List<ProEconPowerstationInfoDay1>> map = cpmap.get(wpinfo.getCompanyId());
  194. List<ProEconPowerstationInfoDay1> qbls = map.get(CompanyType.qb.id);
  195. List<ProEconPowerstationInfoDay1> fdls = map.get(CompanyType.fd.id);
  196. List<ProEconPowerstationInfoDay1> gfls = map.get(CompanyType.gf.id);
  197. if (wpinfo.getWindpowerstationId().contains(WpType.FDC.id)) {
  198. fdls.add(wpinfo);
  199. } else {
  200. gfls.add(wpinfo);
  201. }
  202. qbls.add(wpinfo);
  203. } else {
  204. Map<String, List<ProEconPowerstationInfoDay1>> map = new HashMap<>();
  205. List<ProEconPowerstationInfoDay1> qbls = new ArrayList<>();
  206. List<ProEconPowerstationInfoDay1> gfls = new ArrayList<>();
  207. List<ProEconPowerstationInfoDay1> fdls = new ArrayList<>();
  208. if (wpinfo.getWindpowerstationId().contains(WpType.FDC.id)) {
  209. fdls.add(wpinfo);
  210. } else {
  211. gfls.add(wpinfo);
  212. }
  213. qbls.add(wpinfo);
  214. map.put(CompanyType.qb.id, qbls);
  215. map.put(CompanyType.fd.id, fdls);
  216. map.put(CompanyType.gf.id, gfls);
  217. cpmap.put(wpinfo.getCompanyId(), map);
  218. }
  219. }
  220. //判断是否有重复记录,先删除重复记录
  221. QueryWrapper<ProEconPowerstationInfoDay1> queryWrapper2 = new QueryWrapper<>();
  222. queryWrapper2.eq("record_date", DateUtils.truncate(recordDate)).eq("location", Location.cp.getValue());
  223. List<String> idls = proEconPowerstationInfoDay1Service.list(queryWrapper2).stream()
  224. // .filter(i -> i.getRecordDate().compareTo(DateUtils.truncate(recordDate)) == 0
  225. // && i.getLocation().equals(Location.cp.getValue()))
  226. .map(ProEconPowerstationInfoDay1::getId)
  227. .collect(Collectors.toList());
  228. if (idls.size() > 0) {
  229. proEconPowerstationInfoDay1Service.removeByIds(idls);
  230. }
  231. for (Map.Entry<String, Map<String, List<ProEconPowerstationInfoDay1>>> entry : cpmap.entrySet()) {
  232. Map<String, List<ProEconPowerstationInfoDay1>> map = entry.getValue();
  233. List<ProEconPowerstationInfoDay1> qbls = map.get(CompanyType.qb.id);
  234. List<ProEconPowerstationInfoDay1> fdls = map.get(CompanyType.fd.id);
  235. List<ProEconPowerstationInfoDay1> gfls = map.get(CompanyType.gf.id);
  236. // if(CacheContext.cpwpmap.size()==qbls.size())
  237. // {
  238. ProEconPowerstationInfoDay1 qb = new ProEconPowerstationInfoDay1();
  239. ProEconPowerstationInfoDay1 fd = new ProEconPowerstationInfoDay1();
  240. ProEconPowerstationInfoDay1 gf = new ProEconPowerstationInfoDay1();
  241. if (CacheContext.cpmap.containsKey(entry.getKey())) {
  242. ProBasicCompany cp = CacheContext.cpmap.get(entry.getKey());
  243. gf.setRegionId(cp.getRegionId());
  244. gf.setCompanyId(cp.getId());
  245. gf.setRecordDate(DateUtils.truncate(recordDate));
  246. gf.setForeignKeyId(cp.getId() + "-2");
  247. gf.setLocation(Location.cp.getValue());
  248. fd.setRegionId(cp.getRegionId());
  249. fd.setCompanyId(cp.getId());
  250. fd.setRecordDate(DateUtils.truncate(recordDate));
  251. fd.setForeignKeyId(cp.getId() + "-1");
  252. fd.setLocation(Location.cp.getValue());
  253. qb.setRegionId(cp.getRegionId());
  254. qb.setCompanyId(cp.getId());
  255. qb.setRecordDate(DateUtils.truncate(recordDate));
  256. qb.setForeignKeyId(cp.getId() + "0");
  257. qb.setLocation(Location.cp.getValue());
  258. Initial.initial(qb);
  259. Initial.initial(fd);
  260. Initial.initial(gf);
  261. //计算公司级全部场站
  262. calCp(qb, qbls);
  263. //计算公司级风电场站
  264. calCp(fd, fdls);
  265. //计算公司级光电场站
  266. calCp(gf, gfls);
  267. proEconPowerstationInfoDay1Service.save(qb);
  268. proEconPowerstationInfoDay1Service.save(fd);
  269. proEconPowerstationInfoDay1Service.save(gf);
  270. }
  271. // }else
  272. // {
  273. // logger.debug("公司所属场站数量与保存的场站日信息数量不一致,未进行{0}统计-------结束", entry.getKey());
  274. //
  275. // }
  276. }
  277. }
  278. }
  279. private void calCp(ProEconPowerstationInfoDay1 pewp, List<ProEconPowerstationInfoDay1> ls) {
  280. if (!ls.isEmpty()) {
  281. // DoubleSummaryStatistics summaryStatistics=ls.stream().mapToDouble(ProEconPowerstationInfoDay1::getRzdfs).summaryStatistics();
  282. // //日最大风速
  283. // pewp.setRzdfs(summaryStatistics.getMax());
  284. // //日最小风速
  285. // summaryStatistics=ls.stream().mapToDouble(ProEconPowerstationInfoDay1::getRzxfs).summaryStatistics();
  286. // pewp.setRzxfs(summaryStatistics.getMin());
  287. // //日平均风速
  288. // summaryStatistics=ls.stream().mapToDouble(ProEconPowerstationInfoDay1::getRpjfs).summaryStatistics();
  289. // pewp.setRpjfs(summaryStatistics.getAverage());
  290. //
  291. // summaryStatistics=ls.stream().mapToDouble(ProEconPowerstationInfoDay1::getRzdgl).summaryStatistics();
  292. // //日最大功率
  293. // pewp.setRzdgl(summaryStatistics.getMax());
  294. // //日最小功率
  295. // summaryStatistics=ls.stream().mapToDouble(ProEconPowerstationInfoDay1::getRzxgl).summaryStatistics();
  296. // pewp.setRzxgl(summaryStatistics.getMin());
  297. // //日平均功率
  298. // summaryStatistics=ls.stream().mapToDouble(ProEconPowerstationInfoDay1::getRpjgl).summaryStatistics();
  299. // pewp.setRpjgl(summaryStatistics.getAverage());
  300. //日发电量
  301. DoubleSummaryStatistics summaryStatistics = ls.stream().mapToDouble(ProEconPowerstationInfoDay1::getRfdl).summaryStatistics();
  302. pewp.setRfdl(StringUtils.round(summaryStatistics.getSum(), 2));
  303. //日可用电量
  304. summaryStatistics = ls.stream().mapToDouble(ProEconPowerstationInfoDay1::getRkydl).summaryStatistics();
  305. pewp.setRkydl(StringUtils.round(summaryStatistics.getSum(), 2));
  306. //日理论发电量
  307. summaryStatistics = ls.stream().mapToDouble(ProEconPowerstationInfoDay1::getRllfdl).summaryStatistics();
  308. pewp.setRllfdl(StringUtils.round(summaryStatistics.getSum(), 2));
  309. //日故障损失电量
  310. summaryStatistics = ls.stream().mapToDouble(ProEconPowerstationInfoDay1::getRgzssdl).summaryStatistics();
  311. pewp.setRgzssdl(StringUtils.round(summaryStatistics.getSum(), 2));
  312. //日场内受累故障损失电量
  313. pewp.setRcnslgzssdl(StringUtils.round(summaryStatistics.getSum(), 2));
  314. //日检修损失电量
  315. summaryStatistics = ls.stream().mapToDouble(ProEconPowerstationInfoDay1::getRjxssdl).summaryStatistics();
  316. pewp.setRjxssdl(StringUtils.round(summaryStatistics.getSum(), 2));
  317. //日场内受累检修损失电量
  318. summaryStatistics = ls.stream().mapToDouble(ProEconPowerstationInfoDay1::getRcnsljxssdl).summaryStatistics();
  319. pewp.setRcnsljxssdl(StringUtils.round(summaryStatistics.getSum(), 2));
  320. //日待机损失电量
  321. summaryStatistics = ls.stream().mapToDouble(ProEconPowerstationInfoDay1::getRdjssdl).summaryStatistics();
  322. pewp.setRdjssdl(StringUtils.round(summaryStatistics.getSum(), 2));
  323. //日缺陷降出力损失电量
  324. summaryStatistics = ls.stream().mapToDouble(ProEconPowerstationInfoDay1::getRqxjclssdl).summaryStatistics();
  325. pewp.setRqxjclssdl(StringUtils.round(summaryStatistics.getSum(), 2));
  326. //日手动停机损失电量
  327. summaryStatistics = ls.stream().mapToDouble(ProEconPowerstationInfoDay1::getRsdtjssdl).summaryStatistics();
  328. pewp.setRsdtjssdl(StringUtils.round(summaryStatistics.getSum(), 2));
  329. //日性能损失电量
  330. summaryStatistics = ls.stream().mapToDouble(ProEconPowerstationInfoDay1::getRxnssdl).summaryStatistics();
  331. pewp.setRxnssdl(StringUtils.round(summaryStatistics.getSum(), 2));
  332. //日限电停机损失电量
  333. summaryStatistics = ls.stream().mapToDouble(ProEconPowerstationInfoDay1::getRxdtjssdl).summaryStatistics();
  334. pewp.setRxdtjssdl(StringUtils.round(summaryStatistics.getSum(), 2));
  335. //日限电降出力损失电量
  336. summaryStatistics = ls.stream().mapToDouble(ProEconPowerstationInfoDay1::getRxdjclssdl).summaryStatistics();
  337. pewp.setRxdjclssdl(StringUtils.round(summaryStatistics.getSum(), 2));
  338. //日场外受累电网损失电量
  339. summaryStatistics = ls.stream().mapToDouble(ProEconPowerstationInfoDay1::getRcwsldwssdl).summaryStatistics();
  340. pewp.setRcwsldwssdl(StringUtils.round(summaryStatistics.getSum(), 2));
  341. //日场外受累天气损失电量
  342. summaryStatistics = ls.stream().mapToDouble(ProEconPowerstationInfoDay1::getRcwsltqssdl).summaryStatistics();
  343. pewp.setRcwsltqssdl(StringUtils.round(summaryStatistics.getSum(), 2));
  344. //日增发电量
  345. summaryStatistics = ls.stream().mapToDouble(ProEconPowerstationInfoDay1::getRzfdl).summaryStatistics();
  346. pewp.setRzfdl(StringUtils.round(summaryStatistics.getSum(), 2));
  347. //日欠发电量
  348. summaryStatistics = ls.stream().mapToDouble(ProEconPowerstationInfoDay1::getRqfdl).summaryStatistics();
  349. pewp.setRqfdl(StringUtils.round(summaryStatistics.getSum(), 2));
  350. //日自耗电
  351. summaryStatistics = ls.stream().mapToDouble(ProEconPowerstationInfoDay1::getRzhd).summaryStatistics();
  352. pewp.setRzhd(StringUtils.round(summaryStatistics.getSum(), 2));
  353. //月发电量
  354. summaryStatistics = ls.stream().mapToDouble(ProEconPowerstationInfoDay1::getYfdl).summaryStatistics();
  355. pewp.setYfdl(StringUtils.round(summaryStatistics.getSum(), 2));
  356. //月可用电量
  357. summaryStatistics = ls.stream().mapToDouble(ProEconPowerstationInfoDay1::getYkydl).summaryStatistics();
  358. pewp.setYkydl(StringUtils.round(summaryStatistics.getSum(), 2));
  359. //月理论发电量
  360. summaryStatistics = ls.stream().mapToDouble(ProEconPowerstationInfoDay1::getYllfdl).summaryStatistics();
  361. pewp.setYllfdl(StringUtils.round(summaryStatistics.getSum(), 2));
  362. //月故障损失电量
  363. summaryStatistics = ls.stream().mapToDouble(ProEconPowerstationInfoDay1::getYgzssdl).summaryStatistics();
  364. pewp.setYgzssdl(StringUtils.round(summaryStatistics.getSum(), 2));
  365. //月场内受累故障损失电量
  366. pewp.setYcnslgzssdl(StringUtils.round(summaryStatistics.getSum(), 2));
  367. //月检修损失电量
  368. summaryStatistics = ls.stream().mapToDouble(ProEconPowerstationInfoDay1::getYjxssdl).summaryStatistics();
  369. pewp.setYjxssdl(StringUtils.round(summaryStatistics.getSum(), 2));
  370. //月场内受累检修损失电量
  371. summaryStatistics = ls.stream().mapToDouble(ProEconPowerstationInfoDay1::getYcnsljxssdl).summaryStatistics();
  372. pewp.setYcnsljxssdl(StringUtils.round(summaryStatistics.getSum(), 2));
  373. //月待机损失电量
  374. summaryStatistics = ls.stream().mapToDouble(ProEconPowerstationInfoDay1::getYdjssdl).summaryStatistics();
  375. pewp.setYdjssdl(StringUtils.round(summaryStatistics.getSum(), 2));
  376. //月缺陷降出力损失电量
  377. summaryStatistics = ls.stream().mapToDouble(ProEconPowerstationInfoDay1::getYqxjclssdl).summaryStatistics();
  378. pewp.setYqxjclssdl(StringUtils.round(summaryStatistics.getSum(), 2));
  379. //月手动停机损失电量
  380. summaryStatistics = ls.stream().mapToDouble(ProEconPowerstationInfoDay1::getYsdtjssdl).summaryStatistics();
  381. pewp.setYsdtjssdl(StringUtils.round(summaryStatistics.getSum(), 2));
  382. //月性能损失电量
  383. summaryStatistics = ls.stream().mapToDouble(ProEconPowerstationInfoDay1::getYxnssdl).summaryStatistics();
  384. pewp.setYxnssdl(StringUtils.round(summaryStatistics.getSum(), 2));
  385. //月限电停机损失电量
  386. summaryStatistics = ls.stream().mapToDouble(ProEconPowerstationInfoDay1::getYxdtjssdl).summaryStatistics();
  387. pewp.setYxdtjssdl(StringUtils.round(summaryStatistics.getSum(), 2));
  388. //月限电降出力损失电量
  389. summaryStatistics = ls.stream().mapToDouble(ProEconPowerstationInfoDay1::getYxdjclssdl).summaryStatistics();
  390. pewp.setYxdjclssdl(StringUtils.round(summaryStatistics.getSum(), 2));
  391. //月场外受累电网损失电量
  392. summaryStatistics = ls.stream().mapToDouble(ProEconPowerstationInfoDay1::getYcwsldwssdl).summaryStatistics();
  393. pewp.setYcwsldwssdl(StringUtils.round(summaryStatistics.getSum(), 2));
  394. //月场外受累天气损失电量
  395. summaryStatistics = ls.stream().mapToDouble(ProEconPowerstationInfoDay1::getYcwsltqssdl).summaryStatistics();
  396. pewp.setYcwsltqssdl(StringUtils.round(summaryStatistics.getSum(), 2));
  397. //月增发电量
  398. summaryStatistics = ls.stream().mapToDouble(ProEconPowerstationInfoDay1::getYzfdl).summaryStatistics();
  399. pewp.setYzfdl(StringUtils.round(summaryStatistics.getSum(), 2));
  400. //月欠发电量
  401. summaryStatistics = ls.stream().mapToDouble(ProEconPowerstationInfoDay1::getYqfdl).summaryStatistics();
  402. pewp.setYqfdl(StringUtils.round(summaryStatistics.getSum(), 2));
  403. //月自耗电
  404. summaryStatistics = ls.stream().mapToDouble(ProEconPowerstationInfoDay1::getYzhd).summaryStatistics();
  405. pewp.setYzhd(StringUtils.round(summaryStatistics.getSum(), 2));
  406. //年发电量
  407. summaryStatistics = ls.stream().mapToDouble(ProEconPowerstationInfoDay1::getNfdl).summaryStatistics();
  408. pewp.setNfdl(StringUtils.round(summaryStatistics.getSum(), 2));
  409. //年可用电量
  410. summaryStatistics = ls.stream().mapToDouble(ProEconPowerstationInfoDay1::getNkydl).summaryStatistics();
  411. pewp.setNkydl(StringUtils.round(summaryStatistics.getSum(), 2));
  412. //年理论发电量
  413. summaryStatistics = ls.stream().mapToDouble(ProEconPowerstationInfoDay1::getNllfdl).summaryStatistics();
  414. pewp.setNllfdl(StringUtils.round(summaryStatistics.getSum(), 2));
  415. //年故障损失电量
  416. summaryStatistics = ls.stream().mapToDouble(ProEconPowerstationInfoDay1::getNgzssdl).summaryStatistics();
  417. pewp.setNgzssdl(StringUtils.round(summaryStatistics.getSum(), 2));
  418. //年场内受累故障损失电量
  419. pewp.setNcnslgzssdl(StringUtils.round(summaryStatistics.getSum(), 2));
  420. //年检修损失电量
  421. summaryStatistics = ls.stream().mapToDouble(ProEconPowerstationInfoDay1::getNjxssdl).summaryStatistics();
  422. pewp.setNjxssdl(StringUtils.round(summaryStatistics.getSum(), 2));
  423. //年场内受累检修损失电量
  424. summaryStatistics = ls.stream().mapToDouble(ProEconPowerstationInfoDay1::getNcnsljxssdl).summaryStatistics();
  425. pewp.setNcnsljxssdl(StringUtils.round(summaryStatistics.getSum(), 2));
  426. //年待机损失电量
  427. summaryStatistics = ls.stream().mapToDouble(ProEconPowerstationInfoDay1::getNdjssdl).summaryStatistics();
  428. pewp.setNdjssdl(StringUtils.round(summaryStatistics.getSum(), 2));
  429. //年缺陷降出力损失电量
  430. summaryStatistics = ls.stream().mapToDouble(ProEconPowerstationInfoDay1::getNqxjclssdl).summaryStatistics();
  431. pewp.setNqxjclssdl(StringUtils.round(summaryStatistics.getSum(), 2));
  432. //年手动停机损失电量
  433. summaryStatistics = ls.stream().mapToDouble(ProEconPowerstationInfoDay1::getNsdtjssdl).summaryStatistics();
  434. pewp.setNsdtjssdl(StringUtils.round(summaryStatistics.getSum(), 2));
  435. //年性能损失电量
  436. summaryStatistics = ls.stream().mapToDouble(ProEconPowerstationInfoDay1::getNxnssdl).summaryStatistics();
  437. pewp.setNxnssdl(StringUtils.round(summaryStatistics.getSum(), 2));
  438. //年限电停机损失电量
  439. summaryStatistics = ls.stream().mapToDouble(ProEconPowerstationInfoDay1::getNxdtjssdl).summaryStatistics();
  440. pewp.setNxdtjssdl(StringUtils.round(summaryStatistics.getSum(), 2));
  441. //年限电降出力损失电量
  442. summaryStatistics = ls.stream().mapToDouble(ProEconPowerstationInfoDay1::getNxdjclssdl).summaryStatistics();
  443. pewp.setNxdjclssdl(StringUtils.round(summaryStatistics.getSum(), 2));
  444. //年场外受累电网损失电量
  445. summaryStatistics = ls.stream().mapToDouble(ProEconPowerstationInfoDay1::getNcwsldwssdl).summaryStatistics();
  446. pewp.setNcwsldwssdl(StringUtils.round(summaryStatistics.getSum(), 2));
  447. //年场外受累天气损失电量
  448. summaryStatistics = ls.stream().mapToDouble(ProEconPowerstationInfoDay1::getNcwsltqssdl).summaryStatistics();
  449. pewp.setNcwsltqssdl(StringUtils.round(summaryStatistics.getSum(), 2));
  450. //年增发电量
  451. summaryStatistics = ls.stream().mapToDouble(ProEconPowerstationInfoDay1::getNzfdl).summaryStatistics();
  452. pewp.setNzfdl(StringUtils.round(summaryStatistics.getSum(), 2));
  453. //年欠发电量
  454. summaryStatistics = ls.stream().mapToDouble(ProEconPowerstationInfoDay1::getNqfdl).summaryStatistics();
  455. pewp.setNqfdl(StringUtils.round(summaryStatistics.getSum(), 2));
  456. //年自耗电
  457. summaryStatistics = ls.stream().mapToDouble(ProEconPowerstationInfoDay1::getNzhd).summaryStatistics();
  458. pewp.setNzhd(StringUtils.round(summaryStatistics.getSum(), 2));
  459. }
  460. }
  461. /**
  462. * 计算场站日信息
  463. */
  464. public void calWindpowerInfoDay(Date recordDate) throws Exception {
  465. Calendar c = Calendar.getInstance();
  466. c.setTime(recordDate);
  467. if (c.get(Calendar.HOUR_OF_DAY) == 0 && c.get(Calendar.MINUTE) == 0) {
  468. c.add(Calendar.DAY_OF_MONTH, -1);
  469. }
  470. recordDate = DateUtils.truncate(c.getTime());
  471. Map<String, List<ProEconEquipmentInfoDay1>> pep1map = new HashMap<>();
  472. QueryWrapper<ProEconEquipmentInfoDay1> queryWrapper2 = new QueryWrapper<>();
  473. queryWrapper2.eq("record_date", DateUtils.truncate(recordDate));
  474. List<ProEconEquipmentInfoDay1> pep1ls = proEconEquipmentInfoDay1Service.list(queryWrapper2);
  475. if (!pep1ls.isEmpty()) {
  476. for (ProEconEquipmentInfoDay1 pep : pep1ls) {
  477. if (pep1map.containsKey(pep.getWindpowerstationId())) {
  478. List<ProEconEquipmentInfoDay1> pepls = pep1map.get(pep.getWindpowerstationId());
  479. pepls.add(pep);
  480. } else {
  481. List<ProEconEquipmentInfoDay1> pepls = new ArrayList<>();
  482. pepls.add(pep);
  483. pep1map.put(pep.getWindpowerstationId(), pepls);
  484. }
  485. }
  486. }
  487. List<String> wpls = new ArrayList<>();
  488. List<ProEconPowerstationInfoDay1> dayls = new ArrayList<>();
  489. for (ProBasicPowerstation wp : CacheContext.wpls) {
  490. if (CacheContext.wppointmap.containsKey(wp.getId())) {
  491. Map<String, ProBasicPowerstationPoint> pointmap = CacheContext.wppointmap.get(wp.getId());
  492. ProEconPowerstationInfoDay1 pewp = new ProEconPowerstationInfoDay1();
  493. Initial.initial(pewp);
  494. pewp.setRegionId(wp.getRegionId());
  495. pewp.setCompanyId(wp.getCompanyId());
  496. pewp.setRecordDate(DateUtils.truncate(recordDate));
  497. pewp.setForeignKeyId(wp.getId());
  498. pewp.setWindpowerstationId(wp.getId());
  499. pewp.setLocation(Location.wp.getValue());
  500. String type = null;
  501. if (wp.getId().contains("FDC")) {
  502. type = "FDC";
  503. } else {
  504. type = "GDC";
  505. }
  506. extracted(wp.getId(), type, pewp, pep1map);
  507. //*******************************************年信息统计*********************************************************/
  508. dayls.add(pewp);
  509. // proEconPowerstationInfoDay1Service.save(pewp);
  510. wpls.add(wp.getId());
  511. }
  512. }
  513. //判断是否有重复记录,先删除重复记录
  514. QueryWrapper<ProEconPowerstationInfoDay1> queryWrapper = new QueryWrapper<>();
  515. queryWrapper.eq("record_date", DateUtils.truncate(recordDate))
  516. .in("windpowerstation_id", wpls)
  517. .eq("location", Location.wp.getValue());
  518. List<String> idls = proEconPowerstationInfoDay1Service.list(queryWrapper).stream()
  519. // .filter(i -> i.getRecordDate().compareTo(DateUtils.truncate(recordDate)) == 0
  520. // && CacheContext.wpmap.containsKey(i.getWindpowerstationId())
  521. // && i.getLocation().equals(Location.wp.getValue()))
  522. .map(ProEconPowerstationInfoDay1::getId)
  523. .collect(Collectors.toList());
  524. if (idls.size() > 0) {
  525. proEconPowerstationInfoDay1Service.removeByIds(idls);
  526. }
  527. List<ProEconPowerstationInfoDay1> templs = new ArrayList<>();
  528. for (ProEconPowerstationInfoDay1 vo : dayls) {
  529. templs.add(vo);
  530. if (templs.size() == 1000) {
  531. proEconPowerstationInfoDay1Service.saveBatch(templs);
  532. templs = new ArrayList<>();
  533. }
  534. }
  535. if (!templs.isEmpty()) {
  536. proEconPowerstationInfoDay1Service.saveBatch(templs);
  537. }
  538. // proEconPowerstationInfoDay1Service.saveBatch(dayls);
  539. }
  540. /**
  541. * 计算项目日信息
  542. */
  543. public void calProjectInfoDay(Date recordDate) throws Exception {
  544. Calendar c = Calendar.getInstance();
  545. c.setTime(recordDate);
  546. if (c.get(Calendar.HOUR_OF_DAY) == 0 && c.get(Calendar.MINUTE) == 0) {
  547. c.add(Calendar.DAY_OF_MONTH, -1);
  548. }
  549. recordDate = DateUtils.truncate(c.getTime());
  550. Map<String, List<ProEconEquipmentInfoDay1>> pep1map = new HashMap<>();
  551. QueryWrapper<ProEconEquipmentInfoDay1> queryWrapper2 = new QueryWrapper<>();
  552. queryWrapper2.eq("record_date", DateUtils.truncate(recordDate));
  553. List<ProEconEquipmentInfoDay1> pep1ls = proEconEquipmentInfoDay1Service.list(queryWrapper2);
  554. if (!pep1ls.isEmpty()) {
  555. for (ProEconEquipmentInfoDay1 pep : pep1ls) {
  556. if (pep1map.containsKey(pep.getProjectId())) {
  557. List<ProEconEquipmentInfoDay1> pepls = pep1map.get(pep.getProjectId());
  558. pepls.add(pep);
  559. } else {
  560. List<ProEconEquipmentInfoDay1> pepls = new ArrayList<>();
  561. pepls.add(pep);
  562. pep1map.put(pep.getProjectId(), pepls);
  563. }
  564. }
  565. }
  566. List<String> pjls = new ArrayList<>();
  567. List<ProEconPowerstationInfoDay1> dayls = new ArrayList<>();
  568. for (ProBasicProject pj : CacheContext.pjls) {
  569. if (CacheContext.propointmap.containsKey(pj.getId())) {
  570. Map<String, ProBasicPowerstationPoint> pointmap = CacheContext.propointmap.get(pj.getId());
  571. String type = null;
  572. ProEconPowerstationInfoDay1 pewp = new ProEconPowerstationInfoDay1();
  573. Initial.initial(pewp);
  574. if (CacheContext.wpmap.containsKey(pj.getWindpowerstationId())) {
  575. ProBasicPowerstation wp = CacheContext.wpmap.get(pj.getWindpowerstationId());
  576. pewp.setRegionId(wp.getRegionId());
  577. pewp.setCompanyId(wp.getCompanyId());
  578. if (wp.getId().contains("FDC")) {
  579. type = "FDC";
  580. } else {
  581. type = "GDC";
  582. }
  583. }
  584. pewp.setForeignKeyId(pj.getId());
  585. pewp.setWindpowerstationId(pj.getWindpowerstationId());
  586. pewp.setProjectId(pj.getId());
  587. pewp.setLocation(Location.pj.getValue());
  588. pewp.setRecordDate(DateUtils.truncate(recordDate));
  589. extracted(pj.getId(), type, pewp, pep1map);
  590. dayls.add(pewp);
  591. // proEconPowerstationInfoDay1Service.save(pewp);
  592. pjls.add(pj.getWindpowerstationId());
  593. }
  594. }
  595. //判断是否有重复记录,先删除重复记录
  596. QueryWrapper<ProEconPowerstationInfoDay1> queryWrapper = new QueryWrapper<>();
  597. queryWrapper.eq("record_date", DateUtils.truncate(recordDate))
  598. .in("windpowerstation_id", pjls)
  599. .eq("location", Location.pj.getValue());
  600. List<String> idls = proEconPowerstationInfoDay1Service.list(queryWrapper).stream()
  601. // .filter(i -> i.getRecordDate().compareTo(DateUtils.truncate(recordDate)) == 0
  602. // && CacheContext.pjmap.containsKey(i.getProjectId())
  603. // && i.getLocation().equals(Location.pj.getValue()))
  604. .map(ProEconPowerstationInfoDay1::getId)
  605. .collect(Collectors.toList());
  606. if (idls.size() > 0) {
  607. proEconPowerstationInfoDay1Service.removeByIds(idls);
  608. }
  609. List<ProEconPowerstationInfoDay1> templs = new ArrayList<>();
  610. for (ProEconPowerstationInfoDay1 vo : dayls) {
  611. templs.add(vo);
  612. if (templs.size() == 1000) {
  613. proEconPowerstationInfoDay1Service.saveBatch(templs);
  614. templs = new ArrayList<>();
  615. }
  616. }
  617. if (!templs.isEmpty()) {
  618. proEconPowerstationInfoDay1Service.saveBatch(templs);
  619. }
  620. // proEconPowerstationInfoDay1Service.saveBatch(dayls);
  621. }
  622. /**
  623. * 计算线路日信息
  624. */
  625. public void calLineInfoDay(Date recordDate) throws Exception {
  626. Calendar c = Calendar.getInstance();
  627. c.setTime(recordDate);
  628. if (c.get(Calendar.HOUR_OF_DAY) == 0 && c.get(Calendar.MINUTE) == 0) {
  629. c.add(Calendar.DAY_OF_MONTH, -1);
  630. }
  631. recordDate = DateUtils.truncate(c.getTime());
  632. Map<String, List<ProEconEquipmentInfoDay1>> pep1map = new HashMap<>();
  633. QueryWrapper<ProEconEquipmentInfoDay1> queryWrapper2 = new QueryWrapper<>();
  634. queryWrapper2.eq("record_date", DateUtils.truncate(recordDate));
  635. List<ProEconEquipmentInfoDay1> pep1ls = proEconEquipmentInfoDay1Service.list(queryWrapper2);
  636. if (!pep1ls.isEmpty()) {
  637. for (ProEconEquipmentInfoDay1 pep : pep1ls) {
  638. if (pep1map.containsKey(pep.getLineId())) {
  639. List<ProEconEquipmentInfoDay1> pepls = pep1map.get(pep.getLineId());
  640. pepls.add(pep);
  641. } else {
  642. List<ProEconEquipmentInfoDay1> pepls = new ArrayList<>();
  643. pepls.add(pep);
  644. pep1map.put(pep.getLineId(), pepls);
  645. }
  646. }
  647. }
  648. List<String> lnls = new ArrayList<>();
  649. List<ProEconPowerstationInfoDay1> dayls = new ArrayList<>();
  650. for (ProBasicLine ln : CacheContext.lnls) {
  651. if (CacheContext.linepointmap.containsKey(ln.getId())) {
  652. Map<String, ProBasicPowerstationPoint> pointmap = CacheContext.linepointmap.get(ln.getId());
  653. String type = null;
  654. ProEconPowerstationInfoDay1 pewp = new ProEconPowerstationInfoDay1();
  655. if (CacheContext.pjmap.containsKey(ln.getProjectId())) {
  656. ProBasicProject pj = CacheContext.pjmap.get(ln.getProjectId());
  657. if (CacheContext.wpmap.containsKey(pj.getWindpowerstationId())) {
  658. ProBasicPowerstation wp = CacheContext.wpmap.get(pj.getWindpowerstationId());
  659. pewp.setRegionId(wp.getRegionId());
  660. pewp.setCompanyId(wp.getCompanyId());
  661. pewp.setWindpowerstationId(wp.getId());
  662. if (wp.getId().contains("FDC")) {
  663. type = "FDC";
  664. } else {
  665. type = "GDC";
  666. }
  667. }
  668. }
  669. Initial.initial(pewp);
  670. pewp.setForeignKeyId(ln.getId());
  671. pewp.setLineId(ln.getId());
  672. pewp.setLocation(Location.ln.getValue());
  673. pewp.setProjectId(ln.getProjectId());
  674. pewp.setRecordDate(DateUtils.truncate(recordDate));
  675. extracted(ln.getId(), type, pewp, pep1map);
  676. dayls.add(pewp);
  677. // proEconPowerstationInfoDay1Service.save(pewp);
  678. if (CacheContext.pjmap.containsKey(ln.getProjectId())) {
  679. lnls.add(CacheContext.pjmap.get(ln.getProjectId()).getWindpowerstationId());
  680. }
  681. }
  682. }
  683. //判断是否有重复记录,先删除重复记录
  684. QueryWrapper<ProEconPowerstationInfoDay1> queryWrapper = new QueryWrapper<>();
  685. queryWrapper.eq("record_date", DateUtils.truncate(recordDate))
  686. .in("windpowerstation_id", lnls)
  687. .eq("location", Location.ln.getValue());
  688. List<String> idls = proEconPowerstationInfoDay1Service.list(queryWrapper).stream()
  689. // .filter(i -> i.getRecordDate().compareTo(DateUtils.truncate(recordDate)) == 0
  690. // && CacheContext.lnmap.containsKey(i.getLineId())
  691. // && i.getLocation().equals(Location.ln.getValue()))
  692. .map(ProEconPowerstationInfoDay1::getId)
  693. .collect(Collectors.toList());
  694. if (idls.size() > 0) {
  695. proEconPowerstationInfoDay1Service.removeByIds(idls);
  696. }
  697. List<ProEconPowerstationInfoDay1> templs = new ArrayList<>();
  698. for (ProEconPowerstationInfoDay1 vo : dayls) {
  699. templs.add(vo);
  700. if (templs.size() == 1000) {
  701. proEconPowerstationInfoDay1Service.saveBatch(templs);
  702. templs = new ArrayList<>();
  703. }
  704. }
  705. if (!templs.isEmpty()) {
  706. proEconPowerstationInfoDay1Service.saveBatch(templs);
  707. }
  708. // proEconPowerstationInfoDay1Service.saveBatch(dayls);
  709. }
  710. private void extracted(String id, String type, ProEconPowerstationInfoDay1 pewp, Map<String, List<ProEconEquipmentInfoDay1>> pep1map) throws Exception {
  711. //*******************************************日信息统计*********************************************************/
  712. if (pep1map.containsKey(id) && type != null) {
  713. List<ProEconEquipmentInfoDay1> pep1ls = pep1map.get(id);
  714. if (!pep1ls.isEmpty()) {
  715. DoubleSummaryStatistics summaryStatistics = pep1ls.stream().mapToDouble(ProEconEquipmentInfoDay1::getRzdfs).summaryStatistics();
  716. //日最大风速
  717. pewp.setRzdfs(summaryStatistics.getMax());
  718. summaryStatistics = pep1ls.stream().mapToDouble(ProEconEquipmentInfoDay1::getRzxfs).summaryStatistics();
  719. //日最小风速
  720. pewp.setRzxfs(summaryStatistics.getMin());
  721. summaryStatistics = pep1ls.stream().mapToDouble(ProEconEquipmentInfoDay1::getRpjfs).summaryStatistics();
  722. //日平均风速
  723. if (type.equals("FDC")) {
  724. pewp.setRpjfs(summaryStatistics.getAverage());
  725. } else {
  726. pewp.setRpjfs(pep1ls.get(0).getRpjfs());
  727. }
  728. summaryStatistics = pep1ls.stream().mapToDouble(ProEconEquipmentInfoDay1::getRzdgl).summaryStatistics();
  729. //日最大功率
  730. pewp.setRzdgl(summaryStatistics.getMax());
  731. summaryStatistics = pep1ls.stream().mapToDouble(ProEconEquipmentInfoDay1::getRzxgl).summaryStatistics();
  732. //日最小功率
  733. pewp.setRzxgl(summaryStatistics.getMin());
  734. summaryStatistics = pep1ls.stream().mapToDouble(ProEconEquipmentInfoDay1::getRpjgl).summaryStatistics();
  735. //日平均功率
  736. pewp.setRpjgl(summaryStatistics.getAverage());
  737. summaryStatistics = pep1ls.stream().mapToDouble(ProEconEquipmentInfoDay1::getRfdl).summaryStatistics();
  738. //日发电量
  739. pewp.setRfdl(StringUtils.round(summaryStatistics.getSum(), 2));
  740. summaryStatistics = pep1ls.stream().mapToDouble(ProEconEquipmentInfoDay1::getRkydl).summaryStatistics();
  741. //日可用电量
  742. pewp.setRkydl(StringUtils.round(summaryStatistics.getSum(), 2));
  743. summaryStatistics = pep1ls.stream().mapToDouble(ProEconEquipmentInfoDay1::getRllfdl).summaryStatistics();
  744. //日理论发电量
  745. pewp.setRllfdl(StringUtils.round(summaryStatistics.getSum(), 2));
  746. summaryStatistics = pep1ls.stream().mapToDouble(ProEconEquipmentInfoDay1::getRgzssdl).summaryStatistics();
  747. //日故障损失电量
  748. pewp.setRgzssdl(StringUtils.round(summaryStatistics.getSum(), 2));
  749. summaryStatistics = pep1ls.stream().mapToDouble(ProEconEquipmentInfoDay1::getRcnslgzssdl).summaryStatistics();
  750. //日场内受累故障损失电量
  751. pewp.setRcnslgzssdl(StringUtils.round(summaryStatistics.getSum(), 2));
  752. summaryStatistics = pep1ls.stream().mapToDouble(ProEconEquipmentInfoDay1::getRjxssdl).summaryStatistics();
  753. //日检修损失电量
  754. pewp.setRjxssdl(StringUtils.round(summaryStatistics.getSum(), 2));
  755. summaryStatistics = pep1ls.stream().mapToDouble(ProEconEquipmentInfoDay1::getRcnsljxssdl).summaryStatistics();
  756. //日场内受累检修损失电量
  757. pewp.setRcnsljxssdl(StringUtils.round(summaryStatistics.getSum(), 2));
  758. summaryStatistics = pep1ls.stream().mapToDouble(ProEconEquipmentInfoDay1::getRdjssdl).summaryStatistics();
  759. //日待机损失电量
  760. pewp.setRdjssdl(StringUtils.round(summaryStatistics.getSum(), 2));
  761. summaryStatistics = pep1ls.stream().mapToDouble(ProEconEquipmentInfoDay1::getRqxjclssdl).summaryStatistics();
  762. //日缺陷降出力损失电量
  763. pewp.setRqxjclssdl(StringUtils.round(summaryStatistics.getSum(), 2));
  764. summaryStatistics = pep1ls.stream().mapToDouble(ProEconEquipmentInfoDay1::getRsdtjssdl).summaryStatistics();
  765. //日手动停机损失电量
  766. pewp.setRsdtjssdl(StringUtils.round(summaryStatistics.getSum(), 2));
  767. summaryStatistics = pep1ls.stream().mapToDouble(ProEconEquipmentInfoDay1::getRxnssdl).summaryStatistics();
  768. //日性能损失电量
  769. pewp.setRxnssdl(StringUtils.round(summaryStatistics.getSum(), 2));
  770. summaryStatistics = pep1ls.stream().mapToDouble(ProEconEquipmentInfoDay1::getRxdtjssdl).summaryStatistics();
  771. //日限电停机损失电量
  772. pewp.setRxdtjssdl(StringUtils.round(summaryStatistics.getSum(), 2));
  773. summaryStatistics = pep1ls.stream().mapToDouble(ProEconEquipmentInfoDay1::getRxdjclssdl).summaryStatistics();
  774. //日限电降出力损失电量
  775. pewp.setRxdjclssdl(StringUtils.round(summaryStatistics.getSum(), 2));
  776. summaryStatistics = pep1ls.stream().mapToDouble(ProEconEquipmentInfoDay1::getRcwsldwssdl).summaryStatistics();
  777. //日场外受累电网损失电量
  778. pewp.setRcwsldwssdl(StringUtils.round(summaryStatistics.getSum(), 2));
  779. summaryStatistics = pep1ls.stream().mapToDouble(ProEconEquipmentInfoDay1::getRcwsltqssdl).summaryStatistics();
  780. //日场外受累天气损失电量
  781. pewp.setRcwsltqssdl(StringUtils.round(summaryStatistics.getSum(), 2));
  782. summaryStatistics = pep1ls.stream().mapToDouble(ProEconEquipmentInfoDay1::getRzfdl).summaryStatistics();
  783. //日增发电量
  784. pewp.setRzfdl(StringUtils.round(summaryStatistics.getSum(), 2));
  785. summaryStatistics = pep1ls.stream().mapToDouble(ProEconEquipmentInfoDay1::getRqfdl).summaryStatistics();
  786. //日欠发电量
  787. pewp.setRqfdl(StringUtils.round(summaryStatistics.getSum(), 2));
  788. summaryStatistics = pep1ls.stream().mapToDouble(ProEconEquipmentInfoDay1::getRzhd).summaryStatistics();
  789. //日自耗电
  790. pewp.setRzhd(StringUtils.round(summaryStatistics.getSum(), 2));
  791. }
  792. }
  793. //*******************************************日信息统计*********************************************************/
  794. //*******************************************月信息统计*********************************************************/
  795. if (pep1map.containsKey(id)) {
  796. List<ProEconEquipmentInfoDay1> pep1ls = pep1map.get(id);
  797. if (!pep1ls.isEmpty()) {
  798. DoubleSummaryStatistics summaryStatistics = pep1ls.stream().mapToDouble(ProEconEquipmentInfoDay1::getYzdfs).summaryStatistics();
  799. //月最大风速
  800. pewp.setYzdfs(summaryStatistics.getMax());
  801. summaryStatistics = pep1ls.stream().mapToDouble(ProEconEquipmentInfoDay1::getYzxfs).summaryStatistics();
  802. //月最小风速
  803. pewp.setYzxfs(summaryStatistics.getMin());
  804. summaryStatistics = pep1ls.stream().mapToDouble(ProEconEquipmentInfoDay1::getYpjfs).summaryStatistics();
  805. //日平均风速
  806. if (type.equals("FDC")) {
  807. //月平均风速
  808. pewp.setYpjfs(summaryStatistics.getAverage());
  809. } else {
  810. //月平均风速
  811. pewp.setYpjfs(pep1ls.get(0).getYpjfs());
  812. }
  813. summaryStatistics = pep1ls.stream().mapToDouble(ProEconEquipmentInfoDay1::getYzdgl).summaryStatistics();
  814. //月最大功率
  815. pewp.setYzdgl(summaryStatistics.getMax());
  816. summaryStatistics = pep1ls.stream().mapToDouble(ProEconEquipmentInfoDay1::getYzxgl).summaryStatistics();
  817. //月最小功率
  818. pewp.setYzxgl(summaryStatistics.getMin());
  819. summaryStatistics = pep1ls.stream().mapToDouble(ProEconEquipmentInfoDay1::getYpjgl).summaryStatistics();
  820. //月平均功率
  821. pewp.setYpjgl(summaryStatistics.getAverage());
  822. summaryStatistics = pep1ls.stream().mapToDouble(ProEconEquipmentInfoDay1::getYfdl).summaryStatistics();
  823. //月发电量
  824. pewp.setYfdl(StringUtils.round(summaryStatistics.getSum(), 2));
  825. summaryStatistics = pep1ls.stream().mapToDouble(ProEconEquipmentInfoDay1::getYkydl).summaryStatistics();
  826. //月可用电量
  827. pewp.setYkydl(StringUtils.round(summaryStatistics.getSum(), 2));
  828. summaryStatistics = pep1ls.stream().mapToDouble(ProEconEquipmentInfoDay1::getYllfdl).summaryStatistics();
  829. //月理论发电量
  830. pewp.setYllfdl(StringUtils.round(summaryStatistics.getSum(), 2));
  831. summaryStatistics = pep1ls.stream().mapToDouble(ProEconEquipmentInfoDay1::getYgzssdl).summaryStatistics();
  832. //月故障损失电量
  833. pewp.setYgzssdl(StringUtils.round(summaryStatistics.getSum(), 2));
  834. summaryStatistics = pep1ls.stream().mapToDouble(ProEconEquipmentInfoDay1::getYcnslgzssdl).summaryStatistics();
  835. //月场内受累故障损失电量
  836. pewp.setYcnslgzssdl(StringUtils.round(summaryStatistics.getSum(), 2));
  837. summaryStatistics = pep1ls.stream().mapToDouble(ProEconEquipmentInfoDay1::getYjxssdl).summaryStatistics();
  838. //月检修损失电量
  839. pewp.setYjxssdl(StringUtils.round(summaryStatistics.getSum(), 2));
  840. summaryStatistics = pep1ls.stream().mapToDouble(ProEconEquipmentInfoDay1::getYcnsljxssdl).summaryStatistics();
  841. //月场内受累检修损失电量
  842. pewp.setYcnsljxssdl(StringUtils.round(summaryStatistics.getSum(), 2));
  843. summaryStatistics = pep1ls.stream().mapToDouble(ProEconEquipmentInfoDay1::getYdjssdl).summaryStatistics();
  844. //月待机损失电量
  845. pewp.setYdjssdl(StringUtils.round(summaryStatistics.getSum(), 2));
  846. summaryStatistics = pep1ls.stream().mapToDouble(ProEconEquipmentInfoDay1::getYqxjclssdl).summaryStatistics();
  847. //月缺陷降出力损失电量
  848. pewp.setYqxjclssdl(StringUtils.round(summaryStatistics.getSum(), 2));
  849. summaryStatistics = pep1ls.stream().mapToDouble(ProEconEquipmentInfoDay1::getYsdtjssdl).summaryStatistics();
  850. //月手动停机损失电量
  851. pewp.setYsdtjssdl(StringUtils.round(summaryStatistics.getSum(), 2));
  852. summaryStatistics = pep1ls.stream().mapToDouble(ProEconEquipmentInfoDay1::getYxnssdl).summaryStatistics();
  853. //月性能损失电量
  854. pewp.setYxnssdl(StringUtils.round(summaryStatistics.getSum(), 2));
  855. summaryStatistics = pep1ls.stream().mapToDouble(ProEconEquipmentInfoDay1::getYxdtjssdl).summaryStatistics();
  856. //月限电停机损失电量
  857. pewp.setYxdtjssdl(StringUtils.round(summaryStatistics.getSum(), 2));
  858. summaryStatistics = pep1ls.stream().mapToDouble(ProEconEquipmentInfoDay1::getYxdjclssdl).summaryStatistics();
  859. //月限电降出力损失电量
  860. pewp.setYxdjclssdl(StringUtils.round(summaryStatistics.getSum(), 2));
  861. summaryStatistics = pep1ls.stream().mapToDouble(ProEconEquipmentInfoDay1::getYcwsldwssdl).summaryStatistics();
  862. //月场外受累电网损失电量
  863. pewp.setYcwsldwssdl(StringUtils.round(summaryStatistics.getSum(), 2));
  864. summaryStatistics = pep1ls.stream().mapToDouble(ProEconEquipmentInfoDay1::getYcwsltqssdl).summaryStatistics();
  865. //月场外受累天气损失电量
  866. pewp.setYcwsltqssdl(StringUtils.round(summaryStatistics.getSum(), 2));
  867. summaryStatistics = pep1ls.stream().mapToDouble(ProEconEquipmentInfoDay1::getYzfdl).summaryStatistics();
  868. //月增发电量
  869. pewp.setYzfdl(StringUtils.round(summaryStatistics.getSum(), 2));
  870. summaryStatistics = pep1ls.stream().mapToDouble(ProEconEquipmentInfoDay1::getYqfdl).summaryStatistics();
  871. //月欠发电量
  872. pewp.setYqfdl(StringUtils.round(summaryStatistics.getSum(), 2));
  873. summaryStatistics = pep1ls.stream().mapToDouble(ProEconEquipmentInfoDay1::getYzhd).summaryStatistics();
  874. //月自耗电
  875. pewp.setYzhd(StringUtils.round(summaryStatistics.getSum(), 2));
  876. }
  877. }
  878. ///*******************************************月信息统计*********************************************************/
  879. //*******************************************年信息统计*********************************************************/
  880. if (pep1map.containsKey(id)) {
  881. List<ProEconEquipmentInfoDay1> pep1ls = pep1map.get(id);
  882. if (!pep1ls.isEmpty()) {
  883. DoubleSummaryStatistics summaryStatistics = pep1ls.stream().mapToDouble(ProEconEquipmentInfoDay1::getNzdfs).summaryStatistics();
  884. //年最大风速
  885. pewp.setNzdfs(summaryStatistics.getMax());
  886. summaryStatistics = pep1ls.stream().mapToDouble(ProEconEquipmentInfoDay1::getNzxfs).summaryStatistics();
  887. //年最小风速
  888. pewp.setNzxfs(summaryStatistics.getMin());
  889. summaryStatistics = pep1ls.stream().mapToDouble(ProEconEquipmentInfoDay1::getNpjfs).summaryStatistics();
  890. if (type.equals("FDC")) {
  891. //年平均风速
  892. pewp.setNpjfs(summaryStatistics.getAverage());
  893. } else {
  894. //年平均风速
  895. pewp.setNpjfs(pep1ls.get(0).getNpjfs());
  896. // pewp.setNpjfs(summaryStatistics.getSum());
  897. }
  898. summaryStatistics = pep1ls.stream().mapToDouble(ProEconEquipmentInfoDay1::getNzdgl).summaryStatistics();
  899. //年最大功率
  900. pewp.setNzdgl(summaryStatistics.getMax());
  901. summaryStatistics = pep1ls.stream().mapToDouble(ProEconEquipmentInfoDay1::getNzxgl).summaryStatistics();
  902. //年最小功率
  903. pewp.setNzxgl(summaryStatistics.getMin());
  904. summaryStatistics = pep1ls.stream().mapToDouble(ProEconEquipmentInfoDay1::getNpjgl).summaryStatistics();
  905. //年平均功率
  906. pewp.setNpjgl(summaryStatistics.getAverage());
  907. summaryStatistics = pep1ls.stream().mapToDouble(ProEconEquipmentInfoDay1::getNfdl).summaryStatistics();
  908. //年发电量
  909. pewp.setNfdl(StringUtils.round(summaryStatistics.getSum(), 2));
  910. summaryStatistics = pep1ls.stream().mapToDouble(ProEconEquipmentInfoDay1::getNkydl).summaryStatistics();
  911. //年可用电量
  912. pewp.setNkydl(StringUtils.round(summaryStatistics.getSum(), 2));
  913. summaryStatistics = pep1ls.stream().mapToDouble(ProEconEquipmentInfoDay1::getNllfdl).summaryStatistics();
  914. //年理论发电量
  915. pewp.setNllfdl(StringUtils.round(summaryStatistics.getSum(), 2));
  916. summaryStatistics = pep1ls.stream().mapToDouble(ProEconEquipmentInfoDay1::getNgzssdl).summaryStatistics();
  917. //年故障损失电量
  918. pewp.setNgzssdl(StringUtils.round(summaryStatistics.getSum(), 2));
  919. summaryStatistics = pep1ls.stream().mapToDouble(ProEconEquipmentInfoDay1::getNcnslgzssdl).summaryStatistics();
  920. //年场内受累故障损失电量
  921. pewp.setNcnslgzssdl(StringUtils.round(summaryStatistics.getSum(), 2));
  922. summaryStatistics = pep1ls.stream().mapToDouble(ProEconEquipmentInfoDay1::getNjxssdl).summaryStatistics();
  923. //年检修损失电量
  924. pewp.setNjxssdl(StringUtils.round(summaryStatistics.getSum(), 2));
  925. summaryStatistics = pep1ls.stream().mapToDouble(ProEconEquipmentInfoDay1::getNcnsljxssdl).summaryStatistics();
  926. //年场内受累检修损失电量
  927. pewp.setNcnsljxssdl(StringUtils.round(summaryStatistics.getSum(), 2));
  928. summaryStatistics = pep1ls.stream().mapToDouble(ProEconEquipmentInfoDay1::getNdjssdl).summaryStatistics();
  929. //年待机损失电量
  930. pewp.setNdjssdl(StringUtils.round(summaryStatistics.getSum(), 2));
  931. summaryStatistics = pep1ls.stream().mapToDouble(ProEconEquipmentInfoDay1::getNqxjclssdl).summaryStatistics();
  932. //年缺陷降出力损失电量
  933. pewp.setNqxjclssdl(StringUtils.round(summaryStatistics.getSum(), 2));
  934. summaryStatistics = pep1ls.stream().mapToDouble(ProEconEquipmentInfoDay1::getNsdtjssdl).summaryStatistics();
  935. //年手动停机损失电量
  936. pewp.setNsdtjssdl(StringUtils.round(summaryStatistics.getSum(), 2));
  937. summaryStatistics = pep1ls.stream().mapToDouble(ProEconEquipmentInfoDay1::getNxnssdl).summaryStatistics();
  938. //年性能损失电量
  939. pewp.setNxnssdl(StringUtils.round(summaryStatistics.getSum(), 2));
  940. summaryStatistics = pep1ls.stream().mapToDouble(ProEconEquipmentInfoDay1::getNxdtjssdl).summaryStatistics();
  941. //年限电停机损失电量
  942. pewp.setNxdtjssdl(StringUtils.round(summaryStatistics.getSum(), 2));
  943. summaryStatistics = pep1ls.stream().mapToDouble(ProEconEquipmentInfoDay1::getNxdjclssdl).summaryStatistics();
  944. //年限电降出力损失电量
  945. pewp.setNxdjclssdl(StringUtils.round(summaryStatistics.getSum(), 2));
  946. summaryStatistics = pep1ls.stream().mapToDouble(ProEconEquipmentInfoDay1::getNcwsldwssdl).summaryStatistics();
  947. //年场外受累电网损失电量
  948. pewp.setNcwsldwssdl(StringUtils.round(summaryStatistics.getSum(), 2));
  949. summaryStatistics = pep1ls.stream().mapToDouble(ProEconEquipmentInfoDay1::getNcwsltqssdl).summaryStatistics();
  950. //年场外受累天气损失电量
  951. pewp.setNcwsltqssdl(StringUtils.round(summaryStatistics.getSum(), 2));
  952. summaryStatistics = pep1ls.stream().mapToDouble(ProEconEquipmentInfoDay1::getNzfdl).summaryStatistics();
  953. //年增发电量
  954. pewp.setNzfdl(StringUtils.round(summaryStatistics.getSum(), 2));
  955. summaryStatistics = pep1ls.stream().mapToDouble(ProEconEquipmentInfoDay1::getNqfdl).summaryStatistics();
  956. //年欠发电量
  957. pewp.setNqfdl(StringUtils.round(summaryStatistics.getSum(), 2));
  958. summaryStatistics = pep1ls.stream().mapToDouble(ProEconEquipmentInfoDay1::getNzhd).summaryStatistics();
  959. //年自耗电
  960. pewp.setNzhd(StringUtils.round(summaryStatistics.getSum(), 2));
  961. }
  962. }
  963. }
  964. private void setPowerandSpeedYear(ProEconPowerstationInfoDay1 pewp) {
  965. //年最大风速
  966. pewp.setNzdfs(pewp.getRzdfs());
  967. //年最小风速
  968. pewp.setNzxfs(pewp.getRzxfs());
  969. //年平均风速
  970. pewp.setNpjfs(pewp.getRpjfs());
  971. //年最大功率
  972. pewp.setNzdgl(pewp.getRzdgl());
  973. //年最小功率
  974. pewp.setNzxgl(pewp.getRzxgl());
  975. //年平均功率
  976. pewp.setNpjgl(pewp.getRpjgl());
  977. }
  978. private void setPowerandSpeedMonth(ProEconPowerstationInfoDay1 pewp) {
  979. //月最大风速
  980. pewp.setYzdfs(pewp.getRzdfs());
  981. //月最小风速
  982. pewp.setYzxfs(pewp.getRzxfs());
  983. //月平均风速
  984. pewp.setYpjfs(pewp.getRpjfs());
  985. //月最大功率
  986. pewp.setYzdgl(pewp.getRzdgl());
  987. //月最小功率
  988. pewp.setYzxgl(pewp.getRzxgl());
  989. //月平均功率
  990. pewp.setYpjgl(pewp.getRpjgl());
  991. }
  992. public void writeGf(Date date) throws Exception {
  993. QueryWrapper<ProBaseBackfill> qwf = new QueryWrapper<>();
  994. qwf.lambda().eq(ProBaseBackfill::getType, "CUSTOM_NDGFZB");
  995. List<ProBaseBackfill> list = iProBaseBackfillService.list(qwf);
  996. List<String> str = list.stream().map(ProBaseBackfill::getCode).collect(Collectors.toList());
  997. List<PointData> realData = edosUtil.getRealData(str);
  998. QueryWrapper<ProEconAnalysisSubtableBottom> qw = new QueryWrapper<>();
  999. qw.lambda().eq(ProEconAnalysisSubtableBottom::getRecordDate, date);
  1000. List<ProEconAnalysisSubtableBottom> sel = iProEconAnalysisSubtableBottomService.sel(qw);
  1001. List<ProEconAnalysisSubtableBottom> collect = sel.stream().filter(peasb -> str.contains(peasb.getMeterId())).collect(Collectors.toList());
  1002. List<ProEconAnalysisSubtableBottom> ls = new ArrayList<>();
  1003. if (collect.isEmpty()) {
  1004. for (PointData real : realData) {
  1005. ProEconAnalysisSubtableBottom pb = new ProEconAnalysisSubtableBottom();
  1006. pb.setRecordDate(date);
  1007. String[] split1 = real.getPointName().split("\\.");
  1008. if ("曙光储能电站".equals(split1[2]) || "宁东33光伏场站".equals(split1[2])) {
  1009. pb.setWpid("GJNY_NXGS_SGB_GDC_STA");
  1010. } else if ("霞光储能电站".equals(split1[2]) || "宁东32光伏场站".equals(split1[2])) {
  1011. pb.setWpid("GJNY_NXGS_XGB_GDC_STA");
  1012. } else {
  1013. pb.setWpid("GJNY_NXGS_QZB_GDC_STA");
  1014. }
  1015. pb.setMeterId(real.getPointName());
  1016. pb.setMeterName(real.getPointName());
  1017. pb.setStopCode(real.getPointValueInDouble());
  1018. pb.setStopCodeModify(real.getPointValueInDouble());
  1019. ls.add(pb);
  1020. }
  1021. } else {
  1022. for (PointData real : realData) {
  1023. for (ProEconAnalysisSubtableBottom s : sel) {
  1024. if (real.getPointName().equals(s.getMeterId())) {
  1025. ProEconAnalysisSubtableBottom pb = new ProEconAnalysisSubtableBottom();
  1026. pb.setId(s.getId());
  1027. pb.setStopCode(real.getPointValueInDouble());
  1028. pb.setStopCodeModify(real.getPointValueInDouble());
  1029. pb.setRecordDate(new Date(real.getPointTime()));
  1030. pb.setMeterName(real.getPointName());
  1031. pb.setMeterId(real.getPointName());
  1032. ls.add(pb);
  1033. }
  1034. }
  1035. }
  1036. }
  1037. try {
  1038. boolean b = iProEconAnalysisSubtableBottomService.batchAdd(ls);
  1039. } catch (Exception e) {
  1040. e.printStackTrace();
  1041. }
  1042. }
  1043. public void writeGfHistory(Date date) throws Exception {
  1044. QueryWrapper<ProBaseBackfill> qwf = new QueryWrapper<>();
  1045. qwf.lambda().eq(ProBaseBackfill::getType, "CUSTOM_NDGFZB");
  1046. List<ProBaseBackfill> list = iProBaseBackfillService.list(qwf);
  1047. List<String> str = list.stream().map(ProBaseBackfill::getCode).collect(Collectors.toList());
  1048. List<ProEconAnalysisSubtableBottom> ls = new ArrayList<>();
  1049. String join = String.join(",", str);
  1050. Map<String, PointData2> historySection = adapter.getHistorySection(goldenUri(), join, date.getTime());
  1051. for (String s : str) {
  1052. ProEconAnalysisSubtableBottom pb = new ProEconAnalysisSubtableBottom();
  1053. pb.setRecordDate(date);
  1054. String[] split1 = s.split("\\.");
  1055. if ("曙光储能电站".equals(split1[2]) || "宁东33光伏场站".equals(split1[2])) {
  1056. pb.setWpid("GJNY_NXGS_SGB_GDC_STA");
  1057. } else if ("霞光储能电站".equals(split1[2]) || "宁东32光伏场站".equals(split1[2])) {
  1058. pb.setWpid("GJNY_NXGS_XGB_GDC_STA");
  1059. } else {
  1060. pb.setWpid("GJNY_NXGS_QZB_GDC_STA");
  1061. }
  1062. pb.setMeterId(s);
  1063. pb.setMeterName(s);
  1064. pb.setStopCode(historySection.get(s).getDoubleValue());
  1065. pb.setStopCodeModify(historySection.get(s).getDoubleValue());
  1066. ls.add(pb);
  1067. }
  1068. try {
  1069. boolean b = iProEconAnalysisSubtableBottomService.batchAdd(ls);
  1070. } catch (Exception e) {
  1071. e.printStackTrace();
  1072. }
  1073. }
  1074. public void writeHaWindturbine(Date date) throws Exception {
  1075. QueryWrapper<ProBaseBackfill> qwf = new QueryWrapper<>();
  1076. qwf.lambda().eq(ProBaseBackfill::getType, "AI0003");
  1077. List<ProBaseBackfill> list = iProBaseBackfillService.list(qwf);
  1078. List<String> str = list.stream().map(ProBaseBackfill::getCode).collect(Collectors.toList());
  1079. List<PointData> realData = edosUtil.getRealData(str);
  1080. QueryWrapper<ProEconAnalysisSubtableBottom> qw = new QueryWrapper<>();
  1081. qw.lambda().eq(ProEconAnalysisSubtableBottom::getRecordDate, date);
  1082. List<ProEconAnalysisSubtableBottom> sel = iProEconAnalysisSubtableBottomService.sel(qw);
  1083. List<ProEconAnalysisSubtableBottom> collect = sel.stream().filter(peasb -> str.contains(peasb.getMeterId())).collect(Collectors.toList());
  1084. List<ProEconAnalysisSubtableBottom> ls = new ArrayList<>();
  1085. if (collect.isEmpty()) {
  1086. for (PointData real : realData) {
  1087. ProEconAnalysisSubtableBottom pb = new ProEconAnalysisSubtableBottom();
  1088. pb.setRecordDate(date);
  1089. pb.setWpid("NX_FGS_HA_FDC_STA");
  1090. pb.setMeterId(real.getPointName());
  1091. pb.setMeterName(real.getPointName());
  1092. pb.setStopCode(real.getPointValueInDouble());
  1093. pb.setStopCodeModify(real.getPointValueInDouble());
  1094. ls.add(pb);
  1095. }
  1096. } else {
  1097. for (PointData real : realData) {
  1098. for (ProEconAnalysisSubtableBottom s : sel) {
  1099. if (real.getPointName().equals(s.getMeterId())) {
  1100. ProEconAnalysisSubtableBottom pb = new ProEconAnalysisSubtableBottom();
  1101. pb.setId(s.getId());
  1102. pb.setStopCode(real.getPointValueInDouble());
  1103. pb.setStopCodeModify(real.getPointValueInDouble());
  1104. pb.setRecordDate(date);
  1105. pb.setMeterName(real.getPointName());
  1106. pb.setMeterId(real.getPointName());
  1107. ls.add(pb);
  1108. }
  1109. }
  1110. }
  1111. }
  1112. try {
  1113. boolean b = iProEconAnalysisSubtableBottomService.batchAdd(ls);
  1114. } catch (Exception e) {
  1115. e.printStackTrace();
  1116. }
  1117. }
  1118. public void writeHaWindturbineHistory(Date date) throws Exception {
  1119. QueryWrapper<ProBaseBackfill> qwf = new QueryWrapper<>();
  1120. qwf.lambda().eq(ProBaseBackfill::getType, "AI0003");
  1121. List<ProBaseBackfill> list = iProBaseBackfillService.list(qwf);
  1122. List<String> str = list.stream().map(ProBaseBackfill::getCode).collect(Collectors.toList());
  1123. long time = date.getTime();
  1124. for (long i = time; i < 1742518800000L; i += 86400000) {
  1125. List<ProEconAnalysisSubtableBottom> ls = new ArrayList<>();
  1126. for (String s : str) {
  1127. Map<String, PointData2> historySection = adapter.getHistorySection(goldenUri(), s, i);
  1128. ProEconAnalysisSubtableBottom pb = new ProEconAnalysisSubtableBottom();
  1129. pb.setRecordDate(new Date(i));
  1130. pb.setWpid("NX_FGS_HA_FDC_STA");
  1131. pb.setMeterId(s);
  1132. pb.setMeterName(s);
  1133. pb.setStopCode(historySection.get(s).getDoubleValue());
  1134. pb.setStopCodeModify(historySection.get(s).getDoubleValue());
  1135. ls.add(pb);
  1136. }
  1137. try {
  1138. boolean b = iProEconAnalysisSubtableBottomService.batchAdd(ls);
  1139. } catch (Exception e) {
  1140. e.printStackTrace();
  1141. }
  1142. }
  1143. }
  1144. // public void writeGfHistory(Date date) throws Exception {
  1145. // String s2 = "2024-12-11 23:55:00";
  1146. // String[] split = gf.split(",");
  1147. // List<String> str = new ArrayList<>(Arrays.asList(split));
  1148. // SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  1149. // Date date1 = simpleDateFormat.parse(s2);
  1150. // long time = date1.getTime();
  1151. // for (long i = time; i < 1735106823000L; i += 86400000) {
  1152. // List<ProEconAnalysisSubtableBottom> ls = new ArrayList<>();
  1153. // for (String s : str) {
  1154. // Map<String, PointData2> historySection = adapter.getHistorySection(goldenUri(), s, i);
  1155. // ProEconAnalysisSubtableBottom pb = new ProEconAnalysisSubtableBottom();
  1156. // pb.setRecordDate(new Date(i));
  1157. // String[] split1 = s.split("\\.");
  1158. // if ("曙光储能电站".equals(split1[2]) || "宁东33光伏场站".equals(split1[2])) {
  1159. // pb.setWpid("GJNY_NXGS_SGB_GDC_STA");
  1160. // } else if ("霞光储能电站".equals(split1[2]) || "宁东32光伏场站".equals(split1[2])) {
  1161. // pb.setWpid("GJNY_NXGS_XGB_GDC_STA");
  1162. // } else if ("电度表".equals(split1[3])) {
  1163. // pb.setWpid("NX_FGS_HA_FDC_STA");
  1164. // } else if ("区域集控".equals(split1[0]) && "惠安风场".equals(split1[1])) {
  1165. // pb.setWpid("NX_FGS_HA_FDC_STA");
  1166. // } else {
  1167. // pb.setWpid("GJNY_NXGS_QZB_GDC_STA");
  1168. // }
  1169. // pb.setMeterId(s);
  1170. // pb.setMeterName(s);
  1171. // pb.setStopCode(historySection.get(s).getDoubleValue());
  1172. // pb.setStopCodeModify(historySection.get(s).getDoubleValue());
  1173. // ls.add(pb);
  1174. // }
  1175. // try {
  1176. // boolean b = iProEconAnalysisSubtableBottomService.batchAdd(ls);
  1177. // } catch (Exception e) {
  1178. // e.printStackTrace();
  1179. // }
  1180. // }
  1181. // }
  1182. /**
  1183. * 执行时间:00:00:00,04:00:00,08:00:00,12:00:00,16:00:00,20:00:00,
  1184. */
  1185. public void writeReport1(Date date) throws Exception {
  1186. QueryWrapper<ProBaseBackfill> qwf = new QueryWrapper<>();
  1187. qwf.lambda().eq(ProBaseBackfill::getType, "AI0005");
  1188. List<ProBaseBackfill> list = iProBaseBackfillService.list(qwf);
  1189. List<String> ls = list.stream().map(ProBaseBackfill::getCode).collect(Collectors.toList());
  1190. LocalDateTime currentTime = LocalDateTime.now();
  1191. LocalDateTime modifiedTime = currentTime
  1192. .withMinute(0)
  1193. .withSecond(0)
  1194. .withNano(0);
  1195. List<PointData> realData = edosUtil.getRealData(ls);
  1196. if (null == realData || realData.isEmpty()) {
  1197. return;
  1198. }
  1199. List<StationInfoHour> shs = new ArrayList<>();
  1200. for (PointData realDa : realData) {
  1201. StationInfoHour sh = new StationInfoHour();
  1202. sh.setRecordDate(modifiedTime);
  1203. sh.setWpid("NX_FGS_HA_FDC_STA");
  1204. sh.setMeterId(realDa.getPointName());
  1205. sh.setMeterName(realDa.getPointName());
  1206. sh.setCode(BigDecimal.valueOf(realDa.getPointValueInDouble()));
  1207. sh.setCodeModify(BigDecimal.valueOf(realDa.getPointValueInDouble()));
  1208. shs.add(sh);
  1209. }
  1210. try {
  1211. boolean b = stationInfoHourService.saveBatch(shs);
  1212. System.out.println("成功");
  1213. } catch (Exception e) {
  1214. e.printStackTrace();
  1215. }
  1216. }
  1217. // public void writeReportHistory(Date date) throws Exception {
  1218. //// String[] dateTime = {"2024-12-13 08:00:00","2024-12-13 12:00:00", "2024-12-13 16:00:00", "2024-12-13 20:00:00"};
  1219. // String[] dateTime = {"2024-12-25 00:00:00", "2024-12-25 04:00:00", "2024-12-25 08:00:00", "2024-12-24 20:00:00"};
  1220. // SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  1221. // DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
  1222. // String[] split = repInfo1.split(",");
  1223. // List<String> ls = new ArrayList<>(Arrays.asList(split));
  1224. // for (String s : dateTime) {
  1225. // Date date1 = simpleDateFormat.parse(s);
  1226. // long timestamp = date1.getTime();
  1227. //// for (long i = timestamp; i < 1735033631000L; i += 86400000) {
  1228. // List<StationInfoHour> shs = new ArrayList<>();
  1229. // for (String l : ls) {
  1230. //// Map<String, PointData2> historySection = adapter.getHistorySection(goldenUri(), l, i);
  1231. // Map<String, PointData2> historySection = adapter.getHistorySection(goldenUri(), l, timestamp);
  1232. // if (null == historySection || historySection.isEmpty()) {
  1233. // return;
  1234. // }
  1235. // StationInfoHour sh = new StationInfoHour();
  1236. //// sh.setRecordDate(LocalDateTime.ofInstant(Instant.ofEpochMilli(i),ZoneId.systemDefault()));
  1237. // sh.setRecordDate(LocalDateTime.ofInstant(Instant.ofEpochMilli(timestamp), ZoneId.systemDefault()));
  1238. // sh.setWpid("NX_FGS_HA_FDC_STA");
  1239. // sh.setMeterId(l);
  1240. // sh.setMeterName(l);
  1241. // sh.setCode(BigDecimal.valueOf(historySection.get(l).getDoubleValue()));
  1242. // sh.setCodeModify(BigDecimal.valueOf(historySection.get(l).getDoubleValue()));
  1243. // shs.add(sh);
  1244. //
  1245. // }
  1246. // try {
  1247. // boolean b = stationInfoHourService.saveBatch(shs);
  1248. // } catch (Exception e) {
  1249. // e.printStackTrace();
  1250. // }
  1251. //// }
  1252. // }
  1253. //
  1254. // }
  1255. /**
  1256. * 执行时间:01:00:00,05:00:00,09:00:00,13:00:00,17:00:00,21:00:00,
  1257. */
  1258. public void writeReport2(Date date) throws Exception {
  1259. QueryWrapper<ProBaseBackfill> qwf = new QueryWrapper<>();
  1260. qwf.lambda().eq(ProBaseBackfill::getType, "AI0006");
  1261. List<ProBaseBackfill> list = iProBaseBackfillService.list(qwf);
  1262. List<String> ls = list.stream().map(ProBaseBackfill::getCode).collect(Collectors.toList());
  1263. LocalDateTime currentTime = LocalDateTime.now();
  1264. LocalDateTime modifiedTime = currentTime
  1265. .withMinute(0)
  1266. .withSecond(0)
  1267. .withNano(0);
  1268. List<PointData> realData = edosUtil.getRealData(ls);
  1269. if (null == realData || realData.isEmpty()) {
  1270. return;
  1271. }
  1272. List<StationInfoHour> shs = new ArrayList<>();
  1273. for (PointData realDa : realData) {
  1274. StationInfoHour sh = new StationInfoHour();
  1275. sh.setRecordDate(modifiedTime);
  1276. sh.setWpid("NX_FGS_HA_FDC_STA");
  1277. sh.setMeterId(realDa.getPointName());
  1278. sh.setMeterName(realDa.getPointName());
  1279. sh.setCode(BigDecimal.valueOf(realDa.getPointValueInDouble()));
  1280. sh.setCodeModify(BigDecimal.valueOf(realDa.getPointValueInDouble()));
  1281. shs.add(sh);
  1282. }
  1283. try {
  1284. boolean b = stationInfoHourService.saveBatch(shs);
  1285. System.out.println(b);
  1286. } catch (Exception e) {
  1287. e.printStackTrace();
  1288. }
  1289. }
  1290. public void writeReportHistory2(Date date) throws Exception {
  1291. // String[] dateTime = {"2024-12-13 01:00:00", "2024-12-13 05:00:00", "2024-12-13 09:00:00","2024-12-13 13:00:00", "2024-12-13 17:00:00", "2024-12-13 21:00:00"};
  1292. String[] dateTime = {"2025-03-13 01:00:00", "2025-03-13 05:00:00", "2025-03-13 09:00:00", "2025-03-13 13:00:00", "2025-03-13 17:00:00", "2025-03-13 21:00:00"};
  1293. SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  1294. DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
  1295. QueryWrapper<ProBaseBackfill> qwf = new QueryWrapper<>();
  1296. qwf.lambda().eq(ProBaseBackfill::getType, "AI0006");
  1297. List<ProBaseBackfill> list = iProBaseBackfillService.list(qwf);
  1298. List<String> ls = list.stream().map(ProBaseBackfill::getCode).collect(Collectors.toList());
  1299. // String[] split = repInfo2.split(",");
  1300. // List<String> ls = new ArrayList<>(Arrays.asList(split));
  1301. // List<String> ls = new ArrayList<>();
  1302. // ls.add("区域集控.惠安风场.升压站.110kV宋四风场线测控.Q1");
  1303. // ls.add("区域集控.惠安风场.升压站.110kV宋四风场线测控.UAB1");
  1304. for (String s : dateTime) {
  1305. Date date1 = simpleDateFormat.parse(s);
  1306. long timestamp = date1.getTime();
  1307. for (long i = timestamp; i < 1742176332000L; i += 86400000) {
  1308. List<StationInfoHour> shs = new ArrayList<>();
  1309. for (String l : ls) {
  1310. Map<String, PointData2> historySection = adapter.getHistorySection(goldenUri(), l, timestamp);
  1311. if (null == historySection || historySection.isEmpty()) {
  1312. return;
  1313. }
  1314. StationInfoHour sh = new StationInfoHour();
  1315. sh.setRecordDate(LocalDateTime.ofInstant(Instant.ofEpochMilli(i), ZoneId.systemDefault()));
  1316. sh.setWpid("NX_FGS_HA_FDC_STA");
  1317. sh.setMeterId(l);
  1318. sh.setMeterName(l);
  1319. sh.setCode(BigDecimal.valueOf(historySection.get(l).getDoubleValue()));
  1320. sh.setCodeModify(BigDecimal.valueOf(historySection.get(l).getDoubleValue()));
  1321. shs.add(sh);
  1322. }
  1323. try {
  1324. boolean b = stationInfoHourService.saveBatch(shs);
  1325. } catch (Exception e) {
  1326. e.printStackTrace();
  1327. }
  1328. }
  1329. }
  1330. }
  1331. public void writeReport3(Date date) throws Exception {
  1332. QueryWrapper<ProBaseBackfill> qw = new QueryWrapper<>();
  1333. qw.lambda().eq(ProBaseBackfill::getType, "AI0001");
  1334. List<ProBaseBackfill> backfills = iProBaseBackfillService.list(qw);
  1335. List<ProEconEquipmentInfoJs> jss = new ArrayList<>();
  1336. LocalDate now = LocalDate.now();
  1337. QueryWrapper<ProEconEquipmentInfoJs> qw2 = new QueryWrapper<>();
  1338. qw2.lambda().eq(ProEconEquipmentInfoJs::getRecordDate, now).eq(ProEconEquipmentInfoJs::getMeterId, "AI0001");
  1339. List<ProEconEquipmentInfoJs> projss = iProEconEquipmentInfoJsService.list(qw2);
  1340. if (null != projss && !projss.isEmpty()) {
  1341. List<String> meter = projss.stream().map(ProEconEquipmentInfoJs::getMeterId).collect(Collectors.toList());
  1342. backfills = backfills.stream().filter(bf -> !meter.contains(bf.getCode())).collect(Collectors.toList());
  1343. }
  1344. if (null == backfills || backfills.isEmpty()) {
  1345. return;
  1346. }
  1347. for (ProBaseBackfill backfill : backfills) {
  1348. ProEconEquipmentInfoJs js = new ProEconEquipmentInfoJs();
  1349. js.setRecordDate(now);
  1350. js.setWpid(backfill.getStation());
  1351. js.setMeterId("AI0001");
  1352. js.setMeterName(backfill.getCode());
  1353. jss.add(js);
  1354. }
  1355. try {
  1356. boolean b = iProEconEquipmentInfoJsService.saveBatch(jss);
  1357. System.out.println(b);
  1358. } catch (Exception e) {
  1359. e.printStackTrace();
  1360. }
  1361. }
  1362. public void writeReportHistory3(Date date) throws Exception {
  1363. QueryWrapper<ProBaseBackfill> qw = new QueryWrapper<>();
  1364. qw.lambda().eq(ProBaseBackfill::getType, "AI0001");
  1365. List<ProBaseBackfill> backfills = iProBaseBackfillService.list(qw);
  1366. List<ProEconEquipmentInfoJs> jss = new ArrayList<>();
  1367. String[] dateTime = {"2025-01-09"};
  1368. for (String s : dateTime) {
  1369. LocalDate now = LocalDate.parse(s);
  1370. QueryWrapper<ProEconEquipmentInfoJs> qw2 = new QueryWrapper<>();
  1371. qw2.lambda().eq(ProEconEquipmentInfoJs::getRecordDate, now).eq(ProEconEquipmentInfoJs::getMeterId, "AI0001");
  1372. List<ProEconEquipmentInfoJs> projss = iProEconEquipmentInfoJsService.list(qw2);
  1373. if (null != projss && !projss.isEmpty()) {
  1374. List<String> meter = projss.stream().map(ProEconEquipmentInfoJs::getMeterId).collect(Collectors.toList());
  1375. backfills = backfills.stream().filter(bf -> !meter.contains(bf.getCode())).collect(Collectors.toList());
  1376. }
  1377. if (null == backfills || backfills.isEmpty()) {
  1378. return;
  1379. }
  1380. for (ProBaseBackfill backfill : backfills) {
  1381. ProEconEquipmentInfoJs js = new ProEconEquipmentInfoJs();
  1382. js.setRecordDate(now);
  1383. js.setWpid(backfill.getStation());
  1384. js.setMeterId("AI0001");
  1385. js.setMeterName(backfill.getCode());
  1386. jss.add(js);
  1387. }
  1388. try {
  1389. boolean b = iProEconEquipmentInfoJsService.saveBatch(jss);
  1390. System.out.println(b);
  1391. } catch (Exception e) {
  1392. e.printStackTrace();
  1393. }
  1394. }
  1395. }
  1396. }