SpecificService.java 281 KB

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