NewIvPvCurveFittingService.java 45 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982
  1. package com.gyee.power.fitting.service.impl;
  2. import com.gyee.power.fitting.common.alg.CurrentVoltageCalc;
  3. import com.gyee.power.fitting.common.alg.PolynomialCurveFitting;
  4. import com.gyee.power.fitting.common.config.GyeeConfig;
  5. import com.gyee.power.fitting.common.constants.Constants;
  6. import com.gyee.power.fitting.common.feign.IAdapterService;
  7. import com.gyee.power.fitting.common.feign.RemoteServiceBuilder;
  8. import com.gyee.power.fitting.common.spring.InitialRunner;
  9. import com.gyee.power.fitting.common.util.DateUtils;
  10. import com.gyee.power.fitting.common.util.FileUtil;
  11. import com.gyee.power.fitting.common.util.PowerFittingUtil;
  12. import com.gyee.power.fitting.model.*;
  13. import com.gyee.power.fitting.model.anno.AnnotationTool;
  14. import com.gyee.power.fitting.model.anno.FixedVo;
  15. import com.gyee.power.fitting.model.custom.FjjxbVo;
  16. import com.gyee.power.fitting.model.custom.PhotovoltaicInfo;
  17. import com.gyee.power.fitting.model.custom.TableTitle;
  18. import com.gyee.power.fitting.model.custom.TsDoubleData;
  19. import com.gyee.power.fitting.service.ProBasicEquipmentPointService;
  20. import com.gyee.power.fitting.service.ProBasicPowerstationPointService;
  21. import com.gyee.power.fitting.service.custom.curve.DataScangfService;
  22. import org.apache.commons.lang3.StringUtils;
  23. import org.apache.commons.math3.fitting.WeightedObservedPoints;
  24. import org.springframework.beans.factory.annotation.Autowired;
  25. import org.springframework.stereotype.Service;
  26. import javax.annotation.Resource;
  27. import javax.servlet.http.HttpServletResponse;
  28. import java.io.File;
  29. import java.math.BigDecimal;
  30. import java.util.*;
  31. import java.util.function.Function;
  32. import java.util.stream.Collectors;
  33. @Service
  34. public class NewIvPvCurveFittingService {
  35. @Resource
  36. private ProBasicWeatherStationServiceImpl weatherStationService;
  37. @Resource
  38. private ProBasicEquipmentPointService proBasicEquipmentPointService;
  39. @Resource
  40. private ProBasicPowerstationPointService proBasicPowerstationPointService;
  41. @Resource
  42. private IAdapterService adpClient;
  43. @Autowired
  44. private RemoteServiceBuilder remoteService;
  45. @Resource
  46. private GyeeConfig config;
  47. @Resource
  48. private PolynomialCurveFitting pncf;
  49. private List<FixedVo> fixedVos;
  50. private Map<String, String> uniforcodes;
  51. @Resource
  52. private DataScangfService dataScangfService;
  53. public void getDatas2File(String stationid, long start, long end, int interval) {
  54. int daym = 24 * 60 * 60 * 1000;
  55. //按天
  56. for (long i = start; i < end; i += daym) {
  57. List<List<PhotovoltaicInfo>> datas = getDatas(stationid, i, i + daym, interval);
  58. infos2File(datas);
  59. }
  60. }
  61. public Map<String, List<PhotovoltaicInfo>> getDatas2File1(String stationid,List<String> inverters, long start, long end, int interval) {
  62. int daym = 24 * 60 * 60 * 1000;
  63. Map<String, List<PhotovoltaicInfo>> wj = new HashMap<>();
  64. //按天
  65. for (long i = start; i < end; i += daym) {
  66. List<List<PhotovoltaicInfo>> datas = getDatasnotfile(stationid,inverters, i, i + daym, interval);
  67. for (List<PhotovoltaicInfo> data : datas) {
  68. List<PhotovoltaicInfo> infos = wj.get(data.get(0).getInverter());
  69. if (infos == null) {
  70. wj.put(data.get(0).getInverter(), data);
  71. } else {
  72. infos.addAll(data);
  73. }
  74. }
  75. }
  76. return wj;
  77. }
  78. private void infos2File(List<List<PhotovoltaicInfo>> datas) {
  79. //文件第一行
  80. List<FixedVo> fixedVos = AnnotationTool.getFixedVoList(PhotovoltaicInfo.class);
  81. String columnName = fixedVos.stream().map(FixedVo::getDes).collect(Collectors.joining(","));
  82. //遍历逆变器
  83. for (List<PhotovoltaicInfo> data : datas) {
  84. PhotovoltaicInfo info = data.get(0);
  85. String station = info.getStation();
  86. String fileName = config.getFilePathPrepare() + "gf" + File.separator + "一秒" + File.separator + station + "-" + info.getInverter() + "-" + DateUtils.date2StringS(new Date(info.getTime())) + ".csv";
  87. File file = new File(fileName);
  88. if (file.exists()) continue;
  89. StringBuilder sb = new StringBuilder();
  90. sb.append(columnName).append("\n");
  91. for (PhotovoltaicInfo datum : data) {
  92. sb.append(datum.getStation()).append(",").append(datum.getInverter()).append(",").append(DateUtils.date2StringL(new Date(datum.getTime())))
  93. .append(",").append(datum.getT()).append(",").append(datum.getS()).append(",").append(datum.getI()).append(",").append(datum.getV())
  94. .append(",").append(datum.getActualP()).append(",").append(datum.getAI()).append(",").append(datum.getAV()).append(",")
  95. .append(datum.getBI()).append(",").append(datum.getBV()).append(",").append(datum.getCI()).append(",").append(datum.getCV())
  96. .append("\n");
  97. }
  98. FileUtil.writeFile(fileName, sb.toString());
  99. }
  100. }
  101. public List<String> getFileList(String station, List<String> nbq, long startdate, int interval, long enddate, boolean isOffline) {
  102. List<String> fileList = new ArrayList<>();
  103. File file = null;
  104. //获取文件位置
  105. if (interval == 1) {
  106. file = new File(config.getFilePathPrepare() + "gf" + File.separator + "一秒" + File.separator);
  107. } else if (interval == 1) {
  108. file = new File(config.getFilePathPrepare() + "gf" + File.separator + "一秒" + File.separator);
  109. }
  110. //获取文件列表
  111. File[] files = file.listFiles();
  112. //如果文件不够,返回null
  113. for (long i = startdate; i < enddate; i += 24 * 60 * 60 * 1000) {
  114. int size = fileList.size();
  115. String s = DateUtils.date2StringS(new Date(i));
  116. for (File f : files) {
  117. if (f.getName().contains(station) && f.getName().contains(s) && jiancha(f.getName(), nbq))
  118. fileList.add(f.getName());
  119. }
  120. if (fileList.size() == size && !isOffline) return null;
  121. }
  122. return fileList;
  123. }
  124. private boolean jiancha(String name, List<String> nbq) {
  125. for (String s : nbq) {
  126. if (name.contains(s)) return true;
  127. }
  128. return false;
  129. }
  130. public Map<String, Object> getTable(String s) {
  131. List<FixedVo> fixedVos = AnnotationTool.getFixedVoList(PhotovoltaicInfo.class);
  132. List<TableTitle> collect = fixedVos.stream().map(d -> new TableTitle(d.getName(), d.getDes())).collect(Collectors.toList());
  133. Map<String, Object> tableMap = new HashMap<>();
  134. String fs = config.getFilePathPrepare() + "gf" + File.separator + s;
  135. List<PhotovoltaicInfo> infos = file2Info(fs, false);
  136. tableMap.put("data", infos);
  137. tableMap.put("title", collect);
  138. return tableMap;
  139. }
  140. private List<PhotovoltaicInfo> file2Info(String path, boolean isAll) {
  141. List<String> strings = FileUtil.readFile(path, isAll);
  142. List<PhotovoltaicInfo> infos = new ArrayList<>();
  143. for (int i = 1; i < strings.size(); i++) {
  144. String[] split = strings.get(i).split(",");
  145. PhotovoltaicInfo info = new PhotovoltaicInfo();
  146. try {
  147. info.setStation(split[0]);
  148. info.setInverter(split[1]);
  149. if (!"".equals(split[2])) {
  150. info.setTime(DateUtils.string2DateL(split[2]).getTime());
  151. info.setDatetime(split[2]);
  152. }
  153. info.setT(StringUtils.isBlank(split[3]) ? 0 : Double.parseDouble(split[3]));
  154. info.setS(StringUtils.isBlank(split[4]) ? 0 : Double.parseDouble(split[4]));
  155. info.setI(StringUtils.isBlank(split[5]) ? 0 : Double.parseDouble(split[5]));
  156. info.setV(StringUtils.isBlank(split[6]) ? 0 : Double.parseDouble(split[6]));
  157. info.setActualP(StringUtils.isBlank(split[7]) ? 0 : Double.parseDouble(split[7]));
  158. info.setAI(StringUtils.isBlank(split[8]) ? 0 : Double.parseDouble(split[8]));
  159. info.setAV(StringUtils.isBlank(split[9]) ? 0 : Double.parseDouble(split[9]));
  160. info.setBI(StringUtils.isBlank(split[10]) ? 0 : Double.parseDouble(split[10]));
  161. info.setBV(StringUtils.isBlank(split[11]) ? 0 : Double.parseDouble(split[11]));
  162. info.setCI(StringUtils.isBlank(split[12]) ? 0 : Double.parseDouble(split[12]));
  163. info.setCV(StringUtils.isBlank(split[13]) ? 0 : Double.parseDouble(split[13]));
  164. } catch (Exception e) {
  165. System.out.println();
  166. }
  167. infos.add(info);
  168. }
  169. return infos;
  170. }
  171. /**
  172. * 计算理论功率加入原列表
  173. *
  174. * @return
  175. */
  176. public Map<String, List<PhotovoltaicInfo>> calculatAnalysis(List<String> fileList) {
  177. String bzcldPath = config.getFilePathPrepare() + "bzd" + File.separator + "标准点.csv";
  178. List<PhotovoltaicInfo> bzclds = file2Info(bzcldPath, true);
  179. Map<String, PhotovoltaicInfo> bzcldMap = bzclds.stream().collect(Collectors.toMap(PhotovoltaicInfo::getInverter, Function.identity()));
  180. String fs = config.getFilePathPrepare() + "gf" + File.separator;
  181. Map<String, List<PhotovoltaicInfo>> stringListMap = new HashMap<>();
  182. for (String s : fileList) {
  183. //读取一个文件
  184. List<PhotovoltaicInfo> infos = file2Info(fs + s, true);
  185. List<PhotovoltaicInfo> theoryInfos;
  186. if (s.contains("HZJ_GDC") || s.contains("AK_GDC")) {
  187. theoryInfos = CurrentVoltageCalc.CalcTheoryPowerHZJ(infos, bzcldMap);
  188. } else {
  189. theoryInfos = CurrentVoltageCalc.CalcTheoryPower(infos, bzcldMap);
  190. }
  191. //按逆变器聚合数据
  192. if (stringListMap.containsKey(theoryInfos.get(0).getInverter())) {
  193. stringListMap.get(theoryInfos.get(0).getInverter()).addAll(theoryInfos);
  194. } else {
  195. stringListMap.put(theoryInfos.get(0).getInverter(), theoryInfos);
  196. }
  197. }
  198. return stringListMap;
  199. }
  200. /**
  201. * 计算理论功率加入原列表
  202. *
  203. * @return
  204. */
  205. public Map<String, List<PhotovoltaicInfo>> calculatAnalysis1(List<PhotovoltaicInfo> bzdList, Map<String, List<PhotovoltaicInfo>> datasInfos) {
  206. Map<String, PhotovoltaicInfo> bzcldMap = bzdList.stream().collect(Collectors.toMap(PhotovoltaicInfo::getInverter, Function.identity()));
  207. Map<String, List<PhotovoltaicInfo>> stringListMap = new HashMap<>();
  208. String s;
  209. for (Map.Entry<String, List<PhotovoltaicInfo>> entry : datasInfos.entrySet()) {
  210. s = entry.getKey();
  211. List<PhotovoltaicInfo> theoryInfos;
  212. if (s.contains("HZJ_GDC") || s.contains("AK_GDC")) {
  213. theoryInfos = CurrentVoltageCalc.CalcTheoryPowerHZJ(entry.getValue(), bzcldMap);
  214. } else {
  215. theoryInfos = CurrentVoltageCalc.CalcTheoryPower(entry.getValue(), bzcldMap);
  216. }
  217. stringListMap.put(s, theoryInfos);
  218. }
  219. return stringListMap;
  220. }
  221. // public Map<String, List<PhotovoltaicInfo>> calculatAnalysis1(List<List<List<PhotovoltaicInfo>>> feill) {
  222. //
  223. // String bzcldPath = config.getFilePathPrepare() + "bzd"+File.separator + "标准点.csv";
  224. // List<PhotovoltaicInfo> bzclds = file2Info(bzcldPath, true);
  225. // Map<String, PhotovoltaicInfo> bzcldMap = bzclds.stream().collect(Collectors.toMap(PhotovoltaicInfo::getInverter, Function.identity()));
  226. //
  227. // String fs = config.getFilePathPrepare() + "gf" +File.separator;
  228. // Map<String, List<PhotovoltaicInfo>> stringListMap = new HashMap<>();
  229. // for (String s : fileList) {
  230. // //读取一个文件
  231. // List<PhotovoltaicInfo> infos = file2Info(fs + s, true);
  232. // List<PhotovoltaicInfo> theoryInfos;
  233. // if (s.contains("HZJ_GDC") || s.contains("AK_GDC")) {
  234. // theoryInfos = CurrentVoltageCalc.CalcTheoryPowerHZJ(infos, bzcldMap);
  235. // } else {
  236. // theoryInfos = CurrentVoltageCalc.CalcTheoryPower(infos, bzcldMap);
  237. // }
  238. // //按逆变器聚合数据
  239. // if (stringListMap.containsKey(theoryInfos.get(0).getInverter())) {
  240. // stringListMap.get(theoryInfos.get(0).getInverter()).addAll(theoryInfos);
  241. //
  242. // } else {
  243. // stringListMap.put(theoryInfos.get(0).getInverter(), theoryInfos);
  244. // }
  245. // }
  246. // return stringListMap;
  247. // }
  248. /**
  249. * 合并同逆变器文件
  250. *
  251. * @param fileList
  252. * @return
  253. */
  254. public Map<String, List<PhotovoltaicInfo>> mergeCalculat(List<String> fileList) {
  255. String fs = config.getFilePathPrepare() + "gf" + File.separator;
  256. Map<String, List<PhotovoltaicInfo>> stringListMap = new HashMap<>();
  257. for (String s : fileList) {
  258. //读取一个文件
  259. List<PhotovoltaicInfo> infos = file2Info(fs + s, true);
  260. //按逆变器聚合数据
  261. if (stringListMap.containsKey(infos.get(0).getInverter())) {
  262. stringListMap.get(infos.get(0).getInverter()).addAll(infos);
  263. } else {
  264. stringListMap.put(infos.get(0).getInverter(), infos);
  265. }
  266. }
  267. return stringListMap;
  268. }
  269. public List<Object> str2FileList(List<String> fileList) {
  270. List<ProEconPowerFittingAnalySis> fileLists = new ArrayList<>();
  271. for (String s : fileList) {
  272. String[] split = s.split("-");
  273. ProEconPowerFittingAnalySis fl = new ProEconPowerFittingAnalySis();
  274. /*fl.setPath(s);
  275. fl.setStation(split[0]);
  276. fl.setStationcn(InitialRunner.gfstationMap.get(split[0]));
  277. fl.setWindturbine(split[1]);
  278. fl.setTime(split[2]+"年"+split[3]+"月");
  279. fl.setInterval("五分钟");*/
  280. fl.setPath(s);
  281. fl.setStation(split[0]);
  282. fl.setStationcn(split[1]);
  283. fl.setWindturbineId(split[1]);
  284. fl.setTime(InitialRunner.newgfstationMap.get(split[0]));
  285. fl.setInterval(split[2] + "年" + split[3] + "月");
  286. fileLists.add(fl);
  287. }
  288. List<Object> objects = PowerFittingUtil.powerDataTree(fileLists, Constants.DATA_FITTING);
  289. return objects;
  290. }
  291. public List<String> getAllFileList() {
  292. //获取文件位置
  293. File file = new File(config.getFilePathPrepare() + "gf" + "一秒");
  294. //获取文件列表
  295. File[] files = file.listFiles();
  296. List<String> fileList = Arrays.stream(files).map(f -> f.getName()).collect(Collectors.toList());
  297. return fileList;
  298. }
  299. /**
  300. * 标准点计算
  301. */
  302. public void standardPointCalculate2() {
  303. List<String> allFileList = getAllFileList();
  304. Map<String, List<PhotovoltaicInfo>> stringListMap = mergeCalculat(allFileList);
  305. List<PhotovoltaicInfo> ptInfos = new ArrayList<>();
  306. for (Map.Entry<String, List<PhotovoltaicInfo>> entry : stringListMap.entrySet()) {
  307. List<PhotovoltaicInfo> value = entry.getValue();
  308. Optional<PhotovoltaicInfo> first = value.stream().sorted(Comparator.comparing(PhotovoltaicInfo::getActualP).reversed()).findFirst();
  309. ptInfos.add(first.get());
  310. }
  311. //文件第一行
  312. List<FixedVo> fixedVos = AnnotationTool.getFixedVoList(PhotovoltaicInfo.class);
  313. StringBuilder sb = new StringBuilder();
  314. String columnName = fixedVos.stream().map(FixedVo::getDes).collect(Collectors.joining(","));
  315. sb.append(columnName).append("\n");
  316. for (PhotovoltaicInfo ptInfo : ptInfos) {
  317. sb.append(ptInfo.getStation()).append(",").append(ptInfo.getInverter()).append(",")
  318. .append(DateUtils.date2StringL(new Date(ptInfo.getTime()))).append(",")
  319. .append(ptInfo.getT()).append(",").append(ptInfo.getS()).append(",")
  320. .append(ptInfo.getI()).append(",").append(ptInfo.getV())
  321. .append(",").append(ptInfo.getActualP()).append(",")
  322. .append(ptInfo.getAI()).append(",").append(ptInfo.getAV())
  323. .append(",").append(ptInfo.getBI()).append(",").append(ptInfo.getBV())
  324. .append(",").append(ptInfo.getCI()).append(",").append(ptInfo.getCV())
  325. .append("\n");
  326. }
  327. String fileName = config.getFilePathPrepare() + "bzd" + File.separator + "标准点.csv";
  328. File file = new File(fileName);
  329. file.delete();
  330. FileUtil.writeFile(fileName, sb.toString());
  331. }
  332. /**
  333. * 标准点计算
  334. *
  335. * @param stringListMap
  336. */
  337. public List<PhotovoltaicInfo> standardPointCalculate1(Map<String, List<PhotovoltaicInfo>> stringListMap) {
  338. List<PhotovoltaicInfo> ptInfos = new ArrayList<>();
  339. for (Map.Entry<String, List<PhotovoltaicInfo>> entry : stringListMap.entrySet()) {
  340. List<PhotovoltaicInfo> value = entry.getValue();
  341. Optional<PhotovoltaicInfo> first = value.stream().sorted(Comparator.comparing(PhotovoltaicInfo::getActualP).reversed()).findFirst();
  342. ptInfos.add(first.get());
  343. }
  344. return ptInfos;
  345. }
  346. public List<TableTitle> getTheoryTitel() {
  347. List<FixedVo> fixedVos = AnnotationTool.getFixedVoList(PhotovoltaicInfo.class);
  348. String[] ss = {"station", "datetime", "T", "S", "actualP"};
  349. List<String> strings = Arrays.asList(ss);
  350. List<TableTitle> collect = fixedVos.stream().map(d -> new TableTitle(d.getName(), d.getDes())).collect(Collectors.toList());
  351. collect = collect.stream().filter(c -> strings.contains(c.getKey())).collect(Collectors.toList());
  352. TableTitle title = new TableTitle();
  353. title.setKey("ideaP");
  354. title.setDes("理论功率");
  355. collect.add(title);
  356. return collect;
  357. }
  358. /**
  359. * 获得所有文件的值
  360. *
  361. * @param fileList
  362. * @return
  363. */
  364. public List<PhotovoltaicInfo> calculatFitting(List<String> fileList) {
  365. String fs = config.getFilePathPrepare() + "gf" + File.separator;
  366. List<PhotovoltaicInfo> infoList = new ArrayList<>();
  367. for (String s : fileList) {
  368. List<PhotovoltaicInfo> infos = file2Info(fs + s, true);
  369. if (infoList.size() == 0 || Objects.equals(infos.get(0).getStation(), infoList.get(0).getStation())) {
  370. infoList.addAll(infos);
  371. }
  372. }
  373. return infoList;
  374. }
  375. public List<double[]> oneFileFitting(List<PhotovoltaicInfo> infos) {
  376. WeightedObservedPoints points = new WeightedObservedPoints();
  377. double max = 0;
  378. for (PhotovoltaicInfo info : infos) {
  379. if (info.getS() < 1) {
  380. points.add(0, 0);
  381. }
  382. points.add(info.getS(), info.getActualP());
  383. if (info.getS() > max) {
  384. max = info.getS();
  385. }
  386. }
  387. double[] result = pncf.run(points);
  388. List<double[]> b = new ArrayList<>();
  389. for (int i = 0; i < max; i += 5) {
  390. double[] curve = new double[2];
  391. curve[0] = i;
  392. curve[1] = pncf.calcPoly(i, result);
  393. b.add(curve);
  394. }
  395. return b;
  396. }
  397. /**
  398. * 光伏绩效榜
  399. *
  400. * @param startdate
  401. * @param enddate
  402. */
  403. public List<FjjxbVo> getPhotovoltaicPerformanceList(long startdate, long enddate, int interval) {
  404. int oneday = 24 * 60 * 60;
  405. String bzcldPath = config.getFilePathPrepare() + "bzd" + File.separator + "标准点.csv";
  406. List<PhotovoltaicInfo> bzclds = file2Info(bzcldPath, true);
  407. Map<String, PhotovoltaicInfo> bzcldMap = bzclds.stream().collect(Collectors.toMap(PhotovoltaicInfo::getInverter, Function.identity()));
  408. //获取实际发电量
  409. List<ProBasicPowerstationPoint> rfdl = proBasicPowerstationPointService.getzfsPoints(null, "RFDL");
  410. List<FjjxbVo> infos = new ArrayList<>();
  411. //遍历逆变器
  412. for (ProBasicPowerstationPoint wstp : rfdl) {
  413. //场站
  414. String stationid = wstp.getWindpowerstationId();
  415. List<TsDoubleData> history = remoteService.adapterfd().getHistorySnap(wstp.getNemCode(), startdate + oneday * 1000, enddate, oneday);
  416. double d = 0;
  417. for (TsDoubleData data : history) {
  418. d += data.getDoubleValue();
  419. }
  420. FjjxbVo vo = new FjjxbVo();
  421. vo.setName(InitialRunner.newgfstationMap.get(stationid));
  422. vo.setSjfdl(d);
  423. //理论发电量
  424. double llfdl = 0;
  425. //光照平均值
  426. double gz = 0;
  427. int i = 0;
  428. double t = 5 / 60;
  429. List<List<PhotovoltaicInfo>> datas = getDatas(stationid, startdate, enddate, interval);
  430. //遍历逆变器
  431. for (List<PhotovoltaicInfo> data : datas) {
  432. if ("HZJ_GDC".equals(stationid) || "AK_GDC".equals(stationid)) {
  433. CurrentVoltageCalc.CalcTheoryPowerHZJ(data, bzcldMap);
  434. } else {
  435. CurrentVoltageCalc.CalcTheoryPower(data, bzcldMap);
  436. }
  437. for (PhotovoltaicInfo datum : data) {
  438. llfdl += datum.getIdeaP() * t;
  439. gz += datum.getS();
  440. i++;
  441. }
  442. }
  443. vo.setLlfdl(llfdl);
  444. vo.setSpeed(gz / i);
  445. vo.setFnlly(vo.getSjfdl() / vo.getLlfdl() * 100);
  446. infos.add(vo);
  447. }
  448. return infos;
  449. }
  450. /**
  451. * 获取数据
  452. *
  453. * @return 逆变器,列表
  454. */
  455. public List<List<PhotovoltaicInfo>> getDatas(String stationid, long start, long end, int interval) {
  456. //间隔
  457. interval = 5 * 60; //5分钟-300
  458. //获得测点
  459. Map<String, String> zglpoints = getPoints(stationid, "zgl");
  460. Map<String, String> llglpoints = getPoints(stationid, "llgl");
  461. Map<String, String> adypoints = getPoints(stationid, "ady");
  462. Map<String, String> bdypoints = getPoints(stationid, "bdy");
  463. Map<String, String> cdypoints = getPoints(stationid, "cdy");
  464. Map<String, String> adlpoints = getPoints(stationid, "adl");
  465. Map<String, String> bdlpoints = getPoints(stationid, "bdl");
  466. Map<String, String> cdlpoints = getPoints(stationid, "cdl");
  467. List<ProBasicWeatherStation> weatherStations = weatherStationService.getBaseMapper().selectList(null);
  468. List<ProBasicWeatherStation> collect = weatherStations.stream().filter(c -> stationid.equals(c.getWindpowerstationId())).collect(Collectors.toList());
  469. String station = collect.get(0).getId();
  470. ProBasicPowerstationPoint zfsPoint = InitialRunner.newzfsMap.get(stationid);
  471. ProBasicPowerstationPoint zjwdPoint = InitialRunner.newzjwdMap.get(station);
  472. //总辐射
  473. // List<TsDoubleData> zfsDatas = adpClient.getHistorySnap(zfsPoint.getNemCode(), start, end, interval);
  474. List<TsDoubleData> zfsDatas = remoteService.adapterfd().getHistorySnap(zfsPoint.getNemCode(), start, end, interval);
  475. //组件温度
  476. // List<TsDoubleData> zjwdDatas = adpClient.getHistorySnap(zjwdPoint.getNemCode(), start, end, interval);
  477. List<TsDoubleData> zjwdDatas = remoteService.adaptergf().getHistorySnap(zjwdPoint.getNemCode(), start, end, interval);
  478. List<List<PhotovoltaicInfo>> infosLit = new ArrayList<>();
  479. //按逆变器
  480. for (String wtid : zglpoints.keySet()) {
  481. //总功率
  482. // List<TsDoubleData> zglDatas = adpClient.getHistorySnap(zglpoints.get(wtid), start, end, interval);
  483. List<TsDoubleData> zglDatas = remoteService.adaptergf().getHistorySnap(zglpoints.get(wtid), start, end, interval);
  484. List<TsDoubleData> llglDatas = remoteService.adapterfd().getHistorySnap(llglpoints.get(wtid), start, end, interval);
  485. //电网A相电压
  486. // List<TsDoubleData> adyDatas = adpClient.getHistorySnap(adypoints.get(wtid), start, end, interval);
  487. List<TsDoubleData> adyDatas = remoteService.adaptergf().getHistorySnap(adypoints.get(wtid), start, end, interval);
  488. //电网A相电流
  489. // List<TsDoubleData> adlDatas = adpClient.getHistorySnap(adlpoints.get(wtid), start, end, interval);
  490. List<TsDoubleData> adlDatas = remoteService.adaptergf().getHistorySnap(adlpoints.get(wtid), start, end, interval);
  491. List<PhotovoltaicInfo> infos = new ArrayList<>();
  492. List<TsDoubleData> bdyDatas = null, cdyDatas = null, bdlDatas = null, cdlDatas = null;
  493. if ("HZJ_GDC".equals(stationid) || "AK_GDC".equals(stationid)) {
  494. //电网B相电压
  495. bdyDatas = adpClient.getHistorySnap(bdypoints.get(wtid), start, end, interval);
  496. //电网C相电压
  497. cdyDatas = adpClient.getHistorySnap(cdypoints.get(wtid), start, end, interval);
  498. //电网B相电流
  499. bdlDatas = adpClient.getHistorySnap(bdlpoints.get(wtid), start, end, interval);
  500. //电网C相电流
  501. cdlDatas = adpClient.getHistorySnap(cdlpoints.get(wtid), start, end, interval);
  502. }
  503. for (int j = 0; j < zfsDatas.size(); j++) {
  504. PhotovoltaicInfo info = new PhotovoltaicInfo();
  505. info.setStation(stationid);
  506. info.setInverter(wtid);
  507. long ts = zfsDatas.get(j).getTs();
  508. info.setTime(ts);
  509. info.setDatetime(DateUtils.date2StringL(new Date(ts)));
  510. info.setT(double3Decimal(zjwdDatas.get(j).getDoubleValue()));
  511. info.setS(double3Decimal(zfsDatas.get(j).getDoubleValue(), false));
  512. if ("HZJ_GDC".equals(stationid) || "AK_GDC".equals(stationid)) {
  513. info.setAI(double3Decimal(adlDatas.get(j).getDoubleValue(), false));
  514. info.setBI(double3Decimal(bdlDatas.get(j).getDoubleValue(), false));
  515. info.setCI(double3Decimal(cdlDatas.get(j).getDoubleValue(), false));
  516. info.setAV(double3Decimal(adyDatas.get(j).getDoubleValue(), true));
  517. info.setBV(double3Decimal(bdyDatas.get(j).getDoubleValue(), true));
  518. info.setCV(double3Decimal(cdyDatas.get(j).getDoubleValue(), true));
  519. } else {
  520. if (adlDatas.size() >= 1) {
  521. info.setI(double3Decimal(adlDatas.get(j).getDoubleValue(), false));
  522. } else {
  523. info.setI(0);
  524. }
  525. if (adyDatas.size() >= 1) {
  526. info.setV(double3Decimal(adyDatas.get(j).getDoubleValue(), true));
  527. } else {
  528. info.setV(0);
  529. }
  530. }
  531. if (zglDatas.size() >= 1) {
  532. info.setActualP(double3Decimal(zglDatas.get(j).getDoubleValue(), false));
  533. } else {
  534. info.setActualP(0);
  535. }
  536. if (llglDatas.size() >= 1) {
  537. info.setIdeaP(double3Decimal(llglDatas.get(j).getDoubleValue(), false));
  538. } else {
  539. info.setIdeaP(0);
  540. }
  541. infos.add(info);
  542. }
  543. infosLit.add(infos);
  544. }
  545. return infosLit;
  546. }
  547. /**
  548. * 获取数据
  549. *
  550. * @return 逆变器,列表
  551. */
  552. public List<List<PhotovoltaicInfo>> getDatasnotfile(String stationid,List<String> inverters, long start, long end, int interval) {
  553. //间隔
  554. // interval = 5 * 60; //5分钟-300
  555. //获得测点
  556. // if (inverters.size()>1){
  557. // for (String s : inverters){
  558. Map<String, String> zglpoints = getPoints1(stationid, inverters, "zgl");
  559. Map<String, String> llglpoints = getPoints1(stationid, inverters, "llgl");
  560. Map<String, String> adypoints = getPoints1(stationid, inverters, "ady");
  561. Map<String, String> bdypoints = getPoints1(stationid, inverters, "bdy");
  562. Map<String, String> cdypoints = getPoints1(stationid, inverters, "cdy");
  563. Map<String, String> adlpoints = getPoints1(stationid, inverters, "adl");
  564. Map<String, String> bdlpoints = getPoints1(stationid, inverters, "bdl");
  565. Map<String, String> cdlpoints = getPoints1(stationid, inverters, "cdl");
  566. List<ProBasicWeatherStation> weatherStations = weatherStationService.getBaseMapper().selectList(null);
  567. List<ProBasicWeatherStation> collect = weatherStations.stream().filter(c -> stationid.equals(c.getWindpowerstationId())).collect(Collectors.toList());
  568. String station = collect.get(0).getId();
  569. ProBasicPowerstationPoint zfsPoint = InitialRunner.newzfsMap.get(stationid);
  570. ProBasicPowerstationPoint zjwdPoint = InitialRunner.newzjwdMap.get(station);
  571. //总辐射
  572. // List<TsDoubleData> zfsDatas = adpClient.getHistorySnap(zfsPoint.getNemCode(), start, end, interval);
  573. List<TsDoubleData> zfsDatas = remoteService.adapterfd().getHistorySnap(zfsPoint.getNemCode(), start, end, interval);
  574. //组件温度
  575. // List<TsDoubleData> zjwdDatas = adpClient.getHistorySnap(zjwdPoint.getNemCode(), start, end, interval);
  576. List<TsDoubleData> zjwdDatas = remoteService.adaptergf().getHistorySnap(zjwdPoint.getNemCode(), start, end, interval);
  577. List<List<PhotovoltaicInfo>> infosLit = new ArrayList<>();
  578. //按逆变器
  579. for (String wtid : zglpoints.keySet()) {
  580. //总功率
  581. // List<TsDoubleData> zglDatas = adpClient.getHistorySnap(zglpoints.get(wtid), start, end, interval);
  582. List<TsDoubleData> zglDatas = remoteService.adaptergf().getHistorySnap(zglpoints.get(wtid), start, end, interval);
  583. List<TsDoubleData> llglDatas = remoteService.adapterfd().getHistorySnap(llglpoints.get(wtid), start, end, interval);
  584. //电网A相电压
  585. // List<TsDoubleData> adyDatas = adpClient.getHistorySnap(adypoints.get(wtid), start, end, interval);
  586. List<TsDoubleData> adyDatas = remoteService.adaptergf().getHistorySnap(adypoints.get(wtid), start, end, interval);
  587. //电网A相电流
  588. // List<TsDoubleData> adlDatas = adpClient.getHistorySnap(adlpoints.get(wtid), start, end, interval);
  589. List<TsDoubleData> adlDatas = remoteService.adaptergf().getHistorySnap(adlpoints.get(wtid), start, end, interval);
  590. List<PhotovoltaicInfo> infos = new ArrayList<>();
  591. List<TsDoubleData> bdyDatas = null, cdyDatas = null, bdlDatas = null, cdlDatas = null;
  592. if ("HZJ_GDC".equals(stationid) || "AK_GDC".equals(stationid)) {
  593. //电网B相电压
  594. bdyDatas = adpClient.getHistorySnap(bdypoints.get(wtid), start, end, interval);
  595. //电网C相电压
  596. cdyDatas = adpClient.getHistorySnap(cdypoints.get(wtid), start, end, interval);
  597. //电网B相电流
  598. bdlDatas = adpClient.getHistorySnap(bdlpoints.get(wtid), start, end, interval);
  599. //电网C相电流
  600. cdlDatas = adpClient.getHistorySnap(cdlpoints.get(wtid), start, end, interval);
  601. }
  602. for (int j = 0; j < zfsDatas.size(); j++) {
  603. PhotovoltaicInfo info = new PhotovoltaicInfo();
  604. info.setStation(stationid);
  605. info.setInverter(wtid);
  606. long ts = zfsDatas.get(j).getTs();
  607. info.setTime(ts);
  608. info.setDatetime(DateUtils.date2StringL(new Date(ts)));
  609. info.setT(double3Decimal(zjwdDatas.get(j).getDoubleValue()));
  610. info.setS(double3Decimal(zfsDatas.get(j).getDoubleValue(), false));
  611. if ("HZJ_GDC".equals(stationid) || "AK_GDC".equals(stationid)) {
  612. info.setAI(double3Decimal(adlDatas.get(j).getDoubleValue(), false));
  613. info.setBI(double3Decimal(bdlDatas.get(j).getDoubleValue(), false));
  614. info.setCI(double3Decimal(cdlDatas.get(j).getDoubleValue(), false));
  615. info.setAV(double3Decimal(adyDatas.get(j).getDoubleValue(), true));
  616. info.setBV(double3Decimal(bdyDatas.get(j).getDoubleValue(), true));
  617. info.setCV(double3Decimal(cdyDatas.get(j).getDoubleValue(), true));
  618. } else {
  619. if (adlDatas.size() >= 1) {
  620. info.setI(double3Decimal(adlDatas.get(j).getDoubleValue(), false));
  621. } else {
  622. info.setI(0);
  623. }
  624. if (adyDatas.size() >= 1) {
  625. info.setV(double3Decimal(adyDatas.get(j).getDoubleValue(), true));
  626. } else {
  627. info.setV(0);
  628. }
  629. }
  630. if (zglDatas.size() >= 1) {
  631. info.setActualP(double3Decimal(zglDatas.get(j).getDoubleValue(), false));
  632. } else {
  633. info.setActualP(0);
  634. }
  635. if (llglDatas.size() >= 1) {
  636. info.setIdeaP(double3Decimal(llglDatas.get(j).getDoubleValue(), false));
  637. } else {
  638. info.setIdeaP(0);
  639. }
  640. infos.add(info);
  641. }
  642. infosLit.add(infos);
  643. }
  644. // }
  645. // }
  646. return infosLit;
  647. }
  648. private double double3Decimal(double d) {
  649. BigDecimal bd = new BigDecimal(d);
  650. return bd.setScale(3, BigDecimal.ROUND_HALF_UP).doubleValue();
  651. }
  652. private double double3Decimal(double d, boolean isMultFactor) {
  653. d = d < 1 ? 0 : d;
  654. if (isMultFactor) {
  655. d = d * 0.001;
  656. }
  657. return double3Decimal(d);
  658. }
  659. /**
  660. * 获得测点
  661. * 逆变器,测点
  662. */
  663. private Map<String, String> getPoints(String stationid, String key) {
  664. switch (key) {
  665. case "zgl":
  666. //总功率
  667. return InitialRunner.newzglMap.get(stationid).stream().filter(c -> !c.getNemCode().equals("INTIAL")).collect(Collectors.toMap(ProBasicEquipmentPoint::getWindturbineId, ProBasicEquipmentPoint::getNemCode));
  668. case "llgl":
  669. //总功率
  670. return InitialRunner.newllglMap.get(stationid).stream().filter(c -> !c.getNemCode().equals("INTIAL")).collect(Collectors.toMap(ProBasicEquipmentPoint::getWindturbineId, ProBasicEquipmentPoint::getNemCode));
  671. case "ady":
  672. List<ProBasicEquipmentPoint> adyPoints = null;
  673. if ("HZJ_GDC".equals(stationid)) {
  674. //电网A相电压
  675. adyPoints = proBasicEquipmentPointService.getPoints(stationid, null, "AIG005");
  676. } else {
  677. //电网A相电压
  678. adyPoints = proBasicEquipmentPointService.getPoints(stationid, null, "AIG005");
  679. }
  680. return adyPoints.stream().filter(c -> !c.getNemCode().equals("INTIAL")).collect(Collectors.toMap(ProBasicEquipmentPoint::getWindturbineId, ProBasicEquipmentPoint::getNemCode));
  681. case "bdy":
  682. List<ProBasicEquipmentPoint> bdyPoints = proBasicEquipmentPointService.getPoints(stationid, null, "AIG008");
  683. return bdyPoints.stream().filter(c -> !c.getNemCode().equals("INTIAL")).collect(Collectors.toMap(ProBasicEquipmentPoint::getWindturbineId, ProBasicEquipmentPoint::getNemCode));
  684. case "cdy":
  685. List<ProBasicEquipmentPoint> cdyPoints = proBasicEquipmentPointService.getPoints(stationid, null, "AIG011");
  686. return cdyPoints.stream().filter(c -> !c.getNemCode().equals("INTIAL")).collect(Collectors.toMap(ProBasicEquipmentPoint::getWindturbineId, ProBasicEquipmentPoint::getNemCode));
  687. case "adl":
  688. List<ProBasicEquipmentPoint> adlPoints = proBasicEquipmentPointService.getPoints(stationid, null, "AIG004");
  689. return adlPoints.stream().filter(c -> !c.getNemCode().equals("INTIAL")).collect(Collectors.toMap(ProBasicEquipmentPoint::getWindturbineId, ProBasicEquipmentPoint::getNemCode));
  690. case "bdl":
  691. List<ProBasicEquipmentPoint> bdlPoints = proBasicEquipmentPointService.getPoints(stationid, null, "AIG007");
  692. return bdlPoints.stream().filter(c -> !c.getNemCode().equals("INTIAL")).collect(Collectors.toMap(ProBasicEquipmentPoint::getWindturbineId, ProBasicEquipmentPoint::getNemCode));
  693. case "cdl":
  694. List<ProBasicEquipmentPoint> cdlPoints = proBasicEquipmentPointService.getPoints(stationid, null, "AIG010");
  695. return cdlPoints.stream().filter(c -> !c.getNemCode().equals("INTIAL")).collect(Collectors.toMap(ProBasicEquipmentPoint::getWindturbineId, ProBasicEquipmentPoint::getNemCode));
  696. }
  697. return new HashMap<>();
  698. }
  699. private Map<String, String> getPoints1(String stationid, List<String> inverters, String key) {
  700. // for (String wt : inverters) {
  701. switch (key) {
  702. case "zgl":
  703. //总功率
  704. Map<String, String> intial = new HashMap<>();
  705. for (String wt : inverters) {
  706. Map<String, String> tempMap = InitialRunner.newzglMap.get(stationid).stream()
  707. .filter(c -> !c.getNemCode().equals("INTIAL") && c.getWindturbineId().equals(wt))
  708. .collect(Collectors.toMap(ProBasicEquipmentPoint::getWindturbineId, ProBasicEquipmentPoint::getNemCode));
  709. intial.putAll(tempMap);
  710. }
  711. return intial;
  712. case "llgl":
  713. //总功率
  714. Map<String, String> intial1 = new HashMap<>();
  715. for (String wt : inverters) {
  716. Map<String, String> tempMap1 = InitialRunner.newllglMap.get(stationid).stream().filter(c -> !c.getNemCode().equals("INTIAL") &&
  717. c.getWindturbineId().equals(wt))
  718. .collect(Collectors.toMap(ProBasicEquipmentPoint::getWindturbineId, ProBasicEquipmentPoint::getNemCode));
  719. intial1.putAll(tempMap1);
  720. }
  721. return intial1;
  722. case "ady":
  723. List<ProBasicEquipmentPoint> adyPoints = null;
  724. if ("HZJ_GDC".equals(stationid)) {
  725. //电网A相电压
  726. adyPoints = proBasicEquipmentPointService.getPoints(stationid, null, "AIG005");
  727. } else {
  728. //电网A相电压
  729. adyPoints = proBasicEquipmentPointService.getPoints(stationid, null, "AIG005");
  730. }
  731. Map<String, String> intial2 = new HashMap<>();
  732. for (String wt : inverters) {
  733. Map<String, String> tempMap2 = adyPoints.stream().filter(c -> !c.getNemCode().equals("INTIAL")&& c.getWindturbineId()
  734. .equals(wt)).collect(Collectors.toMap(ProBasicEquipmentPoint::getWindturbineId, ProBasicEquipmentPoint::getNemCode));
  735. intial2.putAll(tempMap2);
  736. }
  737. return intial2;
  738. case "bdy":
  739. List<ProBasicEquipmentPoint> bdyPoints = proBasicEquipmentPointService.getPoints(stationid, null, "AIG008");
  740. Map<String, String> intial3 = new HashMap<>();
  741. for (String wt : inverters) {
  742. Map<String, String> tempMap3 = bdyPoints.stream().filter(c -> !c.getNemCode().equals("INTIAL")&& c.getWindturbineId().equals(wt))
  743. .collect(Collectors.toMap(ProBasicEquipmentPoint::getWindturbineId, ProBasicEquipmentPoint::getNemCode));
  744. intial3.putAll(tempMap3);
  745. }
  746. return intial3;
  747. case "cdy":
  748. List<ProBasicEquipmentPoint> cdyPoints = proBasicEquipmentPointService.getPoints(stationid, null, "AIG011");
  749. Map<String, String> intial4 = new HashMap<>();
  750. for (String wt : inverters) {
  751. Map<String, String> tempMap4 = cdyPoints.stream().filter(c -> !c.getNemCode().equals("INTIAL")&& c.getWindturbineId().equals(wt))
  752. .collect(Collectors.toMap(ProBasicEquipmentPoint::getWindturbineId, ProBasicEquipmentPoint::getNemCode));
  753. intial4.putAll(tempMap4);
  754. }
  755. return intial4;
  756. case "adl":
  757. List<ProBasicEquipmentPoint> adlPoints = proBasicEquipmentPointService.getPoints(stationid, null, "AIG004");
  758. Map<String, String> intial5 = new HashMap<>();
  759. for (String wt : inverters) {
  760. Map<String, String> tempMap5 = adlPoints.stream().filter(c -> !c.getNemCode().equals("INTIAL")&& c.getWindturbineId().equals(wt))
  761. .collect(Collectors.toMap(ProBasicEquipmentPoint::getWindturbineId, ProBasicEquipmentPoint::getNemCode));
  762. intial5.putAll(tempMap5);
  763. }
  764. return intial5;
  765. case "bdl":
  766. List<ProBasicEquipmentPoint> bdlPoints = proBasicEquipmentPointService.getPoints(stationid, null, "AIG007");
  767. Map<String, String> intial6 = new HashMap<>();
  768. for (String wt : inverters) {
  769. Map<String, String> tempMap6 = bdlPoints.stream().filter(c -> !c.getNemCode().equals("INTIAL")&& c.getWindturbineId().equals(wt))
  770. .collect(Collectors.toMap(ProBasicEquipmentPoint::getWindturbineId, ProBasicEquipmentPoint::getNemCode));
  771. intial6.putAll(tempMap6);
  772. }
  773. return intial6;
  774. case "cdl":
  775. List<ProBasicEquipmentPoint> cdlPoints = proBasicEquipmentPointService.getPoints(stationid, null, "AIG010");
  776. Map<String, String> intial7 = new HashMap<>();
  777. for (String wt : inverters) {
  778. Map<String, String> tempMap7 = cdlPoints.stream().filter(c -> !c.getNemCode().equals("INTIAL")&& c.getWindturbineId().equals(wt))
  779. .collect(Collectors.toMap(ProBasicEquipmentPoint::getWindturbineId, ProBasicEquipmentPoint::getNemCode));
  780. intial7.putAll(tempMap7);
  781. }
  782. return intial7;
  783. }
  784. // }
  785. return new HashMap<>();
  786. }
  787. public int deleteFiles(List<String> fileList) {
  788. String fs = config.getFilePathPrepare() + "gf";
  789. List<PhotovoltaicInfo> infoList = new ArrayList<>();
  790. int count = 0;
  791. for (String s : fileList) {
  792. File file = new File(fs + s);
  793. if (file.delete()) count++;
  794. }
  795. return count;
  796. }
  797. public void downFiles(List<String> strings, HttpServletResponse response) {
  798. List<File> files = path2File(strings);
  799. String path = config.getFilePathPrepare() + "zip\\" + System.currentTimeMillis() + ".zip";
  800. String s = FileUtil.zipFiles(files, new File(path));
  801. FileUtil.download(s, response);
  802. }
  803. private List<File> path2File(List<String> strings) {
  804. List<File> files = new ArrayList<>();
  805. for (String string : strings) {
  806. files.add(new File(config.getFilePathPrepare() + "gf" + string));
  807. }
  808. return files;
  809. }
  810. public List<FixedVo> getFixedVos() {
  811. if (fixedVos == null) {
  812. fixedVos = AnnotationTool.getFixedVoList(PhotovoltaicInfo.class);
  813. uniforcodes = fixedVos.stream().filter(fv -> fv.getUniformCode() != null).collect(Collectors.toMap(FixedVo::getDes, FixedVo::getUniformCode));
  814. }
  815. return fixedVos;
  816. }
  817. public Map<String, String> getUniforcodes() {
  818. getFixedVos();
  819. return uniforcodes;
  820. }
  821. public List<ProBasicEquipment> wtByWplist(String wpids) {
  822. List<ProBasicEquipment> equipmentList = InitialRunner.newgfwtList.stream()
  823. .filter(oe -> wpids.contains(oe.getWindpowerstationId()))
  824. .sorted(Comparator.comparingInt(ProBasicEquipment::getOrderNum)) // 根据order_num字段排序
  825. .collect(Collectors.toList());
  826. return equipmentList;
  827. }
  828. /**
  829. * 通过大点的key获取小散点
  830. *
  831. * @param yk
  832. * @param wk
  833. * @return
  834. */
  835. public List<PhotovoltaicInfo> dataOrigin(String yk, String wk) {
  836. List<PhotovoltaicInfo> list = new ArrayList<>();
  837. if (!StringUtils.isEmpty(yk)) {
  838. String[] key = yk.split(",");
  839. for (String k : key) {
  840. Map<String, List<PhotovoltaicInfo>> mapYY = dataScangfService.getMapYY();
  841. List<PhotovoltaicInfo> photovoltaicInfos = mapYY.get(k);
  842. list.addAll(photovoltaicInfos);
  843. }
  844. }
  845. if (!StringUtils.isEmpty(wk)) {
  846. String[] kew = wk.split(",");
  847. for (String k : kew) {
  848. list.addAll(dataScangfService.getMapWY().get(k));
  849. }
  850. }
  851. return list;
  852. }
  853. }