GenerationService.java 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690
  1. package com.gyee.generation.service;
  2. import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
  3. import com.gyee.common.contant.Contant;
  4. import com.gyee.common.model.PointData;
  5. import com.gyee.common.model.StringUtils;
  6. import com.gyee.common.util.DateUtils;
  7. import com.gyee.common.util.DoubleUtils;
  8. import com.gyee.generation.init.CacheContext;
  9. import com.gyee.generation.model.auto.*;
  10. import com.gyee.generation.service.auto.IMeterpointvalueService;
  11. import com.gyee.generation.util.realtimesource.IEdosUtil;
  12. import org.apache.commons.logging.Log;
  13. import org.apache.commons.logging.LogFactory;
  14. import org.springframework.stereotype.Service;
  15. import javax.annotation.Resource;
  16. import java.util.*;
  17. import java.util.concurrent.atomic.AtomicReference;
  18. /**
  19. * @ClassName : GenerationService
  20. * @Author : xieshengjie
  21. * @Date: 2022/2/28 15:23
  22. * @Description :
  23. */
  24. @Service
  25. public class GenerationService {
  26. private Log log = LogFactory.getLog(GenerationService.class);
  27. @Resource
  28. private IEdosUtil edosUtil;
  29. @Resource
  30. private IMeterpointvalueService meterpointvalueService;
  31. /**
  32. * 保存电计量电量,场用电量,购网电量,上网电量
  33. * @throws Exception
  34. */
  35. public void saveGenerationDatas() throws Exception {
  36. List<PointData> resultList = new ArrayList<>();
  37. List<PointData> fdlList = new ArrayList<>();
  38. List<Windpowerstation> wpls = CacheContext.wpls;
  39. List<Line> lines = CacheContext.lines;
  40. Map<String, List<Project>> wppromap = CacheContext.wppromap;
  41. Map<String, List<Line>> prolinemap = CacheContext.prolinemap;
  42. List<Meterpoint> meterpoints = CacheContext.meterpoints;
  43. Map<String, Map<String, Windpowerstationpointnew>> wppointmap = CacheContext.wppointmap;
  44. Map<String, Map<String, Windpowerstationpointnew>> linepointmap = CacheContext.linepointmap;
  45. Map<String, Map<String, Windpowerstationpointnew>> propointmap = CacheContext.propointmap;
  46. Date samedayZero = DateUtils.getSamedayZero();
  47. Date monthFirstZero = DateUtils.getMonthFirstZero();
  48. Date yearFirstZero = DateUtils.getYearFirstZero();
  49. Date currentDate = DateUtils.getCurrentDate();
  50. Date tomorrow = DateUtils.addDays(samedayZero,1);
  51. lines.stream().forEach(line->{
  52. Map<String, Windpowerstationpointnew> linemap = linepointmap.get(line.getId());
  53. //线路发电量
  54. Optional<Meterpoint> fdlOptional = meterpoints.stream().filter(me -> me.getLineid().equals(line.getId()) && me.getUniformcode().equals("ZXYG") && me.getMetertype().equals("进线") && me.getMetersort().equals("主")).findFirst();
  55. computeFdl(fdlList, tomorrow,samedayZero, monthFirstZero, yearFirstZero, currentDate, linemap, fdlOptional);
  56. });
  57. wpls.stream().forEach(wp->{
  58. Map<String, Windpowerstationpointnew> wpmap = wppointmap.get(wp.getId());
  59. AtomicReference<Double> fcrfdl = new AtomicReference<>((double) 0);
  60. AtomicReference<Double> fcyfdl = new AtomicReference<>((double) 0);
  61. AtomicReference<Double> fcnfdl = new AtomicReference<>((double) 0);
  62. AtomicReference<Double> fcrswdl = new AtomicReference<>((double) 0);
  63. AtomicReference<Double> fcyswdl = new AtomicReference<>((double) 0);
  64. AtomicReference<Double> fcnswdl = new AtomicReference<>((double) 0);
  65. AtomicReference<Double> fcrgwdl = new AtomicReference<>((double) 0);
  66. AtomicReference<Double> fcygwdl = new AtomicReference<>((double) 0);
  67. AtomicReference<Double> fcngwdl = new AtomicReference<>((double) 0);
  68. AtomicReference<Double> fcrcydl = new AtomicReference<>((double) 0);
  69. AtomicReference<Double> fcycydl = new AtomicReference<>((double) 0);
  70. AtomicReference<Double> fcncydl = new AtomicReference<>((double) 0);
  71. wppromap.get(wp.getId()).stream().forEach(project -> {
  72. Map<String, Windpowerstationpointnew> projectmap = propointmap.get(project.getId());
  73. AtomicReference<Double> qcrfdl = new AtomicReference<>(0.0);
  74. AtomicReference<Double> qcyfdl = new AtomicReference<>(0.0);
  75. AtomicReference<Double> qcnfdl = new AtomicReference<>(0.0);
  76. AtomicReference<Double> qcrswdl = new AtomicReference<>(0.0);
  77. AtomicReference<Double> qcyswdl = new AtomicReference<>(0.0);
  78. AtomicReference<Double> qcnswdl = new AtomicReference<>(0.0);
  79. AtomicReference<Double> qcrgwdl = new AtomicReference<>(0.0);
  80. AtomicReference<Double> qcygwdl = new AtomicReference<>(0.0);
  81. AtomicReference<Double> qcngwdl = new AtomicReference<>(0.0);
  82. AtomicReference<Double> qcrcydl = new AtomicReference<>(0.0);
  83. AtomicReference<Double> qcycydl = new AtomicReference<>(0.0);
  84. AtomicReference<Double> qcncydl = new AtomicReference<>(0.0);
  85. prolinemap.get(project.getId()).stream().forEach(line -> {
  86. Map<String, Windpowerstationpointnew> linemap = linepointmap.get(line.getId());
  87. //线路发电量
  88. Optional<Meterpoint> fdlOptional = meterpoints.stream().filter(me -> me.getLineid().equals(line.getId()) && me.getUniformcode().equals("ZXYG") && me.getMetertype().equals("进线") && me.getMetersort().equals("主")).findFirst();
  89. lineFdl(resultList,tomorrow, samedayZero, monthFirstZero, yearFirstZero, currentDate, qcrfdl, qcyfdl, qcnfdl, linemap, fdlOptional);
  90. log.info(line.getName()+"电计量电量计算完毕!");
  91. //线路上网电量
  92. Optional<Meterpoint> swdlOptional= null;
  93. Optional<Meterpoint> gwdlOptional=null;
  94. if (wp.getId().equals("GJY_FDC")){
  95. swdlOptional = meterpoints.stream().filter(me -> me.getUniformcode().equals("ZXYG") && me.getMetertype().equals("主变高压侧") && me.getMetersort().equals("主") && me.getLineid().contains(line.getId())).findFirst();
  96. gwdlOptional = meterpoints.stream().filter(me -> me.getUniformcode().equals("FXYG") && me.getMetertype().equals("主变高压侧") && me.getMetersort().equals("主") && me.getLineid().contains(line.getId())).findFirst();
  97. }else{
  98. swdlOptional = meterpoints.stream().filter(me -> me.getUniformcode().equals("ZXYG") && me.getMetertype().equals("出线") && me.getMetersort().equals("主") && me.getLineid().contains(line.getId())).findFirst();
  99. gwdlOptional = meterpoints.stream().filter(me -> me.getUniformcode().equals("FXYG") && me.getMetertype().equals("出线") && me.getMetersort().equals("主") && me.getLineid().contains(line.getId())).findFirst();
  100. }
  101. lineOrtherdl(fdlList,tomorrow,resultList, linepointmap, samedayZero, monthFirstZero, yearFirstZero, currentDate, qcrswdl, qcyswdl, qcnswdl, line, linemap, swdlOptional,Contant.SWDLB,Contant.SWDLY,Contant.SWDLN);
  102. log.info(line.getName()+"上网电量计算完毕!");
  103. //线路购网电量
  104. lineOrtherdl(fdlList,tomorrow,resultList, linepointmap, samedayZero, monthFirstZero, yearFirstZero, currentDate, qcrgwdl, qcygwdl, qcngwdl, line, linemap, gwdlOptional,Contant.GWGWB,Contant.GWGWY,Contant.GWGWN);
  105. log.info(line.getName()+"工网购网电量计算完毕!");
  106. //厂用电量
  107. Optional<Meterpoint> zybOptional = meterpoints.stream().filter(me-> me.getUniformcode().equals("ZXYG") && me.getMetertype().equals("站用变") && me.getMetersort().equals("主") && me.getLineid().contains(line.getId())).findFirst();
  108. lineOrtherdl(fdlList,tomorrow,resultList, linepointmap, samedayZero, monthFirstZero, yearFirstZero, currentDate, qcrcydl, qcycydl, qcncydl, line, linemap, zybOptional,Contant.CYDLB,Contant.CYDLY,Contant.CYDLN);
  109. log.info(line.getName()+"场用电量计算完毕!");
  110. //农网购网电量
  111. setZero(resultList,currentDate,linemap,Contant.NWGWB,Contant.NWGWY,Contant.NWGWN);
  112. log.info(line.getName()+"农网购网电量计算完毕!");
  113. });
  114. //期次发电量
  115. projectFdl(resultList, currentDate, fcrfdl, fcyfdl, fcnfdl, projectmap, qcrfdl, qcyfdl, qcnfdl);
  116. log.info(project.getName()+"发电量计算完毕!");
  117. //期次上网电量
  118. projectOrther(resultList, currentDate, fcrswdl, fcyswdl, fcnswdl, projectmap, qcrswdl, qcyswdl, qcnswdl,Contant.SWDLB,Contant.SWDLY,Contant.SWDLN);
  119. log.info(project.getName()+"上网电量计算完毕!");
  120. //期次购网电量
  121. projectOrther(resultList, currentDate, fcrgwdl, fcygwdl, fcngwdl, projectmap, qcrgwdl, qcygwdl, qcngwdl,Contant.GWGWB,Contant.GWGWY,Contant.GWGWN);
  122. log.info(project.getName()+"工网购网电量计算完毕!");
  123. //期次厂用电量
  124. projectOrther(resultList, currentDate, fcrcydl, fcycydl, fcncydl, projectmap, qcrcydl, qcycydl, qcncydl,Contant.CYDLB,Contant.CYDLY,Contant.CYDLN);
  125. log.info(project.getName()+"场用电量计算完毕!");
  126. //期次农网电量
  127. setZero(resultList,currentDate,projectmap,Contant.NWGWB,Contant.NWGWY,Contant.NWGWN);
  128. log.info(project.getName()+"农网电量计算完毕!");
  129. });
  130. //场站发电量
  131. windpowerFdl(resultList, currentDate, wpmap, fcrfdl, fcyfdl, fcnfdl,Contant.RFDLB,Contant.YFDLB,Contant.NFDLB);
  132. log.info(wp.getName()+"发电量计算完毕!");
  133. //场站上网电量
  134. windpowerFdl(resultList, currentDate, wpmap, fcrswdl, fcyswdl, fcnswdl,Contant.SWDLB,Contant.SWDLY,Contant.SWDLN);
  135. log.info(wp.getName()+"上网电量计算完毕!");
  136. //场站购网电量
  137. windpowerFdl(resultList, currentDate, wpmap, fcrgwdl, fcygwdl, fcngwdl,Contant.GWGWB,Contant.GWGWY,Contant.GWGWN);
  138. log.info(wp.getName()+"工网购网电量计算完毕!");
  139. //场站场用电量
  140. windpowerFdl(resultList, currentDate, wpmap, fcrcydl, fcycydl, fcncydl,Contant.CYDLB,Contant.CYDLY,Contant.CYDLN);
  141. log.info(wp.getName()+"场用电量计算完毕!");
  142. //场站农网电量
  143. setZero(resultList,currentDate,wpmap,Contant.NWGWB,Contant.NWGWY,Contant.NWGWN);
  144. log.info(wp.getName()+"农网购网电量计算完毕!");
  145. });
  146. edosUtil.sendMultiPoint(resultList);
  147. }
  148. /**
  149. * 存储meterpointvalue表
  150. * 实时+0点算前一天
  151. */
  152. public void saveMeterpointValueRealtime(String beginDate,String endDate){
  153. List<Meterpoint> meterpoints = CacheContext.meterpoints;
  154. List<String> days = DateUtils.getDays(beginDate, endDate);
  155. days.stream().forEach(day->{
  156. Date samedayZero = DateUtils.getSamedayZero(day);
  157. Date monthFirstZero = DateUtils.getMonthFirstZero(day);
  158. Date yearFirstZero = DateUtils.getYearFirstZero(day);
  159. Date date = DateUtils.addDays(samedayZero, 1);
  160. List<Meterpointvalue> resultList = new ArrayList<>();
  161. QueryWrapper<Meterpointvalue> qw = new QueryWrapper();
  162. qw.eq("recorddate",date);
  163. meterpointvalueService.remove(qw);
  164. meterpoints.stream().forEach(meterpoint -> {
  165. String meterid = meterpoint.getId();
  166. Double magnification = meterpoint.getMagnification();
  167. Double xs = meterpoint.getXs();
  168. Meterpointvalue meterpointvalue = new Meterpointvalue();
  169. meterpointvalue.setRecorddate(date);
  170. meterpointvalue.setMeterid(meterpoint.getId());
  171. Double real = 0.0;
  172. Double sameday = 0.0;
  173. Double month = 0.0;
  174. Double year = 0.0;
  175. try {
  176. real = edosUtil.getSectionData(meterid,date.getTime()).getPointValueInDouble();
  177. sameday = edosUtil.getSectionData(meterid,samedayZero.getTime()).getPointValueInDouble();
  178. month = edosUtil.getSectionData(meterid,monthFirstZero.getTime()).getPointValueInDouble();
  179. year = edosUtil.getSectionData(meterid,yearFirstZero.getTime()).getPointValueInDouble();
  180. } catch (Exception e) {
  181. e.printStackTrace();
  182. }
  183. meterpointvalue.setYear(DoubleUtils.keepPrecision(year/xs,2));
  184. meterpointvalue.setYear4(DoubleUtils.keepPrecision(year/xs,4));
  185. meterpointvalue.setMonth(DoubleUtils.keepPrecision(month/xs,2));
  186. meterpointvalue.setMonth4(DoubleUtils.keepPrecision(month/xs,4));
  187. meterpointvalue.setDay(DoubleUtils.keepPrecision(sameday/xs,2));
  188. meterpointvalue.setDay4(DoubleUtils.keepPrecision(sameday/xs,4));
  189. meterpointvalue.setNow(DoubleUtils.keepPrecision(real/xs,2));
  190. meterpointvalue.setNow4(DoubleUtils.keepPrecision(real/xs,4));
  191. Double yearvalue = (real/xs - year/xs) * magnification;
  192. Double monthvalue = (real/xs - month/xs) * magnification;
  193. Double dayvalue = (real/xs - sameday/xs) * magnification;
  194. meterpointvalue.setYearvalue(yearvalue);
  195. meterpointvalue.setMonthvalue(monthvalue);
  196. meterpointvalue.setDayvalue(dayvalue);
  197. resultList.add(meterpointvalue);
  198. });
  199. meterpointvalueService.saveBatch(resultList);
  200. });
  201. }
  202. public void updateMeterpointValueHistory(String beginDate,String endDate){
  203. List<Meterpointvalue> resultLsit = new ArrayList<>();
  204. Map<String,Meterpoint> meterpointMap = CacheContext.meterpointMap;
  205. List<String> days = DateUtils.getDays(beginDate, endDate);
  206. days.stream().forEach(day->{
  207. Date date = DateUtils.parseDate(beginDate);
  208. Date date1 = DateUtils.addDays(date, 1);
  209. Date date2= DateUtils.addDays(date1, 1);
  210. QueryWrapper<Meterpointvalue> qw = new QueryWrapper<>();
  211. qw.eq("recorddate",date1);
  212. List<Meterpointvalue> meterpointvalues = meterpointvalueService.list(qw);
  213. meterpointvalues.stream().forEach(meterpointvalue -> {
  214. Meterpoint meterpoint = meterpointMap.get(meterpointvalue.getMeterid());
  215. Double magnification = meterpoint.getMagnification();
  216. Double xs = meterpoint.getXs();
  217. Double real = 0.0;
  218. try {
  219. real = edosUtil.getSectionData(meterpointvalue.getMeterid(),date1.getTime()).getPointValueInDouble();
  220. } catch (Exception e) {
  221. e.printStackTrace();
  222. }
  223. Double yearvalue = (real/xs - meterpointvalue.getYear4()) * magnification;
  224. Double monthvalue = (real/xs - meterpointvalue.getMonth4()) * magnification;
  225. Double dayvalue = (real/xs - meterpointvalue.getDay4()) * magnification;
  226. meterpointvalue.setNow(DoubleUtils.keepPrecision(real,2));
  227. meterpointvalue.setNow4(DoubleUtils.keepPrecision(real,4));
  228. meterpointvalue.setYearvalue(yearvalue);
  229. meterpointvalue.setMonthvalue(monthvalue);
  230. meterpointvalue.setDayvalue(dayvalue);
  231. resultLsit.add(meterpointvalue);
  232. });
  233. meterpointvalueService.saveOrUpdateBatch(resultLsit);
  234. });
  235. }
  236. private void setGsZero(List<PointData> resultList,Date currentDate,Map<String, Map<String, Windpowerstationpointnew>> linemap,String foreignkeyid,String rcode,String ycode,String ncode) {
  237. //线路日发电量
  238. PointData r = new PointData();
  239. r.setPointTime(currentDate.getTime());
  240. r.setPointValue("0");
  241. r.setPointValueInDouble(0);
  242. r.setEdnaId(linemap.get(foreignkeyid).get(rcode).getCode());
  243. r.setPointName(linemap.get(foreignkeyid).get(rcode).getName());
  244. resultList.add(r);
  245. //线路月发电量
  246. PointData y = new PointData();
  247. y.setPointTime(currentDate.getTime());
  248. y.setPointValue("0");
  249. y.setPointValueInDouble(0);
  250. y.setEdnaId(linemap.get(foreignkeyid).get(ycode).getCode());
  251. y.setPointName(linemap.get(foreignkeyid).get(ycode).getName());
  252. resultList.add(y);
  253. //线路年发电量
  254. PointData n = new PointData();
  255. n.setPointTime(currentDate.getTime());
  256. n.setPointValue("0");
  257. n.setPointValueInDouble(0);
  258. n.setEdnaId(linemap.get(foreignkeyid).get(ncode).getCode());
  259. n.setPointName(linemap.get(foreignkeyid).get(ncode).getName());
  260. resultList.add(n);
  261. }
  262. private void setZero(List<PointData> resultList,Date currentDate,Map<String, Windpowerstationpointnew> linemap,String rcode,String ycode,String ncode) {
  263. //线路日发电量
  264. PointData r = new PointData();
  265. r.setPointTime(currentDate.getTime());
  266. r.setPointValue("0");
  267. r.setPointValueInDouble(0);
  268. r.setEdnaId(linemap.get(rcode).getCode());
  269. r.setPointName(linemap.get(rcode).getName());
  270. resultList.add(r);
  271. //线路月发电量
  272. PointData y = new PointData();
  273. y.setPointTime(currentDate.getTime());
  274. y.setPointValue("0");
  275. y.setPointValueInDouble(0);
  276. y.setEdnaId(linemap.get(ycode).getCode());
  277. y.setPointName(linemap.get(ycode).getName());
  278. resultList.add(y);
  279. //线路年发电量
  280. PointData n = new PointData();
  281. n.setPointTime(currentDate.getTime());
  282. n.setPointValue("0");
  283. n.setPointValueInDouble(0);
  284. n.setEdnaId(linemap.get(ncode).getCode());
  285. n.setPointName(linemap.get(ncode).getName());
  286. resultList.add(n);
  287. }
  288. private Map<String,Double> getPercentage(List<PointData> fdlList,Meterpoint swdlMeterpoint,List<PointData> resultList,Map<String, Map<String, Windpowerstationpointnew>> linepointmap,Line line){
  289. Map<String,Double> percentageMap = new HashMap<>();
  290. String[] swdlLines = swdlMeterpoint.getLineid().split("\\|");
  291. AtomicReference<Double> xldl = new AtomicReference<>((double) 0);
  292. AtomicReference<Double> xlzdl = new AtomicReference<>((double) 0);
  293. AtomicReference<Double> xlydl = new AtomicReference<>((double) 0);
  294. AtomicReference<Double> xlzydl = new AtomicReference<>((double) 0);
  295. AtomicReference<Double> xlndl = new AtomicReference<>((double) 0);
  296. AtomicReference<Double> xlzndl = new AtomicReference<>((double) 0);
  297. Arrays.stream(swdlLines).forEach(l->{
  298. Optional<PointData> xldlfirst = fdlList.stream().filter(res -> res.getEdnaId().equals(linepointmap.get(l).get(Contant.RFDLB).getCode())).findFirst();
  299. if (xldlfirst.isPresent()){
  300. if (l.equals(line.getId())){
  301. xldl.set(xldlfirst.get().getPointValueInDouble());
  302. xlzdl.updateAndGet(v -> new Double((double) (v + xldlfirst.get().getPointValueInDouble())));
  303. }else{
  304. xlzdl.updateAndGet(v -> new Double((double) (v + xldlfirst.get().getPointValueInDouble())));
  305. }
  306. }
  307. Optional<PointData> xlydlfirst = fdlList.stream().filter(res -> res.getEdnaId().equals(linepointmap.get(l).get(Contant.YFDLB).getCode())).findFirst();
  308. if (xlydlfirst.isPresent()){
  309. if (l.equals(line.getId())){
  310. xlydl.set(xlydlfirst.get().getPointValueInDouble());
  311. xlzydl.updateAndGet(v -> new Double((double) (v + xlydlfirst.get().getPointValueInDouble())));
  312. }else{
  313. xlzydl.updateAndGet(v -> new Double((double) (v + xlydlfirst.get().getPointValueInDouble())));
  314. }
  315. }
  316. Optional<PointData> xlndlfirst = fdlList.stream().filter(res -> res.getEdnaId().equals(linepointmap.get(l).get(Contant.NFDLB).getCode())).findFirst();
  317. if (xlndlfirst.isPresent()){
  318. if (l.equals(line.getId())){
  319. xlndl.set(xlndlfirst.get().getPointValueInDouble());
  320. xlzndl.updateAndGet(v -> new Double((double) (v + xlndlfirst.get().getPointValueInDouble())));
  321. }else{
  322. xlzndl.updateAndGet(v -> new Double((double) (v + xlndlfirst.get().getPointValueInDouble())));
  323. }
  324. }
  325. });
  326. //电量百分比
  327. double percentage = xlzdl.get() != 0 ? xldl.get() / xlzdl.get() : 0;
  328. percentageMap.put("percentage",percentage);
  329. double ypercentage = xlzydl.get() != 0 ? xlydl.get() / xlzydl.get() : 0;
  330. percentageMap.put("ypercentage",ypercentage);
  331. double npercentage = xlzndl.get() != 0 ? xlndl.get() / xlzndl.get() : 0;
  332. percentageMap.put("npercentage",npercentage);
  333. return percentageMap;
  334. }
  335. private void lineOrtherdl(List<PointData> fdlList,Date tomorrow,List<PointData> resultList, Map<String, Map<String, Windpowerstationpointnew>> linepointmap, Date samedayZero, Date monthFirstZero, Date yearFirstZero, Date currentDate, AtomicReference<Double> qcrswdl, AtomicReference<Double> qcyswdl, AtomicReference<Double> qcnswdl, Line line, Map<String, Windpowerstationpointnew> linemap, Optional<Meterpoint> optionalMeterpoint,String rcode,String ycode,String ncode) {
  336. if (optionalMeterpoint.isPresent()){
  337. Meterpoint swdlMeterpoint = optionalMeterpoint.get();
  338. //获取电量百分比,算其他电量
  339. Map<String, Double> percentageMap = getPercentage(fdlList,swdlMeterpoint, resultList, linepointmap, line);
  340. String pointid = swdlMeterpoint.getId();
  341. Double real = 0.0;
  342. Double sameday = 0.0;
  343. Double month = 0.0;
  344. Double year = 0.0;
  345. try {
  346. real = edosUtil.getSectionData(pointid,tomorrow.getTime()).getPointValueInDouble();
  347. sameday = edosUtil.getSectionData(pointid,samedayZero.getTime()).getPointValueInDouble();
  348. month = edosUtil.getSectionData(pointid,monthFirstZero.getTime()).getPointValueInDouble();
  349. year = edosUtil.getSectionData(pointid,yearFirstZero.getTime()).getPointValueInDouble();
  350. Double magnification = optionalMeterpoint.get().getMagnification();
  351. Double xs = optionalMeterpoint.get().getXs();
  352. double xlswdl = (real - sameday) * magnification / xs * percentageMap.get("percentage");
  353. qcrswdl.updateAndGet(v -> new Double((double) (v + xlswdl)));
  354. //线路上网电量
  355. PointData r = new PointData();
  356. r.setPointTime(currentDate.getTime());
  357. r.setPointValue(String.valueOf(xlswdl));
  358. r.setPointValueInDouble(xlswdl);
  359. r.setEdnaId(linemap.get(rcode).getCode());
  360. r.setPointName(linemap.get(rcode).getName());
  361. resultList.add(r);
  362. //线路月上网发电量
  363. double xlyswdl = (real - month) * magnification / xs * percentageMap.get("ypercentage");
  364. qcyswdl.updateAndGet(v -> new Double((double) (v + xlyswdl)));
  365. PointData y = new PointData();
  366. y.setPointTime(currentDate.getTime());
  367. y.setPointValue(String.valueOf(xlyswdl));
  368. y.setPointValueInDouble(xlyswdl);
  369. y.setEdnaId(linemap.get(ycode).getCode());
  370. y.setPointName(linemap.get(ycode).getName());
  371. resultList.add(y);
  372. //线路年上网发电量
  373. double xlnswfdl = (real - year) * magnification / xs * percentageMap.get("npercentage");
  374. qcnswdl.updateAndGet(v -> new Double((double) (v + xlnswfdl)));
  375. PointData n = new PointData();
  376. n.setPointTime(currentDate.getTime());
  377. n.setPointValue(String.valueOf(xlnswfdl));
  378. n.setPointValueInDouble(xlnswfdl);
  379. n.setEdnaId(linemap.get(ncode).getCode());
  380. n.setPointName(linemap.get(ncode).getName());
  381. resultList.add(n);
  382. } catch (Exception e) {
  383. e.printStackTrace();
  384. }
  385. }
  386. }
  387. private void computeFdl(List<PointData> fdlList, Date tomorrow,Date samedayZero, Date monthFirstZero, Date yearFirstZero, Date currentDate, Map<String, Windpowerstationpointnew> linemap, Optional<Meterpoint> fdlOptional) {
  388. if (fdlOptional.isPresent()){
  389. String pointid = fdlOptional.get().getId();
  390. Double real = 0.0;
  391. Double sameday = 0.0;
  392. Double month = 0.0;
  393. Double year = 0.0;
  394. try {
  395. real = edosUtil.getSectionData(pointid,tomorrow.getTime()).getPointValueInDouble();
  396. sameday = edosUtil.getSectionData(pointid,samedayZero.getTime()).getPointValueInDouble();
  397. month = edosUtil.getSectionData(pointid,monthFirstZero.getTime()).getPointValueInDouble();
  398. year = edosUtil.getSectionData(pointid,yearFirstZero.getTime()).getPointValueInDouble();
  399. Double magnification = fdlOptional.get().getMagnification();
  400. Double xs = fdlOptional.get().getXs();
  401. double xlrfdl = (real - sameday) * magnification / xs;
  402. //线路日发电量
  403. PointData r = new PointData();
  404. r.setPointTime(currentDate.getTime());
  405. r.setPointValue(String.valueOf(xlrfdl));
  406. r.setPointValueInDouble(xlrfdl);
  407. r.setEdnaId(linemap.get(Contant.RFDLB).getCode());
  408. r.setPointName(linemap.get(Contant.RFDLB).getName());
  409. fdlList.add(r);
  410. //线路月发电量
  411. double xlyfdl = (real - month) * magnification / xs;
  412. PointData y = new PointData();
  413. y.setPointTime(currentDate.getTime());
  414. y.setPointValue(String.valueOf(xlyfdl));
  415. y.setPointValueInDouble(xlyfdl);
  416. y.setEdnaId(linemap.get(Contant.YFDLB).getCode());
  417. y.setPointName(linemap.get(Contant.YFDLB).getName());
  418. fdlList.add(y);
  419. //线路年发电量
  420. double xlnfdl = (real - year) * magnification / xs;
  421. PointData n = new PointData();
  422. n.setPointTime(currentDate.getTime());
  423. n.setPointValue(String.valueOf(xlnfdl));
  424. n.setPointValueInDouble(xlnfdl);
  425. n.setEdnaId(linemap.get(Contant.NFDLB).getCode());
  426. n.setPointName(linemap.get(Contant.NFDLB).getName());
  427. fdlList.add(n);
  428. } catch (Exception e) {
  429. e.printStackTrace();
  430. }
  431. }
  432. }
  433. private void lineFdl(List<PointData> resultList, Date tomorrow,Date samedayZero, Date monthFirstZero, Date yearFirstZero, Date currentDate, AtomicReference<Double> qcrfdl, AtomicReference<Double> qcyfdl, AtomicReference<Double> qcnfdl, Map<String, Windpowerstationpointnew> linemap, Optional<Meterpoint> optionalMeterpoint) {
  434. if (optionalMeterpoint.isPresent()){
  435. String pointid = optionalMeterpoint.get().getId();
  436. Double real = 0.0;
  437. Double sameday = 0.0;
  438. Double month = 0.0;
  439. Double year = 0.0;
  440. try {
  441. real = edosUtil.getSectionData(pointid,tomorrow.getTime()).getPointValueInDouble();
  442. sameday = edosUtil.getSectionData(pointid,samedayZero.getTime()).getPointValueInDouble();
  443. month = edosUtil.getSectionData(pointid,monthFirstZero.getTime()).getPointValueInDouble();
  444. year = edosUtil.getSectionData(pointid,yearFirstZero.getTime()).getPointValueInDouble();
  445. Double magnification = optionalMeterpoint.get().getMagnification();
  446. Double xs = optionalMeterpoint.get().getXs();
  447. double xlrfdl = (real - sameday) * magnification / xs;
  448. qcrfdl.updateAndGet(v -> new Double((double) (v + xlrfdl)));
  449. //线路日发电量
  450. PointData r = new PointData();
  451. r.setPointTime(currentDate.getTime());
  452. r.setPointValue(String.valueOf(xlrfdl));
  453. r.setPointValueInDouble(xlrfdl);
  454. r.setEdnaId(linemap.get(Contant.RFDLB).getCode());
  455. r.setPointName(linemap.get(Contant.RFDLB).getName());
  456. resultList.add(r);
  457. //线路月发电量
  458. double xlyfdl = (real - month) * magnification / xs;
  459. qcyfdl.updateAndGet(v -> new Double((double) (v + xlyfdl)));
  460. PointData y = new PointData();
  461. y.setPointTime(currentDate.getTime());
  462. y.setPointValue(String.valueOf(xlyfdl));
  463. y.setPointValueInDouble(xlyfdl);
  464. y.setEdnaId(linemap.get(Contant.YFDLB).getCode());
  465. y.setPointName(linemap.get(Contant.YFDLB).getName());
  466. resultList.add(y);
  467. //线路年发电量
  468. double xlnfdl = (real - year) * magnification / xs;
  469. qcnfdl.updateAndGet(v -> new Double((double) (v + xlnfdl)));
  470. PointData n = new PointData();
  471. n.setPointTime(currentDate.getTime());
  472. n.setPointValue(String.valueOf(xlnfdl));
  473. n.setPointValueInDouble(xlnfdl);
  474. n.setEdnaId(linemap.get(Contant.NFDLB).getCode());
  475. n.setPointName(linemap.get(Contant.NFDLB).getName());
  476. resultList.add(n);
  477. } catch (Exception e) {
  478. e.printStackTrace();
  479. }
  480. }
  481. }
  482. private void windpowerFdl(List<PointData> resultList, Date currentDate, Map<String, Windpowerstationpointnew> wpmap, AtomicReference<Double> fcrswdl, AtomicReference<Double> fcyswdl, AtomicReference<Double> fcnswdl,String rcode,String ycode,String ncode) {
  483. //风场日上网发电量
  484. PointData r = new PointData();
  485. r.setPointTime(currentDate.getTime());
  486. r.setPointValue(String.valueOf(fcrswdl.get()));
  487. r.setPointValueInDouble(fcrswdl.get());
  488. r.setEdnaId(wpmap.get(rcode).getCode());
  489. r.setPointName(wpmap.get(rcode).getName());
  490. resultList.add(r);
  491. //风场月上网发电量
  492. PointData y = new PointData();
  493. y.setPointTime(currentDate.getTime());
  494. y.setPointValue(String.valueOf(fcyswdl.get()));
  495. y.setPointValueInDouble(fcyswdl.get());
  496. y.setEdnaId(wpmap.get(ycode).getCode());
  497. y.setPointName(wpmap.get(ycode).getName());
  498. resultList.add(y);
  499. //风场年上网发电量
  500. PointData n = new PointData();
  501. n.setPointTime(currentDate.getTime());
  502. n.setPointValue(String.valueOf(fcnswdl.get()));
  503. n.setPointValueInDouble(fcnswdl.get());
  504. n.setEdnaId(wpmap.get(ncode).getCode());
  505. n.setPointName(wpmap.get(ncode).getName());
  506. resultList.add(n);
  507. }
  508. private void qygsFdl(List<PointData> resultList, Map<String, Map<String, Windpowerstationpointnew>> wppointmap, Date currentDate, Double gsrfdl, Double gsyfdl, Double gsnfdl, AtomicReference<Double> fdrfdl, AtomicReference<Double> fdyfdl, AtomicReference<Double> fdnfdl, AtomicReference<Double> gfrfdl, AtomicReference<Double> gfyfdl, AtomicReference<Double> gfnfdl, String rcode, String ycode, String ncode) {
  509. if (StringUtils.isNotEmpty(wppointmap.get("-1"))){
  510. PointData fdr = new PointData();
  511. fdr.setPointTime(currentDate.getTime());
  512. fdr.setPointValue(String.valueOf(fdrfdl.get()));
  513. fdr.setPointValueInDouble(fdrfdl.get());
  514. fdr.setEdnaId(wppointmap.get("-1").get(rcode).getCode());
  515. fdr.setPointName(wppointmap.get("-1").get(rcode).getName());
  516. resultList.add(fdr);
  517. //风电月发电量
  518. PointData fdy = new PointData();
  519. fdy.setPointTime(currentDate.getTime());
  520. fdy.setPointValue(String.valueOf(fdyfdl.get()));
  521. fdy.setPointValueInDouble(fdyfdl.get());
  522. fdy.setEdnaId(wppointmap.get("-1").get(ycode).getCode());
  523. fdy.setPointName(wppointmap.get("-1").get(ycode).getName());
  524. resultList.add(fdy);
  525. //风电年发电量
  526. PointData fdn = new PointData();
  527. fdn.setPointTime(currentDate.getTime());
  528. fdn.setPointValue(String.valueOf(fdnfdl.get()));
  529. fdn.setPointValueInDouble(fdnfdl.get());
  530. fdn.setEdnaId(wppointmap.get("-1").get(ncode).getCode());
  531. fdn.setPointName(wppointmap.get("-1").get(ncode).getName());
  532. resultList.add(fdn);
  533. }
  534. if (StringUtils.isNotEmpty(wppointmap.get("-2"))){
  535. //光伏日发电量
  536. PointData gfr = new PointData();
  537. gfr.setPointTime(currentDate.getTime());
  538. gfr.setPointValue(String.valueOf(gfrfdl.get()));
  539. gfr.setPointValueInDouble(gfrfdl.get());
  540. gfr.setEdnaId(wppointmap.get("-2").get(rcode).getCode());
  541. gfr.setPointName(wppointmap.get("-2").get(rcode).getName());
  542. resultList.add(gfr);
  543. //光伏月发电量
  544. PointData gfy = new PointData();
  545. gfy.setPointTime(currentDate.getTime());
  546. gfy.setPointValue(String.valueOf(gfyfdl.get()));
  547. gfy.setPointValueInDouble(gfyfdl.get());
  548. gfy.setEdnaId(wppointmap.get("-2").get(ycode).getCode());
  549. gfy.setPointName(wppointmap.get("-2").get(ycode).getName());
  550. resultList.add(gfy);
  551. //光伏年发电量
  552. PointData gfn = new PointData();
  553. gfn.setPointTime(currentDate.getTime());
  554. gfn.setPointValue(String.valueOf(gfnfdl.get()));
  555. gfn.setPointValueInDouble(gfnfdl.get());
  556. gfn.setEdnaId(wppointmap.get("-2").get(ncode).getCode());
  557. gfn.setPointName(wppointmap.get("-2").get(ncode).getName());
  558. resultList.add(gfn);
  559. }
  560. //风场日发电量
  561. gsrfdl = fdrfdl.get()+gfrfdl.get();
  562. gsyfdl = fdyfdl.get()+gfyfdl.get();
  563. gsnfdl = fdnfdl.get()+gfnfdl.get();
  564. PointData r = new PointData();
  565. r.setPointTime(currentDate.getTime());
  566. r.setPointValue(String.valueOf(gsrfdl));
  567. r.setPointValueInDouble(gsrfdl);
  568. r.setEdnaId(wppointmap.get("0").get(rcode).getCode());
  569. r.setPointName(wppointmap.get("0").get(rcode).getName());
  570. resultList.add(r);
  571. //风场月发电量
  572. PointData y = new PointData();
  573. y.setPointTime(currentDate.getTime());
  574. y.setPointValue(String.valueOf(gsyfdl));
  575. y.setPointValueInDouble(gsyfdl);
  576. y.setEdnaId(wppointmap.get("0").get(ycode).getCode());
  577. y.setPointName(wppointmap.get("0").get(ycode).getName());
  578. resultList.add(y);
  579. //风场年发电量
  580. PointData n = new PointData();
  581. n.setPointTime(currentDate.getTime());
  582. n.setPointValue(String.valueOf(gsnfdl));
  583. n.setPointValueInDouble(gsnfdl);
  584. n.setEdnaId(wppointmap.get("0").get(ncode).getCode());
  585. n.setPointName(wppointmap.get("0").get(ncode).getName());
  586. resultList.add(n);
  587. }
  588. private void projectOrther(List<PointData> resultList, Date currentDate, AtomicReference<Double> fcrswdl, AtomicReference<Double> fcyswdl, AtomicReference<Double> fcnswdl, Map<String, Windpowerstationpointnew> projectmap, AtomicReference<Double> qcrswdl, AtomicReference<Double> qcyswdl, AtomicReference<Double> qcnswdl,String rcode,String ycode,String ncode) {
  589. //-------------------------------------------期次上网电量
  590. fcrswdl.updateAndGet(v -> new Double((double) (v + qcrswdl.get())));
  591. //期次日上网发电量
  592. PointData r = new PointData();
  593. r.setPointTime(currentDate.getTime());
  594. r.setPointValue(String.valueOf(qcrswdl.get()));
  595. r.setPointValueInDouble(qcrswdl.get());
  596. r.setEdnaId(projectmap.get(rcode).getCode());
  597. r.setPointName(projectmap.get(rcode).getName());
  598. resultList.add(r);
  599. fcyswdl.updateAndGet(v -> new Double((double) (v + qcyswdl.get())));
  600. //期次月上网发电量
  601. PointData y = new PointData();
  602. y.setPointTime(currentDate.getTime());
  603. y.setPointValue(String.valueOf(qcyswdl.get()));
  604. y.setPointValueInDouble(qcyswdl.get());
  605. y.setEdnaId(projectmap.get(ycode).getCode());
  606. y.setPointName(projectmap.get(ycode).getName());
  607. resultList.add(y);
  608. fcnswdl.updateAndGet(v -> new Double((double) (v + qcnswdl.get())));
  609. //期次年上网发电量
  610. PointData n = new PointData();
  611. n.setPointTime(currentDate.getTime());
  612. n.setPointValue(String.valueOf(qcnswdl.get()));
  613. n.setPointValueInDouble(qcnswdl.get());
  614. n.setEdnaId(projectmap.get(ncode).getCode());
  615. n.setPointName(projectmap.get(ncode).getName());
  616. resultList.add(n);
  617. }
  618. private void projectFdl(List<PointData> resultList, Date currentDate, AtomicReference<Double> fcrfdl, AtomicReference<Double> fcyfdl, AtomicReference<Double> fcnfdl, Map<String, Windpowerstationpointnew> projectmap, AtomicReference<Double> qcrfdl, AtomicReference<Double> qcyfdl, AtomicReference<Double> qcnfdl) {
  619. //-------------------------------------------期次发电量
  620. fcrfdl.updateAndGet(v -> new Double((double) (v + qcrfdl.get())));
  621. //期次日发电量
  622. PointData r = new PointData();
  623. r.setPointTime(currentDate.getTime());
  624. r.setPointValue(String.valueOf(qcrfdl.get()));
  625. r.setPointValueInDouble(qcrfdl.get());
  626. r.setEdnaId(projectmap.get(Contant.RFDLB).getCode());
  627. r.setPointName(projectmap.get(Contant.RFDLB).getName());
  628. resultList.add(r);
  629. fcyfdl.updateAndGet(v -> new Double((double) (v + qcyfdl.get())));
  630. //期次月发电量
  631. PointData y = new PointData();
  632. y.setPointTime(currentDate.getTime());
  633. y.setPointValue(String.valueOf(qcyfdl.get()));
  634. y.setPointValueInDouble(qcyfdl.get());
  635. y.setEdnaId(projectmap.get(Contant.YFDLB).getCode());
  636. y.setPointName(projectmap.get(Contant.YFDLB).getName());
  637. resultList.add(y);
  638. fcnfdl.updateAndGet(v -> new Double((double) (v + qcnfdl.get())));
  639. //期次年发电量
  640. PointData n = new PointData();
  641. n.setPointTime(currentDate.getTime());
  642. n.setPointValue(String.valueOf(qcnfdl.get()));
  643. n.setPointValueInDouble(qcnfdl.get());
  644. n.setEdnaId(projectmap.get(Contant.NFDLB).getCode());
  645. n.setPointName(projectmap.get(Contant.NFDLB).getName());
  646. resultList.add(n);
  647. }
  648. }