SpecificService.java 295 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995
  1. package com.gyee.runeconomy.service.specific;
  2. import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
  3. import com.gyee.common.model.StringUtils;
  4. import com.gyee.common.util.DateUtils;
  5. import com.gyee.common.util.DoubleUtils;
  6. import com.gyee.common.util.SortUtils;
  7. import com.gyee.common.vo.specific.SpecificCenterVo;
  8. import com.gyee.common.vo.specific.SpecificTarget;
  9. import com.gyee.common.vo.specific.SpecificTargetVo;
  10. import com.gyee.common.vo.specific.SpecificTopVo;
  11. import com.gyee.runeconomy.init.CacheContext;
  12. import com.gyee.runeconomy.model.auto.*;
  13. import com.gyee.runeconomy.service.TokenService;
  14. import com.gyee.runeconomy.service.auto.*;
  15. import com.gyee.runeconomy.service.bmk.BenchmarkingService;
  16. import org.springframework.stereotype.Service;
  17. import org.springframework.web.context.request.RequestContextHolder;
  18. import org.springframework.web.context.request.ServletRequestAttributes;
  19. import javax.annotation.Resource;
  20. import javax.servlet.http.HttpServletRequest;
  21. import java.text.ParseException;
  22. import java.time.Instant;
  23. import java.time.ZoneId;
  24. import java.util.*;
  25. import java.util.stream.Collectors;
  26. /*
  27. @author 谢生杰
  28. @date 2022/11/23-21:38
  29. 专题分析
  30. */
  31. @Service
  32. public class SpecificService {
  33. @Resource
  34. private IProEconPowerstationInfoDay1Service proEconPowerstationInfoDay1Service;
  35. @Resource
  36. private IProEconPowerstationInfoDay4Service proEconPowerstationInfoDay4Service;
  37. @Resource
  38. private IProEconPowerstationInfoDay5Service proEconPowerstationInfoDay5Service;
  39. @Resource
  40. private IProEconPowerstationInfoDay7Service proEconPowerstationInfoDay7Service;
  41. @Resource
  42. private BenchmarkingService benchmarkingService;
  43. @Resource
  44. private TokenService tokenService;
  45. @Resource
  46. private IStationInfoDayService iStationInfoDayService;
  47. @Resource
  48. private ITurbineInfoDayService iTurbineInfoDayService;
  49. /**
  50. * 获取专题分析上面部分
  51. *
  52. * @param yearmonth
  53. * @return
  54. * @throws ParseException
  55. */
  56. public List<SpecificTopVo> maintoplist(String companys, String type, String yearmonth) throws ParseException {
  57. List<SpecificTopVo> resultList = new ArrayList<>();
  58. Date date = DateUtils.parseDate(yearmonth + "-01");
  59. Calendar c = Calendar.getInstance();
  60. c.setTime(date);
  61. Integer year = c.get(Calendar.YEAR);
  62. Integer month = c.get(Calendar.MONTH) + 1;
  63. SpecificTopVo dqvo = new SpecificTopVo();
  64. dqvo.setType("本期");
  65. setDySpecificinfodays(companys, type, yearmonth, dqvo);
  66. setDnSpecificinfodays(companys, type, yearmonth, dqvo);
  67. resultList.add(dqvo);
  68. SpecificTopVo tqvo = new SpecificTopVo();
  69. tqvo.setType("同期");
  70. setTySpecificinfodays(companys, type, yearmonth, tqvo);
  71. setTnSpecificinfodays(companys, type, yearmonth, tqvo);
  72. resultList.add(tqvo);
  73. SpecificTopVo bjvo = new SpecificTopVo();
  74. bjvo.setType("比较");
  75. setBjVo(dqvo, tqvo, bjvo);
  76. resultList.add(bjvo);
  77. return resultList;
  78. }
  79. /**
  80. * 比较当前,同期值,给比较值赋值
  81. *
  82. * @param dqvo
  83. * @param tqvo
  84. * @param bjvo
  85. */
  86. private void setBjVo(SpecificTopVo dqvo, SpecificTopVo tqvo, SpecificTopVo bjvo) {
  87. bjvo.setYfnlyl(dqvo.getYfnlyl() >= tqvo.getYfnlyl() ? 1.0 : 2.0);
  88. bjvo.setYwhssl(dqvo.getYwhssl() >= tqvo.getYwhssl() ? 1.0 : 2.0);
  89. bjvo.setYgzssl(dqvo.getYgzssl() >= tqvo.getYgzssl() ? 1.0 : 2.0);
  90. bjvo.setYxdssl(dqvo.getYxdssl() >= tqvo.getYxdssl() ? 1.0 : 2.0);
  91. bjvo.setYxnssl(dqvo.getYxnssl() >= tqvo.getYxnssl() ? 1.0 : 2.0);
  92. bjvo.setYslssl(dqvo.getYslssl() >= tqvo.getYslssl() ? 1.0 : 2.0);
  93. bjvo.setNfnlyl(dqvo.getNfnlyl() >= tqvo.getNfnlyl() ? 1.0 : 2.0);
  94. bjvo.setNwhssl(dqvo.getNwhssl() >= tqvo.getNwhssl() ? 1.0 : 2.0);
  95. bjvo.setNgzssl(dqvo.getNgzssl() >= tqvo.getNgzssl() ? 1.0 : 2.0);
  96. bjvo.setNxdssl(dqvo.getNxdssl() >= tqvo.getNxdssl() ? 1.0 : 2.0);
  97. bjvo.setNxnssl(dqvo.getNxnssl() >= tqvo.getNxnssl() ? 1.0 : 2.0);
  98. bjvo.setNslssl(dqvo.getNslssl() >= tqvo.getNslssl() ? 1.0 : 2.0);
  99. }
  100. // /**
  101. // * 获取当月专题分析上面数据
  102. // *
  103. // * @param companys
  104. // * @param type
  105. // * @param yearmonth
  106. // * @return
  107. // */
  108. // private void setDySpecificinfodays(String companys, String type, String yearmonth, SpecificTopVo dqvo) {
  109. // QueryWrapper<ProEconPowerstationInfoDay1> qw = new QueryWrapper<>();
  110. // qw.select("sum(rllfdl) as yllfdl,sum(rfdl) as yfdl,sum(rgzssdl) as ygzssdl,sum(rcnslgzssdl) as ycnslgzssdl,sum(rjxssdl) as yjxssdl,sum(rcnsljxssdl) ycnsljxssdl,sum(rdjssdl) ydjssdl,sum(rqxjclssdl) as yqxjclssdl,sum(rsdtjssdl) as ysdtjssdl,sum(rxnssdl) as yxnssdl,sum(rxdtjssdl) as yxdtjssdl,sum(rxdjclssdl) as yxdjclssdl,sum(rcwsldwssdl) ycwsldwssdl,sum(rcwsltqssdl) ycwsltqssdl");
  111. // qw.eq("foreign_key_id", companys + type);
  112. // qw.eq("to_char(record_date,'yyyy-MM')", yearmonth);
  113. // qw.groupBy("to_char(record_date,'yyyy-MM')");
  114. // List<ProEconPowerstationInfoDay1> monthList = proEconPowerstationInfoDay1Service.list(qw);
  115. // if (StringUtils.isNotEmpty(monthList)) {
  116. // Optional<ProEconPowerstationInfoDay1> monthFirst = monthList.stream().findFirst();
  117. // if (monthFirst.isPresent()) {
  118. // ProEconPowerstationInfoDay1 monthSpecific = monthFirst.get();
  119. // dqvo.setYllfdl(DoubleUtils.getRoundingNum(monthSpecific.getYllfdl().doubleValue() / 10000, 2));
  120. // dqvo.setYsjfdl(DoubleUtils.getRoundingNum(monthSpecific.getYfdl().doubleValue() / 10000, 2));
  121. // dqvo.setYwhssdl(DoubleUtils.getRoundingNum(monthSpecific.getYjxssdl().doubleValue() / 10000 + monthSpecific.getYcnsljxssdl().doubleValue() / 10000, 2));
  122. // dqvo.setYgzssdl(DoubleUtils.getRoundingNum(monthSpecific.getYgzssdl().doubleValue() / 10000 + monthSpecific.getYcnslgzssdl().doubleValue() / 10000, 2));
  123. // dqvo.setYxdssdl(DoubleUtils.getRoundingNum(monthSpecific.getYxnssdl().doubleValue() / 10000 + monthSpecific.getYxdjclssdl().doubleValue() / 10000, 2));
  124. // dqvo.setYxnssdl(DoubleUtils.getRoundingNum(monthSpecific.getYdjssdl().doubleValue() / 10000 + monthSpecific.getYqxjclssdl().doubleValue() / 10000 + monthSpecific.getYxnssdl().doubleValue() / 10000 + monthSpecific.getYsdtjssdl().doubleValue() / 10000, 2));
  125. // dqvo.setYslssdl(DoubleUtils.getRoundingNum(monthSpecific.getYcwsldwssdl().doubleValue() / 10000 + monthSpecific.getYcwsltqssdl().doubleValue() / 10000, 2));
  126. // if (dqvo.getYllfdl() != 0) {
  127. // dqvo.setYfnlyl(DoubleUtils.getRoundingNum(dqvo.getYsjfdl() / dqvo.getYllfdl() * 100, 2));
  128. // dqvo.setYwhssl(DoubleUtils.getRoundingNum(dqvo.getYwhssdl() / dqvo.getYllfdl() * 100, 2));
  129. // dqvo.setYgzssl(DoubleUtils.getRoundingNum(dqvo.getYgzssdl() / dqvo.getYllfdl() * 100, 2));
  130. // dqvo.setYxdssl(DoubleUtils.getRoundingNum(dqvo.getYxdssdl() / dqvo.getYllfdl() * 100, 2));
  131. // dqvo.setYxnssl(DoubleUtils.getRoundingNum(dqvo.getYxnssdl() / dqvo.getYllfdl() * 100, 2));
  132. // dqvo.setYslssl(DoubleUtils.getRoundingNum(dqvo.getYslssdl() / dqvo.getYllfdl() * 100, 2));
  133. // } else {
  134. // dqvo.setYfnlyl(0.0);
  135. // dqvo.setYwhssl(0.0);
  136. // dqvo.setYgzssl(0.0);
  137. // dqvo.setYxdssl(0.0);
  138. // dqvo.setYxnssl(0.0);
  139. // dqvo.setYslssl(0.0);
  140. // }
  141. // }
  142. // } else {
  143. // dqvo.setYllfdl(0.0);
  144. // dqvo.setYsjfdl(0.0);
  145. // dqvo.setYwhssdl(0.0);
  146. // dqvo.setYgzssdl(0.0);
  147. // dqvo.setYxdssdl(0.0);
  148. // dqvo.setYxnssdl(0.0);
  149. // dqvo.setYslssdl(0.0);
  150. // dqvo.setYfnlyl(0.0);
  151. // dqvo.setYwhssl(0.0);
  152. // dqvo.setYgzssl(0.0);
  153. // dqvo.setYxdssl(0.0);
  154. // dqvo.setYxnssl(0.0);
  155. // dqvo.setYslssl(0.0);
  156. // }
  157. //
  158. // }
  159. /**
  160. * 获取当月专题分析上面数据
  161. *
  162. * @param companys
  163. * @param type
  164. * @param yearmonth
  165. * @return
  166. */
  167. private void setDySpecificinfodays(String companys, String type, String yearmonth, SpecificTopVo dqvo) {
  168. QueryWrapper<TurbineInfoDay> qw = new QueryWrapper<>();
  169. qw.select("sum(llfdl) as llfdl,sum(rfdl) as rfdl,sum(gzss) as gzss,sum(jhjxss) as jhjxss,sum(fjhjxss) as fjhjxss,sum(djss) djss,sum(xnss) as xnss,sum(slss) as slss");
  170. qw.eq("to_char(record_date,'yyyy-MM')", yearmonth);
  171. qw.groupBy("to_char(record_date,'yyyy-MM')");
  172. List<TurbineInfoDay> monthList = iTurbineInfoDayService.list(qw);
  173. if (StringUtils.isNotEmpty(monthList)) {
  174. Optional<TurbineInfoDay> monthFirst = monthList.stream().findFirst();
  175. if (monthFirst.isPresent()) {
  176. TurbineInfoDay monthSpecific = monthFirst.get();
  177. dqvo.setYllfdl(DoubleUtils.getRoundingNum(monthSpecific.getLlfdl() / 10000, 2));
  178. dqvo.setYsjfdl(DoubleUtils.getRoundingNum(monthSpecific.getRfdl().doubleValue() / 10000, 2));
  179. dqvo.setYwhssdl(DoubleUtils.getRoundingNum(monthSpecific.getJhjxss().doubleValue() / 10000 + monthSpecific.getFjhjxss().doubleValue() / 10000, 2));
  180. dqvo.setYgzssdl(DoubleUtils.getRoundingNum(monthSpecific.getGzss().doubleValue() / 10000, 2));
  181. dqvo.setYxdssdl(DoubleUtils.getRoundingNum(monthSpecific.getXnss().doubleValue() / 10000, 2));
  182. dqvo.setYxnssdl(DoubleUtils.getRoundingNum(monthSpecific.getDjss().doubleValue() / 10000, 2));
  183. dqvo.setYslssdl(DoubleUtils.getRoundingNum(monthSpecific.getSlss().doubleValue() / 10000, 2));
  184. if (dqvo.getYllfdl() != 0) {
  185. dqvo.setYfnlyl(DoubleUtils.getRoundingNum(dqvo.getYsjfdl() / dqvo.getYllfdl() * 100, 2));
  186. dqvo.setYwhssl(DoubleUtils.getRoundingNum(dqvo.getYwhssdl() / dqvo.getYllfdl() * 100, 2));
  187. dqvo.setYgzssl(DoubleUtils.getRoundingNum(dqvo.getYgzssdl() / dqvo.getYllfdl() * 100, 2));
  188. dqvo.setYxdssl(DoubleUtils.getRoundingNum(dqvo.getYxdssdl() / dqvo.getYllfdl() * 100, 2));
  189. dqvo.setYxnssl(DoubleUtils.getRoundingNum(dqvo.getYxnssdl() / dqvo.getYllfdl() * 100, 2));
  190. dqvo.setYslssl(DoubleUtils.getRoundingNum(dqvo.getYslssdl() / dqvo.getYllfdl() * 100, 2));
  191. } else {
  192. dqvo.setYfnlyl(0.0);
  193. dqvo.setYwhssl(0.0);
  194. dqvo.setYgzssl(0.0);
  195. dqvo.setYxdssl(0.0);
  196. dqvo.setYxnssl(0.0);
  197. dqvo.setYslssl(0.0);
  198. }
  199. }
  200. } else {
  201. dqvo.setYllfdl(0.0);
  202. dqvo.setYsjfdl(0.0);
  203. dqvo.setYwhssdl(0.0);
  204. dqvo.setYgzssdl(0.0);
  205. dqvo.setYxdssdl(0.0);
  206. dqvo.setYxnssdl(0.0);
  207. dqvo.setYslssdl(0.0);
  208. dqvo.setYfnlyl(0.0);
  209. dqvo.setYwhssl(0.0);
  210. dqvo.setYgzssl(0.0);
  211. dqvo.setYxdssl(0.0);
  212. dqvo.setYxnssl(0.0);
  213. dqvo.setYslssl(0.0);
  214. }
  215. }
  216. // /**
  217. // * 获取月同期专题分析上面数据
  218. // *
  219. // * @param companys
  220. // * @param type
  221. // * @return
  222. // */
  223. // private void setTySpecificinfodays(String companys, String type, String yearmonth, SpecificTopVo dqvo) {
  224. // String yearString = yearmonth.split("-")[0];
  225. // String year = String.valueOf(Integer.parseInt(yearString) - 1);
  226. // String yearMonth = year + "-" + yearmonth.split("-")[1];
  227. // QueryWrapper<ProEconPowerstationInfoDay1> qw = new QueryWrapper<>();
  228. // qw.select("sum(rllfdl) as yllfdl,sum(rfdl) as yfdl,sum(rgzssdl) as ygzssdl,sum(rcnslgzssdl) as ycnslgzssdl,sum(rjxssdl) as yjxssdl,sum(rcnsljxssdl) ycnsljxssdl,sum(rdjssdl) ydjssdl,sum(rqxjclssdl) as yqxjclssdl,sum(rsdtjssdl) as ysdtjssdl,sum(rxnssdl) as yxnssdl,sum(rxdtjssdl) as yxdtjssdl,sum(rxdjclssdl) as yxdjclssdl,sum(rcwsldwssdl) ycwsldwssdl,sum(rcwsltqssdl) ycwsltqssdl");
  229. // qw.eq("foreign_key_id", companys + type);
  230. // qw.eq("to_char(record_date,'yyyy-MM')", yearMonth);
  231. // qw.groupBy("to_char(record_date,'yyyy-MM')");
  232. // List<ProEconPowerstationInfoDay1> monthList = proEconPowerstationInfoDay1Service.list(qw);
  233. // Optional<ProEconPowerstationInfoDay1> monthFirst = monthList.stream().findFirst();
  234. // if (monthFirst.isPresent()) {
  235. // ProEconPowerstationInfoDay1 monthSpecific = monthFirst.get();
  236. // dqvo.setYllfdl(DoubleUtils.getRoundingNum(monthSpecific.getYllfdl().doubleValue() / 10000, 2));
  237. // dqvo.setYsjfdl(DoubleUtils.getRoundingNum(monthSpecific.getYfdl().doubleValue() / 10000, 2));
  238. // dqvo.setYwhssdl(DoubleUtils.getRoundingNum(monthSpecific.getYjxssdl().doubleValue() / 10000 + monthSpecific.getYcnsljxssdl().doubleValue() / 10000, 2));
  239. // dqvo.setYgzssdl(DoubleUtils.getRoundingNum(monthSpecific.getYgzssdl().doubleValue() / 10000 + monthSpecific.getYcnslgzssdl().doubleValue() / 10000, 2));
  240. // dqvo.setYxdssdl(DoubleUtils.getRoundingNum(monthSpecific.getYxnssdl().doubleValue() / 10000 + monthSpecific.getYxdjclssdl().doubleValue() / 10000, 2));
  241. // dqvo.setYxnssdl(DoubleUtils.getRoundingNum(monthSpecific.getYdjssdl().doubleValue() / 10000 + monthSpecific.getYqxjclssdl().doubleValue() / 10000 + monthSpecific.getYxnssdl().doubleValue() / 10000 + monthSpecific.getYsdtjssdl().doubleValue() / 10000, 2));
  242. // dqvo.setYslssdl(DoubleUtils.getRoundingNum(monthSpecific.getYcwsldwssdl().doubleValue() / 10000 + monthSpecific.getYcwsltqssdl().doubleValue() / 10000, 2));
  243. // if (dqvo.getYllfdl() != 0) {
  244. // dqvo.setYfnlyl(DoubleUtils.getRoundingNum(dqvo.getYsjfdl() / dqvo.getYllfdl() * 100, 2));
  245. // dqvo.setYwhssl(DoubleUtils.getRoundingNum(dqvo.getYwhssdl() / dqvo.getYllfdl() * 100, 2));
  246. // dqvo.setYgzssl(DoubleUtils.getRoundingNum(dqvo.getYgzssdl() / dqvo.getYllfdl() * 100, 2));
  247. // dqvo.setYxdssl(DoubleUtils.getRoundingNum(dqvo.getYxdssdl() / dqvo.getYllfdl() * 100, 2));
  248. // dqvo.setYxnssl(DoubleUtils.getRoundingNum(dqvo.getYxnssdl() / dqvo.getYllfdl() * 100, 2));
  249. // dqvo.setYslssl(DoubleUtils.getRoundingNum(dqvo.getYslssdl() / dqvo.getYllfdl() * 100, 2));
  250. // } else {
  251. // dqvo.setYfnlyl(0.0);
  252. // dqvo.setYwhssl(0.0);
  253. // dqvo.setYgzssl(0.0);
  254. // dqvo.setYxdssl(0.0);
  255. // dqvo.setYxnssl(0.0);
  256. // dqvo.setYslssl(0.0);
  257. // }
  258. // } else {
  259. // dqvo.setYllfdl(0.0);
  260. // dqvo.setYsjfdl(0.0);
  261. // dqvo.setYwhssdl(0.0);
  262. // dqvo.setYgzssdl(0.0);
  263. // dqvo.setYxdssdl(0.0);
  264. // dqvo.setYxnssdl(0.0);
  265. // dqvo.setYslssdl(0.0);
  266. // dqvo.setYfnlyl(0.0);
  267. // dqvo.setYwhssl(0.0);
  268. // dqvo.setYgzssl(0.0);
  269. // dqvo.setYxdssl(0.0);
  270. // dqvo.setYxnssl(0.0);
  271. // dqvo.setYslssl(0.0);
  272. // }
  273. // }
  274. /**
  275. * 获取月同期专题分析上面数据
  276. *
  277. * @param companys
  278. * @param type
  279. * @return
  280. */
  281. private void setTySpecificinfodays(String companys, String type, String yearmonth, SpecificTopVo dqvo) {
  282. String yearString = yearmonth.split("-")[0];
  283. String year = String.valueOf(Integer.parseInt(yearString) - 1);
  284. String yearMonth = year + "-" + yearmonth.split("-")[1];
  285. QueryWrapper<TurbineInfoDay> qw = new QueryWrapper<>();
  286. qw.select("sum(llfdl) as llfdl,sum(rfdl) as rfdl,sum(gzss) as gzss,sum(jhjxss) as jhjxss,sum(fjhjxss) as fjhjxss,sum(djss) djss,sum(xnss) as xnss,sum(slss) as slss");
  287. qw.eq("to_char(record_date,'yyyy-MM')", yearMonth);
  288. qw.groupBy("to_char(record_date,'yyyy-MM')");
  289. List<TurbineInfoDay> monthList = iTurbineInfoDayService.list(qw);
  290. Optional<TurbineInfoDay> monthFirst = monthList.stream().findFirst();
  291. if (monthFirst.isPresent()) {
  292. TurbineInfoDay monthSpecific = monthFirst.get();
  293. dqvo.setYllfdl(DoubleUtils.getRoundingNum(monthSpecific.getLlfdl() / 10000, 2));
  294. dqvo.setYsjfdl(DoubleUtils.getRoundingNum(monthSpecific.getRfdl().doubleValue() / 10000, 2));
  295. dqvo.setYwhssdl(DoubleUtils.getRoundingNum(monthSpecific.getJhjxss().doubleValue() / 10000 + monthSpecific.getFjhjxss().doubleValue() / 10000, 2));
  296. dqvo.setYgzssdl(DoubleUtils.getRoundingNum(monthSpecific.getGzss().doubleValue() / 10000, 2));
  297. dqvo.setYxdssdl(DoubleUtils.getRoundingNum(monthSpecific.getXnss().doubleValue() / 10000, 2));
  298. dqvo.setYxnssdl(DoubleUtils.getRoundingNum(monthSpecific.getDjss().doubleValue() / 10000, 2));
  299. dqvo.setYslssdl(DoubleUtils.getRoundingNum(monthSpecific.getSlss().doubleValue() / 10000, 2));
  300. if (dqvo.getYllfdl() != 0) {
  301. dqvo.setYfnlyl(DoubleUtils.getRoundingNum(dqvo.getYsjfdl() / dqvo.getYllfdl() * 100, 2));
  302. dqvo.setYwhssl(DoubleUtils.getRoundingNum(dqvo.getYwhssdl() / dqvo.getYllfdl() * 100, 2));
  303. dqvo.setYgzssl(DoubleUtils.getRoundingNum(dqvo.getYgzssdl() / dqvo.getYllfdl() * 100, 2));
  304. dqvo.setYxdssl(DoubleUtils.getRoundingNum(dqvo.getYxdssdl() / dqvo.getYllfdl() * 100, 2));
  305. dqvo.setYxnssl(DoubleUtils.getRoundingNum(dqvo.getYxnssdl() / dqvo.getYllfdl() * 100, 2));
  306. dqvo.setYslssl(DoubleUtils.getRoundingNum(dqvo.getYslssdl() / dqvo.getYllfdl() * 100, 2));
  307. } else {
  308. dqvo.setYfnlyl(0.0);
  309. dqvo.setYwhssl(0.0);
  310. dqvo.setYgzssl(0.0);
  311. dqvo.setYxdssl(0.0);
  312. dqvo.setYxnssl(0.0);
  313. dqvo.setYslssl(0.0);
  314. }
  315. } else {
  316. dqvo.setYllfdl(0.0);
  317. dqvo.setYsjfdl(0.0);
  318. dqvo.setYwhssdl(0.0);
  319. dqvo.setYgzssdl(0.0);
  320. dqvo.setYxdssdl(0.0);
  321. dqvo.setYxnssdl(0.0);
  322. dqvo.setYslssdl(0.0);
  323. dqvo.setYfnlyl(0.0);
  324. dqvo.setYwhssl(0.0);
  325. dqvo.setYgzssl(0.0);
  326. dqvo.setYxdssl(0.0);
  327. dqvo.setYxnssl(0.0);
  328. dqvo.setYslssl(0.0);
  329. }
  330. }
  331. // /**
  332. // * 获取当年专题分析上面数据
  333. // *
  334. // * @param companys
  335. // * @param type
  336. // * @param yearmonth
  337. // * @param dqvo
  338. // */
  339. // private void setDnSpecificinfodays(String companys, String type, String yearmonth, SpecificTopVo dqvo) {
  340. // QueryWrapper<ProEconPowerstationInfoDay1> qw = new QueryWrapper<>();
  341. // qw.select("sum(rllfdl) as nllfdl,sum(rfdl) as nfdl,sum(rgzssdl) as ngzssdl,sum(rcnslgzssdl) as ncnslgzssdl,sum(rjxssdl) as njxssdl,sum(rcnsljxssdl) ncnsljxssdl,sum(rdjssdl) ndjssdl,sum(rqxjclssdl) as nqxjclssdl,sum(rsdtjssdl) as nsdtjssdl,sum(rxnssdl) as nxnssdl,sum(rxdtjssdl) as nxdtjssdl,sum(rxdjclssdl) as nxdjclssdl,sum(rcwsldwssdl) ncwsldwssdl,sum(rcwsltqssdl) ncwsltqssdl");
  342. // qw.eq("foreign_key_id", companys + type);
  343. // qw.eq("to_char(record_date,'yyyy')", yearmonth.split("-")[0]);
  344. // qw.groupBy("to_char(record_date,'yyyy')");
  345. // List<ProEconPowerstationInfoDay1> yearList = proEconPowerstationInfoDay1Service.list(qw);
  346. // if (StringUtils.isNotEmpty(yearList)) {
  347. // Optional<ProEconPowerstationInfoDay1> yearFirsts = yearList.stream().findFirst();
  348. // if (yearFirsts.isPresent()) {
  349. // ProEconPowerstationInfoDay1 yearSpecific = yearFirsts.get();
  350. // dqvo.setNllfdl(DoubleUtils.getRoundingNum(yearSpecific.getNllfdl().doubleValue() / 10000, 2));
  351. // dqvo.setNsjfdl(DoubleUtils.getRoundingNum(yearSpecific.getNfdl().doubleValue() / 10000, 2));
  352. // dqvo.setNwhssdl(DoubleUtils.getRoundingNum(yearSpecific.getNjxssdl().doubleValue() / 10000 + yearSpecific.getNcnsljxssdl().doubleValue() / 10000, 2));
  353. // dqvo.setNgzssdl(DoubleUtils.getRoundingNum(yearSpecific.getNgzssdl().doubleValue() / 10000 + yearSpecific.getNcnslgzssdl().doubleValue() / 10000, 2));
  354. // dqvo.setNxdssdl(DoubleUtils.getRoundingNum(yearSpecific.getNxnssdl().doubleValue() / 10000 + yearSpecific.getNxdjclssdl().doubleValue() / 10000, 2));
  355. // dqvo.setNxnssdl(DoubleUtils.getRoundingNum(yearSpecific.getNdjssdl().doubleValue() / 10000 + yearSpecific.getNqxjclssdl().doubleValue() / 10000 + yearSpecific.getNxnssdl().doubleValue() / 10000 + yearSpecific.getNsdtjssdl().doubleValue() / 10000, 2));
  356. // dqvo.setNslssdl(DoubleUtils.getRoundingNum(yearSpecific.getNcwsldwssdl().doubleValue() / 10000 + yearSpecific.getNcwsltqssdl().doubleValue() / 10000, 2));
  357. // if (dqvo.getYllfdl() != 0) {
  358. // dqvo.setNfnlyl(DoubleUtils.getRoundingNum(dqvo.getNsjfdl() / dqvo.getNllfdl() * 100, 2));
  359. // dqvo.setNwhssl(DoubleUtils.getRoundingNum(dqvo.getNwhssdl() / dqvo.getNllfdl() * 100, 2));
  360. // dqvo.setNgzssl(DoubleUtils.getRoundingNum(dqvo.getNgzssdl() / dqvo.getNllfdl() * 100, 2));
  361. // dqvo.setNxdssl(DoubleUtils.getRoundingNum(dqvo.getNxdssdl() / dqvo.getNllfdl() * 100, 2));
  362. // dqvo.setNxnssl(DoubleUtils.getRoundingNum(dqvo.getNxnssdl() / dqvo.getNllfdl() * 100, 2));
  363. // dqvo.setNslssl(DoubleUtils.getRoundingNum(dqvo.getNslssdl() / dqvo.getNllfdl() * 100, 2));
  364. // } else {
  365. // dqvo.setNfnlyl(0.0);
  366. // dqvo.setNwhssl(0.0);
  367. // dqvo.setNgzssl(0.0);
  368. // dqvo.setNxdssl(0.0);
  369. // dqvo.setNxnssl(0.0);
  370. // dqvo.setNslssl(0.0);
  371. // }
  372. // }
  373. // } else {
  374. // dqvo.setNllfdl(0.0);
  375. // dqvo.setNsjfdl(0.0);
  376. // dqvo.setNwhssdl(0.0);
  377. // dqvo.setNgzssdl(0.0);
  378. // dqvo.setNxdssdl(0.0);
  379. // dqvo.setNxnssdl(0.0);
  380. // dqvo.setNslssdl(0.0);
  381. // dqvo.setNfnlyl(0.0);
  382. // dqvo.setNwhssl(0.0);
  383. // dqvo.setNgzssl(0.0);
  384. // dqvo.setNxdssl(0.0);
  385. // dqvo.setNxnssl(0.0);
  386. // dqvo.setNslssl(0.0);
  387. // }
  388. //
  389. // }
  390. /**
  391. * 获取当年专题分析上面数据
  392. *
  393. * @param companys
  394. * @param type
  395. * @param yearmonth
  396. * @param dqvo
  397. */
  398. private void setDnSpecificinfodays(String companys, String type, String yearmonth, SpecificTopVo dqvo) {
  399. QueryWrapper<TurbineInfoDay> qw = new QueryWrapper<>();
  400. qw.select("sum(llfdl) as llfdl,sum(rfdl) as rfdl,sum(gzss) as gzss,sum(jhjxss) as jhjxss,sum(fjhjxss) as fjhjxss,sum(djss) djss,sum(xnss) as xnss,sum(slss) as slss");
  401. qw.eq("to_char(record_date,'yyyy')", yearmonth.split("-")[0]);
  402. qw.groupBy("to_char(record_date,'yyyy')");
  403. List<TurbineInfoDay> yearList = iTurbineInfoDayService.list(qw);
  404. if (StringUtils.isNotEmpty(yearList)) {
  405. Optional<TurbineInfoDay> yearFirsts = yearList.stream().findFirst();
  406. if (yearFirsts.isPresent()) {
  407. TurbineInfoDay yearSpecific = yearFirsts.get();
  408. dqvo.setNllfdl(DoubleUtils.getRoundingNum(yearSpecific.getLlfdl() / 10000, 2));
  409. dqvo.setNsjfdl(DoubleUtils.getRoundingNum(yearSpecific.getRfdl().doubleValue() / 10000, 2));
  410. dqvo.setNwhssdl(DoubleUtils.getRoundingNum(yearSpecific.getJhjxss().doubleValue() / 10000 + yearSpecific.getFjhjxss().doubleValue() / 10000, 2));
  411. dqvo.setNgzssdl(DoubleUtils.getRoundingNum(yearSpecific.getGzss().doubleValue() / 10000, 2));
  412. dqvo.setNxdssdl(DoubleUtils.getRoundingNum(yearSpecific.getXnss().doubleValue() / 10000, 2));
  413. dqvo.setNxnssdl(DoubleUtils.getRoundingNum(yearSpecific.getDjss().doubleValue() / 10000, 2));
  414. dqvo.setNslssdl(DoubleUtils.getRoundingNum(yearSpecific.getSlss().doubleValue() / 10000, 2));
  415. if (dqvo.getYllfdl() != 0) {
  416. dqvo.setNfnlyl(DoubleUtils.getRoundingNum(dqvo.getNsjfdl() / dqvo.getNllfdl() * 100, 2));
  417. dqvo.setNwhssl(DoubleUtils.getRoundingNum(dqvo.getNwhssdl() / dqvo.getNllfdl() * 100, 2));
  418. dqvo.setNgzssl(DoubleUtils.getRoundingNum(dqvo.getNgzssdl() / dqvo.getNllfdl() * 100, 2));
  419. dqvo.setNxdssl(DoubleUtils.getRoundingNum(dqvo.getNxdssdl() / dqvo.getNllfdl() * 100, 2));
  420. dqvo.setNxnssl(DoubleUtils.getRoundingNum(dqvo.getNxnssdl() / dqvo.getNllfdl() * 100, 2));
  421. dqvo.setNslssl(DoubleUtils.getRoundingNum(dqvo.getNslssdl() / dqvo.getNllfdl() * 100, 2));
  422. } else {
  423. dqvo.setNfnlyl(0.0);
  424. dqvo.setNwhssl(0.0);
  425. dqvo.setNgzssl(0.0);
  426. dqvo.setNxdssl(0.0);
  427. dqvo.setNxnssl(0.0);
  428. dqvo.setNslssl(0.0);
  429. }
  430. }
  431. } else {
  432. dqvo.setNllfdl(0.0);
  433. dqvo.setNsjfdl(0.0);
  434. dqvo.setNwhssdl(0.0);
  435. dqvo.setNgzssdl(0.0);
  436. dqvo.setNxdssdl(0.0);
  437. dqvo.setNxnssdl(0.0);
  438. dqvo.setNslssdl(0.0);
  439. dqvo.setNfnlyl(0.0);
  440. dqvo.setNwhssl(0.0);
  441. dqvo.setNgzssl(0.0);
  442. dqvo.setNxdssl(0.0);
  443. dqvo.setNxnssl(0.0);
  444. dqvo.setNslssl(0.0);
  445. }
  446. }
  447. // /**
  448. // * 获取年同期专题分析上面数据
  449. // *
  450. // * @param companys
  451. // * @param dqvo
  452. // */
  453. // private void setTnSpecificinfodays(String companys, String type, String yearmonth, SpecificTopVo dqvo) throws ParseException {
  454. // String yearString = yearmonth.split("-")[0];
  455. // String year = String.valueOf(Integer.parseInt(yearString) - 1);
  456. // QueryWrapper<ProEconPowerstationInfoDay1> qw = new QueryWrapper<>();
  457. // qw.select("sum(rllfdl) as nllfdl,sum(rfdl) as nfdl,sum(rgzssdl) as ngzssdl,sum(rcnslgzssdl) as ncnslgzssdl,sum(rjxssdl) as njxssdl,sum(rcnsljxssdl) ncnsljxssdl,sum(rdjssdl) ndjssdl,sum(rqxjclssdl) as nqxjclssdl,sum(rsdtjssdl) as nsdtjssdl,sum(rxnssdl) as nxnssdl,sum(rxdtjssdl) as nxdtjssdl,sum(rxdjclssdl) as nxdjclssdl,sum(rcwsldwssdl) ncwsldwssdl,sum(rcwsltqssdl) ncwsltqssdl");
  458. // qw.eq("foreign_key_id", companys + type);
  459. // qw.eq("to_char(record_date,'yyyy')", year);
  460. // qw.groupBy("to_char(record_date,'yyyy')");
  461. // List<ProEconPowerstationInfoDay1> yearList = proEconPowerstationInfoDay1Service.list(qw);
  462. //
  463. // Optional<ProEconPowerstationInfoDay1> yearFirsts = yearList.stream().findFirst();
  464. // if (yearFirsts.isPresent()) {
  465. // ProEconPowerstationInfoDay1 yearSpecific = yearFirsts.get();
  466. // dqvo.setNllfdl(DoubleUtils.getRoundingNum(yearSpecific.getNllfdl().doubleValue() / 10000, 2));
  467. // dqvo.setNsjfdl(DoubleUtils.getRoundingNum(yearSpecific.getNfdl().doubleValue() / 10000, 2));
  468. // dqvo.setNwhssdl(DoubleUtils.getRoundingNum(yearSpecific.getNjxssdl().doubleValue() / 10000 + yearSpecific.getNcnsljxssdl().doubleValue() / 10000, 2));
  469. // dqvo.setNgzssdl(DoubleUtils.getRoundingNum(yearSpecific.getNgzssdl().doubleValue() / 10000 + yearSpecific.getNcnslgzssdl().doubleValue() / 10000, 2));
  470. // dqvo.setNxdssdl(DoubleUtils.getRoundingNum(yearSpecific.getNxnssdl().doubleValue() / 10000 + yearSpecific.getNxdjclssdl().doubleValue() / 10000, 2));
  471. // dqvo.setNxnssdl(DoubleUtils.getRoundingNum(yearSpecific.getNdjssdl().doubleValue() / 10000 + yearSpecific.getNqxjclssdl().doubleValue() / 10000 + yearSpecific.getNxnssdl().doubleValue() / 10000 + yearSpecific.getNsdtjssdl().doubleValue() / 10000, 2));
  472. // dqvo.setNslssdl(DoubleUtils.getRoundingNum(yearSpecific.getNcwsldwssdl().doubleValue() / 10000 + yearSpecific.getNcwsltqssdl().doubleValue() / 10000, 2));
  473. // if (dqvo.getYllfdl() != 0) {
  474. // dqvo.setNfnlyl(DoubleUtils.getRoundingNum(dqvo.getNsjfdl() / dqvo.getNllfdl() * 100, 2));
  475. // dqvo.setNwhssl(DoubleUtils.getRoundingNum(dqvo.getNwhssdl() / dqvo.getNllfdl() * 100, 2));
  476. // dqvo.setNgzssl(DoubleUtils.getRoundingNum(dqvo.getNgzssdl() / dqvo.getNllfdl() * 100, 2));
  477. // dqvo.setNxdssl(DoubleUtils.getRoundingNum(dqvo.getNxdssdl() / dqvo.getNllfdl() * 100, 2));
  478. // dqvo.setNxnssl(DoubleUtils.getRoundingNum(dqvo.getNxnssdl() / dqvo.getNllfdl() * 100, 2));
  479. // dqvo.setNslssl(DoubleUtils.getRoundingNum(dqvo.getNslssdl() / dqvo.getNllfdl() * 100, 2));
  480. // } else {
  481. // dqvo.setNfnlyl(0.0);
  482. // dqvo.setNwhssl(0.0);
  483. // dqvo.setNgzssl(0.0);
  484. // dqvo.setNxdssl(0.0);
  485. // dqvo.setNxnssl(0.0);
  486. // dqvo.setNslssl(0.0);
  487. // }
  488. // } else {
  489. // dqvo.setNllfdl(0.0);
  490. // dqvo.setNsjfdl(0.0);
  491. // dqvo.setNwhssdl(0.0);
  492. // dqvo.setNgzssdl(0.0);
  493. // dqvo.setNxdssdl(0.0);
  494. // dqvo.setNxnssdl(0.0);
  495. // dqvo.setNslssdl(0.0);
  496. // dqvo.setNfnlyl(0.0);
  497. // dqvo.setNwhssl(0.0);
  498. // dqvo.setNgzssl(0.0);
  499. // dqvo.setNxdssl(0.0);
  500. // dqvo.setNxnssl(0.0);
  501. // dqvo.setNslssl(0.0);
  502. // }
  503. // }
  504. /**
  505. * 获取年同期专题分析上面数据
  506. *
  507. * @param companys
  508. * @param dqvo
  509. */
  510. private void setTnSpecificinfodays(String companys, String type, String yearmonth, SpecificTopVo dqvo) throws ParseException {
  511. String yearString = yearmonth.split("-")[0];
  512. String year = String.valueOf(Integer.parseInt(yearString) - 1);
  513. QueryWrapper<TurbineInfoDay> qw = new QueryWrapper<>();
  514. qw.select("sum(llfdl) as llfdl,sum(rfdl) as rfdl,sum(gzss) as gzss,sum(jhjxss) as jhjxss,sum(fjhjxss) as fjhjxss,sum(djss) djss,sum(xnss) as xnss,sum(slss) as slss");
  515. qw.eq("to_char(record_date,'yyyy')", year);
  516. qw.groupBy("to_char(record_date,'yyyy')");
  517. List<TurbineInfoDay> yearList = iTurbineInfoDayService.list(qw);
  518. Optional<TurbineInfoDay> yearFirsts = yearList.stream().findFirst();
  519. if (yearFirsts.isPresent()) {
  520. TurbineInfoDay yearSpecific = yearFirsts.get();
  521. dqvo.setNllfdl(DoubleUtils.getRoundingNum(yearSpecific.getLlfdl() / 10000, 2));
  522. dqvo.setNsjfdl(DoubleUtils.getRoundingNum(yearSpecific.getRfdl().doubleValue() / 10000, 2));
  523. dqvo.setNwhssdl(DoubleUtils.getRoundingNum(yearSpecific.getJhjxss().doubleValue() / 10000 + yearSpecific.getFjhjxss().doubleValue() / 10000, 2));
  524. dqvo.setNgzssdl(DoubleUtils.getRoundingNum(yearSpecific.getGzss().doubleValue() / 10000, 2));
  525. dqvo.setNxdssdl(DoubleUtils.getRoundingNum(yearSpecific.getXnss().doubleValue() / 10000, 2));
  526. dqvo.setNxnssdl(DoubleUtils.getRoundingNum(yearSpecific.getDjss().doubleValue() / 10000, 2));
  527. dqvo.setNslssdl(DoubleUtils.getRoundingNum(yearSpecific.getSlss().doubleValue() / 10000, 2));
  528. if (dqvo.getYllfdl() != 0) {
  529. dqvo.setNfnlyl(DoubleUtils.getRoundingNum(dqvo.getNsjfdl() / dqvo.getNllfdl() * 100, 2));
  530. dqvo.setNwhssl(DoubleUtils.getRoundingNum(dqvo.getNwhssdl() / dqvo.getNllfdl() * 100, 2));
  531. dqvo.setNgzssl(DoubleUtils.getRoundingNum(dqvo.getNgzssdl() / dqvo.getNllfdl() * 100, 2));
  532. dqvo.setNxdssl(DoubleUtils.getRoundingNum(dqvo.getNxdssdl() / dqvo.getNllfdl() * 100, 2));
  533. dqvo.setNxnssl(DoubleUtils.getRoundingNum(dqvo.getNxnssdl() / dqvo.getNllfdl() * 100, 2));
  534. dqvo.setNslssl(DoubleUtils.getRoundingNum(dqvo.getNslssdl() / dqvo.getNllfdl() * 100, 2));
  535. } else {
  536. dqvo.setNfnlyl(0.0);
  537. dqvo.setNwhssl(0.0);
  538. dqvo.setNgzssl(0.0);
  539. dqvo.setNxdssl(0.0);
  540. dqvo.setNxnssl(0.0);
  541. dqvo.setNslssl(0.0);
  542. }
  543. } else {
  544. dqvo.setNllfdl(0.0);
  545. dqvo.setNsjfdl(0.0);
  546. dqvo.setNwhssdl(0.0);
  547. dqvo.setNgzssdl(0.0);
  548. dqvo.setNxdssdl(0.0);
  549. dqvo.setNxnssdl(0.0);
  550. dqvo.setNslssdl(0.0);
  551. dqvo.setNfnlyl(0.0);
  552. dqvo.setNwhssl(0.0);
  553. dqvo.setNgzssl(0.0);
  554. dqvo.setNxdssl(0.0);
  555. dqvo.setNxnssl(0.0);
  556. dqvo.setNslssl(0.0);
  557. }
  558. }
  559. /**
  560. * 获取专题分析中间部分
  561. *
  562. * @param yearmonth
  563. * @return
  564. */
  565. public Map<String, List<SpecificCenterVo>> maincenterlist2(String companys, String type, String yearmonth) throws ParseException {
  566. Map<String, ProBasicPowerstation> wpmap = CacheContext.wpmap;
  567. Date date = DateUtils.parseDate(yearmonth + "-01");
  568. Calendar c = Calendar.getInstance();
  569. c.setTime(date);
  570. int year = c.get(Calendar.YEAR);
  571. int month = c.get(Calendar.MONTH) + 1;
  572. //定义左边部分的结果list
  573. List<SpecificCenterVo> monthresultList = new ArrayList<>();
  574. //设置当月数据
  575. setCenterDyInfo(companys, type, yearmonth, monthresultList);
  576. //设置同期数据
  577. setCenterYtqInfo(companys, type, yearmonth, monthresultList);
  578. //设置比较数据
  579. monthresultList.stream().forEach(i -> {
  580. i.setMtbfCompare(null == i.getTqmtbf() ? 2 : (i.getMtbf() > i.getTqmtbf() ? 1 : 2));
  581. i.setMttrCompare(null == i.getTqmttr() ? 2 : (i.getMttr() > i.getTqmttr() ? 1 : 2));
  582. i.setFwjslCompare(null == i.getTqfwjsl() ? 2 : (i.getFwjsl() > i.getTqfwjsl() ? 1 : 2));
  583. i.setZtzhlCompare(null == i.getTqztzhl() ? 2 : (i.getZtzhl() > i.getTqztzhl() ? 1 : 2));
  584. i.setXqjslCompare(null == i.getTqxqjsl() ? 2 : (i.getXqjsl() > i.getTqxqjsl() ? 1 : 2));
  585. });
  586. //定义右边部分的结果list
  587. List<SpecificCenterVo> yearresultList = new ArrayList<>();
  588. //设置当年数据
  589. setCenterDnInfo(companys, type, yearmonth, yearresultList);
  590. //设置同期数据
  591. setCenterNtqInfo(companys, type, yearmonth, yearresultList);
  592. //设置比较数据
  593. yearresultList.stream().forEach(i -> {
  594. i.setMtbfCompare(null == i.getTqmtbf() ? 2 : (i.getMtbf() > i.getTqmtbf() ? 1 : 2));
  595. i.setMttrCompare(null == i.getTqmttr() ? 2 : (i.getMttr() > i.getTqmttr() ? 1 : 2));
  596. i.setFwjslCompare(null == i.getTqfwjsl() ? 2 : (i.getFwjsl() > i.getTqfwjsl() ? 1 : 2));
  597. i.setZtzhlCompare(null == i.getTqztzhl() ? 2 : (i.getZtzhl() > i.getTqztzhl() ? 1 : 2));
  598. i.setXqjslCompare(null == i.getTqxqjsl() ? 2 : (i.getXqjsl() > i.getTqxqjsl() ? 1 : 2));
  599. });
  600. //封装最终返回结果
  601. monthresultList.stream().forEach(i -> {
  602. i.setOrdernum(wpmap.get(i.getWpid()).getOrderNum());
  603. i.setWpid(wpmap.get(i.getWpid()).getAname());
  604. });
  605. yearresultList.stream().forEach(i -> {
  606. i.setOrdernum(wpmap.get(i.getWpid()).getOrderNum());
  607. i.setWpid(wpmap.get(i.getWpid()).getAname());
  608. });
  609. SortUtils.sort(monthresultList, "ordernum", SortUtils.ASC);
  610. SortUtils.sort(yearresultList, "ordernum", SortUtils.ASC);
  611. Map<String, List<SpecificCenterVo>> resultMap = new HashMap<>();
  612. resultMap.put("当月", monthresultList);
  613. resultMap.put("当年", yearresultList);
  614. return resultMap;
  615. }
  616. public Map<String, List<SpecificCenterVo>> maincenterlist(String companys, String type, String yearmonth) throws ParseException {
  617. Map<String, ProBasicPowerstation> wpmap = CacheContext.wpmap;
  618. Date date = DateUtils.parseDate(yearmonth + "-01");
  619. Calendar c = Calendar.getInstance();
  620. c.setTime(date);
  621. int year = c.get(Calendar.YEAR);
  622. int month = c.get(Calendar.MONTH) + 1;
  623. //定义左边部分的结果list
  624. List<SpecificCenterVo> monthresultList = new ArrayList<>();
  625. //设置当月数据
  626. setCenterDyInfo(companys, type, yearmonth, monthresultList);
  627. //设置同期数据
  628. setCenterYtqInfo(companys, type, yearmonth, monthresultList);
  629. //设置比较数据
  630. monthresultList.stream().forEach(i -> {
  631. i.setMtbfCompare(null == i.getTqmtbf() ? 2 : (i.getMtbf() > i.getTqmtbf() ? 1 : 2));
  632. i.setMttrCompare(null == i.getTqmttr() ? 2 : (i.getMttr() > i.getTqmttr() ? 1 : 2));
  633. i.setFwjslCompare(null == i.getTqfwjsl() ? 2 : (i.getFwjsl() > i.getTqfwjsl() ? 1 : 2));
  634. i.setZtzhlCompare(null == i.getTqztzhl() ? 2 : (i.getZtzhl() > i.getTqztzhl() ? 1 : 2));
  635. i.setXqjslCompare(null == i.getTqxqjsl() ? 2 : (i.getXqjsl() > i.getTqxqjsl() ? 1 : 2));
  636. });
  637. //定义右边部分的结果list
  638. List<SpecificCenterVo> yearresultList = new ArrayList<>();
  639. //设置当年数据
  640. setCenterDnInfo(companys, type, yearmonth, yearresultList);
  641. //设置同期数据
  642. setCenterNtqInfo(companys, type, yearmonth, yearresultList);
  643. //设置比较数据
  644. yearresultList.stream().forEach(i -> {
  645. i.setMtbfCompare(null == i.getTqmtbf() ? 2 : (i.getMtbf() > i.getTqmtbf() ? 1 : 2));
  646. i.setMttrCompare(null == i.getTqmttr() ? 2 : (i.getMttr() > i.getTqmttr() ? 1 : 2));
  647. i.setFwjslCompare(null == i.getTqfwjsl() ? 2 : (i.getFwjsl() > i.getTqfwjsl() ? 1 : 2));
  648. i.setZtzhlCompare(null == i.getTqztzhl() ? 2 : (i.getZtzhl() > i.getTqztzhl() ? 1 : 2));
  649. i.setXqjslCompare(null == i.getTqxqjsl() ? 2 : (i.getXqjsl() > i.getTqxqjsl() ? 1 : 2));
  650. });
  651. //封装最终返回结果
  652. monthresultList.stream().forEach(i -> {
  653. i.setOrdernum(wpmap.get(i.getWpid()).getOrderNum());
  654. i.setWpid(wpmap.get(i.getWpid()).getAname());
  655. });
  656. yearresultList.stream().forEach(i -> {
  657. i.setOrdernum(wpmap.get(i.getWpid()).getOrderNum());
  658. i.setWpid(wpmap.get(i.getWpid()).getAname());
  659. });
  660. SortUtils.sort(monthresultList, "ordernum", SortUtils.ASC);
  661. SortUtils.sort(yearresultList, "ordernum", SortUtils.ASC);
  662. Map<String, List<SpecificCenterVo>> resultMap = new HashMap<>();
  663. resultMap.put("当月", monthresultList);
  664. resultMap.put("当年", yearresultList);
  665. return resultMap;
  666. }
  667. /**
  668. * 设置月同期mtbf,mttr,复位及时率,状态转换率,消缺及时率
  669. *
  670. * @param companys
  671. * @param type
  672. * @param yearmonth
  673. * @param monthresultList
  674. */
  675. private void setCenterYtqInfo(String companys, String type, String yearmonth, List<SpecificCenterVo> monthresultList) {
  676. // HttpServletRequest request = ((ServletRequestAttributes) (RequestContextHolder.currentRequestAttributes())).getRequest();
  677. // List<ProBasicPowerstation> wplsToken = tokenService.getWpls(request);
  678. List<ProBasicPowerstation> wplsToken = CacheContext.wpls;
  679. String yearString = yearmonth.split("-")[0];
  680. String year = String.valueOf(Integer.parseInt(yearString) - 1);
  681. String yearMonth = year + "-" + yearmonth.split("-")[1];
  682. QueryWrapper<ProEconPowerstationInfoDay4> qw = new QueryWrapper<>();
  683. QueryWrapper<ProEconPowerstationInfoDay7> qw1 = new QueryWrapper<>();
  684. qw.select("foreign_key_id,sum(rmtbf) ymtbf,sum(rmttr) ymttr,avg(rfwjsl) yfwjsl,avg(rztzhjsl) yztzhjsl,avg(rgzxqjsl) ygzxqjsl");
  685. qw1.select("foreign_key_id,avg(rxtxlpr) yxtxlpr,avg(rlsl) ylsl,avg(rnbqzhxl) ynbqzhxl");
  686. qw.eq("location", "wp");
  687. qw1.eq("location", "wp");
  688. if (type.endsWith("-1")) {
  689. qw.like("foreign_key_id", "_FDC_");
  690. qw1.like("foreign_key_id", "_FDC_");
  691. } else if (type.endsWith("-2")) {
  692. qw.like("foreign_key_id", "_GDC_");
  693. qw1.like("foreign_key_id", "_GDC_");
  694. }
  695. if (companys.endsWith("ZGS")) {
  696. qw.in("foreign_key_id", wplsToken.stream().filter(wp -> wp.getCompanyId().equals(companys)).map(wp -> wp.getId()).collect(Collectors.toList()));
  697. qw1.in("foreign_key_id", wplsToken.stream().filter(wp -> wp.getCompanyId().equals(companys)).map(wp -> wp.getId()).collect(Collectors.toList()));
  698. }
  699. qw.eq("to_char(record_date,'yyyy-MM')", yearMonth);
  700. qw1.eq("to_char(record_date,'yyyy-MM')", yearMonth);
  701. qw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  702. qw1.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  703. List<ProEconPowerstationInfoDay4> tqList = proEconPowerstationInfoDay4Service.list(qw);
  704. List<ProEconPowerstationInfoDay7> tq1List = proEconPowerstationInfoDay7Service.list(qw1);
  705. if (StringUtils.isNotEmpty(tqList)) {
  706. tqList.stream().forEach(i -> {
  707. Optional<SpecificCenterVo> optionMonth = monthresultList.stream().filter(j -> j.getWpid().equals(i.getForeignKeyId())).findFirst();
  708. SpecificCenterVo leftVo = optionMonth.get();
  709. if (optionMonth.isPresent()) {
  710. leftVo.setTqmtbf(DoubleUtils.keepPrecision(i.getYmtbf().doubleValue(), 2));
  711. leftVo.setTqmttr(DoubleUtils.keepPrecision(i.getYmttr().doubleValue(), 2));
  712. if (type.equals("-1")) {
  713. leftVo.setTqfwjsl(DoubleUtils.keepPrecision(i.getYfwjsl().doubleValue(), 2));
  714. leftVo.setTqztzhl(DoubleUtils.keepPrecision(i.getYztzhjsl().doubleValue(), 2));
  715. leftVo.setTqxqjsl(DoubleUtils.keepPrecision(i.getYgzxqjsl().doubleValue(), 2));
  716. } else if (type.equals("-2")) {
  717. Optional<ProEconPowerstationInfoDay7> first = tq1List.stream().filter(d -> d.getForeignKeyId().equals(i.getForeignKeyId())).findFirst();
  718. if (first.isPresent()) {
  719. ProEconPowerstationInfoDay7 proEconPowerstationInfoDay7 = first.get();
  720. leftVo.setFwjsl(DoubleUtils.keepPrecision(proEconPowerstationInfoDay7.getYxtxlpr().doubleValue(), 2));
  721. leftVo.setZtzhl(DoubleUtils.keepPrecision(proEconPowerstationInfoDay7.getYlsl().doubleValue(), 2));
  722. leftVo.setXqjsl(DoubleUtils.keepPrecision(proEconPowerstationInfoDay7.getYnbqzhxl().doubleValue(), 2));
  723. } else {
  724. leftVo.setFwjsl(0.0);
  725. leftVo.setZtzhl(0.0);
  726. leftVo.setXqjsl(0.0);
  727. }
  728. }
  729. } else {
  730. leftVo.setTqmtbf(0.0);
  731. leftVo.setTqmttr(0.0);
  732. leftVo.setTqfwjsl(0.0);
  733. leftVo.setTqztzhl(0.0);
  734. leftVo.setTqxqjsl(0.0);
  735. }
  736. });
  737. } else {
  738. List<ProBasicPowerstation> wpls = benchmarkingService.wpByCplist(companys, type);
  739. wpls.stream().forEach(wp -> {
  740. Optional<SpecificCenterVo> optionMonth = monthresultList.stream().filter(j -> j.getWpid().equals(wp.getId())).findFirst();
  741. if (optionMonth.isPresent()) {
  742. SpecificCenterVo leftVo = optionMonth.get();
  743. leftVo.setTqmtbf(0.0);
  744. leftVo.setTqmttr(0.0);
  745. leftVo.setTqfwjsl(0.0);
  746. leftVo.setTqztzhl(0.0);
  747. leftVo.setTqxqjsl(0.0);
  748. }
  749. });
  750. }
  751. }
  752. /**
  753. * 设置年同期mtbf,mttr,复位及时率,状态转换率,消缺及时率
  754. *
  755. * @param companys
  756. * @param yearresultList
  757. */
  758. private void setCenterNtqInfo(String companys, String type, String yearmonth, List<SpecificCenterVo> yearresultList) throws ParseException {
  759. HttpServletRequest request = ((ServletRequestAttributes) (RequestContextHolder.currentRequestAttributes())).getRequest();
  760. // List<ProBasicPowerstation> wplsToken = tokenService.getWpls(request);
  761. List<ProBasicPowerstation> wplsToken = CacheContext.wpls;
  762. String yearString = yearmonth.split("-")[0];
  763. String year = String.valueOf(Integer.parseInt(yearString) - 1);
  764. QueryWrapper<ProEconPowerstationInfoDay4> qw = new QueryWrapper<>();
  765. QueryWrapper<ProEconPowerstationInfoDay7> qw1 = new QueryWrapper<>();
  766. qw.select("foreign_key_id,sum(rmtbf) nmtbf,sum(rmttr) nmttr,avg(rfwjsl) nfwjsl,avg(rztzhjsl) nztzhjsl,avg(rgzxqjsl) ngzxqjsl");
  767. qw1.select("foreign_key_id,avg(rxtxlpr) nxtxlpr,avg(rlsl) nlsl,avg(rnbqzhxl) nnbqzhxl");
  768. qw.eq("location", "wp");
  769. qw1.eq("location", "wp");
  770. if (type.endsWith("-1")) {
  771. qw.like("foreign_key_id", "_FDC_");
  772. qw1.like("foreign_key_id", "_FDC_");
  773. } else if (type.endsWith("-2")) {
  774. qw.like("foreign_key_id", "_GDC_");
  775. qw1.like("foreign_key_id", "_GDC_");
  776. }
  777. if (companys.endsWith("ZGS")) {
  778. qw.in("foreign_key_id", wplsToken.stream().filter(wp -> wp.getCompanyId().equals(companys)).map(wp -> wp.getId()).collect(Collectors.toList()));
  779. qw1.in("foreign_key_id", wplsToken.stream().filter(wp -> wp.getCompanyId().equals(companys)).map(wp -> wp.getId()).collect(Collectors.toList()));
  780. }
  781. qw.eq("to_char(record_date,'yyyy')", year);
  782. qw1.eq("to_char(record_date,'yyyy')", year);
  783. qw.groupBy("to_char(record_date,'yyyy'),foreign_key_id");
  784. qw1.groupBy("to_char(record_date,'yyyy'),foreign_key_id");
  785. List<ProEconPowerstationInfoDay4> tqList = proEconPowerstationInfoDay4Service.list(qw);
  786. List<ProEconPowerstationInfoDay7> tq1List = proEconPowerstationInfoDay7Service.list(qw1);
  787. if (StringUtils.isNotEmpty(tqList)) {
  788. tqList.stream().forEach(i -> {
  789. Optional<SpecificCenterVo> optionYear = yearresultList.stream().filter(j -> j.getWpid().equals(i.getWindpowerstationId())).findFirst();
  790. if (optionYear.isPresent()) {
  791. SpecificCenterVo rightVo = optionYear.get();
  792. rightVo.setTqmtbf(DoubleUtils.keepPrecision(i.getNmtbf().doubleValue(), 2));
  793. rightVo.setTqmttr(DoubleUtils.keepPrecision(i.getNmttr().doubleValue(), 2));
  794. if (type.equals("-1")) {
  795. rightVo.setTqfwjsl(DoubleUtils.keepPrecision(i.getNfwjsl().doubleValue(), 2));
  796. rightVo.setTqztzhl(DoubleUtils.keepPrecision(i.getNztzhjsl().doubleValue(), 2));
  797. rightVo.setTqxqjsl(DoubleUtils.keepPrecision(i.getNgzxqjsl().doubleValue(), 2));
  798. } else if (type.equals("-2")) {
  799. Optional<ProEconPowerstationInfoDay7> first = tq1List.stream().filter(d -> d.getForeignKeyId().equals(i.getForeignKeyId())).findFirst();
  800. if (first.isPresent()) {
  801. ProEconPowerstationInfoDay7 proEconPowerstationInfoDay7 = first.get();
  802. rightVo.setFwjsl(DoubleUtils.keepPrecision(proEconPowerstationInfoDay7.getNxtxlpr().doubleValue(), 2));
  803. rightVo.setZtzhl(DoubleUtils.keepPrecision(proEconPowerstationInfoDay7.getNlsl().doubleValue(), 2));
  804. rightVo.setXqjsl(DoubleUtils.keepPrecision(proEconPowerstationInfoDay7.getNnbqzhxl().doubleValue(), 2));
  805. } else {
  806. rightVo.setFwjsl(0.0);
  807. rightVo.setZtzhl(0.0);
  808. rightVo.setXqjsl(0.0);
  809. }
  810. }
  811. }
  812. });
  813. } else {
  814. List<ProBasicPowerstation> wpls = benchmarkingService.wpByCplist(companys, type);
  815. wpls.stream().forEach(wp -> {
  816. Optional<SpecificCenterVo> optionMonth = yearresultList.stream().filter(j -> j.getWpid().equals(wp.getId())).findFirst();
  817. if (optionMonth.isPresent()) {
  818. SpecificCenterVo leftVo = optionMonth.get();
  819. leftVo.setTqmtbf(0.0);
  820. leftVo.setTqmttr(0.0);
  821. leftVo.setTqfwjsl(0.0);
  822. leftVo.setTqztzhl(0.0);
  823. leftVo.setTqxqjsl(0.0);
  824. }
  825. });
  826. }
  827. }
  828. /**
  829. * 设置当月mtbf,mttr,复位及时率,状态转换率,消缺及时率
  830. *
  831. * @param companys
  832. * @param type
  833. * @param monthresultList
  834. */
  835. private void setCenterDyInfo(String companys, String type, String yearmonth, List<SpecificCenterVo> monthresultList) {
  836. HttpServletRequest request = ((ServletRequestAttributes) (RequestContextHolder.currentRequestAttributes())).getRequest();
  837. // List<ProBasicPowerstation> wplsToken = tokenService.getWpls(request);
  838. List<ProBasicPowerstation> wplsToken = CacheContext.wpls;
  839. QueryWrapper<ProEconPowerstationInfoDay4> qw = new QueryWrapper<>();
  840. QueryWrapper<ProEconPowerstationInfoDay7> qw1 = new QueryWrapper<>();
  841. qw.select("foreign_key_id,sum(rmtbf) ymtbf,sum(rmttr) ymttr,avg(rfwjsl) yfwjsl,avg(rztzhjsl) yztzhjsl,avg(rgzxqjsl) ygzxqjsl");
  842. qw1.select("foreign_key_id,avg(rxtxlpr) yxtxlpr,avg(rlsl) ylsl,avg(rnbqzhxl) ynbqzhxl");
  843. qw.eq("location", "wp");
  844. qw1.eq("location", "wp");
  845. if (type.endsWith("-1")) {
  846. qw.like("foreign_key_id", "_FDC_");
  847. qw1.like("foreign_key_id", "_FDC_");
  848. } else if (type.endsWith("-2")) {
  849. qw.like("foreign_key_id", "_GDC_");
  850. qw1.like("foreign_key_id", "_GDC_");
  851. }
  852. if (companys.endsWith("ZGS")) {
  853. qw.in("foreign_key_id", wplsToken.stream().filter(wp -> wp.getCompanyId().equals(companys)).map(wp -> wp.getId()).collect(Collectors.toList()));
  854. qw1.in("foreign_key_id", wplsToken.stream().filter(wp -> wp.getCompanyId().equals(companys)).map(wp -> wp.getId()).collect(Collectors.toList()));
  855. }
  856. qw.eq("to_char(record_date,'yyyy-MM')", yearmonth);
  857. qw1.eq("to_char(record_date,'yyyy-MM')", yearmonth);
  858. qw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  859. qw1.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  860. List<ProEconPowerstationInfoDay4> dyList = proEconPowerstationInfoDay4Service.list(qw);
  861. List<ProEconPowerstationInfoDay7> dy1List = proEconPowerstationInfoDay7Service.list(qw1);
  862. if (StringUtils.isNotEmpty(dyList)) {
  863. dyList.stream().forEach(i -> {
  864. SpecificCenterVo leftVo = new SpecificCenterVo();
  865. leftVo.setWpid(i.getForeignKeyId());
  866. leftVo.setMtbf(DoubleUtils.keepPrecision(i.getYmtbf().doubleValue(), 2));
  867. leftVo.setMttr(DoubleUtils.keepPrecision(i.getYmttr().doubleValue(), 2));
  868. if (type.equals("-1")) {
  869. leftVo.setFwjsl(DoubleUtils.keepPrecision(i.getYfwjsl().doubleValue(), 2));
  870. leftVo.setZtzhl(DoubleUtils.keepPrecision(i.getYztzhjsl().doubleValue(), 2));
  871. leftVo.setXqjsl(DoubleUtils.keepPrecision(i.getYgzxqjsl().doubleValue(), 2));
  872. } else if (type.equals("-2")) {
  873. Optional<ProEconPowerstationInfoDay7> first = dy1List.stream().filter(d -> d.getForeignKeyId().equals(i.getForeignKeyId())).findFirst();
  874. if (first.isPresent()) {
  875. ProEconPowerstationInfoDay7 proEconPowerstationInfoDay7 = first.get();
  876. leftVo.setFwjsl(DoubleUtils.keepPrecision(proEconPowerstationInfoDay7.getYxtxlpr().doubleValue(), 2));
  877. leftVo.setZtzhl(DoubleUtils.keepPrecision(proEconPowerstationInfoDay7.getYlsl().doubleValue(), 2));
  878. leftVo.setXqjsl(DoubleUtils.keepPrecision(proEconPowerstationInfoDay7.getYnbqzhxl().doubleValue(), 2));
  879. } else {
  880. leftVo.setFwjsl(0.0);
  881. leftVo.setZtzhl(0.0);
  882. leftVo.setXqjsl(0.0);
  883. }
  884. }
  885. monthresultList.add(leftVo);
  886. });
  887. } else {
  888. List<ProBasicPowerstation> wpls = benchmarkingService.wpByCplist(companys, type);
  889. wpls.stream().forEach(i -> {
  890. SpecificCenterVo leftVo = new SpecificCenterVo();
  891. leftVo.setWpid(i.getId());
  892. leftVo.setMtbf(0.0);
  893. leftVo.setMttr(0.0);
  894. leftVo.setFwjsl(0.0);
  895. leftVo.setZtzhl(0.0);
  896. leftVo.setXqjsl(0.0);
  897. monthresultList.add(leftVo);
  898. });
  899. }
  900. }
  901. /**
  902. * 设置当年mtbf,mttr,复位及时率,状态转换率,消缺及时率
  903. *
  904. * @param companys
  905. * @param yearresultList
  906. */
  907. private void setCenterDnInfo(String companys, String type, String yearmonth, List<SpecificCenterVo> yearresultList) {
  908. HttpServletRequest request = ((ServletRequestAttributes) (RequestContextHolder.currentRequestAttributes())).getRequest();
  909. // List<ProBasicPowerstation> wplsToken = tokenService.getWpls(request);
  910. List<ProBasicPowerstation> wplsToken = CacheContext.wpls;
  911. QueryWrapper<ProEconPowerstationInfoDay4> qw = new QueryWrapper<>();
  912. QueryWrapper<ProEconPowerstationInfoDay7> qw1 = new QueryWrapper<>();
  913. qw.select("foreign_key_id,sum(rmtbf) nmtbf,sum(rmttr) nmttr,avg(rfwjsl) nfwjsl,avg(rztzhjsl) nztzhjsl,avg(rgzxqjsl) ngzxqjsl");
  914. qw1.select("foreign_key_id,avg(rxtxlpr) nxtxlpr,avg(rlsl) nlsl,avg(rnbqzhxl) nnbqzhxl");
  915. qw.eq("location", "wp");
  916. qw1.eq("location", "wp");
  917. if (type.endsWith("-1")) {
  918. qw.like("foreign_key_id", "_FDC_");
  919. qw1.like("foreign_key_id", "_FDC_");
  920. } else if (type.endsWith("-2")) {
  921. qw.like("foreign_key_id", "_GDC_");
  922. qw1.like("foreign_key_id", "_GDC_");
  923. }
  924. if (companys.endsWith("ZGS")) {
  925. qw.in("foreign_key_id", wplsToken.stream().filter(wp -> wp.getCompanyId().equals(companys)).map(wp -> wp.getId()).collect(Collectors.toList()));
  926. qw1.in("foreign_key_id", wplsToken.stream().filter(wp -> wp.getCompanyId().equals(companys)).map(wp -> wp.getId()).collect(Collectors.toList()));
  927. }
  928. qw.eq("to_char(record_date,'yyyy')", yearmonth.split("-")[0]);
  929. qw1.eq("to_char(record_date,'yyyy')", yearmonth.split("-")[0]);
  930. qw.groupBy("to_char(record_date,'yyyy'),foreign_key_id");
  931. qw1.groupBy("to_char(record_date,'yyyy'),foreign_key_id");
  932. List<ProEconPowerstationInfoDay4> dyList = proEconPowerstationInfoDay4Service.list(qw);
  933. List<ProEconPowerstationInfoDay7> dy1List = proEconPowerstationInfoDay7Service.list(qw1);
  934. if (StringUtils.isNotEmpty(dyList)) {
  935. dyList.stream().forEach(i -> {
  936. SpecificCenterVo rightVo = new SpecificCenterVo();
  937. rightVo.setWpid(i.getForeignKeyId());
  938. rightVo.setMtbf(DoubleUtils.keepPrecision(i.getNmtbf().doubleValue(), 2));
  939. rightVo.setMttr(DoubleUtils.keepPrecision(i.getNmttr().doubleValue(), 2));
  940. if (type.equals("-1")) {
  941. rightVo.setFwjsl(DoubleUtils.keepPrecision(i.getNfwjsl().doubleValue(), 2));
  942. rightVo.setZtzhl(DoubleUtils.keepPrecision(i.getNztzhjsl().doubleValue(), 2));
  943. rightVo.setXqjsl(DoubleUtils.keepPrecision(i.getNgzxqjsl().doubleValue(), 2));
  944. } else if (type.equals("-2")) {
  945. Optional<ProEconPowerstationInfoDay7> first = dy1List.stream().filter(d -> d.getForeignKeyId().equals(i.getForeignKeyId())).findFirst();
  946. if (first.isPresent()) {
  947. ProEconPowerstationInfoDay7 proEconPowerstationInfoDay7 = first.get();
  948. rightVo.setFwjsl(DoubleUtils.keepPrecision(proEconPowerstationInfoDay7.getNxtxlpr().doubleValue(), 2));
  949. rightVo.setZtzhl(DoubleUtils.keepPrecision(proEconPowerstationInfoDay7.getNlsl().doubleValue(), 2));
  950. rightVo.setXqjsl(DoubleUtils.keepPrecision(proEconPowerstationInfoDay7.getNnbqzhxl().doubleValue(), 2));
  951. } else {
  952. rightVo.setFwjsl(0.0);
  953. rightVo.setZtzhl(0.0);
  954. rightVo.setXqjsl(0.0);
  955. }
  956. }
  957. yearresultList.add(rightVo);
  958. });
  959. } else {
  960. List<ProBasicPowerstation> wpls = benchmarkingService.wpByCplist(companys, type);
  961. wpls.stream().forEach(i -> {
  962. SpecificCenterVo rightVo = new SpecificCenterVo();
  963. rightVo.setWpid(i.getId());
  964. rightVo.setMtbf(0.0);
  965. rightVo.setMttr(0.0);
  966. rightVo.setFwjsl(0.0);
  967. rightVo.setZtzhl(0.0);
  968. rightVo.setXqjsl(0.0);
  969. yearresultList.add(rightVo);
  970. });
  971. }
  972. }
  973. /**
  974. * 获取风能利用率
  975. *
  976. * @param companys
  977. * @param type
  978. * @param year
  979. * @return
  980. */
  981. public List<SpecificTarget> fnlylList2(String companys, String type, String year) {
  982. //获取年份所有当月的数据
  983. QueryWrapper<ProEconPowerstationInfoDay1> currentqw = new QueryWrapper<>();
  984. currentqw.select("foreign_key_id,max(record_date) record_date,sum(rfdl) yfdl,sum(rllfdl) yllfdl");
  985. currentqw.eq("location", "wp");
  986. currentqw.eq("to_char(record_date,'yyyy')", year);
  987. if (type.equals("-1")) {
  988. currentqw.like("foreign_key_id", "_FDC_");
  989. } else {
  990. currentqw.like("foreign_key_id", "_GDC_");
  991. }
  992. if (companys.endsWith("ZGS") || companys.endsWith("FGS")) {
  993. currentqw.eq("company_id", companys);
  994. } else {
  995. currentqw.eq("region_id", companys);
  996. }
  997. currentqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  998. List<ProEconPowerstationInfoDay1> currentList = proEconPowerstationInfoDay1Service.list(currentqw);
  999. currentqw.clear();
  1000. currentqw.select("foreign_key_id,max(record_date) record_date,sum(rfdl) yfdl,sum(rllfdl) yllfdl");
  1001. currentqw.eq("foreign_key_id", companys + type);
  1002. currentqw.eq("to_char(record_date,'yyyy')", year);
  1003. currentqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  1004. currentList.addAll(proEconPowerstationInfoDay1Service.list(currentqw));
  1005. int subYear = Integer.parseInt(year) - 1;
  1006. QueryWrapper<ProEconPowerstationInfoDay1> sameperiodqw = new QueryWrapper<>();
  1007. sameperiodqw.select("foreign_key_id,max(record_date) record_date,sum(rfdl) yfdl,sum(rllfdl) yllfdl");
  1008. sameperiodqw.eq("location", "wp");
  1009. if (type.equals("-1")) {
  1010. currentqw.like("foreign_key_id", "_FDC_");
  1011. } else {
  1012. currentqw.like("foreign_key_id", "_GDC_");
  1013. }
  1014. if (companys.endsWith("ZGS") || companys.endsWith("FGS")) {
  1015. currentqw.eq("company_id", companys);
  1016. } else {
  1017. currentqw.eq("region_id", companys);
  1018. }
  1019. sameperiodqw.eq("to_char(record_date,'yyyy')", String.valueOf(subYear));
  1020. sameperiodqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  1021. List<ProEconPowerstationInfoDay1> sameperiodList = proEconPowerstationInfoDay1Service.list(sameperiodqw);
  1022. sameperiodqw.clear();
  1023. sameperiodqw.select("foreign_key_id,max(record_date) record_date,sum(rfdl) yfdl,sum(rllfdl) yllfdl");
  1024. sameperiodqw.eq("foreign_key_id", companys + type);
  1025. sameperiodqw.eq("to_char(record_date,'yyyy')", String.valueOf(subYear));
  1026. sameperiodqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  1027. sameperiodList.addAll(proEconPowerstationInfoDay1Service.list(sameperiodqw));
  1028. //合并当月与同期数据为返回结果
  1029. List<SpecificTargetVo> resultList = new ArrayList<>();
  1030. currentList.stream().forEach(i -> {
  1031. SpecificTargetVo vo = new SpecificTargetVo();
  1032. String wpid = i.getForeignKeyId();
  1033. vo.setWpid(wpid);
  1034. if (wpid.contains("_ZGS") || wpid.contains("_FGS" + type)) {
  1035. vo.setWpname(CacheContext.cpmap.get(companys).getAname());
  1036. } else if (wpid.contains("_RGN")) {
  1037. vo.setWpname(CacheContext.rgmap.get(companys).getAname());
  1038. } else {
  1039. vo.setWpname(CacheContext.wpmap.get(wpid).getAname());
  1040. }
  1041. vo.setYear(DateUtils.getYear(i.getRecordDate()));
  1042. vo.setMonth(DateUtils.getMonth(i.getRecordDate()));
  1043. vo.setCurrent(DoubleUtils.keepPrecision(i.getYllfdl().doubleValue() != 0 ? i.getYfdl().doubleValue() / i.getYllfdl().doubleValue() * 100 : 0, 2));
  1044. resultList.add(vo);
  1045. });
  1046. resultList.stream().forEach(i -> {
  1047. Optional<ProEconPowerstationInfoDay1> optional = sameperiodList.stream()
  1048. .filter(j -> j.getForeignKeyId().equals(i.getWpid()) && DateUtils.getMonth(j.getRecordDate()) == (i.getMonth()))
  1049. .findFirst();
  1050. if (optional.isPresent()) {
  1051. ProEconPowerstationInfoDay1 tqinfoday = optional.get();
  1052. i.setSameperiod(DoubleUtils.keepPrecision(tqinfoday.getYllfdl().doubleValue() != 0 ? tqinfoday.getYfdl().doubleValue() / tqinfoday.getYllfdl().doubleValue() * 100 : 0, 2));
  1053. i.setCompare(i.getCurrent().compareTo(i.getSameperiod()));
  1054. } else {
  1055. i.setSameperiod(0.0);
  1056. i.setCompare(0);
  1057. }
  1058. });
  1059. List<SpecificTarget> resultendList = new ArrayList<>();
  1060. Map<String, Map<Integer, SpecificTargetVo>> map = new HashMap<>();
  1061. resultList.stream().forEach(i -> {
  1062. if (map.containsKey(i.getWpid())) {
  1063. Map<Integer, SpecificTargetVo> integerListMap = map.get(i.getWpid());
  1064. if (!integerListMap.containsKey(i.getMonth())) {
  1065. map.get(i.getWpid()).put(i.getMonth(), i);
  1066. } else {
  1067. }
  1068. } else {
  1069. Map<Integer, SpecificTargetVo> tempMap = new HashMap<>();
  1070. tempMap.put(i.getMonth(), i);
  1071. map.put(i.getWpid(), tempMap);
  1072. }
  1073. });
  1074. Set<String> wpids = map.keySet();
  1075. if (StringUtils.isNotNull(wpids)) {
  1076. wpids.stream().forEach(wpid -> {
  1077. SpecificTarget vo = new SpecificTarget();
  1078. vo.setWpid(wpid);
  1079. int orderNum = 100;
  1080. if (wpid.contains("_ZGS") || wpid.contains("_FGS" + type)) {
  1081. vo.setWpname(CacheContext.cpmap.get(companys).getAname());
  1082. } else if (wpid.contains("_RGN")) {
  1083. vo.setWpname(CacheContext.rgmap.get(companys).getAname());
  1084. } else {
  1085. vo.setWpname(CacheContext.wpmap.get(wpid).getAname());
  1086. orderNum = CacheContext.wpmap.get(wpid).getOrderNum();
  1087. }
  1088. vo.setOrderNum(orderNum);
  1089. List<SpecificTargetVo> tempList = new ArrayList<>();
  1090. Map<Integer, SpecificTargetVo> listMap = map.get(wpid);
  1091. for (int x = 1; x <= 12; x++) {
  1092. if (listMap.containsKey(x)) {
  1093. tempList.add(listMap.get(x));
  1094. } else {
  1095. SpecificTargetVo vo1 = new SpecificTargetVo();
  1096. vo1.setWpid(wpid);
  1097. if (wpid.contains("_ZGS") || wpid.contains("_FGS" + type)) {
  1098. vo1.setWpname(CacheContext.cpmap.get(companys).getAname());
  1099. } else if (wpid.contains("_RGN")) {
  1100. vo1.setWpname(CacheContext.rgmap.get(companys).getAname());
  1101. } else {
  1102. vo1.setWpname(CacheContext.wpmap.get(wpid).getAname());
  1103. }
  1104. vo1.setYear(Integer.parseInt(year));
  1105. vo1.setMonth(x);
  1106. tempList.add(vo1);
  1107. }
  1108. }
  1109. vo.setTargetList(tempList);
  1110. resultendList.add(vo);
  1111. });
  1112. }
  1113. SortUtils.sort(resultendList, "orderNum", SortUtils.ASC);
  1114. return resultendList;
  1115. }
  1116. public List<SpecificTarget> fnlylList(String companys, String type, String year) {
  1117. //获取年份所有当月的数据
  1118. QueryWrapper<TurbineInfoDay> currentqw = new QueryWrapper<>();
  1119. currentqw.select("station_id,max(record_date) record_date,sum(rfdl) rfdl,sum(llfdl) llfdl");
  1120. currentqw.eq("to_char(record_date,'yyyy')", year);
  1121. if (type.equals("-1")) {
  1122. currentqw.like("station_id", "_FDC_");
  1123. } else {
  1124. currentqw.like("foreign_key_id", "_GDC_");
  1125. }
  1126. currentqw.groupBy("to_char(record_date,'yyyy-MM'),station_id");
  1127. List<TurbineInfoDay> currentList = iTurbineInfoDayService.list(currentqw);
  1128. // currentqw.clear();
  1129. // currentqw.select("station_id,max(record_date) record_date,sum(rfdl) rfdl,sum(llfdl) llfdl");
  1130. // currentqw.eq("to_char(record_date,'yyyy')", year);
  1131. // currentqw.groupBy("to_char(record_date,'yyyy-MM'),station_id");
  1132. // currentList.addAll(iTurbineInfoDayService.list(currentqw));
  1133. int subYear = Integer.parseInt(year) - 1;
  1134. QueryWrapper<TurbineInfoDay> sameperiodqw = new QueryWrapper<>();
  1135. sameperiodqw.select("station_id,max(record_date) record_date,sum(rfdl) rfdl,sum(llfdl) llfdl");
  1136. if (type.equals("-1")) {
  1137. currentqw.like("station_id", "_FDC_");
  1138. } else {
  1139. currentqw.like("foreign_key_id", "_GDC_");
  1140. }
  1141. sameperiodqw.eq("to_char(record_date,'yyyy')", String.valueOf(subYear));
  1142. sameperiodqw.groupBy("to_char(record_date,'yyyy-MM'),station_id");
  1143. List<TurbineInfoDay> sameperiodList = iTurbineInfoDayService.list(sameperiodqw);
  1144. // sameperiodqw.clear();
  1145. // sameperiodqw.select("station_id,max(record_date) record_date,sum(rfdl) rfdl,sum(llfdl) llfdl");
  1146. // sameperiodqw.eq("station_id", CacheContext.wplsf.get(0).getId());
  1147. // sameperiodqw.eq("to_char(record_date,'yyyy')", String.valueOf(subYear));
  1148. // sameperiodqw.groupBy("to_char(record_date,'yyyy-MM'),station_id");
  1149. // sameperiodList.addAll(iTurbineInfoDayService.list(sameperiodqw));
  1150. //合并当月与同期数据为返回结果
  1151. List<SpecificTargetVo> resultList = new ArrayList<>();
  1152. currentList.stream().forEach(i -> {
  1153. SpecificTargetVo vo = new SpecificTargetVo();
  1154. String wpid = i.getStationId();
  1155. vo.setWpid(wpid);
  1156. // if (wpid.contains("_ZGS") || wpid.contains("_FGS" + type)) {
  1157. // vo.setWpname(CacheContext.cpmap.get(companys).getAname());
  1158. // } else if (wpid.contains("_RGN")) {
  1159. // vo.setWpname(CacheContext.rgmap.get(companys).getAname());
  1160. // } else {
  1161. vo.setWpname(CacheContext.wpmap.get(wpid).getAname());
  1162. // }
  1163. vo.setYear(DateUtils.getYear(i.getRecordDate()));
  1164. vo.setMonth(DateUtils.getMonth(i.getRecordDate()));
  1165. // vo.setCurrent(DoubleUtils.keepPrecision(i.getLlfdl().doubleValue() != 0 ? i.getRfdl().doubleValue() / i.getLlfdl().doubleValue() * 100 : 0, 2));
  1166. double llfdl = i.getLlfdl() != null ? i.getLlfdl().doubleValue() : 0.0;
  1167. double rfdl = i.getRfdl() != null ? i.getRfdl().doubleValue() : 0.0;
  1168. if (llfdl != 0) {
  1169. Double calculatedValue = DoubleUtils.keepPrecision(rfdl / llfdl * 100, 2);
  1170. vo.setCurrent(calculatedValue);
  1171. } else {
  1172. vo.setCurrent(0.0);
  1173. }
  1174. resultList.add(vo);
  1175. });
  1176. resultList.stream().forEach(i -> {
  1177. Optional<TurbineInfoDay> optional = sameperiodList.stream()
  1178. .filter(j -> j.getStationId().equals(i.getWpid()) && DateUtils.getMonth(j.getRecordDate()) == (i.getMonth()))
  1179. .findFirst();
  1180. if (optional.isPresent()) {
  1181. TurbineInfoDay tqinfoday = optional.get();
  1182. // i.setSameperiod(DoubleUtils.keepPrecision(tqinfoday.getLlfdl().doubleValue() != 0 ? tqinfoday.getRfdl().doubleValue() / tqinfoday.getLlfdl().doubleValue() * 100 : 0, 2));
  1183. double llfdl = tqinfoday.getLlfdl() != null ? tqinfoday.getLlfdl().doubleValue() : 0.0;
  1184. double rfdl = tqinfoday.getRfdl() != null ? tqinfoday.getRfdl().doubleValue() : 0.0;
  1185. if (llfdl != 0) {
  1186. Double calculatedValue = DoubleUtils.keepPrecision(rfdl / llfdl * 100, 2);
  1187. i.setSameperiod(calculatedValue);
  1188. } else {
  1189. i.setSameperiod(0.0);
  1190. }
  1191. i.setCompare(i.getCurrent().compareTo(i.getSameperiod()));
  1192. } else {
  1193. i.setSameperiod(0.0);
  1194. i.setCompare(0);
  1195. }
  1196. });
  1197. List<SpecificTarget> resultendList = new ArrayList<>();
  1198. Map<String, Map<Integer, SpecificTargetVo>> map = new HashMap<>();
  1199. resultList.stream().forEach(i -> {
  1200. if (map.containsKey(i.getWpid())) {
  1201. Map<Integer, SpecificTargetVo> integerListMap = map.get(i.getWpid());
  1202. if (!integerListMap.containsKey(i.getMonth())) {
  1203. map.get(i.getWpid()).put(i.getMonth(), i);
  1204. } else {
  1205. }
  1206. } else {
  1207. Map<Integer, SpecificTargetVo> tempMap = new HashMap<>();
  1208. tempMap.put(i.getMonth(), i);
  1209. map.put(i.getWpid(), tempMap);
  1210. }
  1211. });
  1212. Set<String> wpids = map.keySet();
  1213. if (StringUtils.isNotNull(wpids)) {
  1214. wpids.stream().forEach(wpid -> {
  1215. SpecificTarget vo = new SpecificTarget();
  1216. vo.setWpid(wpid);
  1217. int orderNum = 100;
  1218. // if (wpid.contains("_ZGS") || wpid.contains("_FGS" + type)) {
  1219. // vo.setWpname(CacheContext.cpmap.get(companys).getAname());
  1220. // } else if (wpid.contains("_RGN")) {
  1221. // vo.setWpname(CacheContext.rgmap.get(companys).getAname());
  1222. // } else {
  1223. vo.setWpname(CacheContext.wpmap.get(wpid).getAname());
  1224. orderNum = CacheContext.wpmap.get(wpid).getOrderNum();
  1225. // }
  1226. vo.setOrderNum(orderNum);
  1227. List<SpecificTargetVo> tempList = new ArrayList<>();
  1228. Map<Integer, SpecificTargetVo> listMap = map.get(wpid);
  1229. for (int x = 1; x <= 12; x++) {
  1230. if (listMap.containsKey(x)) {
  1231. tempList.add(listMap.get(x));
  1232. } else {
  1233. SpecificTargetVo vo1 = new SpecificTargetVo();
  1234. vo1.setWpid(wpid);
  1235. // if (wpid.contains("_ZGS") || wpid.contains("_FGS" + type)) {
  1236. // vo1.setWpname(CacheContext.cpmap.get(companys).getAname());
  1237. // } else if (wpid.contains("_RGN")) {
  1238. // vo1.setWpname(CacheContext.rgmap.get(companys).getAname());
  1239. // } else {
  1240. vo1.setWpname(CacheContext.wpmap.get(wpid).getAname());
  1241. // }
  1242. vo1.setYear(Integer.parseInt(year));
  1243. vo1.setMonth(x);
  1244. tempList.add(vo1);
  1245. }
  1246. }
  1247. vo.setTargetList(tempList);
  1248. resultendList.add(vo);
  1249. SpecificTarget vo2 = new SpecificTarget();
  1250. vo2.setWpid(vo.getWpid());
  1251. vo2.setTargetList(vo.getTargetList());
  1252. vo2.setOrderNum(vo.getOrderNum() + 1);
  1253. vo2.setWpname(CacheContext.cpmap.get(companys).getAname());
  1254. resultendList.add(vo2);
  1255. });
  1256. }
  1257. SortUtils.sort(resultendList, "orderNum", SortUtils.ASC);
  1258. return resultendList;
  1259. }
  1260. public List<SpecificTarget> fdlList2(String companys, String type, String year) {
  1261. //获取年份所有当月的数据
  1262. QueryWrapper<ProEconPowerstationInfoDay5> currentqw = new QueryWrapper<>();
  1263. currentqw.select("foreign_key_id,max(record_date) record_date,sum(rfdldb) yfdldb");
  1264. currentqw.eq("location", "wp");
  1265. currentqw.eq("to_char(record_date,'yyyy')", year);
  1266. if (type.equals("-1")) {
  1267. currentqw.like("foreign_key_id", "_FDC_");
  1268. } else {
  1269. currentqw.like("foreign_key_id", "_GDC_");
  1270. }
  1271. if (companys.endsWith("ZGS")) {
  1272. currentqw.eq("company_id", companys);
  1273. } else {
  1274. currentqw.eq("region_id", companys);
  1275. }
  1276. currentqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  1277. List<ProEconPowerstationInfoDay5> currentList = proEconPowerstationInfoDay5Service.list(currentqw);
  1278. currentqw.clear();
  1279. currentqw.select("foreign_key_id,max(record_date) record_date,sum(rfdldb) yfdldb");
  1280. currentqw.eq("foreign_key_id", companys + type);
  1281. currentqw.eq("to_char(record_date,'yyyy')", year);
  1282. currentqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  1283. currentList.addAll(proEconPowerstationInfoDay5Service.list(currentqw));
  1284. int subYear = Integer.parseInt(year) - 1;
  1285. QueryWrapper<ProEconPowerstationInfoDay5> sameperiodqw = new QueryWrapper<>();
  1286. sameperiodqw.select("foreign_key_id,max(record_date) record_date,sum(rfdldb) yfdldb");
  1287. sameperiodqw.eq("location", "wp");
  1288. if (type.equals("-1")) {
  1289. currentqw.like("foreign_key_id", "_FDC_");
  1290. } else {
  1291. currentqw.like("foreign_key_id", "_GDC_");
  1292. }
  1293. if (companys.endsWith("ZGS")) {
  1294. currentqw.eq("company_id", companys);
  1295. } else {
  1296. currentqw.eq("region_id", companys);
  1297. }
  1298. sameperiodqw.eq("to_char(record_date,'yyyy')", String.valueOf(subYear));
  1299. sameperiodqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  1300. List<ProEconPowerstationInfoDay5> sameperiodList = proEconPowerstationInfoDay5Service.list(sameperiodqw);
  1301. sameperiodqw.clear();
  1302. sameperiodqw.select("foreign_key_id,max(record_date) record_date,sum(rfdldb) yfdldb");
  1303. sameperiodqw.eq("foreign_key_id", companys + type);
  1304. sameperiodqw.eq("to_char(record_date,'yyyy')", String.valueOf(subYear));
  1305. sameperiodqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  1306. sameperiodList.addAll(proEconPowerstationInfoDay5Service.list(sameperiodqw));
  1307. //合并当月与同期数据为返回结果
  1308. List<SpecificTargetVo> resultList = new ArrayList<>();
  1309. currentList.stream().forEach(i -> {
  1310. SpecificTargetVo vo = new SpecificTargetVo();
  1311. String wpid = i.getForeignKeyId();
  1312. vo.setWpid(wpid);
  1313. if (wpid.contains("_ZGS") || wpid.contains("_FGS" + type)) {
  1314. vo.setWpname(CacheContext.cpmap.get(companys).getAname());
  1315. } else if (wpid.contains("_RGN")) {
  1316. vo.setWpname(CacheContext.rgmap.get(companys).getAname());
  1317. } else {
  1318. vo.setWpname(CacheContext.wpmap.get(wpid).getAname());
  1319. }
  1320. vo.setYear(DateUtils.getYear(i.getRecordDate()));
  1321. vo.setMonth(DateUtils.getMonth(i.getRecordDate()));
  1322. vo.setCurrent(DoubleUtils.keepPrecision(i.getYfdldb().doubleValue() / 10000, 2));
  1323. resultList.add(vo);
  1324. });
  1325. resultList.stream().forEach(i -> {
  1326. Optional<ProEconPowerstationInfoDay5> optional = sameperiodList.stream()
  1327. .filter(j -> i.getWpid().equals(j.getForeignKeyId())
  1328. && i.getMonth().equals(DateUtils.getMonthFromDate(j.getRecordDate())))
  1329. .findFirst();
  1330. if (optional.isPresent()) {
  1331. ProEconPowerstationInfoDay5 tqinfoday = optional.get();
  1332. i.setSameperiod(DoubleUtils.keepPrecision(tqinfoday.getYfdldb().doubleValue() / 10000, 2));
  1333. i.setCompare(i.getCurrent().compareTo(i.getSameperiod()));
  1334. } else {
  1335. i.setSameperiod(0.0);
  1336. i.setCompare(0);
  1337. }
  1338. });
  1339. List<SpecificTarget> resultendList = new ArrayList<>();
  1340. Map<String, Map<Integer, SpecificTargetVo>> map = new HashMap<>();
  1341. resultList.stream().forEach(i -> {
  1342. if (map.containsKey(i.getWpid())) {
  1343. Map<Integer, SpecificTargetVo> integerListMap = map.get(i.getWpid());
  1344. if (!integerListMap.containsKey(i.getMonth())) {
  1345. map.get(i.getWpid()).put(i.getMonth(), i);
  1346. } else {
  1347. }
  1348. } else {
  1349. Map<Integer, SpecificTargetVo> tempMap = new HashMap<>();
  1350. tempMap.put(i.getMonth(), i);
  1351. map.put(i.getWpid(), tempMap);
  1352. }
  1353. });
  1354. Set<String> wpids = map.keySet();
  1355. if (StringUtils.isNotNull(wpids)) {
  1356. wpids.stream().forEach(wpid -> {
  1357. SpecificTarget vo = new SpecificTarget();
  1358. vo.setWpid(wpid);
  1359. int orderNum = 100;
  1360. if (wpid.contains("_ZGS") || wpid.contains("_FGS" + type)) {
  1361. vo.setWpname(CacheContext.cpmap.get(companys).getAname());
  1362. } else if (wpid.contains("_RGN")) {
  1363. vo.setWpname(CacheContext.rgmap.get(companys).getAname());
  1364. } else {
  1365. vo.setWpname(CacheContext.wpmap.get(wpid).getAname());
  1366. orderNum = CacheContext.wpmap.get(wpid).getOrderNum();
  1367. }
  1368. vo.setOrderNum(orderNum);
  1369. List<SpecificTargetVo> tempList = new ArrayList<>();
  1370. Map<Integer, SpecificTargetVo> listMap = map.get(wpid);
  1371. for (int x = 1; x <= 12; x++) {
  1372. if (listMap.containsKey(x)) {
  1373. tempList.add(listMap.get(x));
  1374. } else {
  1375. SpecificTargetVo vo1 = new SpecificTargetVo();
  1376. vo1.setWpid(wpid);
  1377. if (wpid.contains("_ZGS") || wpid.contains("_FGS" + type)) {
  1378. vo1.setWpname(CacheContext.cpmap.get(companys).getAname());
  1379. } else if (wpid.contains("_RGN")) {
  1380. vo1.setWpname(CacheContext.rgmap.get(companys).getAname());
  1381. } else {
  1382. vo1.setWpname(CacheContext.wpmap.get(wpid).getAname());
  1383. }
  1384. vo1.setYear(Integer.parseInt(year));
  1385. vo1.setMonth(x);
  1386. tempList.add(vo1);
  1387. }
  1388. }
  1389. vo.setTargetList(tempList);
  1390. resultendList.add(vo);
  1391. });
  1392. }
  1393. SortUtils.sort(resultendList, "orderNum", SortUtils.ASC);
  1394. return resultendList;
  1395. }
  1396. // public List<SpecificTarget> fdlList(String companys, String type, String year) {
  1397. // //获取年份所有当月的数据
  1398. // QueryWrapper<StationInfoDay> currentqw = new QueryWrapper<>();
  1399. // currentqw.select("station_id,max(record_date) record_date,sum(rfdl_fj) rfdl_fj");
  1400. //// currentqw.eq("location", "wp");
  1401. // currentqw.eq("to_char(record_date,'yyyy')", year);
  1402. // if (type.equals("-1")) {
  1403. // currentqw.like("station_id", "_FDC_");
  1404. // } else {
  1405. // currentqw.like("station_id", "_GDC_");
  1406. // }
  1407. //// if (companys.endsWith("ZGS")) {
  1408. //// currentqw.eq("company_id", companys);
  1409. //// } else {
  1410. //// currentqw.eq("region_id", companys);
  1411. //// }
  1412. // currentqw.groupBy("to_char(record_date,'yyyy-MM'),station_id");
  1413. // List<StationInfoDay> currentList = iStationInfoDayService.list(currentqw);
  1414. // currentqw.clear();
  1415. // currentqw.select("station_id,max(record_date) record_date,sum(rfdl_fj) rfdl_fj");
  1416. //// currentqw.eq("foreign_key_id", companys + type);
  1417. // currentqw.eq("to_char(record_date,'yyyy')", year);
  1418. // currentqw.groupBy("to_char(record_date,'yyyy-MM'),station_id");
  1419. // currentList.addAll(iStationInfoDayService.list(currentqw));
  1420. //
  1421. // int subYear = Integer.parseInt(year) - 1;
  1422. // QueryWrapper<StationInfoDay> sameperiodqw = new QueryWrapper<>();
  1423. // sameperiodqw.select("station_id,max(record_date) record_date,sum(rfdl_fj) rfdl_fj");
  1424. //// sameperiodqw.eq("location", "wp");
  1425. // if (type.equals("-1")) {
  1426. // currentqw.like("station_id", "_FDC_");
  1427. // } else {
  1428. // currentqw.like("station_id", "_GDC_");
  1429. // }
  1430. //// if (companys.endsWith("ZGS")) {
  1431. //// currentqw.eq("company_id", companys);
  1432. //// } else {
  1433. //// currentqw.eq("region_id", companys);
  1434. //// }
  1435. // sameperiodqw.eq("to_char(record_date,'yyyy')", String.valueOf(subYear));
  1436. // sameperiodqw.groupBy("to_char(record_date,'yyyy-MM'),station_id");
  1437. // List<StationInfoDay> sameperiodList = iStationInfoDayService.list(sameperiodqw);
  1438. // sameperiodqw.clear();
  1439. // sameperiodqw.select("station_id,max(record_date) record_date,sum(rfdl_fj) rfdl_fj");
  1440. //// sameperiodqw.eq("foreign_key_id", companys + type);
  1441. // sameperiodqw.eq("to_char(record_date,'yyyy')", String.valueOf(subYear));
  1442. // sameperiodqw.groupBy("to_char(record_date,'yyyy-MM'),station_id");
  1443. // sameperiodList.addAll(iStationInfoDayService.list(sameperiodqw));
  1444. //
  1445. // //合并当月与同期数据为返回结果
  1446. // List<SpecificTargetVo> resultList = new ArrayList<>();
  1447. //
  1448. // currentList.stream().forEach(i -> {
  1449. // SpecificTargetVo vo = new SpecificTargetVo();
  1450. // String wpid = i.getStationId();
  1451. // vo.setWpid(wpid);
  1452. //// if (wpid.contains("_ZGS") || wpid.contains("_FGS" + type)) {
  1453. //// vo.setWpname(CacheContext.cpmap.get(companys).getAname());
  1454. //// } else if (wpid.contains("_RGN")) {
  1455. //// vo.setWpname(CacheContext.rgmap.get(companys).getAname());
  1456. //// } else {
  1457. // vo.setWpname(CacheContext.wpmap.get(wpid).getAname());
  1458. //// }
  1459. // Instant instant = i.getRecordDate().atStartOfDay(ZoneId.systemDefault()).toInstant();
  1460. // Date date = Date.from(instant);
  1461. // vo.setYear(DateUtils.getYear(date));
  1462. // vo.setMonth(DateUtils.getMonth(date));
  1463. // vo.setCurrent(DoubleUtils.keepPrecision(i.getRfdlFj().doubleValue(), 2));
  1464. // resultList.add(vo);
  1465. // });
  1466. // resultList.stream().forEach(i -> {
  1467. // Optional<StationInfoDay> optional = sameperiodList.stream()
  1468. // .filter(j -> i.getWpid().equals(j.getStationId())
  1469. // && i.getMonth().equals(DateUtils.getMonthFromDate(Date.from(j.getRecordDate().atStartOfDay(ZoneId.systemDefault()).toInstant()))))
  1470. // .findFirst();
  1471. //
  1472. // if (optional.isPresent()) {
  1473. // StationInfoDay tqinfoday = optional.get();
  1474. // i.setSameperiod(DoubleUtils.keepPrecision(tqinfoday.getRfdlFj().doubleValue(), 2));
  1475. // i.setCompare(i.getCurrent().compareTo(i.getSameperiod()));
  1476. // } else {
  1477. // i.setSameperiod(0.0);
  1478. // i.setCompare(0);
  1479. // }
  1480. // });
  1481. // List<SpecificTarget> resultendList = new ArrayList<>();
  1482. //
  1483. // Map<String, Map<Integer, SpecificTargetVo>> map = new HashMap<>();
  1484. //
  1485. // resultList.stream().forEach(i -> {
  1486. // if (map.containsKey(i.getWpid())) {
  1487. // Map<Integer, SpecificTargetVo> integerListMap = map.get(i.getWpid());
  1488. // if (!integerListMap.containsKey(i.getMonth())) {
  1489. // map.get(i.getWpid()).put(i.getMonth(), i);
  1490. // } else {
  1491. //
  1492. // }
  1493. // } else {
  1494. // Map<Integer, SpecificTargetVo> tempMap = new HashMap<>();
  1495. // tempMap.put(i.getMonth(), i);
  1496. // map.put(i.getWpid(), tempMap);
  1497. // }
  1498. // });
  1499. // Set<String> wpids = map.keySet();
  1500. // if (StringUtils.isNotNull(wpids)) {
  1501. // wpids.stream().forEach(wpid -> {
  1502. // SpecificTarget vo = new SpecificTarget();
  1503. // vo.setWpid(wpid);
  1504. // int orderNum = 100;
  1505. //// if (wpid.contains("_ZGS")|| wpid.contains("_FGS" + type)) {
  1506. //// vo.setWpname(CacheContext.cpmap.get(companys).getAname());
  1507. //// } else if (wpid.contains("_RGN")) {
  1508. //// vo.setWpname(CacheContext.rgmap.get(companys).getAname());
  1509. //// } else {
  1510. // vo.setWpname(CacheContext.wpmap.get(wpid).getAname());
  1511. // orderNum = CacheContext.wpmap.get(wpid).getOrderNum();
  1512. //// }
  1513. // vo.setOrderNum(orderNum);
  1514. // List<SpecificTargetVo> tempList = new ArrayList<>();
  1515. //
  1516. // Map<Integer, SpecificTargetVo> listMap = map.get(wpid);
  1517. // for (int x = 1; x <= 12; x++) {
  1518. // if (listMap.containsKey(x)) {
  1519. // tempList.add(listMap.get(x));
  1520. // } else {
  1521. // SpecificTargetVo vo1 = new SpecificTargetVo();
  1522. // vo1.setWpid(wpid);
  1523. //// if (wpid.contains("_ZGS")|| wpid.contains("_FGS" + type)) {
  1524. //// vo1.setWpname(CacheContext.cpmap.get(companys).getAname());
  1525. //// } else if (wpid.contains("_RGN")) {
  1526. //// vo1.setWpname(CacheContext.rgmap.get(companys).getAname());
  1527. //// } else {
  1528. // vo1.setWpname(CacheContext.wpmap.get(wpid).getAname());
  1529. //// }
  1530. // vo1.setYear(Integer.parseInt(year));
  1531. // vo1.setMonth(x);
  1532. // tempList.add(vo1);
  1533. // }
  1534. // }
  1535. //
  1536. //
  1537. // vo.setTargetList(tempList);
  1538. // resultendList.add(vo);
  1539. // });
  1540. // }
  1541. // SortUtils.sort(resultendList, "orderNum", SortUtils.ASC);
  1542. //
  1543. // return resultendList;
  1544. // }
  1545. public List<SpecificTarget> fdlList(String companys, String type, String year) {
  1546. //获取年份所有当月的数据
  1547. QueryWrapper<StationInfoDay> currentqw = new QueryWrapper<>();
  1548. currentqw.select("station_id,max(record_date) record_date,sum(rfdl_fj) rfdl_fj");
  1549. currentqw.eq("to_char(record_date,'yyyy')", year);
  1550. if (type.equals("-1")) {
  1551. currentqw.like("station_id", "_FDC_");
  1552. } else {
  1553. currentqw.like("station_id", "_GDC_");
  1554. }
  1555. currentqw.groupBy("to_char(record_date,'yyyy-MM'),station_id");
  1556. List<StationInfoDay> currentList = iStationInfoDayService.list(currentqw);
  1557. currentqw.clear();
  1558. currentqw.select("station_id,max(record_date) record_date,sum(rfdl_fj) rfdl_fj");
  1559. currentqw.eq("to_char(record_date,'yyyy')", year);
  1560. currentqw.groupBy("to_char(record_date,'yyyy-MM'),station_id");
  1561. currentList.addAll(iStationInfoDayService.list(currentqw));
  1562. int subYear = Integer.parseInt(year) - 1;
  1563. QueryWrapper<StationInfoDay> sameperiodqw = new QueryWrapper<>();
  1564. sameperiodqw.select("station_id,max(record_date) record_date,sum(rfdl_fj) rfdl_fj");
  1565. if (type.equals("-1")) {
  1566. currentqw.like("station_id", "_FDC_");
  1567. } else {
  1568. currentqw.like("station_id", "_GDC_");
  1569. }
  1570. sameperiodqw.eq("to_char(record_date,'yyyy')", String.valueOf(subYear));
  1571. sameperiodqw.groupBy("to_char(record_date,'yyyy-MM'),station_id");
  1572. List<StationInfoDay> sameperiodList = iStationInfoDayService.list(sameperiodqw);
  1573. sameperiodqw.clear();
  1574. sameperiodqw.select("station_id,max(record_date) record_date,sum(rfdl_fj) rfdl_fj");
  1575. sameperiodqw.eq("to_char(record_date,'yyyy')", String.valueOf(subYear));
  1576. sameperiodqw.groupBy("to_char(record_date,'yyyy-MM'),station_id");
  1577. sameperiodList.addAll(iStationInfoDayService.list(sameperiodqw));
  1578. //合并当月与同期数据为返回结果
  1579. List<SpecificTargetVo> resultList = new ArrayList<>();
  1580. currentList.stream().forEach(i -> {
  1581. SpecificTargetVo vo = new SpecificTargetVo();
  1582. String wpid = i.getStationId();
  1583. vo.setWpid(wpid);
  1584. vo.setWpname(CacheContext.wpmap.get(wpid).getAname());
  1585. Instant instant = i.getRecordDate().atStartOfDay(ZoneId.systemDefault()).toInstant();
  1586. Date date = Date.from(instant);
  1587. vo.setYear(DateUtils.getYear(date));
  1588. vo.setMonth(DateUtils.getMonth(date));
  1589. vo.setCurrent(DoubleUtils.keepPrecision(i.getRfdlFj().doubleValue(), 2));
  1590. resultList.add(vo);
  1591. });
  1592. resultList.stream().forEach(i -> {
  1593. Optional<StationInfoDay> optional = sameperiodList.stream()
  1594. .filter(j -> i.getWpid().equals(j.getStationId())
  1595. && i.getMonth().equals(DateUtils.getMonthFromDate(Date.from(j.getRecordDate().atStartOfDay(ZoneId.systemDefault()).toInstant()))))
  1596. .findFirst();
  1597. if (optional.isPresent()) {
  1598. StationInfoDay tqinfoday = optional.get();
  1599. i.setSameperiod(DoubleUtils.keepPrecision(tqinfoday.getRfdlFj().doubleValue(), 2));
  1600. i.setCompare(i.getCurrent().compareTo(i.getSameperiod()));
  1601. } else {
  1602. i.setSameperiod(0.0);
  1603. i.setCompare(0);
  1604. }
  1605. });
  1606. List<SpecificTarget> resultendList = new ArrayList<>();
  1607. Map<String, Map<Integer, SpecificTargetVo>> map = new HashMap<>();
  1608. resultList.stream().forEach(i -> {
  1609. if (map.containsKey(i.getWpid())) {
  1610. Map<Integer, SpecificTargetVo> integerListMap = map.get(i.getWpid());
  1611. if (!integerListMap.containsKey(i.getMonth())) {
  1612. map.get(i.getWpid()).put(i.getMonth(), i);
  1613. } else {
  1614. }
  1615. } else {
  1616. Map<Integer, SpecificTargetVo> tempMap = new HashMap<>();
  1617. tempMap.put(i.getMonth(), i);
  1618. map.put(i.getWpid(), tempMap);
  1619. }
  1620. });
  1621. Set<String> wpids = map.keySet();
  1622. if (StringUtils.isNotNull(wpids)) {
  1623. wpids.stream().forEach(wpid -> {
  1624. SpecificTarget vo = new SpecificTarget();
  1625. vo.setWpid(wpid);
  1626. int orderNum = 100;
  1627. vo.setWpname(CacheContext.wpmap.get(wpid).getAname());
  1628. orderNum = CacheContext.wpmap.get(wpid).getOrderNum();
  1629. vo.setOrderNum(orderNum);
  1630. List<SpecificTargetVo> tempList = new ArrayList<>();
  1631. Map<Integer, SpecificTargetVo> listMap = map.get(wpid);
  1632. for (int x = 1; x <= 12; x++) {
  1633. if (listMap.containsKey(x)) {
  1634. tempList.add(listMap.get(x));
  1635. } else {
  1636. SpecificTargetVo vo1 = new SpecificTargetVo();
  1637. vo1.setWpid(wpid);
  1638. vo1.setWpname(CacheContext.wpmap.get(wpid).getAname());
  1639. vo1.setYear(Integer.parseInt(year));
  1640. vo1.setMonth(x);
  1641. tempList.add(vo1);
  1642. }
  1643. }
  1644. vo.setTargetList(tempList);
  1645. resultendList.add(vo);
  1646. SpecificTarget vo2 = new SpecificTarget();
  1647. vo2.setWpid(vo.getWpid());
  1648. vo2.setTargetList(vo.getTargetList());
  1649. vo2.setOrderNum(vo.getOrderNum() + 1);
  1650. vo2.setWpname(CacheContext.cpmap.get(companys).getAname());
  1651. resultendList.add(vo2);
  1652. });
  1653. }
  1654. SortUtils.sort(resultendList, "orderNum", SortUtils.ASC);
  1655. return resultendList;
  1656. }
  1657. public List<SpecificTarget> zhcydlList2(String companys, String type, String year) {
  1658. //获取年份所有当月的数据
  1659. QueryWrapper<ProEconPowerstationInfoDay5> currentqw = new QueryWrapper<>();
  1660. currentqw.select("foreign_key_id,max(record_date) record_date,sum(rzhcydldb) yzhcydldb");
  1661. currentqw.eq("location", "wp");
  1662. currentqw.eq("to_char(record_date,'yyyy')", year);
  1663. if (type.equals("-1")) {
  1664. currentqw.like("foreign_key_id", "_FDC_");
  1665. } else {
  1666. currentqw.like("foreign_key_id", "_GDC_");
  1667. }
  1668. if (companys.endsWith("ZGS")) {
  1669. currentqw.eq("company_id", companys);
  1670. } else {
  1671. currentqw.eq("region_id", companys);
  1672. }
  1673. currentqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  1674. List<ProEconPowerstationInfoDay5> currentList = proEconPowerstationInfoDay5Service.list(currentqw);
  1675. currentqw.clear();
  1676. currentqw.select("foreign_key_id,max(record_date) record_date,sum(rzhcydldb) yzhcydldb");
  1677. currentqw.eq("foreign_key_id", companys + type);
  1678. currentqw.eq("to_char(record_date,'yyyy')", year);
  1679. currentqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  1680. currentList.addAll(proEconPowerstationInfoDay5Service.list(currentqw));
  1681. int subYear = Integer.parseInt(year) - 1;
  1682. QueryWrapper<ProEconPowerstationInfoDay5> sameperiodqw = new QueryWrapper<>();
  1683. sameperiodqw.select("foreign_key_id,max(record_date) record_date,sum(rzhcydldb) yzhcydldb");
  1684. sameperiodqw.eq("location", "wp");
  1685. if (type.equals("-1")) {
  1686. currentqw.like("foreign_key_id", "_FDC_");
  1687. } else {
  1688. currentqw.like("foreign_key_id", "_GDC_");
  1689. }
  1690. if (companys.endsWith("ZGS")) {
  1691. currentqw.eq("company_id", companys);
  1692. } else {
  1693. currentqw.eq("region_id", companys);
  1694. }
  1695. sameperiodqw.eq("to_char(record_date,'yyyy')", String.valueOf(subYear));
  1696. sameperiodqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  1697. List<ProEconPowerstationInfoDay5> sameperiodList = proEconPowerstationInfoDay5Service.list(sameperiodqw);
  1698. sameperiodqw.clear();
  1699. sameperiodqw.select("foreign_key_id,max(record_date) record_date,sum(rzhcydldb) yzhcydldb");
  1700. sameperiodqw.eq("foreign_key_id", companys + type);
  1701. sameperiodqw.eq("to_char(record_date,'yyyy')", String.valueOf(subYear));
  1702. sameperiodqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  1703. sameperiodList.addAll(proEconPowerstationInfoDay5Service.list(sameperiodqw));
  1704. //合并当月与同期数据为返回结果
  1705. List<SpecificTargetVo> resultList = new ArrayList<>();
  1706. currentList.stream().forEach(i -> {
  1707. SpecificTargetVo vo = new SpecificTargetVo();
  1708. String wpid = i.getForeignKeyId();
  1709. vo.setWpid(wpid);
  1710. if (wpid.contains("_ZGS") || wpid.contains("_FGS" + type)) {
  1711. vo.setWpname(CacheContext.cpmap.get(companys).getAname());
  1712. } else if (wpid.contains("_RGN")) {
  1713. vo.setWpname(CacheContext.rgmap.get(companys).getAname());
  1714. } else {
  1715. vo.setWpname(CacheContext.wpmap.get(wpid).getAname());
  1716. }
  1717. vo.setYear(DateUtils.getYear(i.getRecordDate()));
  1718. vo.setMonth(DateUtils.getMonth(i.getRecordDate()));
  1719. vo.setCurrent(DoubleUtils.keepPrecision(i.getYzhcydldb().doubleValue() / 10000, 2));
  1720. resultList.add(vo);
  1721. });
  1722. resultList.stream().forEach(i -> {
  1723. Optional<ProEconPowerstationInfoDay5> optional = sameperiodList.stream()
  1724. // .filter(j -> j.getForeignKeyId().equals(i.getWpid()) && String.valueOf(DateUtils.getMonth(j.getRecordDate())).equals(i.getMonth()))
  1725. .filter(j -> j.getForeignKeyId().equals(i.getWpid()) && i.getMonth().equals(DateUtils.getMonthFromDate(j.getRecordDate())))
  1726. .findFirst();
  1727. if (optional.isPresent()) {
  1728. ProEconPowerstationInfoDay5 tqinfoday = optional.get();
  1729. i.setSameperiod(DoubleUtils.keepPrecision(tqinfoday.getYzhcydldb().doubleValue() / 10000, 2));
  1730. i.setCompare(i.getCurrent().compareTo(i.getSameperiod()));
  1731. } else {
  1732. i.setSameperiod(0.0);
  1733. i.setCompare(0);
  1734. }
  1735. });
  1736. List<SpecificTarget> resultendList = new ArrayList<>();
  1737. Map<String, Map<Integer, SpecificTargetVo>> map = new HashMap<>();
  1738. resultList.stream().forEach(i -> {
  1739. if (map.containsKey(i.getWpid())) {
  1740. Map<Integer, SpecificTargetVo> integerListMap = map.get(i.getWpid());
  1741. if (!integerListMap.containsKey(i.getMonth())) {
  1742. map.get(i.getWpid()).put(i.getMonth(), i);
  1743. } else {
  1744. }
  1745. } else {
  1746. Map<Integer, SpecificTargetVo> tempMap = new HashMap<>();
  1747. tempMap.put(i.getMonth(), i);
  1748. map.put(i.getWpid(), tempMap);
  1749. }
  1750. });
  1751. Set<String> wpids = map.keySet();
  1752. if (StringUtils.isNotNull(wpids)) {
  1753. wpids.stream().forEach(wpid -> {
  1754. SpecificTarget vo = new SpecificTarget();
  1755. vo.setWpid(wpid);
  1756. int orderNum = 100;
  1757. if (wpid.contains("_ZGS") || wpid.contains("_FGS" + type)) {
  1758. vo.setWpname(CacheContext.cpmap.get(companys).getAname());
  1759. } else if (wpid.contains("_RGN")) {
  1760. vo.setWpname(CacheContext.rgmap.get(companys).getAname());
  1761. } else {
  1762. vo.setWpname(CacheContext.wpmap.get(wpid).getAname());
  1763. orderNum = CacheContext.wpmap.get(wpid).getOrderNum();
  1764. }
  1765. vo.setOrderNum(orderNum);
  1766. List<SpecificTargetVo> tempList = new ArrayList<>();
  1767. Map<Integer, SpecificTargetVo> listMap = map.get(wpid);
  1768. for (int x = 1; x <= 12; x++) {
  1769. if (listMap.containsKey(x)) {
  1770. tempList.add(listMap.get(x));
  1771. } else {
  1772. SpecificTargetVo vo1 = new SpecificTargetVo();
  1773. vo1.setWpid(wpid);
  1774. if (wpid.contains("_ZGS") || wpid.contains("_FGS" + type)) {
  1775. vo1.setWpname(CacheContext.cpmap.get(companys).getAname());
  1776. } else if (wpid.contains("_RGN")) {
  1777. vo1.setWpname(CacheContext.rgmap.get(companys).getAname());
  1778. } else {
  1779. vo1.setWpname(CacheContext.wpmap.get(wpid).getAname());
  1780. }
  1781. vo1.setYear(Integer.parseInt(year));
  1782. vo1.setMonth(x);
  1783. tempList.add(vo1);
  1784. }
  1785. }
  1786. vo.setTargetList(tempList);
  1787. resultendList.add(vo);
  1788. });
  1789. }
  1790. SortUtils.sort(resultendList, "orderNum", SortUtils.ASC);
  1791. return resultendList;
  1792. }
  1793. public List<SpecificTarget> zhcydlList(String companys, String type, String year) {
  1794. //获取年份所有当月的数据
  1795. QueryWrapper<StationInfoDay> currentqw = new QueryWrapper<>();
  1796. currentqw.select("station_id,max(record_date) record_date,sum(cydl) cydl");
  1797. // currentqw.eq("location", "wp");
  1798. currentqw.eq("to_char(record_date,'yyyy')", year);
  1799. if (type.equals("-1")) {
  1800. currentqw.like("station_id", "_FDC_");
  1801. } else {
  1802. currentqw.like("station_id", "_GDC_");
  1803. }
  1804. // if (companys.endsWith("ZGS")) {
  1805. // currentqw.eq("company_id", companys);
  1806. // } else {
  1807. // currentqw.eq("region_id", companys);
  1808. // }
  1809. currentqw.groupBy("to_char(record_date,'yyyy-MM'),station_id");
  1810. List<StationInfoDay> currentList = iStationInfoDayService.list(currentqw);
  1811. currentqw.clear();
  1812. currentqw.select("station_id,max(record_date) record_date,sum(cydl) cydl");
  1813. // currentqw.eq("foreign_key_id", companys + type);
  1814. currentqw.eq("to_char(record_date,'yyyy')", year);
  1815. currentqw.groupBy("to_char(record_date,'yyyy-MM'),station_id");
  1816. currentList.addAll(iStationInfoDayService.list(currentqw));
  1817. int subYear = Integer.parseInt(year) - 1;
  1818. QueryWrapper<StationInfoDay> sameperiodqw = new QueryWrapper<>();
  1819. sameperiodqw.select("station_id,max(record_date) record_date,sum(cydl) cydl");
  1820. // sameperiodqw.eq("location", "wp");
  1821. if (type.equals("-1")) {
  1822. currentqw.like("station_id", "_FDC_");
  1823. } else {
  1824. currentqw.like("station_id", "_GDC_");
  1825. }
  1826. // if (companys.endsWith("ZGS")) {
  1827. // currentqw.eq("company_id", companys);
  1828. // } else {
  1829. // currentqw.eq("region_id", companys);
  1830. // }
  1831. sameperiodqw.eq("to_char(record_date,'yyyy')", String.valueOf(subYear));
  1832. sameperiodqw.groupBy("to_char(record_date,'yyyy-MM'),station_id");
  1833. List<StationInfoDay> sameperiodList = iStationInfoDayService.list(sameperiodqw);
  1834. sameperiodqw.clear();
  1835. sameperiodqw.select("station_id,max(record_date) record_date,sum(cydl) cydl");
  1836. // sameperiodqw.eq("foreign_key_id", companys + type);
  1837. sameperiodqw.eq("to_char(record_date,'yyyy')", String.valueOf(subYear));
  1838. sameperiodqw.groupBy("to_char(record_date,'yyyy-MM'),station_id");
  1839. sameperiodList.addAll(iStationInfoDayService.list(sameperiodqw));
  1840. //合并当月与同期数据为返回结果
  1841. List<SpecificTargetVo> resultList = new ArrayList<>();
  1842. currentList.stream().forEach(i -> {
  1843. SpecificTargetVo vo = new SpecificTargetVo();
  1844. String wpid = i.getStationId();
  1845. vo.setWpid(wpid);
  1846. // if (wpid.contains("_ZGS")|| wpid.contains("_FGS" + type)) {
  1847. // vo.setWpname(CacheContext.cpmap.get(companys).getAname());
  1848. // } else if (wpid.contains("_RGN")) {
  1849. // vo.setWpname(CacheContext.rgmap.get(companys).getAname());
  1850. // } else {
  1851. vo.setWpname(CacheContext.wpmap.get(wpid).getAname());
  1852. // }
  1853. Instant instant = i.getRecordDate().atStartOfDay(ZoneId.systemDefault()).toInstant();
  1854. Date date = Date.from(instant);
  1855. vo.setYear(DateUtils.getYear(date));
  1856. vo.setMonth(DateUtils.getMonth(date));
  1857. vo.setCurrent(DoubleUtils.keepPrecision(i.getCydl().doubleValue(), 2));
  1858. resultList.add(vo);
  1859. });
  1860. resultList.stream().forEach(i -> {
  1861. Optional<StationInfoDay> optional = sameperiodList.stream()
  1862. // .filter(j -> j.getForeignKeyId().equals(i.getWpid()) && String.valueOf(DateUtils.getMonth(j.getRecordDate())).equals(i.getMonth()))
  1863. .filter(j -> j.getStationId().equals(i.getWpid()) && i.getMonth().equals(DateUtils.getMonthFromDate(Date.from(j.getRecordDate().atStartOfDay(ZoneId.systemDefault()).toInstant()))))
  1864. .findFirst();
  1865. if (optional.isPresent()) {
  1866. StationInfoDay tqinfoday = optional.get();
  1867. i.setSameperiod(DoubleUtils.keepPrecision(tqinfoday.getCydl().doubleValue(), 2));
  1868. i.setCompare(i.getCurrent().compareTo(i.getSameperiod()));
  1869. } else {
  1870. i.setSameperiod(0.0);
  1871. i.setCompare(0);
  1872. }
  1873. });
  1874. List<SpecificTarget> resultendList = new ArrayList<>();
  1875. Map<String, Map<Integer, SpecificTargetVo>> map = new HashMap<>();
  1876. resultList.stream().forEach(i -> {
  1877. if (map.containsKey(i.getWpid())) {
  1878. Map<Integer, SpecificTargetVo> integerListMap = map.get(i.getWpid());
  1879. if (!integerListMap.containsKey(i.getMonth())) {
  1880. map.get(i.getWpid()).put(i.getMonth(), i);
  1881. } else {
  1882. }
  1883. } else {
  1884. Map<Integer, SpecificTargetVo> tempMap = new HashMap<>();
  1885. tempMap.put(i.getMonth(), i);
  1886. map.put(i.getWpid(), tempMap);
  1887. }
  1888. });
  1889. Set<String> wpids = map.keySet();
  1890. if (StringUtils.isNotNull(wpids)) {
  1891. wpids.stream().forEach(wpid -> {
  1892. SpecificTarget vo = new SpecificTarget();
  1893. vo.setWpid(wpid);
  1894. int orderNum = 100;
  1895. // if (wpid.contains("_ZGS")|| wpid.contains("_FGS" + type)) {
  1896. // vo.setWpname(CacheContext.cpmap.get(companys).getAname());
  1897. // } else if (wpid.contains("_RGN")) {
  1898. // vo.setWpname(CacheContext.rgmap.get(companys).getAname());
  1899. // } else {
  1900. vo.setWpname(CacheContext.wpmap.get(wpid).getAname());
  1901. orderNum = CacheContext.wpmap.get(wpid).getOrderNum();
  1902. // }
  1903. vo.setOrderNum(orderNum);
  1904. List<SpecificTargetVo> tempList = new ArrayList<>();
  1905. Map<Integer, SpecificTargetVo> listMap = map.get(wpid);
  1906. for (int x = 1; x <= 12; x++) {
  1907. if (listMap.containsKey(x)) {
  1908. tempList.add(listMap.get(x));
  1909. } else {
  1910. SpecificTargetVo vo1 = new SpecificTargetVo();
  1911. vo1.setWpid(wpid);
  1912. // if (wpid.contains("_ZGS")|| wpid.contains("_FGS" + type)) {
  1913. // vo1.setWpname(CacheContext.cpmap.get(companys).getAname());
  1914. // } else if (wpid.contains("_RGN")) {
  1915. // vo1.setWpname(CacheContext.rgmap.get(companys).getAname());
  1916. // } else {
  1917. vo1.setWpname(CacheContext.wpmap.get(wpid).getAname());
  1918. // }
  1919. vo1.setYear(Integer.parseInt(year));
  1920. vo1.setMonth(x);
  1921. tempList.add(vo1);
  1922. }
  1923. }
  1924. vo.setTargetList(tempList);
  1925. resultendList.add(vo);
  1926. SpecificTarget vo2 = new SpecificTarget();
  1927. vo2.setWpid(vo.getWpid());
  1928. vo2.setTargetList(vo.getTargetList());
  1929. vo2.setOrderNum(vo.getOrderNum() + 1);
  1930. vo2.setWpname(CacheContext.cpmap.get(companys).getAname());
  1931. resultendList.add(vo2);
  1932. });
  1933. }
  1934. SortUtils.sort(resultendList, "orderNum", SortUtils.ASC);
  1935. return resultendList;
  1936. }
  1937. public List<SpecificTarget> gwdlList2(String companys, String type, String year) {
  1938. //获取年份所有当月的数据
  1939. QueryWrapper<ProEconPowerstationInfoDay5> currentqw = new QueryWrapper<>();
  1940. currentqw.select("foreign_key_id,max(record_date) record_date,sum(rgwgwdldb) ygwgwdldb");
  1941. currentqw.eq("location", "wp");
  1942. currentqw.eq("to_char(record_date,'yyyy')", year);
  1943. if (type.equals("-1")) {
  1944. currentqw.like("foreign_key_id", "_FDC_");
  1945. } else {
  1946. currentqw.like("foreign_key_id", "_GDC_");
  1947. }
  1948. if (companys.endsWith("ZGS")) {
  1949. currentqw.eq("company_id", companys);
  1950. } else {
  1951. currentqw.eq("region_id", companys);
  1952. }
  1953. currentqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  1954. List<ProEconPowerstationInfoDay5> currentList = proEconPowerstationInfoDay5Service.list(currentqw);
  1955. currentqw.clear();
  1956. currentqw.select("foreign_key_id,max(record_date) record_date,sum(rgwgwdldb) ygwgwdldb");
  1957. currentqw.eq("foreign_key_id", companys + type);
  1958. currentqw.eq("to_char(record_date,'yyyy')", year);
  1959. currentqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  1960. currentList.addAll(proEconPowerstationInfoDay5Service.list(currentqw));
  1961. int subYear = Integer.parseInt(year) - 1;
  1962. QueryWrapper<ProEconPowerstationInfoDay5> sameperiodqw = new QueryWrapper<>();
  1963. sameperiodqw.select("foreign_key_id,max(record_date) record_date,sum(rgwgwdldb) ygwgwdldb");
  1964. sameperiodqw.eq("location", "wp");
  1965. if (type.equals("-1")) {
  1966. currentqw.like("foreign_key_id", "_FDC_");
  1967. } else {
  1968. currentqw.like("foreign_key_id", "_GDC_");
  1969. }
  1970. if (companys.endsWith("ZGS")) {
  1971. currentqw.eq("company_id", companys);
  1972. } else {
  1973. currentqw.eq("region_id", companys);
  1974. }
  1975. sameperiodqw.eq("to_char(record_date,'yyyy')", String.valueOf(subYear));
  1976. sameperiodqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  1977. List<ProEconPowerstationInfoDay5> sameperiodList = proEconPowerstationInfoDay5Service.list(sameperiodqw);
  1978. sameperiodqw.clear();
  1979. sameperiodqw.select("foreign_key_id,max(record_date) record_date,sum(rgwgwdldb) ygwgwdldb");
  1980. sameperiodqw.eq("foreign_key_id", companys + type);
  1981. sameperiodqw.eq("to_char(record_date,'yyyy')", String.valueOf(subYear));
  1982. sameperiodqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  1983. sameperiodList.addAll(proEconPowerstationInfoDay5Service.list(sameperiodqw));
  1984. //合并当月与同期数据为返回结果
  1985. List<SpecificTargetVo> resultList = new ArrayList<>();
  1986. currentList.stream().forEach(i -> {
  1987. SpecificTargetVo vo = new SpecificTargetVo();
  1988. String wpid = i.getForeignKeyId();
  1989. vo.setWpid(wpid);
  1990. if (wpid.contains("_ZGS") || wpid.contains("_FGS" + type)) {
  1991. vo.setWpname(CacheContext.cpmap.get(companys).getAname());
  1992. } else if (wpid.contains("_RGN")) {
  1993. vo.setWpname(CacheContext.rgmap.get(companys).getAname());
  1994. } else {
  1995. vo.setWpname(CacheContext.wpmap.get(wpid).getAname());
  1996. }
  1997. vo.setYear(DateUtils.getYear(i.getRecordDate()));
  1998. vo.setMonth(DateUtils.getMonth(i.getRecordDate()));
  1999. vo.setCurrent(DoubleUtils.keepPrecision(i.getYgwgwdldb().doubleValue() / 10000, 2));
  2000. resultList.add(vo);
  2001. });
  2002. resultList.stream().forEach(i -> {
  2003. Optional<ProEconPowerstationInfoDay5> optional = sameperiodList.stream()
  2004. .filter(j -> j.getForeignKeyId().equals(i.getWpid()) && i.getMonth().equals(DateUtils.getMonthFromDate(j.getRecordDate())))
  2005. .findFirst();
  2006. if (optional.isPresent()) {
  2007. ProEconPowerstationInfoDay5 tqinfoday = optional.get();
  2008. i.setSameperiod(DoubleUtils.keepPrecision(tqinfoday.getYgwgwdldb().doubleValue() / 10000, 2));
  2009. i.setCompare(i.getCurrent().compareTo(i.getSameperiod()));
  2010. } else {
  2011. i.setSameperiod(0.0);
  2012. i.setCompare(0);
  2013. }
  2014. });
  2015. List<SpecificTarget> resultendList = new ArrayList<>();
  2016. Map<String, Map<Integer, SpecificTargetVo>> map = new HashMap<>();
  2017. resultList.stream().forEach(i -> {
  2018. if (map.containsKey(i.getWpid())) {
  2019. Map<Integer, SpecificTargetVo> integerListMap = map.get(i.getWpid());
  2020. if (!integerListMap.containsKey(i.getMonth())) {
  2021. map.get(i.getWpid()).put(i.getMonth(), i);
  2022. } else {
  2023. }
  2024. } else {
  2025. Map<Integer, SpecificTargetVo> tempMap = new HashMap<>();
  2026. tempMap.put(i.getMonth(), i);
  2027. map.put(i.getWpid(), tempMap);
  2028. }
  2029. });
  2030. Set<String> wpids = map.keySet();
  2031. if (StringUtils.isNotNull(wpids)) {
  2032. wpids.stream().forEach(wpid -> {
  2033. SpecificTarget vo = new SpecificTarget();
  2034. vo.setWpid(wpid);
  2035. int orderNum = 100;
  2036. if (wpid.contains("_ZGS") || wpid.contains("_FGS" + type)) {
  2037. vo.setWpname(CacheContext.cpmap.get(companys).getAname());
  2038. } else if (wpid.contains("_RGN")) {
  2039. vo.setWpname(CacheContext.rgmap.get(companys).getAname());
  2040. } else {
  2041. vo.setWpname(CacheContext.wpmap.get(wpid).getAname());
  2042. orderNum = CacheContext.wpmap.get(wpid).getOrderNum();
  2043. }
  2044. vo.setOrderNum(orderNum);
  2045. List<SpecificTargetVo> tempList = new ArrayList<>();
  2046. Map<Integer, SpecificTargetVo> listMap = map.get(wpid);
  2047. for (int x = 1; x <= 12; x++) {
  2048. if (listMap.containsKey(x)) {
  2049. tempList.add(listMap.get(x));
  2050. } else {
  2051. SpecificTargetVo vo1 = new SpecificTargetVo();
  2052. vo1.setWpid(wpid);
  2053. if (wpid.contains("_ZGS") || wpid.contains("_FGS" + type)) {
  2054. vo1.setWpname(CacheContext.cpmap.get(companys).getAname());
  2055. } else if (wpid.contains("_RGN")) {
  2056. vo1.setWpname(CacheContext.rgmap.get(companys).getAname());
  2057. } else {
  2058. vo1.setWpname(CacheContext.wpmap.get(wpid).getAname());
  2059. }
  2060. vo1.setYear(Integer.parseInt(year));
  2061. vo1.setMonth(x);
  2062. tempList.add(vo1);
  2063. }
  2064. }
  2065. vo.setTargetList(tempList);
  2066. resultendList.add(vo);
  2067. });
  2068. }
  2069. SortUtils.sort(resultendList, "orderNum", SortUtils.ASC);
  2070. return resultendList;
  2071. }
  2072. public List<SpecificTarget> gwdlList(String companys, String type, String year) {
  2073. //获取年份所有当月的数据
  2074. QueryWrapper<StationInfoDay> currentqw = new QueryWrapper<>();
  2075. currentqw.select("station_id,max(record_date) record_date,sum(gwdl) gwdl");
  2076. // currentqw.eq("location", "wp");
  2077. currentqw.eq("to_char(record_date,'yyyy')", year);
  2078. if (type.equals("-1")) {
  2079. currentqw.like("station_id", "_FDC_");
  2080. } else {
  2081. currentqw.like("station_id", "_GDC_");
  2082. }
  2083. // if (companys.endsWith("ZGS")) {
  2084. // currentqw.eq("company_id", companys);
  2085. // } else {
  2086. // currentqw.eq("region_id", companys);
  2087. // }
  2088. currentqw.groupBy("to_char(record_date,'yyyy-MM'),station_id");
  2089. List<StationInfoDay> currentList = iStationInfoDayService.list(currentqw);
  2090. currentqw.clear();
  2091. currentqw.select("station_id,max(record_date) record_date,sum(gwdl) gwdl");
  2092. // currentqw.eq("foreign_key_id", companys + type);
  2093. currentqw.eq("to_char(record_date,'yyyy')", year);
  2094. currentqw.groupBy("to_char(record_date,'yyyy-MM'),station_id");
  2095. currentList.addAll(iStationInfoDayService.list(currentqw));
  2096. int subYear = Integer.parseInt(year) - 1;
  2097. QueryWrapper<StationInfoDay> sameperiodqw = new QueryWrapper<>();
  2098. sameperiodqw.select("station_id,max(record_date) record_date,sum(gwdl) gwdl");
  2099. // sameperiodqw.eq("location", "wp");
  2100. if (type.equals("-1")) {
  2101. currentqw.like("station_id", "_FDC_");
  2102. } else {
  2103. currentqw.like("station_id", "_GDC_");
  2104. }
  2105. // if (companys.endsWith("ZGS")) {
  2106. // currentqw.eq("company_id", companys);
  2107. // } else {
  2108. // currentqw.eq("region_id", companys);
  2109. // }
  2110. sameperiodqw.eq("to_char(record_date,'yyyy')", String.valueOf(subYear));
  2111. sameperiodqw.groupBy("to_char(record_date,'yyyy-MM'),station_id");
  2112. List<StationInfoDay> sameperiodList = iStationInfoDayService.list(sameperiodqw);
  2113. sameperiodqw.clear();
  2114. sameperiodqw.select("station_id,max(record_date) record_date,sum(gwdl) gwdl");
  2115. // sameperiodqw.eq("foreign_key_id", companys + type);
  2116. sameperiodqw.eq("to_char(record_date,'yyyy')", String.valueOf(subYear));
  2117. sameperiodqw.groupBy("to_char(record_date,'yyyy-MM'),station_id");
  2118. sameperiodList.addAll(iStationInfoDayService.list(sameperiodqw));
  2119. //合并当月与同期数据为返回结果
  2120. List<SpecificTargetVo> resultList = new ArrayList<>();
  2121. currentList.stream().forEach(i -> {
  2122. SpecificTargetVo vo = new SpecificTargetVo();
  2123. String wpid = i.getStationId();
  2124. vo.setWpid(wpid);
  2125. // if (wpid.contains("_ZGS")|| wpid.contains("_FGS" + type)) {
  2126. // vo.setWpname(CacheContext.cpmap.get(companys).getAname());
  2127. // } else if (wpid.contains("_RGN")) {
  2128. // vo.setWpname(CacheContext.rgmap.get(companys).getAname());
  2129. // } else {
  2130. vo.setWpname(CacheContext.wpmap.get(wpid).getAname());
  2131. // }
  2132. Instant instant = i.getRecordDate().atStartOfDay(ZoneId.systemDefault()).toInstant();
  2133. Date date = Date.from(instant);
  2134. vo.setYear(DateUtils.getYear(date));
  2135. vo.setMonth(DateUtils.getMonth(date));
  2136. vo.setCurrent(DoubleUtils.keepPrecision(i.getGwdl().doubleValue(), 2));
  2137. resultList.add(vo);
  2138. });
  2139. resultList.stream().forEach(i -> {
  2140. Optional<StationInfoDay> optional = sameperiodList.stream()
  2141. .filter(j -> j.getStationId().equals(i.getWpid()) && i.getMonth().equals(DateUtils.getMonthFromDate(Date.from(j.getRecordDate().atStartOfDay(ZoneId.systemDefault()).toInstant()))))
  2142. .findFirst();
  2143. if (optional.isPresent()) {
  2144. StationInfoDay tqinfoday = optional.get();
  2145. i.setSameperiod(DoubleUtils.keepPrecision(tqinfoday.getGwdl().doubleValue(), 2));
  2146. i.setCompare(i.getCurrent().compareTo(i.getSameperiod()));
  2147. } else {
  2148. i.setSameperiod(0.0);
  2149. i.setCompare(0);
  2150. }
  2151. });
  2152. List<SpecificTarget> resultendList = new ArrayList<>();
  2153. Map<String, Map<Integer, SpecificTargetVo>> map = new HashMap<>();
  2154. resultList.stream().forEach(i -> {
  2155. if (map.containsKey(i.getWpid())) {
  2156. Map<Integer, SpecificTargetVo> integerListMap = map.get(i.getWpid());
  2157. if (!integerListMap.containsKey(i.getMonth())) {
  2158. map.get(i.getWpid()).put(i.getMonth(), i);
  2159. } else {
  2160. }
  2161. } else {
  2162. Map<Integer, SpecificTargetVo> tempMap = new HashMap<>();
  2163. tempMap.put(i.getMonth(), i);
  2164. map.put(i.getWpid(), tempMap);
  2165. }
  2166. });
  2167. Set<String> wpids = map.keySet();
  2168. if (StringUtils.isNotNull(wpids)) {
  2169. wpids.stream().forEach(wpid -> {
  2170. SpecificTarget vo = new SpecificTarget();
  2171. vo.setWpid(wpid);
  2172. int orderNum = 100;
  2173. // if (wpid.contains("_ZGS")|| wpid.contains("_FGS" + type)) {
  2174. // vo.setWpname(CacheContext.cpmap.get(companys).getAname());
  2175. // } else if (wpid.contains("_RGN")) {
  2176. // vo.setWpname(CacheContext.rgmap.get(companys).getAname());
  2177. // } else {
  2178. vo.setWpname(CacheContext.wpmap.get(wpid).getAname());
  2179. orderNum = CacheContext.wpmap.get(wpid).getOrderNum();
  2180. // }
  2181. vo.setOrderNum(orderNum);
  2182. List<SpecificTargetVo> tempList = new ArrayList<>();
  2183. Map<Integer, SpecificTargetVo> listMap = map.get(wpid);
  2184. for (int x = 1; x <= 12; x++) {
  2185. if (listMap.containsKey(x)) {
  2186. tempList.add(listMap.get(x));
  2187. } else {
  2188. SpecificTargetVo vo1 = new SpecificTargetVo();
  2189. vo1.setWpid(wpid);
  2190. // if (wpid.contains("_ZGS")|| wpid.contains("_FGS" + type)) {
  2191. // vo1.setWpname(CacheContext.cpmap.get(companys).getAname());
  2192. // } else if (wpid.contains("_RGN")) {
  2193. // vo1.setWpname(CacheContext.rgmap.get(companys).getAname());
  2194. // } else {
  2195. vo1.setWpname(CacheContext.wpmap.get(wpid).getAname());
  2196. // }
  2197. vo1.setYear(Integer.parseInt(year));
  2198. vo1.setMonth(x);
  2199. tempList.add(vo1);
  2200. }
  2201. }
  2202. vo.setTargetList(tempList);
  2203. resultendList.add(vo);
  2204. SpecificTarget vo2 = new SpecificTarget();
  2205. vo2.setWpid(vo.getWpid());
  2206. vo2.setTargetList(vo.getTargetList());
  2207. vo2.setOrderNum(vo.getOrderNum() + 1);
  2208. vo2.setWpname(CacheContext.cpmap.get(companys).getAname());
  2209. resultendList.add(vo2);
  2210. });
  2211. }
  2212. SortUtils.sort(resultendList, "orderNum", SortUtils.ASC);
  2213. return resultendList;
  2214. }
  2215. public List<SpecificTarget> swdlList2(String companys, String type, String year) {
  2216. //获取年份所有当月的数据
  2217. QueryWrapper<ProEconPowerstationInfoDay5> currentqw = new QueryWrapper<>();
  2218. currentqw.select("foreign_key_id,max(record_date) record_date,sum(rswdldb) yswdldb");
  2219. currentqw.eq("location", "wp");
  2220. currentqw.eq("to_char(record_date,'yyyy')", year);
  2221. if (type.equals("-1")) {
  2222. currentqw.like("foreign_key_id", "_FDC_");
  2223. } else {
  2224. currentqw.like("foreign_key_id", "_GDC_");
  2225. }
  2226. if (companys.endsWith("ZGS")) {
  2227. currentqw.eq("company_id", companys);
  2228. } else {
  2229. currentqw.eq("region_id", companys);
  2230. }
  2231. currentqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  2232. List<ProEconPowerstationInfoDay5> currentList = proEconPowerstationInfoDay5Service.list(currentqw);
  2233. currentqw.clear();
  2234. currentqw.select("foreign_key_id,max(record_date) record_date,sum(rswdldb) yswdldb");
  2235. currentqw.eq("foreign_key_id", companys + type);
  2236. currentqw.eq("to_char(record_date,'yyyy')", year);
  2237. currentqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  2238. currentList.addAll(proEconPowerstationInfoDay5Service.list(currentqw));
  2239. int subYear = Integer.parseInt(year) - 1;
  2240. QueryWrapper<ProEconPowerstationInfoDay5> sameperiodqw = new QueryWrapper<>();
  2241. sameperiodqw.select("foreign_key_id,max(record_date) record_date,sum(rswdldb) yswdldb");
  2242. sameperiodqw.eq("location", "wp");
  2243. if (type.equals("-1")) {
  2244. currentqw.like("foreign_key_id", "_FDC_");
  2245. } else {
  2246. currentqw.like("foreign_key_id", "_GDC_");
  2247. }
  2248. if (companys.endsWith("ZGS")) {
  2249. currentqw.eq("company_id", companys);
  2250. } else {
  2251. currentqw.eq("region_id", companys);
  2252. }
  2253. sameperiodqw.eq("to_char(record_date,'yyyy')", String.valueOf(subYear));
  2254. sameperiodqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  2255. List<ProEconPowerstationInfoDay5> sameperiodList = proEconPowerstationInfoDay5Service.list(sameperiodqw);
  2256. sameperiodqw.clear();
  2257. sameperiodqw.select("foreign_key_id,max(record_date) record_date,sum(rswdldb) yswdldb");
  2258. sameperiodqw.eq("foreign_key_id", companys + type);
  2259. sameperiodqw.eq("to_char(record_date,'yyyy')", String.valueOf(subYear));
  2260. sameperiodqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  2261. sameperiodList.addAll(proEconPowerstationInfoDay5Service.list(sameperiodqw));
  2262. //合并当月与同期数据为返回结果
  2263. List<SpecificTargetVo> resultList = new ArrayList<>();
  2264. currentList.stream().forEach(i -> {
  2265. SpecificTargetVo vo = new SpecificTargetVo();
  2266. String wpid = i.getForeignKeyId();
  2267. vo.setWpid(wpid);
  2268. if (wpid.contains("_ZGS") || wpid.contains("_FGS" + type)) {
  2269. vo.setWpname(CacheContext.cpmap.get(companys).getAname());
  2270. } else if (wpid.contains("_RGN")) {
  2271. vo.setWpname(CacheContext.rgmap.get(companys).getAname());
  2272. } else {
  2273. vo.setWpname(CacheContext.wpmap.get(wpid).getAname());
  2274. }
  2275. vo.setYear(DateUtils.getYear(i.getRecordDate()));
  2276. vo.setMonth(DateUtils.getMonth(i.getRecordDate()));
  2277. vo.setCurrent(DoubleUtils.keepPrecision(i.getYswdldb().doubleValue() / 10000, 2));
  2278. resultList.add(vo);
  2279. });
  2280. resultList.stream().forEach(i -> {
  2281. Optional<ProEconPowerstationInfoDay5> optional = sameperiodList.stream()
  2282. .filter(j -> j.getForeignKeyId().equals(i.getWpid()) && i.getMonth().equals(DateUtils.getMonthFromDate(j.getRecordDate())))
  2283. .findFirst();
  2284. if (optional.isPresent()) {
  2285. ProEconPowerstationInfoDay5 tqinfoday = optional.get();
  2286. i.setSameperiod(DoubleUtils.keepPrecision(tqinfoday.getYswdldb().doubleValue() / 10000, 2));
  2287. i.setCompare(i.getCurrent().compareTo(i.getSameperiod()));
  2288. } else {
  2289. i.setSameperiod(0.0);
  2290. i.setCompare(0);
  2291. }
  2292. });
  2293. List<SpecificTarget> resultendList = new ArrayList<>();
  2294. Map<String, Map<Integer, SpecificTargetVo>> map = new HashMap<>();
  2295. resultList.stream().forEach(i -> {
  2296. if (map.containsKey(i.getWpid())) {
  2297. Map<Integer, SpecificTargetVo> integerListMap = map.get(i.getWpid());
  2298. if (!integerListMap.containsKey(i.getMonth())) {
  2299. map.get(i.getWpid()).put(i.getMonth(), i);
  2300. } else {
  2301. }
  2302. } else {
  2303. Map<Integer, SpecificTargetVo> tempMap = new HashMap<>();
  2304. tempMap.put(i.getMonth(), i);
  2305. map.put(i.getWpid(), tempMap);
  2306. }
  2307. });
  2308. Set<String> wpids = map.keySet();
  2309. if (StringUtils.isNotNull(wpids)) {
  2310. wpids.stream().forEach(wpid -> {
  2311. SpecificTarget vo = new SpecificTarget();
  2312. vo.setWpid(wpid);
  2313. int orderNum = 100;
  2314. if (wpid.contains("_ZGS") || wpid.contains("_FGS" + type)) {
  2315. vo.setWpname(CacheContext.cpmap.get(companys).getAname());
  2316. } else if (wpid.contains("_RGN")) {
  2317. vo.setWpname(CacheContext.rgmap.get(companys).getAname());
  2318. } else {
  2319. vo.setWpname(CacheContext.wpmap.get(wpid).getAname());
  2320. orderNum = CacheContext.wpmap.get(wpid).getOrderNum();
  2321. }
  2322. vo.setOrderNum(orderNum);
  2323. List<SpecificTargetVo> tempList = new ArrayList<>();
  2324. Map<Integer, SpecificTargetVo> listMap = map.get(wpid);
  2325. for (int x = 1; x <= 12; x++) {
  2326. if (listMap.containsKey(x)) {
  2327. tempList.add(listMap.get(x));
  2328. } else {
  2329. SpecificTargetVo vo1 = new SpecificTargetVo();
  2330. vo1.setWpid(wpid);
  2331. if (wpid.contains("_ZGS") || wpid.contains("_FGS" + type)) {
  2332. vo1.setWpname(CacheContext.cpmap.get(companys).getAname());
  2333. } else if (wpid.contains("_RGN")) {
  2334. vo1.setWpname(CacheContext.rgmap.get(companys).getAname());
  2335. } else {
  2336. vo1.setWpname(CacheContext.wpmap.get(wpid).getAname());
  2337. }
  2338. vo1.setYear(Integer.parseInt(year));
  2339. vo1.setMonth(x);
  2340. tempList.add(vo1);
  2341. }
  2342. }
  2343. vo.setTargetList(tempList);
  2344. resultendList.add(vo);
  2345. });
  2346. }
  2347. SortUtils.sort(resultendList, "orderNum", SortUtils.ASC);
  2348. return resultendList;
  2349. }
  2350. public List<SpecificTarget> swdlList(String companys, String type, String year) {
  2351. //获取年份所有当月的数据
  2352. QueryWrapper<StationInfoDay> currentqw = new QueryWrapper<>();
  2353. currentqw.select("station_id,max(record_date) record_date,sum(swdl) swdl");
  2354. // currentqw.eq("location", "wp");
  2355. currentqw.eq("to_char(record_date,'yyyy')", year);
  2356. if (type.equals("-1")) {
  2357. currentqw.like("station_id", "_FDC_");
  2358. } else {
  2359. currentqw.like("station_id", "_GDC_");
  2360. }
  2361. // if (companys.endsWith("ZGS")) {
  2362. // currentqw.eq("company_id", companys);
  2363. // } else {
  2364. // currentqw.eq("region_id", companys);
  2365. // }
  2366. currentqw.groupBy("to_char(record_date,'yyyy-MM'),station_id");
  2367. List<StationInfoDay> currentList = iStationInfoDayService.list(currentqw);
  2368. currentqw.clear();
  2369. currentqw.select("station_id,max(record_date) record_date,sum(swdl) swdl");
  2370. // currentqw.eq("foreign_key_id", companys + type);
  2371. currentqw.eq("to_char(record_date,'yyyy')", year);
  2372. currentqw.groupBy("to_char(record_date,'yyyy-MM'),station_id");
  2373. currentList.addAll(iStationInfoDayService.list(currentqw));
  2374. int subYear = Integer.parseInt(year) - 1;
  2375. QueryWrapper<StationInfoDay> sameperiodqw = new QueryWrapper<>();
  2376. sameperiodqw.select("station_id,max(record_date) record_date,sum(swdl) swdl");
  2377. // sameperiodqw.eq("location", "wp");
  2378. if (type.equals("-1")) {
  2379. currentqw.like("station_id", "_FDC_");
  2380. } else {
  2381. currentqw.like("station_id", "_GDC_");
  2382. }
  2383. // if (companys.endsWith("ZGS")) {
  2384. // currentqw.eq("company_id", companys);
  2385. // } else {
  2386. // currentqw.eq("region_id", companys);
  2387. // }
  2388. sameperiodqw.eq("to_char(record_date,'yyyy')", String.valueOf(subYear));
  2389. sameperiodqw.groupBy("to_char(record_date,'yyyy-MM'),station_id");
  2390. List<StationInfoDay> sameperiodList = iStationInfoDayService.list(sameperiodqw);
  2391. sameperiodqw.clear();
  2392. sameperiodqw.select("station_id,max(record_date) record_date,sum(swdl) swdl");
  2393. // sameperiodqw.eq("foreign_key_id", companys + type);
  2394. sameperiodqw.eq("to_char(record_date,'yyyy')", String.valueOf(subYear));
  2395. sameperiodqw.groupBy("to_char(record_date,'yyyy-MM'),station_id");
  2396. sameperiodList.addAll(iStationInfoDayService.list(sameperiodqw));
  2397. //合并当月与同期数据为返回结果
  2398. List<SpecificTargetVo> resultList = new ArrayList<>();
  2399. currentList.stream().forEach(i -> {
  2400. SpecificTargetVo vo = new SpecificTargetVo();
  2401. String wpid = i.getStationId();
  2402. vo.setWpid(wpid);
  2403. // if (wpid.contains("_ZGS")|| wpid.contains("_FGS" + type)) {
  2404. // vo.setWpname(CacheContext.cpmap.get(companys).getAname());
  2405. // } else if (wpid.contains("_RGN")) {
  2406. // vo.setWpname(CacheContext.rgmap.get(companys).getAname());
  2407. // } else {
  2408. vo.setWpname(CacheContext.wpmap.get(wpid).getAname());
  2409. // }
  2410. Instant instant = i.getRecordDate().atStartOfDay(ZoneId.systemDefault()).toInstant();
  2411. Date date = Date.from(instant);
  2412. vo.setYear(DateUtils.getYear(date));
  2413. vo.setMonth(DateUtils.getMonth(date));
  2414. vo.setCurrent(DoubleUtils.keepPrecision(i.getSwdl().doubleValue(), 2));
  2415. resultList.add(vo);
  2416. });
  2417. resultList.stream().forEach(i -> {
  2418. Optional<StationInfoDay> optional = sameperiodList.stream()
  2419. .filter(j -> j.getStationId().equals(i.getWpid()) && i.getMonth().equals(DateUtils.getMonthFromDate(Date.from(j.getRecordDate().atStartOfDay(ZoneId.systemDefault()).toInstant()))))
  2420. .findFirst();
  2421. if (optional.isPresent()) {
  2422. StationInfoDay tqinfoday = optional.get();
  2423. i.setSameperiod(DoubleUtils.keepPrecision(tqinfoday.getSwdl().doubleValue(), 2));
  2424. i.setCompare(i.getCurrent().compareTo(i.getSameperiod()));
  2425. } else {
  2426. i.setSameperiod(0.0);
  2427. i.setCompare(0);
  2428. }
  2429. });
  2430. List<SpecificTarget> resultendList = new ArrayList<>();
  2431. Map<String, Map<Integer, SpecificTargetVo>> map = new HashMap<>();
  2432. resultList.stream().forEach(i -> {
  2433. if (map.containsKey(i.getWpid())) {
  2434. Map<Integer, SpecificTargetVo> integerListMap = map.get(i.getWpid());
  2435. if (!integerListMap.containsKey(i.getMonth())) {
  2436. map.get(i.getWpid()).put(i.getMonth(), i);
  2437. } else {
  2438. }
  2439. } else {
  2440. Map<Integer, SpecificTargetVo> tempMap = new HashMap<>();
  2441. tempMap.put(i.getMonth(), i);
  2442. map.put(i.getWpid(), tempMap);
  2443. }
  2444. });
  2445. Set<String> wpids = map.keySet();
  2446. if (StringUtils.isNotNull(wpids)) {
  2447. wpids.stream().forEach(wpid -> {
  2448. SpecificTarget vo = new SpecificTarget();
  2449. vo.setWpid(wpid);
  2450. int orderNum = 100;
  2451. // if (wpid.contains("_ZGS")|| wpid.contains("_FGS" + type)) {
  2452. // vo.setWpname(CacheContext.cpmap.get(companys).getAname());
  2453. // } else if (wpid.contains("_RGN")) {
  2454. // vo.setWpname(CacheContext.rgmap.get(companys).getAname());
  2455. // } else {
  2456. vo.setWpname(CacheContext.wpmap.get(wpid).getAname());
  2457. orderNum = CacheContext.wpmap.get(wpid).getOrderNum();
  2458. // }
  2459. vo.setOrderNum(orderNum);
  2460. List<SpecificTargetVo> tempList = new ArrayList<>();
  2461. Map<Integer, SpecificTargetVo> listMap = map.get(wpid);
  2462. for (int x = 1; x <= 12; x++) {
  2463. if (listMap.containsKey(x)) {
  2464. tempList.add(listMap.get(x));
  2465. } else {
  2466. SpecificTargetVo vo1 = new SpecificTargetVo();
  2467. vo1.setWpid(wpid);
  2468. if (wpid.contains("_ZGS") || wpid.contains("_FGS" + type)) {
  2469. vo1.setWpname(CacheContext.cpmap.get(companys).getAname());
  2470. } else if (wpid.contains("_RGN")) {
  2471. vo1.setWpname(CacheContext.rgmap.get(companys).getAname());
  2472. } else {
  2473. vo1.setWpname(CacheContext.wpmap.get(wpid).getAname());
  2474. }
  2475. vo1.setYear(Integer.parseInt(year));
  2476. vo1.setMonth(x);
  2477. tempList.add(vo1);
  2478. }
  2479. }
  2480. vo.setTargetList(tempList);
  2481. resultendList.add(vo);
  2482. SpecificTarget vo2 = new SpecificTarget();
  2483. vo2.setWpid(vo.getWpid());
  2484. vo2.setTargetList(vo.getTargetList());
  2485. vo2.setOrderNum(vo.getOrderNum() + 1);
  2486. vo2.setWpname(CacheContext.cpmap.get(companys).getAname());
  2487. resultendList.add(vo2);
  2488. });
  2489. }
  2490. SortUtils.sort(resultendList, "orderNum", SortUtils.ASC);
  2491. return resultendList;
  2492. }
  2493. public List<SpecificTarget> lyxsList2(String companys, String type, String year) {
  2494. //获取年份所有当月的数据
  2495. QueryWrapper<ProEconPowerstationInfoDay5> currentqw = new QueryWrapper<>();
  2496. currentqw.select("foreign_key_id,max(record_date) record_date,sum(rfdldb) yfdldb");
  2497. currentqw.eq("location", "wp");
  2498. currentqw.eq("to_char(record_date,'yyyy')", year);
  2499. if (type.equals("-1")) {
  2500. currentqw.like("foreign_key_id", "_FDC_");
  2501. } else {
  2502. currentqw.like("foreign_key_id", "_GDC_");
  2503. }
  2504. if (companys.endsWith("ZGS")) {
  2505. currentqw.eq("company_id", companys);
  2506. } else {
  2507. currentqw.eq("region_id", companys);
  2508. }
  2509. currentqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  2510. List<ProEconPowerstationInfoDay5> currentList = proEconPowerstationInfoDay5Service.list(currentqw);
  2511. currentqw.clear();
  2512. currentqw.select("foreign_key_id,max(record_date) record_date,sum(rfdldb) yfdldb");
  2513. currentqw.eq("foreign_key_id", companys + type);
  2514. currentqw.eq("to_char(record_date,'yyyy')", year);
  2515. currentqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  2516. currentList.addAll(proEconPowerstationInfoDay5Service.list(currentqw));
  2517. // int subYear = Integer.parseInt(year) - 1;
  2518. int subYear = Integer.parseInt(year);
  2519. QueryWrapper<ProEconPowerstationInfoDay5> sameperiodqw = new QueryWrapper<>();
  2520. sameperiodqw.select("foreign_key_id,max(record_date) record_date,sum(rfdldb) yfdldb");
  2521. sameperiodqw.eq("location", "wp");
  2522. if (type.equals("-1")) {
  2523. currentqw.like("foreign_key_id", "_FDC_");
  2524. } else {
  2525. currentqw.like("foreign_key_id", "_GDC_");
  2526. }
  2527. if (companys.endsWith("ZGS")) {
  2528. currentqw.eq("company_id", companys);
  2529. } else {
  2530. currentqw.eq("region_id", companys);
  2531. }
  2532. sameperiodqw.eq("to_char(record_date,'yyyy')", String.valueOf(subYear));
  2533. sameperiodqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  2534. List<ProEconPowerstationInfoDay5> sameperiodList = proEconPowerstationInfoDay5Service.list(sameperiodqw);
  2535. sameperiodqw.clear();
  2536. sameperiodqw.select("foreign_key_id,max(record_date) record_date,sum(rfdldb) yfdldb");
  2537. sameperiodqw.eq("foreign_key_id", companys + type);
  2538. sameperiodqw.eq("to_char(record_date,'yyyy')", String.valueOf(subYear));
  2539. sameperiodqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  2540. sameperiodList.addAll(proEconPowerstationInfoDay5Service.list(sameperiodqw));
  2541. //合并当月与同期数据为返回结果
  2542. List<SpecificTargetVo> resultList = new ArrayList<>();
  2543. currentList.stream().forEach(i -> {
  2544. SpecificTargetVo vo = new SpecificTargetVo();
  2545. String wpid = i.getForeignKeyId();
  2546. List<ProBasicPowerstation> rl = CacheContext.wpls.stream().filter(wp -> wpid.equals(wp.getId())).collect(Collectors.toList());
  2547. List<ProBasicCompany> gsrl = CacheContext.cpls.stream().filter(wp -> wpid.contains(wp.getId())).collect(Collectors.toList());
  2548. double capacity = 1;
  2549. if (!rl.isEmpty() && rl.size() > 0) {
  2550. capacity = (rl.get(0).getJrCapacity() / 10000) + (rl.get(0).getJrwindCapacity() / 10000);
  2551. } else {
  2552. capacity = (gsrl.get(0).getJrCapacity() / 10000) + (gsrl.get(0).getJrwindCapacity() / 10000);
  2553. }
  2554. vo.setWpid(wpid);
  2555. if (wpid.contains("_ZGS") || wpid.contains("_FGS" + type)) {
  2556. vo.setWpname(CacheContext.cpmap.get(companys).getAname());
  2557. } else if (wpid.contains("_RGN")) {
  2558. vo.setWpname(CacheContext.rgmap.get(companys).getAname());
  2559. } else {
  2560. vo.setWpname(CacheContext.wpmap.get(wpid).getAname());
  2561. }
  2562. vo.setYear(DateUtils.getYear(i.getRecordDate()));
  2563. vo.setMonth(DateUtils.getMonth(i.getRecordDate()));
  2564. vo.setCurrent(DoubleUtils.keepPrecision((i.getYfdldb().doubleValue() / 10000) / capacity, 2));
  2565. resultList.add(vo);
  2566. });
  2567. resultList.stream().forEach(i -> {
  2568. Optional<ProEconPowerstationInfoDay5> optional = sameperiodList.stream()
  2569. .filter(j -> i.getWpid().equals(j.getForeignKeyId())
  2570. && i.getMonth().equals(DateUtils.getMonthFromDate(j.getRecordDate())))
  2571. .findFirst();
  2572. List<ProBasicPowerstation> rl = CacheContext.wpls.stream().filter(wp -> i.getWpid().equals(wp.getId())).collect(Collectors.toList());
  2573. List<ProBasicCompany> gsrl = CacheContext.cpls.stream().filter(wp -> i.getWpid().contains(wp.getId())).collect(Collectors.toList());
  2574. double capacity = 1;
  2575. if (!rl.isEmpty() && rl.size() > 0) {
  2576. capacity = (rl.get(0).getJrCapacity() / 10000) + (rl.get(0).getJrwindCapacity() / 10000);
  2577. } else {
  2578. capacity = (gsrl.get(0).getJrCapacity() / 10000) + (gsrl.get(0).getJrwindCapacity() / 10000);
  2579. }
  2580. if (optional.isPresent()) {
  2581. ProEconPowerstationInfoDay5 tqinfoday = optional.get();
  2582. i.setSameperiod(DoubleUtils.keepPrecision(((tqinfoday.getYfdldb().doubleValue() / 10000)) / capacity, 2));
  2583. i.setCompare(i.getCurrent().compareTo(i.getSameperiod()));
  2584. } else {
  2585. i.setSameperiod(0.0);
  2586. i.setCompare(0);
  2587. }
  2588. });
  2589. List<SpecificTarget> resultendList = new ArrayList<>();
  2590. Map<String, Map<Integer, SpecificTargetVo>> map = new HashMap<>();
  2591. resultList.stream().forEach(i -> {
  2592. if (map.containsKey(i.getWpid())) {
  2593. Map<Integer, SpecificTargetVo> integerListMap = map.get(i.getWpid());
  2594. if (!integerListMap.containsKey(i.getMonth())) {
  2595. map.get(i.getWpid()).put(i.getMonth(), i);
  2596. } else {
  2597. }
  2598. } else {
  2599. Map<Integer, SpecificTargetVo> tempMap = new HashMap<>();
  2600. tempMap.put(i.getMonth(), i);
  2601. map.put(i.getWpid(), tempMap);
  2602. }
  2603. });
  2604. Set<String> wpids = map.keySet();
  2605. if (StringUtils.isNotNull(wpids)) {
  2606. wpids.stream().forEach(wpid -> {
  2607. SpecificTarget vo = new SpecificTarget();
  2608. vo.setWpid(wpid);
  2609. int orderNum = 100;
  2610. if (wpid.contains("_ZGS") || wpid.contains("_FGS" + type)) {
  2611. vo.setWpname(CacheContext.cpmap.get(companys).getAname());
  2612. } else if (wpid.contains("_RGN")) {
  2613. vo.setWpname(CacheContext.rgmap.get(companys).getAname());
  2614. } else {
  2615. vo.setWpname(CacheContext.wpmap.get(wpid).getAname());
  2616. orderNum = CacheContext.wpmap.get(wpid).getOrderNum();
  2617. }
  2618. vo.setOrderNum(orderNum);
  2619. List<SpecificTargetVo> tempList = new ArrayList<>();
  2620. Map<Integer, SpecificTargetVo> listMap = map.get(wpid);
  2621. for (int x = 1; x <= 12; x++) {
  2622. if (listMap.containsKey(x)) {
  2623. tempList.add(listMap.get(x));
  2624. } else {
  2625. SpecificTargetVo vo1 = new SpecificTargetVo();
  2626. vo1.setWpid(wpid);
  2627. if (wpid.contains("_ZGS") || wpid.contains("_FGS" + type)) {
  2628. vo1.setWpname(CacheContext.cpmap.get(companys).getAname());
  2629. } else if (wpid.contains("_RGN")) {
  2630. vo1.setWpname(CacheContext.rgmap.get(companys).getAname());
  2631. } else {
  2632. vo1.setWpname(CacheContext.wpmap.get(wpid).getAname());
  2633. }
  2634. vo1.setYear(Integer.parseInt(year));
  2635. vo1.setMonth(x);
  2636. tempList.add(vo1);
  2637. }
  2638. }
  2639. vo.setTargetList(tempList);
  2640. resultendList.add(vo);
  2641. });
  2642. }
  2643. SortUtils.sort(resultendList, "orderNum", SortUtils.ASC);
  2644. return resultendList;
  2645. }
  2646. public List<SpecificTarget> lyxsList(String companys, String type, String year) {
  2647. //获取年份所有当月的数据
  2648. QueryWrapper<TurbineInfoDay> currentqw = new QueryWrapper<>();
  2649. currentqw.select("station_id,max(record_date) record_date,sum(lyxs) lyxs");
  2650. currentqw.eq("to_char(record_date,'yyyy')", year);
  2651. if (type.equals("-1")) {
  2652. currentqw.like("station_id", "_FDC_");
  2653. } else {
  2654. currentqw.like("station_id", "_GDC_");
  2655. }
  2656. currentqw.groupBy("to_char(record_date,'yyyy-MM'),station_id");
  2657. List<TurbineInfoDay> currentList = iTurbineInfoDayService.list(currentqw);
  2658. int subYear = Integer.parseInt(year);
  2659. QueryWrapper<TurbineInfoDay> sameperiodqw = new QueryWrapper<>();
  2660. sameperiodqw.select("station_id,max(record_date) record_date,sum(lyxs) lyxs");
  2661. if (type.equals("-1")) {
  2662. currentqw.like("station_id", "_FDC_");
  2663. } else {
  2664. currentqw.like("station_id", "_GDC_");
  2665. }
  2666. sameperiodqw.eq("to_char(record_date,'yyyy')", String.valueOf(subYear-1));
  2667. sameperiodqw.groupBy("to_char(record_date,'yyyy-MM'),station_id");
  2668. List<TurbineInfoDay> sameperiodList = iTurbineInfoDayService.list(sameperiodqw);
  2669. //合并当月与同期数据为返回结果
  2670. List<SpecificTargetVo> resultList = new ArrayList<>();
  2671. currentList.stream().forEach(i -> {
  2672. SpecificTargetVo vo = new SpecificTargetVo();
  2673. String wpid = i.getStationId();
  2674. vo.setWpid(wpid);
  2675. vo.setWpname(CacheContext.wpmap.get(wpid).getAname());
  2676. vo.setYear(DateUtils.getYear(i.getRecordDate()));
  2677. vo.setMonth(DateUtils.getMonth(i.getRecordDate()));
  2678. vo.setCurrent(i.getLyxs()/50);
  2679. resultList.add(vo);
  2680. });
  2681. resultList.stream().forEach(i -> {
  2682. Optional<TurbineInfoDay> optional = sameperiodList.stream()
  2683. .filter(j -> i.getWpid().equals(j.getStationId())
  2684. && i.getMonth().equals(DateUtils.getMonthFromDate(j.getRecordDate())))
  2685. .findFirst();
  2686. if (optional.isPresent()) {
  2687. TurbineInfoDay tqinfoday = optional.get();
  2688. i.setSameperiod(tqinfoday.getLyxs()/50);
  2689. i.setCompare(i.getCurrent().compareTo(i.getSameperiod()));
  2690. } else {
  2691. i.setSameperiod(0.0);
  2692. i.setCompare(0);
  2693. }
  2694. });
  2695. List<SpecificTarget> resultendList = new ArrayList<>();
  2696. Map<String, Map<Integer, SpecificTargetVo>> map = new HashMap<>();
  2697. resultList.stream().forEach(i -> {
  2698. if (map.containsKey(i.getWpid())) {
  2699. Map<Integer, SpecificTargetVo> integerListMap = map.get(i.getWpid());
  2700. if (!integerListMap.containsKey(i.getMonth())) {
  2701. map.get(i.getWpid()).put(i.getMonth(), i);
  2702. }
  2703. } else {
  2704. Map<Integer, SpecificTargetVo> tempMap = new HashMap<>();
  2705. tempMap.put(i.getMonth(), i);
  2706. map.put(i.getWpid(), tempMap);
  2707. }
  2708. });
  2709. Set<String> wpids = map.keySet();
  2710. if (StringUtils.isNotNull(wpids)) {
  2711. wpids.stream().forEach(wpid -> {
  2712. SpecificTarget vo = new SpecificTarget();
  2713. vo.setWpid(wpid);
  2714. int orderNum = 100;
  2715. vo.setWpname(CacheContext.wpmap.get(wpid).getAname());
  2716. orderNum = CacheContext.wpmap.get(wpid).getOrderNum();
  2717. vo.setOrderNum(orderNum);
  2718. List<SpecificTargetVo> tempList = new ArrayList<>();
  2719. Map<Integer, SpecificTargetVo> listMap = map.get(wpid);
  2720. for (int x = 1; x <= 12; x++) {
  2721. if (listMap.containsKey(x)) {
  2722. tempList.add(listMap.get(x));
  2723. } else {
  2724. SpecificTargetVo vo1 = new SpecificTargetVo();
  2725. vo1.setWpid(wpid);
  2726. vo1.setWpname(CacheContext.wpmap.get(wpid).getAname());
  2727. vo1.setYear(Integer.parseInt(year));
  2728. vo1.setMonth(x);
  2729. tempList.add(vo1);
  2730. }
  2731. }
  2732. vo.setTargetList(tempList);
  2733. resultendList.add(vo);
  2734. SpecificTarget vo2 = new SpecificTarget();
  2735. vo2.setWpid(vo.getWpid());
  2736. vo2.setTargetList(vo.getTargetList());
  2737. vo2.setOrderNum(vo.getOrderNum() + 1);
  2738. vo2.setWpname(CacheContext.cpmap.get(companys).getAname());
  2739. resultendList.add(vo2);
  2740. });
  2741. }
  2742. SortUtils.sort(resultendList, "orderNum", SortUtils.ASC);
  2743. return resultendList;
  2744. }
  2745. public List<SpecificTarget> lyxsList3(String companys, String type, String year) {
  2746. //获取年份所有当月的数据
  2747. QueryWrapper<StationInfoDay> currentqw = new QueryWrapper<>();
  2748. currentqw.select("station_id,max(record_date) record_date,sum(rfdl_fj) rfdl_fj");
  2749. // currentqw.eq("location", "wp");
  2750. currentqw.eq("to_char(record_date,'yyyy')", year);
  2751. if (type.equals("-1")) {
  2752. currentqw.like("station_id", "_FDC_");
  2753. } else {
  2754. currentqw.like("station_id", "_GDC_");
  2755. }
  2756. // if (companys.endsWith("ZGS")) {
  2757. // currentqw.eq("company_id", companys);
  2758. // } else {
  2759. // currentqw.eq("region_id", companys);
  2760. // }
  2761. currentqw.groupBy("to_char(record_date,'yyyy-MM'),station_id");
  2762. List<StationInfoDay> currentList = iStationInfoDayService.list(currentqw);
  2763. currentqw.clear();
  2764. currentqw.select("station_id,max(record_date) record_date,sum(rfdl_fj) rfdl_fj");
  2765. // currentqw.eq("foreign_key_id", companys + type);
  2766. currentqw.eq("to_char(record_date,'yyyy')", year);
  2767. currentqw.groupBy("to_char(record_date,'yyyy-MM'),station_id");
  2768. currentList.addAll(iStationInfoDayService.list(currentqw));
  2769. // int subYear = Integer.parseInt(year) - 1;
  2770. int subYear = Integer.parseInt(year);
  2771. QueryWrapper<StationInfoDay> sameperiodqw = new QueryWrapper<>();
  2772. sameperiodqw.select("station_id,max(record_date) record_date,sum(rfdl_fj) rfdl_fj");
  2773. // sameperiodqw.eq("location", "wp");
  2774. if (type.equals("-1")) {
  2775. currentqw.like("station_id", "_FDC_");
  2776. } else {
  2777. currentqw.like("station_id", "_GDC_");
  2778. }
  2779. // if (companys.endsWith("ZGS")) {
  2780. // currentqw.eq("company_id", companys);
  2781. // } else {
  2782. // currentqw.eq("region_id", companys);
  2783. // }
  2784. sameperiodqw.eq("to_char(record_date,'yyyy')", String.valueOf(subYear));
  2785. sameperiodqw.groupBy("to_char(record_date,'yyyy-MM'),station_id");
  2786. List<StationInfoDay> sameperiodList = iStationInfoDayService.list(sameperiodqw);
  2787. sameperiodqw.clear();
  2788. sameperiodqw.select("station_id,max(record_date) record_date,sum(rfdl_fj) rfdl_fj");
  2789. // sameperiodqw.eq("foreign_key_id", companys + type);
  2790. sameperiodqw.eq("to_char(record_date,'yyyy')", String.valueOf(subYear));
  2791. sameperiodqw.groupBy("to_char(record_date,'yyyy-MM'),station_id");
  2792. sameperiodList.addAll(iStationInfoDayService.list(sameperiodqw));
  2793. //合并当月与同期数据为返回结果
  2794. List<SpecificTargetVo> resultList = new ArrayList<>();
  2795. currentList.stream().forEach(i -> {
  2796. SpecificTargetVo vo = new SpecificTargetVo();
  2797. String wpid = i.getStationId();
  2798. List<ProBasicPowerstation> rl = CacheContext.wpls.stream().filter(wp -> wpid.equals(wp.getId())).collect(Collectors.toList());
  2799. List<ProBasicCompany> gsrl = CacheContext.cpls.stream().filter(wp -> wpid.contains(wp.getId())).collect(Collectors.toList());
  2800. double capacity = 1;
  2801. if (!rl.isEmpty() && rl.size() > 0) {
  2802. capacity = (rl.get(0).getJrCapacity()) + (rl.get(0).getJrwindCapacity());
  2803. } else {
  2804. capacity = (gsrl.get(0).getJrCapacity()) + (gsrl.get(0).getJrwindCapacity());
  2805. }
  2806. vo.setWpid(wpid);
  2807. // if (wpid.contains("_ZGS")|| wpid.contains("_FGS" + type)) {
  2808. // vo.setWpname(CacheContext.cpmap.get(companys).getAname());
  2809. // } else if (wpid.contains("_RGN")) {
  2810. // vo.setWpname(CacheContext.rgmap.get(companys).getAname());
  2811. // } else {
  2812. vo.setWpname(CacheContext.wpmap.get(wpid).getAname());
  2813. // }
  2814. Instant instant = i.getRecordDate().atStartOfDay(ZoneId.systemDefault()).toInstant();
  2815. Date date = Date.from(instant);
  2816. vo.setYear(DateUtils.getYear(date));
  2817. vo.setMonth(DateUtils.getMonth(date));
  2818. vo.setCurrent(DoubleUtils.keepPrecision((i.getRfdlFj().doubleValue()) / capacity, 2));
  2819. resultList.add(vo);
  2820. });
  2821. resultList.stream().forEach(i -> {
  2822. Optional<StationInfoDay> optional = sameperiodList.stream()
  2823. .filter(j -> i.getWpid().equals(j.getStationId())
  2824. && i.getMonth().equals(DateUtils.getMonthFromDate(Date.from(j.getRecordDate().atStartOfDay(ZoneId.systemDefault()).toInstant()))))
  2825. .findFirst();
  2826. List<ProBasicPowerstation> rl = CacheContext.wpls.stream().filter(wp -> i.getWpid().equals(wp.getId())).collect(Collectors.toList());
  2827. List<ProBasicCompany> gsrl = CacheContext.cpls.stream().filter(wp -> i.getWpid().contains(wp.getId())).collect(Collectors.toList());
  2828. double capacity = 1;
  2829. if (!rl.isEmpty() && rl.size() > 0) {
  2830. capacity = (rl.get(0).getJrCapacity()) + (rl.get(0).getJrwindCapacity());
  2831. } else {
  2832. capacity = (gsrl.get(0).getJrCapacity()) + (gsrl.get(0).getJrwindCapacity());
  2833. }
  2834. if (optional.isPresent()) {
  2835. StationInfoDay tqinfoday = optional.get();
  2836. i.setSameperiod(DoubleUtils.keepPrecision(((tqinfoday.getRfdlFj().doubleValue())) / capacity, 2));
  2837. i.setCompare(i.getCurrent().compareTo(i.getSameperiod()));
  2838. } else {
  2839. i.setSameperiod(0.0);
  2840. i.setCompare(0);
  2841. }
  2842. });
  2843. List<SpecificTarget> resultendList = new ArrayList<>();
  2844. Map<String, Map<Integer, SpecificTargetVo>> map = new HashMap<>();
  2845. resultList.stream().forEach(i -> {
  2846. if (map.containsKey(i.getWpid())) {
  2847. Map<Integer, SpecificTargetVo> integerListMap = map.get(i.getWpid());
  2848. if (!integerListMap.containsKey(i.getMonth())) {
  2849. map.get(i.getWpid()).put(i.getMonth(), i);
  2850. } else {
  2851. }
  2852. } else {
  2853. Map<Integer, SpecificTargetVo> tempMap = new HashMap<>();
  2854. tempMap.put(i.getMonth(), i);
  2855. map.put(i.getWpid(), tempMap);
  2856. }
  2857. });
  2858. Set<String> wpids = map.keySet();
  2859. if (StringUtils.isNotNull(wpids)) {
  2860. wpids.stream().forEach(wpid -> {
  2861. SpecificTarget vo = new SpecificTarget();
  2862. vo.setWpid(wpid);
  2863. int orderNum = 100;
  2864. // if (wpid.contains("_ZGS")|| wpid.contains("_FGS" + type)) {
  2865. // vo.setWpname(CacheContext.cpmap.get(companys).getAname());
  2866. // } else if (wpid.contains("_RGN")) {
  2867. // vo.setWpname(CacheContext.rgmap.get(companys).getAname());
  2868. // } else {
  2869. vo.setWpname(CacheContext.wpmap.get(wpid).getAname());
  2870. orderNum = CacheContext.wpmap.get(wpid).getOrderNum();
  2871. // }
  2872. vo.setOrderNum(orderNum);
  2873. List<SpecificTargetVo> tempList = new ArrayList<>();
  2874. Map<Integer, SpecificTargetVo> listMap = map.get(wpid);
  2875. for (int x = 1; x <= 12; x++) {
  2876. if (listMap.containsKey(x)) {
  2877. tempList.add(listMap.get(x));
  2878. } else {
  2879. SpecificTargetVo vo1 = new SpecificTargetVo();
  2880. vo1.setWpid(wpid);
  2881. // if (wpid.contains("_ZGS")|| wpid.contains("_FGS" + type)) {
  2882. // vo1.setWpname(CacheContext.cpmap.get(companys).getAname());
  2883. // } else if (wpid.contains("_RGN")) {
  2884. // vo1.setWpname(CacheContext.rgmap.get(companys).getAname());
  2885. // } else {
  2886. vo1.setWpname(CacheContext.wpmap.get(wpid).getAname());
  2887. // }
  2888. vo1.setYear(Integer.parseInt(year));
  2889. vo1.setMonth(x);
  2890. tempList.add(vo1);
  2891. }
  2892. }
  2893. vo.setTargetList(tempList);
  2894. resultendList.add(vo);
  2895. SpecificTarget vo2 = new SpecificTarget();
  2896. vo2.setWpid(vo.getWpid());
  2897. vo2.setTargetList(vo.getTargetList());
  2898. vo2.setOrderNum(vo.getOrderNum() + 1);
  2899. vo2.setWpname(CacheContext.cpmap.get(companys).getAname());
  2900. resultendList.add(vo2);
  2901. });
  2902. }
  2903. SortUtils.sort(resultendList, "orderNum", SortUtils.ASC);
  2904. return resultendList;
  2905. }
  2906. public List<SpecificTarget> gzsslList2(String companys, String type, String year) {
  2907. //获取年份所有当月的数据
  2908. QueryWrapper<ProEconPowerstationInfoDay1> currentqw = new QueryWrapper<>();
  2909. currentqw.select("foreign_key_id,max(record_date) record_date,sum(rgzssdl) ygzssdl,sum(rcnslgzssdl) ycnslgzssdl,sum(rllfdl) yllfdl");
  2910. currentqw.eq("location", "wp");
  2911. currentqw.eq("to_char(record_date,'yyyy')", year);
  2912. if (type.equals("-1")) {
  2913. currentqw.like("foreign_key_id", "_FDC_");
  2914. } else {
  2915. currentqw.like("foreign_key_id", "_GDC_");
  2916. }
  2917. if (companys.endsWith("ZGS")) {
  2918. currentqw.eq("company_id", companys);
  2919. } else {
  2920. currentqw.eq("region_id", companys);
  2921. }
  2922. currentqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  2923. List<ProEconPowerstationInfoDay1> currentList = proEconPowerstationInfoDay1Service.list(currentqw);
  2924. currentqw.clear();
  2925. currentqw.select("foreign_key_id,max(record_date) record_date,sum(rgzssdl) ygzssdl,sum(rcnslgzssdl) ycnslgzssdl,sum(rllfdl) yllfdl");
  2926. currentqw.eq("foreign_key_id", companys + type);
  2927. currentqw.eq("to_char(record_date,'yyyy')", year);
  2928. currentqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  2929. currentList.addAll(proEconPowerstationInfoDay1Service.list(currentqw));
  2930. int subYear = Integer.parseInt(year) - 1;
  2931. QueryWrapper<ProEconPowerstationInfoDay1> sameperiodqw = new QueryWrapper<>();
  2932. sameperiodqw.select("foreign_key_id,max(record_date) record_date,sum(rgzssdl) ygzssdl,sum(rcnslgzssdl) ycnslgzssdl,sum(rllfdl) yllfdl");
  2933. sameperiodqw.eq("location", "wp");
  2934. if (type.equals("-1")) {
  2935. currentqw.like("foreign_key_id", "_FDC_");
  2936. } else {
  2937. currentqw.like("foreign_key_id", "_GDC_");
  2938. }
  2939. if (companys.endsWith("ZGS") || companys.endsWith("FGS")) {
  2940. currentqw.eq("company_id", companys);
  2941. } else {
  2942. currentqw.eq("region_id", companys);
  2943. }
  2944. sameperiodqw.eq("to_char(record_date,'yyyy')", String.valueOf(subYear));
  2945. sameperiodqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  2946. List<ProEconPowerstationInfoDay1> sameperiodList = proEconPowerstationInfoDay1Service.list(sameperiodqw);
  2947. sameperiodqw.clear();
  2948. sameperiodqw.select("foreign_key_id,max(record_date) record_date,sum(rgzssdl) ygzssdl,sum(rcnslgzssdl) ycnslgzssdl,sum(rllfdl) yllfdl");
  2949. sameperiodqw.eq("foreign_key_id", companys + type);
  2950. sameperiodqw.eq("to_char(record_date,'yyyy')", String.valueOf(subYear));
  2951. sameperiodqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  2952. sameperiodList.addAll(proEconPowerstationInfoDay1Service.list(sameperiodqw));
  2953. //合并当月与同期数据为返回结果
  2954. List<SpecificTargetVo> resultList = new ArrayList<>();
  2955. currentList.stream().forEach(i -> {
  2956. SpecificTargetVo vo = new SpecificTargetVo();
  2957. String wpid = i.getForeignKeyId();
  2958. vo.setWpid(wpid);
  2959. if (companys.endsWith("ZGS") || companys.endsWith("FGS")) {
  2960. vo.setWpname(CacheContext.cpmap.get(companys).getAname());
  2961. } else if (wpid.contains("_RGN")) {
  2962. vo.setWpname(CacheContext.rgmap.get(companys).getAname());
  2963. } else {
  2964. vo.setWpname(CacheContext.wpmap.get(wpid).getAname());
  2965. }
  2966. vo.setYear(DateUtils.getYear(i.getRecordDate()));
  2967. vo.setMonth(DateUtils.getMonth(i.getRecordDate()));
  2968. vo.setCurrent(DoubleUtils.keepPrecision(i.getYllfdl().doubleValue() != 0 ? (i.getYgzssdl().doubleValue() + i.getYcnslgzssdl().doubleValue()) / i.getYllfdl().doubleValue() * 100 : 0, 2));
  2969. resultList.add(vo);
  2970. });
  2971. resultList.stream().forEach(i -> {
  2972. Optional<ProEconPowerstationInfoDay1> optional = sameperiodList.stream()
  2973. .filter(j -> j.getForeignKeyId().equals(i.getWpid()) && String.valueOf(DateUtils.getMonth(j.getRecordDate())).equals(i.getMonth()))
  2974. .findFirst();
  2975. if (optional.isPresent()) {
  2976. ProEconPowerstationInfoDay1 tqinfoday = optional.get();
  2977. i.setSameperiod(DoubleUtils.keepPrecision(tqinfoday.getYllfdl().doubleValue() != 0 ? (tqinfoday.getYgzssdl().doubleValue() + tqinfoday.getYcnslgzssdl().doubleValue()) / tqinfoday.getYllfdl().doubleValue() * 100 : 0, 2));
  2978. i.setCompare(i.getCurrent().compareTo(i.getSameperiod()));
  2979. } else {
  2980. i.setSameperiod(0.0);
  2981. i.setCompare(0);
  2982. }
  2983. });
  2984. List<SpecificTarget> resultendList = new ArrayList<>();
  2985. Map<String, Map<Integer, SpecificTargetVo>> map = new HashMap<>();
  2986. resultList.stream().forEach(i -> {
  2987. if (map.containsKey(i.getWpid())) {
  2988. Map<Integer, SpecificTargetVo> integerListMap = map.get(i.getWpid());
  2989. if (!integerListMap.containsKey(i.getMonth())) {
  2990. map.get(i.getWpid()).put(i.getMonth(), i);
  2991. } else {
  2992. }
  2993. } else {
  2994. Map<Integer, SpecificTargetVo> tempMap = new HashMap<>();
  2995. tempMap.put(i.getMonth(), i);
  2996. map.put(i.getWpid(), tempMap);
  2997. }
  2998. });
  2999. Set<String> wpids = map.keySet();
  3000. if (StringUtils.isNotNull(wpids)) {
  3001. wpids.stream().forEach(wpid -> {
  3002. SpecificTarget vo = new SpecificTarget();
  3003. vo.setWpid(wpid);
  3004. int orderNum = 100;
  3005. if (wpid.contains("_ZGS") || wpid.contains("_FGS" + type)) {
  3006. vo.setWpname(CacheContext.cpmap.get(companys).getAname());
  3007. } else if (wpid.contains("_RGN")) {
  3008. vo.setWpname(CacheContext.rgmap.get(companys).getAname());
  3009. } else {
  3010. vo.setWpname(CacheContext.wpmap.get(wpid).getAname());
  3011. orderNum = CacheContext.wpmap.get(wpid).getOrderNum();
  3012. }
  3013. vo.setOrderNum(orderNum);
  3014. List<SpecificTargetVo> tempList = new ArrayList<>();
  3015. Map<Integer, SpecificTargetVo> listMap = map.get(wpid);
  3016. for (int x = 1; x <= 12; x++) {
  3017. if (listMap.containsKey(x)) {
  3018. tempList.add(listMap.get(x));
  3019. } else {
  3020. SpecificTargetVo vo1 = new SpecificTargetVo();
  3021. vo1.setWpid(wpid);
  3022. if (wpid.contains("_ZGS") || wpid.contains("_FGS" + type)) {
  3023. vo1.setWpname(CacheContext.cpmap.get(companys).getAname());
  3024. } else if (wpid.contains("_RGN")) {
  3025. vo1.setWpname(CacheContext.rgmap.get(companys).getAname());
  3026. } else {
  3027. vo1.setWpname(CacheContext.wpmap.get(wpid).getAname());
  3028. }
  3029. vo1.setYear(Integer.parseInt(year));
  3030. vo1.setMonth(x);
  3031. tempList.add(vo1);
  3032. }
  3033. }
  3034. vo.setTargetList(tempList);
  3035. resultendList.add(vo);
  3036. });
  3037. }
  3038. SortUtils.sort(resultendList, "orderNum", SortUtils.ASC);
  3039. return resultendList;
  3040. }
  3041. public List<SpecificTarget> gzsslList(String companys, String type, String year) {
  3042. //获取年份所有当月的数据
  3043. QueryWrapper<TurbineInfoDay> currentqw = new QueryWrapper<>();
  3044. currentqw.select("station_id,max(record_date) record_date,sum(gzss) gzss,sum(llfdl) llfdl");
  3045. // currentqw.eq("location", "wp");
  3046. currentqw.eq("to_char(record_date,'yyyy')", year);
  3047. if (type.equals("-1")) {
  3048. currentqw.like("station_id", "_FDC_");
  3049. } else {
  3050. currentqw.like("station_id", "_GDC_");
  3051. }
  3052. // if (companys.endsWith("ZGS")) {
  3053. // currentqw.eq("company_id", companys);
  3054. // } else {
  3055. // currentqw.eq("station_id", companys);
  3056. // }
  3057. currentqw.groupBy("to_char(record_date,'yyyy-MM'),station_id");
  3058. List<TurbineInfoDay> currentList = iTurbineInfoDayService.list(currentqw);
  3059. // currentqw.clear();
  3060. // currentqw.select("station_id,max(record_date) record_date,sum(gzss) gzss,sum(llfdl) llfdl");
  3061. // currentqw.eq("station_id", CacheContext.wplsf.get(0).getId());
  3062. // currentqw.eq("to_char(record_date,'yyyy')", year);
  3063. // currentqw.groupBy("to_char(record_date,'yyyy-MM'),station_id");
  3064. // currentList.addAll(iTurbineInfoDayService.list(currentqw));
  3065. int subYear = Integer.parseInt(year) - 1;
  3066. QueryWrapper<TurbineInfoDay> sameperiodqw = new QueryWrapper<>();
  3067. sameperiodqw.select("station_id,max(record_date) record_date,sum(gzss) gzss,sum(llfdl) llfdl");
  3068. // sameperiodqw.eq("location", "wp");
  3069. if (type.equals("-1")) {
  3070. currentqw.like("station_id", "_FDC_");
  3071. } else {
  3072. currentqw.like("station_id", "_GDC_");
  3073. }
  3074. // if (companys.endsWith("ZGS") || companys.endsWith("FGS")) {
  3075. // currentqw.eq("station_id", companys);
  3076. // } else {
  3077. // currentqw.eq("station_id", companys);
  3078. // }
  3079. sameperiodqw.eq("to_char(record_date,'yyyy')", String.valueOf(subYear));
  3080. sameperiodqw.groupBy("to_char(record_date,'yyyy-MM'),station_id");
  3081. List<TurbineInfoDay> sameperiodList = iTurbineInfoDayService.list(sameperiodqw);
  3082. // sameperiodqw.clear();
  3083. // sameperiodqw.select("station_id,max(record_date) record_date,sum(gzss) gzss,sum(llfdl) llfdl");
  3084. // sameperiodqw.eq("station_id", CacheContext.wplsf.get(0).getId());
  3085. // sameperiodqw.eq("to_char(record_date,'yyyy')", String.valueOf(subYear));
  3086. // sameperiodqw.groupBy("to_char(record_date,'yyyy-MM'),station_id");
  3087. // sameperiodList.addAll(iTurbineInfoDayService.list(sameperiodqw));
  3088. //合并当月与同期数据为返回结果
  3089. List<SpecificTargetVo> resultList = new ArrayList<>();
  3090. currentList.stream().forEach(i -> {
  3091. SpecificTargetVo vo = new SpecificTargetVo();
  3092. String wpid = i.getStationId();
  3093. vo.setWpid(wpid);
  3094. // if (companys.endsWith("ZGS") || companys.endsWith("FGS")) {
  3095. // vo.setWpname(CacheContext.cpmap.get(companys).getAname());
  3096. // } else if (wpid.contains("_RGN")) {
  3097. // vo.setWpname(CacheContext.rgmap.get(companys).getAname());
  3098. // } else {
  3099. vo.setWpname(CacheContext.wpmap.get(wpid).getAname());
  3100. // }
  3101. // Instant instant = i.getRecordDate().atStartOfDay(ZoneId.systemDefault()).toInstant();
  3102. // Date date2 = Date.from(instant);
  3103. vo.setYear(i.getRecordDate().getYear()+1900);
  3104. vo.setMonth(i.getRecordDate().getMonth()+1);
  3105. // vo.setCurrent(DoubleUtils.keepPrecision(i.getLlfdl().doubleValue() != 0 ? (i.getGzss().doubleValue()) / i.getLlfdl().doubleValue() * 100 : 0, 2));
  3106. double llfdl = i.getLlfdl() != null ? i.getLlfdl().doubleValue() : 0.0;
  3107. double rfdl = i.getGzss() != null ? i.getGzss().doubleValue() : 0.0;
  3108. if (llfdl != 0) {
  3109. Double calculatedValue = DoubleUtils.keepPrecision(rfdl / llfdl * 100, 2);
  3110. vo.setCurrent(calculatedValue);
  3111. } else {
  3112. vo.setCurrent(0.0);
  3113. }
  3114. resultList.add(vo);
  3115. });
  3116. resultList.stream().forEach(i -> {
  3117. Optional<TurbineInfoDay> optional = sameperiodList.stream()
  3118. // .filter(j -> j.getStationId().equals(i.getWpid()) && String.valueOf(DateUtils.getMonth(Date.from(j.getRecordDate().atStartOfDay(ZoneId.systemDefault()).toInstant()))).equals(i.getMonth()))
  3119. .findFirst();
  3120. if (optional.isPresent()) {
  3121. TurbineInfoDay tqinfoday = optional.get();
  3122. // i.setSameperiod(DoubleUtils.keepPrecision(tqinfoday.getLlfdl().doubleValue() != 0 ? (tqinfoday.getGzss().doubleValue() ) / tqinfoday.getLlfdl().doubleValue() * 100 : 0, 2));
  3123. double llfdl = tqinfoday.getLlfdl() != null ? tqinfoday.getLlfdl().doubleValue() : 0.0;
  3124. double rfdl = tqinfoday.getGzss() != null ? tqinfoday.getGzss().doubleValue() : 0.0;
  3125. if (llfdl != 0) {
  3126. Double calculatedValue = DoubleUtils.keepPrecision(rfdl / llfdl * 100, 2);
  3127. i.setSameperiod(calculatedValue);
  3128. } else {
  3129. i.setSameperiod(0.0);
  3130. }
  3131. i.setCompare(i.getCurrent().compareTo(i.getSameperiod()));
  3132. } else {
  3133. i.setSameperiod(0.0);
  3134. i.setCompare(0);
  3135. }
  3136. });
  3137. List<SpecificTarget> resultendList = new ArrayList<>();
  3138. Map<String, Map<Integer, SpecificTargetVo>> map = new HashMap<>();
  3139. resultList.stream().forEach(i -> {
  3140. if (map.containsKey(i.getWpid())) {
  3141. Map<Integer, SpecificTargetVo> integerListMap = map.get(i.getWpid());
  3142. if (!integerListMap.containsKey(i.getMonth())) {
  3143. map.get(i.getWpid()).put(i.getMonth(), i);
  3144. } else {
  3145. }
  3146. } else {
  3147. Map<Integer, SpecificTargetVo> tempMap = new HashMap<>();
  3148. tempMap.put(i.getMonth(), i);
  3149. map.put(i.getWpid(), tempMap);
  3150. }
  3151. });
  3152. Set<String> wpids = map.keySet();
  3153. if (StringUtils.isNotNull(wpids)) {
  3154. wpids.stream().forEach(wpid -> {
  3155. SpecificTarget vo = new SpecificTarget();
  3156. vo.setWpid(wpid);
  3157. int orderNum = 100;
  3158. // if (wpid.contains("_ZGS") || wpid.contains("_FGS" + type)) {
  3159. // vo.setWpname(CacheContext.cpmap.get(companys).getAname());
  3160. // } else if (wpid.contains("_RGN")) {
  3161. // vo.setWpname(CacheContext.rgmap.get(companys).getAname());
  3162. // } else {
  3163. vo.setWpname(CacheContext.wpmap.get(wpid).getAname());
  3164. orderNum = CacheContext.wpmap.get(wpid).getOrderNum();
  3165. // }
  3166. vo.setOrderNum(orderNum);
  3167. List<SpecificTargetVo> tempList = new ArrayList<>();
  3168. Map<Integer, SpecificTargetVo> listMap = map.get(wpid);
  3169. for (int x = 1; x <= 12; x++) {
  3170. if (listMap.containsKey(x)) {
  3171. tempList.add(listMap.get(x));
  3172. } else {
  3173. SpecificTargetVo vo1 = new SpecificTargetVo();
  3174. vo1.setWpid(wpid);
  3175. // if (wpid.contains("_ZGS") || wpid.contains("_FGS" + type)) {
  3176. // vo1.setWpname(CacheContext.cpmap.get(companys).getAname());
  3177. // } else if (wpid.contains("_RGN")) {
  3178. // vo1.setWpname(CacheContext.rgmap.get(companys).getAname());
  3179. // } else {
  3180. vo1.setWpname(CacheContext.wpmap.get(wpid).getAname());
  3181. // }
  3182. vo1.setYear(Integer.parseInt(year));
  3183. vo1.setMonth(x);
  3184. tempList.add(vo1);
  3185. }
  3186. }
  3187. vo.setTargetList(tempList);
  3188. resultendList.add(vo);
  3189. SpecificTarget vo2 = new SpecificTarget();
  3190. vo2.setWpid(vo.getWpid());
  3191. vo2.setTargetList(vo.getTargetList());
  3192. vo2.setOrderNum(vo.getOrderNum() + 1);
  3193. vo2.setWpname(CacheContext.cpmap.get(companys).getAname());
  3194. resultendList.add(vo2);
  3195. });
  3196. }
  3197. SortUtils.sort(resultendList, "orderNum", SortUtils.ASC);
  3198. return resultendList;
  3199. }
  3200. public List<SpecificTarget> whsslList2(String companys, String type, String year) {
  3201. //获取年份所有当月的数据
  3202. QueryWrapper<ProEconPowerstationInfoDay1> currentqw = new QueryWrapper<>();
  3203. currentqw.select("foreign_key_id,max(record_date) record_date,sum(rjxssdl) yjxssdl,sum(rcnsljxssdl) ycnsljxssdl,sum(rllfdl) yllfdl");
  3204. currentqw.eq("location", "wp");
  3205. currentqw.eq("to_char(record_date,'yyyy')", year);
  3206. if (type.equals("-1")) {
  3207. currentqw.like("foreign_key_id", "_FDC_");
  3208. } else {
  3209. currentqw.like("foreign_key_id", "_GDC_");
  3210. }
  3211. if (companys.endsWith("ZGS")) {
  3212. currentqw.eq("company_id", companys);
  3213. } else {
  3214. currentqw.eq("region_id", companys);
  3215. }
  3216. currentqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  3217. List<ProEconPowerstationInfoDay1> currentList = proEconPowerstationInfoDay1Service.list(currentqw);
  3218. currentqw.clear();
  3219. currentqw.select("foreign_key_id,max(record_date) record_date,sum(rjxssdl) yjxssdl,sum(rcnsljxssdl) ycnsljxssdl,sum(rllfdl) yllfdl");
  3220. currentqw.eq("foreign_key_id", companys + type);
  3221. currentqw.eq("to_char(record_date,'yyyy')", year);
  3222. currentqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  3223. currentList.addAll(proEconPowerstationInfoDay1Service.list(currentqw));
  3224. int subYear = Integer.parseInt(year) - 1;
  3225. QueryWrapper<ProEconPowerstationInfoDay1> sameperiodqw = new QueryWrapper<>();
  3226. sameperiodqw.select("foreign_key_id,max(record_date) record_date,sum(rjxssdl) yjxssdl,sum(rcnsljxssdl) ycnsljxssdl,sum(rllfdl) yllfdl");
  3227. sameperiodqw.eq("location", "wp");
  3228. if (type.equals("-1")) {
  3229. currentqw.like("foreign_key_id", "_FDC_");
  3230. } else {
  3231. currentqw.like("foreign_key_id", "_GDC_");
  3232. }
  3233. if (companys.endsWith("ZGS")) {
  3234. currentqw.eq("company_id", companys);
  3235. } else {
  3236. currentqw.eq("region_id", companys);
  3237. }
  3238. sameperiodqw.eq("to_char(record_date,'yyyy')", String.valueOf(subYear));
  3239. sameperiodqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  3240. List<ProEconPowerstationInfoDay1> sameperiodList = proEconPowerstationInfoDay1Service.list(sameperiodqw);
  3241. sameperiodqw.clear();
  3242. sameperiodqw.select("foreign_key_id,max(record_date) record_date,sum(rjxssdl) yjxssdl,sum(rcnsljxssdl) ycnsljxssdl,sum(rllfdl) yllfdl");
  3243. sameperiodqw.eq("foreign_key_id", companys + type);
  3244. sameperiodqw.eq("to_char(record_date,'yyyy')", String.valueOf(subYear));
  3245. sameperiodqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  3246. sameperiodList.addAll(proEconPowerstationInfoDay1Service.list(sameperiodqw));
  3247. //合并当月与同期数据为返回结果
  3248. List<SpecificTargetVo> resultList = new ArrayList<>();
  3249. currentList.stream().forEach(i -> {
  3250. SpecificTargetVo vo = new SpecificTargetVo();
  3251. String wpid = i.getForeignKeyId();
  3252. vo.setWpid(wpid);
  3253. if (wpid.contains("_ZGS") || wpid.contains("_FGS" + type)) {
  3254. vo.setWpname(CacheContext.cpmap.get(companys).getAname());
  3255. } else if (wpid.contains("_RGN")) {
  3256. vo.setWpname(CacheContext.rgmap.get(companys).getAname());
  3257. } else {
  3258. vo.setWpname(CacheContext.wpmap.get(wpid).getAname());
  3259. }
  3260. vo.setYear(DateUtils.getYear(i.getRecordDate()));
  3261. vo.setMonth(DateUtils.getMonth(i.getRecordDate()));
  3262. vo.setCurrent(DoubleUtils.keepPrecision(i.getYllfdl().doubleValue() != 0 ? (i.getYjxssdl().doubleValue() + i.getYcnsljxssdl().doubleValue()) / i.getYllfdl().doubleValue() * 100 : 0, 2));
  3263. resultList.add(vo);
  3264. });
  3265. resultList.stream().forEach(i -> {
  3266. Optional<ProEconPowerstationInfoDay1> optional = sameperiodList.stream()
  3267. .filter(j -> j.getForeignKeyId().equals(i.getWpid()) && String.valueOf(DateUtils.getMonth(j.getRecordDate())).equals(i.getMonth()))
  3268. .findFirst();
  3269. if (optional.isPresent()) {
  3270. ProEconPowerstationInfoDay1 tqinfoday = optional.get();
  3271. i.setSameperiod(DoubleUtils.keepPrecision(tqinfoday.getYllfdl().doubleValue() != 0 ? (tqinfoday.getYjxssdl().doubleValue() + tqinfoday.getYcnsljxssdl().doubleValue()) / tqinfoday.getYllfdl().doubleValue() * 100 : 0, 2));
  3272. i.setCompare(i.getCurrent().compareTo(i.getSameperiod()));
  3273. } else {
  3274. i.setSameperiod(0.0);
  3275. i.setCompare(0);
  3276. }
  3277. });
  3278. List<SpecificTarget> resultendList = new ArrayList<>();
  3279. Map<String, Map<Integer, SpecificTargetVo>> map = new HashMap<>();
  3280. resultList.stream().forEach(i -> {
  3281. if (map.containsKey(i.getWpid())) {
  3282. Map<Integer, SpecificTargetVo> integerListMap = map.get(i.getWpid());
  3283. if (!integerListMap.containsKey(i.getMonth())) {
  3284. map.get(i.getWpid()).put(i.getMonth(), i);
  3285. } else {
  3286. }
  3287. } else {
  3288. Map<Integer, SpecificTargetVo> tempMap = new HashMap<>();
  3289. tempMap.put(i.getMonth(), i);
  3290. map.put(i.getWpid(), tempMap);
  3291. }
  3292. });
  3293. Set<String> wpids = map.keySet();
  3294. if (StringUtils.isNotNull(wpids)) {
  3295. wpids.stream().forEach(wpid -> {
  3296. SpecificTarget vo = new SpecificTarget();
  3297. vo.setWpid(wpid);
  3298. int orderNum = 100;
  3299. if (wpid.contains("_ZGS") || wpid.contains("_FGS" + type)) {
  3300. vo.setWpname(CacheContext.cpmap.get(companys).getAname());
  3301. } else if (wpid.contains("_RGN")) {
  3302. vo.setWpname(CacheContext.rgmap.get(companys).getAname());
  3303. } else {
  3304. vo.setWpname(CacheContext.wpmap.get(wpid).getAname());
  3305. orderNum = CacheContext.wpmap.get(wpid).getOrderNum();
  3306. }
  3307. vo.setOrderNum(orderNum);
  3308. List<SpecificTargetVo> tempList = new ArrayList<>();
  3309. Map<Integer, SpecificTargetVo> listMap = map.get(wpid);
  3310. for (int x = 1; x <= 12; x++) {
  3311. if (listMap.containsKey(x)) {
  3312. tempList.add(listMap.get(x));
  3313. } else {
  3314. SpecificTargetVo vo1 = new SpecificTargetVo();
  3315. vo1.setWpid(wpid);
  3316. if (wpid.contains("_ZGS") || wpid.contains("_FGS" + type)) {
  3317. vo1.setWpname(CacheContext.cpmap.get(companys).getAname());
  3318. } else if (wpid.contains("_RGN")) {
  3319. vo1.setWpname(CacheContext.rgmap.get(companys).getAname());
  3320. } else {
  3321. vo1.setWpname(CacheContext.wpmap.get(wpid).getAname());
  3322. }
  3323. vo1.setYear(Integer.parseInt(year));
  3324. vo1.setMonth(x);
  3325. tempList.add(vo1);
  3326. }
  3327. }
  3328. vo.setTargetList(tempList);
  3329. resultendList.add(vo);
  3330. });
  3331. }
  3332. SortUtils.sort(resultendList, "orderNum", SortUtils.ASC);
  3333. return resultendList;
  3334. }
  3335. // public List<SpecificTarget> whsslList(String companys, String type, String year) {
  3336. // //获取年份所有当月的数据
  3337. // QueryWrapper<ProEconPowerstationInfoDay1> currentqw = new QueryWrapper<>();
  3338. // currentqw.select("foreign_key_id,max(record_date) record_date,sum(rjxssdl) yjxssdl,sum(rcnsljxssdl) ycnsljxssdl,sum(rllfdl) yllfdl");
  3339. // currentqw.eq("location", "wp");
  3340. // currentqw.eq("to_char(record_date,'yyyy')", year);
  3341. // if (type.equals("-1")) {
  3342. // currentqw.like("foreign_key_id", "_FDC_");
  3343. // } else {
  3344. // currentqw.like("foreign_key_id", "_GDC_");
  3345. // }
  3346. // if (companys.endsWith("ZGS")) {
  3347. // currentqw.eq("company_id", companys);
  3348. // } else {
  3349. // currentqw.eq("region_id", companys);
  3350. // }
  3351. // currentqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  3352. // List<ProEconPowerstationInfoDay1> currentList = proEconPowerstationInfoDay1Service.list(currentqw);
  3353. // currentqw.clear();
  3354. // currentqw.select("foreign_key_id,max(record_date) record_date,sum(rjxssdl) yjxssdl,sum(rcnsljxssdl) ycnsljxssdl,sum(rllfdl) yllfdl");
  3355. // currentqw.eq("foreign_key_id", companys + type);
  3356. // currentqw.eq("to_char(record_date,'yyyy')", year);
  3357. // currentqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  3358. // currentList.addAll(proEconPowerstationInfoDay1Service.list(currentqw));
  3359. //
  3360. // int subYear = Integer.parseInt(year) - 1;
  3361. // QueryWrapper<ProEconPowerstationInfoDay1> sameperiodqw = new QueryWrapper<>();
  3362. // sameperiodqw.select("foreign_key_id,max(record_date) record_date,sum(rjxssdl) yjxssdl,sum(rcnsljxssdl) ycnsljxssdl,sum(rllfdl) yllfdl");
  3363. // sameperiodqw.eq("location", "wp");
  3364. // if (type.equals("-1")) {
  3365. // currentqw.like("foreign_key_id", "_FDC_");
  3366. // } else {
  3367. // currentqw.like("foreign_key_id", "_GDC_");
  3368. // }
  3369. // if (companys.endsWith("ZGS")) {
  3370. // currentqw.eq("company_id", companys);
  3371. // } else {
  3372. // currentqw.eq("region_id", companys);
  3373. // }
  3374. // sameperiodqw.eq("to_char(record_date,'yyyy')", String.valueOf(subYear));
  3375. // sameperiodqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  3376. // List<ProEconPowerstationInfoDay1> sameperiodList = proEconPowerstationInfoDay1Service.list(sameperiodqw);
  3377. // sameperiodqw.clear();
  3378. // sameperiodqw.select("foreign_key_id,max(record_date) record_date,sum(rjxssdl) yjxssdl,sum(rcnsljxssdl) ycnsljxssdl,sum(rllfdl) yllfdl");
  3379. // sameperiodqw.eq("foreign_key_id", companys + type);
  3380. // sameperiodqw.eq("to_char(record_date,'yyyy')", String.valueOf(subYear));
  3381. // sameperiodqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  3382. // sameperiodList.addAll(proEconPowerstationInfoDay1Service.list(sameperiodqw));
  3383. //
  3384. // //合并当月与同期数据为返回结果
  3385. // List<SpecificTargetVo> resultList = new ArrayList<>();
  3386. //
  3387. // currentList.stream().forEach(i -> {
  3388. // SpecificTargetVo vo = new SpecificTargetVo();
  3389. // String wpid = i.getForeignKeyId();
  3390. // vo.setWpid(wpid);
  3391. // if (wpid.contains("_ZGS") || wpid.contains("_FGS" + type)) {
  3392. // vo.setWpname(CacheContext.cpmap.get(companys).getAname());
  3393. // } else if (wpid.contains("_RGN")) {
  3394. // vo.setWpname(CacheContext.rgmap.get(companys).getAname());
  3395. // } else {
  3396. // vo.setWpname(CacheContext.wpmap.get(wpid).getAname());
  3397. // }
  3398. // vo.setYear(DateUtils.getYear(i.getRecordDate()));
  3399. // vo.setMonth(DateUtils.getMonth(i.getRecordDate()));
  3400. // vo.setCurrent(DoubleUtils.keepPrecision(i.getYllfdl().doubleValue() != 0 ? (i.getYjxssdl().doubleValue() + i.getYcnsljxssdl().doubleValue()) / i.getYllfdl().doubleValue() * 100 : 0, 2));
  3401. // resultList.add(vo);
  3402. // });
  3403. // resultList.stream().forEach(i -> {
  3404. // Optional<ProEconPowerstationInfoDay1> optional = sameperiodList.stream()
  3405. // .filter(j -> j.getForeignKeyId().equals(i.getWpid()) && String.valueOf(DateUtils.getMonth(j.getRecordDate())).equals(i.getMonth()))
  3406. // .findFirst();
  3407. // if (optional.isPresent()) {
  3408. // ProEconPowerstationInfoDay1 tqinfoday = optional.get();
  3409. // i.setSameperiod(DoubleUtils.keepPrecision(tqinfoday.getYllfdl().doubleValue() != 0 ? (tqinfoday.getYjxssdl().doubleValue() + tqinfoday.getYcnsljxssdl().doubleValue()) / tqinfoday.getYllfdl().doubleValue() * 100 : 0, 2));
  3410. // i.setCompare(i.getCurrent().compareTo(i.getSameperiod()));
  3411. // } else {
  3412. // i.setSameperiod(0.0);
  3413. // i.setCompare(0);
  3414. // }
  3415. // });
  3416. // List<SpecificTarget> resultendList = new ArrayList<>();
  3417. //
  3418. // Map<String, Map<Integer, SpecificTargetVo>> map = new HashMap<>();
  3419. //
  3420. // resultList.stream().forEach(i -> {
  3421. // if (map.containsKey(i.getWpid())) {
  3422. // Map<Integer, SpecificTargetVo> integerListMap = map.get(i.getWpid());
  3423. // if (!integerListMap.containsKey(i.getMonth())) {
  3424. // map.get(i.getWpid()).put(i.getMonth(), i);
  3425. // } else {
  3426. //
  3427. // }
  3428. // } else {
  3429. // Map<Integer, SpecificTargetVo> tempMap = new HashMap<>();
  3430. // tempMap.put(i.getMonth(), i);
  3431. // map.put(i.getWpid(), tempMap);
  3432. // }
  3433. // });
  3434. // Set<String> wpids = map.keySet();
  3435. // if (StringUtils.isNotNull(wpids)) {
  3436. // wpids.stream().forEach(wpid -> {
  3437. // SpecificTarget vo = new SpecificTarget();
  3438. // vo.setWpid(wpid);
  3439. // int orderNum = 100;
  3440. // if (wpid.contains("_ZGS") || wpid.contains("_FGS" + type)) {
  3441. // vo.setWpname(CacheContext.cpmap.get(companys).getAname());
  3442. // } else if (wpid.contains("_RGN")) {
  3443. // vo.setWpname(CacheContext.rgmap.get(companys).getAname());
  3444. // } else {
  3445. // vo.setWpname(CacheContext.wpmap.get(wpid).getAname());
  3446. // orderNum = CacheContext.wpmap.get(wpid).getOrderNum();
  3447. // }
  3448. // vo.setOrderNum(orderNum);
  3449. // List<SpecificTargetVo> tempList = new ArrayList<>();
  3450. //
  3451. // Map<Integer, SpecificTargetVo> listMap = map.get(wpid);
  3452. // for (int x = 1; x <= 12; x++) {
  3453. // if (listMap.containsKey(x)) {
  3454. // tempList.add(listMap.get(x));
  3455. // } else {
  3456. // SpecificTargetVo vo1 = new SpecificTargetVo();
  3457. // vo1.setWpid(wpid);
  3458. // if (wpid.contains("_ZGS") || wpid.contains("_FGS" + type)) {
  3459. // vo1.setWpname(CacheContext.cpmap.get(companys).getAname());
  3460. // } else if (wpid.contains("_RGN")) {
  3461. // vo1.setWpname(CacheContext.rgmap.get(companys).getAname());
  3462. // } else {
  3463. // vo1.setWpname(CacheContext.wpmap.get(wpid).getAname());
  3464. // }
  3465. // vo1.setYear(Integer.parseInt(year));
  3466. // vo1.setMonth(x);
  3467. // tempList.add(vo1);
  3468. // }
  3469. // }
  3470. //
  3471. // vo.setTargetList(tempList);
  3472. // resultendList.add(vo);
  3473. // });
  3474. // }
  3475. // SortUtils.sort(resultendList, "orderNum", SortUtils.ASC);
  3476. //
  3477. // return resultendList;
  3478. // }
  3479. public List<SpecificTarget> whsslList(String companys, String type, String year) {
  3480. //获取年份所有当月的数据
  3481. QueryWrapper<TurbineInfoDay> currentqw = new QueryWrapper<>();
  3482. currentqw.select("station_id,max(record_date) record_date,sum(jhjxss) jhjxss,sum(fjhjxss) fjhjxss,sum(llfdl) llfdl");
  3483. currentqw.eq("to_char(record_date,'yyyy')", year);
  3484. if (type.equals("-1")) {
  3485. currentqw.like("station_id", "_FDC_");
  3486. } else {
  3487. currentqw.like("station_id", "_GDC_");
  3488. }
  3489. currentqw.groupBy("to_char(record_date,'yyyy-MM'),station_id");
  3490. List<TurbineInfoDay> currentList = iTurbineInfoDayService.list(currentqw);
  3491. int subYear = Integer.parseInt(year) - 1;
  3492. QueryWrapper<TurbineInfoDay> sameperiodqw = new QueryWrapper<>();
  3493. sameperiodqw.select("station_id,max(record_date) record_date,sum(jhjxss) jhjxss,sum(fjhjxss) fjhjxss,sum(llfdl) llfdl");
  3494. if (type.equals("-1")) {
  3495. currentqw.like("station_id", "_FDC_");
  3496. } else {
  3497. currentqw.like("station_id", "_GDC_");
  3498. }
  3499. sameperiodqw.eq("to_char(record_date,'yyyy')", String.valueOf(subYear));
  3500. sameperiodqw.groupBy("to_char(record_date,'yyyy-MM'),station_id");
  3501. List<TurbineInfoDay> sameperiodList = iTurbineInfoDayService.list(sameperiodqw);
  3502. //合并当月与同期数据为返回结果
  3503. List<SpecificTargetVo> resultList = new ArrayList<>();
  3504. currentList.stream().forEach(i -> {
  3505. SpecificTargetVo vo = new SpecificTargetVo();
  3506. String wpid = i.getStationId();
  3507. vo.setWpid(wpid);
  3508. vo.setWpname(CacheContext.wpmap.get(wpid).getAname());
  3509. double llfdl = i.getLlfdl() != null ? i.getLlfdl() : 0.0;
  3510. double rfdl = i.getJhjxss().doubleValue() + i.getFjhjxss().doubleValue() != 0 ? i.getJhjxss().doubleValue() + i.getFjhjxss().doubleValue() : 0.0;
  3511. if (llfdl != 0) {
  3512. Double calculatedValue = DoubleUtils.keepPrecision(rfdl / llfdl * 100, 2);
  3513. vo.setCurrent(calculatedValue);
  3514. } else {
  3515. vo.setCurrent(0.0);
  3516. }
  3517. vo.setYear(i.getRecordDate().getYear()+1900);
  3518. vo.setMonth(i.getRecordDate().getMonth()+1);
  3519. resultList.add(vo);
  3520. });
  3521. resultList.stream().forEach(i -> {
  3522. Optional<TurbineInfoDay> optional = sameperiodList.stream()
  3523. .findFirst();
  3524. if (optional.isPresent()) {
  3525. TurbineInfoDay tqinfoday = optional.get();
  3526. double llfdl = tqinfoday.getLlfdl() != null ? tqinfoday.getLlfdl() : 0.0;
  3527. double rfdl = tqinfoday.getJhjxss() != null ? tqinfoday.getJhjxss().doubleValue() + tqinfoday.getFjhjxss().doubleValue() : 0.0;
  3528. if (llfdl != 0) {
  3529. Double calculatedValue = DoubleUtils.keepPrecision(rfdl / llfdl * 100, 2);
  3530. i.setSameperiod(calculatedValue);
  3531. } else {
  3532. i.setSameperiod(0.0);
  3533. }
  3534. i.setCompare(i.getCurrent().compareTo(i.getSameperiod()));
  3535. } else {
  3536. i.setSameperiod(0.0);
  3537. i.setCompare(0);
  3538. }
  3539. });
  3540. List<SpecificTarget> resultendList = new ArrayList<>();
  3541. Map<String, Map<Integer, SpecificTargetVo>> map = new HashMap<>();
  3542. resultList.stream().forEach(i -> {
  3543. if (map.containsKey(i.getWpid())) {
  3544. Map<Integer, SpecificTargetVo> integerListMap = map.get(i.getWpid());
  3545. if (!integerListMap.containsKey(i.getMonth())) {
  3546. map.get(i.getWpid()).put(i.getMonth(), i);
  3547. } else {
  3548. }
  3549. } else {
  3550. Map<Integer, SpecificTargetVo> tempMap = new HashMap<>();
  3551. tempMap.put(i.getMonth(), i);
  3552. map.put(i.getWpid(), tempMap);
  3553. }
  3554. });
  3555. Set<String> wpids = map.keySet();
  3556. if (StringUtils.isNotNull(wpids)) {
  3557. wpids.stream().forEach(wpid -> {
  3558. SpecificTarget vo = new SpecificTarget();
  3559. vo.setWpid(wpid);
  3560. int orderNum = 100;
  3561. vo.setWpname(CacheContext.wpmap.get(wpid).getAname());
  3562. orderNum = CacheContext.wpmap.get(wpid).getOrderNum();
  3563. vo.setOrderNum(orderNum);
  3564. List<SpecificTargetVo> tempList = new ArrayList<>();
  3565. Map<Integer, SpecificTargetVo> listMap = map.get(wpid);
  3566. for (int x = 1; x <= 12; x++) {
  3567. if (listMap.containsKey(x)) {
  3568. tempList.add(listMap.get(x));
  3569. } else {
  3570. SpecificTargetVo vo1 = new SpecificTargetVo();
  3571. vo1.setWpid(wpid);
  3572. vo1.setWpname(CacheContext.wpmap.get(wpid).getAname());
  3573. vo1.setYear(Integer.parseInt(year));
  3574. vo1.setMonth(x);
  3575. tempList.add(vo1);
  3576. }
  3577. }
  3578. vo.setTargetList(tempList);
  3579. resultendList.add(vo);
  3580. SpecificTarget vo2 = new SpecificTarget();
  3581. vo2.setWpid(vo.getWpid());
  3582. vo2.setTargetList(vo.getTargetList());
  3583. vo2.setOrderNum(vo.getOrderNum() + 1);
  3584. vo2.setWpname(CacheContext.cpmap.get(companys).getAname());
  3585. resultendList.add(vo2);
  3586. });
  3587. }
  3588. SortUtils.sort(resultendList, "orderNum", SortUtils.ASC);
  3589. return resultendList;
  3590. }
  3591. public List<SpecificTarget> xdsslList2(String companys, String type, String year) {
  3592. //获取年份所有当月的数据
  3593. QueryWrapper<ProEconPowerstationInfoDay1> currentqw = new QueryWrapper<>();
  3594. currentqw.select("foreign_key_id,max(record_date) record_date,sum(rxdtjssdl) yxdtjssdl,sum(rxdjclssdl) yxdjclssdl,sum(rllfdl) yllfdl");
  3595. currentqw.eq("location", "wp");
  3596. currentqw.eq("to_char(record_date,'yyyy')", year);
  3597. if (type.equals("-1")) {
  3598. currentqw.like("foreign_key_id", "_FDC_");
  3599. } else {
  3600. currentqw.like("foreign_key_id", "_GDC_");
  3601. }
  3602. if (companys.endsWith("ZGS")) {
  3603. currentqw.eq("company_id", companys);
  3604. } else {
  3605. currentqw.eq("region_id", companys);
  3606. }
  3607. currentqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  3608. List<ProEconPowerstationInfoDay1> currentList = proEconPowerstationInfoDay1Service.list(currentqw);
  3609. currentqw.clear();
  3610. currentqw.select("foreign_key_id,max(record_date) record_date,sum(rxdtjssdl) yxdtjssdl,sum(rxdjclssdl) yxdjclssdl,sum(rllfdl) yllfdl");
  3611. currentqw.eq("foreign_key_id", companys + type);
  3612. currentqw.eq("to_char(record_date,'yyyy')", year);
  3613. currentqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  3614. currentList.addAll(proEconPowerstationInfoDay1Service.list(currentqw));
  3615. int subYear = Integer.parseInt(year) - 1;
  3616. QueryWrapper<ProEconPowerstationInfoDay1> sameperiodqw = new QueryWrapper<>();
  3617. sameperiodqw.select("foreign_key_id,max(record_date) record_date,sum(rxdtjssdl) yxdtjssdl,sum(rxdjclssdl) yxdjclssdl,sum(rllfdl) yllfdl");
  3618. sameperiodqw.eq("location", "wp");
  3619. if (type.equals("-1")) {
  3620. currentqw.like("foreign_key_id", "_FDC_");
  3621. } else {
  3622. currentqw.like("foreign_key_id", "_GDC_");
  3623. }
  3624. if (companys.endsWith("ZGS")) {
  3625. currentqw.eq("company_id", companys);
  3626. } else {
  3627. currentqw.eq("region_id", companys);
  3628. }
  3629. sameperiodqw.eq("to_char(record_date,'yyyy')", String.valueOf(subYear));
  3630. sameperiodqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  3631. List<ProEconPowerstationInfoDay1> sameperiodList = proEconPowerstationInfoDay1Service.list(sameperiodqw);
  3632. sameperiodqw.clear();
  3633. sameperiodqw.select("foreign_key_id,max(record_date) record_date,sum(rxdtjssdl) yxdtjssdl,sum(rxdjclssdl) yxdjclssdl,sum(rllfdl) yllfdl");
  3634. sameperiodqw.eq("foreign_key_id", companys + type);
  3635. sameperiodqw.eq("to_char(record_date,'yyyy')", String.valueOf(subYear));
  3636. sameperiodqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  3637. sameperiodList.addAll(proEconPowerstationInfoDay1Service.list(sameperiodqw));
  3638. //合并当月与同期数据为返回结果
  3639. List<SpecificTargetVo> resultList = new ArrayList<>();
  3640. currentList.stream().forEach(i -> {
  3641. SpecificTargetVo vo = new SpecificTargetVo();
  3642. String wpid = i.getForeignKeyId();
  3643. vo.setWpid(wpid);
  3644. if (wpid.contains("_ZGS") || wpid.contains("_FGS" + type)) {
  3645. vo.setWpname(CacheContext.cpmap.get(companys).getAname());
  3646. } else if (wpid.contains("_RGN")) {
  3647. vo.setWpname(CacheContext.rgmap.get(companys).getAname());
  3648. } else {
  3649. vo.setWpname(CacheContext.wpmap.get(wpid).getAname());
  3650. }
  3651. vo.setYear(DateUtils.getYear(i.getRecordDate()));
  3652. vo.setMonth(DateUtils.getMonth(i.getRecordDate()));
  3653. vo.setCurrent(DoubleUtils.keepPrecision(i.getYllfdl().doubleValue() != 0 ? (i.getYxdjclssdl().doubleValue() + i.getYxdtjssdl().doubleValue()) / i.getYllfdl().doubleValue() * 100 : 0, 2));
  3654. resultList.add(vo);
  3655. });
  3656. resultList.stream().forEach(i -> {
  3657. Optional<ProEconPowerstationInfoDay1> optional = sameperiodList.stream()
  3658. .filter(j -> j.getForeignKeyId().equals(i.getWpid()) && String.valueOf(DateUtils.getMonth(j.getRecordDate())).equals(i.getMonth()))
  3659. .findFirst();
  3660. if (optional.isPresent()) {
  3661. ProEconPowerstationInfoDay1 tqinfoday = optional.get();
  3662. i.setSameperiod(DoubleUtils.keepPrecision(tqinfoday.getYllfdl().doubleValue() != 0 ? (tqinfoday.getYxdjclssdl().doubleValue() + tqinfoday.getYxdtjssdl().doubleValue()) / tqinfoday.getYllfdl().doubleValue() * 100 : 0, 2));
  3663. i.setCompare(i.getCurrent().compareTo(i.getSameperiod()));
  3664. } else {
  3665. i.setSameperiod(0.0);
  3666. i.setCompare(0);
  3667. }
  3668. });
  3669. List<SpecificTarget> resultendList = new ArrayList<>();
  3670. Map<String, Map<Integer, SpecificTargetVo>> map = new HashMap<>();
  3671. resultList.stream().forEach(i -> {
  3672. if (map.containsKey(i.getWpid())) {
  3673. Map<Integer, SpecificTargetVo> integerListMap = map.get(i.getWpid());
  3674. if (!integerListMap.containsKey(i.getMonth())) {
  3675. map.get(i.getWpid()).put(i.getMonth(), i);
  3676. } else {
  3677. }
  3678. } else {
  3679. Map<Integer, SpecificTargetVo> tempMap = new HashMap<>();
  3680. tempMap.put(i.getMonth(), i);
  3681. map.put(i.getWpid(), tempMap);
  3682. }
  3683. });
  3684. Set<String> wpids = map.keySet();
  3685. if (StringUtils.isNotNull(wpids)) {
  3686. wpids.stream().forEach(wpid -> {
  3687. SpecificTarget vo = new SpecificTarget();
  3688. vo.setWpid(wpid);
  3689. int orderNum = 100;
  3690. if (wpid.contains("_ZGS") || wpid.contains("_FGS" + type)) {
  3691. vo.setWpname(CacheContext.cpmap.get(companys).getAname());
  3692. } else if (wpid.contains("_RGN")) {
  3693. vo.setWpname(CacheContext.rgmap.get(companys).getAname());
  3694. } else {
  3695. vo.setWpname(CacheContext.wpmap.get(wpid).getAname());
  3696. orderNum = CacheContext.wpmap.get(wpid).getOrderNum();
  3697. }
  3698. vo.setOrderNum(orderNum);
  3699. List<SpecificTargetVo> tempList = new ArrayList<>();
  3700. Map<Integer, SpecificTargetVo> listMap = map.get(wpid);
  3701. for (int x = 1; x <= 12; x++) {
  3702. if (listMap.containsKey(x)) {
  3703. tempList.add(listMap.get(x));
  3704. } else {
  3705. SpecificTargetVo vo1 = new SpecificTargetVo();
  3706. vo1.setWpid(wpid);
  3707. if (wpid.contains("_ZGS") || wpid.contains("_FGS" + type)) {
  3708. vo1.setWpname(CacheContext.cpmap.get(companys).getAname());
  3709. } else if (wpid.contains("_RGN")) {
  3710. vo1.setWpname(CacheContext.rgmap.get(companys).getAname());
  3711. } else {
  3712. vo1.setWpname(CacheContext.wpmap.get(wpid).getAname());
  3713. }
  3714. vo1.setYear(Integer.parseInt(year));
  3715. vo1.setMonth(x);
  3716. tempList.add(vo1);
  3717. }
  3718. }
  3719. vo.setTargetList(tempList);
  3720. resultendList.add(vo);
  3721. });
  3722. }
  3723. SortUtils.sort(resultendList, "orderNum", SortUtils.ASC);
  3724. return resultendList;
  3725. }
  3726. public List<SpecificTarget> xdsslList(String companys, String type, String year) {
  3727. //获取年份所有当月的数据
  3728. QueryWrapper<TurbineInfoDay> currentqw = new QueryWrapper<>();
  3729. currentqw.select("station_id,max(record_date) record_date,sum(xdss) xdss,sum(llfdl) llfdl");
  3730. // currentqw.eq("location", "wp");
  3731. currentqw.eq("to_char(record_date,'yyyy')", year);
  3732. if (type.equals("-1")) {
  3733. currentqw.like("station_id", "_FDC_");
  3734. } else {
  3735. currentqw.like("station_id", "_GDC_");
  3736. }
  3737. // if (companys.endsWith("ZGS")) {
  3738. // currentqw.eq("company_id", companys);
  3739. // } else {
  3740. // currentqw.eq("region_id", companys);
  3741. // }
  3742. currentqw.groupBy("to_char(record_date,'yyyy-MM'),station_id");
  3743. List<TurbineInfoDay> currentList = iTurbineInfoDayService.list(currentqw);
  3744. // currentqw.clear();
  3745. // currentqw.select("station_id,max(record_date) record_date,sum(xdss) xdss,sum(llfdl) llfdl");
  3746. //// currentqw.eq("foreign_key_id", companys + type);
  3747. // currentqw.eq("to_char(record_date,'yyyy')", year);
  3748. // currentqw.groupBy("to_char(record_date,'yyyy-MM'),station_id");
  3749. // currentList.addAll(iTurbineInfoDayService.list(currentqw));
  3750. int subYear = Integer.parseInt(year) - 1;
  3751. QueryWrapper<TurbineInfoDay> sameperiodqw = new QueryWrapper<>();
  3752. sameperiodqw.select("station_id,max(record_date) record_date,sum(xdss) xdss,sum(llfdl) llfdl");
  3753. // sameperiodqw.eq("location", "wp");
  3754. if (type.equals("-1")) {
  3755. currentqw.like("station_id", "_FDC_");
  3756. } else {
  3757. currentqw.like("station_id", "_GDC_");
  3758. }
  3759. // if (companys.endsWith("ZGS")) {
  3760. // currentqw.eq("company_id", companys);
  3761. // } else {
  3762. // currentqw.eq("region_id", companys);
  3763. // }
  3764. sameperiodqw.eq("to_char(record_date,'yyyy')", String.valueOf(subYear));
  3765. sameperiodqw.groupBy("to_char(record_date,'yyyy-MM'),station_id");
  3766. List<TurbineInfoDay> sameperiodList = iTurbineInfoDayService.list(sameperiodqw);
  3767. // sameperiodqw.clear();
  3768. // sameperiodqw.select("station_id,max(record_date) record_date,sum(xdss) xdss,sum(llfdl) llfdl");
  3769. //// sameperiodqw.eq("foreign_key_id", companys + type);
  3770. // sameperiodqw.eq("to_char(record_date,'yyyy')", String.valueOf(subYear));
  3771. // sameperiodqw.groupBy("to_char(record_date,'yyyy-MM'),station_id");
  3772. // sameperiodList.addAll(iTurbineInfoDayService.list(sameperiodqw));
  3773. //合并当月与同期数据为返回结果
  3774. List<SpecificTargetVo> resultList = new ArrayList<>();
  3775. currentList.stream().forEach(i -> {
  3776. SpecificTargetVo vo = new SpecificTargetVo();
  3777. String wpid = i.getStationId();
  3778. vo.setWpid(wpid);
  3779. // if (wpid.contains("_ZGS") || wpid.contains("_FGS" + type)) {
  3780. // vo.setWpname(CacheContext.cpmap.get(companys).getAname());
  3781. // } else if (wpid.contains("_RGN")) {
  3782. // vo.setWpname(CacheContext.rgmap.get(companys).getAname());
  3783. // } else {
  3784. vo.setWpname(CacheContext.wpmap.get(wpid).getAname());
  3785. // }
  3786. // Instant instant = i.getRecordDate().atStartOfDay(ZoneId.systemDefault()).toInstant();
  3787. // Date date = Date.from(instant);
  3788. vo.setYear(i.getRecordDate().getYear()+1900);
  3789. vo.setMonth(i.getRecordDate().getMonth()+1);
  3790. // vo.setCurrent(DoubleUtils.keepPrecision(i.getLlfdl().doubleValue() != 0 ? (i.getXdss().doubleValue()) / i.getLlfdl().doubleValue() * 100 : 0, 2));
  3791. double llfdl = i.getLlfdl() != null ? i.getLlfdl().doubleValue() : 0.0;
  3792. double rfdl = i.getXdss() != null ? i.getXdss().doubleValue() : 0.0;
  3793. if (llfdl != 0) {
  3794. Double calculatedValue = DoubleUtils.keepPrecision(rfdl / llfdl * 100, 2);
  3795. vo.setCurrent(calculatedValue);
  3796. } else {
  3797. vo.setCurrent(0.0);
  3798. }
  3799. resultList.add(vo);
  3800. });
  3801. resultList.stream().forEach(i -> {
  3802. Optional<TurbineInfoDay> optional = sameperiodList.stream()
  3803. // .filter(j -> j.getStationId().equals(i.getWpid()) && String.valueOf(DateUtils.getMonth(Date.from(j.getRecordDate().atStartOfDay(ZoneId.systemDefault()).toInstant()))).equals(i.getMonth()))
  3804. .findFirst();
  3805. if (optional.isPresent()) {
  3806. TurbineInfoDay tqinfoday = optional.get();
  3807. // i.setSameperiod(DoubleUtils.keepPrecision(tqinfoday.getLlfdl().doubleValue() != 0 ? (tqinfoday.getXdss().doubleValue() ) / tqinfoday.getLlfdl().doubleValue() * 100 : 0, 2));
  3808. double llfdl = tqinfoday.getLlfdl() != null ? tqinfoday.getLlfdl().doubleValue() : 0.0;
  3809. double rfdl = tqinfoday.getXdss() != null ? tqinfoday.getXdss().doubleValue() : 0.0;
  3810. if (llfdl != 0) {
  3811. Double calculatedValue = DoubleUtils.keepPrecision(rfdl / llfdl * 100, 2);
  3812. i.setSameperiod(calculatedValue);
  3813. } else {
  3814. i.setSameperiod(0.0);
  3815. }
  3816. i.setCompare(i.getCurrent().compareTo(i.getSameperiod()));
  3817. } else {
  3818. i.setSameperiod(0.0);
  3819. i.setCompare(0);
  3820. }
  3821. });
  3822. List<SpecificTarget> resultendList = new ArrayList<>();
  3823. Map<String, Map<Integer, SpecificTargetVo>> map = new HashMap<>();
  3824. resultList.stream().forEach(i -> {
  3825. if (map.containsKey(i.getWpid())) {
  3826. Map<Integer, SpecificTargetVo> integerListMap = map.get(i.getWpid());
  3827. if (!integerListMap.containsKey(i.getMonth())) {
  3828. map.get(i.getWpid()).put(i.getMonth(), i);
  3829. } else {
  3830. }
  3831. } else {
  3832. Map<Integer, SpecificTargetVo> tempMap = new HashMap<>();
  3833. tempMap.put(i.getMonth(), i);
  3834. map.put(i.getWpid(), tempMap);
  3835. }
  3836. });
  3837. Set<String> wpids = map.keySet();
  3838. if (StringUtils.isNotNull(wpids)) {
  3839. wpids.stream().forEach(wpid -> {
  3840. SpecificTarget vo = new SpecificTarget();
  3841. vo.setWpid(wpid);
  3842. int orderNum = 100;
  3843. // if (wpid.contains("_ZGS") || wpid.contains("_FGS" + type)) {
  3844. // vo.setWpname(CacheContext.cpmap.get(companys).getAname());
  3845. // } else if (wpid.contains("_RGN")) {
  3846. // vo.setWpname(CacheContext.rgmap.get(companys).getAname());
  3847. // } else {
  3848. vo.setWpname(CacheContext.wpmap.get(wpid).getAname());
  3849. orderNum = CacheContext.wpmap.get(wpid).getOrderNum();
  3850. // }
  3851. vo.setOrderNum(orderNum);
  3852. List<SpecificTargetVo> tempList = new ArrayList<>();
  3853. Map<Integer, SpecificTargetVo> listMap = map.get(wpid);
  3854. for (int x = 1; x <= 12; x++) {
  3855. if (listMap.containsKey(x)) {
  3856. tempList.add(listMap.get(x));
  3857. } else {
  3858. SpecificTargetVo vo1 = new SpecificTargetVo();
  3859. vo1.setWpid(wpid);
  3860. // if (wpid.contains("_ZGS") || wpid.contains("_FGS" + type)) {
  3861. // vo1.setWpname(CacheContext.cpmap.get(companys).getAname());
  3862. // } else if (wpid.contains("_RGN")) {
  3863. // vo1.setWpname(CacheContext.rgmap.get(companys).getAname());
  3864. // } else {
  3865. vo1.setWpname(CacheContext.wpmap.get(wpid).getAname());
  3866. // }
  3867. vo1.setYear(Integer.parseInt(year));
  3868. vo1.setMonth(x);
  3869. tempList.add(vo1);
  3870. }
  3871. }
  3872. vo.setTargetList(tempList);
  3873. resultendList.add(vo);
  3874. SpecificTarget vo2 = new SpecificTarget();
  3875. vo2.setWpid(vo.getWpid());
  3876. vo2.setTargetList(vo.getTargetList());
  3877. vo2.setOrderNum(vo.getOrderNum() + 1);
  3878. vo2.setWpname(CacheContext.cpmap.get(companys).getAname());
  3879. resultendList.add(vo2);
  3880. });
  3881. }
  3882. SortUtils.sort(resultendList, "orderNum", SortUtils.ASC);
  3883. return resultendList;
  3884. }
  3885. public List<SpecificTarget> xnsslList2(String companys, String type, String year) {
  3886. //获取年份所有当月的数据
  3887. QueryWrapper<ProEconPowerstationInfoDay1> currentqw = new QueryWrapper<>();
  3888. currentqw.select("foreign_key_id,max(record_date) record_date,sum(rdjssdl) ydjssdl,sum(rqxjclssdl) yqxjclssdl,sum(rsdtjssdl) ysdtjssdl,sum(rxnssdl) yxnssdl,sum(rllfdl) yllfdl");
  3889. currentqw.eq("location", "wp");
  3890. currentqw.eq("to_char(record_date,'yyyy')", year);
  3891. if (type.equals("-1")) {
  3892. currentqw.like("foreign_key_id", "_FDC_");
  3893. } else {
  3894. currentqw.like("foreign_key_id", "_GDC_");
  3895. }
  3896. if (companys.endsWith("ZGS")) {
  3897. currentqw.eq("company_id", companys);
  3898. } else {
  3899. currentqw.eq("region_id", companys);
  3900. }
  3901. currentqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  3902. List<ProEconPowerstationInfoDay1> currentList = proEconPowerstationInfoDay1Service.list(currentqw);
  3903. currentqw.clear();
  3904. currentqw.select("foreign_key_id,max(record_date) record_date,sum(rdjssdl) ydjssdl,sum(rqxjclssdl) yqxjclssdl,sum(rsdtjssdl) ysdtjssdl,sum(rxnssdl) yxnssdl,sum(rllfdl) yllfdl");
  3905. currentqw.eq("foreign_key_id", companys + type);
  3906. currentqw.eq("to_char(record_date,'yyyy')", year);
  3907. currentqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  3908. currentList.addAll(proEconPowerstationInfoDay1Service.list(currentqw));
  3909. int subYear = Integer.parseInt(year) - 1;
  3910. QueryWrapper<ProEconPowerstationInfoDay1> sameperiodqw = new QueryWrapper<>();
  3911. sameperiodqw.select("foreign_key_id,max(record_date) record_date,sum(rdjssdl) ydjssdl,sum(rqxjclssdl) yqxjclssdl,sum(rsdtjssdl) ysdtjssdl,sum(rxnssdl) yxnssdl,sum(rllfdl) yllfdl");
  3912. sameperiodqw.eq("location", "wp");
  3913. if (type.equals("-1")) {
  3914. currentqw.like("foreign_key_id", "_FDC_");
  3915. } else {
  3916. currentqw.like("foreign_key_id", "_GDC_");
  3917. }
  3918. if (companys.endsWith("ZGS")) {
  3919. currentqw.eq("company_id", companys);
  3920. } else {
  3921. currentqw.eq("region_id", companys);
  3922. }
  3923. sameperiodqw.eq("to_char(record_date,'yyyy')", String.valueOf(subYear));
  3924. sameperiodqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  3925. List<ProEconPowerstationInfoDay1> sameperiodList = proEconPowerstationInfoDay1Service.list(sameperiodqw);
  3926. sameperiodqw.clear();
  3927. sameperiodqw.select("foreign_key_id,max(record_date) record_date,sum(rdjssdl) ydjssdl,sum(rqxjclssdl) yqxjclssdl,sum(rsdtjssdl) ysdtjssdl,sum(rxnssdl) yxnssdl,sum(rllfdl) yllfdl");
  3928. sameperiodqw.eq("foreign_key_id", companys + type);
  3929. sameperiodqw.eq("to_char(record_date,'yyyy')", String.valueOf(subYear));
  3930. sameperiodqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  3931. sameperiodList.addAll(proEconPowerstationInfoDay1Service.list(sameperiodqw));
  3932. //合并当月与同期数据为返回结果
  3933. List<SpecificTargetVo> resultList = new ArrayList<>();
  3934. currentList.stream().forEach(i -> {
  3935. SpecificTargetVo vo = new SpecificTargetVo();
  3936. String wpid = i.getForeignKeyId();
  3937. vo.setWpid(wpid);
  3938. if (wpid.contains("_ZGS") || wpid.contains("_FGS" + type)) {
  3939. vo.setWpname(CacheContext.cpmap.get(companys).getAname());
  3940. } else if (wpid.contains("_RGN")) {
  3941. vo.setWpname(CacheContext.rgmap.get(companys).getAname());
  3942. } else {
  3943. vo.setWpname(CacheContext.wpmap.get(wpid).getAname());
  3944. }
  3945. vo.setYear(DateUtils.getYear(i.getRecordDate()));
  3946. vo.setMonth(DateUtils.getMonth(i.getRecordDate()));
  3947. vo.setCurrent(DoubleUtils.keepPrecision(i.getYllfdl().doubleValue() != 0 ? (i.getYdjssdl().doubleValue() + i.getYqxjclssdl().doubleValue() + i.getYsdtjssdl().doubleValue() + i.getYxnssdl().doubleValue()) / i.getYllfdl().doubleValue() * 100 : 0, 2));
  3948. resultList.add(vo);
  3949. });
  3950. resultList.stream().forEach(i -> {
  3951. Optional<ProEconPowerstationInfoDay1> optional = sameperiodList.stream()
  3952. .filter(j -> j.getForeignKeyId().equals(i.getWpid()) && String.valueOf(DateUtils.getMonth(j.getRecordDate())).equals(i.getMonth()))
  3953. .findFirst();
  3954. if (optional.isPresent()) {
  3955. ProEconPowerstationInfoDay1 tqinfoday = optional.get();
  3956. i.setSameperiod(DoubleUtils.keepPrecision(tqinfoday.getYllfdl().doubleValue() != 0 ? (tqinfoday.getYdjssdl().doubleValue() + tqinfoday.getYqxjclssdl().doubleValue() + tqinfoday.getYsdtjssdl().doubleValue() + tqinfoday.getYxnssdl().doubleValue()) / tqinfoday.getYllfdl().doubleValue() * 100 : 0, 2));
  3957. i.setCompare(i.getCurrent().compareTo(i.getSameperiod()));
  3958. } else {
  3959. i.setSameperiod(0.0);
  3960. i.setCompare(0);
  3961. }
  3962. });
  3963. List<SpecificTarget> resultendList = new ArrayList<>();
  3964. Map<String, Map<Integer, SpecificTargetVo>> map = new HashMap<>();
  3965. resultList.stream().forEach(i -> {
  3966. if (map.containsKey(i.getWpid())) {
  3967. Map<Integer, SpecificTargetVo> integerListMap = map.get(i.getWpid());
  3968. if (!integerListMap.containsKey(i.getMonth())) {
  3969. map.get(i.getWpid()).put(i.getMonth(), i);
  3970. } else {
  3971. }
  3972. } else {
  3973. Map<Integer, SpecificTargetVo> tempMap = new HashMap<>();
  3974. tempMap.put(i.getMonth(), i);
  3975. map.put(i.getWpid(), tempMap);
  3976. }
  3977. });
  3978. Set<String> wpids = map.keySet();
  3979. if (StringUtils.isNotNull(wpids)) {
  3980. wpids.stream().forEach(wpid -> {
  3981. SpecificTarget vo = new SpecificTarget();
  3982. vo.setWpid(wpid);
  3983. int orderNum = 100;
  3984. if (wpid.contains("_ZGS") || wpid.contains("_FGS" + type)) {
  3985. vo.setWpname(CacheContext.cpmap.get(companys).getAname());
  3986. } else if (wpid.contains("_RGN")) {
  3987. vo.setWpname(CacheContext.rgmap.get(companys).getAname());
  3988. } else {
  3989. vo.setWpname(CacheContext.wpmap.get(wpid).getAname());
  3990. orderNum = CacheContext.wpmap.get(wpid).getOrderNum();
  3991. }
  3992. vo.setOrderNum(orderNum);
  3993. List<SpecificTargetVo> tempList = new ArrayList<>();
  3994. Map<Integer, SpecificTargetVo> listMap = map.get(wpid);
  3995. for (int x = 1; x <= 12; x++) {
  3996. if (listMap.containsKey(x)) {
  3997. tempList.add(listMap.get(x));
  3998. } else {
  3999. SpecificTargetVo vo1 = new SpecificTargetVo();
  4000. vo1.setWpid(wpid);
  4001. if (wpid.contains("_ZGS") || wpid.contains("_FGS" + type)) {
  4002. vo1.setWpname(CacheContext.cpmap.get(companys).getAname());
  4003. } else if (wpid.contains("_RGN")) {
  4004. vo1.setWpname(CacheContext.rgmap.get(companys).getAname());
  4005. } else {
  4006. vo1.setWpname(CacheContext.wpmap.get(wpid).getAname());
  4007. }
  4008. vo1.setYear(Integer.parseInt(year));
  4009. vo1.setMonth(x);
  4010. tempList.add(vo1);
  4011. }
  4012. }
  4013. vo.setTargetList(tempList);
  4014. resultendList.add(vo);
  4015. });
  4016. }
  4017. SortUtils.sort(resultendList, "orderNum", SortUtils.ASC);
  4018. return resultendList;
  4019. }
  4020. public List<SpecificTarget> xnsslList(String companys, String type, String year) {
  4021. //获取年份所有当月的数据
  4022. QueryWrapper<TurbineInfoDay> currentqw = new QueryWrapper<>();
  4023. currentqw.select("station_id,max(record_date) record_date,sum(xnss) xnss,sum(llfdl) llfdl");
  4024. // currentqw.eq("location", "wp");
  4025. currentqw.eq("to_char(record_date,'yyyy')", year);
  4026. if (type.equals("-1")) {
  4027. currentqw.like("station_id", "_FDC_");
  4028. } else {
  4029. currentqw.like("station_id", "_GDC_");
  4030. }
  4031. // if (companys.endsWith("ZGS")) {
  4032. // currentqw.eq("company_id", companys);
  4033. // } else {
  4034. // currentqw.eq("region_id", companys);
  4035. // }
  4036. currentqw.groupBy("to_char(record_date,'yyyy-MM'),station_id");
  4037. List<TurbineInfoDay> currentList = iTurbineInfoDayService.list(currentqw);
  4038. // currentqw.clear();
  4039. // currentqw.select("station_id,max(record_date) record_date,sum(xnss) xnss,sum(llfdl) llfdl");
  4040. //// currentqw.eq("foreign_key_id", companys + type);
  4041. // currentqw.eq("to_char(record_date,'yyyy')", year);
  4042. // currentqw.groupBy("to_char(record_date,'yyyy-MM'),station_id");
  4043. // currentList.addAll(iTurbineInfoDayService.list(currentqw));
  4044. int subYear = Integer.parseInt(year) - 1;
  4045. QueryWrapper<TurbineInfoDay> sameperiodqw = new QueryWrapper<>();
  4046. sameperiodqw.select("station_id,max(record_date) record_date,sum(xnss) xnss,sum(llfdl) llfdl");
  4047. // sameperiodqw.eq("location", "wp");
  4048. if (type.equals("-1")) {
  4049. currentqw.like("station_id", "_FDC_");
  4050. } else {
  4051. currentqw.like("station_id", "_GDC_");
  4052. }
  4053. // if (companys.endsWith("ZGS")) {
  4054. // currentqw.eq("company_id", companys);
  4055. // } else {
  4056. // currentqw.eq("region_id", companys);
  4057. // }
  4058. sameperiodqw.eq("to_char(record_date,'yyyy')", String.valueOf(subYear));
  4059. sameperiodqw.groupBy("to_char(record_date,'yyyy-MM'),station_id");
  4060. List<TurbineInfoDay> sameperiodList = iTurbineInfoDayService.list(sameperiodqw);
  4061. // sameperiodqw.clear();
  4062. // sameperiodqw.select("station_id,max(record_date) record_date,sum(xnss) xnss,sum(llfdl) llfdl");
  4063. //// sameperiodqw.eq("station_id", companys + type);
  4064. // sameperiodqw.eq("to_char(record_date,'yyyy')", String.valueOf(subYear));
  4065. // sameperiodqw.groupBy("to_char(record_date,'yyyy-MM'),station_id");
  4066. // sameperiodList.addAll(iTurbineInfoDayService.list(sameperiodqw));
  4067. //合并当月与同期数据为返回结果
  4068. List<SpecificTargetVo> resultList = new ArrayList<>();
  4069. currentList.stream().forEach(i -> {
  4070. SpecificTargetVo vo = new SpecificTargetVo();
  4071. String wpid = i.getStationId();
  4072. vo.setWpid(wpid);
  4073. if (wpid.contains("_ZGS") || wpid.contains("_FGS" + type)) {
  4074. vo.setWpname(CacheContext.cpmap.get(companys).getAname());
  4075. } else if (wpid.contains("_RGN")) {
  4076. vo.setWpname(CacheContext.rgmap.get(companys).getAname());
  4077. } else {
  4078. vo.setWpname(CacheContext.wpmap.get(wpid).getAname());
  4079. }
  4080. // Instant instant = i.getRecordDate().atStartOfDay(ZoneId.systemDefault()).toInstant();
  4081. // Date date = Date.from(instant);
  4082. vo.setYear(i.getRecordDate().getYear()+1900);
  4083. vo.setMonth(i.getRecordDate().getMonth()+1);
  4084. // vo.setCurrent(DoubleUtils.keepPrecision(i.getLlfdl().doubleValue() != 0 ? (i.getXnss().doubleValue()) / i.getLlfdl().doubleValue() * 100 : 0, 2));
  4085. double llfdl = i.getLlfdl() != null ? i.getLlfdl().doubleValue() : 0.0;
  4086. double rfdl = i.getXnss() != null ? i.getXnss().doubleValue() : 0.0;
  4087. if (llfdl != 0) {
  4088. Double calculatedValue = DoubleUtils.keepPrecision(rfdl / llfdl * 100, 2);
  4089. vo.setCurrent(calculatedValue);
  4090. } else {
  4091. vo.setCurrent(0.0);
  4092. }
  4093. resultList.add(vo);
  4094. });
  4095. resultList.stream().forEach(i -> {
  4096. Optional<TurbineInfoDay> optional = sameperiodList.stream()
  4097. // .filter(j -> j.getStationId().equals(i.getWpid()) && String.valueOf(DateUtils.getMonth(Date.from(j.getRecordDate().atStartOfDay(ZoneId.systemDefault()).toInstant()))).equals(i.getMonth()))
  4098. .findFirst();
  4099. if (optional.isPresent()) {
  4100. TurbineInfoDay tqinfoday = optional.get();
  4101. i.setSameperiod(DoubleUtils.keepPrecision(tqinfoday.getLlfdl().doubleValue() != 0 ? (tqinfoday.getXnss().doubleValue()) / tqinfoday.getLlfdl().doubleValue() * 100 : 0, 2));
  4102. double llfdl = tqinfoday.getLlfdl() != null ? tqinfoday.getLlfdl().doubleValue() : 0.0;
  4103. double rfdl = tqinfoday.getXnss() != null ? tqinfoday.getXnss().doubleValue() : 0.0;
  4104. if (llfdl != 0) {
  4105. Double calculatedValue = DoubleUtils.keepPrecision(rfdl / llfdl * 100, 2);
  4106. i.setSameperiod(calculatedValue);
  4107. } else {
  4108. i.setSameperiod(0.0);
  4109. }
  4110. i.setCompare(i.getCurrent().compareTo(i.getSameperiod()));
  4111. } else {
  4112. i.setSameperiod(0.0);
  4113. i.setCompare(0);
  4114. }
  4115. });
  4116. List<SpecificTarget> resultendList = new ArrayList<>();
  4117. Map<String, Map<Integer, SpecificTargetVo>> map = new HashMap<>();
  4118. resultList.stream().forEach(i -> {
  4119. if (map.containsKey(i.getWpid())) {
  4120. Map<Integer, SpecificTargetVo> integerListMap = map.get(i.getWpid());
  4121. if (!integerListMap.containsKey(i.getMonth())) {
  4122. map.get(i.getWpid()).put(i.getMonth(), i);
  4123. } else {
  4124. }
  4125. } else {
  4126. Map<Integer, SpecificTargetVo> tempMap = new HashMap<>();
  4127. tempMap.put(i.getMonth(), i);
  4128. map.put(i.getWpid(), tempMap);
  4129. }
  4130. });
  4131. Set<String> wpids = map.keySet();
  4132. if (StringUtils.isNotNull(wpids)) {
  4133. wpids.stream().forEach(wpid -> {
  4134. SpecificTarget vo = new SpecificTarget();
  4135. vo.setWpid(wpid);
  4136. int orderNum = 100;
  4137. // if (wpid.contains("_ZGS") || wpid.contains("_FGS" + type)) {
  4138. // vo.setWpname(CacheContext.cpmap.get(companys).getAname());
  4139. // } else if (wpid.contains("_RGN")) {
  4140. // vo.setWpname(CacheContext.rgmap.get(companys).getAname());
  4141. // } else {
  4142. vo.setWpname(CacheContext.wpmap.get(wpid).getAname());
  4143. orderNum = CacheContext.wpmap.get(wpid).getOrderNum();
  4144. // }
  4145. vo.setOrderNum(orderNum);
  4146. List<SpecificTargetVo> tempList = new ArrayList<>();
  4147. Map<Integer, SpecificTargetVo> listMap = map.get(wpid);
  4148. for (int x = 1; x <= 12; x++) {
  4149. if (listMap.containsKey(x)) {
  4150. tempList.add(listMap.get(x));
  4151. } else {
  4152. SpecificTargetVo vo1 = new SpecificTargetVo();
  4153. vo1.setWpid(wpid);
  4154. // if (wpid.contains("_ZGS") || wpid.contains("_FGS" + type)) {
  4155. // vo1.setWpname(CacheContext.cpmap.get(companys).getAname());
  4156. // } else if (wpid.contains("_RGN")) {
  4157. // vo1.setWpname(CacheContext.rgmap.get(companys).getAname());
  4158. // } else {
  4159. vo1.setWpname(CacheContext.wpmap.get(wpid).getAname());
  4160. // }
  4161. vo1.setYear(Integer.parseInt(year));
  4162. vo1.setMonth(x);
  4163. tempList.add(vo1);
  4164. }
  4165. }
  4166. vo.setTargetList(tempList);
  4167. resultendList.add(vo);
  4168. SpecificTarget vo2 = new SpecificTarget();
  4169. vo2.setWpid(vo.getWpid());
  4170. vo2.setTargetList(vo.getTargetList());
  4171. vo2.setOrderNum(vo.getOrderNum() + 1);
  4172. vo2.setWpname(CacheContext.cpmap.get(companys).getAname());
  4173. resultendList.add(vo2);
  4174. });
  4175. }
  4176. SortUtils.sort(resultendList, "orderNum", SortUtils.ASC);
  4177. return resultendList;
  4178. }
  4179. public List<SpecificTarget> slsslList2(String companys, String type, String year) {
  4180. //获取年份所有当月的数据
  4181. QueryWrapper<ProEconPowerstationInfoDay1> currentqw = new QueryWrapper<>();
  4182. currentqw.select("foreign_key_id,max(record_date) record_date,sum(rcwsldwssdl) ycwsldwssdl,sum(rcwsltqssdl) ycwsltqssdl,sum(rllfdl) yllfdl");
  4183. currentqw.eq("location", "wp");
  4184. currentqw.eq("to_char(record_date,'yyyy')", year);
  4185. if (type.equals("-1")) {
  4186. currentqw.like("foreign_key_id", "_FDC_");
  4187. } else {
  4188. currentqw.like("foreign_key_id", "_GDC_");
  4189. }
  4190. if (companys.endsWith("ZGS")) {
  4191. currentqw.eq("company_id", companys);
  4192. } else {
  4193. currentqw.eq("region_id", companys);
  4194. }
  4195. currentqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  4196. List<ProEconPowerstationInfoDay1> currentList = proEconPowerstationInfoDay1Service.list(currentqw);
  4197. currentqw.clear();
  4198. currentqw.select("foreign_key_id,max(record_date) record_date,sum(rcwsldwssdl) ycwsldwssdl,sum(rcwsltqssdl) ycwsltqssdl,sum(rllfdl) yllfdl");
  4199. currentqw.eq("foreign_key_id", companys + type);
  4200. currentqw.eq("to_char(record_date,'yyyy')", year);
  4201. currentqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  4202. currentList.addAll(proEconPowerstationInfoDay1Service.list(currentqw));
  4203. int subYear = Integer.parseInt(year) - 1;
  4204. QueryWrapper<ProEconPowerstationInfoDay1> sameperiodqw = new QueryWrapper<>();
  4205. sameperiodqw.select("foreign_key_id,max(record_date) record_date,sum(rcwsldwssdl) ycwsldwssdl,sum(rcwsltqssdl) ycwsltqssdl,sum(rllfdl) yllfdl");
  4206. sameperiodqw.eq("location", "wp");
  4207. if (type.equals("-1")) {
  4208. currentqw.like("foreign_key_id", "_FDC_");
  4209. } else {
  4210. currentqw.like("foreign_key_id", "_GDC_");
  4211. }
  4212. if (companys.endsWith("ZGS")) {
  4213. currentqw.eq("company_id", companys);
  4214. } else {
  4215. currentqw.eq("region_id", companys);
  4216. }
  4217. sameperiodqw.eq("to_char(record_date,'yyyy')", String.valueOf(subYear));
  4218. sameperiodqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  4219. List<ProEconPowerstationInfoDay1> sameperiodList = proEconPowerstationInfoDay1Service.list(sameperiodqw);
  4220. sameperiodqw.clear();
  4221. sameperiodqw.select("foreign_key_id,max(record_date) record_date,sum(rcwsldwssdl) ycwsldwssdl,sum(rcwsltqssdl) ycwsltqssdl,sum(rllfdl) yllfdl");
  4222. sameperiodqw.eq("foreign_key_id", companys + type);
  4223. sameperiodqw.eq("to_char(record_date,'yyyy')", String.valueOf(subYear));
  4224. sameperiodqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  4225. sameperiodList.addAll(proEconPowerstationInfoDay1Service.list(sameperiodqw));
  4226. //合并当月与同期数据为返回结果
  4227. List<SpecificTargetVo> resultList = new ArrayList<>();
  4228. currentList.stream().forEach(i -> {
  4229. SpecificTargetVo vo = new SpecificTargetVo();
  4230. String wpid = i.getForeignKeyId();
  4231. vo.setWpid(wpid);
  4232. if (wpid.contains("_ZGS") || wpid.contains("_FGS" + type)) {
  4233. vo.setWpname(CacheContext.cpmap.get(companys).getAname());
  4234. } else if (wpid.contains("_RGN")) {
  4235. vo.setWpname(CacheContext.rgmap.get(companys).getAname());
  4236. } else {
  4237. vo.setWpname(CacheContext.wpmap.get(wpid).getAname());
  4238. }
  4239. vo.setYear(DateUtils.getYear(i.getRecordDate()));
  4240. vo.setMonth(DateUtils.getMonth(i.getRecordDate()));
  4241. vo.setCurrent(DoubleUtils.keepPrecision(i.getYllfdl().doubleValue() != 0 ? (i.getYcwsldwssdl().doubleValue() + i.getYcwsltqssdl().doubleValue()) / i.getYllfdl().doubleValue() * 100 : 0, 2));
  4242. resultList.add(vo);
  4243. });
  4244. resultList.stream().forEach(i -> {
  4245. Optional<ProEconPowerstationInfoDay1> optional = sameperiodList.stream()
  4246. .filter(j -> j.getForeignKeyId().equals(i.getWpid()) && String.valueOf(DateUtils.getMonth(j.getRecordDate())).equals(i.getMonth()))
  4247. .findFirst();
  4248. if (optional.isPresent()) {
  4249. ProEconPowerstationInfoDay1 tqinfoday = optional.get();
  4250. i.setSameperiod(DoubleUtils.keepPrecision(tqinfoday.getYllfdl().doubleValue() != 0 ? (tqinfoday.getYcwsldwssdl().doubleValue() + tqinfoday.getYcwsltqssdl().doubleValue()) / tqinfoday.getYllfdl().doubleValue() * 100 : 0, 2));
  4251. i.setCompare(i.getCurrent().compareTo(i.getSameperiod()));
  4252. } else {
  4253. i.setSameperiod(0.0);
  4254. i.setCompare(0);
  4255. }
  4256. });
  4257. List<SpecificTarget> resultendList = new ArrayList<>();
  4258. Map<String, Map<Integer, SpecificTargetVo>> map = new HashMap<>();
  4259. resultList.stream().forEach(i -> {
  4260. if (map.containsKey(i.getWpid())) {
  4261. Map<Integer, SpecificTargetVo> integerListMap = map.get(i.getWpid());
  4262. if (!integerListMap.containsKey(i.getMonth())) {
  4263. map.get(i.getWpid()).put(i.getMonth(), i);
  4264. } else {
  4265. }
  4266. } else {
  4267. Map<Integer, SpecificTargetVo> tempMap = new HashMap<>();
  4268. tempMap.put(i.getMonth(), i);
  4269. map.put(i.getWpid(), tempMap);
  4270. }
  4271. });
  4272. Set<String> wpids = map.keySet();
  4273. if (StringUtils.isNotNull(wpids)) {
  4274. wpids.stream().forEach(wpid -> {
  4275. SpecificTarget vo = new SpecificTarget();
  4276. vo.setWpid(wpid);
  4277. int orderNum = 100;
  4278. if (wpid.contains("_ZGS") || wpid.contains("_FGS" + type)) {
  4279. vo.setWpname(CacheContext.cpmap.get(companys).getAname());
  4280. } else if (wpid.contains("_RGN")) {
  4281. vo.setWpname(CacheContext.rgmap.get(companys).getAname());
  4282. } else {
  4283. vo.setWpname(CacheContext.wpmap.get(wpid).getAname());
  4284. orderNum = CacheContext.wpmap.get(wpid).getOrderNum();
  4285. }
  4286. vo.setOrderNum(orderNum);
  4287. List<SpecificTargetVo> tempList = new ArrayList<>();
  4288. Map<Integer, SpecificTargetVo> listMap = map.get(wpid);
  4289. for (int x = 1; x <= 12; x++) {
  4290. if (listMap.containsKey(x)) {
  4291. tempList.add(listMap.get(x));
  4292. } else {
  4293. SpecificTargetVo vo1 = new SpecificTargetVo();
  4294. vo1.setWpid(wpid);
  4295. if (wpid.contains("_ZGS") || wpid.contains("_FGS" + type)) {
  4296. vo1.setWpname(CacheContext.cpmap.get(companys).getAname());
  4297. } else if (wpid.contains("_RGN")) {
  4298. vo1.setWpname(CacheContext.rgmap.get(companys).getAname());
  4299. } else {
  4300. vo1.setWpname(CacheContext.wpmap.get(wpid).getAname());
  4301. }
  4302. vo1.setYear(Integer.parseInt(year));
  4303. vo1.setMonth(x);
  4304. tempList.add(vo1);
  4305. }
  4306. }
  4307. vo.setTargetList(tempList);
  4308. resultendList.add(vo);
  4309. });
  4310. }
  4311. SortUtils.sort(resultendList, "orderNum", SortUtils.ASC);
  4312. return resultendList;
  4313. }
  4314. public List<SpecificTarget> slsslList(String companys, String type, String year) {
  4315. //获取年份所有当月的数据
  4316. QueryWrapper<TurbineInfoDay> currentqw = new QueryWrapper<>();
  4317. currentqw.select("station_id,max(record_date) record_date,sum(slss) slss,sum(llfdl) llfdl");
  4318. // currentqw.eq("location", "wp");
  4319. currentqw.eq("to_char(record_date,'yyyy')", year);
  4320. if (type.equals("-1")) {
  4321. currentqw.like("station_id", "_FDC_");
  4322. } else {
  4323. currentqw.like("station_id", "_GDC_");
  4324. }
  4325. // if (companys.endsWith("ZGS")) {
  4326. // currentqw.eq("company_id", companys);
  4327. // } else {
  4328. // currentqw.eq("region_id", companys);
  4329. // }
  4330. currentqw.groupBy("to_char(record_date,'yyyy-MM'),station_id");
  4331. List<TurbineInfoDay> currentList = iTurbineInfoDayService.list(currentqw);
  4332. // currentqw.clear();
  4333. // currentqw.select("station_id,max(record_date) record_date,sum(slss) slss,sum(llfdl) llfdl");
  4334. //// currentqw.eq("foreign_key_id", companys + type);
  4335. // currentqw.eq("to_char(record_date,'yyyy')", year);
  4336. // currentqw.groupBy("to_char(record_date,'yyyy-MM'),station_id");
  4337. // currentList.addAll(iTurbineInfoDayService.list(currentqw));
  4338. int subYear = Integer.parseInt(year) - 1;
  4339. QueryWrapper<TurbineInfoDay> sameperiodqw = new QueryWrapper<>();
  4340. sameperiodqw.select("station_id,max(record_date) record_date,sum(slss) slss,sum(llfdl) llfdl");
  4341. // sameperiodqw.eq("location", "wp");
  4342. if (type.equals("-1")) {
  4343. currentqw.like("station_id", "_FDC_");
  4344. } else {
  4345. currentqw.like("station_id", "_GDC_");
  4346. }
  4347. // if (companys.endsWith("ZGS")) {
  4348. // currentqw.eq("company_id", companys);
  4349. // } else {
  4350. // currentqw.eq("region_id", companys);
  4351. // }
  4352. sameperiodqw.eq("to_char(record_date,'yyyy')", String.valueOf(subYear));
  4353. sameperiodqw.groupBy("to_char(record_date,'yyyy-MM'),station_id");
  4354. List<TurbineInfoDay> sameperiodList = iTurbineInfoDayService.list(sameperiodqw);
  4355. // sameperiodqw.clear();
  4356. // sameperiodqw.select("station_id,max(record_date) record_date,sum(slss) slss,sum(llfdl) llfdl");
  4357. // sameperiodqw.eq("station_id", companys + type);
  4358. // sameperiodqw.eq("to_char(record_date,'yyyy')", String.valueOf(subYear));
  4359. // sameperiodqw.groupBy("to_char(record_date,'yyyy-MM'),station_id");
  4360. // sameperiodList.addAll(iTurbineInfoDayService.list(sameperiodqw));
  4361. //合并当月与同期数据为返回结果
  4362. List<SpecificTargetVo> resultList = new ArrayList<>();
  4363. currentList.stream().forEach(i -> {
  4364. SpecificTargetVo vo = new SpecificTargetVo();
  4365. String wpid = i.getStationId();
  4366. vo.setWpid(wpid);
  4367. // if (wpid.contains("_ZGS") || wpid.contains("_FGS" + type)) {
  4368. // vo.setWpname(CacheContext.cpmap.get(companys).getAname());
  4369. // } else if (wpid.contains("_RGN")) {
  4370. // vo.setWpname(CacheContext.rgmap.get(companys).getAname());
  4371. // } else {
  4372. vo.setWpname(CacheContext.wpmap.get(wpid).getAname());
  4373. // }
  4374. // Instant instant = i.getRecordDate().atStartOfDay(ZoneId.systemDefault()).toInstant();
  4375. // Date date = Date.from(instant);
  4376. vo.setYear(i.getRecordDate().getYear()+1900);
  4377. vo.setMonth(i.getRecordDate().getMonth()+1);
  4378. // vo.setCurrent(DoubleUtils.keepPrecision(i.getLlfdl().doubleValue() != 0 ? (i.getSlss().doubleValue()) / i.getLlfdl().doubleValue() * 100 : 0, 2));
  4379. double llfdl = i.getLlfdl() != null ? i.getLlfdl().doubleValue() : 0.0;
  4380. double rfdl = i.getSlss() != null ? i.getSlss().doubleValue() : 0.0;
  4381. if (llfdl != 0) {
  4382. Double calculatedValue = DoubleUtils.keepPrecision(rfdl / llfdl * 100, 2);
  4383. vo.setCurrent(calculatedValue);
  4384. } else {
  4385. vo.setCurrent(0.0);
  4386. }
  4387. resultList.add(vo);
  4388. });
  4389. resultList.stream().forEach(i -> {
  4390. Optional<TurbineInfoDay> optional = sameperiodList.stream()
  4391. // .filter(j -> j.getStationId().equals(i.getWpid()) && String.valueOf(DateUtils.getMonth(Date.from(j.getRecordDate().atStartOfDay(ZoneId.systemDefault()).toInstant()))).equals(i.getMonth()))
  4392. .findFirst();
  4393. if (optional.isPresent()) {
  4394. TurbineInfoDay tqinfoday = optional.get();
  4395. // i.setSameperiod(DoubleUtils.keepPrecision(tqinfoday.getLlfdl().doubleValue() != 0 ? (tqinfoday.getSlss().doubleValue() ) / tqinfoday.getLlfdl().doubleValue() * 100 : 0, 2));
  4396. double llfdl = tqinfoday.getLlfdl() != null ? tqinfoday.getLlfdl().doubleValue() : 0.0;
  4397. double rfdl = tqinfoday.getSlss() != null ? tqinfoday.getSlss().doubleValue() : 0.0;
  4398. if (llfdl != 0) {
  4399. Double calculatedValue = DoubleUtils.keepPrecision(rfdl / llfdl * 100, 2);
  4400. i.setSameperiod(calculatedValue);
  4401. } else {
  4402. i.setSameperiod(0.0);
  4403. }
  4404. i.setCompare(i.getCurrent().compareTo(i.getSameperiod()));
  4405. } else {
  4406. i.setSameperiod(0.0);
  4407. i.setCompare(0);
  4408. }
  4409. });
  4410. List<SpecificTarget> resultendList = new ArrayList<>();
  4411. Map<String, Map<Integer, SpecificTargetVo>> map = new HashMap<>();
  4412. resultList.stream().forEach(i -> {
  4413. if (map.containsKey(i.getWpid())) {
  4414. Map<Integer, SpecificTargetVo> integerListMap = map.get(i.getWpid());
  4415. if (!integerListMap.containsKey(i.getMonth())) {
  4416. map.get(i.getWpid()).put(i.getMonth(), i);
  4417. } else {
  4418. }
  4419. } else {
  4420. Map<Integer, SpecificTargetVo> tempMap = new HashMap<>();
  4421. tempMap.put(i.getMonth(), i);
  4422. map.put(i.getWpid(), tempMap);
  4423. }
  4424. });
  4425. Set<String> wpids = map.keySet();
  4426. if (StringUtils.isNotNull(wpids)) {
  4427. wpids.stream().forEach(wpid -> {
  4428. SpecificTarget vo = new SpecificTarget();
  4429. vo.setWpid(wpid);
  4430. int orderNum = 100;
  4431. // if (wpid.contains("_ZGS") || wpid.contains("_FGS" + type)) {
  4432. // vo.setWpname(CacheContext.cpmap.get(companys).getAname());
  4433. // } else if (wpid.contains("_RGN")) {
  4434. // vo.setWpname(CacheContext.rgmap.get(companys).getAname());
  4435. // } else {
  4436. vo.setWpname(CacheContext.wpmap.get(wpid).getAname());
  4437. orderNum = CacheContext.wpmap.get(wpid).getOrderNum();
  4438. // }
  4439. vo.setOrderNum(orderNum);
  4440. List<SpecificTargetVo> tempList = new ArrayList<>();
  4441. Map<Integer, SpecificTargetVo> listMap = map.get(wpid);
  4442. for (int x = 1; x <= 12; x++) {
  4443. if (listMap.containsKey(x)) {
  4444. tempList.add(listMap.get(x));
  4445. } else {
  4446. SpecificTargetVo vo1 = new SpecificTargetVo();
  4447. vo1.setWpid(wpid);
  4448. // if (wpid.contains("_ZGS") || wpid.contains("_FGS" + type)) {
  4449. // vo1.setWpname(CacheContext.cpmap.get(companys).getAname());
  4450. // } else if (wpid.contains("_RGN")) {
  4451. // vo1.setWpname(CacheContext.rgmap.get(companys).getAname());
  4452. // } else {
  4453. vo1.setWpname(CacheContext.wpmap.get(wpid).getAname());
  4454. // }
  4455. vo1.setYear(Integer.parseInt(year));
  4456. vo1.setMonth(x);
  4457. tempList.add(vo1);
  4458. }
  4459. }
  4460. vo.setTargetList(tempList);
  4461. resultendList.add(vo);
  4462. SpecificTarget vo2 = new SpecificTarget();
  4463. vo2.setWpid(vo.getWpid());
  4464. vo2.setTargetList(vo.getTargetList());
  4465. vo2.setOrderNum(vo.getOrderNum() + 1);
  4466. vo2.setWpname(CacheContext.cpmap.get(companys).getAname());
  4467. resultendList.add(vo2);
  4468. });
  4469. }
  4470. SortUtils.sort(resultendList, "orderNum", SortUtils.ASC);
  4471. return resultendList;
  4472. }
  4473. public List<SpecificTarget> fwjslList(String companys, String type, String year) {
  4474. //获取年份所有当月的数据
  4475. QueryWrapper<ProEconPowerstationInfoDay4> currentqw = new QueryWrapper<>();
  4476. currentqw.select("foreign_key_id,max(record_date) record_date,avg(yfwjsl) yfwjsl");
  4477. currentqw.eq("location", "wp");
  4478. currentqw.eq("to_char(record_date,'yyyy')", year);
  4479. if (type.equals("-1")) {
  4480. currentqw.like("foreign_key_id", "_FDC_");
  4481. } else {
  4482. currentqw.like("foreign_key_id", "_GDC_");
  4483. }
  4484. if (companys.endsWith("ZGS")) {
  4485. currentqw.eq("company_id", companys);
  4486. } else {
  4487. currentqw.eq("region_id", companys);
  4488. }
  4489. currentqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  4490. List<ProEconPowerstationInfoDay4> currentList = proEconPowerstationInfoDay4Service.list(currentqw);
  4491. currentqw.clear();
  4492. currentqw.select("foreign_key_id,max(record_date) record_date,avg(yfwjsl) yfwjsl");
  4493. currentqw.eq("foreign_key_id", companys + type);
  4494. currentqw.eq("to_char(record_date,'yyyy')", year);
  4495. currentqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  4496. currentList.addAll(proEconPowerstationInfoDay4Service.list(currentqw));
  4497. int subYear = Integer.parseInt(year) - 1;
  4498. QueryWrapper<ProEconPowerstationInfoDay4> sameperiodqw = new QueryWrapper<>();
  4499. sameperiodqw.select("foreign_key_id,max(record_date) record_date,avg(yfwjsl) yfwjsl");
  4500. sameperiodqw.eq("location", "wp");
  4501. if (type.equals("-1")) {
  4502. currentqw.like("foreign_key_id", "_FDC_");
  4503. } else {
  4504. currentqw.like("foreign_key_id", "_GDC_");
  4505. }
  4506. if (companys.endsWith("ZGS")) {
  4507. currentqw.eq("company_id", companys);
  4508. } else {
  4509. currentqw.eq("region_id", companys);
  4510. }
  4511. sameperiodqw.eq("to_char(record_date,'yyyy')", String.valueOf(subYear));
  4512. sameperiodqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  4513. List<ProEconPowerstationInfoDay4> sameperiodList = proEconPowerstationInfoDay4Service.list(sameperiodqw);
  4514. sameperiodqw.clear();
  4515. sameperiodqw.select("foreign_key_id,max(record_date) record_date,avg(yfwjsl) yfwjsl");
  4516. sameperiodqw.eq("foreign_key_id", companys + type);
  4517. sameperiodqw.eq("to_char(record_date,'yyyy')", String.valueOf(subYear));
  4518. sameperiodqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  4519. sameperiodList.addAll(proEconPowerstationInfoDay4Service.list(sameperiodqw));
  4520. //合并当月与同期数据为返回结果
  4521. List<SpecificTargetVo> resultList = new ArrayList<>();
  4522. currentList.stream().forEach(i -> {
  4523. SpecificTargetVo vo = new SpecificTargetVo();
  4524. String wpid = i.getForeignKeyId();
  4525. vo.setWpid(wpid);
  4526. if (wpid.contains("_ZGS") || wpid.contains("_FGS" + type)) {
  4527. vo.setWpname(CacheContext.cpmap.get(companys).getAname());
  4528. } else if (wpid.contains("_RGN")) {
  4529. vo.setWpname(CacheContext.rgmap.get(companys).getAname());
  4530. } else {
  4531. vo.setWpname(CacheContext.wpmap.get(wpid).getAname());
  4532. }
  4533. vo.setYear(DateUtils.getYear(i.getRecordDate()));
  4534. vo.setMonth(DateUtils.getMonth(i.getRecordDate()));
  4535. vo.setCurrent(DoubleUtils.keepPrecision(i.getYfwjsl().doubleValue(), 2));
  4536. resultList.add(vo);
  4537. });
  4538. resultList.stream().forEach(i -> {
  4539. Optional<ProEconPowerstationInfoDay4> optional = sameperiodList.stream()
  4540. .filter(j -> j.getForeignKeyId().equals(i.getWpid()) && String.valueOf(DateUtils.getMonth(j.getRecordDate())).equals(i.getMonth()))
  4541. .findFirst();
  4542. if (optional.isPresent()) {
  4543. ProEconPowerstationInfoDay4 tqinfoday = optional.get();
  4544. i.setSameperiod(DoubleUtils.keepPrecision(tqinfoday.getYfwjsl().doubleValue(), 2));
  4545. i.setCompare(i.getCurrent().compareTo(i.getSameperiod()));
  4546. } else {
  4547. i.setSameperiod(0.0);
  4548. i.setCompare(0);
  4549. }
  4550. });
  4551. List<SpecificTarget> resultendList = new ArrayList<>();
  4552. Map<String, Map<Integer, SpecificTargetVo>> map = new HashMap<>();
  4553. resultList.stream().forEach(i -> {
  4554. if (map.containsKey(i.getWpid())) {
  4555. Map<Integer, SpecificTargetVo> integerListMap = map.get(i.getWpid());
  4556. if (!integerListMap.containsKey(i.getMonth())) {
  4557. map.get(i.getWpid()).put(i.getMonth(), i);
  4558. } else {
  4559. }
  4560. } else {
  4561. Map<Integer, SpecificTargetVo> tempMap = new HashMap<>();
  4562. tempMap.put(i.getMonth(), i);
  4563. map.put(i.getWpid(), tempMap);
  4564. }
  4565. });
  4566. Set<String> wpids = map.keySet();
  4567. if (StringUtils.isNotNull(wpids)) {
  4568. wpids.stream().forEach(wpid -> {
  4569. SpecificTarget vo = new SpecificTarget();
  4570. vo.setWpid(wpid);
  4571. int orderNum = 100;
  4572. if (wpid.contains("_ZGS") || wpid.contains("_FGS" + type)) {
  4573. vo.setWpname(CacheContext.cpmap.get(companys).getAname());
  4574. } else if (wpid.contains("_RGN")) {
  4575. vo.setWpname(CacheContext.rgmap.get(companys).getAname());
  4576. } else {
  4577. vo.setWpname(CacheContext.wpmap.get(wpid).getAname());
  4578. orderNum = CacheContext.wpmap.get(wpid).getOrderNum();
  4579. }
  4580. vo.setOrderNum(orderNum);
  4581. List<SpecificTargetVo> tempList = new ArrayList<>();
  4582. Map<Integer, SpecificTargetVo> listMap = map.get(wpid);
  4583. for (int x = 1; x <= 12; x++) {
  4584. if (listMap.containsKey(x)) {
  4585. tempList.add(listMap.get(x));
  4586. } else {
  4587. SpecificTargetVo vo1 = new SpecificTargetVo();
  4588. vo1.setWpid(wpid);
  4589. if (wpid.contains("_ZGS") || wpid.contains("_FGS" + type)) {
  4590. vo1.setWpname(CacheContext.cpmap.get(companys).getAname());
  4591. } else if (wpid.contains("_RGN")) {
  4592. vo1.setWpname(CacheContext.rgmap.get(companys).getAname());
  4593. } else {
  4594. vo1.setWpname(CacheContext.wpmap.get(wpid).getAname());
  4595. }
  4596. vo1.setYear(Integer.parseInt(year));
  4597. vo1.setMonth(x);
  4598. tempList.add(vo1);
  4599. }
  4600. }
  4601. vo.setTargetList(tempList);
  4602. resultendList.add(vo);
  4603. });
  4604. }
  4605. SortUtils.sort(resultendList, "orderNum", SortUtils.ASC);
  4606. return resultendList;
  4607. }
  4608. public List<SpecificTarget> ztzhlList(String companys, String type, String year) {
  4609. //获取年份所有当月的数据
  4610. QueryWrapper<ProEconPowerstationInfoDay4> currentqw = new QueryWrapper<>();
  4611. currentqw.select("foreign_key_id,max(record_date) record_date,avg(yztzhjsl) yztzhjsl");
  4612. currentqw.eq("location", "wp");
  4613. currentqw.eq("to_char(record_date,'yyyy')", year);
  4614. if (type.equals("-1")) {
  4615. currentqw.like("foreign_key_id", "_FDC_");
  4616. } else {
  4617. currentqw.like("foreign_key_id", "_GDC_");
  4618. }
  4619. if (companys.endsWith("ZGS")) {
  4620. currentqw.eq("company_id", companys);
  4621. } else {
  4622. currentqw.eq("region_id", companys);
  4623. }
  4624. currentqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  4625. List<ProEconPowerstationInfoDay4> currentList = proEconPowerstationInfoDay4Service.list(currentqw);
  4626. currentqw.clear();
  4627. currentqw.select("foreign_key_id,max(record_date) record_date,avg(yztzhjsl) yztzhjsl");
  4628. currentqw.eq("foreign_key_id", companys + type);
  4629. currentqw.eq("to_char(record_date,'yyyy')", year);
  4630. currentqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  4631. currentList.addAll(proEconPowerstationInfoDay4Service.list(currentqw));
  4632. int subYear = Integer.parseInt(year) - 1;
  4633. QueryWrapper<ProEconPowerstationInfoDay4> sameperiodqw = new QueryWrapper<>();
  4634. sameperiodqw.select("foreign_key_id,max(record_date) record_date,avg(yztzhjsl) yztzhjsl");
  4635. sameperiodqw.eq("location", "wp");
  4636. if (type.equals("-1")) {
  4637. currentqw.like("foreign_key_id", "_FDC_");
  4638. } else {
  4639. currentqw.like("foreign_key_id", "_GDC_");
  4640. }
  4641. if (companys.endsWith("ZGS")) {
  4642. currentqw.eq("company_id", companys);
  4643. } else {
  4644. currentqw.eq("region_id", companys);
  4645. }
  4646. sameperiodqw.eq("to_char(record_date,'yyyy')", String.valueOf(subYear));
  4647. sameperiodqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  4648. List<ProEconPowerstationInfoDay4> sameperiodList = proEconPowerstationInfoDay4Service.list(sameperiodqw);
  4649. sameperiodqw.clear();
  4650. sameperiodqw.select("foreign_key_id,max(record_date) record_date,avg(yztzhjsl) yztzhjsl");
  4651. sameperiodqw.eq("foreign_key_id", companys + type);
  4652. sameperiodqw.eq("to_char(record_date,'yyyy')", String.valueOf(subYear));
  4653. sameperiodqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  4654. sameperiodList.addAll(proEconPowerstationInfoDay4Service.list(sameperiodqw));
  4655. //合并当月与同期数据为返回结果
  4656. List<SpecificTargetVo> resultList = new ArrayList<>();
  4657. currentList.stream().forEach(i -> {
  4658. SpecificTargetVo vo = new SpecificTargetVo();
  4659. String wpid = i.getForeignKeyId();
  4660. vo.setWpid(wpid);
  4661. if (wpid.contains("_ZGS")) {
  4662. vo.setWpname(CacheContext.cpmap.get(companys).getAname());
  4663. } else if (wpid.contains("_RGN")) {
  4664. vo.setWpname(CacheContext.rgmap.get(companys).getAname());
  4665. } else {
  4666. vo.setWpname(CacheContext.wpmap.get(wpid).getAname());
  4667. }
  4668. vo.setYear(DateUtils.getYear(i.getRecordDate()));
  4669. vo.setMonth(DateUtils.getMonth(i.getRecordDate()));
  4670. vo.setCurrent(DoubleUtils.keepPrecision(i.getYztzhjsl().doubleValue(), 2));
  4671. resultList.add(vo);
  4672. });
  4673. resultList.stream().forEach(i -> {
  4674. Optional<ProEconPowerstationInfoDay4> optional = sameperiodList.stream()
  4675. .filter(j -> j.getForeignKeyId().equals(i.getWpid()) && String.valueOf(DateUtils.getMonth(j.getRecordDate())).equals(i.getMonth()))
  4676. .findFirst();
  4677. if (optional.isPresent()) {
  4678. ProEconPowerstationInfoDay4 tqinfoday = optional.get();
  4679. i.setSameperiod(DoubleUtils.keepPrecision(tqinfoday.getYztzhjsl().doubleValue(), 2));
  4680. i.setCompare(i.getCurrent().compareTo(i.getSameperiod()));
  4681. } else {
  4682. i.setSameperiod(0.0);
  4683. i.setCompare(0);
  4684. }
  4685. });
  4686. List<SpecificTarget> resultendList = new ArrayList<>();
  4687. Map<String, Map<Integer, SpecificTargetVo>> map = new HashMap<>();
  4688. resultList.stream().forEach(i -> {
  4689. if (map.containsKey(i.getWpid())) {
  4690. Map<Integer, SpecificTargetVo> integerListMap = map.get(i.getWpid());
  4691. if (!integerListMap.containsKey(i.getMonth())) {
  4692. map.get(i.getWpid()).put(i.getMonth(), i);
  4693. } else {
  4694. }
  4695. } else {
  4696. Map<Integer, SpecificTargetVo> tempMap = new HashMap<>();
  4697. tempMap.put(i.getMonth(), i);
  4698. map.put(i.getWpid(), tempMap);
  4699. }
  4700. });
  4701. Set<String> wpids = map.keySet();
  4702. if (StringUtils.isNotNull(wpids)) {
  4703. wpids.stream().forEach(wpid -> {
  4704. SpecificTarget vo = new SpecificTarget();
  4705. vo.setWpid(wpid);
  4706. int orderNum = 100;
  4707. if (wpid.contains("_ZGS")) {
  4708. vo.setWpname(CacheContext.cpmap.get(companys).getAname());
  4709. } else if (wpid.contains("_RGN")) {
  4710. vo.setWpname(CacheContext.rgmap.get(companys).getAname());
  4711. } else {
  4712. vo.setWpname(CacheContext.wpmap.get(wpid).getAname());
  4713. orderNum = CacheContext.wpmap.get(wpid).getOrderNum();
  4714. }
  4715. vo.setOrderNum(orderNum);
  4716. List<SpecificTargetVo> tempList = new ArrayList<>();
  4717. Map<Integer, SpecificTargetVo> listMap = map.get(wpid);
  4718. for (int x = 1; x <= 12; x++) {
  4719. if (listMap.containsKey(x)) {
  4720. tempList.add(listMap.get(x));
  4721. } else {
  4722. SpecificTargetVo vo1 = new SpecificTargetVo();
  4723. vo1.setWpid(wpid);
  4724. if (wpid.contains("_ZGS")) {
  4725. vo1.setWpname(CacheContext.cpmap.get(companys).getAname());
  4726. } else if (wpid.contains("_RGN")) {
  4727. vo1.setWpname(CacheContext.rgmap.get(companys).getAname());
  4728. } else {
  4729. vo1.setWpname(CacheContext.wpmap.get(wpid).getAname());
  4730. }
  4731. vo1.setYear(Integer.parseInt(year));
  4732. vo1.setMonth(x);
  4733. tempList.add(vo1);
  4734. }
  4735. }
  4736. vo.setTargetList(tempList);
  4737. resultendList.add(vo);
  4738. });
  4739. }
  4740. SortUtils.sort(resultendList, "orderNum", SortUtils.ASC);
  4741. return resultendList;
  4742. }
  4743. public List<SpecificTarget> xqjslList(String companys, String type, String year) {
  4744. //获取年份所有当月的数据
  4745. QueryWrapper<ProEconPowerstationInfoDay4> currentqw = new QueryWrapper<>();
  4746. currentqw.select("foreign_key_id,max(record_date) record_date,avg(ygzxqjsl) ygzxqjsl");
  4747. currentqw.eq("location", "wp");
  4748. currentqw.eq("to_char(record_date,'yyyy')", year);
  4749. if (type.equals("-1")) {
  4750. currentqw.like("foreign_key_id", "_FDC_");
  4751. } else {
  4752. currentqw.like("foreign_key_id", "_GDC_");
  4753. }
  4754. if (companys.endsWith("ZGS")) {
  4755. currentqw.eq("company_id", companys);
  4756. } else {
  4757. currentqw.eq("region_id", companys);
  4758. }
  4759. currentqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  4760. List<ProEconPowerstationInfoDay4> currentList = proEconPowerstationInfoDay4Service.list(currentqw);
  4761. currentqw.clear();
  4762. currentqw.select("foreign_key_id,max(record_date) record_date,avg(ygzxqjsl) ygzxqjsl");
  4763. currentqw.eq("foreign_key_id", companys + type);
  4764. currentqw.eq("to_char(record_date,'yyyy')", year);
  4765. currentqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  4766. currentList.addAll(proEconPowerstationInfoDay4Service.list(currentqw));
  4767. int subYear = Integer.parseInt(year) - 1;
  4768. QueryWrapper<ProEconPowerstationInfoDay4> sameperiodqw = new QueryWrapper<>();
  4769. sameperiodqw.select("foreign_key_id,max(record_date) record_date,avg(ygzxqjsl) ygzxqjsl");
  4770. sameperiodqw.eq("location", "wp");
  4771. if (type.equals("-1")) {
  4772. currentqw.like("foreign_key_id", "_FDC_");
  4773. } else {
  4774. currentqw.like("foreign_key_id", "_GDC_");
  4775. }
  4776. if (companys.endsWith("ZGS")) {
  4777. currentqw.eq("company_id", companys);
  4778. } else {
  4779. currentqw.eq("region_id", companys);
  4780. }
  4781. sameperiodqw.eq("to_char(record_date,'yyyy')", String.valueOf(subYear));
  4782. sameperiodqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  4783. List<ProEconPowerstationInfoDay4> sameperiodList = proEconPowerstationInfoDay4Service.list(sameperiodqw);
  4784. sameperiodqw.clear();
  4785. sameperiodqw.select("foreign_key_id,max(record_date) record_date,avg(ygzxqjsl) ygzxqjsl");
  4786. sameperiodqw.eq("foreign_key_id", companys + type);
  4787. sameperiodqw.eq("to_char(record_date,'yyyy')", String.valueOf(subYear));
  4788. sameperiodqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  4789. sameperiodList.addAll(proEconPowerstationInfoDay4Service.list(sameperiodqw));
  4790. //合并当月与同期数据为返回结果
  4791. List<SpecificTargetVo> resultList = new ArrayList<>();
  4792. currentList.stream().forEach(i -> {
  4793. SpecificTargetVo vo = new SpecificTargetVo();
  4794. String wpid = i.getForeignKeyId();
  4795. vo.setWpid(wpid);
  4796. if (wpid.contains("_ZGS")) {
  4797. vo.setWpname(CacheContext.cpmap.get(companys).getAname());
  4798. } else if (wpid.contains("_RGN")) {
  4799. vo.setWpname(CacheContext.rgmap.get(companys).getAname());
  4800. } else {
  4801. vo.setWpname(CacheContext.wpmap.get(wpid).getAname());
  4802. }
  4803. vo.setYear(DateUtils.getYear(i.getRecordDate()));
  4804. vo.setMonth(DateUtils.getMonth(i.getRecordDate()));
  4805. vo.setCurrent(DoubleUtils.keepPrecision(i.getYgzxqjsl().doubleValue(), 2));
  4806. resultList.add(vo);
  4807. });
  4808. resultList.stream().forEach(i -> {
  4809. Optional<ProEconPowerstationInfoDay4> optional = sameperiodList.stream()
  4810. .filter(j -> j.getForeignKeyId().equals(i.getWpid()) && String.valueOf(DateUtils.getMonth(j.getRecordDate())).equals(i.getMonth()))
  4811. .findFirst();
  4812. if (optional.isPresent()) {
  4813. ProEconPowerstationInfoDay4 tqinfoday = optional.get();
  4814. i.setSameperiod(DoubleUtils.keepPrecision(tqinfoday.getYgzxqjsl().doubleValue(), 2));
  4815. i.setCompare(i.getCurrent().compareTo(i.getSameperiod()));
  4816. } else {
  4817. i.setSameperiod(0.0);
  4818. i.setCompare(0);
  4819. }
  4820. });
  4821. List<SpecificTarget> resultendList = new ArrayList<>();
  4822. Map<String, Map<Integer, SpecificTargetVo>> map = new HashMap<>();
  4823. resultList.stream().forEach(i -> {
  4824. if (map.containsKey(i.getWpid())) {
  4825. Map<Integer, SpecificTargetVo> integerListMap = map.get(i.getWpid());
  4826. if (!integerListMap.containsKey(i.getMonth())) {
  4827. map.get(i.getWpid()).put(i.getMonth(), i);
  4828. } else {
  4829. }
  4830. } else {
  4831. Map<Integer, SpecificTargetVo> tempMap = new HashMap<>();
  4832. tempMap.put(i.getMonth(), i);
  4833. map.put(i.getWpid(), tempMap);
  4834. }
  4835. });
  4836. Set<String> wpids = map.keySet();
  4837. if (StringUtils.isNotNull(wpids)) {
  4838. wpids.stream().forEach(wpid -> {
  4839. SpecificTarget vo = new SpecificTarget();
  4840. vo.setWpid(wpid);
  4841. int orderNum = 100;
  4842. if (wpid.contains("_ZGS")) {
  4843. vo.setWpname(CacheContext.cpmap.get(companys).getAname());
  4844. } else if (wpid.contains("_RGN")) {
  4845. vo.setWpname(CacheContext.rgmap.get(companys).getAname());
  4846. } else {
  4847. vo.setWpname(CacheContext.wpmap.get(wpid).getAname());
  4848. orderNum = CacheContext.wpmap.get(wpid).getOrderNum();
  4849. }
  4850. vo.setOrderNum(orderNum);
  4851. List<SpecificTargetVo> tempList = new ArrayList<>();
  4852. Map<Integer, SpecificTargetVo> listMap = map.get(wpid);
  4853. for (int x = 1; x <= 12; x++) {
  4854. if (listMap.containsKey(x)) {
  4855. tempList.add(listMap.get(x));
  4856. } else {
  4857. SpecificTargetVo vo1 = new SpecificTargetVo();
  4858. vo1.setWpid(wpid);
  4859. if (wpid.contains("_ZGS")) {
  4860. vo1.setWpname(CacheContext.cpmap.get(companys).getAname());
  4861. } else if (wpid.contains("_RGN")) {
  4862. vo1.setWpname(CacheContext.rgmap.get(companys).getAname());
  4863. } else {
  4864. vo1.setWpname(CacheContext.wpmap.get(wpid).getAname());
  4865. }
  4866. vo1.setYear(Integer.parseInt(year));
  4867. vo1.setMonth(x);
  4868. tempList.add(vo1);
  4869. }
  4870. }
  4871. vo.setTargetList(tempList);
  4872. resultendList.add(vo);
  4873. });
  4874. }
  4875. SortUtils.sort(resultendList, "orderNum", SortUtils.ASC);
  4876. return resultendList;
  4877. }
  4878. public List<SpecificTarget> mtbfList(String companys, String type, String year) {
  4879. //获取年份所有当月的数据
  4880. QueryWrapper<ProEconPowerstationInfoDay4> currentqw = new QueryWrapper<>();
  4881. currentqw.select("foreign_key_id,max(record_date) record_date,sum(rmtbf) ymtbf");
  4882. currentqw.eq("location", "wp");
  4883. currentqw.eq("to_char(record_date,'yyyy')", year);
  4884. if (type.equals("-1")) {
  4885. currentqw.like("foreign_key_id", "_FDC_");
  4886. } else {
  4887. currentqw.like("foreign_key_id", "_GDC_");
  4888. }
  4889. if (companys.endsWith("ZGS")) {
  4890. currentqw.eq("company_id", companys);
  4891. } else {
  4892. currentqw.eq("region_id", companys);
  4893. }
  4894. currentqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  4895. List<ProEconPowerstationInfoDay4> currentList = proEconPowerstationInfoDay4Service.list(currentqw);
  4896. currentqw.clear();
  4897. currentqw.select("foreign_key_id,max(record_date) record_date,sum(rmtbf) ymtbf");
  4898. currentqw.eq("foreign_key_id", companys + type);
  4899. currentqw.eq("to_char(record_date,'yyyy')", year);
  4900. currentqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  4901. currentList.addAll(proEconPowerstationInfoDay4Service.list(currentqw));
  4902. int subYear = Integer.parseInt(year) - 1;
  4903. QueryWrapper<ProEconPowerstationInfoDay4> sameperiodqw = new QueryWrapper<>();
  4904. sameperiodqw.select("foreign_key_id,max(record_date) record_date,sum(rmtbf) ymtbf");
  4905. sameperiodqw.eq("location", "wp");
  4906. if (type.equals("-1")) {
  4907. currentqw.like("foreign_key_id", "_FDC_");
  4908. } else {
  4909. currentqw.like("foreign_key_id", "_GDC_");
  4910. }
  4911. if (companys.endsWith("ZGS")) {
  4912. currentqw.eq("company_id", companys);
  4913. } else {
  4914. currentqw.eq("region_id", companys);
  4915. }
  4916. sameperiodqw.eq("to_char(record_date,'yyyy')", String.valueOf(subYear));
  4917. sameperiodqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  4918. List<ProEconPowerstationInfoDay4> sameperiodList = proEconPowerstationInfoDay4Service.list(sameperiodqw);
  4919. sameperiodqw.clear();
  4920. sameperiodqw.select("foreign_key_id,max(record_date) record_date,sum(rmtbf) ymtbf");
  4921. sameperiodqw.eq("foreign_key_id", companys + type);
  4922. sameperiodqw.eq("to_char(record_date,'yyyy')", String.valueOf(subYear));
  4923. sameperiodqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  4924. sameperiodList.addAll(proEconPowerstationInfoDay4Service.list(sameperiodqw));
  4925. //合并当月与同期数据为返回结果
  4926. List<SpecificTargetVo> resultList = new ArrayList<>();
  4927. currentList.stream().forEach(i -> {
  4928. SpecificTargetVo vo = new SpecificTargetVo();
  4929. String wpid = i.getForeignKeyId();
  4930. vo.setWpid(wpid);
  4931. if (wpid.contains("_ZGS") || wpid.contains("_FGS" + type)) {
  4932. vo.setWpname(CacheContext.cpmap.get(companys).getAname());
  4933. } else if (wpid.contains("_RGN")) {
  4934. vo.setWpname(CacheContext.rgmap.get(companys).getAname());
  4935. } else {
  4936. vo.setWpname(CacheContext.wpmap.get(wpid).getAname());
  4937. }
  4938. vo.setYear(DateUtils.getYear(i.getRecordDate()));
  4939. vo.setMonth(DateUtils.getMonth(i.getRecordDate()));
  4940. vo.setCurrent(DoubleUtils.keepPrecision(i.getYmtbf().doubleValue(), 2));
  4941. resultList.add(vo);
  4942. });
  4943. resultList.stream().forEach(i -> {
  4944. Optional<ProEconPowerstationInfoDay4> optional = sameperiodList.stream()
  4945. .filter(j -> j.getForeignKeyId().equals(i.getWpid()) && String.valueOf(DateUtils.getMonth(j.getRecordDate())).equals(i.getMonth()))
  4946. .findFirst();
  4947. if (optional.isPresent()) {
  4948. ProEconPowerstationInfoDay4 tqinfoday = optional.get();
  4949. i.setSameperiod(DoubleUtils.keepPrecision(tqinfoday.getYmtbf().doubleValue(), 2));
  4950. i.setCompare(i.getCurrent().compareTo(i.getSameperiod()));
  4951. } else {
  4952. i.setSameperiod(0.0);
  4953. i.setCompare(0);
  4954. }
  4955. });
  4956. List<SpecificTarget> resultendList = new ArrayList<>();
  4957. Map<String, Map<Integer, SpecificTargetVo>> map = new HashMap<>();
  4958. resultList.stream().forEach(i -> {
  4959. if (map.containsKey(i.getWpid())) {
  4960. Map<Integer, SpecificTargetVo> integerListMap = map.get(i.getWpid());
  4961. if (!integerListMap.containsKey(i.getMonth())) {
  4962. map.get(i.getWpid()).put(i.getMonth(), i);
  4963. } else {
  4964. }
  4965. } else {
  4966. Map<Integer, SpecificTargetVo> tempMap = new HashMap<>();
  4967. tempMap.put(i.getMonth(), i);
  4968. map.put(i.getWpid(), tempMap);
  4969. }
  4970. });
  4971. Set<String> wpids = map.keySet();
  4972. if (StringUtils.isNotNull(wpids)) {
  4973. wpids.stream().forEach(wpid -> {
  4974. SpecificTarget vo = new SpecificTarget();
  4975. vo.setWpid(wpid);
  4976. int orderNum = 100;
  4977. if (wpid.contains("_ZGS") || wpid.contains("_FGS" + type)) {
  4978. vo.setWpname(CacheContext.cpmap.get(companys).getAname());
  4979. } else if (wpid.contains("_RGN")) {
  4980. vo.setWpname(CacheContext.rgmap.get(companys).getAname());
  4981. } else {
  4982. vo.setWpname(CacheContext.wpmap.get(wpid).getAname());
  4983. orderNum = CacheContext.wpmap.get(wpid).getOrderNum();
  4984. }
  4985. vo.setOrderNum(orderNum);
  4986. List<SpecificTargetVo> tempList = new ArrayList<>();
  4987. Map<Integer, SpecificTargetVo> listMap = map.get(wpid);
  4988. for (int x = 1; x <= 12; x++) {
  4989. if (listMap.containsKey(x)) {
  4990. tempList.add(listMap.get(x));
  4991. } else {
  4992. SpecificTargetVo vo1 = new SpecificTargetVo();
  4993. vo1.setWpid(wpid);
  4994. if (wpid.contains("_ZGS") || wpid.contains("_FGS" + type)) {
  4995. vo1.setWpname(CacheContext.cpmap.get(companys).getAname());
  4996. } else if (wpid.contains("_RGN")) {
  4997. vo1.setWpname(CacheContext.rgmap.get(companys).getAname());
  4998. } else {
  4999. vo1.setWpname(CacheContext.wpmap.get(wpid).getAname());
  5000. }
  5001. vo1.setYear(Integer.parseInt(year));
  5002. vo1.setMonth(x);
  5003. tempList.add(vo1);
  5004. }
  5005. }
  5006. vo.setTargetList(tempList);
  5007. resultendList.add(vo);
  5008. });
  5009. }
  5010. SortUtils.sort(resultendList, "orderNum", SortUtils.ASC);
  5011. return resultendList;
  5012. }
  5013. public List<SpecificTarget> mttrList(String companys, String type, String year) {
  5014. //获取年份所有当月的数据
  5015. QueryWrapper<ProEconPowerstationInfoDay4> currentqw = new QueryWrapper<>();
  5016. currentqw.select("foreign_key_id,max(record_date) record_date,sum(rmttr) ymttr");
  5017. currentqw.eq("location", "wp");
  5018. currentqw.eq("to_char(record_date,'yyyy')", year);
  5019. if (type.equals("-1")) {
  5020. currentqw.like("foreign_key_id", "_FDC_");
  5021. } else {
  5022. currentqw.like("foreign_key_id", "_GDC_");
  5023. }
  5024. if (companys.endsWith("ZGS")) {
  5025. currentqw.eq("company_id", companys);
  5026. } else {
  5027. currentqw.eq("region_id", companys);
  5028. }
  5029. currentqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  5030. List<ProEconPowerstationInfoDay4> currentList = proEconPowerstationInfoDay4Service.list(currentqw);
  5031. currentqw.clear();
  5032. currentqw.select("foreign_key_id,max(record_date) record_date,sum(rmttr) ymttr");
  5033. currentqw.eq("foreign_key_id", companys + type);
  5034. currentqw.eq("to_char(record_date,'yyyy')", year);
  5035. currentqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  5036. currentList.addAll(proEconPowerstationInfoDay4Service.list(currentqw));
  5037. int subYear = Integer.parseInt(year) - 1;
  5038. QueryWrapper<ProEconPowerstationInfoDay4> sameperiodqw = new QueryWrapper<>();
  5039. sameperiodqw.select("foreign_key_id,max(record_date) record_date,sum(rmttr) ymttr");
  5040. sameperiodqw.eq("location", "wp");
  5041. if (type.equals("-1")) {
  5042. currentqw.like("foreign_key_id", "_FDC_");
  5043. } else {
  5044. currentqw.like("foreign_key_id", "_GDC_");
  5045. }
  5046. if (companys.endsWith("ZGS")) {
  5047. currentqw.eq("company_id", companys);
  5048. } else {
  5049. currentqw.eq("region_id", companys);
  5050. }
  5051. sameperiodqw.eq("to_char(record_date,'yyyy')", String.valueOf(subYear));
  5052. sameperiodqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  5053. List<ProEconPowerstationInfoDay4> sameperiodList = proEconPowerstationInfoDay4Service.list(sameperiodqw);
  5054. sameperiodqw.clear();
  5055. sameperiodqw.select("foreign_key_id,max(record_date) record_date,sum(rmttr) ymttr");
  5056. sameperiodqw.eq("foreign_key_id", companys + type);
  5057. sameperiodqw.eq("to_char(record_date,'yyyy')", String.valueOf(subYear));
  5058. sameperiodqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  5059. sameperiodList.addAll(proEconPowerstationInfoDay4Service.list(sameperiodqw));
  5060. //合并当月与同期数据为返回结果
  5061. List<SpecificTargetVo> resultList = new ArrayList<>();
  5062. currentList.stream().forEach(i -> {
  5063. SpecificTargetVo vo = new SpecificTargetVo();
  5064. String wpid = i.getForeignKeyId();
  5065. vo.setWpid(wpid);
  5066. if (wpid.contains("_ZGS") || wpid.contains("_FGS" + type)) {
  5067. vo.setWpname(CacheContext.cpmap.get(companys).getAname());
  5068. } else if (wpid.contains("_RGN")) {
  5069. vo.setWpname(CacheContext.rgmap.get(companys).getAname());
  5070. } else {
  5071. vo.setWpname(CacheContext.wpmap.get(wpid).getAname());
  5072. }
  5073. vo.setYear(DateUtils.getYear(i.getRecordDate()));
  5074. vo.setMonth(DateUtils.getMonth(i.getRecordDate()));
  5075. vo.setCurrent(DoubleUtils.keepPrecision(i.getYmttr().doubleValue(), 2));
  5076. resultList.add(vo);
  5077. });
  5078. resultList.stream().forEach(i -> {
  5079. Optional<ProEconPowerstationInfoDay4> optional = sameperiodList.stream()
  5080. .filter(j -> j.getForeignKeyId().equals(i.getWpid()) && String.valueOf(DateUtils.getMonth(j.getRecordDate())).equals(i.getMonth()))
  5081. .findFirst();
  5082. if (optional.isPresent()) {
  5083. ProEconPowerstationInfoDay4 tqinfoday = optional.get();
  5084. i.setSameperiod(DoubleUtils.keepPrecision(tqinfoday.getYmttr().doubleValue(), 2));
  5085. i.setCompare(i.getCurrent().compareTo(i.getSameperiod()));
  5086. } else {
  5087. i.setSameperiod(0.0);
  5088. i.setCompare(0);
  5089. }
  5090. });
  5091. List<SpecificTarget> resultendList = new ArrayList<>();
  5092. Map<String, Map<Integer, SpecificTargetVo>> map = new HashMap<>();
  5093. resultList.stream().forEach(i -> {
  5094. if (map.containsKey(i.getWpid())) {
  5095. Map<Integer, SpecificTargetVo> integerListMap = map.get(i.getWpid());
  5096. if (!integerListMap.containsKey(i.getMonth())) {
  5097. map.get(i.getWpid()).put(i.getMonth(), i);
  5098. } else {
  5099. }
  5100. } else {
  5101. Map<Integer, SpecificTargetVo> tempMap = new HashMap<>();
  5102. tempMap.put(i.getMonth(), i);
  5103. map.put(i.getWpid(), tempMap);
  5104. }
  5105. });
  5106. Set<String> wpids = map.keySet();
  5107. if (StringUtils.isNotNull(wpids)) {
  5108. wpids.stream().forEach(wpid -> {
  5109. SpecificTarget vo = new SpecificTarget();
  5110. vo.setWpid(wpid);
  5111. int orderNum = 100;
  5112. if (wpid.contains("_ZGS") || wpid.contains("_FGS" + type)) {
  5113. vo.setWpname(CacheContext.cpmap.get(companys).getAname());
  5114. } else if (wpid.contains("_RGN")) {
  5115. vo.setWpname(CacheContext.rgmap.get(companys).getAname());
  5116. } else {
  5117. vo.setWpname(CacheContext.wpmap.get(wpid).getAname());
  5118. orderNum = CacheContext.wpmap.get(wpid).getOrderNum();
  5119. }
  5120. vo.setOrderNum(orderNum);
  5121. List<SpecificTargetVo> tempList = new ArrayList<>();
  5122. Map<Integer, SpecificTargetVo> listMap = map.get(wpid);
  5123. for (int x = 1; x <= 12; x++) {
  5124. if (listMap.containsKey(x)) {
  5125. tempList.add(listMap.get(x));
  5126. } else {
  5127. SpecificTargetVo vo1 = new SpecificTargetVo();
  5128. vo1.setWpid(wpid);
  5129. if (wpid.contains("_ZGS") || wpid.contains("_FGS" + type)) {
  5130. vo1.setWpname(CacheContext.cpmap.get(companys).getAname());
  5131. } else if (wpid.contains("_RGN")) {
  5132. vo1.setWpname(CacheContext.rgmap.get(companys).getAname());
  5133. } else {
  5134. vo1.setWpname(CacheContext.wpmap.get(wpid).getAname());
  5135. }
  5136. vo1.setYear(Integer.parseInt(year));
  5137. vo1.setMonth(x);
  5138. tempList.add(vo1);
  5139. }
  5140. }
  5141. vo.setTargetList(tempList);
  5142. resultendList.add(vo);
  5143. });
  5144. }
  5145. SortUtils.sort(resultendList, "orderNum", SortUtils.ASC);
  5146. return resultendList;
  5147. }
  5148. public List<SpecificTarget> xtxlList(String companys, String type, String year) {
  5149. //获取年份所有当月的数据
  5150. QueryWrapper<ProEconPowerstationInfoDay7> currentqw = new QueryWrapper<>();
  5151. currentqw.select("foreign_key_id,max(record_date) record_date,avg(yxtxlpr) yxtxlpr");
  5152. currentqw.eq("location", "wp");
  5153. currentqw.eq("to_char(record_date,'yyyy')", year);
  5154. if (type.equals("-1")) {
  5155. currentqw.like("foreign_key_id", "_FDC_");
  5156. } else {
  5157. currentqw.like("foreign_key_id", "_GDC_");
  5158. }
  5159. if (companys.endsWith("ZGS")) {
  5160. currentqw.eq("company_id", companys);
  5161. } else {
  5162. currentqw.eq("region_id", companys);
  5163. }
  5164. currentqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  5165. List<ProEconPowerstationInfoDay7> currentList = proEconPowerstationInfoDay7Service.list(currentqw);
  5166. currentqw.clear();
  5167. currentqw.select("foreign_key_id,max(record_date) record_date,avg(yxtxlpr) yxtxlpr");
  5168. currentqw.eq("foreign_key_id", companys + type);
  5169. currentqw.eq("to_char(record_date,'yyyy')", year);
  5170. currentqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  5171. currentList.addAll(proEconPowerstationInfoDay7Service.list(currentqw));
  5172. int subYear = Integer.parseInt(year) - 1;
  5173. QueryWrapper<ProEconPowerstationInfoDay7> sameperiodqw = new QueryWrapper<>();
  5174. sameperiodqw.select("foreign_key_id,max(record_date) record_date,avg(yxtxlpr) yxtxlpr");
  5175. sameperiodqw.eq("location", "wp");
  5176. if (type.equals("-1")) {
  5177. currentqw.like("foreign_key_id", "_FDC_");
  5178. } else {
  5179. currentqw.like("foreign_key_id", "_GDC_");
  5180. }
  5181. if (companys.endsWith("ZGS")) {
  5182. currentqw.eq("company_id", companys);
  5183. } else {
  5184. currentqw.eq("region_id", companys);
  5185. }
  5186. sameperiodqw.eq("to_char(record_date,'yyyy')", String.valueOf(subYear));
  5187. sameperiodqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  5188. List<ProEconPowerstationInfoDay7> sameperiodList = proEconPowerstationInfoDay7Service.list(sameperiodqw);
  5189. sameperiodqw.clear();
  5190. sameperiodqw.select("foreign_key_id,max(record_date) record_date,avg(yxtxlpr) yxtxlpr");
  5191. sameperiodqw.eq("foreign_key_id", companys + type);
  5192. sameperiodqw.eq("to_char(record_date,'yyyy')", String.valueOf(subYear));
  5193. sameperiodqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  5194. sameperiodList.addAll(proEconPowerstationInfoDay7Service.list(sameperiodqw));
  5195. //合并当月与同期数据为返回结果
  5196. List<SpecificTargetVo> resultList = new ArrayList<>();
  5197. currentList.stream().forEach(i -> {
  5198. SpecificTargetVo vo = new SpecificTargetVo();
  5199. String wpid = i.getForeignKeyId();
  5200. vo.setWpid(wpid);
  5201. if (wpid.contains("_ZGS")) {
  5202. vo.setWpname(CacheContext.cpmap.get(companys).getAname());
  5203. } else if (wpid.contains("_RGN")) {
  5204. vo.setWpname(CacheContext.rgmap.get(companys).getAname());
  5205. } else {
  5206. vo.setWpname(CacheContext.wpmap.get(wpid).getAname());
  5207. }
  5208. vo.setYear(DateUtils.getYear(i.getRecordDate()));
  5209. vo.setMonth(DateUtils.getMonth(i.getRecordDate()));
  5210. vo.setCurrent(DoubleUtils.keepPrecision(i.getYxtxlpr().doubleValue(), 2));
  5211. resultList.add(vo);
  5212. });
  5213. resultList.stream().forEach(i -> {
  5214. Optional<ProEconPowerstationInfoDay7> optional = sameperiodList.stream()
  5215. .filter(j -> j.getForeignKeyId().equals(i.getWpid()) && String.valueOf(DateUtils.getMonth(j.getRecordDate())).equals(i.getMonth()))
  5216. .findFirst();
  5217. if (optional.isPresent()) {
  5218. ProEconPowerstationInfoDay7 tqinfoday = optional.get();
  5219. i.setSameperiod(DoubleUtils.keepPrecision(tqinfoday.getYxtxlpr().doubleValue(), 2));
  5220. i.setCompare(i.getCurrent().compareTo(i.getSameperiod()));
  5221. } else {
  5222. i.setSameperiod(0.0);
  5223. i.setCompare(0);
  5224. }
  5225. });
  5226. List<SpecificTarget> resultendList = new ArrayList<>();
  5227. Map<String, Map<Integer, SpecificTargetVo>> map = new HashMap<>();
  5228. resultList.stream().forEach(i -> {
  5229. if (map.containsKey(i.getWpid())) {
  5230. Map<Integer, SpecificTargetVo> integerListMap = map.get(i.getWpid());
  5231. if (!integerListMap.containsKey(i.getMonth())) {
  5232. map.get(i.getWpid()).put(i.getMonth(), i);
  5233. } else {
  5234. }
  5235. } else {
  5236. Map<Integer, SpecificTargetVo> tempMap = new HashMap<>();
  5237. tempMap.put(i.getMonth(), i);
  5238. map.put(i.getWpid(), tempMap);
  5239. }
  5240. });
  5241. Set<String> wpids = map.keySet();
  5242. if (StringUtils.isNotNull(wpids)) {
  5243. wpids.stream().forEach(wpid -> {
  5244. SpecificTarget vo = new SpecificTarget();
  5245. vo.setWpid(wpid);
  5246. int orderNum = 100;
  5247. if (wpid.contains("_ZGS")) {
  5248. vo.setWpname(CacheContext.cpmap.get(companys).getAname());
  5249. } else if (wpid.contains("_RGN")) {
  5250. vo.setWpname(CacheContext.rgmap.get(companys).getAname());
  5251. } else {
  5252. vo.setWpname(CacheContext.wpmap.get(wpid).getAname());
  5253. orderNum = CacheContext.wpmap.get(wpid).getOrderNum();
  5254. }
  5255. vo.setOrderNum(orderNum);
  5256. List<SpecificTargetVo> tempList = new ArrayList<>();
  5257. Map<Integer, SpecificTargetVo> listMap = map.get(wpid);
  5258. for (int x = 1; x <= 12; x++) {
  5259. if (listMap.containsKey(x)) {
  5260. tempList.add(listMap.get(x));
  5261. } else {
  5262. SpecificTargetVo vo1 = new SpecificTargetVo();
  5263. vo1.setWpid(wpid);
  5264. if (wpid.contains("_ZGS")) {
  5265. vo1.setWpname(CacheContext.cpmap.get(companys).getAname());
  5266. } else if (wpid.contains("_RGN")) {
  5267. vo1.setWpname(CacheContext.rgmap.get(companys).getAname());
  5268. } else {
  5269. vo1.setWpname(CacheContext.wpmap.get(wpid).getAname());
  5270. }
  5271. vo1.setYear(Integer.parseInt(year));
  5272. vo1.setMonth(x);
  5273. tempList.add(vo1);
  5274. }
  5275. }
  5276. vo.setTargetList(tempList);
  5277. resultendList.add(vo);
  5278. });
  5279. }
  5280. SortUtils.sort(resultendList, "orderNum", SortUtils.ASC);
  5281. return resultendList;
  5282. }
  5283. public List<SpecificTarget> lslList(String companys, String type, String year) {
  5284. //获取年份所有当月的数据
  5285. QueryWrapper<ProEconPowerstationInfoDay7> currentqw = new QueryWrapper<>();
  5286. currentqw.select("foreign_key_id,max(record_date) record_date,avg(ylsl) ylsl");
  5287. currentqw.eq("location", "wp");
  5288. currentqw.eq("to_char(record_date,'yyyy')", year);
  5289. if (type.equals("-1")) {
  5290. currentqw.like("foreign_key_id", "_FDC_");
  5291. } else {
  5292. currentqw.like("foreign_key_id", "_GDC_");
  5293. }
  5294. if (companys.endsWith("ZGS")) {
  5295. currentqw.eq("company_id", companys);
  5296. } else {
  5297. currentqw.eq("region_id", companys);
  5298. }
  5299. currentqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  5300. List<ProEconPowerstationInfoDay7> currentList = proEconPowerstationInfoDay7Service.list(currentqw);
  5301. currentqw.clear();
  5302. currentqw.select("foreign_key_id,max(record_date) record_date,avg(ylsl) ylsl");
  5303. currentqw.eq("foreign_key_id", companys + type);
  5304. currentqw.eq("to_char(record_date,'yyyy')", year);
  5305. currentqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  5306. currentList.addAll(proEconPowerstationInfoDay7Service.list(currentqw));
  5307. int subYear = Integer.parseInt(year) - 1;
  5308. QueryWrapper<ProEconPowerstationInfoDay7> sameperiodqw = new QueryWrapper<>();
  5309. sameperiodqw.select("foreign_key_id,max(record_date) record_date,avg(ylsl) ylsl");
  5310. sameperiodqw.eq("location", "wp");
  5311. if (type.equals("-1")) {
  5312. currentqw.like("foreign_key_id", "_FDC_");
  5313. } else {
  5314. currentqw.like("foreign_key_id", "_GDC_");
  5315. }
  5316. if (companys.endsWith("ZGS")) {
  5317. currentqw.eq("company_id", companys);
  5318. } else {
  5319. currentqw.eq("region_id", companys);
  5320. }
  5321. sameperiodqw.eq("to_char(record_date,'yyyy')", String.valueOf(subYear));
  5322. sameperiodqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  5323. List<ProEconPowerstationInfoDay7> sameperiodList = proEconPowerstationInfoDay7Service.list(sameperiodqw);
  5324. sameperiodqw.clear();
  5325. sameperiodqw.select("foreign_key_id,max(record_date) record_date,avg(ylsl) ylsl");
  5326. sameperiodqw.eq("foreign_key_id", companys + type);
  5327. sameperiodqw.eq("to_char(record_date,'yyyy')", String.valueOf(subYear));
  5328. sameperiodqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  5329. sameperiodList.addAll(proEconPowerstationInfoDay7Service.list(sameperiodqw));
  5330. //合并当月与同期数据为返回结果
  5331. List<SpecificTargetVo> resultList = new ArrayList<>();
  5332. currentList.stream().forEach(i -> {
  5333. SpecificTargetVo vo = new SpecificTargetVo();
  5334. String wpid = i.getForeignKeyId();
  5335. vo.setWpid(wpid);
  5336. if (wpid.contains("_ZGS")) {
  5337. vo.setWpname(CacheContext.cpmap.get(companys).getAname());
  5338. } else if (wpid.contains("_RGN")) {
  5339. vo.setWpname(CacheContext.rgmap.get(companys).getAname());
  5340. } else {
  5341. vo.setWpname(CacheContext.wpmap.get(wpid).getAname());
  5342. }
  5343. vo.setYear(DateUtils.getYear(i.getRecordDate()));
  5344. vo.setMonth(DateUtils.getMonth(i.getRecordDate()));
  5345. vo.setCurrent(DoubleUtils.keepPrecision(i.getYlsl().doubleValue(), 2));
  5346. resultList.add(vo);
  5347. });
  5348. resultList.stream().forEach(i -> {
  5349. Optional<ProEconPowerstationInfoDay7> optional = sameperiodList.stream()
  5350. .filter(j -> j.getForeignKeyId().equals(i.getWpid()) && String.valueOf(DateUtils.getMonth(j.getRecordDate())).equals(i.getMonth()))
  5351. .findFirst();
  5352. if (optional.isPresent()) {
  5353. ProEconPowerstationInfoDay7 tqinfoday = optional.get();
  5354. i.setSameperiod(DoubleUtils.keepPrecision(tqinfoday.getYxtxlpr().doubleValue(), 2));
  5355. i.setCompare(i.getCurrent().compareTo(i.getSameperiod()));
  5356. } else {
  5357. i.setSameperiod(0.0);
  5358. i.setCompare(0);
  5359. }
  5360. });
  5361. List<SpecificTarget> resultendList = new ArrayList<>();
  5362. Map<String, Map<Integer, SpecificTargetVo>> map = new HashMap<>();
  5363. resultList.stream().forEach(i -> {
  5364. if (map.containsKey(i.getWpid())) {
  5365. Map<Integer, SpecificTargetVo> integerListMap = map.get(i.getWpid());
  5366. if (!integerListMap.containsKey(i.getMonth())) {
  5367. map.get(i.getWpid()).put(i.getMonth(), i);
  5368. } else {
  5369. }
  5370. } else {
  5371. Map<Integer, SpecificTargetVo> tempMap = new HashMap<>();
  5372. tempMap.put(i.getMonth(), i);
  5373. map.put(i.getWpid(), tempMap);
  5374. }
  5375. });
  5376. Set<String> wpids = map.keySet();
  5377. if (StringUtils.isNotNull(wpids)) {
  5378. wpids.stream().forEach(wpid -> {
  5379. SpecificTarget vo = new SpecificTarget();
  5380. vo.setWpid(wpid);
  5381. int orderNum = 100;
  5382. if (wpid.contains("_ZGS")) {
  5383. vo.setWpname(CacheContext.cpmap.get(companys).getAname());
  5384. } else if (wpid.contains("_RGN")) {
  5385. vo.setWpname(CacheContext.rgmap.get(companys).getAname());
  5386. } else {
  5387. vo.setWpname(CacheContext.wpmap.get(wpid).getAname());
  5388. orderNum = CacheContext.wpmap.get(wpid).getOrderNum();
  5389. }
  5390. vo.setOrderNum(orderNum);
  5391. List<SpecificTargetVo> tempList = new ArrayList<>();
  5392. Map<Integer, SpecificTargetVo> listMap = map.get(wpid);
  5393. for (int x = 1; x <= 12; x++) {
  5394. if (listMap.containsKey(x)) {
  5395. tempList.add(listMap.get(x));
  5396. } else {
  5397. SpecificTargetVo vo1 = new SpecificTargetVo();
  5398. vo1.setWpid(wpid);
  5399. if (wpid.contains("_ZGS")) {
  5400. vo1.setWpname(CacheContext.cpmap.get(companys).getAname());
  5401. } else if (wpid.contains("_RGN")) {
  5402. vo1.setWpname(CacheContext.rgmap.get(companys).getAname());
  5403. } else {
  5404. vo1.setWpname(CacheContext.wpmap.get(wpid).getAname());
  5405. }
  5406. vo1.setYear(Integer.parseInt(year));
  5407. vo1.setMonth(x);
  5408. tempList.add(vo1);
  5409. }
  5410. }
  5411. vo.setTargetList(tempList);
  5412. resultendList.add(vo);
  5413. });
  5414. }
  5415. SortUtils.sort(resultendList, "orderNum", SortUtils.ASC);
  5416. return resultendList;
  5417. }
  5418. public List<SpecificTarget> zhxlList(String companys, String type, String year) {
  5419. //获取年份所有当月的数据
  5420. QueryWrapper<ProEconPowerstationInfoDay7> currentqw = new QueryWrapper<>();
  5421. currentqw.select("foreign_key_id,max(record_date) record_date,avg(ynbqzhxl) ynbqzhxl");
  5422. currentqw.eq("location", "wp");
  5423. currentqw.eq("to_char(record_date,'yyyy')", year);
  5424. if (type.equals("-1")) {
  5425. currentqw.like("foreign_key_id", "_FDC_");
  5426. } else {
  5427. currentqw.like("foreign_key_id", "_GDC_");
  5428. }
  5429. if (companys.endsWith("ZGS")) {
  5430. currentqw.eq("company_id", companys);
  5431. } else {
  5432. currentqw.eq("region_id", companys);
  5433. }
  5434. currentqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  5435. List<ProEconPowerstationInfoDay7> currentList = proEconPowerstationInfoDay7Service.list(currentqw);
  5436. currentqw.clear();
  5437. currentqw.select("foreign_key_id,max(record_date) record_date,avg(ynbqzhxl) ynbqzhxl");
  5438. currentqw.eq("foreign_key_id", companys + type);
  5439. currentqw.eq("to_char(record_date,'yyyy')", year);
  5440. currentqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  5441. currentList.addAll(proEconPowerstationInfoDay7Service.list(currentqw));
  5442. int subYear = Integer.parseInt(year) - 1;
  5443. QueryWrapper<ProEconPowerstationInfoDay7> sameperiodqw = new QueryWrapper<>();
  5444. sameperiodqw.select("foreign_key_id,max(record_date) record_date,avg(ynbqzhxl) ynbqzhxl");
  5445. sameperiodqw.eq("location", "wp");
  5446. if (type.equals("-1")) {
  5447. currentqw.like("foreign_key_id", "_FDC_");
  5448. } else {
  5449. currentqw.like("foreign_key_id", "_GDC_");
  5450. }
  5451. if (companys.endsWith("ZGS")) {
  5452. currentqw.eq("company_id", companys);
  5453. } else {
  5454. currentqw.eq("region_id", companys);
  5455. }
  5456. sameperiodqw.eq("to_char(record_date,'yyyy')", String.valueOf(subYear));
  5457. sameperiodqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  5458. List<ProEconPowerstationInfoDay7> sameperiodList = proEconPowerstationInfoDay7Service.list(sameperiodqw);
  5459. sameperiodqw.clear();
  5460. sameperiodqw.select("foreign_key_id,max(record_date) record_date,avg(ynbqzhxl) ynbqzhxl");
  5461. sameperiodqw.eq("foreign_key_id", companys + type);
  5462. sameperiodqw.eq("to_char(record_date,'yyyy')", String.valueOf(subYear));
  5463. sameperiodqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  5464. sameperiodList.addAll(proEconPowerstationInfoDay7Service.list(sameperiodqw));
  5465. //合并当月与同期数据为返回结果
  5466. List<SpecificTargetVo> resultList = new ArrayList<>();
  5467. currentList.stream().forEach(i -> {
  5468. SpecificTargetVo vo = new SpecificTargetVo();
  5469. String wpid = i.getForeignKeyId();
  5470. vo.setWpid(wpid);
  5471. if (wpid.contains("_ZGS")) {
  5472. vo.setWpname(CacheContext.cpmap.get(companys).getAname());
  5473. } else if (wpid.contains("_RGN")) {
  5474. vo.setWpname(CacheContext.rgmap.get(companys).getAname());
  5475. } else {
  5476. vo.setWpname(CacheContext.wpmap.get(wpid).getAname());
  5477. }
  5478. vo.setYear(DateUtils.getYear(i.getRecordDate()));
  5479. vo.setMonth(DateUtils.getMonth(i.getRecordDate()));
  5480. vo.setCurrent(DoubleUtils.keepPrecision(i.getYnbqzhxl().doubleValue(), 2));
  5481. resultList.add(vo);
  5482. });
  5483. resultList.stream().forEach(i -> {
  5484. Optional<ProEconPowerstationInfoDay7> optional = sameperiodList.stream()
  5485. .filter(j -> j.getForeignKeyId().equals(i.getWpid()) && String.valueOf(DateUtils.getMonth(j.getRecordDate())).equals(i.getMonth()))
  5486. .findFirst();
  5487. if (optional.isPresent()) {
  5488. ProEconPowerstationInfoDay7 tqinfoday = optional.get();
  5489. i.setSameperiod(DoubleUtils.keepPrecision(tqinfoday.getYxtxlpr().doubleValue(), 2));
  5490. i.setCompare(i.getCurrent().compareTo(i.getSameperiod()));
  5491. } else {
  5492. i.setSameperiod(0.0);
  5493. i.setCompare(0);
  5494. }
  5495. });
  5496. List<SpecificTarget> resultendList = new ArrayList<>();
  5497. Map<String, Map<Integer, SpecificTargetVo>> map = new HashMap<>();
  5498. resultList.stream().forEach(i -> {
  5499. if (map.containsKey(i.getWpid())) {
  5500. Map<Integer, SpecificTargetVo> integerListMap = map.get(i.getWpid());
  5501. if (!integerListMap.containsKey(i.getMonth())) {
  5502. map.get(i.getWpid()).put(i.getMonth(), i);
  5503. } else {
  5504. }
  5505. } else {
  5506. Map<Integer, SpecificTargetVo> tempMap = new HashMap<>();
  5507. tempMap.put(i.getMonth(), i);
  5508. map.put(i.getWpid(), tempMap);
  5509. }
  5510. });
  5511. Set<String> wpids = map.keySet();
  5512. if (StringUtils.isNotNull(wpids)) {
  5513. wpids.stream().forEach(wpid -> {
  5514. SpecificTarget vo = new SpecificTarget();
  5515. vo.setWpid(wpid);
  5516. int orderNum = 100;
  5517. if (wpid.contains("_ZGS")) {
  5518. vo.setWpname(CacheContext.cpmap.get(companys).getAname());
  5519. } else if (wpid.contains("_RGN")) {
  5520. vo.setWpname(CacheContext.rgmap.get(companys).getAname());
  5521. } else {
  5522. vo.setWpname(CacheContext.wpmap.get(wpid).getAname());
  5523. orderNum = CacheContext.wpmap.get(wpid).getOrderNum();
  5524. }
  5525. vo.setOrderNum(orderNum);
  5526. List<SpecificTargetVo> tempList = new ArrayList<>();
  5527. Map<Integer, SpecificTargetVo> listMap = map.get(wpid);
  5528. for (int x = 1; x <= 12; x++) {
  5529. if (listMap.containsKey(x)) {
  5530. tempList.add(listMap.get(x));
  5531. } else {
  5532. SpecificTargetVo vo1 = new SpecificTargetVo();
  5533. vo1.setWpid(wpid);
  5534. if (wpid.contains("_ZGS")) {
  5535. vo1.setWpname(CacheContext.cpmap.get(companys).getAname());
  5536. } else if (wpid.contains("_RGN")) {
  5537. vo1.setWpname(CacheContext.rgmap.get(companys).getAname());
  5538. } else {
  5539. vo1.setWpname(CacheContext.wpmap.get(wpid).getAname());
  5540. }
  5541. vo1.setYear(Integer.parseInt(year));
  5542. vo1.setMonth(x);
  5543. tempList.add(vo1);
  5544. }
  5545. }
  5546. vo.setTargetList(tempList);
  5547. resultendList.add(vo);
  5548. });
  5549. }
  5550. SortUtils.sort(resultendList, "orderNum", SortUtils.ASC);
  5551. return resultendList;
  5552. }
  5553. }