BackConfigService.java 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497
  1. package com.gyee.backconfig.service;
  2. import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
  3. import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
  4. import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
  5. import com.gyee.backconfig.config.CacheContext;
  6. import com.gyee.backconfig.model.auto.*;
  7. import com.gyee.backconfig.service.auto.*;
  8. import com.gyee.backconfig.vo.*;
  9. import com.gyee.common.model.StringUtils;
  10. import org.springframework.stereotype.Service;
  11. import javax.annotation.Resource;
  12. import java.util.*;
  13. import java.util.stream.Collectors;
  14. /**
  15. * @author 50560
  16. * @create 2022-09-14 13:41
  17. * backConfig:大部分逻辑在此处
  18. */
  19. @Service
  20. public class BackConfigService {
  21. @Resource
  22. private IProjectplanService ProjectplanService;
  23. @Resource
  24. private ICompanysService companysService;
  25. @Resource
  26. private IWindpowerstationService windpowerstationService;
  27. @Resource
  28. private IProjectService projectService;
  29. @Resource
  30. private ILineService lineService;
  31. /**
  32. * @param
  33. * @return
  34. */
  35. //返回所有
  36. public List<Projectplan> backConfigList() {
  37. List<Projectplan> ProjectplanList = ProjectplanService.list();
  38. return ProjectplanList;
  39. }
  40. //根据id返回
  41. public Projectplan projectplanById(String id) {
  42. QueryWrapper<Projectplan> queryWrapper = new QueryWrapper<>();
  43. Projectplan xrpProjectplan = ProjectplanService.getOne(queryWrapper);
  44. queryWrapper.eq("id", id);
  45. return xrpProjectplan;
  46. }
  47. public void updateXpp(Projectplan xpp) {
  48. ProjectplanService.updateById(xpp);
  49. }
  50. public Boolean saveSingle(Projectplan Projectplan) {
  51. return ProjectplanService.saveOrUpdate(Projectplan);
  52. }
  53. //Projectplan分页查询
  54. public Page<Projectplan> listBypage(Projectplanvo vo) {
  55. Page<Projectplan> page = new Page<Projectplan>(vo.getCurrent(), vo.getPageSize());
  56. QueryWrapper<Projectplan> queryWrapper = new QueryWrapper<>();
  57. String id = vo.getId();
  58. String projectid = vo.getProjectid();
  59. String generatingcapacity = vo.getGeneratingcapacity();
  60. Double outagehours = vo.getOutagehours();
  61. String year = vo.getYear();
  62. String month = vo.getMonth();
  63. String windpower = vo.getWindpower();
  64. if (StringUtils.isNotNull(id) && !id.equals("")) {
  65. queryWrapper.eq("id", id);
  66. }
  67. if (StringUtils.isNotNull(projectid) && !projectid.equals("")) {
  68. queryWrapper.eq("projectid", projectid);
  69. }
  70. if (StringUtils.isNotNull(generatingcapacity) && !generatingcapacity.equals("")) {
  71. queryWrapper.eq("generatingcapacity", generatingcapacity);
  72. }
  73. if (StringUtils.isNotNull(outagehours) && outagehours != 0.0) {
  74. queryWrapper.eq("outagehours", outagehours);
  75. }
  76. if (StringUtils.isNotNull(year) && !year.equals("")) {
  77. queryWrapper.eq("year", year);
  78. }
  79. if (StringUtils.isNotNull(month) && !month.equals("")) {
  80. queryWrapper.eq("month", month);
  81. }
  82. if (StringUtils.isNotNull(windpower) && !windpower.equals("")) {
  83. queryWrapper.eq("windpower", windpower);
  84. }
  85. Page<Projectplan> page1 = ProjectplanService.page(page, queryWrapper);
  86. return page1;
  87. }
  88. //期次新增
  89. public boolean saveOrUpdate(Projectplan Projectplan) {
  90. return ProjectplanService.saveOrUpdate(Projectplan);
  91. }
  92. public boolean removeWapper(Projectplan Projectplan) {
  93. QueryWrapper<Projectplan> queryWrapper = new QueryWrapper<Projectplan>();
  94. conditionJudge(Projectplan, queryWrapper);
  95. return ProjectplanService.remove(queryWrapper);
  96. }
  97. private void conditionJudge(Projectplan Projectplan, QueryWrapper<Projectplan> queryWrapper) {
  98. String id = Projectplan.getId();
  99. String projectid = Projectplan.getProjectid();
  100. String generatingcapacity = Projectplan.getGeneratingcapacity();
  101. Double outagehours = Projectplan.getOutagehours();
  102. String year = Projectplan.getYear();
  103. String month = Projectplan.getMonth();
  104. String windpower = Projectplan.getWindpower();
  105. if (StringUtils.isNotNull(id) && !id.equals("")) {
  106. queryWrapper.eq("id", id);
  107. }
  108. if (StringUtils.isNotNull(projectid) && !projectid.equals("")) {
  109. queryWrapper.eq("projectid", projectid);
  110. }
  111. if (StringUtils.isNotNull(generatingcapacity) && !generatingcapacity.equals("")) {
  112. queryWrapper.eq("generatingcapacity", generatingcapacity);
  113. }
  114. if (StringUtils.isNotNull(outagehours) && outagehours != 0.0) {
  115. queryWrapper.eq("outagehours", outagehours);
  116. }
  117. if (StringUtils.isNotNull(year) && !year.equals("")) {
  118. queryWrapper.eq("year", year);
  119. }
  120. if (StringUtils.isNotNull(month) && !month.equals("")) {
  121. queryWrapper.eq("month", month);
  122. }
  123. if (StringUtils.isNotNull(windpower) && !windpower.equals("")) {
  124. queryWrapper.eq("windpower", windpower);
  125. }
  126. }
  127. //单个删除
  128. public boolean removeWapperById(String id) {
  129. QueryWrapper<Projectplan> queryWrapper = new QueryWrapper<Projectplan>();
  130. queryWrapper.eq("id", id);
  131. return ProjectplanService.remove(queryWrapper);
  132. }
  133. public boolean removeByIds(String ids) {
  134. String[] strings = ids.split(",");
  135. return ProjectplanService.removeByIds(Arrays.asList(strings));
  136. }
  137. //windpowerstation表
  138. public Page<Windpowerstation> Bypage(Windpowerstationvo vo) {
  139. Page<Windpowerstation> page = new Page<Windpowerstation>(vo.getCurrent(), vo.getPagesize());
  140. QueryWrapper<Windpowerstation> queryWrapper = new QueryWrapper<>();
  141. String id = vo.getId();
  142. String code = vo.getCode();
  143. String name = vo.getName();
  144. String address = vo.getAddress();
  145. String telephone = vo.getTelephone();
  146. Integer capacity = vo.getCapacity();
  147. String capacityunit = vo.getCapacityunit();
  148. Integer quantity = vo.getQuantity();
  149. String aname = vo.getAname();
  150. Integer longitude = vo.getLongitude();
  151. Integer latitude = vo.getLatitude();
  152. String photo = vo.getPhoto();
  153. String companyid = vo.getCompanyid();
  154. String systemmanufact = vo.getSystemmanufact();
  155. String headfarm = vo.getHeadfarm();
  156. String headfarmphone = vo.getHeadfarmphone();
  157. String model = vo.getModel();
  158. Integer ordernum = vo.getOrdernum();
  159. Integer altitudevo = vo.getAltitude();
  160. Integer height = vo.getHeight();
  161. if (StringUtils.isNotNull(id) && !id.equals("")) {
  162. queryWrapper.eq("id", id);
  163. }
  164. if (StringUtils.isNotNull(code) && !code.equals("")) {
  165. queryWrapper.eq("code", code);
  166. }
  167. if (StringUtils.isNotNull(name) && !name.equals("")) {
  168. queryWrapper.eq("name", name);
  169. }
  170. if (StringUtils.isNotNull(address) && !address.equals("")) {
  171. queryWrapper.eq("address", address);
  172. }
  173. if (StringUtils.isNotNull(telephone) && !telephone.equals("")) {
  174. queryWrapper.eq("telephone", telephone);
  175. }
  176. if (StringUtils.isNotNull(capacity) && !capacity.equals("")) {
  177. queryWrapper.eq("capacity", capacity);
  178. }
  179. if (StringUtils.isNotNull(capacityunit) && !capacityunit.equals("")) {
  180. queryWrapper.eq("capacityunit", capacityunit);
  181. }
  182. if (StringUtils.isNotNull(aname) && !aname.equals("")) {
  183. queryWrapper.eq("aname", aname);
  184. }
  185. if (StringUtils.isNotNull(longitude) && !longitude.equals("")) {
  186. queryWrapper.eq("longitude", longitude);
  187. }
  188. if (StringUtils.isNotNull(photo) && !photo.equals("")) {
  189. queryWrapper.eq("photo", photo);
  190. }
  191. if (StringUtils.isNotNull(quantity) && !quantity.equals("")) {
  192. queryWrapper.eq("quantity", quantity);
  193. }
  194. if (StringUtils.isNotNull(latitude) && !latitude.equals("")) {
  195. queryWrapper.eq("latitude", latitude);
  196. }
  197. if (StringUtils.isNotNull(companyid) && !companyid.equals("")) {
  198. queryWrapper.eq("companyid", companyid);
  199. }
  200. if (StringUtils.isNotNull(systemmanufact) && !systemmanufact.equals("")) {
  201. queryWrapper.eq("systemmanufact", systemmanufact);
  202. }
  203. if (StringUtils.isNotNull(headfarm) && !headfarm.equals("")) {
  204. queryWrapper.eq("headfarm", headfarm);
  205. }
  206. if (StringUtils.isNotNull(headfarmphone) && !headfarmphone.equals("")) {
  207. queryWrapper.eq("headfarmphone", headfarmphone);
  208. }
  209. if (StringUtils.isNotNull(model) && !model.equals("")) {
  210. queryWrapper.eq("model", model);
  211. }
  212. if (StringUtils.isNotNull(ordernum) && !ordernum.equals("")) {
  213. queryWrapper.eq("ordernum", ordernum);
  214. }
  215. if (StringUtils.isNotNull(altitudevo) && !altitudevo.equals("")) {
  216. queryWrapper.eq("altitudevo", altitudevo);
  217. }
  218. if (StringUtils.isNotNull(height) && !height.equals("")) {
  219. queryWrapper.eq("height", height);
  220. }
  221. Page<Windpowerstation> page1 = windpowerstationService.page(page, queryWrapper);
  222. return page1;
  223. }
  224. public Page<Project> ProjectBypage(Projectvo vo) {
  225. Page<Project> page = new Page<Project>(vo.getCurrent(), vo.getPageSize());
  226. QueryWrapper<Project> queryWrapper = new QueryWrapper<>();
  227. String id = vo.getId();
  228. String code = vo.getCode();
  229. String aname = vo.getAname();
  230. String name = vo.getName();
  231. String capacityunit = vo.getCapacityunit();
  232. Integer capacity = vo.getCapacity();
  233. String windpowerstationid = vo.getWindpowerstationid();
  234. Integer quantity = vo.getQuantity();
  235. String model = vo.getModel();
  236. Date commissiondate = vo.getCommissiondate();
  237. String masterphone = vo.getMasterphone();
  238. String shiftforeman = vo.getShiftforeman();
  239. String shiftforemanphone = vo.getShiftforemanphone();
  240. Integer ordernum = vo.getOrdernum();
  241. if (StringUtils.isNotNull(id) && !id.equals("")) {
  242. queryWrapper.eq("id", id);
  243. }
  244. if (StringUtils.isNotNull(code) && !code.equals("")) {
  245. queryWrapper.eq("code", code);
  246. }
  247. if (StringUtils.isNotNull(aname) && !aname.equals("")) {
  248. queryWrapper.eq("aname", aname);
  249. }
  250. if (StringUtils.isNotNull(name) && !name.equals("")) {
  251. queryWrapper.eq("name", name);
  252. }
  253. if (StringUtils.isNotNull(capacityunit) && !capacityunit.equals("")) {
  254. queryWrapper.eq("capacityunit", capacityunit);
  255. }
  256. if (StringUtils.isNotNull(capacity) && !capacity.equals("")) {
  257. queryWrapper.eq("capacity", capacity);
  258. }
  259. if (StringUtils.isNotNull(windpowerstationid) && !windpowerstationid.equals("")) {
  260. queryWrapper.eq("windpowerstationid", windpowerstationid);
  261. }
  262. if (StringUtils.isNotNull(quantity) && !quantity.equals("")) {
  263. queryWrapper.eq("quantity", quantity);
  264. }
  265. if (StringUtils.isNotNull(model) && !model.equals("")) {
  266. queryWrapper.eq("model", model);
  267. }
  268. if (StringUtils.isNotNull(commissiondate) && !commissiondate.equals("")) {
  269. queryWrapper.eq("commissiondate", commissiondate);
  270. }
  271. if (StringUtils.isNotNull(masterphone) && !masterphone.equals("")) {
  272. queryWrapper.eq("masterphone", masterphone);
  273. }
  274. if (StringUtils.isNotNull(shiftforeman) && !shiftforeman.equals("")) {
  275. queryWrapper.eq("shiftforeman", shiftforeman);
  276. }
  277. if (StringUtils.isNotNull(shiftforemanphone) && !shiftforemanphone.equals("")) {
  278. queryWrapper.eq("shiftforemanphone", shiftforemanphone);
  279. }
  280. if (StringUtils.isNotNull(ordernum) && !ordernum.equals("")) {
  281. queryWrapper.eq("ordernum", ordernum);
  282. }
  283. Page<Project> page1 = projectService.page(page, queryWrapper);
  284. return page1;
  285. }
  286. //line分页
  287. public Page<Line> lineBypage(Linevo vo) {
  288. Page<Line> page = new Page<Line>(vo.getCurrent(), vo.getPageSize());
  289. QueryWrapper<Line> queryWrapper = new QueryWrapper<>();
  290. String id = vo.getId();
  291. String code = vo.getCode();
  292. String aname = vo.getAname();
  293. String name = vo.getName();
  294. String projectid = vo.getProjectid();
  295. Integer ordernum = vo.getOrdernum();
  296. String capacityunit = vo.getCapacityunit();
  297. Integer capacity = vo.getCapacity();
  298. Integer quantity = vo.getQuantity();
  299. if (StringUtils.isNotNull(id) && !id.equals("")) {
  300. queryWrapper.like("id", id);
  301. }
  302. if (StringUtils.isNotNull(code) && !code.equals("")) {
  303. queryWrapper.like("code", code);
  304. }
  305. if (StringUtils.isNotNull(aname) && !aname.equals("")) {
  306. queryWrapper.like("aname", aname);
  307. }
  308. if (StringUtils.isNotNull(name) && !name.equals("")) {
  309. queryWrapper.like("name", name);
  310. }
  311. if (StringUtils.isNotNull(capacityunit) && !capacityunit.equals("")) {
  312. queryWrapper.like("capacityunit", capacityunit);
  313. }
  314. if (StringUtils.isNotNull(capacity) && !capacity.equals("")) {
  315. queryWrapper.like("capacity", capacity);
  316. }
  317. if (StringUtils.isNotNull(projectid) && !projectid.equals("")) {
  318. queryWrapper.like("projectid", projectid);
  319. }
  320. if (StringUtils.isNotNull(ordernum) && !ordernum.equals("")) {
  321. queryWrapper.like("ordernum", ordernum);
  322. }
  323. if (StringUtils.isNotNull(quantity) && !quantity.equals("")) {
  324. queryWrapper.like("quantity", quantity);
  325. }
  326. Page<Line> page1 = lineService.page(page, queryWrapper);
  327. return page1;
  328. }
  329. public boolean saveOrUpdate(Line Line) {
  330. return lineService.saveOrUpdate(Line);
  331. }
  332. //Companys
  333. public Page<Companys> CompanysBypage(Companysvo vo) {
  334. Page<Companys> page = new Page<Companys>(vo.getCurrent(), vo.getPageSize());
  335. QueryWrapper<Companys> queryWrapper = new QueryWrapper<>();
  336. String id = vo.getId();
  337. // String rid = vo.getRid();
  338. String name = vo.getName();
  339. if (StringUtils.isNotNull(id) && !id.equals("")) {
  340. queryWrapper.like("id", id);
  341. }
  342. // if (StringUtils.isNotNull(rid) && !rid.equals("")) {
  343. // queryWrapper.like("code", rid);
  344. // }
  345. if (StringUtils.isNotNull(name) && !name.equals("")) {
  346. queryWrapper.like("name", name);
  347. }
  348. Page<Companys> page1 = companysService.page(page, queryWrapper);
  349. return page1;
  350. }
  351. //计划电量树
  352. public List<Companys> wtls() {
  353. List<Companys> cpls = CacheContext.cpls;
  354. if(cpls.get(0).getChildren().size()>0) return cpls;
  355. List<Windpowerstation> wpls = CacheContext.wpls;
  356. List<Project> prols= CacheContext.prols;
  357. cpls.forEach(cpl -> {
  358. List<Windpowerstation> collect = wpls.stream().filter(w -> w.getCompanyid().equals(cpl.getId())).collect(Collectors.toList());
  359. cpl.getChildren().addAll(collect);
  360. });
  361. wpls.forEach(wpl -> {
  362. List<Project> projects = prols.stream().filter(l -> l.getWindpowerstationid().equals(wpl.getId())).collect(Collectors.toList());
  363. wpl.getChildren().addAll(projects);
  364. });
  365. // prols.forEach(wp->{
  366. // wpls.stream().filter(pr ->pr.getId().equals(wp.getWindpowerstationid())).collect(Collectors.toList());
  367. //// Companys.get(0).getData2().add(wp);
  368. // });
  369. // //返回结果为期次在上面,场站在下面
  370. //// prols.stream().forEach(cp->{
  371. //// Windpowerstationvo vo = new Windpowerstationvo();
  372. //// vo.setId(cp.getId());
  373. //// vo.setCode(cp.getName());
  374. ////
  375. //// List<Windpowerstation> wt = wpls.stream().filter(wt1 ->wt1.getId().equals(cp.getWindpowerstationid())).collect(Collectors.toList());
  376. //// vo.setData(wt);
  377. //// wtlist.add(vo);
  378. //// });
  379. // //返回结果为场站在上面,期次在下面,但是公司表setdata需要为vo
  380. // wpls.forEach(wp->{
  381. // //Projectvo vo = new Projectvo();
  382. // /*Windpowerstationvo vo = new Windpowerstationvo();
  383. // vo.setId(wp.getId());
  384. // List<Projectvo> Project = prols.stream().filter(wt -> wt.getWindpowerstationid().equals(wp.getId())).collect(Collectors.toList());
  385. // vo.setData(Project);
  386. //
  387. // vo.setId(wp.getId());
  388. // vo.setCode(wp.getName());
  389. // List<Project> Project = prols.stream().filter(wt -> wt.getWindpowerstationid().equals(wp.getId())).collect(Collectors.toList());
  390. // vo.setData(Project);
  391. // volist.add(vo);*/
  392. // cpls.stream().filter(ct ->ct.getId().equals(wp.getCompanyid())).collect(Collectors.toList());
  393. // Companysvo vo = new Companysvo();
  394. // vo.setId(Companys.get(0).getId());
  395. // vo.setName(Companys.get(0).getName());
  396. // vo.setRid(Companys.get(0).getRid());
  397. // vo.getData1().add(wp);
  398. // colist.add(vo);
  399. // });
  400. // cpls.stream().forEach(cpl->{
  401. // Projectvo vo = new Projectvo();
  402. // vo.setWindpowerstationid(cpl.getId());
  403. //
  404. // List<Projectvo> cc = volist.stream().filter((wt2 ->wt2.getWindpowerstationid().equals(cpl.getId()))).collect(Collectors.toList());
  405. // vo.setData(cc);
  406. // volist.add(vo);
  407. // });
  408. //
  409. // volist.stream().forEach(vol->{
  410. // Companysvo vo = new Companysvo();
  411. // vo.setId(vol.get());
  412. // List<Companys> Companys = cpls.stream().filter(ct ->ct.getId().equals(vol.getWindpowerstationid())).collect(Collectors.toList());
  413. // vo.setData(Companys);
  414. // colist.add(vo);
  415. // });
  416. //
  417. // cpls.stream().forEach(wp->{
  418. // Companysvo vo = new Companysvo();
  419. //
  420. //// vo.setId(wp.getCompanyid());
  421. // List<Windpowerstationvo> Companys = wtlist.stream().filter(wt -> wt.getCompanyid().equals(wp.getId())).collect(Collectors.toList());
  422. // vo.setData(Companys);
  423. // colist.add(vo);
  424. // });
  425. return cpls;
  426. }
  427. public List<Windpowerstation> stationtree() {
  428. List<Windpowerstation> wpls = CacheContext.wpls;
  429. List<Project> prols= CacheContext.prols;
  430. List<Line> lines = CacheContext.lines;
  431. wpls.forEach(wpl -> {
  432. List<Project> projects = prols.stream().filter(l -> l.getWindpowerstationid().equals(wpl.getId())).collect(Collectors.toList());
  433. wpl.getChildren().addAll(projects);
  434. });
  435. prols.forEach(prol -> {
  436. List<Line> lineList = lines.stream().filter(l->l.getProjectid().equals(prol.getId())).collect(Collectors.toList());
  437. prol.getChildren().addAll(lineList);
  438. });
  439. return wpls;
  440. }
  441. }