WindturbinegoodnessService.java 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977
  1. package com.gyee.runeconomy.service.goodness;
  2. import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
  3. import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
  4. import com.gyee.common.contant.ContantXk;
  5. import com.gyee.common.model.PointData;
  6. import com.gyee.common.util.DoubleUtils;
  7. import com.gyee.common.util.SortUtils;
  8. import com.gyee.common.vo.benchmark.DataVo;
  9. import com.gyee.common.vo.threerate.PvVo;
  10. import com.gyee.runeconomy.dto.EchartDataVo;
  11. import com.gyee.runeconomy.init.CacheContext;
  12. import com.gyee.runeconomy.model.auto.*;
  13. import com.gyee.runeconomy.service.auto.IProEconEquipmentInfoDay6Service;
  14. import com.gyee.runeconomy.service.auto.IProEconWindturbineGoodnessService;
  15. import com.gyee.runeconomy.util.DateUtils;
  16. import com.gyee.runeconomy.util.StringUtils;
  17. import com.gyee.runeconomy.util.realtimesource.IEdosUtil;
  18. import org.springframework.stereotype.Service;
  19. import javax.annotation.Resource;
  20. import java.math.BigDecimal;
  21. import java.math.RoundingMode;
  22. import java.text.SimpleDateFormat;
  23. import java.util.*;
  24. /**
  25. * @ClassName : WindturbinegoodnessService
  26. * @Author : xieshengjie
  27. * @Date: 2021/2/20 20:35
  28. * @Description : 单机性能总览service
  29. */
  30. @Service
  31. public class WindturbinegoodnessService {
  32. @Resource
  33. private IProEconWindturbineGoodnessService proEconWindturbineGoodnessService;
  34. @Resource
  35. private IProEconEquipmentInfoDay6Service proEconEquipmentInfoDay6Service;
  36. @Resource
  37. private IEdosUtil edosUtil;
  38. public Page<ProEconWindturbineGoodness> windturbinegoodnessList(Integer pageNum, Integer pageSize, String cmId, String type, String wpId, String recorddate) {
  39. if (StringUtils.empty(pageNum)) {
  40. pageNum = 1;
  41. }
  42. if (StringUtils.empty(pageSize)) {
  43. pageSize = 10;
  44. }
  45. //构造分页构造器
  46. Page<ProEconWindturbineGoodness> pageInfo = new Page<>(pageNum, pageSize);
  47. if (StringUtils.notEmp(type) && StringUtils.notEmp(recorddate)) {
  48. Date date = com.gyee.common.util.DateUtils.parseDate(recorddate);
  49. //构造条件构造器
  50. LambdaQueryWrapper<ProEconWindturbineGoodness> queryWrapper = new LambdaQueryWrapper<>();
  51. //添加过滤条件
  52. if (StringUtils.notEmp(wpId)) {
  53. queryWrapper.eq(ProEconWindturbineGoodness::getWindtpowerstationId, wpId).
  54. eq(ProEconWindturbineGoodness::getRecordDate, date);
  55. if (StringUtils.notEmp(type) && !type.equals("0")) {
  56. queryWrapper.eq(ProEconWindturbineGoodness::getTypes, type);
  57. }
  58. } else if (StringUtils.notEmp(cmId) && CacheContext.cpmap.containsKey(cmId)) {
  59. queryWrapper.
  60. eq(ProEconWindturbineGoodness::getCompanyId, cmId).
  61. eq(ProEconWindturbineGoodness::getRecordDate, date);
  62. if (StringUtils.notEmp(type) && !type.equals("0")) {
  63. queryWrapper.eq(ProEconWindturbineGoodness::getTypes, type);
  64. }
  65. } else if (StringUtils.notEmp(cmId) && CacheContext.rgmap.containsKey(cmId)) {
  66. queryWrapper.eq(ProEconWindturbineGoodness::getRegionId, cmId).
  67. eq(ProEconWindturbineGoodness::getRecordDate, date);
  68. if (StringUtils.notEmp(type) && !type.equals("0")) {
  69. queryWrapper.eq(ProEconWindturbineGoodness::getTypes, type);
  70. }
  71. }
  72. queryWrapper.orderByAsc(ProEconWindturbineGoodness::getWindturbineId);
  73. //执行查询
  74. proEconWindturbineGoodnessService.page(pageInfo, queryWrapper);
  75. }
  76. return pageInfo;
  77. }
  78. /**
  79. * 初始化折线图数据
  80. *
  81. * @return
  82. */
  83. public List<DataVo> findWtRealPowerChar(String wtId, Date recorddate) throws Exception {
  84. List<DataVo> vos = new ArrayList<DataVo>();
  85. SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
  86. SimpleDateFormat sdfs = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  87. Date endDate = sdfs.parse(sdf.format(DateUtils.addDays(recorddate, 1)) + " 01:00:00");
  88. Date beginDate = sdfs.parse(sdf.format(recorddate) + " 00:00:00");
  89. int length = 25;
  90. for (int i = 0; i < length; i++) {
  91. DataVo vo = new DataVo();
  92. vo.setValue1(0.0);// 实发功率
  93. vo.setValue2(0.0);// 保证功率
  94. vo.setValue3(0.0);// 风速
  95. vo.setValue4(0.0);// 状态
  96. vos.add(vo);
  97. }
  98. Map<String, ProBasicEquipmentPoint> wtpointmap = CacheContext.wtpAimap.get(wtId);
  99. ProBasicEquipmentPoint sjgl = wtpointmap.get(ContantXk.CJ_SSGL);
  100. // ProBasicEquipmentPoint bzgl = wtpointmap.get(ContantXk.ZSGL);
  101. // ProBasicEquipmentPoint bzgl = wtpointmap.get(ContantXk.BZGL);
  102. ProBasicEquipmentPoint bzgl = wtpointmap.get(ContantXk.SSBZGL);
  103. ProBasicEquipmentPoint pjfs = wtpointmap.get(ContantXk.CJ_SSFS);
  104. // WindTurbineTestingPointAi2 fs = map.get(ContantXk.TPOINT_WT_PJFS);
  105. List<PointData> sjglls = null;
  106. if (null != sjgl) {
  107. sjglls = edosUtil.getHistoryDatasSnap(sjgl, beginDate.getTime() / 1000, endDate.getTime() / 1000, (long) length, 3600L);
  108. if (!sjglls.isEmpty()) {
  109. int count = 0;
  110. double temp = 0;
  111. for (int i = 0; i < vos.size(); i++) {
  112. vos.get(i).setTime(sjglls.get(i).getPointTime());
  113. if (i < sjglls.size() && StringUtils.notEmp(sjglls.get(i).getPointTime())) {
  114. if (vos.get(i).getTime() <= DateUtils.now().getTime()) {
  115. temp = sjglls.get(i).getPointValueInDouble();
  116. if (Math.abs(temp) < 10000) {
  117. vos.get(i).setValue1(StringUtils.round(temp, 2));// 实际功率
  118. }
  119. count++;
  120. } else {
  121. vos.get(i).setValue1(0d);// 实际功率
  122. }
  123. }
  124. }
  125. }
  126. }
  127. if (null != bzgl) {
  128. List<PointData> bzglls = edosUtil.getHistoryDatasSnap(bzgl, beginDate.getTime() / 1000, endDate.getTime() / 1000, (long) length, 3600L);
  129. if (!bzglls.isEmpty()) {
  130. int count = 0;
  131. double temp = 0;
  132. for (int i = 0; i < vos.size(); i++) {
  133. vos.get(i).setTime(bzglls.get(i).getPointTime());
  134. if (i < bzglls.size() && StringUtils.notEmp(bzglls.get(i).getPointTime())) {
  135. if (vos.get(i).getTime() <= DateUtils.now().getTime()) {
  136. temp = bzglls.get(i).getPointValueInDouble();
  137. if (Math.abs(temp) < 10000) {
  138. if (sjglls != null && sjglls.get(i).getPointValueInDouble() > temp) {
  139. temp = sjglls.get(i).getPointValueInDouble();
  140. }
  141. vos.get(i).setValue2(StringUtils.round(temp, 2));// 保证功率
  142. }
  143. count++;
  144. } else {
  145. vos.get(i).setValue2(0d);// 保证功率
  146. }
  147. }
  148. }
  149. }
  150. }
  151. if (null != pjfs) {
  152. List<PointData> pjfsls = edosUtil.getHistoryDatasSnap(pjfs, beginDate.getTime() / 1000, endDate.getTime() / 1000, (long) length, 3600L);
  153. if (!pjfsls.isEmpty()) {
  154. int count = 0;
  155. double temp = 0;
  156. for (int i = 0; i < vos.size(); i++) {
  157. vos.get(i).setTime(pjfsls.get(i).getPointTime());
  158. if (i < pjfsls.size() && StringUtils.notEmp(pjfsls.get(i).getPointTime())) {
  159. if (vos.get(i).getTime() <= DateUtils.now().getTime()) {
  160. temp = pjfsls.get(i).getPointValueInDouble();
  161. vos.get(i).setValue3(StringUtils.round(temp, 2));// 风速
  162. count++;
  163. } else {
  164. vos.get(i).setValue3(0d);// 实际功率
  165. }
  166. }
  167. }
  168. }
  169. }
  170. return vos;
  171. }
  172. public List<List<EchartDataVo>> getplotBands(String wtId, Date recorddate) throws Exception {
  173. SimpleDateFormat sdf = new SimpleDateFormat("HH:mm");
  174. SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM-dd HH:mm");
  175. Calendar c = Calendar.getInstance();
  176. c.setTime(recorddate);
  177. c.set(Calendar.HOUR_OF_DAY, 0);
  178. c.set(Calendar.MINUTE, 0);
  179. c.set(Calendar.SECOND, 0);
  180. c.set(Calendar.MILLISECOND, 0);
  181. Date beginDate = c.getTime();
  182. c.add(Calendar.DAY_OF_MONTH, 1);
  183. Date endDate = c.getTime();
  184. List<String> xtime = new ArrayList<>();
  185. List<EchartDataVo> vos = new ArrayList<>();
  186. List<List<EchartDataVo>> resultvos = new ArrayList<>();
  187. Map<String, String> map = new HashMap<>();
  188. int length = 240;
  189. String plotBands = null;
  190. StringBuilder sb = new StringBuilder("");
  191. Map<String, ProBasicEquipmentPoint> wtpointmap = CacheContext.wtpAimap.get(wtId);
  192. ProBasicEquipmentPoint fjzt = wtpointmap.get(ContantXk.SBZT);
  193. String beginTime = null;
  194. String endTime = null;
  195. String time = null;
  196. if (null != fjzt) {
  197. List<PointData> fjztls = edosUtil.getHistoryDatasSnap(fjzt, beginDate.getTime() / 1000, endDate.getTime() / 1000, (long) length, 360L);
  198. int zt = 0;
  199. for (int i = 0; i < fjztls.size(); i++) {
  200. if (i < fjztls.size()) {
  201. PointData pd = fjztls.get(i);
  202. int zttemp = Double.valueOf(pd.getPointValueInDouble()).intValue();
  203. Date resultDate = new Date(pd.getPointTime());
  204. beginTime = sdf.format(resultDate);
  205. time = sdf2.format(resultDate);
  206. xtime.add(beginTime);
  207. if (i == 0) {
  208. zt = zttemp;
  209. EchartDataVo vo = new EchartDataVo();
  210. vo.setxAxis(beginTime);
  211. vo.setTime1(time);
  212. vo.setName(judgeSatte(zttemp));
  213. EchartDataVo.ItemStyle item = vo.new ItemStyle();
  214. item.setColor(judgeColor(zttemp));
  215. vo.setItemStyle(item);
  216. vos.add(vo);
  217. } else {
  218. if (zt != zttemp) {
  219. zt = zttemp;
  220. c = Calendar.getInstance();
  221. c.setTime(resultDate);
  222. // c.add(Calendar.MINUTE, -6);
  223. endTime = sdf.format(c.getTime());
  224. time = sdf2.format(c.getTime());
  225. vos.get(0).setTime2(time);
  226. EchartDataVo vo = new EchartDataVo();
  227. vo.setxAxis(endTime);
  228. vos.add(vo);
  229. if (vos.size() == 2) {
  230. resultvos.add(vos);
  231. vos = new ArrayList<>();
  232. vo = new EchartDataVo();
  233. vo.setxAxis(beginTime);
  234. vo.setTime1(sdf2.format(resultDate));
  235. vo.setName(judgeSatte(zttemp));
  236. EchartDataVo.ItemStyle item = vo.new ItemStyle();
  237. item.setColor(judgeColor(zttemp));
  238. vo.setItemStyle(item);
  239. vos.add(vo);
  240. }
  241. } else if (i == fjztls.size() - 1) {
  242. zt = zttemp;
  243. c = Calendar.getInstance();
  244. c.setTime(resultDate);
  245. // c.add(Calendar.MINUTE, -6);
  246. endTime = sdf.format(c.getTime());
  247. time = sdf2.format(c.getTime());
  248. vos.get(0).setTime2(time);
  249. EchartDataVo vo = new EchartDataVo();
  250. vo.setxAxis(endTime);
  251. vo.setxAxis(beginTime);
  252. vo.setTime1(sdf2.format(resultDate));
  253. vo.setName(judgeSatte(zttemp));
  254. EchartDataVo.ItemStyle item = vo.new ItemStyle();
  255. item.setColor(judgeColor(zttemp));
  256. vo.setItemStyle(item);
  257. vos.add(vo);
  258. resultvos.add(vos);
  259. }
  260. }
  261. }
  262. }
  263. }
  264. return resultvos;
  265. }
  266. private String judgeSatte(int zt) {
  267. String ztname = null;
  268. switch (zt) {
  269. case 0:
  270. ztname = "待机";
  271. break;
  272. case 1:
  273. ztname = "运行";
  274. break;
  275. case 2:
  276. ztname = "故障";
  277. break;
  278. case 3:
  279. ztname = "检修";
  280. break;
  281. case 4:
  282. ztname = "限电";
  283. break;
  284. case 5:
  285. ztname = "受累";
  286. break;
  287. case 6:
  288. ztname = "中断";
  289. break;
  290. default:
  291. }
  292. return ztname;
  293. }
  294. // 运行 #08FCF0 待机 #34A90A 维护 #FD7D1C 故障 #FD0100 限电 #D201D8 离线 #A6A6A6
  295. private String judgeColor(int zt) {
  296. String ztname = null;
  297. switch (zt) {
  298. case 0:
  299. ztname = "#BFFFDF";
  300. break;
  301. case 1:
  302. ztname = "#E7FFFF";
  303. break;
  304. case 2:
  305. ztname = "#FFBFBF";
  306. break;
  307. case 3:
  308. ztname = "#FFDFBF";
  309. break;
  310. case 4:
  311. ztname = "#FFDFFF";
  312. break;
  313. case 5:
  314. ztname = "#FFDFFF";
  315. break;
  316. case 6:
  317. ztname = "#DDDDDD";
  318. break;
  319. default:
  320. }
  321. return ztname;
  322. }
  323. public Map<String, String> getPlotBand(String wtId, String begin, String end) throws Exception {
  324. Map<String, ProBasicEquipmentPoint> wtpointmap = CacheContext.wtpAimap.get(wtId);
  325. ProBasicEquipmentPoint fdlAi = wtpointmap.get(ContantXk.RFDL);
  326. ProBasicEquipmentPoint fsAi = wtpointmap.get(ContantXk.CJ_SSFS);
  327. ProBasicEquipmentPoint llfdlAi = wtpointmap.get(ContantXk.RLLFDL);
  328. ProBasicEquipmentPoint glAi = wtpointmap.get(ContantXk.CJ_SSGL);
  329. ProBasicEquipmentPoint fjztAi = wtpointmap.get(ContantXk.SBZT);
  330. Date begindate = DateUtils.parseDate5(begin);
  331. Date enddate = DateUtils.parseDate5(end);
  332. Map<String, String> tempmap = new HashMap<String, String>();
  333. // 发电量
  334. double beginfdl = 0.0;
  335. double endfdl = 0.0;
  336. double fdl = 0.0;
  337. // String[] id=new String[1];
  338. // DNAVal[] val= edosUtil.getHistMatrix(id,begindate.getTime() / 1000);
  339. // beginfdl=val[0].DValue;
  340. // val= edosUtil.getHistMatrix(id,enddate.getTime() / 1000);
  341. // endfdl=val[0].DValue;
  342. List<PointData> beginfdlls = edosUtil.getHistoryDatasSnap(fdlAi,
  343. begindate.getTime() / 1000, begindate.getTime() / 1000,
  344. (long) 1, 3600L);
  345. if (!beginfdlls.isEmpty()) {
  346. beginfdl = beginfdlls.get(0).getPointValueInDouble();
  347. }
  348. List<PointData> endfdlls = edosUtil.getHistoryDatasSnap(fdlAi,
  349. enddate.getTime() / 1000, enddate.getTime() / 1000, (long) 1,
  350. 3600L);
  351. if (!endfdlls.isEmpty()) {
  352. endfdl = endfdlls.get(0).getPointValueInDouble();
  353. }
  354. fdl = endfdl - beginfdl;
  355. tempmap.put("fdl", String.valueOf(StringUtils.round(fdl, 2)));
  356. // 理论电量
  357. double beginllfdl = 0.0;
  358. double endllfdl = 0.0;
  359. double llfdl = 0.0;
  360. List<PointData> beginllfdls = edosUtil.getHistoryDatasSnap(llfdlAi,
  361. begindate.getTime() / 1000, begindate.getTime() / 1000,
  362. (long) 1, 3600L);
  363. if (!beginllfdls.isEmpty()) {
  364. beginllfdl = beginllfdls.get(0).getPointValueInDouble();
  365. }
  366. List<PointData> endllfdls = edosUtil.getHistoryDatasSnap(llfdlAi,
  367. enddate.getTime() / 1000, enddate.getTime() / 1000, (long) 1,
  368. 3600L);
  369. if (!endllfdls.isEmpty()) {
  370. endllfdl = endllfdls.get(0).getPointValueInDouble();
  371. }
  372. llfdl = endllfdl - beginllfdl;
  373. // llfdl=new BigDecimal(llfdl).multiply(new
  374. // BigDecimal(10000)).doubleValue();
  375. tempmap.put("llfdl", String.valueOf(StringUtils.round(llfdl, 2)));
  376. // 风机状态
  377. int fjzt = 0;
  378. List<PointData> fjztls = edosUtil.getHistoryDatasSnap(fjztAi,
  379. begindate.getTime() / 1000, enddate.getTime() / 1000, (long) 1,
  380. 3600L);
  381. if (!fjztls.isEmpty()) {
  382. fjzt = Double.valueOf(fjztls.get(0).getPointValueInDouble()).intValue();
  383. tempmap.put("fjzt", judgeSatte(fjzt));
  384. }
  385. // 风速
  386. double fs = 0.0;
  387. Double time1 = new BigDecimal(DateUtils.minutesDiff(begindate, enddate))
  388. .divide(new BigDecimal(60), 2, RoundingMode.HALF_EVEN)
  389. .doubleValue();
  390. List<PointData> fsls = edosUtil.getHistoryDatasSnap(fsAi,
  391. begindate.getTime() / 1000, enddate.getTime() / 1000,
  392. (long) time1.longValue(), 3600L);
  393. if (!fsls.isEmpty()) {
  394. for (PointData po : fsls) {
  395. fs = fs + po.getPointValueInDouble();
  396. }
  397. if (time1 == 0) {
  398. time1 = 1.0;
  399. }
  400. double fstemp = new BigDecimal(fs).divide(
  401. new BigDecimal(time1.doubleValue()), 2,
  402. RoundingMode.HALF_EVEN).doubleValue();
  403. tempmap.put("fs", String.valueOf(StringUtils.round(fstemp, 2)));
  404. }
  405. // 功率
  406. double gl = 0.0;
  407. Double time2 = new BigDecimal(DateUtils.minutesDiff(begindate, enddate))
  408. .divide(new BigDecimal(60), 2, RoundingMode.HALF_EVEN)
  409. .doubleValue();
  410. List<PointData> glls = edosUtil.getHistoryDatasSnap(glAi,
  411. begindate.getTime() / 1000, enddate.getTime() / 1000,
  412. (long) time2.longValue(), 3600L);
  413. if (!glls.isEmpty()) {
  414. for (PointData po : glls) {
  415. gl = gl + po.getPointValueInDouble();
  416. }
  417. if (time2 == 0) {
  418. time2 = 1.0;
  419. }
  420. double gltemp = new BigDecimal(gl).divide(
  421. new BigDecimal(time2.doubleValue()), 2,
  422. RoundingMode.HALF_EVEN).doubleValue();
  423. tempmap.put("gl", String.valueOf(StringUtils.round(gltemp, 2)));
  424. }
  425. // 时长
  426. tempmap.put("sc", String.valueOf(StringUtils.round(DateUtils.hoursDiff2(begindate, enddate), 2)));
  427. // 损失电量
  428. if (fjzt != 1) {
  429. fdl = 0.0;
  430. tempmap.put("fdl", "0.0");
  431. tempmap.put("gl", "0.0");
  432. }
  433. tempmap.put("ssdl", String.valueOf(StringUtils.round(llfdl - fdl, 2)));
  434. tempmap.put("ks", begin);
  435. tempmap.put("js", end);
  436. return tempmap;
  437. }
  438. private String getColor(StringBuilder temp, Integer zt) {
  439. if (StringUtils.notEmp(zt)) {
  440. switch (zt) {
  441. case 0:
  442. temp.setLength(0);
  443. temp.append("color: '#BFFFDF',");
  444. break;
  445. case 1:
  446. temp.setLength(0);
  447. temp.append("color: '#E7FFFF',");
  448. break;
  449. case 2:
  450. temp.setLength(0);
  451. temp.append("color: '#FFBFBF',");
  452. break;
  453. case 3:
  454. temp.setLength(0);
  455. temp.append("color: '#DDDDDD',");
  456. break;
  457. case 4:
  458. temp.setLength(0);
  459. temp.append("color: '#FFDFBF',");
  460. break;
  461. case 5:
  462. temp.setLength(0);
  463. temp.append("color: '#FFDFFF',");
  464. break;
  465. case 6:
  466. temp.setLength(0);
  467. temp.append("color: '#FFDFFF',");
  468. break;
  469. default:
  470. break;
  471. }
  472. }
  473. return String.valueOf(temp);
  474. }
  475. public List<DataVo> findRealPowerCharBy24(String wtId, Date recorddate) throws Exception {
  476. List<DataVo> vos = new ArrayList<DataVo>();
  477. SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
  478. SimpleDateFormat sdfs = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  479. Date endDate = sdfs.parse(sdf.format(DateUtils.addDays(recorddate, 1)) + " 00:0:00");
  480. Date beginDate = sdfs.parse(sdf.format(recorddate) + " 00:00:00");
  481. int length = 24;
  482. for (int i = 0; i < length; i++) {
  483. DataVo vo = new DataVo();
  484. vo.setValue1(0.0);// scada发电量
  485. vo.setValue2(0.0);// 维护损失
  486. vo.setValue3(0.0);// 故障损失
  487. vo.setValue4(0.0);// 限电损失
  488. vo.setValue5(0.0);// 欠发损失
  489. vo.setValue6(0.0);// 风速
  490. vos.add(vo);
  491. }
  492. Map<String, ProBasicEquipmentPoint> wtpointmap = CacheContext.wtpAimap.get(wtId);
  493. ProBasicEquipmentPoint fdl = wtpointmap.get(ContantXk.RFDL);
  494. ProBasicEquipmentPoint whss = wtpointmap.get(ContantXk.RJXSSDL);
  495. ProBasicEquipmentPoint gzss = wtpointmap.get(ContantXk.RGZSSDL);
  496. ProBasicEquipmentPoint xdss = wtpointmap.get(ContantXk.RXDTJSSDL);
  497. ProBasicEquipmentPoint qfss = wtpointmap.get(ContantXk.RXNSSDL);
  498. ProBasicEquipmentPoint fs = wtpointmap.get(ContantXk.CJ_SSFS);
  499. try {
  500. if (null != fdl) {
  501. List<PointData> fdlls = edosUtil.getHistoryDatasSnap(fdl, beginDate.getTime() / 1000, endDate.getTime() / 1000, (long) length, 3600L);
  502. int count = 0;
  503. double temp1 = 0;
  504. for (int i = 0; i < length; i++) {
  505. if (i < fdlls.size() && StringUtils.notEmp(fdlls.get(i + 1).getPointTime())) {
  506. vos.get(i).setTime(fdlls.get(i + 1).getPointTime());
  507. if (vos.get(i).getTime() <= DateUtils.now().getTime()) {
  508. if (i != 0) {
  509. temp1 = fdlls.get(i + 1).getPointValueInDouble();
  510. double temp2 = fdlls.get(i).getPointValueInDouble();
  511. temp1 = temp1 - temp2;
  512. vos.get(i).setValue1(StringUtils.round(temp1 * 1000, 2));// 发电量
  513. } else {
  514. temp1 = fdlls.get(i + 1).getPointValueInDouble();
  515. vos.get(i).setValue1(StringUtils.round(temp1 * 1000, 2));// 发电量
  516. }
  517. // temp1 = new BigDecimal(temp1).divide(new
  518. // BigDecimal(10000), 2,
  519. // RoundingMode.HALF_EVEN).doubleValue();
  520. // temp1 = new BigDecimal(temp1).divide(
  521. // new BigDecimal(100000), 2,
  522. // RoundingMode.HALF_EVEN).multiply(
  523. // new BigDecimal(100)).doubleValue();
  524. count++;
  525. } else {
  526. vos.get(i).setTime(fdlls.get(i).getPointTime());
  527. vos.get(i).setValue1(0d);// 发电量
  528. }
  529. }
  530. }
  531. }
  532. } catch (Exception e) {
  533. // TODO: handle exception
  534. }
  535. /*
  536. * 维护损失
  537. */
  538. try {
  539. if (null != whss) {
  540. List<PointData> whssls = edosUtil.getHistoryDatasSnap(whss, beginDate.getTime() / 1000, endDate.getTime() / 1000, (long) length, 3600L);
  541. int count = 0;
  542. double temp1 = 0;
  543. for (int i = 0; i < length; i++) {
  544. if (i < whssls.size() && StringUtils.notEmp(whssls.get(i + 1).getPointTime())) {
  545. vos.get(i).setTime(whssls.get(i + 1).getPointTime());
  546. if (vos.get(i).getTime() <= DateUtils.now().getTime()) {
  547. if (i != 0) {
  548. temp1 = whssls.get(i + 1).getPointValueInDouble();
  549. double temp2 = whssls.get(i).getPointValueInDouble();
  550. temp1 = temp1 - temp2;
  551. // temp1 = new BigDecimal(temp1).divide(new
  552. // BigDecimal(10000), 2,
  553. // RoundingMode.HALF_EVEN).doubleValue();
  554. vos.get(i).setValue2(StringUtils.round(temp1 * 1000, 2));// 维护损失电量
  555. count++;
  556. } else {
  557. temp1 = whssls.get(i + 1).getPointValueInDouble();
  558. vos.get(i).setValue2(StringUtils.round(temp1 * 1000, 2));// 维护损失电量
  559. }
  560. // temp1 = new BigDecimal(temp1).divide(
  561. // new BigDecimal(100000), 2,
  562. // RoundingMode.HALF_EVEN).multiply(
  563. // new BigDecimal(100)).doubleValue();
  564. } else {
  565. // vos.get(i-1).setTime(whssls.get(i).getPointTime()*1000);
  566. vos.get(i).setValue2(0d);// 维护损失电量
  567. }
  568. }
  569. }
  570. }
  571. } catch (Exception e) {
  572. // TODO: handle exception
  573. }
  574. /*
  575. * 故障损失
  576. */
  577. try {
  578. if (null != gzss) {
  579. List<PointData> gzssls = edosUtil.getHistoryDatasSnap(gzss, beginDate.getTime() / 1000, endDate.getTime() / 1000, (long) length, 3600L);
  580. int count = 0;
  581. double temp1 = 0;
  582. for (int i = 0; i < length; i++) {
  583. if (i < gzssls.size() && StringUtils.notEmp(gzssls.get(i + 1).getPointTime())) {
  584. vos.get(i).setTime(gzssls.get(i + 1).getPointTime());
  585. if (vos.get(i).getTime() <= DateUtils.now().getTime()) {
  586. if (i != 0) {
  587. temp1 = gzssls.get(i + 1).getPointValueInDouble();
  588. double temp2 = gzssls.get(i).getPointValueInDouble();
  589. temp1 = temp1 - temp2;
  590. // temp1 = new BigDecimal(temp1).divide(new
  591. // BigDecimal(10000), 2,
  592. // RoundingMode.HALF_EVEN).doubleValue();
  593. // temp1 = new BigDecimal(temp1).divide(
  594. // new BigDecimal(100000), 2,
  595. // RoundingMode.HALF_EVEN).multiply(
  596. // new BigDecimal(100)).doubleValue();
  597. vos.get(i).setValue3(StringUtils.round(temp1 * 1000, 2));// 维护损失电量
  598. count++;
  599. } else {
  600. temp1 = gzssls.get(i + 1).getPointValueInDouble();
  601. vos.get(i).setValue3(StringUtils.round(temp1 * 1000, 2));// 维护损失电量
  602. }
  603. } else {
  604. // vos.get(i-1).setTime(gzssls.get(i).getPointTime()*1000);
  605. vos.get(i).setValue3(0d);// 维护损失电量
  606. }
  607. }
  608. }
  609. }
  610. } catch (Exception e) {
  611. // TODO: handle exception
  612. }
  613. /*
  614. * 限电损失
  615. */
  616. try {
  617. if (null != xdss) {
  618. List<PointData> xdssls = edosUtil.getHistoryDatasSnap(xdss, beginDate.getTime() / 1000, endDate.getTime() / 1000, (long) length, 3600L);
  619. int count = 0;
  620. double temp1 = 0;
  621. for (int i = 0; i < length; i++) {
  622. if (i < xdssls.size() && StringUtils.notEmp(xdssls.get(i + 1).getPointTime())) {
  623. vos.get(i).setTime(xdssls.get(i + 1).getPointTime());
  624. if (vos.get(i).getTime() <= DateUtils.now().getTime()) {
  625. if (i != 0) {
  626. temp1 = xdssls.get(i + 1).getPointValueInDouble();
  627. double temp2 = xdssls.get(i).getPointValueInDouble();
  628. temp1 = temp1 - temp2;
  629. // temp1 = new BigDecimal(temp1).divide(new
  630. // BigDecimal(10000), 2,
  631. // RoundingMode.HALF_EVEN).doubleValue();
  632. // temp1 = new BigDecimal(temp1).divide(
  633. // new BigDecimal(100000), 2,
  634. // RoundingMode.HALF_EVEN).multiply(
  635. // new BigDecimal(100)).doubleValue();
  636. vos.get(i).setValue4(StringUtils.round(temp1 * 1000, 2));// 限电损失电量
  637. count++;
  638. } else {
  639. temp1 = xdssls.get(i + 1).getPointValueInDouble();
  640. vos.get(i).setValue4(StringUtils.round(temp1 * 1000, 2));// 限电损失电量
  641. }
  642. } else {
  643. // vos.get(i).setTime(xdssls.get(i).getPointTime()*1000);
  644. vos.get(i).setValue4(0d);// 限电损失电量
  645. }
  646. }
  647. }
  648. }
  649. } catch (Exception e) {
  650. // TODO: handle exception
  651. }
  652. /*
  653. * 欠发损失
  654. */
  655. try {
  656. if (null != qfss) {
  657. List<PointData> qfssls = edosUtil.getHistoryDatasSnap(qfss, beginDate.getTime() / 1000, endDate.getTime() / 1000, (long) length, 3600L);
  658. int count = 0;
  659. double temp1 = 0;
  660. for (int i = 0; i < length; i++) {
  661. if (i < qfssls.size() && StringUtils.notEmp(qfssls.get(i + 1).getPointTime())) {
  662. vos.get(i).setTime(qfssls.get(i + 1).getPointTime());
  663. if (vos.get(i).getTime() <= DateUtils.now().getTime()) {
  664. if (i != 0) {
  665. temp1 = qfssls.get(i + 1).getPointValueInDouble();
  666. double temp2 = qfssls.get(i).getPointValueInDouble();
  667. temp1 = temp1 - temp2;
  668. // temp1 = new BigDecimal(temp1).divide(new
  669. // BigDecimal(10000), 2,
  670. // RoundingMode.HALF_EVEN).doubleValue();
  671. // temp1 = new BigDecimal(temp1).divide(
  672. // new BigDecimal(100000), 2,
  673. // RoundingMode.HALF_EVEN).multiply(
  674. // new BigDecimal(100)).doubleValue();
  675. vos.get(i).setValue5(StringUtils.round(temp1, 2));// 欠发损失电量
  676. count++;
  677. } else {
  678. temp1 = qfssls.get(i + 1).getPointValueInDouble();
  679. vos.get(i).setValue5(StringUtils.round(temp1, 2));// 欠发损失电量
  680. }
  681. } else {
  682. vos.get(i - 1).setTime(qfssls.get(i).getPointTime() * 1000);
  683. vos.get(i).setValue5(0d);// 欠发损失电量
  684. }
  685. }
  686. }
  687. }
  688. } catch (Exception e) {
  689. // TODO: handle exception
  690. }
  691. /*
  692. * 风速
  693. */
  694. try {
  695. if (null != fs) {
  696. List<PointData> fsls = edosUtil.getHistoryDatasSnap(fs, beginDate.getTime() / 1000, endDate.getTime() / 1000, (long) length, 3600L);
  697. int count = 0;
  698. double temp1 = 0;
  699. for (int i = 0; i < 24; i++) {
  700. if (i < fsls.size() && StringUtils.notEmp(fsls.get(i + 1).getPointTime())) {
  701. vos.get(i).setTime(fsls.get(i + 1).getPointTime());
  702. if (vos.get(i).getTime() <= DateUtils.now().getTime()) {
  703. temp1 = fsls.get(i + 1).getPointValueInDouble();
  704. // double temp2
  705. // =fsls.get(i-1).getPointValueInDouble();
  706. // temp1=temp1-temp2;
  707. // temp1 = new BigDecimal(temp1).divide(new
  708. // BigDecimal(1), 2,
  709. // RoundingMode.HALF_EVEN).doubleValue();
  710. // temp1 = new BigDecimal(temp1).divide(
  711. // new BigDecimal(100000), 2,
  712. // RoundingMode.HALF_EVEN).multiply(
  713. // new BigDecimal(100)).doubleValue();
  714. vos.get(i).setValue6(StringUtils.round(temp1, 2));// 风速
  715. count++;
  716. // else
  717. // {
  718. // temp1 = qfssls.get(i).getPointValueInDouble();
  719. // }
  720. } else {
  721. // vos.get(i-1).setTime(qfssls.get(i).getPointTime()*1000);
  722. vos.get(i).setValue6(0d);// 风速
  723. }
  724. }
  725. }
  726. }
  727. } catch (Exception e) {
  728. // TODO: handle exception
  729. }
  730. // ////////////////////////////////////////////////
  731. return vos;
  732. }
  733. public List<PvVo> pvgoodness(String companys, String wpid, String recorddate, String target, String sort) {
  734. Map<String, ProEconEquipmentmodel> modelMap = CacheContext.modelMap;
  735. Map<String, ProBasicEquipment> wtmap = CacheContext.wtmap;
  736. List<PvVo> resultList = new ArrayList<>();
  737. LambdaQueryWrapper<ProEconEquipmentInfoDay6> qw = new LambdaQueryWrapper<>();
  738. qw.eq(ProEconEquipmentInfoDay6::getRecordDate, DateUtils.parseDate(recorddate));
  739. if (StringUtils.isNotEmpty(companys)) {
  740. if (companys.endsWith("ZGS")) {
  741. qw.eq(ProEconEquipmentInfoDay6::getCompanyId, companys);
  742. }
  743. if (companys.endsWith("RGN")) {
  744. qw.eq(ProEconEquipmentInfoDay6::getRegionId, companys);
  745. }
  746. }
  747. if (StringUtils.isNotEmpty(wpid)) {
  748. qw.eq(ProEconEquipmentInfoDay6::getWindpowerstationId, wpid);
  749. }
  750. List<ProEconEquipmentInfoDay6> equipmentInfoDay6s = proEconEquipmentInfoDay6Service.list(qw);
  751. equipmentInfoDay6s.stream().forEach(i -> {
  752. PvVo vo = new PvVo();
  753. vo.setWtid(i.getWindturbineId());
  754. vo.setWtname(wtmap.get(i.getWindturbineId()).getAname());
  755. vo.setModel(modelMap.get(wtmap.get(i.getWindturbineId()).getModelId()).getAname());
  756. vo.setRxtxl(DoubleUtils.keepPrecision(i.getRxtxl(), 2));
  757. vo.setRlsl(DoubleUtils.keepPrecision(i.getRlsl(), 2));
  758. vo.setRzhxl(DoubleUtils.keepPrecision(i.getRnbqzhxl(), 2));
  759. vo.setYxtxl(DoubleUtils.keepPrecision(i.getYxtxl(), 2));
  760. vo.setYlsl(DoubleUtils.keepPrecision(i.getYlsl(), 2));
  761. vo.setYzhxl(DoubleUtils.keepPrecision(i.getYnbqzhxl(), 2));
  762. vo.setNxtxl(DoubleUtils.keepPrecision(i.getNxtxl(), 2));
  763. vo.setNlsl(DoubleUtils.keepPrecision(i.getNlsl(), 2));
  764. vo.setNzhxl(DoubleUtils.keepPrecision(i.getNnbqzhxl(), 2));
  765. resultList.add(vo);
  766. });
  767. if (StringUtils.isNotEmpty(target)) {
  768. if (sort.equals("1"))
  769. SortUtils.sort(resultList, target, SortUtils.ASC);
  770. SortUtils.sort(resultList, target, SortUtils.DESC);
  771. }
  772. return resultList;
  773. }
  774. public List<PvVo> pvgoodnesshis(String wpid, String wtid, String beginDate, String endDate, String target, String sort) {
  775. Map<String, ProEconEquipmentmodel> modelMap = CacheContext.modelMap;
  776. Map<String, ProBasicEquipment> wtmap = CacheContext.wtmap;
  777. List<PvVo> resultList = new ArrayList<>();
  778. LambdaQueryWrapper<ProEconEquipmentInfoDay6> qw = new LambdaQueryWrapper<>();
  779. qw.le(ProEconEquipmentInfoDay6::getRecordDate, DateUtils.parseDate(endDate));
  780. qw.ge(ProEconEquipmentInfoDay6::getRecordDate, DateUtils.parseDate(beginDate));
  781. if (StringUtils.isNotEmpty(wpid)) {
  782. qw.eq(ProEconEquipmentInfoDay6::getWindpowerstationId, wpid);
  783. }
  784. if (StringUtils.isNotEmpty(wtid)) {
  785. qw.eq(ProEconEquipmentInfoDay6::getWindturbineId, wtid);
  786. }
  787. List<ProEconEquipmentInfoDay6> equipmentInfoDay6s = proEconEquipmentInfoDay6Service.list(qw);
  788. equipmentInfoDay6s.stream().forEach(i -> {
  789. PvVo vo = new PvVo();
  790. vo.setWtid(i.getWindturbineId());
  791. vo.setWtname(wtmap.get(i.getWindturbineId()).getAname());
  792. vo.setDate(i.getRecordDate());
  793. vo.setModel(modelMap.get(wtmap.get(i.getWindturbineId()).getModelId()).getAname());
  794. vo.setRxtxl(DoubleUtils.keepPrecision(i.getRxtxl(), 2));
  795. vo.setRlsl(DoubleUtils.keepPrecision(i.getRlsl(), 2));
  796. vo.setRzhxl(DoubleUtils.keepPrecision(i.getRnbqzhxl(), 2));
  797. vo.setYxtxl(DoubleUtils.keepPrecision(i.getYxtxl(), 2));
  798. vo.setYlsl(DoubleUtils.keepPrecision(i.getYlsl(), 2));
  799. vo.setYzhxl(DoubleUtils.keepPrecision(i.getYnbqzhxl(), 2));
  800. vo.setNxtxl(DoubleUtils.keepPrecision(i.getNxtxl(), 2));
  801. vo.setNlsl(DoubleUtils.keepPrecision(i.getNlsl(), 2));
  802. vo.setNzhxl(DoubleUtils.keepPrecision(i.getNnbqzhxl(), 2));
  803. resultList.add(vo);
  804. });
  805. if (StringUtils.isNotEmpty(target)) {
  806. if (sort.equals("1"))
  807. SortUtils.sort(resultList, target, SortUtils.ASC);
  808. SortUtils.sort(resultList, target, SortUtils.DESC);
  809. }
  810. return resultList;
  811. }
  812. }