123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589 |
- package com.gyee.benchmarkingimpala.service;
- import com.alibaba.fastjson.JSON;
- import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
- import com.gyee.benchmarkingimpala.common.PointData;
- import com.gyee.benchmarkingimpala.common.StringUtils;
- import com.gyee.benchmarkingimpala.contant.Contant;
- import com.gyee.benchmarkingimpala.init.CacheContext;
- import com.gyee.benchmarkingimpala.model.auto.*;
- import com.gyee.benchmarkingimpala.model.vo.*;
- import com.gyee.benchmarkingimpala.service.auto.*;
- import com.gyee.benchmarkingimpala.util.*;
- import com.gyee.benchmarkingimpala.util.taos.EdosUtil;
- import org.springframework.stereotype.Service;
- import javax.annotation.Resource;
- import java.math.BigDecimal;
- import java.text.ParseException;
- import java.text.SimpleDateFormat;
- import java.util.*;
- import java.util.concurrent.atomic.AtomicReference;
- import java.util.stream.Collectors;
- /**
- * @ClassName : BenchmarkingService
- * @Author : xieshengjie
- * @Date: 2021/6/15 17:46
- * @Description : 对标管理service
- */
- @Service
- public class BenchmarkingService {
- private final String TYPE_DATE = "date";
- private final String TYPE_WIND = "wind";
- private final String TYPE_PROJECT = "project";
- private final String TYPE_LINE = "line";
- private final String TYPE_WINDTURBINE = "windturbine";
- private EdosUtil edosUtil = new EdosUtil();
- @Resource
- private IEquipmentdayinfoService equipmentdayinfoService;
- @Resource
- private IEquipmentdaydetailedService equipmentdaydetailedService;
- @Resource
- private IDutyscheduleService dutyscheduleService;
- @Resource
- private IOperationrecordService operationrecordService;
- @Resource
- private IBenchmarkingbetweenService benchmarkingbetweenService;
- @Resource
- private IWindturbineanalysisdayService windturbineanalysisdayService;
- @Resource
- private IWindturbinethewindinfoService windturbinethewindinfoService;
- @Resource
- private IWindturbinecurvefittingService windturbinecurvefittingService;
- @Resource
- private IWindpowerinfodayService windpowerinfodayService;
- @Resource
- private IWindpowerinfoday3Service windpowerinfoday3Service;
- @Resource
- private IBenchmarkService benchmarkService;
- @Resource
- private IWpmttrandmtbfdayService wpmttrandmtbfdayService;
- @Resource
- private IWindpowerspecificinfodayService windpowerspecificinfodayService;
- @Resource
- private IWindpowerstationthewindinfoService windpowerstationthewindinfoService;
- @Resource
- private IWindpowerstationService windpowerstationService;
- /**
- * 保存日信息表
- * @param beginDate
- * @param endDate
- */
- public void saveEquipmentdayinfo(String beginDate,String endDate){
- Map<String, Map<String, Windturbinetestingpointai2>> wtpAimap = CacheContext.wtpAimap;
- List<Windturbine> wtls = CacheContext.wtls.stream().filter(i->i.getWindpowerstationid().equals("MHS_FDC") || i.getWindpowerstationid().equals("NSS_FDC") || i.getWindpowerstationid().equals("QS_FDC")
- || i.getWindpowerstationid().equals("SBQ_FDC") || i.getWindpowerstationid().equals("XS_FDC")).collect(Collectors.toList());
- String[] uniformcodes = Contant.WXSS.split(",");
- List<String> days = getDays(beginDate, endDate);
- for (String d : days) {
- Map<String,Object> delMap = new HashMap<>();
- delMap.put("recorddate",DateUtils.parseDate(d));
- equipmentdayinfoService.removeByMap(delMap);
- List<Equipmentdayinfo> resultList = new ArrayList<>();
- Date date = DateUtils.parseDate(d);
- Date addDays = DateUtils.addDays(date, 1);
- Date begin = DateUtils.getStartOfDay(addDays);
- Date end = DateUtils.addSeconds(begin, 1);
- wtls.stream().filter(i->i.getWindpowerstationid().endsWith("FDC")).forEach(wt->{
- Map<String,Double> wtDataMap = new HashMap<>();
- Map<String, Windturbinetestingpointai2> nmap = wtpAimap.get(wt.getId());
- for (String uniformcode : uniformcodes) {
- try {
- Windturbinetestingpointai2 windturbinetestingpointai2 = nmap.get(uniformcode);
- if (windturbinetestingpointai2!=null){
- List<PointData> pointDatas = edosUtil.getHistoryDatasSnap(windturbinetestingpointai2, begin.getTime()/1000, end.getTime()/1000,1l,1l);
- Optional<PointData> first = pointDatas.stream().findFirst();
- Double value = first.isPresent()?first.get().getPointValueInDouble():0;
- wtDataMap.put(wt.getId()+"_"+uniformcode,value);
- }else {
- System.out.println(wt.getId()+"----"+uniformcode);
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- Equipmentdayinfo equipmentdayinfo = new Equipmentdayinfo();
- equipmentdayinfo.setId(StringUtils.getUUID());
- equipmentdayinfo.setWindturbineid(wt.getId());
- equipmentdayinfo.setLineid(wt.getLineid());
- equipmentdayinfo.setProjectid(wt.getProjectid());
- equipmentdayinfo.setWindpowerstationid(wt.getWindpowerstationid());
- equipmentdayinfo.setRecorddate(DateUtils.parseDate(d));
- equipmentdayinfo.setGenecapacity(wtDataMap.get(wt.getId()+"_RFDL"));
- equipmentdayinfo.setSpeed(wtDataMap.get(wt.getId()+"_AI022"));
- //维护:RJXSSDL-ZS,RLZSSDL-ZS
- equipmentdayinfo.setDaynhwhssdl(wtDataMap.get(wt.getId()+"_RJXSSDL-ZS") + wtDataMap.get(wt.getId()+"_RLZSSDL-ZS"));
- //故障:RGZSSDL-ZS,NSZSSDL-ZS
- equipmentdayinfo.setDaynhgzssdl(wtDataMap.get(wt.getId()+"_RGZSSDL-ZS") + wtDataMap.get(wt.getId()+"_NSZSSDL-ZS"));
- //限电:RQFSSDL-ZS,RXDSSDL-ZS
- equipmentdayinfo.setDaynhxdssdl(wtDataMap.get(wt.getId()+"_RQFSSDL-ZS") + wtDataMap.get(wt.getId()+"_RXDSSDL-ZS"));
- //性能:RDJSSDL-ZS,RSTSSDL-ZS,RXNSSDL-ZS,RQXSSDL-ZS(集团项目需把发电欠发去掉)
- equipmentdayinfo.setDaynhqfdl(wtDataMap.get(wt.getId()+"_RDJSSDL-ZS") + wtDataMap.get(wt.getId()+"_RSTSSDL-ZS") + wtDataMap.get(wt.getId()+"_RXNSSDL-ZS") + wtDataMap.get(wt.getId()+"_RQXSSDL-ZS"));
- //受累:RWZSSDL-ZS,RTZSSDL-ZS
- equipmentdayinfo.setDaynhcfdl(wtDataMap.get(wt.getId()+"_RWZSSDL-ZS") + wtDataMap.get(wt.getId()+"_RTZSSDL-ZS"));
- equipmentdayinfo.setTherogenecapacity(equipmentdayinfo.getGenecapacity()+equipmentdayinfo.getDaynhwhssdl()+equipmentdayinfo.getDaynhgzssdl()+equipmentdayinfo.getDaynhxdssdl()+equipmentdayinfo.getDaynhqfdl()+equipmentdayinfo.getDaynhcfdl());
- resultList.add(equipmentdayinfo);
- });
- equipmentdayinfoService.saveBatch(resultList);
- }
- }
- /**
- * 保存日信息明细
- * @param beginDate
- * @param endDate
- */
- public void saveEquipmentdaydetailed(String beginDate,String endDate){
- Map<String, Map<String, Windturbinetestingpointai2>> wtpAimap = CacheContext.wtpAimap;
- List<Windturbine> wtls = CacheContext.wtls;
- String[] uniformcodes = Contant.WXSS.split(",");
- List<String> days = getDays(beginDate, endDate);
- for (String d : days) {
- Map<String,Object> delMap = new HashMap<>();
- delMap.put("recorddate",DateUtils.parseDate(d));
- equipmentdaydetailedService.removeByMap(delMap);
- List<Equipmentdaydetailed> resultList = new ArrayList<>();
- Date date = DateUtils.parseDate(d);
- Date addDays = DateUtils.addDays(date, 1);
- Date begin = DateUtils.getStartOfDay(addDays);
- Date end = DateUtils.addSeconds(begin, 1);
- wtls.stream().filter(i->i.getWindpowerstationid().endsWith("FDC")).forEach(wt->{
- Map<String,Double> wtDataMap = new HashMap<>();
- Map<String, Windturbinetestingpointai2> nmap = wtpAimap.get(wt.getId());
- for (String uniformcode : uniformcodes) {
- try {
- Windturbinetestingpointai2 windturbinetestingpointai2 = nmap.get(uniformcode);
- List<PointData> pointDatas = edosUtil.getHistoryDatasSnap(windturbinetestingpointai2, begin.getTime()/1000, end.getTime()/1000,1l,1l);
- Optional<PointData> first = pointDatas.stream().findFirst();
- Double value = first.isPresent()?first.get().getPointValueInDouble():0;
- wtDataMap.put(wt.getId()+"_"+uniformcode,value);
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- Equipmentdaydetailed equipmentdayinfo = new Equipmentdaydetailed();
- equipmentdayinfo.setId(StringUtils.getUUID());
- equipmentdayinfo.setWindturbineid(wt.getId());
- equipmentdayinfo.setLineid(wt.getLineid());
- equipmentdayinfo.setProjectid(wt.getProjectid());
- equipmentdayinfo.setWindpowerstationid(wt.getWindpowerstationid());
- equipmentdayinfo.setRecorddate(DateUtils.parseDate(d));
- equipmentdayinfo.setGenecapacity(wtDataMap.get(wt.getId()+"_RFDL"));
- equipmentdayinfo.setSpeed(wtDataMap.get(wt.getId()+"_AI022"));
- //维护:RJXSSDL-ZS,RLZSSDL-ZS
- equipmentdayinfo.setDaynhwhssdl1(wtDataMap.get(wt.getId()+"_RJXSSDL-ZS"));
- equipmentdayinfo.setDaynhwhssdl2(wtDataMap.get(wt.getId()+"_RLZSSDL-ZS"));
- //故障:RGZSSDL-ZS,NSZSSDL-ZS
- equipmentdayinfo.setDaynhgzssdl1(wtDataMap.get(wt.getId()+"_RGZSSDL-ZS"));
- equipmentdayinfo.setDaynhgzssdl2(wtDataMap.get(wt.getId()+"_NSZSSDL-ZS"));
- //限电:RQFSSDL-ZS,RXDSSDL-ZS
- equipmentdayinfo.setDaynhxdssdl1(wtDataMap.get(wt.getId()+"_RQFSSDL-ZS"));
- equipmentdayinfo.setDaynhxdssdl2(wtDataMap.get(wt.getId()+"_RXDSSDL-ZS"));
- //性能:RDJSSDL-ZS,RSTSSDL-ZS,RXNSSDL-ZS,RQXSSDL-ZS
- equipmentdayinfo.setDaynhqfdl1(wtDataMap.get(wt.getId()+"_RDJSSDL-ZS"));
- equipmentdayinfo.setDaynhqfdl2(wtDataMap.get(wt.getId()+"_RSTSSDL-ZS"));
- equipmentdayinfo.setDaynhqfdl3(wtDataMap.get(wt.getId()+"_RXNSSDL-ZS"));
- equipmentdayinfo.setDaynhqfdl4(wtDataMap.get(wt.getId()+"_RQXSSDL-ZS"));
- //受累:RWZSSDL-ZS,RTZSSDL-ZS
- equipmentdayinfo.setDaynhcfdl1(wtDataMap.get(wt.getId()+"_RWZSSDL-ZS"));
- equipmentdayinfo.setDaynhcfdl2(wtDataMap.get(wt.getId()+"_RTZSSDL-ZS"));
- equipmentdayinfo.setTherogenecapacity(equipmentdayinfo.getGenecapacity()+equipmentdayinfo.getDaynhwhssdl1()+equipmentdayinfo.getDaynhwhssdl2()
- +equipmentdayinfo.getDaynhgzssdl1()+equipmentdayinfo.getDaynhgzssdl2()
- +equipmentdayinfo.getDaynhxdssdl1()+equipmentdayinfo.getDaynhxdssdl2()
- +equipmentdayinfo.getDaynhqfdl1()+equipmentdayinfo.getDaynhqfdl2()+equipmentdayinfo.getDaynhqfdl3()+equipmentdayinfo.getDaynhqfdl4()
- +equipmentdayinfo.getDaynhcfdl1()+equipmentdayinfo.getDaynhcfdl2());
- resultList.add(equipmentdayinfo);
- });
- equipmentdaydetailedService.saveBatch(resultList);
- }
- }
- /**
- * 保存值际操作指令表
- * @param beginDate
- * @param endDate
- */
- public void saveOperationrecord(String beginDate,String endDate) throws ParseException {
- List<String> days = getDays(beginDate, endDate);
- for (String day : days) {
- Date date = DateUtils.parseDate(day);
- Date startOfDay = DateUtils.getStartOfDay(date);
- Date endOfDay = DateUtils.getEndOfDay(date);
- Map<String, Object> params1 = new HashMap<>();
- params1.put("createdate", date);
- List<Dutyschedule> dutyList = dutyscheduleService.listByMap(params1);
- params1.remove("createdate");
- params1.put("time",date);
- operationrecordService.removeByMap(params1);
- Map<String, Map<String, Windturbinetestingpointai2>> wtpointMap = CacheContext.wtpAimap;
- String[] points = Contant.opePoints.split(",");
- List<Windturbine> wtls = CacheContext.wtls;
- List<OpeVo> resuList = new ArrayList<>();
- for (Windturbine wt : wtls) {
- if (wt.getWindpowerstationid().endsWith("GDC")){
- continue;
- }
- for (String point : points) {
- Windturbinetestingpointai2 windturbinetestingpointai2 = wtpointMap.get(wt.getId()).get(point);
- try {
- List<PointData> pointDatas = edosUtil.getHistoryDatasRaw(windturbinetestingpointai2.getId(), startOfDay.getTime()/1000, endOfDay.getTime()/1000);
- pointDatas.stream().forEach(pointData -> {
- OpeVo vo = new OpeVo();
- vo.setWtid(wt.getId());
- vo.setTime(DateUtils.parseLongToDate(pointData.getPointTime()*1000));
- vo.setValue(pointData.getPointValueInDouble());
- resuList.add(vo);
- });
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- }
- for (Dutyschedule duty : dutyList) {
- for (OpeVo vo : resuList) {
- if (isTimeRange(duty,vo.getTime())) {
- Operationrecord operationrecord = new Operationrecord();
- operationrecord.setDutyname(duty.getName());
- operationrecord.setWtid(vo.getWtid());
- operationrecord.setTime(vo.getTime());
- operationrecord.setValue(vo.getValue());
- operationrecordService.save(operationrecord);
- }
- }
- }
- }
- }
- /**
- * 保存值际五损
- * @param beginDate
- * @param endDate
- */
- public void saveBeanchmarkList(String beginDate,String endDate) throws Exception {
- List<String> days = getDays(beginDate, endDate);
- for (String day : days) {
- Date date = DateUtils.parseDate(day);
- Date startOfDay = DateUtils.getStartOfDay(date);
- Date endOfDay = DateUtils.getEndOfDay(date);
- Map<String, Object> params = new HashMap<>();
- params.put("theday", date);
- benchmarkingbetweenService.removeByMap(params);
- Map<String, Object> params1 = new HashMap<>();
- params1.put("createdate", date);
- List<Dutyschedule> dutyList = dutyscheduleService.listByMap(params1);
- String[] points = Contant.benchPoints.split(",");
- Map<String, Windpowerstationtestingpoint2> wpmap = CacheContext.wppointmap.get("0");
- SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- Map<String, Map<String, Double>> remap = new HashMap<>();
- for (Dutyschedule dutyschedule : dutyList) {
- String[] begins = dutyschedule.getBegin().split(",");
- String[] ends = dutyschedule.getEnd().split(",");
- Map<String, Double> map = new HashMap<>();
- for (int i = 0; i < begins.length; i++) {
- Date begin = df.parse(day + " " + begins[i] + ":00");
- Date end = df.parse(day + " " + ends[i] + ":00");
- for (String point : points) {
- Windpowerstationtestingpoint2 windpowerstationtestingpoint2 = wpmap.get(point);
- List<PointData> maxs = edosUtil.getHistStat(windpowerstationtestingpoint2.getCode(), begin.getTime() / 1000, end.getTime() / 1000, (long) 1, null, 0);
- List<PointData> mins = edosUtil.getHistStat(windpowerstationtestingpoint2.getCode(), begin.getTime() / 1000, end.getTime() / 1000, (long) 1, null, 1);
- double ssdl = 0;
- if (StringUtils.isNotEmpty(maxs) && StringUtils.isNotEmpty(mins)) {
- ssdl = (maxs.get(0).getPointValueInDouble() - mins.get(0).getPointValueInDouble()) / 10000;
- }
- if (!map.containsKey(point)) {
- map.put(point, ssdl);
- } else {
- map.put(point, map.get(point) + ssdl);
- }
- }
- Windpowerstationtestingpoint2 windpowerstationtestingpoint2 = wpmap.get("RFDL");
- List<PointData> maxs = edosUtil.getHistStat(windpowerstationtestingpoint2.getCode(), begin.getTime() / 1000, end.getTime() / 1000, (long) 1, null, 0);
- List<PointData> mins = edosUtil.getHistStat(windpowerstationtestingpoint2.getCode(), begin.getTime() / 1000, end.getTime() / 1000, (long) 1, null, 1);
- double fdl = 0;
- if (StringUtils.isNotEmpty(maxs) && StringUtils.isNotEmpty(mins)) {
- fdl = maxs.get(0).getPointValueInDouble() - mins.get(0).getPointValueInDouble();
- }
- if (!map.containsKey("RFDL")) {
- map.put("RFDL", fdl);
- } else {
- map.put("RFDL", map.get("RFDL") + fdl);
- }
- remap.put(dutyschedule.getName(), map);
- }
- }
- Set<String> dutyset = remap.keySet();
- for (String duty : dutyset) {
- Benchmarkingbetween bench = new Benchmarkingbetween();
- bench.setDutyname(duty);
- bench.setTheday(date);
- Map<String, Double> pointmap = remap.get(duty);
- bench.setPerformanceloss(pointmap.get("RSDJZSDL") + pointmap.get("RSSTZSDL") + pointmap.get("RXNZSDL") + pointmap.get("RSQXZSDL"));
- bench.setFaultloss(pointmap.get("RGZZSDL") + pointmap.get("RSZZSDL"));
- bench.setMainloss(pointmap.get("RJXZSDL") + pointmap.get("RLZZSDL"));
- bench.setRationingloss(pointmap.get("RQFZSDL") + pointmap.get("RXDZSDL"));
- bench.setInvolvesloss(pointmap.get("RWZZSDL") + pointmap.get("RTZZSDL"));
- bench.setGeneratity(pointmap.get("RFDL"));
- bench.setTheoreticalgeneratity(bench.getPerformanceloss() + bench.getFaultloss() + bench.getMainloss() + bench.getRationingloss() + bench.getInvolvesloss() + bench.getGeneratity());
- benchmarkingbetweenService.save(bench);
- }
- }
- }
- /**
- * 判断实际操作指令时间是否属于某个值班
- * @param duty
- * @param time
- * @return
- * @throws ParseException
- */
- private boolean isTimeRange(Dutyschedule duty,Date time) throws ParseException {
- SimpleDateFormat df = new SimpleDateFormat("HH:mm");
- Date now = df.parse(df.format(time));
- String[] begins=duty.getBegin().split(",");
- String[] ends=duty.getEnd().split(",");
- for (int i=0 ; i<begins.length;i++) {
- Date begin = df.parse(begins[i]);
- Date end = df.parse(ends[i]);
- Calendar nowTime = Calendar.getInstance();
- nowTime.setTime(now);
- Calendar beginTime = Calendar.getInstance();
- beginTime.setTime(begin);
- Calendar endTime = Calendar.getInstance();
- endTime.setTime(end);
- if (nowTime.before(endTime) && nowTime.after(beginTime)) {
- return true;
- }
- }
- return false;
- }
- /**
- * 获取两日期间日期list
- *
- * @param beginDate
- * @param endDate
- * @return
- */
- public static List<String> getDays(String beginDate, String endDate) {
- List<String> days = null;
- if (StringUtils.isNotEmpty(beginDate) && StringUtils.isNotEmpty(endDate)) {
- days = DateUtils.getDays(beginDate, endDate);
- } else {
- days = new ArrayList<>();
- days.add(DateUtils.getYesterdayStr("yyyy-MM-dd"));
- }
- return days;
- }
- /**
- * 风机绩效榜
- * @param wpids
- * @param projectids
- * @param lineids
- * @param beginDate
- * @param endDate
- * @param type
- * @return
- */
- public List<FjjxbVo> fjjxb(String wpids, String projectids, String lineids, String beginDate, String endDate, String type,String target,String sort) {
- List<FjjxbVo> resultList = new ArrayList<>();
- QueryWrapper<Equipmentdayinfo> qw = new QueryWrapper<>();
- StringBuilder sb = new StringBuilder();
- if (type.equals("1") ){
- sb.append("windpowerstationid,");
- }else if (type.equals("2")){
- sb.append("projectid,");
- } else if (type.equals("3")){
- sb.append("lineid,");
- }else {
- sb.append("windturbineid,");
- }
- sb.append("sum(genecapacity) genecapacity,sum(therogenecapacity) therogenecapacity,avg(speed) speed,sum(daynhwhssdl) daynhwhssdl,sum(daynhgzssdl) daynhgzssdl,sum(daynhxdssdl) daynhxdssdl,sum(daynhqfdl) daynhqfdl,sum(daynhcfdl) daynhcfdl");
- qw.select(String.valueOf(sb));
- qw.ge("recorddate",DateUtils.parseDate(beginDate)).le("recorddate",DateUtils.parseDate(endDate));
- if (StringUtils.isNotEmpty(wpids)){
- List<String> wpList = Arrays.asList(wpids.split(","));
- qw.in("windpowerstationid",wpList);
- }
- if (StringUtils.isNotEmpty(projectids)){
- List<String> proList = Arrays.asList(projectids.split(","));
- qw.in("projectid",proList);
- }
- if (StringUtils.isNotEmpty(lineids)){
- List<String> lineList = Arrays.asList(lineids.split(","));
- qw.in("lineid",lineList);
- }
- if (type.equals("1")){
- qw.groupBy("windpowerstationid");
- }else if(type.equals("2")){
- qw.groupBy("projectid");
- }else if(type.equals("3")){
- qw.groupBy("lineid");
- }else{
- qw.groupBy("windturbineid");
- }
- List<Equipmentdayinfo> list = equipmentdayinfoService.list(qw);
- AtomicReference<Double> llfdl = new AtomicReference<>((double) 0);
- AtomicReference<Double> sjfdl = new AtomicReference<>((double) 0);
- AtomicReference<Double> pjfs = new AtomicReference<>((double) 0);
- AtomicReference<Double> wh = new AtomicReference<>((double) 0);
- AtomicReference<Double> gz = new AtomicReference<>((double) 0);
- AtomicReference<Double> xd = new AtomicReference<>((double) 0);
- AtomicReference<Double> xn = new AtomicReference<>((double) 0);
- AtomicReference<Double> sl = new AtomicReference<>((double) 0);
- list.stream().forEach(i->{
- FjjxbVo vo = new FjjxbVo();
- if (type.equals("1")){
- vo.setId(i.getWindpowerstationid());
- vo.setName(CacheContext.wpmap.get(i.getWindpowerstationid().trim()).getName());
- }else if(type.equals("2")){
- vo.setId(i.getProjectid());
- vo.setName(CacheContext.projects.stream().filter(p->p.getId().equals(i.getProjectid().trim())).findFirst().get().getName());
- }else if(type.equals("3")){
- vo.setId(i.getLineid());
- vo.setName(CacheContext.lines.stream().filter(l->l.getId().equals(i.getLineid().trim())).findFirst().get().getName());
- }else{
- vo.setId(i.getWindturbineid());
- vo.setName(CacheContext.wtls.stream().filter(w->w.getId().equals(i.getWindturbineid().trim())).findFirst().get().getName());
- }
- vo.setSjfdl(BigDecimalUtils.divide(new BigDecimal(i.getGenecapacity()),new BigDecimal(10000),2).doubleValue());
- vo.setLlfdl(BigDecimalUtils.divide(new BigDecimal(i.getTherogenecapacity()),new BigDecimal(10000),2).doubleValue());
- vo.setSpeed(BigDecimalUtils.divide(new BigDecimal(i.getSpeed()),new BigDecimal(1),2).doubleValue());
- vo.setFjhjx(BigDecimalUtils.divide(new BigDecimal(i.getDaynhgzssdl()),new BigDecimal(10000),2).doubleValue());
- vo.setJhjx(BigDecimalUtils.divide(new BigDecimal(i.getDaynhwhssdl()),new BigDecimal(10000),2).doubleValue());
- vo.setXd(BigDecimalUtils.divide(new BigDecimal(i.getDaynhxdssdl()),new BigDecimal(10000),2).doubleValue());
- vo.setSl(BigDecimalUtils.divide(new BigDecimal(i.getDaynhcfdl()),new BigDecimal(10000),2).doubleValue());
- vo.setXn(BigDecimalUtils.divide(new BigDecimal(i.getDaynhqfdl()),new BigDecimal(10000),2).doubleValue());
- // vo.setLlfdl(DoubleUtils.getRoundingNum(vo.getSjfdl()+vo.getFjhjx()+vo.getJhjx()+vo.getXd()+vo.getXn(),2));
- vo.setFnlly(vo.getLlfdl()!=0?keepPrecision(vo.getSjfdl()/vo.getLlfdl()*100,2):0);
- llfdl.updateAndGet(v -> new Double((double) (v + vo.getLlfdl())));
- sjfdl.updateAndGet(v -> new Double((double) (v + vo.getSjfdl())));
- pjfs.updateAndGet(v -> new Double((double) (v + vo.getSpeed())));
- wh.updateAndGet(v -> new Double((double) (v + vo.getJhjx())));
- gz.updateAndGet(v -> new Double((double) (v + vo.getFjhjx())));
- xd.updateAndGet(v -> new Double((double) (v + vo.getXd())));
- xn.updateAndGet(v -> new Double((double) (v + vo.getXn())));
- sl.updateAndGet(v -> new Double((double) (v + vo.getSl())));
- resultList.add(vo);
- });
- if (StringUtils.isNotEmpty(target) && StringUtils.isNotEmpty(sort)){
- if (sort.equals("1")){
- SortUtils.sort(resultList,target,SortUtils.ASC);
- }else {
- SortUtils.sort(resultList,target,SortUtils.DESC);
- }
- }else {
- SortUtils.sort(resultList,"fnlly",SortUtils.ASC);
- }
- FjjxbVo vo = new FjjxbVo();
- vo.setId("hj");
- vo.setName("合计");
- vo.setSjfdl(keepPrecision(sjfdl.get().doubleValue(),2));
- vo.setLlfdl(keepPrecision(llfdl.get().doubleValue(),2));
- vo.setSpeed(list.size()!=0?keepPrecision(pjfs.get().doubleValue()/list.size(),2):0.0);
- vo.setJhjx(keepPrecision(wh.get().doubleValue(),2));
- vo.setFjhjx(keepPrecision(gz.get().doubleValue(),2));
- vo.setXd(keepPrecision(xd.get().doubleValue(),2));
- vo.setXn(keepPrecision(xn.get().doubleValue(),2));
- vo.setSl(keepPrecision(sl.get().doubleValue(),2));
- vo.setFnlly(vo.getLlfdl()!=0?keepPrecision(vo.getSjfdl()/vo.getLlfdl()*100,2):0.0);
- resultList.add(vo);
- return resultList;
- }
- /**
- * 保留两位小数
- * @param number
- * @param precision
- * @return
- */
- private double keepPrecision(double number, int precision) {
- BigDecimal bg = new BigDecimal(number);
- return bg.setScale(precision, BigDecimal.ROUND_HALF_UP).doubleValue();
- }
- /**
- * 风机绩效榜明细
- * @param wpids
- * @param projectids
- * @param lineids
- * @param beginDate
- * @param endDate
- * @param type
- * @return
- */
- public List<FjjxbmxVo> fjjxbmx(String wpids, String projectids, String lineids, String beginDate, String endDate, String type,String target,String sort) {
- List<FjjxbmxVo> resultList = new ArrayList<>();
- QueryWrapper<Equipmentdaydetailed> qw = new QueryWrapper<>();
- StringBuilder sb = new StringBuilder();
- if (type.equals("1") ){
- sb.append("windpowerstationid,");
- }else if (type.equals("2")){
- sb.append("projectid,");
- } else if (type.equals("3")){
- sb.append("lineid,");
- }else {
- sb.append("windturbineid,");
- }
- sb.append("sum(genecapacity) genecapacity,sum(therogenecapacity) therogenecapacity,avg(speed) speed,sum(daynhwhssdl1) daynhwhssdl1,sum(daynhwhssdl2) daynhwhssdl2,sum(daynhgzssdl1) daynhgzssdl1,sum(daynhgzssdl2) daynhgzssdl2,sum(daynhxdssdl1) daynhxdssdl1,sum(daynhxdssdl2) daynhxdssdl2,sum(daynhqfdl1) daynhqfdl1,sum(daynhqfdl2) daynhqfdl2,sum(daynhqfdl3) daynhqfdl3,sum(daynhqfdl4) daynhqfdl4,sum(daynhcfdl1) daynhcfdl1,sum(daynhcfdl2) daynhcfdl2 ");
- qw.select(String.valueOf(sb));
- qw.ge("recorddate",DateUtils.parseDate(beginDate)).le("recorddate",DateUtils.parseDate(endDate));
- if (StringUtils.isNotEmpty(wpids)){
- List<String> wpList = Arrays.asList(wpids.split(","));
- qw.in("windpowerstationid",wpList);
- }
- if (StringUtils.isNotEmpty(projectids)){
- List<String> proList = Arrays.asList(projectids.split(","));
- qw.in("projectid",proList);
- }
- if (StringUtils.isNotEmpty(lineids)){
- List<String> lineList = Arrays.asList(lineids.split(","));
- qw.in("lineid",lineList);
- }
- if (type.equals("1")){
- qw.groupBy("windpowerstationid");
- }else if(type.equals("2")){
- qw.groupBy("projectid");
- }else if(type.equals("3")){
- qw.groupBy("lineid");
- }else{
- qw.groupBy("windturbineid");
- }
- List<Equipmentdaydetailed> list = equipmentdaydetailedService.list(qw);
- AtomicReference<Double> llfdl = new AtomicReference<>((double) 0);
- AtomicReference<Double> sjfdl = new AtomicReference<>((double) 0);
- AtomicReference<Double> pjfs = new AtomicReference<>((double) 0);
- AtomicReference<Double> wh1 = new AtomicReference<>((double) 0);
- AtomicReference<Double> wh2 = new AtomicReference<>((double) 0);
- AtomicReference<Double> gz1 = new AtomicReference<>((double) 0);
- AtomicReference<Double> gz2 = new AtomicReference<>((double) 0);
- AtomicReference<Double> xd1 = new AtomicReference<>((double) 0);
- AtomicReference<Double> xd2 = new AtomicReference<>((double) 0);
- AtomicReference<Double> xn1 = new AtomicReference<>((double) 0);
- AtomicReference<Double> xn2 = new AtomicReference<>((double) 0);
- AtomicReference<Double> xn3 = new AtomicReference<>((double) 0);
- AtomicReference<Double> xn4 = new AtomicReference<>((double) 0);
- AtomicReference<Double> sl1 = new AtomicReference<>((double) 0);
- AtomicReference<Double> sl2 = new AtomicReference<>((double) 0);
- list.stream().forEach(i->{
- FjjxbmxVo vo = new FjjxbmxVo();
- if (type.equals("1")){
- vo.setId(i.getWindpowerstationid());
- vo.setName(CacheContext.wpmap.get(i.getWindpowerstationid().trim()).getName());
- }else if(type.equals("2")){
- vo.setId(i.getProjectid());
- vo.setName(CacheContext.projects.stream().filter(p->p.getId().equals(i.getProjectid().trim())).findFirst().get().getName());
- }else if(type.equals("3")){
- vo.setId(i.getLineid());
- vo.setName(CacheContext.lines.stream().filter(l->l.getId().equals(i.getLineid().trim())).findFirst().get().getName());
- }else{
- vo.setId(i.getWindturbineid());
- vo.setName(CacheContext.wtls.stream().filter(w->w.getId().equals(i.getWindturbineid().trim())).findFirst().get().getName());
- }
- vo.setSjfdl(keepPrecision(i.getGenecapacity()/10000,2));
- vo.setLlfdl(keepPrecision(i.getTherogenecapacity()/10000,2));
- vo.setSpeed(keepPrecision(i.getSpeed(),2));
- vo.setFjhjx1(keepPrecision(i.getDaynhgzssdl1()/10000,2));
- vo.setFjhjx2(keepPrecision(i.getDaynhgzssdl2()/10000,2));
- vo.setJhjx1(keepPrecision(i.getDaynhwhssdl1()/10000,2));
- vo.setJhjx2(keepPrecision(i.getDaynhwhssdl2()/10000,2));
- vo.setXd1(keepPrecision(i.getDaynhxdssdl1()/10000,2));
- vo.setXd2(keepPrecision(i.getDaynhxdssdl2()/10000,2));
- vo.setSl1(keepPrecision(i.getDaynhcfdl1()/10000,2));
- vo.setSl2(keepPrecision(i.getDaynhcfdl2()/10000,2));
- vo.setXn1(keepPrecision(i.getDaynhqfdl1()/10000,2));
- vo.setXn2(keepPrecision(i.getDaynhqfdl2()/10000,2));
- vo.setXn3(keepPrecision(i.getDaynhqfdl3()/10000,2));
- vo.setXn4(keepPrecision(i.getDaynhqfdl4()/10000,2));
- vo.setFnlly(vo.getLlfdl()!=0?keepPrecision(vo.getSjfdl()/vo.getLlfdl()*100,2):0.0);
- llfdl.updateAndGet(v -> new Double((double) (v + vo.getLlfdl())));
- sjfdl.updateAndGet(v -> new Double((double) (v + vo.getSjfdl())));
- pjfs.updateAndGet(v -> new Double((double) (v + vo.getSpeed())));
- wh1.updateAndGet(v -> new Double((double) (v + vo.getJhjx1())));
- wh2.updateAndGet(v -> new Double((double) (v + vo.getJhjx2())));
- gz1.updateAndGet(v -> new Double((double) (v + vo.getFjhjx1())));
- gz2.updateAndGet(v -> new Double((double) (v + vo.getFjhjx2())));
- xd1.updateAndGet(v -> new Double((double) (v + vo.getXd1())));
- xd2.updateAndGet(v -> new Double((double) (v + vo.getXd2())));
- xn1.updateAndGet(v -> new Double((double) (v + vo.getXn1())));
- xn2.updateAndGet(v -> new Double((double) (v + vo.getXn2())));
- xn3.updateAndGet(v -> new Double((double) (v + vo.getXn3())));
- xn4.updateAndGet(v -> new Double((double) (v + vo.getXn4())));
- sl1.updateAndGet(v -> new Double((double) (v + vo.getSl1())));
- sl2.updateAndGet(v -> new Double((double) (v + vo.getSl2())));
- resultList.add(vo);
- });
- if (StringUtils.isNotEmpty(target) && StringUtils.isNotEmpty(sort)){
- if (sort.equals("1")){
- SortUtils.sort(resultList,target,SortUtils.ASC);
- }else {
- SortUtils.sort(resultList,target,SortUtils.DESC);
- }
- }else {
- SortUtils.sort(resultList,"fnlly",SortUtils.ASC);
- }
- FjjxbmxVo vo = new FjjxbmxVo();
- vo.setId("hj");
- vo.setName("合计");
- vo.setSjfdl(keepPrecision(sjfdl.get().doubleValue(),2));
- vo.setLlfdl(keepPrecision(llfdl.get().doubleValue(),2));
- vo.setSpeed(list.size()!=0?keepPrecision(pjfs.get().doubleValue()/list.size(),2):0.0);
- vo.setJhjx1(keepPrecision(wh1.get().doubleValue(),2));
- vo.setJhjx2(keepPrecision(wh2.get().doubleValue(),2));
- vo.setFjhjx1(keepPrecision(gz1.get().doubleValue(),2));
- vo.setFjhjx2(keepPrecision(gz2.get().doubleValue(),2));
- vo.setXd1(keepPrecision(xd1.get().doubleValue(),2));
- vo.setXd2(keepPrecision(xd2.get().doubleValue(),2));
- vo.setXn1(keepPrecision(xn1.get().doubleValue(),2));
- vo.setXn2(keepPrecision(xn2.get().doubleValue(),2));
- vo.setXn3(keepPrecision(xn3.get().doubleValue(),2));
- vo.setXn4(keepPrecision(xn4.get().doubleValue(),2));
- vo.setSl1(keepPrecision(sl1.get().doubleValue(),2));
- vo.setSl2(keepPrecision(sl2.get().doubleValue(),2));
- vo.setFnlly(vo.getLlfdl()!=0?keepPrecision(vo.getSjfdl()/vo.getLlfdl()*100,2):0.0);
- resultList.add(vo);
- return resultList;
- }
- /**
- * 场站列表
- * @return
- */
- public List<Windpowerstation> wplist() {
- List<Windpowerstation> wplist = CacheContext.wplist.stream().filter(i->i.getId().endsWith("FDC") && i.getCompanyid().equals("NXGD_GS")).collect(Collectors.toList());
- return wplist;
- }
- /**
- * GF场站列表
- * @return
- */
- public List<Windpowerstation> wpGFList() {
- List<Windpowerstation> wplist = CacheContext.wplist.stream().filter(i->i.getId().endsWith("GDC") && i.getCompanyid().equals("NXGD_GS")).collect(Collectors.toList());
- return wplist;
- }
- /**
- * 根据场站查询风机列表
- * @param wpid
- * @return
- */
- public List<Windturbine> wtList(String wpid) {
- List<Windturbine> windturbineList = CacheContext.wtls.stream().filter(i -> i.getWindpowerstationid().equals(wpid)).collect(Collectors.toList());
- return windturbineList;
- }
- /**
- * 根据场站查询项目列表
- * @param wpids
- * @return
- */
- public List<Project> projectList(String wpids) {
- List<Project> projects = CacheContext.projects.stream().filter(i -> wpids.contains(i.getWindpowerstationid())).collect(Collectors.toList());
- return projects;
- }
- /**
- * 根据项目查询线路列表
- * @param projects
- * @return
- */
- public List<Line> lineList(String projects) {
- List<Line> lines = CacheContext.lines.stream().filter(i -> projects.contains(i.getProjectid())).collect(Collectors.toList());
- return lines;
- }
- /**
- * 五项损失率
- * @param wpids
- * @param projectids
- * @param lineids
- * @param beginDate
- * @param endDate
- * @return
- */
- public List<WxsslVo> wxssl(String wpids, String projectids, String lineids, String beginDate, String endDate,String target,String sort) {
- List<WxsslVo> resultList = new ArrayList<>();
- QueryWrapper<Equipmentdayinfo> qw = new QueryWrapper<>();
- StringBuilder sb = new StringBuilder();
- if (StringUtils.isNotEmpty(wpids) && StringUtils.isEmpty(projectids) && StringUtils.isEmpty(lineids)){
- sb.append("windpowerstationid,");
- }else if (StringUtils.isNotEmpty(wpids) && StringUtils.isNotEmpty(projectids) && StringUtils.isEmpty(lineids)){
- sb.append("projectid,");
- } else if (StringUtils.isNotEmpty(wpids) && StringUtils.isNotEmpty(projectids) && StringUtils.isNotEmpty(lineids)){
- sb.append("lineid,");
- }else {
- sb.append("windpowerstationid,");
- }
- sb.append("sum(genecapacity) genecapacity,sum(therogenecapacity) therogenecapacity,sum(daynhwhssdl) daynhwhssdl,sum(daynhgzssdl) daynhgzssdl,sum(daynhxdssdl) daynhxdssdl,sum(daynhqfdl) daynhqfdl,sum(daynhcfdl) daynhcfdl");
- qw.select(String.valueOf(sb));
- qw.ge("recorddate",DateUtils.parseDate(beginDate)).le("recorddate",DateUtils.parseDate(endDate));
- if (StringUtils.isNotEmpty(wpids)){
- List<String> wpList = Arrays.asList(wpids.split(","));
- qw.in("windpowerstationid",wpList);
- }
- if (StringUtils.isNotEmpty(projectids)){
- List<String> proList = Arrays.asList(projectids.split(","));
- qw.in("projectid",proList);
- }
- if (StringUtils.isNotEmpty(lineids)){
- List<String> lineList = Arrays.asList(lineids.split(","));
- qw.in("lineid",lineList);
- }
- if (StringUtils.isNotEmpty(wpids) && StringUtils.isEmpty(projectids) && StringUtils.isEmpty(lineids)){
- qw.groupBy("windpowerstationid");
- }else if (StringUtils.isNotEmpty(wpids) && StringUtils.isNotEmpty(projectids) && StringUtils.isEmpty(lineids)){
- qw.groupBy("projectid");
- } else if (StringUtils.isNotEmpty(wpids) && StringUtils.isNotEmpty(projectids) && StringUtils.isNotEmpty(lineids)){
- qw.groupBy("lineid");
- }else {
- qw.groupBy("windpowerstationid");
- }
- List<Equipmentdayinfo> list = equipmentdayinfoService.list(qw);
- Map<String,Double> station = windpowerstationService.list()
- .stream().collect(Collectors.toMap(Windpowerstation::getId,Windpowerstation::getOrdernum));
- list.stream().forEach(i->{
- WxsslVo vo = new WxsslVo();
- station.get(i.getWindpowerstationid());
- vo.setOrdernum(station.get(i.getWindpowerstationid()));
- if (StringUtils.isNotEmpty(wpids) && StringUtils.isEmpty(projectids) && StringUtils.isEmpty(lineids)){
- vo.setId(i.getWindpowerstationid());
- vo.setName(CacheContext.wpmap.get(i.getWindpowerstationid().trim()).getName());
- }else if (StringUtils.isNotEmpty(wpids) && StringUtils.isNotEmpty(projectids) && StringUtils.isEmpty(lineids)){
- vo.setId(i.getProjectid());
- vo.setName(CacheContext.projects.stream().filter(p->p.getId().equals(i.getProjectid().trim())).findFirst().get().getName());
- } else if (StringUtils.isNotEmpty(wpids) && StringUtils.isNotEmpty(projectids) && StringUtils.isNotEmpty(lineids)){
- vo.setId(i.getLineid());
- vo.setName(CacheContext.lines.stream().filter(l->l.getId().equals(i.getLineid().trim())).findFirst().get().getName());
- }else {
- vo.setId(i.getWindpowerstationid());
- vo.setName(CacheContext.wpmap.get(i.getWindpowerstationid().trim()).getName());
- }
- vo.setFdl(keepPrecision(i.getGenecapacity()/10000,2));
- vo.setLlfdl(keepPrecision(i.getTherogenecapacity()/10000,2));
- vo.setJxssdl(keepPrecision(i.getDaynhwhssdl()/10000,2));
- vo.setGzssdl(keepPrecision(i.getDaynhgzssdl()/10000,2));
- vo.setXdssdl(keepPrecision(i.getDaynhxdssdl()/10000,2));
- vo.setSlssdl(keepPrecision(i.getDaynhcfdl()/10000,2));
- vo.setXnssdl(keepPrecision(i.getDaynhqfdl()/10000,2));
- vo.setZssdl(keepPrecision((vo.getGzssdl()+vo.getJxssdl()+vo.getXdssdl()+vo.getXnssdl()+vo.getSlssdl())/10000,2));
- vo.setFnlyl(vo.getLlfdl()!=0?keepPrecision(vo.getFdl()/vo.getLlfdl()*100,2):0.0);
- vo.setGzssl(vo.getLlfdl()!=0?keepPrecision(vo.getGzssdl()/vo.getLlfdl()*100,2):0.0);
- vo.setJxssl(vo.getLlfdl()!=0?keepPrecision(vo.getJxssdl()/vo.getLlfdl()*100,2):0.0);
- vo.setQfl(vo.getLlfdl()!=0?keepPrecision(vo.getXdssdl()/vo.getLlfdl()*100,2):0.0);
- vo.setXnssl(vo.getLlfdl()!=0?keepPrecision(vo.getXnssdl()/vo.getLlfdl()*100,2):0.0);
- vo.setSlssl(vo.getLlfdl()!=0?keepPrecision(vo.getSlssdl()/vo.getLlfdl()*100,2):0.0);
- resultList.add(vo);
- });
- SortUtils.sort(resultList,"fdl",SortUtils.DESC);
- for (int i=0;i<resultList.size();i++){
- resultList.get(i).setFdlpm(i+1);
- }
- SortUtils.sort(resultList,"fnlyl",SortUtils.DESC);
- for (int i=0;i<resultList.size();i++){
- resultList.get(i).setFnlylpm(i+1);
- }
- SortUtils.sort(resultList,"zssdl",SortUtils.ASC);
- for (int i=0;i<resultList.size();i++){
- resultList.get(i).setZhpm(i+1);
- }
- SortUtils.sort(resultList,"gzssdl",SortUtils.ASC);
- for (int i=0;i<resultList.size();i++){
- resultList.get(i).setGzssdlpm(i+1);
- }
- SortUtils.sort(resultList,"gzssl",SortUtils.ASC);
- for (int i=0;i<resultList.size();i++){
- resultList.get(i).setGzsslpm(i+1);
- }
- SortUtils.sort(resultList,"jxssdl",SortUtils.ASC);
- for (int i=0;i<resultList.size();i++){
- resultList.get(i).setJxssdlpm(i+1);
- }
- SortUtils.sort(resultList,"jxssl",SortUtils.ASC);
- for (int i=0;i<resultList.size();i++){
- resultList.get(i).setJxsslpm(i+1);
- }
- SortUtils.sort(resultList,"xdssdl",SortUtils.ASC);
- for (int i=0;i<resultList.size();i++){
- resultList.get(i).setXdssdlpm(i+1);
- }
- SortUtils.sort(resultList,"qfl",SortUtils.ASC);
- for (int i=0;i<resultList.size();i++){
- resultList.get(i).setQflpm(i+1);
- }
- SortUtils.sort(resultList,"xnssdl",SortUtils.ASC);
- for (int i=0;i<resultList.size();i++){
- resultList.get(i).setXnssdlpm(i+1);
- }
- SortUtils.sort(resultList,"xnssl",SortUtils.ASC);
- for (int i=0;i<resultList.size();i++){
- resultList.get(i).setXnsslpm(i+1);
- }
- SortUtils.sort(resultList,"slssdl",SortUtils.ASC);
- for (int i=0;i<resultList.size();i++){
- resultList.get(i).setSlssdlpm(i+1);
- }
- SortUtils.sort(resultList,"slssl",SortUtils.ASC);
- for (int i=0;i<resultList.size();i++){
- resultList.get(i).setSlsslpm(i+1);
- }
- if (StringUtils.isNotEmpty(target) && StringUtils.isNotEmpty(sort)){
- if (sort.equals("1")){
- SortUtils.sort(resultList,target,SortUtils.ASC);
- }else {
- SortUtils.sort(resultList,target,SortUtils.DESC);
- }
- }else {
- //SortUtils.sort(resultList,"fdl",SortUtils.DESC);
- SortUtils.sort(resultList,"ordernum",SortUtils.ASC);
- }
- return resultList;
- }
- /**
- * 场内对标
- * @param wpid
- * @param beginDate
- * @param endDate
- * @return
- */
- public List<WxsslVo> cndb(String wpid, String beginDate, String endDate,String target,String sort) {
- QueryWrapper<Equipmentdayinfo> qw = new QueryWrapper<>();
- List<WxsslVo> resultList = new ArrayList<>();
- qw.select("recorddate,sum(genecapacity) genecapacity,sum(therogenecapacity) therogenecapacity,sum(daynhwhssdl) daynhwhssdl,sum(daynhgzssdl) daynhgzssdl,sum(daynhxdssdl) daynhxdssdl,sum(daynhqfdl) daynhqfdl,sum(daynhcfdl) daynhcfdl");
- qw.ge("recorddate",DateUtils.parseDate(beginDate)).le("recorddate",DateUtils.parseDate(endDate));
- if (StringUtils.isNotEmpty(wpid)){
- qw.eq("windpowerstationid",wpid);
- }
- qw.groupBy("recorddate");
- List<WxsslVo> wxsslVoList = getWxsslSortVos(qw,resultList,TYPE_DATE);
- if (StringUtils.isNotEmpty(target) && StringUtils.isNotEmpty(sort)){
- if (sort.equals("1")){
- SortUtils.sort(resultList,target,SortUtils.ASC);
- }else {
- SortUtils.sort(resultList,target,SortUtils.DESC);
- }
- }else {
- SortUtils.sort(resultList,"date",SortUtils.ASC);
- }
- return wxsslVoList;
- }
- /**
- * 场际对标
- * @param wpids
- * @param beginDate
- * @param endDate
- * @return
- */
- public List<WxsslVo> cjdb(String wpids, String beginDate, String endDate,String target,String sort) {
- List<WxsslVo> resultList = new ArrayList<>();
- QueryWrapper<Equipmentdayinfo> qw = new QueryWrapper<>();
- qw.select("windpowerstationid,sum(genecapacity) genecapacity,sum(therogenecapacity) therogenecapacity,sum(daynhwhssdl) daynhwhssdl,sum(daynhgzssdl) daynhgzssdl,sum(daynhxdssdl) daynhxdssdl,sum(daynhqfdl) daynhqfdl,sum(daynhcfdl) daynhcfdl");
- qw.ge("recorddate",DateUtils.parseDate(beginDate)).le("recorddate",DateUtils.parseDate(endDate));
- if (StringUtils.isNotEmpty(wpids)){
- List<String> wpList = Arrays.asList(wpids.split(","));
- qw.in("windpowerstationid",wpList);
- }
- qw.groupBy("windpowerstationid");
- List<WxsslVo> wxsslVoList = getWxsslSortVos(qw,resultList,TYPE_WIND);
- if (StringUtils.isNotEmpty(target) && StringUtils.isNotEmpty(sort)){
- if (sort.equals("1")){
- SortUtils.sort(resultList,target,SortUtils.ASC);
- }else {
- SortUtils.sort(resultList,target,SortUtils.DESC);
- }
- }else {
- SortUtils.sort(resultList,"ordernum",SortUtils.ASC);
- }
- return wxsslVoList;
- }
- /**
- * 项目对标
- * @param wpids
- * @param projectids
- * @param beginDate
- * @param endDate
- * @return
- */
- public List<WxsslVo> xmdb(String wpids, String projectids, String beginDate, String endDate,String target,String sort) {
- List<WxsslVo> resultList = new ArrayList<>();
- QueryWrapper<Equipmentdayinfo> qw = new QueryWrapper<>();
- qw.select("projectid,sum(genecapacity) genecapacity,sum(therogenecapacity) therogenecapacity,sum(daynhwhssdl) daynhwhssdl,sum(daynhgzssdl) daynhgzssdl,sum(daynhxdssdl) daynhxdssdl,sum(daynhqfdl) daynhqfdl,sum(daynhcfdl) daynhcfdl");
- qw.ge("recorddate",DateUtils.parseDate(beginDate)).le("recorddate",DateUtils.parseDate(endDate));
- if (StringUtils.isNotEmpty(wpids)){
- List<String> wpList = Arrays.asList(wpids.split(","));
- qw.in("windpowerstationid",wpList);
- }
- if (StringUtils.isNotEmpty(projectids)){
- List<String> projectList = Arrays.asList(projectids.split(","));
- qw.in("projectid",projectList);
- }
- qw.groupBy("projectid");
- List<WxsslVo> wxsslVoList = getWxsslSortVos(qw,resultList,TYPE_PROJECT);
- if (StringUtils.isNotEmpty(target) && StringUtils.isNotEmpty(sort)){
- if (sort.equals("1")){
- SortUtils.sort(resultList,target,SortUtils.ASC);
- }else {
- SortUtils.sort(resultList,target,SortUtils.DESC);
- }
- }else {
- SortUtils.sort(resultList,"fdl",SortUtils.ASC);
- }
- return wxsslVoList;
- }
- /**
- * 线路对标
- * @param wpids
- * @param projectids
- * @param lineids
- * @param beginDate
- * @param endDate
- * @return
- */
- public List<WxsslVo> xldb(String wpids, String projectids, String lineids, String beginDate, String endDate,String target,String sort) {
- List<WxsslVo> resultList = new ArrayList<>();
- QueryWrapper<Equipmentdayinfo> qw = new QueryWrapper<>();
- qw.select("lineid,sum(genecapacity) genecapacity,sum(therogenecapacity) therogenecapacity,sum(daynhwhssdl) daynhwhssdl,sum(daynhgzssdl) daynhgzssdl,sum(daynhxdssdl) daynhxdssdl,sum(daynhqfdl) daynhqfdl,sum(daynhcfdl) daynhcfdl");
- qw.ge("recorddate",DateUtils.parseDate(beginDate)).le("recorddate",DateUtils.parseDate(endDate));
- if (StringUtils.isNotEmpty(wpids)){
- List<String> wpList = Arrays.asList(wpids.split(","));
- qw.in("windpowerstationid",wpList);
- }
- if (StringUtils.isNotEmpty(projectids)){
- List<String> projectList = Arrays.asList(projectids.split(","));
- qw.in("projectid",projectList);
- }
- if (StringUtils.isNotEmpty(lineids)){
- List<String> lineList = Arrays.asList(lineids.split(","));
- qw.in("lineid",lineList);
- }
- qw.groupBy("lineid");
- List<WxsslVo> wxsslVoList = getWxsslSortVos(qw,resultList,TYPE_LINE);
- if (StringUtils.isNotEmpty(target) && StringUtils.isNotEmpty(sort)){
- if (sort.equals("1")){
- SortUtils.sort(resultList,target,SortUtils.ASC);
- }else {
- SortUtils.sort(resultList,target,SortUtils.DESC);
- }
- }else {
- SortUtils.sort(resultList,"fdl",SortUtils.ASC);
- }
- return wxsslVoList;
- }
- /**
- * 根据查询条件和类型,查询处五项损失并封装到结果list
- * @param qw
- * @param resultList
- * @param type
- * @return
- */
- private List<WxsslVo> getWxsslSortVos(QueryWrapper<Equipmentdayinfo> qw, List<WxsslVo> resultList, String type) {
- Map<String,Double> station = windpowerstationService.list()
- .stream().collect(Collectors.toMap(Windpowerstation::getId,Windpowerstation::getOrdernum));
- List<Equipmentdayinfo> list = equipmentdayinfoService.list(qw);
- list.stream().forEach(i->{
- WxsslVo vo = new WxsslVo();
- vo.setOrdernum(station.get(i.getWindpowerstationid()));
- if (type.equals(TYPE_WIND)){
- vo.setId(i.getWindpowerstationid());
- vo.setName(CacheContext.wpmap.get(i.getWindpowerstationid().trim()).getName());
- }else if(type.equals(TYPE_PROJECT)){
- vo.setId(i.getProjectid());
- vo.setName(CacheContext.projects.stream().filter(p->p.getId().equals(i.getProjectid().trim())).findFirst().get().getName());
- }else if(type.equals(TYPE_LINE)){
- vo.setId(i.getLineid());
- vo.setName(CacheContext.lines.stream().filter(l->l.getId().equals(i.getLineid().trim())).findFirst().get().getName());
- }else if(type.equals(TYPE_WINDTURBINE)){
- vo.setId(i.getWindturbineid());
- vo.setName(CacheContext.wtls.stream().filter(w->w.getId().equals(i.getWindturbineid().trim())).findFirst().get().getName());
- }
- vo.setDate(i.getRecorddate());
- vo.setFdl(keepPrecision(i.getGenecapacity()/10000,2));
- vo.setLlfdl(keepPrecision(i.getTherogenecapacity()/10000,2));
- vo.setGzssdl(keepPrecision(i.getDaynhgzssdl()/10000,2));
- vo.setJxssdl(keepPrecision(i.getDaynhwhssdl()/10000,2));
- vo.setXdssdl(keepPrecision(i.getDaynhxdssdl()/10000,2));
- vo.setXnssdl(keepPrecision(i.getDaynhqfdl()/10000,2));
- vo.setSlssdl(keepPrecision(i.getDaynhcfdl()/10000,2));
- vo.setFnlyl(vo.getLlfdl()!=0?keepPrecision(vo.getFdl()/vo.getLlfdl()*100,2):0);
- vo.setGzssl(vo.getLlfdl()!=0?keepPrecision(vo.getGzssdl()/vo.getLlfdl()*100,2):0);
- vo.setJxssl(vo.getLlfdl()!=0?keepPrecision(vo.getJxssdl()/vo.getLlfdl()*100,2):0);
- vo.setQfl(vo.getLlfdl()!=0?keepPrecision(vo.getXdssdl()/vo.getLlfdl()*100,2):0);
- vo.setXnssl(vo.getLlfdl()!=0?keepPrecision(vo.getXnssdl()/vo.getLlfdl()*100,2):0);
- vo.setSlssl(vo.getLlfdl()!=0?keepPrecision(vo.getSlssdl()/vo.getLlfdl()*100,2):0);
- resultList.add(vo);
- });
- SortUtils.sort(resultList,"llfdl",SortUtils.DESC);
- for (int i=0;i<resultList.size();i++){
- resultList.get(i).setZhpm(i+1);
- }
- SortUtils.sort(resultList,"fdl",SortUtils.DESC);
- for (int i=0;i<resultList.size();i++){
- resultList.get(i).setFdlpm(i+1);
- }
- SortUtils.sort(resultList,"fnlyl",SortUtils.DESC);
- for (int i=0;i<resultList.size();i++){
- resultList.get(i).setFnlylpm(i+1);
- }
- SortUtils.sort(resultList,"gzssdl",SortUtils.ASC);
- for (int i=0;i<resultList.size();i++){
- resultList.get(i).setGzssdlpm(i+1);
- }
- SortUtils.sort(resultList,"gzssl",SortUtils.ASC);
- for (int i=0;i<resultList.size();i++){
- resultList.get(i).setGzsslpm(i+1);
- }
- SortUtils.sort(resultList,"jxssdl",SortUtils.ASC);
- for (int i=0;i<resultList.size();i++){
- resultList.get(i).setJxssdlpm(i+1);
- }
- SortUtils.sort(resultList,"jxssl",SortUtils.ASC);
- for (int i=0;i<resultList.size();i++){
- resultList.get(i).setJxsslpm(i+1);
- }
- SortUtils.sort(resultList,"xdssdl",SortUtils.ASC);
- for (int i=0;i<resultList.size();i++){
- resultList.get(i).setXdssdlpm(i+1);
- }
- SortUtils.sort(resultList,"qfl",SortUtils.ASC);
- for (int i=0;i<resultList.size();i++){
- resultList.get(i).setQflpm(i+1);
- }
- SortUtils.sort(resultList,"xnssdl",SortUtils.ASC);
- for (int i=0;i<resultList.size();i++){
- resultList.get(i).setXnssdlpm(i+1);
- }
- SortUtils.sort(resultList,"xnssl",SortUtils.ASC);
- for (int i=0;i<resultList.size();i++){
- resultList.get(i).setXnsslpm(i+1);
- }
- SortUtils.sort(resultList,"slssdl",SortUtils.ASC);
- for (int i=0;i<resultList.size();i++){
- resultList.get(i).setSlssdlpm(i+1);
- }
- SortUtils.sort(resultList,"slssl",SortUtils.ASC);
- for (int i=0;i<resultList.size();i++){
- resultList.get(i).setSlsslpm(i+1);
- }
- return resultList;
- }
- /**
- * 值际操作指令list
- * @param beginDate
- * @param endDate
- * @return
- */
- public List<Operation> findOperecords(String beginDate, String endDate) {
- List<Operation> resultList = new ArrayList<>();
- Date begin = DateUtils.parseDate(beginDate);
- Date end = DateUtils.getEndOfDay(DateUtils.parseDate(endDate));
- List<Operationrecord> opeList = operationrecordService.listByBeginAndEnd(begin, end);
- QueryWrapper<Dutyschedule> wrapper = new QueryWrapper();
- wrapper.select("max(id) id,name,max(begin) begin,max(end) end,max(createdate) createdate");
- wrapper.le("createdate",end).ge("createdate",begin).groupBy("name");
- List<Dutyschedule> dutyList= dutyscheduleService.list(wrapper);
- for (Dutyschedule duty : dutyList) {
- Operation ope = new Operation();
- ope.setNameOfDuty(duty.getName());
- List<Operationrecord> opeVos= opeList.stream().filter(v -> v.getDutyname().equals(duty.getName())).collect(Collectors.toList());
- ope.setStartCount(opeVos.stream().filter(vo -> vo.getValue()==1.0).collect(Collectors.toList()).size());
- ope.setStopCount(opeVos.stream().filter(vo -> vo.getValue()==2.0).collect(Collectors.toList()).size());
- ope.setResetCount(opeVos.stream().filter(vo -> vo.getValue()==3.0).collect(Collectors.toList()).size());
- ope.setMaintainCount(opeVos.stream().filter(vo -> vo.getValue()==4.0).collect(Collectors.toList()).size());
- ope.setUnmaintainCount(opeVos.stream().filter(vo -> vo.getValue()==5.0).collect(Collectors.toList()).size());
- ope.setGpmaintainCount(opeVos.stream().filter(vo -> vo.getValue()==6.0).collect(Collectors.toList()).size());
- ope.setGpfaultCount(opeVos.stream().filter(vo -> vo.getValue()==7.0).collect(Collectors.toList()).size());
- ope.setGponsiteinvolvementMaintainCount(opeVos.stream().filter(vo -> vo.getValue()==8.0).collect(Collectors.toList()).size());
- ope.setGponsiteinvolvementFaultCount(opeVos.stream().filter(vo -> vo.getValue()==9.0).collect(Collectors.toList()).size());
- ope.setGpoffsiteaffectedgridCount(opeVos.stream().filter(vo -> vo.getValue()==100).collect(Collectors.toList()).size());
- ope.setGpweatherOutsideCount(opeVos.stream().filter(vo -> vo.getValue()==11.0).collect(Collectors.toList()).size());
- ope.setUngpCount(opeVos.stream().filter(vo -> vo.getValue()==12.0).collect(Collectors.toList()).size());
- resultList.add(ope);
- }
- return resultList;
- }
- /**
- * 值际点击钻取
- * @param beginDate
- * @param endDate
- * @param dutyname
- * @param direct
- * @return
- */
- public List<Operationrecord> drillOperecords(String beginDate, String endDate, String dutyname, String direct) {
- Date begin = DateUtils.parseDate(beginDate);
- Date end = DateUtils.getEndOfDay(DateUtils.parseDate(endDate));
- List<Operationrecord> opeList = operationrecordService.listByBeginAndEnd(begin,end);
- List<Operationrecord> resuList = opeList.stream().filter(ope -> ope.getDutyname().equals(dutyname) && ope.getValue() == Double.parseDouble(direct)).collect(Collectors.toList());
- return resuList;
- }
- /**
- * 值际五项损失
- * @param beginDate
- * @param endDate
- * @return
- */
- public List<Benchmarkingbetween> findbenchlist(String beginDate, String endDate) {
- Date begin = DateUtils.parseDate(beginDate);
- Date end = DateUtils.parseDate(endDate);
- List<Benchmarkingbetween> resuList = benchmarkingbetweenService.findByBeginAndEnd(begin,end);
- return resuList;
- }
- /**
- * 对标管理详情页面
- * @param id
- * @param beginDate
- * @param endDate
- * @return
- */
- public List<WxsslVo> details(String id, String beginDate, String endDate, String target,String sort) {
- List<WxsslVo> resultList = new ArrayList<>();
- QueryWrapper<Equipmentdayinfo> qw = new QueryWrapper<>();
- qw.select("windturbineid,sum(genecapacity) genecapacity,sum(therogenecapacity) therogenecapacity,sum(daynhwhssdl) daynhwhssdl,sum(daynhgzssdl) daynhgzssdl,sum(daynhxdssdl) daynhxdssdl,sum(daynhqfdl) daynhqfdl,sum(daynhcfdl) daynhcfdl");
- qw.ge("recorddate",DateUtils.parseDate(beginDate)).le("recorddate",DateUtils.parseDate(endDate));
- if (id.endsWith("FDC")){
- qw.eq("windpowerstationid",id);
- }else if(id.endsWith("GC")){
- qw.eq("projectid",id);
- }else if(id.endsWith("XL")){
- qw.eq("lineid",id);
- }
- qw.groupBy("windturbineid");
- List<WxsslVo> wxsslVoList = getWxsslSortVos(qw,resultList,TYPE_WINDTURBINE);
- if (StringUtils.isNotEmpty(target) && StringUtils.isNotEmpty(sort)){
- if (sort.equals("1")){
- SortUtils.sort(resultList,target,SortUtils.ASC);
- }else {
- SortUtils.sort(resultList,target,SortUtils.DESC);
- }
- }else {
- SortUtils.sort(resultList,"fdl",SortUtils.ASC);
- }
- return wxsslVoList;
- }
- /**
- * 日单机横向对比列表
- * @param wpid
- * @param wtids
- * @param date
- * @return
- */
- public List<Object> daydjhxdbtop(String wpid, String wtids, String date) {
- List<DjhxdbtopVo> resultList = new ArrayList<>();
- QueryWrapper<Windturbineanalysisday> qw = new QueryWrapper<>();
- Date recorddate = DateUtils.parseDate(date);
- if (StringUtils.isNotEmpty(wpid) && StringUtils.isNotEmpty(wtids)){
- String[] wtidArray = wtids.split(",");
- List<String> wtidList = Arrays.asList(wtidArray);
- qw.in("windturbineid",wtidList);
- }else {
- qw.eq("windturbineid","MG01_01");
- }
- qw.eq("recorddate",recorddate);
- List<Windturbineanalysisday> windturbineanalysisdayList = windturbineanalysisdayService.list(qw);
- windturbineanalysisdayList.stream().forEach(i->{
- DjhxdbtopVo vo = new DjhxdbtopVo();
- vo.setWtid(i.getWindturbineid());
- vo.setFdl(i.getC1());
- vo.setYfdl(i.getC4());
- vo.setPjgl(i.getC7());
- vo.setPjfs(i.getC10());
- vo.setYxxs(i.getC13());
- vo.setDjxs(i.getC16());
- vo.setGzxs(i.getC19());
- vo.setWhxs(i.getC22());
- vo.setZdxs(i.getC25());
- vo.setYxfs(i.getC28());
- vo.setSsdl(i.getC31());
- vo.setBjcs(i.getC34());
- vo.setTjcs(i.getC37());
- vo.setBbhcs(i.getC40());
- vo.setSbklly(i.getC43());
- vo.setPjwd(i.getC46());
- vo.setPjsd(i.getC49());
- vo.setPjyq(i.getC52());
- vo.setNhyd(i.getC55());
- vo.setSjbz(i.getC58());
- resultList.add(vo);
- });
- List<Windturbinethewindinfo> fzyList = getFzy(wtids, date);
- resultList.stream().forEach(i->{
- String wtid = i.getWtid();
- if (fzyList!=null && fzyList.size()>0){
- Optional<Windturbinethewindinfo> first = fzyList.stream().filter(fzy -> fzy.getWindturbineid().equals(wtid)).findFirst();
- Windturbinethewindinfo winfo = null;
- if (first.isPresent()){
- winfo = first.get();
- }
- List<FzyVo> vos = new ArrayList<>();
- for (int j = 0; j < 16; j++) {
- FzyVo vo = new FzyVo();
- switch (j) {
- case 0:
- // vo.setName("N("+winfo.getN4()+"/"+winfo.getN()+")");
- vo.setName("N");
- vo.setValue(winfo.getN4());
- break;
- case 1:
- // vo.setName("NNE("+winfo.getNne4()+"/"+winfo.getNne()+")");
- vo.setName("NNE");
- vo.setValue(winfo.getNne4());
- break;
- case 2:
- // vo.setName("NE("+winfo.getNe4()+"/"+winfo.getNe()+")");
- vo.setName("NE");
- vo.setValue(winfo.getNe4());
- break;
- case 3:
- // vo.setName("ENE("+winfo.getEne4()+"/"+winfo.getEne()+")");
- vo.setName("ENE");
- vo.setValue(winfo.getEne4());
- break;
- case 4:
- // vo.setName("E("+winfo.getE4()+"/"+winfo.getE()+")");
- vo.setName("E");
- vo.setValue(winfo.getE4());
- break;
- case 5:
- // vo.setName("ESE("+winfo.getEse()+"/"+winfo.getEse()+")");
- vo.setName("ESE");
- vo.setValue(winfo.getEse4());
- break;
- case 6:
- // vo.setName("SE("+winfo.getSe4()+"/"+winfo.getSe()+")");
- vo.setName("SE");
- vo.setValue(winfo.getSe4());
- break;
- case 7:
- // vo.setName("SSE("+winfo.getSse4()+"/"+winfo.getSse()+")");
- vo.setName("SSE");
- vo.setValue(winfo.getSse4());
- break;
- case 8:
- // vo.setName("S("+winfo.getS4()+"/"+winfo.getS()+")");
- vo.setName("S");
- vo.setValue(winfo.getS4());
- break;
- case 9:
- // vo.setName("SSW("+winfo.getSsw4()+"/"+winfo.getSsw()+")");
- vo.setName("SSW");
- vo.setValue(winfo.getSsw4());
- break;
- case 10:
- // vo.setName("SW("+winfo.getSw4()+"/"+winfo.getSw()+")");
- vo.setName("SW");
- vo.setValue(winfo.getSw4());
- break;
- case 11:
- // vo.setName("WSW("+winfo.getWsw4()+"/"+winfo.getWsw()+")");
- vo.setName("WSW");
- vo.setValue(winfo.getWsw4());
- break;
- case 12:
- // vo.setName("W("+winfo.getW4()+"/"+winfo.getW()+")");
- vo.setName("W");
- vo.setValue(winfo.getW4());
- break;
- case 13:
- // vo.setName("WNW("+winfo.getWnw4()+"/"+winfo.getWnw()+")");
- vo.setName("WNW");
- vo.setValue(winfo.getWnw4());
- break;
- case 14:
- // vo.setName("NW("+winfo.getNw4()+"/"+winfo.getNw()+")");
- vo.setName("NW");
- vo.setValue(winfo.getNw4());
- break;
- case 15:
- // vo.setName("NNW("+winfo.getNnw4()+"/"+winfo.getNnw()+")");
- vo.setName("NNW");
- vo.setValue(winfo.getNnw4());
- break;
- default:
- break;
- }
- vos.add(vo);
- }
- i.setFzyList(vos);
- i.setJfpl(winfo.getCb());
- }
- });
- List<Object> list = convert(resultList);
- return list;
- }
- /**
- * 月单机横向对比列表
- * @param wpid
- * @param wtids
- * @param date
- * @return
- */
- public List<Object> monthdjhxdbtop(String wpid, String wtids, String date) {
- List<DjhxdbtopVo> resultList = new ArrayList<>();
- QueryWrapper<Windturbineanalysisday> qw = new QueryWrapper<>();
- Date recorddate = DateUtils.parseDate(date);
- if (StringUtils.isNotEmpty(wpid) && StringUtils.isNotEmpty(wtids)){
- String[] wtidArray = wtids.split(",");
- List<String> wtidList = Arrays.asList(wtidArray);
- qw.in("windturbineid",wtidList);
- }else {
- qw.eq("windturbineid","MG01_01");
- }
- qw.eq("recorddate",recorddate);
- List<Windturbineanalysisday> windturbineanalysisdayList = windturbineanalysisdayService.list(qw);
- windturbineanalysisdayList.stream().forEach(i->{
- DjhxdbtopVo vo = new DjhxdbtopVo();
- vo.setWtid(i.getWindturbineid());
- vo.setFdl(i.getC2());
- vo.setYfdl(i.getC5());
- vo.setPjgl(i.getC8());
- vo.setPjfs(i.getC11());
- vo.setYxxs(i.getC14());
- vo.setDjxs(i.getC17());
- vo.setGzxs(i.getC20());
- vo.setWhxs(i.getC23());
- vo.setZdxs(i.getC26());
- vo.setYxfs(i.getC29());
- vo.setSsdl(i.getC32());
- vo.setBjcs(i.getC35());
- vo.setTjcs(i.getC38());
- vo.setBbhcs(i.getC41());
- vo.setSbklly(i.getC44());
- vo.setPjwd(i.getC47());
- vo.setPjsd(i.getC50());
- vo.setPjyq(i.getC53());
- vo.setNhyd(i.getC56());
- vo.setSjbz(i.getC59());
- resultList.add(vo);
- });
- List<Windturbinethewindinfo> fzyList = getFzy(wtids, date);
- resultList.stream().forEach(i->{
- String wtid = i.getWtid();
- Optional<Windturbinethewindinfo> first = fzyList.stream().filter(fzy -> fzy.getWindturbineid().equals(wtid)).findFirst();
- Windturbinethewindinfo winfo = null;
- if (first.isPresent()){
- winfo = first.get();
- }
- List<FzyVo> vos = new ArrayList<>();
- for (int j = 0; j < 16; j++) {
- FzyVo vo = new FzyVo();
- switch (j) {
- case 0:
- // vo.setName("N("+winfo.getN4()+"/"+winfo.getN()+")");
- vo.setName("N");
- vo.setValue(winfo.getN10());
- break;
- case 1:
- // vo.setName("NNE("+winfo.getNne4()+"/"+winfo.getNne()+")");
- vo.setName("NNE");
- vo.setValue(winfo.getNne10());
- break;
- case 2:
- // vo.setName("NE("+winfo.getNe4()+"/"+winfo.getNe()+")");
- vo.setName("NE");
- vo.setValue(winfo.getNe10());
- break;
- case 3:
- // vo.setName("ENE("+winfo.getEne4()+"/"+winfo.getEne()+")");
- vo.setName("ENE");
- vo.setValue(winfo.getEne10());
- break;
- case 4:
- // vo.setName("E("+winfo.getE4()+"/"+winfo.getE()+")");
- vo.setName("E");
- vo.setValue(winfo.getE10());
- break;
- case 5:
- // vo.setName("ESE("+winfo.getEse()+"/"+winfo.getEse()+")");
- vo.setName("ESE");
- vo.setValue(winfo.getEse10());
- break;
- case 6:
- // vo.setName("SE("+winfo.getSe4()+"/"+winfo.getSe()+")");
- vo.setName("SE");
- vo.setValue(winfo.getSe10());
- break;
- case 7:
- // vo.setName("SSE("+winfo.getSse4()+"/"+winfo.getSse()+")");
- vo.setName("SSE");
- vo.setValue(winfo.getSse10());
- break;
- case 8:
- // vo.setName("S("+winfo.getS4()+"/"+winfo.getS()+")");
- vo.setName("S");
- vo.setValue(winfo.getS10());
- break;
- case 9:
- // vo.setName("SSW("+winfo.getSsw4()+"/"+winfo.getSsw()+")");
- vo.setName("SSW");
- vo.setValue(winfo.getSsw10());
- break;
- case 10:
- // vo.setName("SW("+winfo.getSw4()+"/"+winfo.getSw()+")");
- vo.setName("SW");
- vo.setValue(winfo.getSw10());
- break;
- case 11:
- // vo.setName("WSW("+winfo.getWsw4()+"/"+winfo.getWsw()+")");
- vo.setName("WSW");
- vo.setValue(winfo.getWsw10());
- break;
- case 12:
- // vo.setName("W("+winfo.getW4()+"/"+winfo.getW()+")");
- vo.setName("W");
- vo.setValue(winfo.getW10());
- break;
- case 13:
- // vo.setName("WNW("+winfo.getWnw4()+"/"+winfo.getWnw()+")");
- vo.setName("WNW");
- vo.setValue(winfo.getWnw10());
- break;
- case 14:
- // vo.setName("NW("+winfo.getNw4()+"/"+winfo.getNw()+")");
- vo.setName("NW");
- vo.setValue(winfo.getNw10());
- break;
- case 15:
- // vo.setName("NNW("+winfo.getNnw4()+"/"+winfo.getNnw()+")");
- vo.setName("NNW");
- vo.setValue(winfo.getNnw10());
- break;
- default:
- break;
- }
- vos.add(vo);
- }
- i.setFzyList(vos);
- i.setJfpl(winfo.getCb());
- });
- List<Object> list = convert(resultList);
- return list;
- }
- /**
- * 年单机横向对比列表
- * @param wpid
- * @param wtids
- * @param date
- * @return
- */
- public List<Object> yeardjhxdbtop(String wpid, String wtids, String date) {
- List<DjhxdbtopVo> resultList = new ArrayList<>();
- QueryWrapper<Windturbineanalysisday> qw = new QueryWrapper<>();
- Date recorddate = DateUtils.parseDate(date);
- if (StringUtils.isNotEmpty(wpid) && StringUtils.isNotEmpty(wtids)){
- String[] wtidArray = wtids.split(",");
- List<String> wtidList = Arrays.asList(wtidArray);
- qw.in("windturbineid",wtidList);
- }else {
- qw.eq("windturbineid","MG01_01");
- }
- qw.eq("recorddate",recorddate);
- List<Windturbineanalysisday> windturbineanalysisdayList = windturbineanalysisdayService.list(qw);
- windturbineanalysisdayList.stream().forEach(i->{
- DjhxdbtopVo vo = new DjhxdbtopVo();
- vo.setWtid(i.getWindturbineid());
- vo.setFdl(i.getC3());
- vo.setYfdl(i.getC6());
- vo.setPjgl(i.getC9());
- vo.setPjfs(i.getC12());
- vo.setYxxs(i.getC15());
- vo.setDjxs(i.getC18());
- vo.setGzxs(i.getC21());
- vo.setWhxs(i.getC24());
- vo.setZdxs(i.getC27());
- vo.setYxfs(i.getC30());
- vo.setSsdl(i.getC33());
- vo.setBjcs(i.getC36());
- vo.setTjcs(i.getC39());
- vo.setBbhcs(i.getC42());
- vo.setSbklly(i.getC45());
- vo.setPjwd(i.getC48());
- vo.setPjsd(i.getC51());
- vo.setPjyq(i.getC54());
- vo.setNhyd(i.getC57());
- vo.setSjbz(i.getC60());
- resultList.add(vo);
- });
- List<Windturbinethewindinfo> fzyList = getFzy(wtids, date);
- resultList.stream().forEach(i->{
- String wtid = i.getWtid();
- Optional<Windturbinethewindinfo> first = fzyList.stream().filter(fzy -> fzy.getWindturbineid().equals(wtid)).findFirst();
- Windturbinethewindinfo winfo = null;
- if (first.isPresent()){
- winfo = first.get();
- }
- List<FzyVo> vos = new ArrayList<>();
- for (int j = 0; j < 16; j++) {
- FzyVo vo = new FzyVo();
- switch (j) {
- case 0:
- // vo.setName("N("+winfo.getN4()+"/"+winfo.getN()+")");
- vo.setName("N");
- vo.setValue(winfo.getN16());
- break;
- case 1:
- // vo.setName("NNE("+winfo.getNne4()+"/"+winfo.getNne()+")");
- vo.setName("NNE");
- vo.setValue(winfo.getNne16());
- break;
- case 2:
- // vo.setName("NE("+winfo.getNe4()+"/"+winfo.getNe()+")");
- vo.setName("NE");
- vo.setValue(winfo.getNe16());
- break;
- case 3:
- // vo.setName("ENE("+winfo.getEne4()+"/"+winfo.getEne()+")");
- vo.setName("ENE");
- vo.setValue(winfo.getEne16());
- break;
- case 4:
- // vo.setName("E("+winfo.getE4()+"/"+winfo.getE()+")");
- vo.setName("E");
- vo.setValue(winfo.getE16());
- break;
- case 5:
- // vo.setName("ESE("+winfo.getEse()+"/"+winfo.getEse()+")");
- vo.setName("ESE");
- vo.setValue(winfo.getEse16());
- break;
- case 6:
- // vo.setName("SE("+winfo.getSe4()+"/"+winfo.getSe()+")");
- vo.setName("SE");
- vo.setValue(winfo.getSe16());
- break;
- case 7:
- // vo.setName("SSE("+winfo.getSse4()+"/"+winfo.getSse()+")");
- vo.setName("SSE");
- vo.setValue(winfo.getSse16());
- break;
- case 8:
- // vo.setName("S("+winfo.getS4()+"/"+winfo.getS()+")");
- vo.setName("S");
- vo.setValue(winfo.getS16());
- break;
- case 9:
- // vo.setName("SSW("+winfo.getSsw4()+"/"+winfo.getSsw()+")");
- vo.setName("SSW");
- vo.setValue(winfo.getSsw16());
- break;
- case 10:
- // vo.setName("SW("+winfo.getSw4()+"/"+winfo.getSw()+")");
- vo.setName("SW");
- vo.setValue(winfo.getSw16());
- break;
- case 11:
- // vo.setName("WSW("+winfo.getWsw4()+"/"+winfo.getWsw()+")");
- vo.setName("WSW");
- vo.setValue(winfo.getWsw16());
- break;
- case 12:
- // vo.setName("W("+winfo.getW4()+"/"+winfo.getW()+")");
- vo.setName("W");
- vo.setValue(winfo.getW16());
- break;
- case 13:
- // vo.setName("WNW("+winfo.getWnw4()+"/"+winfo.getWnw()+")");
- vo.setName("WNW");
- vo.setValue(winfo.getWnw16());
- break;
- case 14:
- // vo.setName("NW("+winfo.getNw4()+"/"+winfo.getNw()+")");
- vo.setName("NW");
- vo.setValue(winfo.getNw16());
- break;
- case 15:
- // vo.setName("NNW("+winfo.getNnw4()+"/"+winfo.getNnw()+")");
- vo.setName("NNW");
- vo.setValue(winfo.getNnw16());
- break;
- default:
- break;
- }
- vos.add(vo);
- }
- i.setFzyList(vos);
- i.setJfpl(winfo.getCb());
- });
- List<Object> list = convert(resultList);
- return list;
- }
- /**
- * 单机横向对比列表行转列
- * @param resultList
- * @return
- */
- private List<Object> convert(List<DjhxdbtopVo> resultList) {
- List<Object> rList = new ArrayList<>();
- List<String> wtids = resultList.stream().map(i -> i.getWtid()).collect(Collectors.toList());
- DjhxdbInitVo fdj = new DjhxdbInitVo();
- fdj.setName("风电机");
- try {
- LinkedHashMap addMap = new LinkedHashMap();
- LinkedHashMap addValMap = new LinkedHashMap();
- for (int j=0;j<wtids.size();j++){
- addMap.put(String.valueOf(j+1), Class.forName("java.lang.String"));
- addValMap.put(String.valueOf(j+1), wtids.get(j));
- }
- Object blo = new ClassUtil().dynamicClass(fdj, addMap, addValMap);
- rList.add(blo);
- System.out.println(JSON.toJSONString(blo));
- } catch (Exception e) {
- e.printStackTrace();
- }
- DjhxdbInitVo fdl = new DjhxdbInitVo();
- fdl.setName("发电量");
- try {
- LinkedHashMap addMap = new LinkedHashMap();
- LinkedHashMap addValMap = new LinkedHashMap();
- for (int j=0;j<wtids.size();j++){
- addMap.put(String.valueOf(j+1), Class.forName("java.lang.Double"));
- int finalJ = j;
- addValMap.put(String.valueOf(j+1), resultList.stream().filter(i->i.getWtid().equals(wtids.get(finalJ))).findFirst().get().getFdl());
- }
- Object blo = new ClassUtil().dynamicClass(fdl, addMap, addValMap);
- rList.add(blo);
- System.out.println(JSON.toJSONString(blo));
- } catch (Exception e) {
- e.printStackTrace();
- }
- DjhxdbInitVo yfdl = new DjhxdbInitVo();
- yfdl.setName("应发电量");
- try {
- LinkedHashMap addMap = new LinkedHashMap();
- LinkedHashMap addValMap = new LinkedHashMap();
- for (int j=0;j<wtids.size();j++){
- addMap.put(String.valueOf(j+1), Class.forName("java.lang.Double"));
- int finalJ = j;
- addValMap.put(String.valueOf(j+1), resultList.stream().filter(i->i.getWtid().equals(wtids.get(finalJ))).findFirst().get().getYfdl());
- }
- Object blo = new ClassUtil().dynamicClass(yfdl, addMap, addValMap);
- rList.add(blo);
- System.out.println(JSON.toJSONString(blo));
- } catch (Exception e) {
- e.printStackTrace();
- }
- DjhxdbInitVo pjgl = new DjhxdbInitVo();
- pjgl.setName("平均功率");
- try {
- LinkedHashMap addMap = new LinkedHashMap();
- LinkedHashMap addValMap = new LinkedHashMap();
- for (int j=0;j<wtids.size();j++){
- addMap.put(String.valueOf(j+1), Class.forName("java.lang.Double"));
- int finalJ = j;
- addValMap.put(String.valueOf(j+1), resultList.stream().filter(i->i.getWtid().equals(wtids.get(finalJ))).findFirst().get().getPjgl());
- }
- Object blo = new ClassUtil().dynamicClass(pjgl, addMap, addValMap);
- rList.add(blo);
- System.out.println(JSON.toJSONString(blo));
- } catch (Exception e) {
- e.printStackTrace();
- }
- DjhxdbInitVo pjfs = new DjhxdbInitVo();
- pjfs.setName("平均风速");
- try {
- LinkedHashMap addMap = new LinkedHashMap();
- LinkedHashMap addValMap = new LinkedHashMap();
- for (int j=0;j<wtids.size();j++){
- addMap.put(String.valueOf(j+1), Class.forName("java.lang.Double"));
- int finalJ = j;
- addValMap.put(String.valueOf(j+1), resultList.stream().filter(i->i.getWtid().equals(wtids.get(finalJ))).findFirst().get().getPjfs());
- }
- Object blo = new ClassUtil().dynamicClass(pjfs, addMap, addValMap);
- rList.add(blo);
- System.out.println(JSON.toJSONString(blo));
- } catch (Exception e) {
- e.printStackTrace();
- }
- DjhxdbInitVo yxxs = new DjhxdbInitVo();
- yxxs.setName("运行小时");
- try {
- LinkedHashMap addMap = new LinkedHashMap();
- LinkedHashMap addValMap = new LinkedHashMap();
- for (int j=0;j<wtids.size();j++){
- addMap.put(String.valueOf(j+1), Class.forName("java.lang.Double"));
- int finalJ = j;
- addValMap.put(String.valueOf(j+1), resultList.stream().filter(i->i.getWtid().equals(wtids.get(finalJ))).findFirst().get().getYxxs());
- }
- Object blo = new ClassUtil().dynamicClass(yxxs, addMap, addValMap);
- rList.add(blo);
- System.out.println(JSON.toJSONString(blo));
- } catch (Exception e) {
- e.printStackTrace();
- }
- DjhxdbInitVo djxs = new DjhxdbInitVo();
- djxs.setName("待机小时");
- try {
- LinkedHashMap addMap = new LinkedHashMap();
- LinkedHashMap addValMap = new LinkedHashMap();
- for (int j=0;j<wtids.size();j++){
- addMap.put(String.valueOf(j+1), Class.forName("java.lang.Double"));
- int finalJ = j;
- addValMap.put(String.valueOf(j+1), resultList.stream().filter(i->i.getWtid().equals(wtids.get(finalJ))).findFirst().get().getDjxs());
- }
- Object blo = new ClassUtil().dynamicClass(djxs, addMap, addValMap);
- rList.add(blo);
- System.out.println(JSON.toJSONString(blo));
- } catch (Exception e) {
- e.printStackTrace();
- }
- DjhxdbInitVo gzxs = new DjhxdbInitVo();
- gzxs.setName("故障小时");
- try {
- LinkedHashMap addMap = new LinkedHashMap();
- LinkedHashMap addValMap = new LinkedHashMap();
- for (int j=0;j<wtids.size();j++){
- addMap.put(String.valueOf(j+1), Class.forName("java.lang.Double"));
- int finalJ = j;
- addValMap.put(String.valueOf(j+1), resultList.stream().filter(i->i.getWtid().equals(wtids.get(finalJ))).findFirst().get().getGzxs());
- }
- Object blo = new ClassUtil().dynamicClass(gzxs, addMap, addValMap);
- rList.add(blo);
- System.out.println(JSON.toJSONString(blo));
- } catch (Exception e) {
- e.printStackTrace();
- }
- DjhxdbInitVo whxs = new DjhxdbInitVo();
- whxs.setName("维护小时");
- try {
- LinkedHashMap addMap = new LinkedHashMap();
- LinkedHashMap addValMap = new LinkedHashMap();
- for (int j=0;j<wtids.size();j++){
- addMap.put(String.valueOf(j+1), Class.forName("java.lang.Double"));
- int finalJ = j;
- addValMap.put(String.valueOf(j+1), resultList.stream().filter(i->i.getWtid().equals(wtids.get(finalJ))).findFirst().get().getWhxs());
- }
- Object blo = new ClassUtil().dynamicClass(whxs, addMap, addValMap);
- rList.add(blo);
- System.out.println(JSON.toJSONString(blo));
- } catch (Exception e) {
- e.printStackTrace();
- }
- DjhxdbInitVo zdxs = new DjhxdbInitVo();
- zdxs.setName("中断小时");
- try {
- LinkedHashMap addMap = new LinkedHashMap();
- LinkedHashMap addValMap = new LinkedHashMap();
- for (int j=0;j<wtids.size();j++){
- addMap.put(String.valueOf(j+1), Class.forName("java.lang.Double"));
- int finalJ = j;
- addValMap.put(String.valueOf(j+1), resultList.stream().filter(i->i.getWtid().equals(wtids.get(finalJ))).findFirst().get().getZdxs());
- }
- Object blo = new ClassUtil().dynamicClass(zdxs, addMap, addValMap);
- rList.add(blo);
- System.out.println(JSON.toJSONString(blo));
- } catch (Exception e) {
- e.printStackTrace();
- }
- DjhxdbInitVo yxfs = new DjhxdbInitVo();
- yxfs.setName("有效风时");
- try {
- LinkedHashMap addMap = new LinkedHashMap();
- LinkedHashMap addValMap = new LinkedHashMap();
- for (int j=0;j<wtids.size();j++){
- addMap.put(String.valueOf(j+1), Class.forName("java.lang.Double"));
- int finalJ = j;
- addValMap.put(String.valueOf(j+1), resultList.stream().filter(i->i.getWtid().equals(wtids.get(finalJ))).findFirst().get().getYxfs());
- }
- Object blo = new ClassUtil().dynamicClass(yxfs, addMap, addValMap);
- rList.add(blo);
- System.out.println(JSON.toJSONString(blo));
- } catch (Exception e) {
- e.printStackTrace();
- }
- DjhxdbInitVo ssdl = new DjhxdbInitVo();
- ssdl.setName("损失电量");
- try {
- LinkedHashMap addMap = new LinkedHashMap();
- LinkedHashMap addValMap = new LinkedHashMap();
- for (int j=0;j<wtids.size();j++){
- addMap.put(String.valueOf(j+1), Class.forName("java.lang.Double"));
- int finalJ = j;
- addValMap.put(String.valueOf(j+1), resultList.stream().filter(i->i.getWtid().equals(wtids.get(finalJ))).findFirst().get().getSsdl());
- }
- Object blo = new ClassUtil().dynamicClass(ssdl, addMap, addValMap);
- rList.add(blo);
- System.out.println(JSON.toJSONString(blo));
- } catch (Exception e) {
- e.printStackTrace();
- }
- DjhxdbInitVo bjcs = new DjhxdbInitVo();
- bjcs.setName("报警次数");
- try {
- LinkedHashMap addMap = new LinkedHashMap();
- LinkedHashMap addValMap = new LinkedHashMap();
- for (int j=0;j<wtids.size();j++){
- addMap.put(String.valueOf(j+1), Class.forName("java.lang.Double"));
- int finalJ = j;
- addValMap.put(String.valueOf(j+1), resultList.stream().filter(i->i.getWtid().equals(wtids.get(finalJ))).findFirst().get().getBjcs());
- }
- Object blo = new ClassUtil().dynamicClass(bjcs, addMap, addValMap);
- rList.add(blo);
- System.out.println(JSON.toJSONString(blo));
- } catch (Exception e) {
- e.printStackTrace();
- }
- DjhxdbInitVo tjcs = new DjhxdbInitVo();
- tjcs.setName("停机次数");
- try {
- LinkedHashMap addMap = new LinkedHashMap();
- LinkedHashMap addValMap = new LinkedHashMap();
- for (int j=0;j<wtids.size();j++){
- addMap.put(String.valueOf(j+1), Class.forName("java.lang.Double"));
- int finalJ = j;
- addValMap.put(String.valueOf(j+1), resultList.stream().filter(i->i.getWtid().equals(wtids.get(finalJ))).findFirst().get().getTjcs());
- }
- Object blo = new ClassUtil().dynamicClass(tjcs, addMap, addValMap);
- rList.add(blo);
- System.out.println(JSON.toJSONString(blo));
- } catch (Exception e) {
- e.printStackTrace();
- }
- DjhxdbInitVo bbhcs = new DjhxdbInitVo();
- bbhcs.setName("不饱和次数");
- try {
- LinkedHashMap addMap = new LinkedHashMap();
- LinkedHashMap addValMap = new LinkedHashMap();
- for (int j=0;j<wtids.size();j++){
- addMap.put(String.valueOf(j+1), Class.forName("java.lang.Double"));
- int finalJ = j;
- addValMap.put(String.valueOf(j+1), resultList.stream().filter(i->i.getWtid().equals(wtids.get(finalJ))).findFirst().get().getBbhcs());
- }
- Object blo = new ClassUtil().dynamicClass(bbhcs, addMap, addValMap);
- rList.add(blo);
- System.out.println(JSON.toJSONString(blo));
- } catch (Exception e) {
- e.printStackTrace();
- }
- DjhxdbInitVo sbklly = new DjhxdbInitVo();
- sbklly.setName("设备可利用率");
- try {
- LinkedHashMap addMap = new LinkedHashMap();
- LinkedHashMap addValMap = new LinkedHashMap();
- for (int j=0;j<wtids.size();j++){
- addMap.put(String.valueOf(j+1), Class.forName("java.lang.Double"));
- int finalJ = j;
- addValMap.put(String.valueOf(j+1), resultList.stream().filter(i->i.getWtid().equals(wtids.get(finalJ))).findFirst().get().getSbklly());
- }
- Object blo = new ClassUtil().dynamicClass(sbklly, addMap, addValMap);
- rList.add(blo);
- System.out.println(JSON.toJSONString(blo));
- } catch (Exception e) {
- e.printStackTrace();
- }
- DjhxdbInitVo pjwd = new DjhxdbInitVo();
- pjwd.setName("平均温度");
- try {
- LinkedHashMap addMap = new LinkedHashMap();
- LinkedHashMap addValMap = new LinkedHashMap();
- for (int j=0;j<wtids.size();j++){
- addMap.put(String.valueOf(j+1), Class.forName("java.lang.Double"));
- int finalJ = j;
- addValMap.put(String.valueOf(j+1), resultList.stream().filter(i->i.getWtid().equals(wtids.get(finalJ))).findFirst().get().getPjwd());
- }
- Object blo = new ClassUtil().dynamicClass(pjwd, addMap, addValMap);
- rList.add(blo);
- System.out.println(JSON.toJSONString(blo));
- } catch (Exception e) {
- e.printStackTrace();
- }
- DjhxdbInitVo pjsd = new DjhxdbInitVo();
- pjsd.setName("平均湿度");
- try {
- LinkedHashMap addMap = new LinkedHashMap();
- LinkedHashMap addValMap = new LinkedHashMap();
- for (int j=0;j<wtids.size();j++){
- addMap.put(String.valueOf(j+1), Class.forName("java.lang.Double"));
- int finalJ = j;
- addValMap.put(String.valueOf(j+1), resultList.stream().filter(i->i.getWtid().equals(wtids.get(finalJ))).findFirst().get().getPjsd());
- }
- Object blo = new ClassUtil().dynamicClass(pjsd, addMap, addValMap);
- rList.add(blo);
- System.out.println(JSON.toJSONString(blo));
- } catch (Exception e) {
- e.printStackTrace();
- }
- DjhxdbInitVo pjyq = new DjhxdbInitVo();
- pjyq.setName("平均压强");
- try {
- LinkedHashMap addMap = new LinkedHashMap();
- LinkedHashMap addValMap = new LinkedHashMap();
- for (int j=0;j<wtids.size();j++){
- addMap.put(String.valueOf(j+1), Class.forName("java.lang.Double"));
- int finalJ = j;
- addValMap.put(String.valueOf(j+1), resultList.stream().filter(i->i.getWtid().equals(wtids.get(finalJ))).findFirst().get().getPjyq());
- }
- Object blo = new ClassUtil().dynamicClass(pjyq, addMap, addValMap);
- rList.add(blo);
- System.out.println(JSON.toJSONString(blo));
- } catch (Exception e) {
- e.printStackTrace();
- }
- DjhxdbInitVo nhyd = new DjhxdbInitVo();
- nhyd.setName("拟合优度");
- try {
- LinkedHashMap addMap = new LinkedHashMap();
- LinkedHashMap addValMap = new LinkedHashMap();
- for (int j=0;j<wtids.size();j++){
- addMap.put(String.valueOf(j+1), Class.forName("java.lang.Double"));
- int finalJ = j;
- addValMap.put(String.valueOf(j+1), resultList.stream().filter(i->i.getWtid().equals(wtids.get(finalJ))).findFirst().get().getNhyd());
- }
- Object blo = new ClassUtil().dynamicClass(nhyd, addMap, addValMap);
- rList.add(blo);
- System.out.println(JSON.toJSONString(blo));
- } catch (Exception e) {
- e.printStackTrace();
- }
- DjhxdbInitVo sjbz = new DjhxdbInitVo();
- sjbz.setName("实际/保证");
- try {
- LinkedHashMap addMap = new LinkedHashMap();
- LinkedHashMap addValMap = new LinkedHashMap();
- for (int j=0;j<wtids.size();j++){
- addMap.put(String.valueOf(j+1), Class.forName("java.lang.Double"));
- int finalJ = j;
- addValMap.put(String.valueOf(j+1), resultList.stream().filter(i->i.getWtid().equals(wtids.get(finalJ))).findFirst().get().getSjbz());
- }
- Object blo = new ClassUtil().dynamicClass(sjbz, addMap, addValMap);
- rList.add(blo);
- System.out.println(JSON.toJSONString(blo));
- } catch (Exception e) {
- e.printStackTrace();
- }
- DjhxdbInitVo fzy = new DjhxdbInitVo();
- fzy.setName("风资源");
- try {
- LinkedHashMap addMap = new LinkedHashMap();
- LinkedHashMap addValMap = new LinkedHashMap();
- for (int j=0;j<wtids.size();j++){
- addMap.put(String.valueOf(j+1), Class.forName("java.util.List"));
- int finalJ = j;
- addValMap.put(String.valueOf(j+1), resultList.stream().filter(i->i.getWtid().equals(wtids.get(finalJ))).findFirst().get().getFzyList());
- }
- Object blo = new ClassUtil().dynamicClass(fzy, addMap, addValMap);
- rList.add(blo);
- System.out.println(JSON.toJSONString(blo));
- } catch (Exception e) {
- e.printStackTrace();
- }
- DjhxdbInitVo jfpl = new DjhxdbInitVo();
- jfpl.setName("静风频率");
- try {
- LinkedHashMap addMap = new LinkedHashMap();
- LinkedHashMap addValMap = new LinkedHashMap();
- for (int j=0;j<wtids.size();j++){
- addMap.put(String.valueOf(j+1), Class.forName("java.lang.Double"));
- int finalJ = j;
- addValMap.put(String.valueOf(j+1), resultList.stream().filter(i->i.getWtid().equals(wtids.get(finalJ))).findFirst().get().getJfpl());
- }
- Object blo = new ClassUtil().dynamicClass(jfpl, addMap, addValMap);
- rList.add(blo);
- System.out.println(JSON.toJSONString(blo));
- } catch (Exception e) {
- e.printStackTrace();
- }
- return rList;
- }
- /**
- * 获取风资源和静风频率
- * @param wtids
- * @param date
- */
- private List<Windturbinethewindinfo> getFzy(String wtids, String date) {
- QueryWrapper<Windturbinethewindinfo> qw = new QueryWrapper<>();
- Date recorddate = DateUtils.parseDate(date);
- if (StringUtils.isNotEmpty(wtids)){
- String[] wtidArray = wtids.split(",");
- List<String> wtidList = Arrays.asList(wtidArray);
- qw.in("windturbineid",wtidList);
- }else {
- qw.eq("windturbineid","MG01_01");
- }
- qw.eq("recorddate",recorddate);
- List<Windturbinethewindinfo> fzyList = windturbinethewindinfoService.list(qw);
- return fzyList;
- }
- /**
- * 日单机横向对比图
- * @param wpid
- * @param wtids
- * @param date
- * @return
- */
- public List<Object> djhxdbbottom(String wpid, String wtids, String date) {
- List<DjhxdbtopVo> resultList = new ArrayList<>();
- QueryWrapper<Windturbinecurvefitting> qw = new QueryWrapper<>();
- Date recorddate = DateUtils.parseDate(date);
- if (StringUtils.isNotEmpty(wpid) && StringUtils.isNotEmpty(wtids)){
- String[] wtidArray = wtids.split(",");
- List<String> wtidList = Arrays.asList(wtidArray);
- qw.in("windturbineid",wtidList);
- }else {
- qw.eq("windturbineid","MG01_01");
- }
- qw.eq("recorddate",recorddate);
- List<Windturbinecurvefitting> windturbinecurvefittingList = windturbinecurvefittingService.list(qw);
- List<String> wtidList = windturbinecurvefittingList.stream().map(i -> i.getWindturbineid()).distinct().collect(Collectors.toList());
- List<Object> rList = new ArrayList<>();
- for (String wtid : wtidList) {
- List<Windturbinecurvefitting> windturbinecurvefittings = windturbinecurvefittingList.stream().filter(i -> i.getWindturbineid().equals(wtid)).collect(Collectors.toList());
- DjhxdbInitVo vo = new DjhxdbInitVo();
- vo.setName(wtid);
- try {
- LinkedHashMap addMap = new LinkedHashMap();
- LinkedHashMap addValMap = new LinkedHashMap();
- for (Windturbinecurvefitting curve : windturbinecurvefittings) {
- addMap.put(String.valueOf(curve.getSpeed()), Class.forName("java.lang.Double"));
- addValMap.put(String.valueOf(curve.getSpeed()), curve.getActualpower());
- }
- Object blo = new ClassUtil().dynamicClass(vo, addMap, addValMap);
- rList.add(blo);
- System.out.println(JSON.toJSONString(blo));
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- return rList;
- }
- /**
- * 保存对标管理首页大表
- * @param beginDate
- * @param endDate
- */
- public void saveBenchmark(String beginDate,String endDate){
- List<Windpowerstation> wplist = CacheContext.wplist;
- List<String> days = getDays(beginDate, endDate);
- for (String day : days) {
- Date date = DateUtils.parseDate(day);
- Map<String,Object> selMap = new HashMap<>();
- selMap.put("recorddate",date);
- benchmarkService.removeByMap(selMap);
- //获取数据
- List<Windpowerinfoday> windpowerinfodays = windpowerinfodayService.listByMap(selMap);
- List<Windpowerinfoday3> windpowerinfoday3s = windpowerinfoday3Service.listByMap(selMap);
- List<Wpmttrandmtbfday> wpmttrandmtbfdays = wpmttrandmtbfdayService.listByMap(selMap);
- List<Windpowerspecificinfoday> windpowerspecificinfodays = windpowerspecificinfodayService.listByMap(selMap);
- List<Windpowerstationthewindinfo> windpowerstationthewindinfos = windpowerstationthewindinfoService.listByMap(selMap);
- //封装结果list一起存储
- List<Benchmark> resultList = new ArrayList<>();
- //赋值
- wplist.stream().forEach(wp -> {
- Benchmark benchmark = new Benchmark();
- benchmark.setId(StringUtils.getUUID());
- benchmark.setForeignkeyid(wp.getId()); //场站
- benchmark.setRecorddate(date);
- benchmark.setMark(RandomUtil.getRandomForDoubleBounded(80.0,95.0));
- benchmark.setCapacity(wp.getCapacity());
- benchmark.setUnits(wp.getQuantity());
- double fdl = 0.0;
- double swdl = 0.0;
- double gwdl = 0.0;
- double gzdl = 0.0;
- double whdl = 0.0;
- double xddl = 0.0;
- double xndl = 0.0;
- double sldl = 0.0;
- double zhcydl = 0.0;
- double gzcs = 0.0;
- double gzsj = 0.0;
- double rlsj = 0.0;
- double sbklyl = 0.0;
- double dxkyxs = 0.0;
- double yfwcs = 0.0;
- double sjfwcs = 0.0;
- double yzhcs = 0.0;
- double sjzhcs = 0.0;
- double yxqcs = 0.0;
- double sjxqcs = 0.0;
- double speed = 0.0;
- double jfpl = 0.0;
- double jfcs = 0.0;
- List<Windpowerinfoday> infodayList = windpowerinfodays.stream().filter(i -> i.getForeignkeyid().equals(wp.getId())).collect(Collectors.toList());
- if (StringUtils.isNotNull(infodayList) && StringUtils.isNotEmpty(infodayList)){
- Windpowerinfoday windpowerinfoday = infodayList.get(0);
- fdl = windpowerinfoday.getGeneratingcapacity();
- swdl = windpowerinfoday.getGridelectricity();
- gwdl = windpowerinfoday.getBuyelectricity();
- zhcydl = fdl + gwdl - swdl;
- sbklyl = windpowerinfoday.getDaysbklyl();
- dxkyxs = windpowerinfoday.getDaydxkyxs();
- speed = windpowerinfoday.getSpeed();
- }
- List<Windpowerinfoday3> infoday3List = windpowerinfoday3s.stream().filter(i -> i.getForeignkeyid().equals(wp.getId())).collect(Collectors.toList());
- if (StringUtils.isNotNull(infoday3List) && StringUtils.isNotEmpty(infoday3List)){
- Windpowerinfoday3 windpowerinfoday3 = infoday3List.get(0);
- gzdl = windpowerinfoday3.getDaynhgzssdl()/10000;
- whdl = windpowerinfoday3.getDaynhwhssdl()/10000;
- xddl = windpowerinfoday3.getDaynhxdssdl()/10000;
- xndl = windpowerinfoday3.getDaynhqfdl()/10000;
- //sldl = windpowerinfoday3.getDaynhcfdl()/10000;
- }
- List<Wpmttrandmtbfday> wpmttrandmtbfdayList = wpmttrandmtbfdays.stream().filter(i -> i.getWpid().equals(wp.getId())).collect(Collectors.toList());
- if (StringUtils.isNotNull(wpmttrandmtbfdayList) && StringUtils.isNotEmpty(wpmttrandmtbfdayList)){
- Wpmttrandmtbfday wpmttrandmtbfday = wpmttrandmtbfdayList.get(0);
- gzcs = wpmttrandmtbfday.getStoprtimes();
- gzsj = wpmttrandmtbfday.getStophours();
- rlsj = wpmttrandmtbfday.getWthours();
- }
- List<Windpowerspecificinfoday> windpowerspecificinfodayList = windpowerspecificinfodays.stream().filter(i -> i.getWindpowerstationid().equals(wp.getId())).collect(Collectors.toList());
- if (StringUtils.isNotNull(windpowerspecificinfodayList) && StringUtils.isNotEmpty(windpowerspecificinfodayList)){
- Windpowerspecificinfoday windpowerspecificinfoday = windpowerspecificinfodayList.get(0);
- yfwcs = windpowerspecificinfoday.getTheoresettimes();
- sjfwcs = windpowerspecificinfoday.getResettimes();
- yzhcs = windpowerspecificinfoday.getTheoconversiontimes();
- sjzhcs = windpowerspecificinfoday.getConversiontimes();
- yxqcs = windpowerspecificinfoday.getTheofaultcount();
- sjxqcs = windpowerspecificinfoday.getRightcount();
- }
- List<Windpowerstationthewindinfo> windpowerstationthewindinfoList = windpowerstationthewindinfos.stream().filter(i -> i.getWindpowerstationid().equals(wp.getId())).collect(Collectors.toList());
- if (StringUtils.isNotNull(windpowerstationthewindinfoList) && StringUtils.isNotEmpty(windpowerstationthewindinfoList)){
- Windpowerstationthewindinfo windpowerstationthewindinfo = windpowerstationthewindinfoList.get(0);
- jfcs = windpowerstationthewindinfo.getCa();
- jfpl = windpowerstationthewindinfo.getCb();
- }
- benchmark.setActualpower(fdl);
- benchmark.setDaynhgzssdl(gzdl);
- benchmark.setDaynhwhssdl(whdl);
- benchmark.setDaynhxdssdl(xddl);
- benchmark.setDaynhqfdl(xndl);
- benchmark.setDaynhcfdl(sldl);
- benchmark.setTheoreticalpower(benchmark.getActualpower()+benchmark.getDaynhgzssdl()+benchmark.getDaynhwhssdl()+benchmark.getDaynhxdssdl()+benchmark.getDaynhqfdl()+benchmark.getDaynhcfdl());
- benchmark.setWindenergy(benchmark.getTheoreticalpower()!=0?benchmark.getActualpower()/benchmark.getTheoreticalpower()*100:0.0);
- benchmark.setPowerlossrate(benchmark.getTheoreticalpower()!=0?benchmark.getDaynhxdssdl()/benchmark.getTheoreticalpower()*100:0.0);
- benchmark.setPerformancelossrate(benchmark.getTheoreticalpower()!=0?benchmark.getDaynhqfdl()/benchmark.getTheoreticalpower()*100:0.0);
- benchmark.setComprehensiverate(benchmark.getActualpower()!=0?zhcydl/benchmark.getActualpower()*100:0.0);
- benchmark.setUtilizationhours(benchmark.getActualpower()/benchmark.getCapacity()*10);
- benchmark.setWindpoweraccuracy(RandomUtil.getRandomForDoubleBounded(91.0,99.0));
- benchmark.setAgccurvefollowing(RandomUtil.getRandomForDoubleBounded(91.0,99.0));
- benchmark.setMttr(gzcs!=0?gzsj/gzcs:0.0);
- benchmark.setMtbf(gzcs!=0?rlsj/gzcs:0.0);
- benchmark.setMttf(benchmark.getMtbf()-benchmark.getMttr());
- benchmark.setAvailability(sbklyl);
- benchmark.setAvailabilityfactor(dxkyxs);
- benchmark.setFailurelossrate(benchmark.getTheoreticalpower()!=0?benchmark.getDaynhgzssdl()/benchmark.getTheoreticalpower()*100:0.0);
- benchmark.setMainlossrate(benchmark.getTheoreticalpower()!=0?benchmark.getDaynhwhssdl()/benchmark.getTheoreticalpower()*100:0.0);
- benchmark.setHiddentimely(RandomUtil.getRandomForDoubleBounded(70.0,99.0));
- benchmark.setResettimelyrate(yfwcs!=0?sjfwcs/yfwcs*100:0.0);
- benchmark.setStatetransitionrate(yzhcs!=0?sjzhcs/yzhcs*100:0.0);
- benchmark.setEliminationrate(yxqcs!=0?sjxqcs/yxqcs*100:0.0);
- benchmark.setSpeed(speed);
- benchmark.setStaticwindfrequency(jfpl);
- benchmark.setEffectivewindhourrate(0.0);
- resultList.add(benchmark);
- });
- benchmarkService.saveBatch(resultList);
- }
- }
- /**
- * 对标首页下面部分
- * @param timetype
- * @param foreigntype
- * @return
- */
- public List<Benchmark> dbmainbottom(String timetype, String foreigntype) throws Exception {
- if (StringUtils.isEmpty(timetype)){
- timetype = "日";
- }
- if (StringUtils.isEmpty(foreigntype)){
- foreigntype = "风电";
- }
- QueryWrapper<Benchmark> qw = new QueryWrapper<>();
- qw.select("foreignkeyid,avg(mark) mark," +
- "avg(capacity) capacity," +
- "avg(units) units," +
- "sum(theoreticalpower) theoreticalpower," +
- "sum(actualpower) actualpower," +
- "sum(daynhgzssdl) daynhgzssdl, " +
- "sum(daynhwhssdl) daynhwhssdl," +
- "sum(daynhxdssdl) daynhxdssdl," +
- "sum(daynhqfdl) daynhqfdl," +
- "sum(daynhcfdl) daynhcfdl, " +
- "nvl(sum(actualpower),0)/nvl(sum(theoreticalpower),1)*100 windenergy, " +
- "nvl(sum(daynhxdssdl),0)/nvl(sum(theoreticalpower),1)*100 powerlossrate, " +
- "nvl(sum(daynhqfdl),0)/nvl(sum(theoreticalpower),1)*100 performancelossrate, " +
- "nvl(sum(daynhgzssdl),0)/nvl(sum(theoreticalpower),1)*100 failurelossrate, " +
- "nvl(sum(daynhwhssdl),0)/nvl(sum(theoreticalpower),1)*100 mainlossrate," +
- "avg(comprehensiverate) comprehensiverate,sum(actualpower)/avg(capacity) utilizationhours," +
- "avg(windpoweraccuracy) windpoweraccuracy," +
- "avg(agccurvefollowing) agccurvefollowing," +
- "avg(mtbf) mtbf,avg(mttr) mttr,avg(mttf) mttf," +
- "avg(availability) availability,avg(availabilityfactor) availabilityfactor," +
- "avg(hiddentimely) hiddentimely," +
- "avg(resettimelyrate) resettimelyrate," +
- "avg(statetransitionrate) statetransitionrate," +
- "avg(eliminationrate) eliminationrate," +
- "avg(speed) speed," +
- "avg(staticwindfrequency) staticwindfrequency," +
- "avg(effectivewindhourrate) effectivewindhourrate");
- if (foreigntype.equals("风电")){
- qw.like("foreignkeyid","_FDC");
- }else {
- qw.like("foreignkeyid","_GDC");
- }
- Date end = DateUtils.getYesterdayStart();
- Date begin = end;
- if (timetype.equals("日")){
- begin = end;
- }else if(timetype.equals("周")){
- begin = DateUtils.getThisWeekMonday(end);
- }else if(timetype.equals("月")){
- begin = DateUtils.getFirstAndLastDayOfMonth(end);
- }else if(timetype.equals("季")){
- begin = DateUtils.getSeasonStartDate(end);
- }else if(timetype.equals("年")){
- begin = DateUtils.getYearBegin(end);
- }
- qw.ge("recorddate",begin).le("recorddate",end);
- qw.groupBy("foreignkeyid");
- List<Benchmark> benchmarkList = benchmarkService.list(qw);
- return benchmarkList;
- }
- public void getSj(String timetype, String foreigntype,List<Benchmark> resultList) throws Exception {
- QueryWrapper<Benchmark> qw = new QueryWrapper<>();
- qw.select("max(foreignkeyid) foreignkeyid," +
- "sum(theoreticalpower) theoreticalpower," +
- "sum(actualpower) actualpower," +
- "sum(daynhgzssdl) daynhgzssdl," +
- "sum(daynhwhssdl) daynhwhssdl," +
- "sum(daynhxdssdl) daynhxdssdl," +
- "sum(daynhqfdl) daynhqfdl," +
- "sum(daynhcfdl) daynhcfdl," +
- "CASE WHEN SUM ( theoreticalpower ) = 0 THEN 0 ELSE SUM ( actualpower ) / SUM ( theoreticalpower ) * 100 END AS windenergy," +
- "CASE WHEN SUM ( theoreticalpower ) = 0 THEN 0 ELSE SUM ( daynhxdssdl ) / SUM ( theoreticalpower ) * 100 END AS powerlossrate," +
- "CASE WHEN SUM ( theoreticalpower ) = 0 THEN 0 ELSE SUM ( daynhqfdl ) / SUM ( theoreticalpower ) * 100 END AS performancelossrate," +
- "CASE WHEN SUM ( theoreticalpower ) = 0 THEN 0 ELSE SUM ( daynhgzssdl ) / SUM ( theoreticalpower ) * 100 END AS failurelossrate," +
- "CASE WHEN SUM ( theoreticalpower ) = 0 THEN 0 ELSE SUM ( daynhwhssdl ) / SUM ( theoreticalpower ) * 100 END AS mainlossrate," +
- "avg(resettimelyrate) resettimelyrate," +
- "avg(statetransitionrate) statetransitionrate," +
- "avg(eliminationrate) eliminationrate," +
- "avg(comprehensiverate) comprehensiverate," +
- "avg(windpoweraccuracy) windpoweraccuracy," +
- "avg(agccurvefollowing) agccurvefollowing");
- if (foreigntype.equals("风电")){
- qw.like("foreignkeyid","_FDC");
- }else {
- qw.like("foreignkeyid","_GDC");
- }
- Date end = DateUtils.getYesterdayStart();
- Date begin = end;
- if (timetype.equals("日")){
- begin = end;
- }else if(timetype.equals("周")){
- begin = DateUtils.getThisWeekMonday(end);
- }else if(timetype.equals("月")){
- begin = DateUtils.getFirstAndLastDayOfMonth(end);
- }else if(timetype.equals("季")){
- begin = DateUtils.getSeasonStartDate(end);
- }else if(timetype.equals("年")){
- begin = DateUtils.getYearBegin(end);
- }
- qw.ge("recorddate",begin).le("recorddate",end);
- List<Benchmark> sjList = benchmarkService.list(qw);
- if (StringUtils.isNotNull(sjList)){
- sjList.get(0).setForeignkeyid("实际");
- resultList.add(sjList.get(0));
- }
- }
- public void getHb(String timetype, String foreigntype,List<Benchmark> resultList) throws Exception {
- QueryWrapper<Benchmark> qw = new QueryWrapper<>();
- qw.select("max(foreignkeyid) foreignkeyid," +
- "sum(theoreticalpower) theoreticalpower," +
- "sum(actualpower) actualpower," +
- "sum(daynhgzssdl) daynhgzssdl," +
- "sum(daynhwhssdl) daynhwhssdl," +
- "sum(daynhxdssdl) daynhxdssdl," +
- "sum(daynhqfdl) daynhqfdl," +
- "sum(daynhcfdl) daynhcfdl," +
- "isnull(sum(actualpower)/nullif(sum(theoreticalpower),0),0)*100 windenergy," +
- "isnull(sum(daynhxdssdl)/nullif(sum(theoreticalpower),0),0)*100 powerlossrate," +
- "isnull(sum(daynhqfdl)/nullif(sum(theoreticalpower),0),0)*100 performancelossrate," +
- "isnull(sum(daynhgzssdl)/nullif(sum(theoreticalpower),0),0)*100 failurelossrate," +
- "isnull(sum(daynhwhssdl)/nullif(sum(theoreticalpower),0),0)*100 mainlossrate," +
- "avg(resettimelyrate) resettimelyrate,avg(statetransitionrate) statetransitionrate," +
- "avg(eliminationrate) eliminationrate,avg(comprehensiverate) comprehensiverate," +
- "avg(windpoweraccuracy) windpoweraccuracy,avg(agccurvefollowing) agccurvefollowing");
- if (foreigntype.equals("风电")){
- qw.like("foreignkeyid","_FDC");
- }else {
- qw.like("foreignkeyid","_GDC");
- }
- Date end = DateUtils.getYesterdayStart();
- Date begin = end;
- if (timetype.equals("日")){
- begin = end;
- }else if(timetype.equals("周")){
- begin = DateUtils.getThisWeekMonday(end);
- }else if(timetype.equals("月")){
- begin = DateUtils.getFirstAndLastDayOfMonth(end);
- }else if(timetype.equals("季")){
- begin = DateUtils.getSeasonStartDate(end);
- }else if(timetype.equals("年")){
- begin = DateUtils.getYearBegin(end);
- }
- begin = DateUtils.addMonths(begin,-1);
- end = DateUtils.addMonths(end,-1);
- qw.ge("recorddate",begin).le("recorddate",end);
- List<Benchmark> hbList = benchmarkService.list(qw);
- if (StringUtils.isNotNull(hbList) && StringUtils.isNotEmpty(hbList)){
- hbList.get(0).setForeignkeyid("环比");
- resultList.add(hbList.get(0));
- }
- }
- public void getTb(String timetype, String foreigntype,List<Benchmark> resultList) throws Exception {
- QueryWrapper<Benchmark> qw = new QueryWrapper<>();
- qw.select("max(foreignkeyid) foreignkeyid," +
- "sum(theoreticalpower) theoreticalpower," +
- "sum(actualpower) actualpower," +
- "sum(daynhgzssdl) daynhgzssdl," +
- "sum(daynhwhssdl) daynhwhssdl," +
- "sum(daynhxdssdl) daynhxdssdl," +
- "sum(daynhqfdl) daynhqfdl," +
- "sum(daynhcfdl) daynhcfdl," +
- "CASE WHEN sum(theoreticalpower) = 0 THEN 0 ELSE sum(actualpower)/sum(theoreticalpower)*100 END AS windenergy," +
- "CASE WHEN sum(theoreticalpower) = 0 THEN 0 ELSE sum(daynhxdssdl)/sum(theoreticalpower)*100 END AS powerlossrate," +
- "CASE WHEN sum(theoreticalpower) = 0 THEN 0 ELSE sum(daynhqfdl)/sum(theoreticalpower)*100 END AS performancelossrate," +
- "CASE WHEN SUM ( theoreticalpower ) = 0 THEN 0 ELSE SUM ( daynhgzssdl ) / SUM ( theoreticalpower ) * 100 END AS failurelossrate,"+
- "CASE WHEN SUM ( theoreticalpower ) = 0 THEN 0 ELSE SUM ( daynhwhssdl ) / SUM ( theoreticalpower ) * 100 END AS mainlossrate," +
- "avg(resettimelyrate) resettimelyrate," +
- "avg(statetransitionrate) statetransitionrate," +
- "avg(eliminationrate) eliminationrate," +
- "avg(comprehensiverate) comprehensiverate," +
- "avg(windpoweraccuracy) windpoweraccuracy," +
- "avg(agccurvefollowing) agccurvefollowing");
- if (foreigntype.equals("风电")){
- qw.like("foreignkeyid","_FDC");
- }else {
- qw.like("foreignkeyid","_GDC");
- }
- Date end = DateUtils.getYesterdayStart();
- Date begin = end;
- if (timetype.equals("日")){
- begin = end;
- }else if(timetype.equals("周")){
- begin = DateUtils.getThisWeekMonday(end);
- }else if(timetype.equals("月")){
- begin = DateUtils.getFirstAndLastDayOfMonth(end);
- }else if(timetype.equals("季")){
- begin = DateUtils.getSeasonStartDate(end);
- }else if(timetype.equals("年")){
- begin = DateUtils.getYearBegin(end);
- }
- begin = DateUtils.addYears(DateUtils.addMonths(begin,1),-1);
- end = DateUtils.addYears(DateUtils.addMonths(end,1),-1);
- qw.ge("recorddate",begin).le("recorddate",end);
- List<Benchmark> tbList = benchmarkService.list(qw);
- if (StringUtils.isNotNull(tbList) && StringUtils.isNotEmpty(tbList)){
- Benchmark benchmark = tbList.get(0);
- if(benchmark!=null){
- benchmark.setForeignkeyid("同比");
- resultList.add(benchmark);
- }
- }
- }
- public void getJz(String timetype, String foreigntype,List<Benchmark> resultList) throws Exception {
- QueryWrapper<Benchmark> qw = new QueryWrapper<>();
- qw.select("max(foreignkeyid) foreignkeyid," +
- "sum(theoreticalpower) theoreticalpower," +
- "sum(actualpower) actualpower," +
- "sum(daynhgzssdl) daynhgzssdl," +
- "sum(daynhwhssdl) daynhwhssdl," +
- "sum(daynhxdssdl) daynhxdssdl," +
- "sum(daynhqfdl) daynhqfdl," +
- "sum(daynhcfdl) daynhcfdl," +
- "CASE WHEN SUM ( theoreticalpower ) = 0 THEN 0 ELSE SUM ( actualpower ) / SUM ( theoreticalpower ) * 100 END AS windenergy," +
- "CASE WHEN SUM ( theoreticalpower ) = 0 THEN 0 ELSE SUM ( daynhxdssdl ) / SUM ( theoreticalpower ) * 100 END AS powerlossrate," +
- "CASE WHEN SUM ( theoreticalpower ) = 0 THEN 0 ELSE SUM ( daynhqfdl ) / SUM ( theoreticalpower ) * 100 END AS performancelossrate," +
- "CASE WHEN SUM ( theoreticalpower ) = 0 THEN 0 ELSE SUM ( daynhgzssdl ) / SUM ( theoreticalpower ) * 100 END AS failurelossrate," +
- "CASE WHEN SUM ( theoreticalpower ) = 0 THEN 0 ELSE SUM ( daynhwhssdl ) / SUM ( theoreticalpower ) * 100 END AS mainlossrate," +
- "avg(resettimelyrate) resettimelyrate," +
- "avg(statetransitionrate) statetransitionrate," +
- "avg(eliminationrate) eliminationrate," +
- "avg(comprehensiverate) comprehensiverate," +
- "avg(windpoweraccuracy) windpoweraccuracy," +
- "avg(agccurvefollowing) agccurvefollowing");
- if (foreigntype.equals("风电")){
- qw.like("foreignkeyid","_FDC");
- }else {
- qw.like("foreignkeyid","_GDC");
- }
- Date end = DateUtils.getYesterdayStart();
- Date begin = end;
- if (timetype.equals("日")){
- begin = end;
- }else if(timetype.equals("周")){
- begin = DateUtils.getThisWeekMonday(end);
- }else if(timetype.equals("月")){
- begin = DateUtils.getFirstAndLastDayOfMonth(end);
- }else if(timetype.equals("季")){
- begin = DateUtils.getSeasonStartDate(end);
- }else if(timetype.equals("年")){
- begin = DateUtils.getYearBegin(end);
- }
- begin = DateUtils.addYears(begin,-5);
- end = DateUtils.addYears(end,-5);
- qw.ge("recorddate",begin).le("recorddate",end);
- List<Benchmark> jzList = benchmarkService.list(qw);
- if (StringUtils.isNotNull(jzList) && StringUtils.isNotEmpty(jzList)){
- jzList.get(0).setForeignkeyid("基准");
- resultList.add(jzList.get(0));
- }
- }
- /**
- * 对标首页上面部分
- * @param timetype
- * @param foreigntype
- * @return
- */
- public List<Benchmark> dbmaintop(String timetype, String foreigntype) throws Exception {
- List<Benchmark> resultList = new ArrayList<>();
- getSj(timetype,foreigntype,resultList);
- getHb(timetype,foreigntype,resultList);
- getTb(timetype,foreigntype,resultList);
- getJz(timetype,foreigntype,resultList);
- return resultList;
- }
- }
|