SpecificService.java 283 KB

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