123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497 |
- package com.gyee.backconfig.service;
- import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
- import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
- import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
- import com.gyee.backconfig.config.CacheContext;
- import com.gyee.backconfig.model.auto.*;
- import com.gyee.backconfig.service.auto.*;
- import com.gyee.backconfig.vo.*;
- import com.gyee.common.model.StringUtils;
- import org.springframework.stereotype.Service;
- import javax.annotation.Resource;
- import java.util.*;
- import java.util.stream.Collectors;
- /**
- * @author 50560
- * @create 2022-09-14 13:41
- * backConfig:大部分逻辑在此处
- */
- @Service
- public class BackConfigService {
- @Resource
- private IProjectplanService ProjectplanService;
- @Resource
- private ICompanysService companysService;
- @Resource
- private IWindpowerstationService windpowerstationService;
- @Resource
- private IProjectService projectService;
- @Resource
- private ILineService lineService;
- /**
- * @param
- * @return
- */
- //返回所有
- public List<Projectplan> backConfigList() {
- List<Projectplan> ProjectplanList = ProjectplanService.list();
- return ProjectplanList;
- }
- //根据id返回
- public Projectplan projectplanById(String id) {
- QueryWrapper<Projectplan> queryWrapper = new QueryWrapper<>();
- Projectplan xrpProjectplan = ProjectplanService.getOne(queryWrapper);
- queryWrapper.eq("id", id);
- return xrpProjectplan;
- }
- public void updateXpp(Projectplan xpp) {
- ProjectplanService.updateById(xpp);
- }
- public Boolean saveSingle(Projectplan Projectplan) {
- return ProjectplanService.saveOrUpdate(Projectplan);
- }
- //Projectplan分页查询
- public Page<Projectplan> listBypage(Projectplanvo vo) {
- Page<Projectplan> page = new Page<Projectplan>(vo.getCurrent(), vo.getPageSize());
- QueryWrapper<Projectplan> queryWrapper = new QueryWrapper<>();
- String id = vo.getId();
- String projectid = vo.getProjectid();
- String generatingcapacity = vo.getGeneratingcapacity();
- Double outagehours = vo.getOutagehours();
- String year = vo.getYear();
- String month = vo.getMonth();
- String windpower = vo.getWindpower();
- if (StringUtils.isNotNull(id) && !id.equals("")) {
- queryWrapper.eq("id", id);
- }
- if (StringUtils.isNotNull(projectid) && !projectid.equals("")) {
- queryWrapper.eq("projectid", projectid);
- }
- if (StringUtils.isNotNull(generatingcapacity) && !generatingcapacity.equals("")) {
- queryWrapper.eq("generatingcapacity", generatingcapacity);
- }
- if (StringUtils.isNotNull(outagehours) && outagehours != 0.0) {
- queryWrapper.eq("outagehours", outagehours);
- }
- if (StringUtils.isNotNull(year) && !year.equals("")) {
- queryWrapper.eq("year", year);
- }
- if (StringUtils.isNotNull(month) && !month.equals("")) {
- queryWrapper.eq("month", month);
- }
- if (StringUtils.isNotNull(windpower) && !windpower.equals("")) {
- queryWrapper.eq("windpower", windpower);
- }
- Page<Projectplan> page1 = ProjectplanService.page(page, queryWrapper);
- return page1;
- }
- //期次新增
- public boolean saveOrUpdate(Projectplan Projectplan) {
- return ProjectplanService.saveOrUpdate(Projectplan);
- }
- public boolean removeWapper(Projectplan Projectplan) {
- QueryWrapper<Projectplan> queryWrapper = new QueryWrapper<Projectplan>();
- conditionJudge(Projectplan, queryWrapper);
- return ProjectplanService.remove(queryWrapper);
- }
- private void conditionJudge(Projectplan Projectplan, QueryWrapper<Projectplan> queryWrapper) {
- String id = Projectplan.getId();
- String projectid = Projectplan.getProjectid();
- String generatingcapacity = Projectplan.getGeneratingcapacity();
- Double outagehours = Projectplan.getOutagehours();
- String year = Projectplan.getYear();
- String month = Projectplan.getMonth();
- String windpower = Projectplan.getWindpower();
- if (StringUtils.isNotNull(id) && !id.equals("")) {
- queryWrapper.eq("id", id);
- }
- if (StringUtils.isNotNull(projectid) && !projectid.equals("")) {
- queryWrapper.eq("projectid", projectid);
- }
- if (StringUtils.isNotNull(generatingcapacity) && !generatingcapacity.equals("")) {
- queryWrapper.eq("generatingcapacity", generatingcapacity);
- }
- if (StringUtils.isNotNull(outagehours) && outagehours != 0.0) {
- queryWrapper.eq("outagehours", outagehours);
- }
- if (StringUtils.isNotNull(year) && !year.equals("")) {
- queryWrapper.eq("year", year);
- }
- if (StringUtils.isNotNull(month) && !month.equals("")) {
- queryWrapper.eq("month", month);
- }
- if (StringUtils.isNotNull(windpower) && !windpower.equals("")) {
- queryWrapper.eq("windpower", windpower);
- }
- }
- //单个删除
- public boolean removeWapperById(String id) {
- QueryWrapper<Projectplan> queryWrapper = new QueryWrapper<Projectplan>();
- queryWrapper.eq("id", id);
- return ProjectplanService.remove(queryWrapper);
- }
- public boolean removeByIds(String ids) {
- String[] strings = ids.split(",");
- return ProjectplanService.removeByIds(Arrays.asList(strings));
- }
- //windpowerstation表
- public Page<Windpowerstation> Bypage(Windpowerstationvo vo) {
- Page<Windpowerstation> page = new Page<Windpowerstation>(vo.getCurrent(), vo.getPagesize());
- QueryWrapper<Windpowerstation> queryWrapper = new QueryWrapper<>();
- String id = vo.getId();
- String code = vo.getCode();
- String name = vo.getName();
- String address = vo.getAddress();
- String telephone = vo.getTelephone();
- Integer capacity = vo.getCapacity();
- String capacityunit = vo.getCapacityunit();
- Integer quantity = vo.getQuantity();
- String aname = vo.getAname();
- Integer longitude = vo.getLongitude();
- Integer latitude = vo.getLatitude();
- String photo = vo.getPhoto();
- String companyid = vo.getCompanyid();
- String systemmanufact = vo.getSystemmanufact();
- String headfarm = vo.getHeadfarm();
- String headfarmphone = vo.getHeadfarmphone();
- String model = vo.getModel();
- Integer ordernum = vo.getOrdernum();
- Integer altitudevo = vo.getAltitude();
- Integer height = vo.getHeight();
- if (StringUtils.isNotNull(id) && !id.equals("")) {
- queryWrapper.eq("id", id);
- }
- if (StringUtils.isNotNull(code) && !code.equals("")) {
- queryWrapper.eq("code", code);
- }
- if (StringUtils.isNotNull(name) && !name.equals("")) {
- queryWrapper.eq("name", name);
- }
- if (StringUtils.isNotNull(address) && !address.equals("")) {
- queryWrapper.eq("address", address);
- }
- if (StringUtils.isNotNull(telephone) && !telephone.equals("")) {
- queryWrapper.eq("telephone", telephone);
- }
- if (StringUtils.isNotNull(capacity) && !capacity.equals("")) {
- queryWrapper.eq("capacity", capacity);
- }
- if (StringUtils.isNotNull(capacityunit) && !capacityunit.equals("")) {
- queryWrapper.eq("capacityunit", capacityunit);
- }
- if (StringUtils.isNotNull(aname) && !aname.equals("")) {
- queryWrapper.eq("aname", aname);
- }
- if (StringUtils.isNotNull(longitude) && !longitude.equals("")) {
- queryWrapper.eq("longitude", longitude);
- }
- if (StringUtils.isNotNull(photo) && !photo.equals("")) {
- queryWrapper.eq("photo", photo);
- }
- if (StringUtils.isNotNull(quantity) && !quantity.equals("")) {
- queryWrapper.eq("quantity", quantity);
- }
- if (StringUtils.isNotNull(latitude) && !latitude.equals("")) {
- queryWrapper.eq("latitude", latitude);
- }
- if (StringUtils.isNotNull(companyid) && !companyid.equals("")) {
- queryWrapper.eq("companyid", companyid);
- }
- if (StringUtils.isNotNull(systemmanufact) && !systemmanufact.equals("")) {
- queryWrapper.eq("systemmanufact", systemmanufact);
- }
- if (StringUtils.isNotNull(headfarm) && !headfarm.equals("")) {
- queryWrapper.eq("headfarm", headfarm);
- }
- if (StringUtils.isNotNull(headfarmphone) && !headfarmphone.equals("")) {
- queryWrapper.eq("headfarmphone", headfarmphone);
- }
- if (StringUtils.isNotNull(model) && !model.equals("")) {
- queryWrapper.eq("model", model);
- }
- if (StringUtils.isNotNull(ordernum) && !ordernum.equals("")) {
- queryWrapper.eq("ordernum", ordernum);
- }
- if (StringUtils.isNotNull(altitudevo) && !altitudevo.equals("")) {
- queryWrapper.eq("altitudevo", altitudevo);
- }
- if (StringUtils.isNotNull(height) && !height.equals("")) {
- queryWrapper.eq("height", height);
- }
- Page<Windpowerstation> page1 = windpowerstationService.page(page, queryWrapper);
- return page1;
- }
- public Page<Project> ProjectBypage(Projectvo vo) {
- Page<Project> page = new Page<Project>(vo.getCurrent(), vo.getPageSize());
- QueryWrapper<Project> queryWrapper = new QueryWrapper<>();
- String id = vo.getId();
- String code = vo.getCode();
- String aname = vo.getAname();
- String name = vo.getName();
- String capacityunit = vo.getCapacityunit();
- Integer capacity = vo.getCapacity();
- String windpowerstationid = vo.getWindpowerstationid();
- Integer quantity = vo.getQuantity();
- String model = vo.getModel();
- Date commissiondate = vo.getCommissiondate();
- String masterphone = vo.getMasterphone();
- String shiftforeman = vo.getShiftforeman();
- String shiftforemanphone = vo.getShiftforemanphone();
- Integer ordernum = vo.getOrdernum();
- if (StringUtils.isNotNull(id) && !id.equals("")) {
- queryWrapper.eq("id", id);
- }
- if (StringUtils.isNotNull(code) && !code.equals("")) {
- queryWrapper.eq("code", code);
- }
- if (StringUtils.isNotNull(aname) && !aname.equals("")) {
- queryWrapper.eq("aname", aname);
- }
- if (StringUtils.isNotNull(name) && !name.equals("")) {
- queryWrapper.eq("name", name);
- }
- if (StringUtils.isNotNull(capacityunit) && !capacityunit.equals("")) {
- queryWrapper.eq("capacityunit", capacityunit);
- }
- if (StringUtils.isNotNull(capacity) && !capacity.equals("")) {
- queryWrapper.eq("capacity", capacity);
- }
- if (StringUtils.isNotNull(windpowerstationid) && !windpowerstationid.equals("")) {
- queryWrapper.eq("windpowerstationid", windpowerstationid);
- }
- if (StringUtils.isNotNull(quantity) && !quantity.equals("")) {
- queryWrapper.eq("quantity", quantity);
- }
- if (StringUtils.isNotNull(model) && !model.equals("")) {
- queryWrapper.eq("model", model);
- }
- if (StringUtils.isNotNull(commissiondate) && !commissiondate.equals("")) {
- queryWrapper.eq("commissiondate", commissiondate);
- }
- if (StringUtils.isNotNull(masterphone) && !masterphone.equals("")) {
- queryWrapper.eq("masterphone", masterphone);
- }
- if (StringUtils.isNotNull(shiftforeman) && !shiftforeman.equals("")) {
- queryWrapper.eq("shiftforeman", shiftforeman);
- }
- if (StringUtils.isNotNull(shiftforemanphone) && !shiftforemanphone.equals("")) {
- queryWrapper.eq("shiftforemanphone", shiftforemanphone);
- }
- if (StringUtils.isNotNull(ordernum) && !ordernum.equals("")) {
- queryWrapper.eq("ordernum", ordernum);
- }
- Page<Project> page1 = projectService.page(page, queryWrapper);
- return page1;
- }
- //line分页
- public Page<Line> lineBypage(Linevo vo) {
- Page<Line> page = new Page<Line>(vo.getCurrent(), vo.getPageSize());
- QueryWrapper<Line> queryWrapper = new QueryWrapper<>();
- String id = vo.getId();
- String code = vo.getCode();
- String aname = vo.getAname();
- String name = vo.getName();
- String projectid = vo.getProjectid();
- Integer ordernum = vo.getOrdernum();
- String capacityunit = vo.getCapacityunit();
- Integer capacity = vo.getCapacity();
- Integer quantity = vo.getQuantity();
- if (StringUtils.isNotNull(id) && !id.equals("")) {
- queryWrapper.like("id", id);
- }
- if (StringUtils.isNotNull(code) && !code.equals("")) {
- queryWrapper.like("code", code);
- }
- if (StringUtils.isNotNull(aname) && !aname.equals("")) {
- queryWrapper.like("aname", aname);
- }
- if (StringUtils.isNotNull(name) && !name.equals("")) {
- queryWrapper.like("name", name);
- }
- if (StringUtils.isNotNull(capacityunit) && !capacityunit.equals("")) {
- queryWrapper.like("capacityunit", capacityunit);
- }
- if (StringUtils.isNotNull(capacity) && !capacity.equals("")) {
- queryWrapper.like("capacity", capacity);
- }
- if (StringUtils.isNotNull(projectid) && !projectid.equals("")) {
- queryWrapper.like("projectid", projectid);
- }
- if (StringUtils.isNotNull(ordernum) && !ordernum.equals("")) {
- queryWrapper.like("ordernum", ordernum);
- }
- if (StringUtils.isNotNull(quantity) && !quantity.equals("")) {
- queryWrapper.like("quantity", quantity);
- }
- Page<Line> page1 = lineService.page(page, queryWrapper);
- return page1;
- }
- public boolean saveOrUpdate(Line Line) {
- return lineService.saveOrUpdate(Line);
- }
- //Companys
- public Page<Companys> CompanysBypage(Companysvo vo) {
- Page<Companys> page = new Page<Companys>(vo.getCurrent(), vo.getPageSize());
- QueryWrapper<Companys> queryWrapper = new QueryWrapper<>();
- String id = vo.getId();
- // String rid = vo.getRid();
- String name = vo.getName();
- if (StringUtils.isNotNull(id) && !id.equals("")) {
- queryWrapper.like("id", id);
- }
- // if (StringUtils.isNotNull(rid) && !rid.equals("")) {
- // queryWrapper.like("code", rid);
- // }
- if (StringUtils.isNotNull(name) && !name.equals("")) {
- queryWrapper.like("name", name);
- }
- Page<Companys> page1 = companysService.page(page, queryWrapper);
- return page1;
- }
- //计划电量树
- public List<Companys> wtls() {
- List<Companys> cpls = CacheContext.cpls;
- if(cpls.get(0).getChildren().size()>0) return cpls;
- List<Windpowerstation> wpls = CacheContext.wpls;
- List<Project> prols= CacheContext.prols;
- cpls.forEach(cpl -> {
- List<Windpowerstation> collect = wpls.stream().filter(w -> w.getCompanyid().equals(cpl.getId())).collect(Collectors.toList());
- cpl.getChildren().addAll(collect);
- });
- wpls.forEach(wpl -> {
- List<Project> projects = prols.stream().filter(l -> l.getWindpowerstationid().equals(wpl.getId())).collect(Collectors.toList());
- wpl.getChildren().addAll(projects);
- });
- // prols.forEach(wp->{
- // wpls.stream().filter(pr ->pr.getId().equals(wp.getWindpowerstationid())).collect(Collectors.toList());
- //// Companys.get(0).getData2().add(wp);
- // });
- // //返回结果为期次在上面,场站在下面
- //// prols.stream().forEach(cp->{
- //// Windpowerstationvo vo = new Windpowerstationvo();
- //// vo.setId(cp.getId());
- //// vo.setCode(cp.getName());
- ////
- //// List<Windpowerstation> wt = wpls.stream().filter(wt1 ->wt1.getId().equals(cp.getWindpowerstationid())).collect(Collectors.toList());
- //// vo.setData(wt);
- //// wtlist.add(vo);
- //// });
- // //返回结果为场站在上面,期次在下面,但是公司表setdata需要为vo
- // wpls.forEach(wp->{
- // //Projectvo vo = new Projectvo();
- // /*Windpowerstationvo vo = new Windpowerstationvo();
- // vo.setId(wp.getId());
- // List<Projectvo> Project = prols.stream().filter(wt -> wt.getWindpowerstationid().equals(wp.getId())).collect(Collectors.toList());
- // vo.setData(Project);
- //
- // vo.setId(wp.getId());
- // vo.setCode(wp.getName());
- // List<Project> Project = prols.stream().filter(wt -> wt.getWindpowerstationid().equals(wp.getId())).collect(Collectors.toList());
- // vo.setData(Project);
- // volist.add(vo);*/
- // cpls.stream().filter(ct ->ct.getId().equals(wp.getCompanyid())).collect(Collectors.toList());
- // Companysvo vo = new Companysvo();
- // vo.setId(Companys.get(0).getId());
- // vo.setName(Companys.get(0).getName());
- // vo.setRid(Companys.get(0).getRid());
- // vo.getData1().add(wp);
- // colist.add(vo);
- // });
- // cpls.stream().forEach(cpl->{
- // Projectvo vo = new Projectvo();
- // vo.setWindpowerstationid(cpl.getId());
- //
- // List<Projectvo> cc = volist.stream().filter((wt2 ->wt2.getWindpowerstationid().equals(cpl.getId()))).collect(Collectors.toList());
- // vo.setData(cc);
- // volist.add(vo);
- // });
- //
- // volist.stream().forEach(vol->{
- // Companysvo vo = new Companysvo();
- // vo.setId(vol.get());
- // List<Companys> Companys = cpls.stream().filter(ct ->ct.getId().equals(vol.getWindpowerstationid())).collect(Collectors.toList());
- // vo.setData(Companys);
- // colist.add(vo);
- // });
- //
- // cpls.stream().forEach(wp->{
- // Companysvo vo = new Companysvo();
- //
- //// vo.setId(wp.getCompanyid());
- // List<Windpowerstationvo> Companys = wtlist.stream().filter(wt -> wt.getCompanyid().equals(wp.getId())).collect(Collectors.toList());
- // vo.setData(Companys);
- // colist.add(vo);
- // });
- return cpls;
- }
- public List<Windpowerstation> stationtree() {
- List<Windpowerstation> wpls = CacheContext.wpls;
- List<Project> prols= CacheContext.prols;
- List<Line> lines = CacheContext.lines;
- wpls.forEach(wpl -> {
- List<Project> projects = prols.stream().filter(l -> l.getWindpowerstationid().equals(wpl.getId())).collect(Collectors.toList());
- wpl.getChildren().addAll(projects);
- });
- prols.forEach(prol -> {
- List<Line> lineList = lines.stream().filter(l->l.getProjectid().equals(prol.getId())).collect(Collectors.toList());
- prol.getChildren().addAll(lineList);
- });
- return wpls;
- }
- }
|