PmDemandServiceImpl.java 245 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628
  1. package com.ozs.pm.service.impl;
  2. import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
  3. import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
  4. import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
  5. import com.baomidou.mybatisplus.core.metadata.IPage;
  6. import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
  7. import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
  8. import com.ozs.base.domain.BaseAgency;
  9. import com.ozs.base.domain.BaseExpert;
  10. import com.ozs.base.domain.BaseNotice;
  11. import com.ozs.base.domain.BaseNoticeType;
  12. import com.ozs.base.domain.BaseUnitInformation;
  13. import com.ozs.base.domain.vo.BaseExpertVo;
  14. import com.ozs.base.mapper.BaseExpertMapper;
  15. import com.ozs.base.service.BaseAgencyService;
  16. import com.ozs.base.service.BaseExpertService;
  17. import com.ozs.base.service.BaseNoticeService;
  18. import com.ozs.base.service.BaseNoticeTypeService;
  19. import com.ozs.common.constant.Constants;
  20. import com.ozs.common.core.domain.AjaxResult;
  21. import com.ozs.common.core.domain.entity.SysDept;
  22. import com.ozs.common.core.domain.entity.SysDictData;
  23. import com.ozs.common.core.domain.entity.SysRole;
  24. import com.ozs.common.core.domain.entity.SysUser;
  25. import com.ozs.common.core.domain.model.LoginUser;
  26. import com.ozs.common.enums.BidWinningStatus;
  27. import com.ozs.common.enums.ExpertType;
  28. import com.ozs.common.enums.IsExcess;
  29. import com.ozs.common.enums.NameListType;
  30. import com.ozs.common.enums.PlanPurchaseMode;
  31. import com.ozs.common.enums.PmProjectStatus;
  32. import com.ozs.common.enums.ProcurementMethodSuggest;
  33. import com.ozs.common.enums.ProjectAttribute;
  34. import com.ozs.common.enums.ProjectTypes;
  35. import com.ozs.common.enums.SysFileRefEnum;
  36. import com.ozs.common.enums.WarnStatus;
  37. import com.ozs.common.utils.DateUtils;
  38. import com.ozs.common.utils.RandomUtil;
  39. import com.ozs.common.utils.SecurityUtils;
  40. import com.ozs.common.utils.StringUtils;
  41. import com.ozs.common.utils.bean.BeanUtils;
  42. import com.ozs.home.domain.vo.HomeToDoQueryResVo;
  43. import com.ozs.plan.doman.PlanYears;
  44. import com.ozs.plan.doman.ProvisionalPlan;
  45. import com.ozs.plan.doman.vo.responseVo.PlanQuarterResponseVo;
  46. import com.ozs.plan.mapper.ProvisionalPlanMapper;
  47. import com.ozs.plan.service.PlanYearsService;
  48. import com.ozs.pm.doman.PmAuditDeptRef;
  49. import com.ozs.pm.doman.PmBidFailure;
  50. import com.ozs.pm.doman.PmBidOpening;
  51. import com.ozs.pm.doman.PmBidWinning;
  52. import com.ozs.pm.doman.PmBidWinningOpeningRef;
  53. import com.ozs.pm.doman.PmBookBuilding;
  54. import com.ozs.pm.doman.PmCallQuestion;
  55. import com.ozs.pm.doman.PmContractInfo;
  56. import com.ozs.pm.doman.PmDemand;
  57. import com.ozs.pm.doman.PmDemandExpertRef;
  58. import com.ozs.pm.doman.PmExpertFeedback;
  59. import com.ozs.pm.doman.PmProcurementDocumentsReview;
  60. import com.ozs.pm.doman.PmProjectConstruction;
  61. import com.ozs.pm.doman.PmReleaseAnnouncement;
  62. import com.ozs.pm.doman.vo.requestVo.PmBaseExpertExtractReqVo;
  63. import com.ozs.pm.doman.vo.requestVo.PmBaseExpertFillReqVo;
  64. import com.ozs.pm.doman.vo.requestVo.PmBidFailureReqVo;
  65. import com.ozs.pm.doman.vo.requestVo.PmBidOpeningFillReqVo;
  66. import com.ozs.pm.doman.vo.requestVo.PmBidWinningReqVo;
  67. import com.ozs.pm.doman.vo.requestVo.PmBookBuildingReqVo;
  68. import com.ozs.pm.doman.vo.requestVo.PmContractInfoReqVo;
  69. import com.ozs.pm.doman.vo.requestVo.PmDemandReqVo;
  70. import com.ozs.pm.doman.vo.requestVo.PmProjectConstructionReqVo;
  71. import com.ozs.pm.doman.vo.requestVo.PmReleaseAnnouncementReqVo;
  72. import com.ozs.pm.doman.vo.responseVo.PmBaseExpertResVo;
  73. import com.ozs.pm.doman.vo.responseVo.PmBidFailureResVo;
  74. import com.ozs.pm.doman.vo.responseVo.PmBidOpeningResVo;
  75. import com.ozs.pm.doman.vo.responseVo.PmBidWinningResVo;
  76. import com.ozs.pm.doman.vo.responseVo.PmBookBuildingResVo;
  77. import com.ozs.pm.doman.vo.responseVo.PmCallQuestionResVo;
  78. import com.ozs.pm.doman.vo.responseVo.PmContractInfoResVo;
  79. import com.ozs.pm.doman.vo.responseVo.PmDemandResVo;
  80. import com.ozs.pm.doman.vo.responseVo.PmExpertFeedbackResVo;
  81. import com.ozs.pm.doman.vo.responseVo.PmProcurementDocumentsReviewResVo;
  82. import com.ozs.pm.doman.vo.responseVo.PmProjectConstructionResVo;
  83. import com.ozs.pm.doman.vo.responseVo.PmPurchaseExecutionResVo;
  84. import com.ozs.pm.doman.vo.responseVo.PmReleaseAnnouncementResVo;
  85. import com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo;
  86. import com.ozs.pm.mapper.PmDemandMapper;
  87. import com.ozs.pm.service.IPmDemandService;
  88. import com.ozs.pm.service.PmAuditDeptRefService;
  89. import com.ozs.pm.service.PmBidFailureService;
  90. import com.ozs.pm.service.PmBidOpeningService;
  91. import com.ozs.pm.service.PmBidWinningOpeningRefService;
  92. import com.ozs.pm.service.PmBidWinningService;
  93. import com.ozs.pm.service.PmBookBuildingService;
  94. import com.ozs.pm.service.PmCallQuestionHisService;
  95. import com.ozs.pm.service.PmCallQuestionService;
  96. import com.ozs.pm.service.PmContractInfoService;
  97. import com.ozs.pm.service.PmDemandExpertRefService;
  98. import com.ozs.pm.service.PmExpertFeedbackService;
  99. import com.ozs.pm.service.PmProcurementDocumentsReviewService;
  100. import com.ozs.pm.service.PmProjectConstructionService;
  101. import com.ozs.pm.service.PmReleaseAnnouncementService;
  102. import com.ozs.system.domain.SysFileInfo;
  103. import com.ozs.system.domain.SysFileRef;
  104. import com.ozs.system.domain.vo.SysRegionVO;
  105. import com.ozs.system.domain.vo.responseVo.SysDeptResponseVo;
  106. import com.ozs.system.mapper.SysDeptMapper;
  107. import com.ozs.system.mapper.SysFileRefMapper;
  108. import com.ozs.system.mapper.SysRoleMapper;
  109. import com.ozs.system.service.ISysDeptService;
  110. import com.ozs.system.service.ISysDictDataService;
  111. import com.ozs.system.service.ISysDictTypeService;
  112. import com.ozs.system.service.ISysRegionService;
  113. import com.ozs.system.service.ISysUserService;
  114. import com.ozs.system.service.SysFileRefService;
  115. import com.ozs.system.service.SysFileService;
  116. import lombok.extern.slf4j.Slf4j;
  117. import org.springframework.beans.factory.annotation.Autowired;
  118. import org.springframework.stereotype.Service;
  119. import org.springframework.transaction.annotation.Transactional;
  120. import org.springframework.util.ObjectUtils;
  121. import java.math.BigDecimal;
  122. import java.text.DecimalFormat;
  123. import java.text.ParseException;
  124. import java.util.ArrayList;
  125. import java.util.Arrays;
  126. import java.util.Calendar;
  127. import java.util.Date;
  128. import java.util.HashMap;
  129. import java.util.HashSet;
  130. import java.util.LinkedHashMap;
  131. import java.util.LinkedList;
  132. import java.util.List;
  133. import java.util.Map;
  134. import java.util.Set;
  135. import java.util.stream.Collectors;
  136. /**
  137. * 采购需求Service业务层处理
  138. *
  139. * @author ruoyi
  140. * @date 2023-01-16
  141. */
  142. @Service
  143. @Slf4j
  144. public class PmDemandServiceImpl extends ServiceImpl<PmDemandMapper, PmDemand> implements IPmDemandService {
  145. @Autowired
  146. private PmDemandMapper pmDemandMapper;
  147. @Autowired
  148. private ISysDeptService deptService;
  149. @Autowired
  150. private SysRoleMapper sysRoleMapper;
  151. @Autowired
  152. private ISysDictDataService dictDataService;
  153. @Autowired
  154. private ISysDictTypeService dictTypeService;
  155. @Autowired
  156. private SysFileService fileService;
  157. @Autowired
  158. private SysFileRefService sysFileRefService;
  159. @Autowired
  160. private PmReleaseAnnouncementService pmReleaseAnnouncementService;
  161. @Autowired
  162. private BaseExpertService baseExpertService;
  163. @Autowired
  164. private PmDemandExpertRefService pmDemandExpertRefService;
  165. @Autowired
  166. private PmBidOpeningService pmBidOpeningService;
  167. @Autowired
  168. private SysFileRefMapper sysFileRefMapper;
  169. @Autowired
  170. private PmBookBuildingService pmBookBuildingService;
  171. @Autowired
  172. private PmCallQuestionService pmCallQuestionService;
  173. @Autowired
  174. private PmBidWinningService pmBidWinningService;
  175. @Autowired
  176. private ISysDictTypeService iSysDictTypeService;
  177. @Autowired
  178. private PmBidFailureService pmBidFailureService;
  179. @Autowired
  180. private PmBidWinningOpeningRefService pmBidWinningOpeningRefService;
  181. @Autowired
  182. private PmContractInfoService pmContractInfoService;
  183. @Autowired
  184. private BaseAgencyService baseAgencyService;
  185. @Autowired
  186. private PmProjectConstructionService pmProjectConstructionService;
  187. @Autowired
  188. private BaseNoticeTypeService baseNoticeTypeService;
  189. @Autowired
  190. private BaseNoticeService baseNoticeService;
  191. @Autowired
  192. private PlanYearsService planYearsService;
  193. @Autowired
  194. private ISysRegionService iSysRegionService;
  195. @Autowired
  196. private ISysUserService userService;
  197. @Autowired
  198. private SysDeptMapper deptMapper;
  199. @Autowired
  200. private BaseExpertMapper baseExpertMapper;
  201. @Autowired
  202. private PmAuditDeptRefService pmAuditDeptRefService;
  203. @Autowired
  204. private ProvisionalPlanMapper provisionalPlanMapper;
  205. @Autowired
  206. private PmExpertFeedbackService pmExpertFeedbackService;
  207. @Autowired
  208. private PmProcurementDocumentsReviewService pmProcurementDocumentsReviewService;
  209. @Autowired
  210. private PmCallQuestionHisService questionHisService;
  211. /**
  212. * 查询采购需求
  213. *
  214. * @param demandId 采购需求主键
  215. * @return 采购需求
  216. */
  217. @Override
  218. public PmDemandResVo selectPmDemandByDemandId(Long demandId, String detailType) {
  219. PmDemand pmDemand = this.getById(demandId);
  220. if (pmDemand != null) {
  221. PmDemandResVo vo = new PmDemandResVo();
  222. vo.setProjectName(pmDemand.getProjectName());
  223. vo.setDemandId(demandId);
  224. if ("1".equals(detailType)) { //项目计划
  225. BeanUtils.copyProperties(pmDemand, vo);
  226. //project_type,evaluation 从原来计划里取
  227. ProvisionalPlan provisionalPlan = provisionalPlanMapper.seletById(pmDemand.getPlanId());
  228. if (provisionalPlan != null) {
  229. vo.setProjectType(provisionalPlan.getProjectType());
  230. vo.setEvaluation(provisionalPlan.getEvaluation().doubleValue());
  231. }
  232. SysDeptResponseVo sysDeptResponseVo = (SysDeptResponseVo) deptService.selectDeptById(vo.getPurchaseDeptId()).get("sysDept");
  233. if (sysDeptResponseVo != null) {
  234. vo.setPurchaseDeptName(sysDeptResponseVo.getDeptName());
  235. }
  236. String purchaseServicesName = dictDataService.selectDictLabel("purchase_services", vo.getPurchaseServices());
  237. if (StringUtils.isNotEmpty(purchaseServicesName)) {
  238. vo.setPurchaseServicesName(purchaseServicesName);
  239. }
  240. //采购需求附件
  241. List<SysFileInfo> demandFileInfos = getSysFileInfoList(vo.getDemandId(), SysFileRefEnum.PM_DEMAND.getType());
  242. if (!ObjectUtils.isEmpty(demandFileInfos)) {
  243. vo.setDemandFileInfos(demandFileInfos);
  244. }
  245. //项目类型
  246. String projectTypeName = dictDataService.selectDictLabel("sys_project_type", vo.getProjectType());
  247. if (StringUtils.isNotEmpty(projectTypeName)) {
  248. vo.setProjectTypeName(projectTypeName);
  249. }
  250. //是否为超限额计划
  251. for (IsExcess value : IsExcess.values()) {
  252. if (vo.getIsExcess() != null && vo.getIsExcess().equals(value.getCode())) {
  253. vo.setIsExcessName(value.getInfo());
  254. break;
  255. }
  256. }
  257. //采购方式
  258. for (PlanPurchaseMode value : PlanPurchaseMode.values()) {
  259. if (vo.getPurchaseMode() != null && vo.getPurchaseMode().equals(value.getCode())) {
  260. vo.setPurchaseModeName(value.getInfo());
  261. break;
  262. }
  263. }
  264. //项目属性
  265. for (ProjectAttribute value : ProjectAttribute.values()) {
  266. if (vo.getProjectAttr() != null && vo.getProjectAttr().equals(value.getCode())) {
  267. vo.setProjectAttrName(value.getInfo());
  268. break;
  269. }
  270. }
  271. //预警状态
  272. for (WarnStatus value : WarnStatus.values()) {
  273. if (vo.getWarnStatus() != null && vo.getWarnStatus().equals(value.getCode())) {
  274. vo.setWarnStatusName(value.getInfo());
  275. break;
  276. }
  277. }
  278. //项目状态
  279. for (PmProjectStatus value : PmProjectStatus.values()) {
  280. if (vo.getProjectStatus() != null && vo.getProjectStatus().equals(value.getCode())) {
  281. vo.setProjectStatusName(value.getInfo());
  282. break;
  283. }
  284. }
  285. } else if ("2".equals(detailType)) { //需求建档
  286. //采购需求审核文件
  287. List<SysFileInfo> auditFileInfos = getSysFileInfoList(vo.getDemandId(), SysFileRefEnum.PM_DEMAND_EXAMINE.getType());
  288. if (!ObjectUtils.isEmpty(auditFileInfos)) {
  289. vo.setAuditFileInfos(auditFileInfos);
  290. }
  291. LambdaQueryWrapper<PmBookBuilding> lambdaQueryWrapper = new LambdaQueryWrapper<>();
  292. lambdaQueryWrapper.eq(PmBookBuilding::getDemandId, demandId);
  293. PmBookBuilding pmBookBuilding = pmBookBuildingService.getOne(lambdaQueryWrapper);
  294. if (pmBookBuilding != null) {
  295. PmBookBuildingResVo responseVo = new PmBookBuildingResVo();
  296. BeanUtils.copyProperties(pmBookBuilding, responseVo);
  297. List<SysFileInfo> fileInfos = getSysFileInfoList(pmBookBuilding.getId(), SysFileRefEnum.PM_BOOK_BUILDING.getType());
  298. if (!ObjectUtils.isEmpty(fileInfos)) {
  299. if (!ObjectUtils.isEmpty(auditFileInfos)) {
  300. fileInfos.addAll(auditFileInfos);
  301. }
  302. responseVo.setFileInfos(fileInfos);
  303. }
  304. vo.setPmBookBuildingResVo(responseVo);
  305. }
  306. } else if ("3".equals(detailType)) { //任务下达
  307. vo.setTaskReleaseTime(pmDemand.getTaskReleaseTime());
  308. //任务下达文件
  309. List<SysFileInfo> taskReleaseFileInfos = getSysFileInfoList(vo.getDemandId(), SysFileRefEnum.PM_TAST_RELEASE.getType());
  310. if (!ObjectUtils.isEmpty(taskReleaseFileInfos)) {
  311. vo.setTaskReleaseFileInfos(taskReleaseFileInfos);
  312. }
  313. } else if ("4".equals(detailType)) { //中标信息
  314. setPmPurchaseExecutionResVo(vo, pmDemand);
  315. } else if ("5".equals(detailType)) { //合同信息
  316. setPmPurchaseExecutionResVo(vo, pmDemand);
  317. LambdaQueryWrapper<PmContractInfo> lambdaQueryWrapper = new LambdaQueryWrapper<>();
  318. lambdaQueryWrapper.eq(PmContractInfo::getDemandId, demandId);
  319. PmContractInfo pmContractInfo = pmContractInfoService.getOne(lambdaQueryWrapper);
  320. if (pmContractInfo != null) {
  321. PmContractInfoResVo pmContractInfoResVo = new PmContractInfoResVo();
  322. BeanUtils.copyProperties(pmContractInfo, pmContractInfoResVo);
  323. //合同信息文件
  324. List<SysFileInfo> fileInfos = getSysFileInfoList(pmContractInfo.getId(), SysFileRefEnum.PM_CONTRACT_INFO.getType());
  325. if (!ObjectUtils.isEmpty(fileInfos)) {
  326. pmContractInfoResVo.setFileInfos(fileInfos);
  327. }
  328. vo.setPmContractInfoResVo(pmContractInfoResVo);
  329. }
  330. } else if ("6".equals(detailType)) { //建设情况
  331. LambdaQueryWrapper<PmProjectConstruction> lambdaQueryWrapper = new LambdaQueryWrapper<>();
  332. lambdaQueryWrapper.eq(PmProjectConstruction::getDemandId, demandId);
  333. PmProjectConstruction pmProjectConstruction = pmProjectConstructionService.getOne(lambdaQueryWrapper);
  334. if (pmProjectConstruction != null) {
  335. PmProjectConstructionResVo pmProjectConstructionResVo = new PmProjectConstructionResVo();
  336. BeanUtils.copyProperties(pmProjectConstruction, pmProjectConstructionResVo);
  337. //建设情况文件
  338. List<SysFileInfo> fileInfos = getSysFileInfoList(pmProjectConstruction.getId(), SysFileRefEnum.PM_PROJECT_CONSTRUCTION.getType());
  339. if (!ObjectUtils.isEmpty(fileInfos)) {
  340. pmProjectConstructionResVo.setFileInfos(fileInfos);
  341. }
  342. vo.setPmProjectConstructionResVo(pmProjectConstructionResVo);
  343. }
  344. }
  345. return vo;
  346. } else {
  347. return null;
  348. }
  349. }
  350. private void setPmPurchaseExecutionResVo(PmDemandResVo vo, PmDemand pmDemand) {
  351. Long demandId = pmDemand.getDemandId();
  352. PmPurchaseExecutionResVo pmPurchaseExecutionResVo = new PmPurchaseExecutionResVo();
  353. //代理商信息
  354. BaseAgency baseAgency = this.baseAgencyService.getById(pmDemand.getAgencyId());
  355. List<SysDictData> dictData = dictTypeService.selectDictDataByType(Constants.SYS_COMPANY_NATURE);
  356. for (SysDictData data : dictData) {
  357. if (data.getDictValue().equals(baseAgency.getCompanyNature())) {
  358. baseAgency.setCompanyNatureName(data.getDictLabel());
  359. break;
  360. }
  361. }
  362. List<SysDictData> dictDataT = dictTypeService.selectDictDataByType(Constants.SYS_PROJECT_TYPE);
  363. for (SysDictData data : dictDataT) {
  364. if (data.getDictValue().equals(baseAgency.getCompanyType() + "")) {
  365. baseAgency.setCompanyTypeName(data.getDictLabel());
  366. break;
  367. }
  368. }
  369. pmPurchaseExecutionResVo.setBaseAgency(baseAgency);
  370. vo.setPurchaseTaskDocumentNumber(pmDemand.getPurchaseTaskDocumentNumber());
  371. //专家意见反馈
  372. LambdaQueryWrapper<PmExpertFeedback> pmExpertFeedbackLambdaQueryWrapper = new LambdaQueryWrapper<>();
  373. pmExpertFeedbackLambdaQueryWrapper.eq(PmExpertFeedback::getDemandId, demandId);
  374. PmExpertFeedback pmExpertFeedback = pmExpertFeedbackService.getOne(pmExpertFeedbackLambdaQueryWrapper);
  375. if (!ObjectUtils.isEmpty(pmExpertFeedback)) {
  376. PmExpertFeedbackResVo pmExpertFeedbackResVo = new PmExpertFeedbackResVo();
  377. BeanUtils.copyProperties(pmExpertFeedback, pmExpertFeedbackResVo);
  378. List<SysFileInfo> fileInfos = getSysFileInfoList(pmExpertFeedbackResVo.getId(), SysFileRefEnum.PM_EXPERT_FEEDBACK.getType());
  379. if (!ObjectUtils.isEmpty(fileInfos)) {
  380. pmExpertFeedbackResVo.setFileInfos(fileInfos);
  381. }
  382. pmPurchaseExecutionResVo.setPmExpertFeedbackResVo(pmExpertFeedbackResVo);
  383. }
  384. //采购文件编制审核
  385. LambdaQueryWrapper<PmProcurementDocumentsReview> pmProcurementDocumentsReviewLambdaQueryWrapper = new LambdaQueryWrapper<>();
  386. pmProcurementDocumentsReviewLambdaQueryWrapper.eq(PmProcurementDocumentsReview::getDemandId, demandId);
  387. PmProcurementDocumentsReview pmProcurementDocumentsReview = pmProcurementDocumentsReviewService.getOne(pmProcurementDocumentsReviewLambdaQueryWrapper);
  388. if (!ObjectUtils.isEmpty(pmProcurementDocumentsReview)) {
  389. PmProcurementDocumentsReviewResVo pmProcurementDocumentsReviewResVo = new PmProcurementDocumentsReviewResVo();
  390. BeanUtils.copyProperties(pmProcurementDocumentsReview, pmProcurementDocumentsReviewResVo);
  391. List<SysFileInfo> fileInfos = getSysFileInfoList(pmProcurementDocumentsReviewResVo.getId(), SysFileRefEnum.PM_BID_FILE.getType());
  392. if (!ObjectUtils.isEmpty(fileInfos)) {
  393. pmProcurementDocumentsReviewResVo.setFileInfos(fileInfos);
  394. }
  395. pmPurchaseExecutionResVo.setPmProcurementDocumentsReviewResVo(pmProcurementDocumentsReviewResVo);
  396. }
  397. //采购公告列表
  398. LambdaQueryWrapper<PmReleaseAnnouncement> lambdaQueryWrapper = new LambdaQueryWrapper<>();
  399. lambdaQueryWrapper.eq(PmReleaseAnnouncement::getDemandId, demandId).orderByDesc(PmReleaseAnnouncement::getReleaseTime);
  400. List<PmReleaseAnnouncement> pmReleaseAnnouncementList = this.pmReleaseAnnouncementService.list(lambdaQueryWrapper);
  401. if (!ObjectUtils.isEmpty(pmReleaseAnnouncementList)) {
  402. List<PmReleaseAnnouncementResVo> pmReleaseAnnouncementResVoList = new ArrayList<>();
  403. List<SysFileInfo> fileInfosAll = new ArrayList<>();
  404. for (PmReleaseAnnouncement pmReleaseAnnouncement : pmReleaseAnnouncementList) {
  405. PmReleaseAnnouncementResVo pmReleaseAnnouncementResVo = new PmReleaseAnnouncementResVo();
  406. BeanUtils.copyProperties(pmReleaseAnnouncement, pmReleaseAnnouncementResVo);
  407. List<SysFileInfo> fileInfos = getSysFileInfoList(pmReleaseAnnouncementResVo.getId(), SysFileRefEnum.PM_ANNOUNCEMENT_FILE.getType());
  408. if (!ObjectUtils.isEmpty(fileInfos)) {
  409. fileInfosAll.addAll(fileInfos);
  410. }
  411. pmReleaseAnnouncementResVoList.add(pmReleaseAnnouncementResVo);
  412. }
  413. pmPurchaseExecutionResVo.setPmReleaseAnnouncementFileInfos(fileInfosAll);
  414. pmPurchaseExecutionResVo.setPmReleaseAnnouncementResVoList(pmReleaseAnnouncementResVoList);
  415. }
  416. //标前质疑投诉
  417. LambdaQueryWrapper<PmCallQuestion> pmCallQuestionLambdaQueryWrapper = new LambdaQueryWrapper<>();
  418. pmCallQuestionLambdaQueryWrapper.eq(PmCallQuestion::getDemandId, demandId)
  419. .eq(PmCallQuestion::getType, '0').orderByDesc(PmCallQuestion::getCallQuestionTime);
  420. List<PmCallQuestion> pmCallQuestionList = pmCallQuestionService.list(pmCallQuestionLambdaQueryWrapper);
  421. if (!ObjectUtils.isEmpty(pmCallQuestionList)) {
  422. List<PmCallQuestionResVo> pmCallQuestionResVoList = new ArrayList<>();
  423. List<SysFileInfo> fileInfosAll = new ArrayList<>();
  424. for (PmCallQuestion pmCallQuestion : pmCallQuestionList) {
  425. PmCallQuestionResVo pmCallQuestionResVo = new PmCallQuestionResVo();
  426. BeanUtils.copyProperties(pmCallQuestion, pmCallQuestionResVo);
  427. List<SysFileInfo> fileInfos = getSysFileInfoList(pmCallQuestionResVo.getId(), SysFileRefEnum.PM_PRE_BID_CALL_QUESTION.getType());
  428. if (!ObjectUtils.isEmpty(fileInfos)) {
  429. fileInfosAll.addAll(fileInfos);
  430. }
  431. pmCallQuestionResVoList.add(pmCallQuestionResVo);
  432. }
  433. pmPurchaseExecutionResVo.setPmCallQuestionPreResVoList(pmCallQuestionResVoList);
  434. pmPurchaseExecutionResVo.setPmCallQuestionPreFileInfos(fileInfosAll);
  435. }
  436. //专家信息列表
  437. List<PmBaseExpertResVo> pmBaseExpertResVoList = this.pmDemandExpertRefService.getPmBaseExpertResVoList(demandId);
  438. pmPurchaseExecutionResVo.setPmBaseExpertResVoList(pmBaseExpertResVoList);
  439. //开标信息列表
  440. List<PmBidOpeningResVo> pmBidOpeningResVoList = this.pmBidOpeningService.getPmBidOpeningResVoList(demandId);
  441. pmPurchaseExecutionResVo.setPmBidOpeningResVoList(pmBidOpeningResVoList);
  442. //评标结果公告列表
  443. LambdaQueryWrapper<PmBidWinning> lambdaQueryWrapper1 = new LambdaQueryWrapper<>();
  444. lambdaQueryWrapper1.eq(PmBidWinning::getDemandId, demandId)
  445. .ne(PmBidWinning::getStatus, BidWinningStatus.BE_REPLACED.getCode()).orderByDesc(PmBidWinning::getBidAnnouncementTime);
  446. List<PmBidWinning> pmBidWinningList = this.pmBidWinningService.list(lambdaQueryWrapper1);
  447. if (!ObjectUtils.isEmpty(pmBidWinningList)) {
  448. List<PmBidWinningResVo> pmBidWinningResVoList = new ArrayList<>();
  449. List<SysFileInfo> fileInfosAll = new ArrayList<>();
  450. for (PmBidWinning pmBidWinning : pmBidWinningList) {
  451. PmBidWinningResVo pmBidWinningResVo = new PmBidWinningResVo();
  452. BeanUtils.copyProperties(pmBidWinning, pmBidWinningResVo);
  453. pmBidWinningResVoList.add(pmBidWinningResVo);
  454. List<SysFileInfo> fileInfos = getSysFileInfoList(pmBidWinningResVo.getId(), SysFileRefEnum.PM_BID_WINNING_FILE.getType());
  455. if (!ObjectUtils.isEmpty(fileInfos)) {
  456. fileInfosAll.addAll(fileInfos);
  457. }
  458. }
  459. pmPurchaseExecutionResVo.setPmBidWinningResVoList(pmBidWinningResVoList);
  460. pmPurchaseExecutionResVo.setPmBidWinningFileInfos(fileInfosAll);
  461. }
  462. //标后质疑
  463. LambdaQueryWrapper<PmCallQuestion> pmCallQuestionLambdaQueryWrapper2 = new LambdaQueryWrapper<>();
  464. pmCallQuestionLambdaQueryWrapper2.eq(PmCallQuestion::getDemandId, demandId)
  465. .eq(PmCallQuestion::getType, '1').orderByDesc(PmCallQuestion::getCallQuestionTime);
  466. List<PmCallQuestion> pmCallQuestionList2 = pmCallQuestionService.list(pmCallQuestionLambdaQueryWrapper2);
  467. if (!ObjectUtils.isEmpty(pmCallQuestionList2)) {
  468. List<PmCallQuestionResVo> pmCallQuestionResVoList = new ArrayList<>();
  469. List<SysFileInfo> fileInfosAll = new ArrayList<>();
  470. for (PmCallQuestion pmCallQuestion : pmCallQuestionList2) {
  471. PmCallQuestionResVo pmCallQuestionResVo = new PmCallQuestionResVo();
  472. BeanUtils.copyProperties(pmCallQuestion, pmCallQuestionResVo);
  473. List<SysFileInfo> fileInfos = getSysFileInfoList(pmCallQuestionResVo.getId(), SysFileRefEnum.PM_BID_CALL_QEUSTION_FILE.getType());
  474. if (!ObjectUtils.isEmpty(fileInfos)) {
  475. fileInfosAll.addAll(fileInfos);
  476. }
  477. pmCallQuestionResVoList.add(pmCallQuestionResVo);
  478. }
  479. pmPurchaseExecutionResVo.setPmCallQuestionPostResVoList(pmCallQuestionResVoList);
  480. pmPurchaseExecutionResVo.setPmCallRequestPostFileInfos(fileInfosAll);
  481. }
  482. //流标情况
  483. LambdaQueryWrapper<PmBidFailure> lambdaQueryWrapper2 = new LambdaQueryWrapper<>();
  484. lambdaQueryWrapper2.eq(PmBidFailure::getDemandId, demandId).orderByDesc(PmBidFailure::getBidFailureTime);
  485. List<PmBidFailure> pmBidFailureList = this.pmBidFailureService.list(lambdaQueryWrapper2);
  486. if (!ObjectUtils.isEmpty(pmBidFailureList)) {
  487. List<PmBidFailureResVo> pmBidFailureResVoList = new ArrayList<>();
  488. List<PmCallQuestionResVo> pmCallQuestionBidFailureResVoList = new ArrayList<>();
  489. List<SysFileInfo> pmBidFailureFileInfos = new ArrayList<>();
  490. List<SysFileInfo> pmCallRequestBidFailureFileInfos = new ArrayList<>();
  491. for (PmBidFailure pmBidFailure : pmBidFailureList) {
  492. PmBidFailureResVo pmBidFailureResVo = new PmBidFailureResVo();
  493. BeanUtils.copyProperties(pmBidFailure, pmBidFailureResVo);
  494. pmBidFailureResVoList.add(pmBidFailureResVo);
  495. //流标文件
  496. List<SysFileInfo> fileInfos = getSysFileInfoList(pmBidFailure.getId(), SysFileRefEnum.PM_BID_FAILURE_FILE.getType());
  497. if (!ObjectUtils.isEmpty(fileInfos)) {
  498. pmBidFailureFileInfos.addAll(fileInfos);
  499. }
  500. if ("1".equals(pmBidFailure.getCallQuestion())) { //有质疑
  501. PmCallQuestionResVo pmCallQuestionResVo = new PmCallQuestionResVo();
  502. pmCallQuestionResVo.setCallQuestion(pmBidFailure.getCallQuestion());
  503. pmCallQuestionResVo.setCallQuestionTime(pmBidFailure.getCallQuestionTime());
  504. pmCallQuestionBidFailureResVoList.add(pmCallQuestionResVo);
  505. //流废标质疑文件
  506. List<SysFileInfo> fileInfos2 = getSysFileInfoList(pmBidFailure.getId(), SysFileRefEnum.PM_BID_FAILURE_CALL_QUESTION.getType());
  507. if (!ObjectUtils.isEmpty(fileInfos2)) {
  508. pmCallRequestBidFailureFileInfos.addAll(fileInfos2);
  509. }
  510. }
  511. }
  512. pmPurchaseExecutionResVo.setPmBidFailureResVoList(pmBidFailureResVoList);
  513. pmPurchaseExecutionResVo.setPmBidFailureFileInfos(pmBidFailureFileInfos);
  514. //流废标处置
  515. pmPurchaseExecutionResVo.setPmCallQuestionBidFailureResVoList(pmCallQuestionBidFailureResVoList);
  516. pmPurchaseExecutionResVo.setPmCallRequestBidFailureFileInfos(pmCallRequestBidFailureFileInfos);
  517. }
  518. //中标通知书
  519. List<SysFileInfo> pmBidWinningNotificationFileInfos = getSysFileInfoList(vo.getDemandId(), SysFileRefEnum.PM_BID_WINNING_NOTIFICATION.getType());
  520. pmPurchaseExecutionResVo.setFileInfos(pmBidWinningNotificationFileInfos);
  521. vo.setUpAcceptanceTime(pmDemand.getUpAcceptanceTime());
  522. vo.setPmPurchaseExecutionResVo(pmPurchaseExecutionResVo);
  523. }
  524. /**
  525. * 查询采购需求列表
  526. *
  527. * @param pmDemandReqVo
  528. * @return 采购需求
  529. */
  530. @Override
  531. public IPage<PmDemandResVo> selectPmDemandList(PmDemandReqVo pmDemandReqVo, int reqType) {
  532. LambdaQueryWrapper<PmDemand> lw = new LambdaQueryWrapper<>();
  533. SysUser sysUser = userService.selectUserById(SecurityUtils.getUserId());
  534. List<PmAuditDeptRef> list = new ArrayList<>();
  535. LambdaQueryWrapper<PmAuditDeptRef> l = new LambdaQueryWrapper<>();
  536. l.eq(PmAuditDeptRef::getDeptId, SecurityUtils.getDeptId());
  537. l.eq(PmAuditDeptRef::getRefType, "2");
  538. list = pmAuditDeptRefService.list(l);
  539. if (!pmDemandReqVo.getIsAdmin()) {
  540. if (1 == reqType) {
  541. if (!ObjectUtils.isEmpty(list)) {
  542. lw.in(PmDemand::getDemandId, list.stream().map(PmAuditDeptRef::getRefId).collect(Collectors.toSet()));
  543. }
  544. } else if (2 == reqType) {
  545. lw.in(PmDemand::getDemandId, list.stream().map(PmAuditDeptRef::getRefId).collect(Collectors.toSet()));
  546. lw.eq(PmDemand::getPurchaseDeptId, SecurityUtils.getDeptId());
  547. } else if (3 == reqType) {
  548. //采购执行管理中,本单位超额项目交给上级处理,本单位不处理。
  549. if (!ObjectUtils.isEmpty(list)) {
  550. // 如果有上级单位存在,本单位不处理
  551. SysDept sysDept = deptMapper.selectDeptById(sysUser.getDeptId());
  552. //本单位所有参与审核的项目id
  553. Set<Long> refList = new HashSet<>();
  554. for (PmAuditDeptRef deptRef : list) {
  555. refList.add(deptRef.getRefId());
  556. }
  557. //上级参与审核的项目
  558. List<Long> refListf = new ArrayList<>();
  559. List<PmAuditDeptRef> listf = new ArrayList<>();
  560. if (sysDept.getParentId() != 0) {
  561. LambdaQueryWrapper<PmAuditDeptRef> lf = new LambdaQueryWrapper<>();
  562. lf.eq(PmAuditDeptRef::getDeptId, sysDept.getParentId());
  563. lf.eq(PmAuditDeptRef::getRefType, "2");
  564. listf = pmAuditDeptRefService.list(lf);
  565. //上级参与审核的项目id
  566. refListf = listf.stream().map(PmAuditDeptRef::getRefId).collect(Collectors.toList());
  567. }
  568. //取集合差集,只处理差集中的数据
  569. if (!ObjectUtils.isEmpty(refListf)) {
  570. refList.removeAll(refListf);
  571. }
  572. //为空就返回空
  573. if (ObjectUtils.isEmpty(refList) && !SysUser.isAdmin(SecurityUtils.getUserId())) {
  574. lw.in(PmDemand::getDemandId, -1);
  575. } else if (!ObjectUtils.isEmpty(refList) && !SysUser.isAdmin(SecurityUtils.getUserId())) {
  576. lw.in(PmDemand::getDemandId, refList);
  577. }
  578. }
  579. } else {
  580. lw.eq(PmDemand::getCreateBy, SecurityUtils.getUserId());
  581. //lw.eq(PmDemand::getPurchaseDeptId, SecurityUtils.getDeptId());
  582. }
  583. }
  584. if (!StringUtils.isBlank(pmDemandReqVo.getProjectName())) {
  585. lw.like(PmDemand::getProjectName, "%" + pmDemandReqVo.getProjectName() + "%");
  586. }
  587. if (!StringUtils.isBlank(pmDemandReqVo.getPurchaseServices())) {
  588. lw.eq(PmDemand::getPurchaseServices, pmDemandReqVo.getPurchaseServices());
  589. }
  590. if (!ObjectUtils.isEmpty(pmDemandReqVo.getProjectStatus())) {
  591. lw.eq(PmDemand::getProjectStatus, pmDemandReqVo.getProjectStatus());
  592. }
  593. if (!ObjectUtils.isEmpty(pmDemandReqVo.getWarnStatus())) {
  594. lw.eq(PmDemand::getWarnStatus, pmDemandReqVo.getWarnStatus());
  595. }
  596. if (!ObjectUtils.isEmpty(pmDemandReqVo.getIsExcess())) {
  597. lw.eq(PmDemand::getIsExcess, pmDemandReqVo.getIsExcess());
  598. }
  599. if (!StringUtils.isBlank(pmDemandReqVo.getBeginDate())) {
  600. lw.apply("(plan_demand_sub_time >= '" + pmDemandReqVo.getBeginDate() + "' or plan_purchase_finish_time >= '" + pmDemandReqVo.getBeginDate() + "' or plan_deliver_time >= '" + pmDemandReqVo.getBeginDate() + "' )");
  601. }
  602. if (!StringUtils.isBlank(pmDemandReqVo.getEndDate())) {
  603. lw.apply("(plan_demand_sub_time <= '" + pmDemandReqVo.getEndDate() + "' or plan_purchase_finish_time <= '" + pmDemandReqVo.getEndDate() + "' or plan_deliver_time <= '" + pmDemandReqVo.getEndDate() + "' )");
  604. }
  605. if (reqType == 1) { //需求审核单位列表
  606. lw.apply("(project_status >=6 )");
  607. } else if (reqType == 2) { //任务下达列表
  608. lw.apply("(project_status >=8 )");
  609. } else if (reqType == 3) { //采购执行列表
  610. lw.apply("(project_status >=9 )");
  611. } else if (reqType == 4) { //合同信息列表
  612. lw.apply("(project_status >=19 )");
  613. } else if (reqType == 5) { //项目建设列表
  614. lw.apply("(project_status >=20 )");
  615. }
  616. lw.last(" order by project_status, plan_demand_sub_time");
  617. IPage<PmDemand> pageRes = this.page(new Page<>(pmDemandReqVo.getPageNum(), pmDemandReqVo.getPageSize()), lw);
  618. IPage<PmDemandResVo> results = new Page<>(pageRes.getCurrent(), pageRes.getSize(), pageRes.getTotal());
  619. if (pageRes.getRecords() != null && pageRes.getRecords().size() > 0) {
  620. List<PmDemandResVo> pmDemandResVos = demandChangeTo(pageRes.getRecords());
  621. for (PmDemandResVo vo : pmDemandResVos) {
  622. if (1 == reqType) {
  623. // 根据项目id 和 部门id 和 参数类型 获取 部门级别
  624. List<PmAuditDeptRef> collect = list.stream()
  625. .filter(o -> o.getRefId().equals(vo.getDemandId()))
  626. .collect(Collectors.toList());
  627. if (!ObjectUtils.isEmpty(collect)) {
  628. String deptLevel = collect.get(0).getDeptLevel();
  629. // 根据项目id 和 参数类型 获取 所有审核数据
  630. LambdaQueryWrapper<PmAuditDeptRef> ll = new LambdaQueryWrapper<>();
  631. ll.eq(PmAuditDeptRef::getRefId, vo.getDemandId());
  632. ll.eq(PmAuditDeptRef::getRefType, "2");
  633. List<PmAuditDeptRef> listl = pmAuditDeptRefService.list(l);
  634. // 判断当前用户是否有审核权限
  635. boolean flay = true;
  636. List<PmAuditDeptRef> collect1 = listl.stream()
  637. .filter(pmAuditDeptRef -> pmAuditDeptRef.getRefId().equals(vo.getDemandId()))
  638. .collect(Collectors.toList());
  639. for (PmAuditDeptRef pmAuditDeptRef : collect1) {
  640. if (pmAuditDeptRef.getDeptLevel().compareTo(deptLevel) > 0
  641. && pmAuditDeptRef.getStatus().equals(Integer.parseInt("0"))) {
  642. flay = false;
  643. } else if (pmAuditDeptRef.getDeptLevel().compareTo(deptLevel) == 0
  644. && pmAuditDeptRef.getStatus().equals(Integer.parseInt("1"))) {
  645. flay = false;
  646. }
  647. }
  648. vo.setFlay(flay);
  649. }
  650. }
  651. LambdaQueryWrapper<PmExpertFeedback> pmExpertFeedbackLambdaQueryWrapper = new LambdaQueryWrapper<>();
  652. pmExpertFeedbackLambdaQueryWrapper.eq(PmExpertFeedback::getDemandId, vo.getDemandId());
  653. PmExpertFeedback pmExpertFeedback = this.pmExpertFeedbackService.getOne(pmExpertFeedbackLambdaQueryWrapper);
  654. if (pmExpertFeedback != null) {
  655. vo.setProjectNumber(pmExpertFeedback.getProjectNumber());
  656. vo.setDocumentReviewTime(pmExpertFeedback.getDocumentReviewTime());
  657. }
  658. LambdaQueryWrapper<PmProcurementDocumentsReview> pmProcurementDocumentsReviewLambdaQueryWrapper = new LambdaQueryWrapper<>();
  659. pmProcurementDocumentsReviewLambdaQueryWrapper.eq(PmProcurementDocumentsReview::getDemandId, vo.getDemandId());
  660. PmProcurementDocumentsReview pmProcurementDocumentsReview = this.pmProcurementDocumentsReviewService.getOne(pmProcurementDocumentsReviewLambdaQueryWrapper);
  661. if (pmProcurementDocumentsReview != null) {
  662. vo.setProcurementOfficeApprovalTime(pmProcurementDocumentsReview.getProcurementOfficeApprovalTime());
  663. }
  664. if (Integer.parseInt(vo.getProjectStatus()) > 12 && Integer.parseInt(vo.getProjectStatus()) != 18) {
  665. LambdaQueryWrapper<PmReleaseAnnouncement> pmReleaseAnnouncementLambdaQueryWrapper = new LambdaQueryWrapper<>();
  666. pmReleaseAnnouncementLambdaQueryWrapper.eq(PmReleaseAnnouncement::getDemandId, vo.getDemandId())
  667. .orderByDesc(PmReleaseAnnouncement::getReleaseTime)
  668. .last(" limit 1");
  669. PmReleaseAnnouncement pmReleaseAnnouncement = this.pmReleaseAnnouncementService.getOne(pmReleaseAnnouncementLambdaQueryWrapper);
  670. if (pmReleaseAnnouncement != null) {
  671. vo.setAnnouncementReleaseTime(pmReleaseAnnouncement.getReleaseTime());
  672. vo.setTenderOpenTime(pmReleaseAnnouncement.getTenderOpenTime());
  673. }
  674. }
  675. if (Integer.parseInt(vo.getProjectStatus()) > 15 && Integer.parseInt(vo.getProjectStatus()) != 16 && Integer.parseInt(vo.getProjectStatus()) != 18) {
  676. LambdaQueryWrapper<PmBidWinning> pmBidWinningLambdaQueryWrapper = new LambdaQueryWrapper<>();
  677. pmBidWinningLambdaQueryWrapper.eq(PmBidWinning::getDemandId, vo.getDemandId()).eq(PmBidWinning::getStatus, BidWinningStatus.NORMAL.getCode())
  678. .orderByDesc(PmBidWinning::getBidAnnouncementTime)
  679. .last(" limit 1");
  680. PmBidWinning pmBidWinning = this.pmBidWinningService.getOne(pmBidWinningLambdaQueryWrapper);
  681. if (pmBidWinning != null) {
  682. vo.setBidAnnouncementTime(pmBidWinning.getBidAnnouncementTime());
  683. }
  684. }
  685. }
  686. results.setRecords(pmDemandResVos);
  687. }
  688. return results;
  689. }
  690. /**
  691. * 查询采购需求列表
  692. *
  693. * @param pmDemandReqVo
  694. * @return 采购需求
  695. */
  696. @Override
  697. public List<PmDemandResVo> selectPmDemandListDe(PmDemandReqVo pmDemandReqVo) {
  698. LambdaQueryWrapper<PmDemand> lw = new LambdaQueryWrapper<>();
  699. SysUser sysUser = userService.selectUserById(SecurityUtils.getUserId());
  700. List<PmAuditDeptRef> list = new ArrayList<>();
  701. LambdaQueryWrapper<PmAuditDeptRef> l = new LambdaQueryWrapper<>();
  702. l.eq(PmAuditDeptRef::getDeptId, SecurityUtils.getDeptId());
  703. l.eq(PmAuditDeptRef::getRefType, "2");
  704. list = pmAuditDeptRefService.list(l);
  705. if (!pmDemandReqVo.getIsAdmin()) {
  706. if (!ObjectUtils.isEmpty(list)) {
  707. lw.eq(PmDemand::getPurchaseDeptId, SecurityUtils.getDeptId());
  708. lw.in(PmDemand::getDemandId, list.stream().map(PmAuditDeptRef::getRefId).collect(Collectors.toSet()));
  709. }
  710. }
  711. if (!StringUtils.isBlank(pmDemandReqVo.getProjectName())) {
  712. lw.like(PmDemand::getProjectName, "%" + pmDemandReqVo.getProjectName() + "%");
  713. }
  714. if (!StringUtils.isBlank(pmDemandReqVo.getPurchaseServices())) {
  715. lw.eq(PmDemand::getPurchaseServices, pmDemandReqVo.getPurchaseServices());
  716. }
  717. if (!ObjectUtils.isEmpty(pmDemandReqVo.getProjectStatus())) {
  718. lw.eq(PmDemand::getProjectStatus, pmDemandReqVo.getProjectStatus());
  719. }
  720. if (!ObjectUtils.isEmpty(pmDemandReqVo.getWarnStatus())) {
  721. lw.eq(PmDemand::getWarnStatus, pmDemandReqVo.getWarnStatus());
  722. }
  723. if (!ObjectUtils.isEmpty(pmDemandReqVo.getIsExcess())) {
  724. lw.eq(PmDemand::getIsExcess, pmDemandReqVo.getIsExcess());
  725. }
  726. if (!StringUtils.isBlank(pmDemandReqVo.getBeginDate())) {
  727. lw.apply("(plan_demand_sub_time >= '" + pmDemandReqVo.getBeginDate() + "' or plan_purchase_finish_time >= '" + pmDemandReqVo.getBeginDate() + "' or plan_deliver_time >= '" + pmDemandReqVo.getBeginDate() + "' )");
  728. }
  729. if (!StringUtils.isBlank(pmDemandReqVo.getEndDate())) {
  730. lw.apply("(plan_demand_sub_time <= '" + pmDemandReqVo.getEndDate() + "' or plan_purchase_finish_time <= '" + pmDemandReqVo.getEndDate() + "' or plan_deliver_time <= '" + pmDemandReqVo.getEndDate() + "' )");
  731. }
  732. lw.apply("(project_status >=8 )");
  733. lw.last(" order by project_status, plan_demand_sub_time");
  734. List<PmDemand> demandList = pmDemandMapper.selectList(lw);
  735. List<PmDemandResVo> pmDemandResVosTwo = new LinkedList<>();
  736. if (!ObjectUtils.isEmpty(demandList)) {
  737. List<PmDemandResVo> pmDemandResVos = demandChangeTo(demandList);
  738. for (PmDemandResVo vo : pmDemandResVos) {
  739. // 根据项目id 和 部门id 和 参数类型 获取 部门级别
  740. List<PmAuditDeptRef> collect = list.stream()
  741. .filter(o -> o.getRefId().equals(vo.getDemandId()))
  742. .collect(Collectors.toList());
  743. if (!ObjectUtils.isEmpty(collect)) {
  744. String deptLevel = collect.get(0).getDeptLevel();
  745. // 根据项目id 和 参数类型 获取 所有审核数据
  746. LambdaQueryWrapper<PmAuditDeptRef> ll = new LambdaQueryWrapper<>();
  747. ll.eq(PmAuditDeptRef::getRefId, vo.getDemandId());
  748. ll.eq(PmAuditDeptRef::getRefType, "2");
  749. List<PmAuditDeptRef> listl = pmAuditDeptRefService.list(l);
  750. // 判断当前用户是否有审核权限
  751. boolean flay = true;
  752. List<PmAuditDeptRef> collect1 = listl.stream()
  753. .filter(pmAuditDeptRef -> pmAuditDeptRef.getRefId().equals(vo.getDemandId()))
  754. .collect(Collectors.toList());
  755. for (PmAuditDeptRef pmAuditDeptRef : collect1) {
  756. if (pmAuditDeptRef.getDeptLevel().compareTo(deptLevel) > 0
  757. && pmAuditDeptRef.getStatus().equals(Integer.parseInt("0"))) {
  758. flay = false;
  759. } else if (pmAuditDeptRef.getDeptLevel().compareTo(deptLevel) == 0
  760. && pmAuditDeptRef.getStatus().equals(Integer.parseInt("1"))) {
  761. flay = false;
  762. }
  763. }
  764. vo.setFlay(flay);
  765. if (flay == true || vo.getPurchaseDeptId().equals(SecurityUtils.getDeptId())) {
  766. LambdaQueryWrapper<PmExpertFeedback> pmExpertFeedbackLambdaQueryWrapper = new LambdaQueryWrapper<>();
  767. pmExpertFeedbackLambdaQueryWrapper.eq(PmExpertFeedback::getDemandId, vo.getDemandId());
  768. PmExpertFeedback pmExpertFeedback = this.pmExpertFeedbackService.getOne(pmExpertFeedbackLambdaQueryWrapper);
  769. if (pmExpertFeedback != null) {
  770. vo.setProjectNumber(pmExpertFeedback.getProjectNumber());
  771. vo.setDocumentReviewTime(pmExpertFeedback.getDocumentReviewTime());
  772. }
  773. LambdaQueryWrapper<PmProcurementDocumentsReview> pmProcurementDocumentsReviewLambdaQueryWrapper = new LambdaQueryWrapper<>();
  774. pmProcurementDocumentsReviewLambdaQueryWrapper.eq(PmProcurementDocumentsReview::getDemandId, vo.getDemandId());
  775. PmProcurementDocumentsReview pmProcurementDocumentsReview = this.pmProcurementDocumentsReviewService.getOne(pmProcurementDocumentsReviewLambdaQueryWrapper);
  776. if (pmProcurementDocumentsReview != null) {
  777. vo.setProcurementOfficeApprovalTime(pmProcurementDocumentsReview.getProcurementOfficeApprovalTime());
  778. }
  779. if (Integer.parseInt(vo.getProjectStatus()) > 12 && Integer.parseInt(vo.getProjectStatus()) != 18) {
  780. LambdaQueryWrapper<PmReleaseAnnouncement> pmReleaseAnnouncementLambdaQueryWrapper = new LambdaQueryWrapper<>();
  781. pmReleaseAnnouncementLambdaQueryWrapper.eq(PmReleaseAnnouncement::getDemandId, vo.getDemandId())
  782. .orderByDesc(PmReleaseAnnouncement::getReleaseTime)
  783. .last(" limit 1");
  784. PmReleaseAnnouncement pmReleaseAnnouncement = this.pmReleaseAnnouncementService.getOne(pmReleaseAnnouncementLambdaQueryWrapper);
  785. if (pmReleaseAnnouncement != null) {
  786. vo.setAnnouncementReleaseTime(pmReleaseAnnouncement.getReleaseTime());
  787. vo.setTenderOpenTime(pmReleaseAnnouncement.getTenderOpenTime());
  788. }
  789. }
  790. if (Integer.parseInt(vo.getProjectStatus()) > 15 && Integer.parseInt(vo.getProjectStatus()) != 16 && Integer.parseInt(vo.getProjectStatus()) != 18) {
  791. LambdaQueryWrapper<PmBidWinning> pmBidWinningLambdaQueryWrapper = new LambdaQueryWrapper<>();
  792. pmBidWinningLambdaQueryWrapper.eq(PmBidWinning::getDemandId, vo.getDemandId()).eq(PmBidWinning::getStatus, BidWinningStatus.NORMAL.getCode())
  793. .orderByDesc(PmBidWinning::getBidAnnouncementTime)
  794. .last(" limit 1");
  795. PmBidWinning pmBidWinning = this.pmBidWinningService.getOne(pmBidWinningLambdaQueryWrapper);
  796. if (pmBidWinning != null) {
  797. vo.setBidAnnouncementTime(pmBidWinning.getBidAnnouncementTime());
  798. }
  799. }
  800. pmDemandResVosTwo.add(vo);
  801. }
  802. }
  803. }
  804. }
  805. return pmDemandResVosTwo;
  806. }
  807. /**
  808. * 需求建档
  809. *
  810. * @param vo 采购需求
  811. * @return 结果
  812. */
  813. @Override
  814. @Transactional(rollbackFor = Exception.class)
  815. public boolean bookBuilding(PmBookBuildingReqVo vo) throws Exception {
  816. PmDemand pmDemand = this.getById(vo.getDemandId());
  817. LambdaQueryWrapper<PmBookBuilding> lambdaQueryWrapper = new LambdaQueryWrapper<>();
  818. lambdaQueryWrapper.eq(PmBookBuilding::getDemandId, vo.getDemandId());
  819. PmBookBuilding pmBookBuilding = pmBookBuildingService.getOne(lambdaQueryWrapper);
  820. if (pmBookBuilding != null) {
  821. vo.setId(pmBookBuilding.getId());
  822. BeanUtils.copyProperties(vo, pmBookBuilding);
  823. pmBookBuilding.setUpdateBy(vo.getUpdateBy());
  824. pmBookBuilding.setUpdateTime(new Date());
  825. } else {
  826. pmBookBuilding = new PmBookBuilding();
  827. BeanUtils.copyProperties(vo, pmBookBuilding);
  828. pmBookBuilding.setCreateBy(vo.getUpdateBy());
  829. pmBookBuilding.setCreateTime(new Date());
  830. pmBookBuilding.setUpdateBy(vo.getUpdateBy());
  831. pmBookBuilding.setUpdateTime(pmBookBuilding.getCreateTime());
  832. }
  833. if (pmBookBuildingService.saveOrUpdate(pmBookBuilding)) {
  834. List<SysFileRef> sysFileRefs = vo.getSysFileRefs();
  835. uploadFile(pmBookBuilding.getId(), SysFileRefEnum.PM_BOOK_BUILDING.getType(), sysFileRefs, vo.getUpdateBy());
  836. PmDemand pmDemandUpdate = new PmDemand();
  837. pmDemandUpdate.setDemandId(pmDemand.getDemandId());
  838. pmDemandUpdate.setProjectStatus(PmProjectStatus.DEMAND_WAIT_COMMIT.getCode());
  839. pmDemandUpdate.setEvaluation(vo.getBudgetAmount());
  840. pmDemandUpdate.setProjectType(vo.getProjectType());
  841. pmDemandUpdate.setPurchaseMode(vo.getPurchaseMode());
  842. pmDemandUpdate.setUpdateBy(vo.getUpdateBy());
  843. pmDemandUpdate.setUpdateTime(DateUtils.getNowDate());
  844. return this.updateById(pmDemandUpdate);
  845. } else {
  846. return false;
  847. }
  848. }
  849. private List<SysFileInfo> getSysFileInfoList(Long redId, Integer type) {
  850. HashMap<String, Object> map = new HashMap<>();
  851. map.put("red_id", redId);
  852. map.put("type", type);
  853. List<SysFileRef> fileRefs = sysFileRefService.listByMap(map);
  854. if (!ObjectUtils.isEmpty(fileRefs)) {
  855. List<SysFileInfo> fileInfos = new ArrayList<>();
  856. for (SysFileRef ref : fileRefs) {
  857. SysFileInfo fileInfo = fileService.getById(ref.getFileId());
  858. fileInfos.add(fileInfo);
  859. }
  860. return fileInfos;
  861. } else {
  862. return null;
  863. }
  864. }
  865. /**
  866. * 提交采购需求
  867. *
  868. * @param pmDemandReqVo
  869. * @return 结果
  870. */
  871. @Override
  872. @Transactional(rollbackFor = Exception.class)
  873. public boolean commit(PmDemandReqVo pmDemandReqVo) {
  874. PmDemand pmDemand = this.getById(pmDemandReqVo.getDemandId());
  875. SysUser sysUser = userService.selectUserById(SecurityUtils.getUserId());
  876. Long deptId = sysUser.getDeptId();
  877. pmAuditDeptRefService.insertPmAuditDeptRefs(pmDemandReqVo.getDemandId()
  878. , "2"
  879. , deptId
  880. , BigDecimal.valueOf(pmDemand.getEvaluation())
  881. , sysUser.getUserId()
  882. , pmDemand.getProjectType());
  883. PmDemand pmDemandUpdate = new PmDemand();
  884. pmDemandUpdate.setDemandId(pmDemand.getDemandId());
  885. pmDemandUpdate.setProjectStatus(PmProjectStatus.DEMAND_WAIT_AUDIT.getCode());
  886. pmDemandUpdate.setRealDemandCommitTime(DateUtils.getNowDate());
  887. pmDemandUpdate.setUpdateBy(pmDemandReqVo.getUpdateBy());
  888. pmDemandUpdate.setUpdateTime(DateUtils.getNowDate());
  889. List<SysDictData> data = iSysDictTypeService.selectDictDataByType("alert_time_setting");
  890. int setting2 = Integer.parseInt(data.stream().filter(item -> item.getDictLabel().equals("计划完成时间")).collect(Collectors.toList()).get(0).getDictValue());
  891. log.info("******** setting2 == " + setting2);
  892. //采购完成时间:根据数据阈值中设置的采购完成时间进行判断,进行预警
  893. int diff2 = DateUtils.differentDaysByMillisecond(pmDemand.getPlanPurchaseFinishTime(), DateUtils.parseDate(DateUtils.getDate()));
  894. if (ObjectUtils.isEmpty(pmDemand.getRealPurchaseFinishTime()) && diff2 > 0 && diff2 <= setting2) {
  895. log.info("******** 采购完成预警: " + pmDemand.getProjectName());
  896. pmDemandUpdate.setWarnStatus(WarnStatus.PURCHASE_FINISH_WARNING.getCode());
  897. } else if (ObjectUtils.isEmpty(pmDemand.getRealPurchaseFinishTime()) && pmDemand.getPlanPurchaseFinishTime().getTime() < System.currentTimeMillis()) {
  898. log.info("******** 采购完成逾期: " + pmDemand.getProjectName());
  899. pmDemandUpdate.setWarnStatus(WarnStatus.PURCHASE_FINISH_EX.getCode());
  900. this.updateById(pmDemandUpdate);
  901. } else {
  902. pmDemandUpdate.setWarnStatus(WarnStatus.NORMAL.getCode());
  903. }
  904. return this.updateById(pmDemandUpdate);
  905. }
  906. /**
  907. * 查看流程图
  908. *
  909. * @param demandId 采购需求主键
  910. * @return 采购需求
  911. */
  912. @Override
  913. public Object viewFlowChart(Long demandId) {
  914. PmDemand pmDemand = this.getById(demandId);
  915. String projectStatus = String.valueOf(pmDemand.getProjectStatus());
  916. String moduleName = null;
  917. if (PmProjectStatus.DEMAND_WAIT_FILL.getCode().equals(projectStatus)
  918. || PmProjectStatus.DEMAND_AUDIT_RETURN.getCode().equals(projectStatus)
  919. || PmProjectStatus.WASTE_BID_RETURN.getCode().equals(projectStatus)) {
  920. moduleName = "需求填制";
  921. } else if (PmProjectStatus.DEMAND_WAIT_COMMIT.getCode().equals(projectStatus)) {
  922. moduleName = "需求提交";
  923. } else if (PmProjectStatus.DEMAND_WAIT_AUDIT.getCode().equals(projectStatus)) {
  924. moduleName = "需求审核";
  925. } else if (PmProjectStatus.TASK_WAIT_RELEASE.getCode().equals(projectStatus)) {
  926. moduleName = "任务下达";
  927. } else if (PmProjectStatus.PURCHASE_DEMAND_DOCKING.getCode().equals(projectStatus)) {
  928. moduleName = "选取代理";
  929. } else if (PmProjectStatus.EXPERT_FEEDBACK.getCode().equals(projectStatus)) {
  930. moduleName = "上传意见反馈单";
  931. } else if (PmProjectStatus.PROCUREMENT_DOCUMENTS_REVIEW.getCode().equals(projectStatus)) {
  932. moduleName = "上传招标文件审批表";
  933. } else if (PmProjectStatus.PROCUREMENT_ANNOUNCEMENT.getCode().equals(projectStatus)) {
  934. moduleName = "采购公告发布";
  935. } else if (PmProjectStatus.PRE_BID_QUERY.getCode().equals(projectStatus)) {
  936. moduleName = "标前质疑投诉";
  937. } else if (PmProjectStatus.WAIT_OPEN_BID.getCode().equals(projectStatus)) {
  938. moduleName = "填写专家信息,开评标";
  939. } else if (PmProjectStatus.BID_RESULT_ANNOUNCEMENT.getCode().equals(projectStatus) || PmProjectStatus.WASTE_BID_HANDLE.getCode().equals(projectStatus)) {
  940. moduleName = "评标结果公告";
  941. } else if (PmProjectStatus.POST_BID_QUERY.getCode().equals(projectStatus)) {
  942. moduleName = "质疑处理,上传中标通知书";
  943. } else if (PmProjectStatus.CONTRACT_WAIT_FILL.getCode().equals(projectStatus)) {
  944. moduleName = "合同填制";
  945. } else if (PmProjectStatus.UNDER_CONSTRUCTION.getCode().equals(projectStatus)) {
  946. moduleName = "建设文档填制";
  947. } else if (PmProjectStatus.COMPLETION_CONSTRUCTION.getCode().equals(projectStatus)) {
  948. moduleName = "项目归档";
  949. }
  950. return moduleName;
  951. }
  952. /**
  953. * 审核采购需求通过
  954. *
  955. * @param pmDemandReqVo
  956. * @return 结果
  957. */
  958. @Override
  959. @Transactional(rollbackFor = Exception.class)
  960. public boolean reviewTo(PmDemandReqVo pmDemandReqVo) {
  961. PmDemand pmDemand = this.getById(pmDemandReqVo.getDemandId());
  962. PmDemand pmDemandUpdate = new PmDemand();
  963. pmDemandUpdate.setDemandId(pmDemand.getDemandId());
  964. SysUser sysUser = userService.selectUserById(SecurityUtils.getUserId());
  965. Long deptId = sysUser.getDeptId();
  966. SysDept sysDept = deptMapper.selectDeptById(deptId);
  967. String[] ancestors = sysDept.getAncestors().split(",");
  968. String deptLevel = null;
  969. if (ancestors.length == 2) { //C级
  970. deptLevel = "C";
  971. } else if (ancestors.length == 3) { //B级
  972. deptLevel = "B";
  973. } else if (ancestors.length == 4) { //A级
  974. deptLevel = "A";
  975. }
  976. LambdaQueryWrapper<PmAuditDeptRef> lw = new LambdaQueryWrapper();
  977. lw.eq(PmAuditDeptRef::getRefId, pmDemandReqVo.getDemandId());
  978. lw.eq(PmAuditDeptRef::getRefType, "2");
  979. List<PmAuditDeptRef> list = pmAuditDeptRefService.list(lw);
  980. boolean flay = true;
  981. if (!ObjectUtils.isEmpty(list)) {
  982. for (PmAuditDeptRef pmAuditDeptRef : list) {
  983. // 判断 deptLevel 是否还有更高的 且是 待审核的数据
  984. if (pmAuditDeptRef.getDeptLevel().compareTo(deptLevel) > 0
  985. && pmAuditDeptRef.getStatus().equals(Integer.parseInt("0"))) {
  986. flay = false;
  987. }
  988. // 更新当前 deptLevel 级别的审核状态
  989. if (pmAuditDeptRef.getDeptLevel().compareTo(deptLevel) == 0) {
  990. pmAuditDeptRef.setStatus(1);
  991. pmAuditDeptRefService.updateById(pmAuditDeptRef);
  992. }
  993. }
  994. }
  995. if (flay) {
  996. pmDemandUpdate.setProjectStatus(PmProjectStatus.TASK_WAIT_RELEASE.getCode());
  997. }
  998. List<SysFileRef> sysFileRefs = pmDemandReqVo.getSysFileRefs();
  999. uploadFile(pmDemandReqVo.getDemandId(), SysFileRefEnum.PM_DEMAND_EXAMINE.getType(), sysFileRefs, pmDemandReqVo.getUpdateBy());
  1000. pmDemandUpdate.setUpdateBy(pmDemandReqVo.getUpdateBy());
  1001. pmDemandUpdate.setUpdateTime(DateUtils.getNowDate());
  1002. pmDemandUpdate.setAuditTime(DateUtils.getNowDate());
  1003. return this.updateById(pmDemandUpdate);
  1004. }
  1005. /**
  1006. * 审核采购需求退回
  1007. *
  1008. * @param pmDemandReqVo
  1009. * @return 结果
  1010. */
  1011. @Override
  1012. @Transactional(rollbackFor = Exception.class)
  1013. public boolean reviewReturn(PmDemandReqVo pmDemandReqVo) {
  1014. UpdateWrapper<PmDemand> updateWrapper = new UpdateWrapper<>();
  1015. updateWrapper.lambda().eq(PmDemand::getDemandId, pmDemandReqVo.getDemandId())
  1016. .set(PmDemand::getProjectStatus, PmProjectStatus.DEMAND_AUDIT_RETURN.getCode())
  1017. .set(PmDemand::getAdjustReason, pmDemandReqVo.getRefuseReason())
  1018. .set(PmDemand::getRealDemandCommitTime, null)
  1019. .set(PmDemand::getUpdateBy, pmDemandReqVo.getUpdateBy())
  1020. .set(PmDemand::getUpdateTime, DateUtils.getNowDate())
  1021. .set(PmDemand::getAuditTime, DateUtils.getNowDate());
  1022. LambdaQueryWrapper<PmAuditDeptRef> lw = new LambdaQueryWrapper();
  1023. lw.eq(PmAuditDeptRef::getRefId, pmDemandReqVo.getDemandId());
  1024. lw.eq(PmAuditDeptRef::getRefType, "2");
  1025. pmAuditDeptRefService.remove(lw);
  1026. return this.update(updateWrapper);
  1027. }
  1028. /**
  1029. * 下达任务
  1030. *
  1031. * @param pmDemandReqVo
  1032. * @return 结果
  1033. */
  1034. @Override
  1035. @Transactional(rollbackFor = Exception.class)
  1036. public boolean releaseTask(PmDemandReqVo pmDemandReqVo) {
  1037. PmDemand pmDemand = new PmDemand();
  1038. pmDemand.setDemandId(pmDemandReqVo.getDemandId());
  1039. pmDemand.setTaskReleaseTime(pmDemandReqVo.getTaskReleaseTime());
  1040. pmDemand.setProjectStatus(PmProjectStatus.PURCHASE_DEMAND_DOCKING.getCode());
  1041. List<SysFileRef> sysFileRefs = pmDemandReqVo.getSysFileRefs();
  1042. uploadFile(pmDemandReqVo.getDemandId(), SysFileRefEnum.PM_TAST_RELEASE.getType(), sysFileRefs, pmDemandReqVo.getUpdateBy());
  1043. pmDemand.setUpdateBy(pmDemandReqVo.getUpdateBy());
  1044. pmDemand.setUpdateTime(DateUtils.getNowDate());
  1045. pmDemand.setAuditTime(DateUtils.getNowDate());
  1046. return this.updateById(pmDemand);
  1047. }
  1048. @Override
  1049. @Transactional(rollbackFor = Exception.class)
  1050. public boolean uploadFile(Long redId, Integer fileType, List<SysFileRef> sysFileRefs, String upateBy, boolean delOld) {
  1051. if (!ObjectUtils.isEmpty(sysFileRefs)) {
  1052. // 删关联
  1053. LambdaQueryWrapper<SysFileRef> lw = new LambdaQueryWrapper<>();
  1054. lw.eq(SysFileRef::getRedId, redId);
  1055. lw.eq(SysFileRef::getType, fileType);
  1056. sysFileRefMapper.delete(lw);
  1057. //添加新的
  1058. for (SysFileRef ref : sysFileRefs) {
  1059. if (ref.getFileId() == null) {
  1060. continue;
  1061. }
  1062. ref.setRedId(redId);
  1063. ref.setType(fileType);
  1064. ref.setCreated(upateBy);
  1065. ref.setCreateTime(new Date());
  1066. ref.setUpdated(upateBy);
  1067. ref.setUpdateTime(ref.getCreateTime());
  1068. sysFileRefService.save(ref);
  1069. }
  1070. return true;
  1071. } else {
  1072. return false;
  1073. }
  1074. }
  1075. @Override
  1076. @Transactional(rollbackFor = Exception.class)
  1077. public boolean uploadFile(Long redId, Integer fileType, List<SysFileRef> sysFileRefs, String upateBy) {
  1078. return uploadFile(redId, fileType, sysFileRefs, upateBy, false);
  1079. }
  1080. @Override
  1081. @Transactional(rollbackFor = Exception.class)
  1082. public boolean insertPmReleaseAnnouncement(PmReleaseAnnouncementReqVo pmReleaseAnnouncementReqVo) throws Exception {
  1083. PmDemand pmDemand = this.getById(pmReleaseAnnouncementReqVo.getDemandId());
  1084. if (ObjectUtils.isEmpty(pmDemand)) {
  1085. throw new Exception("参数错误");
  1086. }
  1087. if (ObjectUtils.isEmpty(pmReleaseAnnouncementReqVo.getSysFileRefs())) {
  1088. throw new Exception("上传附件不能为空");
  1089. }
  1090. PmReleaseAnnouncement pmReleaseAnnouncement = new PmReleaseAnnouncement();
  1091. BeanUtils.copyProperties(pmReleaseAnnouncementReqVo, pmReleaseAnnouncement);
  1092. if (pmReleaseAnnouncementService.saveOrUpdate(pmReleaseAnnouncement)) {
  1093. uploadFile(pmReleaseAnnouncement.getId(), SysFileRefEnum.PM_ANNOUNCEMENT_FILE.getType(), pmReleaseAnnouncementReqVo.getSysFileRefs(), pmReleaseAnnouncementReqVo.getUpdateBy());
  1094. PmDemand pmDemandUpdate = new PmDemand();
  1095. pmDemandUpdate.setDemandId(pmReleaseAnnouncementReqVo.getDemandId());
  1096. pmDemandUpdate.setProjectStatus(PmProjectStatus.PRE_BID_QUERY.getCode());
  1097. pmDemandUpdate.setUpdateTime(pmReleaseAnnouncementReqVo.getUpdateTime());
  1098. pmDemandUpdate.setUpdateBy(pmReleaseAnnouncementReqVo.getUpdateBy());
  1099. if (this.updateById(pmDemandUpdate)) {
  1100. //发布公告生成后,会默认将该数据同步到公告管理和首页中
  1101. BaseNotice baseNotice = new BaseNotice();
  1102. baseNotice.setName(pmDemand.getProjectName());
  1103. baseNotice.setTitle(pmDemand.getProjectName() + "招标公告");
  1104. LambdaQueryWrapper<BaseNoticeType> lambdaQueryWrapper = new LambdaQueryWrapper<>();
  1105. lambdaQueryWrapper.eq(BaseNoticeType::getName, "招标公告");
  1106. BaseNoticeType baseNoticeType = baseNoticeTypeService.getOne(lambdaQueryWrapper);
  1107. if (baseNoticeType == null) {
  1108. throw new Exception("招标公告 公告类型不存在");
  1109. }
  1110. baseNotice.setDemandId(pmDemand.getDemandId());
  1111. baseNotice.setDeptId(pmDemand.getPurchaseDeptId());
  1112. baseNotice.setIsExcess(pmDemand.getIsExcess());
  1113. baseNotice.setType(baseNoticeType.getId());
  1114. baseNotice.setReleaseTime(pmReleaseAnnouncement.getReleaseTime());
  1115. baseNotice.setCreated(pmReleaseAnnouncementReqVo.getCreateBy());
  1116. baseNotice.setCreateTime(pmReleaseAnnouncementReqVo.getCreateTime());
  1117. baseNotice.setUpdated(pmReleaseAnnouncementReqVo.getUpdateBy());
  1118. baseNotice.setUpdateTime(pmReleaseAnnouncementReqVo.getUpdateTime());
  1119. return this.baseNoticeService.saveOrUpdate(baseNotice);
  1120. } else {
  1121. return false;
  1122. }
  1123. } else {
  1124. return false;
  1125. }
  1126. }
  1127. @Override
  1128. @Transactional(rollbackFor = Exception.class)
  1129. public boolean insertExpertBatch(PmBaseExpertFillReqVo pmBaseExpertFillReqVo) throws Exception {
  1130. PmDemand pmDemand = this.getById(pmBaseExpertFillReqVo.getDemandId());
  1131. if (ObjectUtils.isEmpty(pmDemand)) {
  1132. throw new Exception("参数错误");
  1133. }
  1134. List<BaseExpert> baseExpertList = pmBaseExpertFillReqVo.getBaseExpertList();
  1135. if (ObjectUtils.isEmpty(baseExpertList)) {
  1136. throw new Exception("参数错误");
  1137. }
  1138. Date now = new Date();
  1139. for (BaseExpert baseExpert : baseExpertList) {
  1140. if (NameListType.BLACK.getCode().equals(baseExpert.getStatus())) {
  1141. throw new Exception("该专家(身份证号:" + baseExpert.getIdNumber() + ")属于黑名单");
  1142. } else {
  1143. if (ObjectUtils.isEmpty(baseExpert.getStatus())) {
  1144. baseExpert.setStatus(NameListType.WHITE.getCode());
  1145. }
  1146. }
  1147. if (!ObjectUtils.isEmpty(baseExpert.getVarietyPurchase()) && !baseExpert.getVarietyPurchase().contains(pmDemand.getProjectType())) {
  1148. throw new Exception("该专家(身份证号:" + baseExpert.getIdNumber() + ")所属采购品种和项目类型不匹配");
  1149. } else {
  1150. baseExpert.setVarietyPurchase(pmDemand.getProjectType());
  1151. }
  1152. if (ObjectUtils.isEmpty(baseExpert.getCreated())) {
  1153. baseExpert.setCreated(pmBaseExpertFillReqVo.getCreateBy());
  1154. baseExpert.setCreateTime(now);
  1155. }
  1156. if (ObjectUtils.isEmpty(baseExpert.getUpdated())) {
  1157. baseExpert.setUpdated(pmBaseExpertFillReqVo.getUpdateBy());
  1158. baseExpert.setUpdateTime(now);
  1159. }
  1160. if (ObjectUtils.isEmpty(baseExpert.getId())) {
  1161. LambdaQueryWrapper<BaseExpert> lambdaQueryWrapper = new LambdaQueryWrapper<>();
  1162. lambdaQueryWrapper.eq(BaseExpert::getIdNumber, baseExpert.getIdNumber());
  1163. BaseExpert baseExpert1 = baseExpertService.getOne(lambdaQueryWrapper);
  1164. if (!ObjectUtils.isEmpty(baseExpert1)) {
  1165. baseExpert.setId(baseExpert1.getId());
  1166. }
  1167. }
  1168. if (baseExpertService.saveOrUpdate(baseExpert)) {
  1169. LambdaQueryWrapper<PmDemandExpertRef> pmDemandExpertRefLambdaQueryWrapper = new LambdaQueryWrapper<>();
  1170. pmDemandExpertRefLambdaQueryWrapper.eq(PmDemandExpertRef::getDemandId, pmDemand.getDemandId())
  1171. .eq(PmDemandExpertRef::getExpertId, baseExpert.getId().longValue())
  1172. .eq(PmDemandExpertRef::getAccessTime, pmBaseExpertFillReqVo.getAccessTime());
  1173. PmDemandExpertRef pmDemandExpertRef = pmDemandExpertRefService.getOne(pmDemandExpertRefLambdaQueryWrapper);
  1174. if (pmDemandExpertRef == null) {
  1175. pmDemandExpertRef = new PmDemandExpertRef();
  1176. pmDemandExpertRef.setCreateBy(pmBaseExpertFillReqVo.getCreateBy());
  1177. pmDemandExpertRef.setCreateTime(now);
  1178. }
  1179. pmDemandExpertRef.setDemandId(pmDemand.getDemandId());
  1180. pmDemandExpertRef.setExpertId(baseExpert.getId().longValue());
  1181. pmDemandExpertRef.setAccessTime(DateUtils.parseDate(pmBaseExpertFillReqVo.getAccessTime()));
  1182. pmDemandExpertRef.setUpdateBy(pmBaseExpertFillReqVo.getCreateBy());
  1183. pmDemandExpertRef.setUpdateTime(pmDemandExpertRef.getCreateTime());
  1184. pmDemandExpertRefService.saveOrUpdate(pmDemandExpertRef);
  1185. //专家单位
  1186. if (StringUtils.isNotNull(baseExpert.getUnitInformation())) {
  1187. List<BaseUnitInformation> baseUnitInformationList = baseExpertMapper.selectByUnitInformation(baseExpert.getUnitInformation());
  1188. if (baseUnitInformationList.size() <= 0) {
  1189. BaseUnitInformation baseUnitInformation = new BaseUnitInformation();
  1190. baseUnitInformation.setUnitName(baseExpert.getUnitInformation());
  1191. baseUnitInformation.setVarietyPurchase(baseExpert.getVarietyPurchase());
  1192. baseUnitInformation.setCreated(baseExpert.getExpertName());
  1193. baseUnitInformation.setCreateTime(new Date());
  1194. Integer i = baseExpertMapper.insertBaseUnitInformation(baseUnitInformation);
  1195. }
  1196. }
  1197. }
  1198. }
  1199. PmDemand pmDemandUpdate = new PmDemand();
  1200. pmDemandUpdate.setDemandId(pmDemand.getDemandId());
  1201. pmDemandUpdate.setHasExpert("1");
  1202. this.updateById(pmDemandUpdate);
  1203. return true;
  1204. }
  1205. @Override
  1206. @Transactional(rollbackFor = Exception.class)
  1207. public boolean extractExpertBatch(PmBaseExpertExtractReqVo pmBaseExpertExtractReqVo) throws Exception {
  1208. PmDemand pmDemand = this.getById(pmBaseExpertExtractReqVo.getDemandId());
  1209. if (ObjectUtils.isEmpty(pmDemand)) {
  1210. throw new Exception("参数错误");
  1211. }
  1212. String professional = pmBaseExpertExtractReqVo.getProfessional();
  1213. if (ObjectUtils.isEmpty(professional)) {
  1214. throw new Exception("必须选择专家专业");
  1215. }
  1216. String localArea = pmBaseExpertExtractReqVo.getLocalArea();
  1217. if (ObjectUtils.isEmpty(localArea)) {
  1218. throw new Exception("必须选择地域");
  1219. }
  1220. if (!StringUtils.isNumeric(localArea)) {
  1221. throw new Exception("地域必须传数字代码");
  1222. }
  1223. Integer technicalExpertNumber = pmBaseExpertExtractReqVo.getTechnicalExpertNumber();
  1224. if (technicalExpertNumber == null) {
  1225. technicalExpertNumber = 0;
  1226. }
  1227. Integer economicExpertNumber = pmBaseExpertExtractReqVo.getEconomicExpertNumber();
  1228. if (economicExpertNumber == null) {
  1229. economicExpertNumber = 0;
  1230. }
  1231. Integer legalAffairsExpertNumber = pmBaseExpertExtractReqVo.getLegalAffairsExpertNumber();
  1232. if (legalAffairsExpertNumber == null) {
  1233. legalAffairsExpertNumber = 0;
  1234. }
  1235. Integer spareExpertNumber = pmBaseExpertExtractReqVo.getSpareExpertNumber();
  1236. if (spareExpertNumber == null) {
  1237. spareExpertNumber = 0;
  1238. }
  1239. if (technicalExpertNumber + economicExpertNumber + legalAffairsExpertNumber + spareExpertNumber == 0) {
  1240. throw new Exception("必须至少填写一个数量");
  1241. }
  1242. String needAvoidUnit = pmBaseExpertExtractReqVo.getNeedAvoidUnit();
  1243. List<String> needAvoidUnitList = null;
  1244. if (!ObjectUtils.isEmpty(needAvoidUnit)) {
  1245. String[] arr = needAvoidUnit.split(",");
  1246. needAvoidUnitList = Arrays.asList(arr);
  1247. }
  1248. List<String> sysRegionCodeList = new ArrayList<>();
  1249. if (!ObjectUtils.isEmpty(localArea)) {
  1250. sysRegionCodeList.add(localArea);
  1251. //找到该地域code对应的子列表
  1252. List<SysRegionVO> sysRegionVOList = iSysRegionService.findChildDivisions(localArea);
  1253. if (!ObjectUtils.isEmpty(sysRegionVOList)) {
  1254. for (SysRegionVO vo : sysRegionVOList) {
  1255. sysRegionCodeList.add(vo.getCode());
  1256. }
  1257. }
  1258. }
  1259. //从专家库中查询符合项目类型的以及是白名单的全部列表
  1260. LambdaQueryWrapper<BaseExpert> lw = new LambdaQueryWrapper<>();
  1261. lw.eq(BaseExpert::getVarietyPurchase, pmDemand.getProjectType())
  1262. .eq(BaseExpert::getStatus, NameListType.WHITE.getCode())
  1263. .notIn(!ObjectUtils.isEmpty(needAvoidUnitList), BaseExpert::getUnitInformation, needAvoidUnitList)
  1264. .in(!ObjectUtils.isEmpty(sysRegionCodeList), BaseExpert::getLocalArea, sysRegionCodeList); //地域
  1265. List<BaseExpert> baseExpertList = baseExpertService.list(lw);
  1266. if (ObjectUtils.isEmpty(baseExpertList)) {
  1267. throw new Exception("没抽取到符合条件的专家");
  1268. }
  1269. //从列表中挑出来各个类型的子列表
  1270. List<BaseExpert> technicalExpertList = new ArrayList<>();
  1271. List<BaseExpert> economicExpertList = new ArrayList<>();
  1272. List<BaseExpert> legalAffairsExpertList = new ArrayList<>();
  1273. List<BaseExpert> spareExpertList = new ArrayList<>();
  1274. String[] arr = professional.split(",");
  1275. List<String> professionalList = Arrays.asList(arr);
  1276. for (BaseExpert baseExpert : baseExpertList) {
  1277. //专业类型判断
  1278. String majorType = baseExpert.getMajorType();
  1279. if (!ObjectUtils.isEmpty(majorType)) {
  1280. String[] arr2 = majorType.split(",");
  1281. List<String> majorTypeList = Arrays.asList(arr2);
  1282. if (!hasIntersection(professionalList, majorTypeList)) { //不符合专业类型
  1283. continue;
  1284. }
  1285. }
  1286. //备用专家
  1287. if (spareExpertNumber > 0) { //都加进去
  1288. spareExpertList.add(baseExpert);
  1289. }
  1290. if (technicalExpertNumber > 0) {
  1291. if (baseExpert.getExpertType().contains(ExpertType.TECHNICAL_EXPERT.getCode())) {
  1292. technicalExpertList.add(baseExpert);
  1293. continue;
  1294. }
  1295. }
  1296. if (economicExpertNumber > 0) {
  1297. if (baseExpert.getExpertType().contains(ExpertType.ECONOMIC_EXPERT.getCode())) {
  1298. economicExpertList.add(baseExpert);
  1299. continue;
  1300. }
  1301. }
  1302. if (legalAffairsExpertNumber > 0) {
  1303. if (baseExpert.getExpertType().contains(ExpertType.LEGALAFFAIRS_EXPERT.getCode())) {
  1304. legalAffairsExpertList.add(baseExpert);
  1305. continue;
  1306. }
  1307. }
  1308. }
  1309. //从子列表中随机抽取符合数据量的
  1310. List<BaseExpert> alltExpertList = new ArrayList<>();
  1311. if (technicalExpertNumber > 0 && technicalExpertList.size() < technicalExpertNumber) {
  1312. throw new Exception("抽取到符合条件的技术专家数量不够");
  1313. }
  1314. if (!ObjectUtils.isEmpty(technicalExpertList)) {
  1315. alltExpertList.addAll(RandomUtil.getRandomList(technicalExpertList, technicalExpertNumber));
  1316. }
  1317. if (economicExpertNumber > 0 && economicExpertList.size() < economicExpertNumber) {
  1318. throw new Exception("抽取到符合条件的经济专家数量不够");
  1319. }
  1320. if (!ObjectUtils.isEmpty(economicExpertList)) {
  1321. alltExpertList.addAll(RandomUtil.getRandomList(economicExpertList, economicExpertNumber));
  1322. }
  1323. if (legalAffairsExpertNumber > 0 && legalAffairsExpertList.size() < legalAffairsExpertNumber) {
  1324. throw new Exception("抽取到符合条件的法务专家数量不够");
  1325. }
  1326. if (!ObjectUtils.isEmpty(legalAffairsExpertList)) {
  1327. alltExpertList.addAll(RandomUtil.getRandomList(legalAffairsExpertList, legalAffairsExpertNumber));
  1328. }
  1329. List<BaseExpert> spareExpertListNew = new ArrayList<>();
  1330. if (!ObjectUtils.isEmpty(spareExpertList)) {
  1331. //获取全部IDlist
  1332. List<Integer> allExpertIdList = new ArrayList<>();
  1333. if (!ObjectUtils.isEmpty(alltExpertList)) {
  1334. for (BaseExpert baseExpert : alltExpertList) {
  1335. allExpertIdList.add(baseExpert.getId());
  1336. }
  1337. }
  1338. //遍历全部IDlist
  1339. if (!ObjectUtils.isEmpty(allExpertIdList)) { //去重
  1340. for (BaseExpert baseExpert : spareExpertList) {
  1341. if (!allExpertIdList.contains(baseExpert.getId())) {
  1342. spareExpertListNew.add(baseExpert);
  1343. }
  1344. }
  1345. } else {
  1346. spareExpertListNew = spareExpertList;
  1347. }
  1348. if (!ObjectUtils.isEmpty(spareExpertListNew)) {
  1349. alltExpertList.addAll(RandomUtil.getRandomList(spareExpertListNew, spareExpertNumber));
  1350. }
  1351. }
  1352. if (spareExpertNumber > 0 && spareExpertListNew.size() < spareExpertNumber) {
  1353. throw new Exception("抽取到符合条件的备用专家数量不够");
  1354. }
  1355. if (ObjectUtils.isEmpty(alltExpertList)) {
  1356. throw new Exception("没抽取到符合条件的专家");
  1357. } else {
  1358. List<PmDemandExpertRef> pmDemandExpertRefList = new ArrayList<>();
  1359. for (BaseExpert baseExpert : alltExpertList) {
  1360. LambdaQueryWrapper<PmDemandExpertRef> baseExpertLambdaQueryWrapper = new LambdaQueryWrapper<>();
  1361. baseExpertLambdaQueryWrapper.eq(PmDemandExpertRef::getExpertId, baseExpert.getId().longValue())
  1362. .eq(PmDemandExpertRef::getDemandId, pmDemand.getDemandId())
  1363. .eq(PmDemandExpertRef::getAccessTime, pmBaseExpertExtractReqVo.getAccessTime());
  1364. PmDemandExpertRef pmDemandExpertRef = pmDemandExpertRefService.getOne(baseExpertLambdaQueryWrapper);
  1365. if (pmDemandExpertRef == null) {
  1366. pmDemandExpertRef = new PmDemandExpertRef();
  1367. pmDemandExpertRef.setCreateBy(pmBaseExpertExtractReqVo.getCreateBy());
  1368. pmDemandExpertRef.setCreateTime(new Date());
  1369. }
  1370. pmDemandExpertRef.setDemandId(pmDemand.getDemandId());
  1371. pmDemandExpertRef.setExpertId(baseExpert.getId().longValue());
  1372. pmDemandExpertRef.setAccessTime(DateUtils.parseDate(pmBaseExpertExtractReqVo.getAccessTime()));
  1373. pmDemandExpertRef.setUpdateBy(pmBaseExpertExtractReqVo.getCreateBy());
  1374. pmDemandExpertRef.setUpdateTime(pmDemandExpertRef.getCreateTime());
  1375. pmDemandExpertRefList.add(pmDemandExpertRef);
  1376. }
  1377. PmDemand pmDemandUpdate = new PmDemand();
  1378. pmDemandUpdate.setDemandId(pmDemand.getDemandId());
  1379. pmDemandUpdate.setHasExpert("1");
  1380. this.updateById(pmDemandUpdate);
  1381. return pmDemandExpertRefService.saveOrUpdateBatch(pmDemandExpertRefList);
  1382. }
  1383. }
  1384. //二个列表是否有交集
  1385. private boolean hasIntersection(List<String> professionalList, List<String> majorTypeList) {
  1386. for (String professiona : professionalList) {
  1387. for (String majorType : majorTypeList) {
  1388. if (professiona.equals(majorType)) {
  1389. return true;
  1390. }
  1391. }
  1392. }
  1393. return false;
  1394. }
  1395. @Override
  1396. @Transactional(rollbackFor = Exception.class)
  1397. public boolean insertBidOpeningBatch(PmBidOpeningFillReqVo pmBidOpeningFillReqVo) throws Exception {
  1398. PmDemand pmDemand = this.getById(pmBidOpeningFillReqVo.getDemandId());
  1399. if (ObjectUtils.isEmpty(pmDemand)) {
  1400. throw new Exception("参数错误");
  1401. }
  1402. //从发布公告里获取开标时间
  1403. LambdaQueryWrapper<PmReleaseAnnouncement> lw = new LambdaQueryWrapper<>();
  1404. lw.eq(PmReleaseAnnouncement::getDemandId, pmDemand.getDemandId()).orderByDesc(PmReleaseAnnouncement::getReleaseTime)
  1405. .last(" limit 1 ");
  1406. PmReleaseAnnouncement pmReleaseAnnouncement = this.pmReleaseAnnouncementService.getOne(lw);
  1407. if (pmReleaseAnnouncement == null) {
  1408. throw new Exception("发布公告不存在");
  1409. }
  1410. Date tenderOpenTime = pmReleaseAnnouncement.getTenderOpenTime();
  1411. Date now = new Date();
  1412. List<PmBidOpening> pmBidOpeningList = pmBidOpeningFillReqVo.getPmBidOpeningList();
  1413. for (PmBidOpening pmBidOpening : pmBidOpeningList) {
  1414. if (ObjectUtils.isEmpty(pmBidOpening.getBidderName())) {
  1415. throw new Exception("投标人名称不能为空");
  1416. }
  1417. if (ObjectUtils.isEmpty(pmBidOpening.getScore())) {
  1418. throw new Exception("分数不能为空");
  1419. }
  1420. pmBidOpening.setOpenBidTime(tenderOpenTime);
  1421. pmBidOpening.setDemandId(pmBidOpeningFillReqVo.getDemandId());
  1422. pmBidOpening.setCreateBy(pmBidOpeningFillReqVo.getCreateBy());
  1423. pmBidOpening.setCreateTime(now);
  1424. pmBidOpening.setUpdateBy(pmBidOpeningFillReqVo.getUpdateBy());
  1425. pmBidOpening.setUpdateTime(now);
  1426. }
  1427. if (pmBidOpeningService.saveOrUpdateBatch(pmBidOpeningList)) {
  1428. PmDemand pmDemandUpdate = new PmDemand();
  1429. pmDemandUpdate.setDemandId(pmDemand.getDemandId());
  1430. pmDemandUpdate.setProjectStatus(PmProjectStatus.BID_RESULT_ANNOUNCEMENT.getCode());
  1431. pmDemandUpdate.setUpdateTime(now);
  1432. pmDemandUpdate.setUpdateBy(pmBidOpeningFillReqVo.getUpdateBy());
  1433. return this.updateById(pmDemandUpdate);
  1434. } else {
  1435. return false;
  1436. }
  1437. }
  1438. /**
  1439. * 预中标
  1440. *
  1441. * @param pmBidWinningReqVo
  1442. * @return
  1443. * @throws Exception
  1444. */
  1445. @Override
  1446. @Transactional(rollbackFor = Exception.class)
  1447. public boolean insertPmBidWinning(PmBidWinningReqVo pmBidWinningReqVo) throws Exception {
  1448. List<Long> pmBidOpeningIdList = pmBidWinningReqVo.getPmBidOpeningIdList();
  1449. if (ObjectUtils.isEmpty(pmBidWinningReqVo.getBidWinningAmount()) && ObjectUtils.isEmpty(pmBidWinningReqVo.getRemarks())) {
  1450. throw new Exception("中标金额或备注必须填写一个");
  1451. }
  1452. if (ObjectUtils.isEmpty(pmBidOpeningIdList)) {
  1453. throw new Exception("中标单位信息列表不能为空");
  1454. }
  1455. if (ObjectUtils.isEmpty(pmBidWinningReqVo.getSysFileRefs())) {
  1456. throw new Exception("上传附件不能为空");
  1457. }
  1458. PmBidWinning pmBidWinning = new PmBidWinning();
  1459. BeanUtils.copyProperties(pmBidWinningReqVo, pmBidWinning);
  1460. //修改老的中标信息状态
  1461. if (ObjectUtils.isEmpty(pmBidWinningReqVo.getId())) { //属于新增
  1462. LambdaQueryWrapper<PmBidWinning> pmBidWinningLambdaQueryWrapper = new LambdaQueryWrapper<>();
  1463. pmBidWinningLambdaQueryWrapper.eq(PmBidWinning::getDemandId, pmBidWinningReqVo.getDemandId())
  1464. .eq(PmBidWinning::getStatus, BidWinningStatus.NORMAL.getCode());
  1465. List<PmBidWinning> pmBidWinninglist = pmBidWinningService.list(pmBidWinningLambdaQueryWrapper);
  1466. if (!ObjectUtils.isEmpty(pmBidWinninglist)) {
  1467. for (PmBidWinning item : pmBidWinninglist) {
  1468. UpdateWrapper<PmBidWinning> updateWrapper1 = new UpdateWrapper<>();
  1469. updateWrapper1.lambda().set(PmBidWinning::getStatus, BidWinningStatus.BE_REPLACED.getCode())
  1470. .eq(PmBidWinning::getId, item.getId());
  1471. pmBidWinningService.update(updateWrapper1);
  1472. UpdateWrapper<PmBidWinningOpeningRef> updateWrapper2 = new UpdateWrapper<>();
  1473. updateWrapper2.lambda().set(PmBidWinningOpeningRef::getStatus, BidWinningStatus.BE_REPLACED.getCode())
  1474. .eq(PmBidWinningOpeningRef::getWinningId, item.getId())
  1475. .eq(PmBidWinningOpeningRef::getStatus, BidWinningStatus.NORMAL.getCode());
  1476. pmBidWinningOpeningRefService.update(updateWrapper2);
  1477. }
  1478. }
  1479. }
  1480. if (pmBidWinningService.saveOrUpdate(pmBidWinning)) {
  1481. List<PmBidWinningOpeningRef> pmBidWinningOpeningRefList = new ArrayList<>();
  1482. for (Long pmBidOpeningId : pmBidOpeningIdList) {
  1483. LambdaQueryWrapper<PmBidWinningOpeningRef> pmBidWinningOpeningRefLambdaQueryWrapper = new LambdaQueryWrapper<>();
  1484. pmBidWinningOpeningRefLambdaQueryWrapper.eq(PmBidWinningOpeningRef::getOpeningId, pmBidOpeningId)
  1485. .eq(PmBidWinningOpeningRef::getWinningId, pmBidWinning.getId());
  1486. PmBidWinningOpeningRef pmBidWinningOpeningRef = pmBidWinningOpeningRefService.getOne(pmBidWinningOpeningRefLambdaQueryWrapper);
  1487. if (pmBidWinningOpeningRef == null) {
  1488. pmBidWinningOpeningRef = new PmBidWinningOpeningRef();
  1489. pmBidWinningOpeningRef.setCreateBy(pmBidWinningReqVo.getCreateBy());
  1490. pmBidWinningOpeningRef.setCreateTime(pmBidWinningReqVo.getCreateTime());
  1491. }
  1492. pmBidWinningOpeningRef.setDemandId(pmBidWinning.getDemandId());
  1493. pmBidWinningOpeningRef.setOpeningId(pmBidOpeningId);
  1494. pmBidWinningOpeningRef.setWinningId(pmBidWinning.getId());
  1495. pmBidWinningOpeningRef.setUpdateBy(pmBidWinningReqVo.getUpdateBy());
  1496. pmBidWinningOpeningRef.setUpdateTime(pmBidWinningReqVo.getUpdateTime());
  1497. pmBidWinningOpeningRefList.add(pmBidWinningOpeningRef);
  1498. }
  1499. if (pmBidWinningOpeningRefService.saveOrUpdateBatch(pmBidWinningOpeningRefList)) {
  1500. uploadFile(pmBidWinning.getId(), SysFileRefEnum.PM_BID_WINNING_FILE.getType(), pmBidWinningReqVo.getSysFileRefs(), pmBidWinningReqVo.getUpdateBy());
  1501. //发布公告生成后,会默认将该数据同步到公告管理和首页中
  1502. PmDemand pmDemand = this.getById(pmBidWinningReqVo.getDemandId());
  1503. BaseNotice baseNotice = new BaseNotice();
  1504. baseNotice.setName(pmDemand.getProjectName());
  1505. baseNotice.setTitle(pmDemand.getProjectName() + "预中标公告");
  1506. LambdaQueryWrapper<BaseNoticeType> lambdaQueryWrapper = new LambdaQueryWrapper<>();
  1507. lambdaQueryWrapper.eq(BaseNoticeType::getName, "预中标公告");
  1508. BaseNoticeType baseNoticeType = baseNoticeTypeService.getOne(lambdaQueryWrapper);
  1509. if (baseNoticeType == null) {
  1510. throw new Exception("预中标公告 公告类型不存在");
  1511. }
  1512. baseNotice.setDemandId(pmDemand.getDemandId());
  1513. baseNotice.setDeptId(pmDemand.getPurchaseDeptId());
  1514. baseNotice.setIsExcess(pmDemand.getIsExcess());
  1515. baseNotice.setType(baseNoticeType.getId());
  1516. baseNotice.setReleaseTime(pmBidWinningReqVo.getBidAnnouncementTime());
  1517. baseNotice.setCreated(pmBidWinningReqVo.getCreateBy());
  1518. baseNotice.setCreateTime(pmBidWinningReqVo.getCreateTime());
  1519. baseNotice.setUpdated(pmBidWinningReqVo.getUpdateBy());
  1520. baseNotice.setUpdateTime(pmBidWinningReqVo.getUpdateTime());
  1521. this.baseNoticeService.saveOrUpdate(baseNotice);
  1522. PmDemand pmDemandUpdate = new PmDemand();
  1523. pmDemandUpdate.setDemandId(pmBidWinningReqVo.getDemandId());
  1524. pmDemandUpdate.setProjectStatus(PmProjectStatus.POST_BID_QUERY.getCode());
  1525. pmDemandUpdate.setUpdateTime(pmBidWinningReqVo.getUpdateTime());
  1526. pmDemandUpdate.setUpdateBy(pmBidWinningReqVo.getUpdateBy());
  1527. return this.updateById(pmDemandUpdate);
  1528. } else {
  1529. return false;
  1530. }
  1531. } else {
  1532. return false;
  1533. }
  1534. }
  1535. @Override
  1536. @Transactional(rollbackFor = Exception.class)
  1537. public boolean updatePmBidWinning(PmBidWinningReqVo pmBidWinningReqVo) throws Exception {
  1538. List<Long> pmBidOpeningIdList = pmBidWinningReqVo.getPmBidOpeningIdList();
  1539. if (ObjectUtils.isEmpty(pmBidOpeningIdList)) {
  1540. throw new Exception("中标单位信息列表不能为空");
  1541. }
  1542. if (ObjectUtils.isEmpty(pmBidWinningReqVo.getBidWinningAmount())) {
  1543. throw new Exception("中标金额不能为空");
  1544. }
  1545. if (ObjectUtils.isEmpty(pmBidWinningReqVo.getSysFileRefs())) {
  1546. throw new Exception("上传附件不能为空");
  1547. }
  1548. LambdaQueryWrapper<PmBidWinning> lw = new LambdaQueryWrapper<>();
  1549. lw.eq(PmBidWinning::getDemandId, pmBidWinningReqVo.getDemandId()).eq(PmBidWinning::getStatus, BidWinningStatus.NORMAL.getCode());
  1550. List<PmBidWinning> pmBidWinninglist = pmBidWinningService.list(lw);
  1551. if (ObjectUtils.isEmpty(pmBidWinninglist)) {
  1552. throw new Exception("原中标信息不存在");
  1553. }
  1554. //修改老的状态
  1555. for (PmBidWinning item : pmBidWinninglist) {
  1556. UpdateWrapper<PmBidWinning> updateWrapper1 = new UpdateWrapper<>();
  1557. updateWrapper1.lambda().set(PmBidWinning::getStatus, BidWinningStatus.BE_REPLACED.getCode())
  1558. .eq(PmBidWinning::getId, item.getId());
  1559. pmBidWinningService.update(updateWrapper1);
  1560. UpdateWrapper<PmBidWinningOpeningRef> updateWrapper2 = new UpdateWrapper<>();
  1561. updateWrapper2.lambda().set(PmBidWinningOpeningRef::getStatus, BidWinningStatus.BE_REPLACED.getCode())
  1562. .eq(PmBidWinningOpeningRef::getWinningId, item.getId())
  1563. .eq(PmBidWinningOpeningRef::getStatus, BidWinningStatus.NORMAL.getCode());
  1564. pmBidWinningOpeningRefService.update(updateWrapper2);
  1565. }
  1566. //新增
  1567. PmBidWinning pmBidWinning = new PmBidWinning();
  1568. BeanUtils.copyProperties(pmBidWinninglist.get(0), pmBidWinning);
  1569. pmBidWinning.setId(null);
  1570. pmBidWinning.setBidWinningAmount(pmBidWinningReqVo.getBidWinningAmount());
  1571. pmBidWinning.setStatus(BidWinningStatus.NORMAL.getCode());
  1572. pmBidWinning.setUpdateBy(pmBidWinningReqVo.getUpdateBy());
  1573. pmBidWinning.setUpdateTime(pmBidWinningReqVo.getUpdateTime());
  1574. if (pmBidWinningService.save(pmBidWinning)) {
  1575. List<PmBidWinningOpeningRef> pmBidWinningOpeningRefList = new ArrayList<>();
  1576. for (Long pmBidOpeningId : pmBidOpeningIdList) {
  1577. PmBidWinningOpeningRef pmBidWinningOpeningRef = new PmBidWinningOpeningRef();
  1578. pmBidWinningOpeningRef.setDemandId(pmBidWinning.getDemandId());
  1579. pmBidWinningOpeningRef.setOpeningId(pmBidOpeningId);
  1580. pmBidWinningOpeningRef.setWinningId(pmBidWinning.getId());
  1581. pmBidWinningOpeningRef.setStatus(BidWinningStatus.NORMAL.getCode());
  1582. pmBidWinningOpeningRef.setCreateBy(pmBidWinningReqVo.getCreateBy());
  1583. pmBidWinningOpeningRef.setCreateTime(pmBidWinningReqVo.getCreateTime());
  1584. pmBidWinningOpeningRef.setUpdateBy(pmBidWinningReqVo.getUpdateBy());
  1585. pmBidWinningOpeningRef.setUpdateTime(pmBidWinningReqVo.getUpdateTime());
  1586. pmBidWinningOpeningRefList.add(pmBidWinningOpeningRef);
  1587. }
  1588. LambdaQueryWrapper<SysFileRef> sysFileRefLambdaQueryWrapper = new LambdaQueryWrapper<>();
  1589. sysFileRefLambdaQueryWrapper.eq(SysFileRef::getType, SysFileRefEnum.PM_BID_WINNING_FILE.getType())
  1590. .eq(SysFileRef::getRedId, pmBidWinninglist.get(0));
  1591. List<SysFileRef> sysFileRefs = sysFileRefService.list(sysFileRefLambdaQueryWrapper);
  1592. uploadFile(pmBidWinning.getId(), SysFileRefEnum.PM_BID_WINNING_FILE.getType(), sysFileRefs, pmBidWinningReqVo.getUpdateBy());
  1593. return pmBidWinningOpeningRefService.saveBatch(pmBidWinningOpeningRefList);
  1594. } else {
  1595. return false;
  1596. }
  1597. }
  1598. /**
  1599. * 流标
  1600. *
  1601. * @param pmBidFailureReqVo
  1602. * @return
  1603. * @throws Exception
  1604. */
  1605. @Override
  1606. @Transactional(rollbackFor = Exception.class)
  1607. public boolean insertPmBidFailure(PmBidFailureReqVo pmBidFailureReqVo) throws Exception {
  1608. PmBidFailure pmBidFailure = new PmBidFailure();
  1609. BeanUtils.copyProperties(pmBidFailureReqVo, pmBidFailure);
  1610. if (pmBidFailureService.saveOrUpdate(pmBidFailure)) {
  1611. //把中标信息修改状态
  1612. LambdaQueryWrapper<PmBidWinning> lw = new LambdaQueryWrapper<>();
  1613. lw.eq(PmBidWinning::getDemandId, pmBidFailureReqVo.getDemandId()).eq(PmBidWinning::getStatus, BidWinningStatus.NORMAL.getCode());
  1614. List<PmBidWinning> pmBidWinninglist = pmBidWinningService.list(lw);
  1615. if (!ObjectUtils.isEmpty(pmBidWinninglist)) {
  1616. for (PmBidWinning item : pmBidWinninglist) {
  1617. UpdateWrapper<PmBidWinning> updateWrapper1 = new UpdateWrapper<>();
  1618. updateWrapper1.lambda().set(PmBidWinning::getStatus, BidWinningStatus.BE_BID_FAILURE.getCode())
  1619. .eq(PmBidWinning::getId, item.getId());
  1620. pmBidWinningService.update(updateWrapper1);
  1621. UpdateWrapper<PmBidWinningOpeningRef> updateWrapper2 = new UpdateWrapper<>();
  1622. updateWrapper2.lambda().set(PmBidWinningOpeningRef::getStatus, BidWinningStatus.BE_BID_FAILURE.getCode())
  1623. .eq(PmBidWinningOpeningRef::getWinningId, item.getId())
  1624. .eq(PmBidWinningOpeningRef::getStatus, BidWinningStatus.NORMAL.getCode());
  1625. pmBidWinningOpeningRefService.update(updateWrapper2);
  1626. }
  1627. }
  1628. uploadFile(pmBidFailure.getId(), SysFileRefEnum.PM_BID_FAILURE_FILE.getType(), pmBidFailureReqVo.getSysFileRefs(), pmBidFailureReqVo.getUpdateBy());
  1629. //发布公告生成后,会默认将该数据同步到公告管理和首页中
  1630. PmDemand pmDemand = this.getById(pmBidFailureReqVo.getDemandId());
  1631. BaseNotice baseNotice = new BaseNotice();
  1632. baseNotice.setName(pmDemand.getProjectName());
  1633. baseNotice.setTitle(pmDemand.getProjectName() + "流废标公告");
  1634. LambdaQueryWrapper<BaseNoticeType> lambdaQueryWrapper = new LambdaQueryWrapper<>();
  1635. lambdaQueryWrapper.eq(BaseNoticeType::getName, "流废标公告");
  1636. BaseNoticeType baseNoticeType = baseNoticeTypeService.getOne(lambdaQueryWrapper);
  1637. if (baseNoticeType == null) {
  1638. throw new Exception("流废标公告 公告类型不存在");
  1639. }
  1640. baseNotice.setDemandId(pmDemand.getDemandId());
  1641. baseNotice.setDeptId(pmDemand.getPurchaseDeptId());
  1642. baseNotice.setIsExcess(pmDemand.getIsExcess());
  1643. baseNotice.setType(baseNoticeType.getId());
  1644. baseNotice.setReleaseTime(pmBidFailureReqVo.getBidFailureTime());
  1645. baseNotice.setCreated(pmBidFailureReqVo.getCreateBy());
  1646. baseNotice.setCreateTime(pmBidFailureReqVo.getCreateTime());
  1647. baseNotice.setUpdated(pmBidFailureReqVo.getUpdateBy());
  1648. baseNotice.setUpdateTime(pmBidFailureReqVo.getUpdateTime());
  1649. this.baseNoticeService.saveOrUpdate(baseNotice);
  1650. PmDemand pmDemandUpdate = new PmDemand();
  1651. pmDemandUpdate.setDemandId(pmBidFailureReqVo.getDemandId());
  1652. pmDemandUpdate.setProjectStatus(PmProjectStatus.WASTE_BID_HANDLE.getCode());
  1653. pmDemandUpdate.setHasExpert("0");
  1654. pmDemandUpdate.setUpdateTime(pmBidFailureReqVo.getUpdateTime());
  1655. pmDemandUpdate.setUpdateBy(pmBidFailureReqVo.getUpdateBy());
  1656. return this.updateById(pmDemandUpdate);
  1657. } else {
  1658. return false;
  1659. }
  1660. }
  1661. @Override
  1662. @Transactional(rollbackFor = Exception.class)
  1663. public boolean insertContractInfo(PmContractInfoReqVo pmContractInfoReqVo) throws Exception {
  1664. Long demandId = pmContractInfoReqVo.getDemandId();
  1665. if (ObjectUtils.isEmpty(demandId)) {
  1666. throw new Exception("采购需求ID不能为空");
  1667. }
  1668. PmDemand pmDemand = this.getById(demandId);
  1669. if (ObjectUtils.isEmpty(pmDemand)) {
  1670. throw new Exception("采购需求ID错误");
  1671. }
  1672. List<SysFileRef> sysFileRefs = pmContractInfoReqVo.getSysFileRefs();
  1673. if (ObjectUtils.isEmpty(sysFileRefs)) {
  1674. throw new Exception("上传附件不能为空");
  1675. }
  1676. LambdaQueryWrapper<PmContractInfo> lambdaQueryWrapper = new LambdaQueryWrapper<>();
  1677. lambdaQueryWrapper.eq(PmContractInfo::getDemandId, demandId);
  1678. PmContractInfo pmContractInfo = pmContractInfoService.getOne(lambdaQueryWrapper);
  1679. if (pmContractInfo != null) {
  1680. pmContractInfoReqVo.setId(pmContractInfo.getId());
  1681. BeanUtils.copyProperties(pmContractInfoReqVo, pmContractInfo);
  1682. pmContractInfo.setUpdateTime(pmContractInfoReqVo.getUpdateTime());
  1683. pmContractInfo.setUpdateBy(pmContractInfoReqVo.getUpdateBy());
  1684. } else {
  1685. pmContractInfo = new PmContractInfo();
  1686. BeanUtils.copyProperties(pmContractInfoReqVo, pmContractInfo);
  1687. pmContractInfo.setCreateBy(pmContractInfoReqVo.getCreateBy());
  1688. pmContractInfo.setCreateTime(pmContractInfoReqVo.getCreateTime());
  1689. pmContractInfo.setUpdateTime(pmContractInfoReqVo.getUpdateTime());
  1690. pmContractInfo.setUpdateBy(pmContractInfoReqVo.getUpdateBy());
  1691. }
  1692. if (pmContractInfoService.saveOrUpdate(pmContractInfo)) {
  1693. this.uploadFile(pmContractInfo.getId(), SysFileRefEnum.PM_CONTRACT_INFO.getType(), sysFileRefs, pmContractInfoReqVo.getUpdateBy());
  1694. PmDemand pmDemandUpdate = new PmDemand();
  1695. pmDemandUpdate.setDemandId(demandId);
  1696. pmDemandUpdate.setProjectStatus(PmProjectStatus.UNDER_CONSTRUCTION.getCode());
  1697. pmDemandUpdate.setUpdateTime(pmContractInfoReqVo.getUpdateTime());
  1698. pmDemandUpdate.setUpdateBy(pmContractInfoReqVo.getUpdateBy());
  1699. return this.updateById(pmDemandUpdate);
  1700. } else {
  1701. return false;
  1702. }
  1703. }
  1704. @Override
  1705. @Transactional(rollbackFor = Exception.class)
  1706. public boolean insertProjectConstruction(PmProjectConstructionReqVo pmProjectConstructionReqVo) throws Exception {
  1707. Long demandId = pmProjectConstructionReqVo.getDemandId();
  1708. if (ObjectUtils.isEmpty(demandId)) {
  1709. throw new Exception("采购需求ID不能为空");
  1710. }
  1711. PmDemand pmDemand = this.getById(demandId);
  1712. if (ObjectUtils.isEmpty(pmDemand)) {
  1713. throw new Exception("采购需求ID错误");
  1714. }
  1715. List<SysFileRef> sysFileRefs = pmProjectConstructionReqVo.getSysFileRefs();
  1716. if (ObjectUtils.isEmpty(sysFileRefs)) {
  1717. throw new Exception("上传附件不能为空");
  1718. }
  1719. LambdaQueryWrapper<PmProjectConstruction> lambdaQueryWrapper = new LambdaQueryWrapper<>();
  1720. lambdaQueryWrapper.eq(PmProjectConstruction::getDemandId, demandId);
  1721. PmProjectConstruction pmProjectConstruction = pmProjectConstructionService.getOne(lambdaQueryWrapper);
  1722. if (pmProjectConstruction != null) {
  1723. pmProjectConstructionReqVo.setId(pmProjectConstruction.getId());
  1724. BeanUtils.copyProperties(pmProjectConstructionReqVo, pmProjectConstruction);
  1725. pmProjectConstruction.setUpdateBy(pmProjectConstructionReqVo.getUpdateBy());
  1726. pmProjectConstruction.setUpdateTime(pmProjectConstructionReqVo.getUpdateTime());
  1727. } else {
  1728. pmProjectConstruction = new PmProjectConstruction();
  1729. BeanUtils.copyProperties(pmProjectConstructionReqVo, pmProjectConstruction);
  1730. pmProjectConstruction.setCreateBy(pmProjectConstructionReqVo.getCreateBy());
  1731. pmProjectConstruction.setCreateTime(pmProjectConstructionReqVo.getCreateTime());
  1732. pmProjectConstruction.setUpdateBy(pmProjectConstructionReqVo.getUpdateBy());
  1733. pmProjectConstruction.setUpdateTime(pmProjectConstructionReqVo.getUpdateTime());
  1734. }
  1735. if (pmProjectConstructionService.saveOrUpdate(pmProjectConstruction)) {
  1736. this.uploadFile(pmProjectConstruction.getId(), SysFileRefEnum.PM_PROJECT_CONSTRUCTION.getType(), sysFileRefs, pmProjectConstructionReqVo.getUpdateBy());
  1737. PmDemand pmDemandUpdate = new PmDemand();
  1738. pmDemandUpdate.setDemandId(demandId);
  1739. pmDemandUpdate.setProjectStatus(PmProjectStatus.COMPLETION_CONSTRUCTION.getCode());
  1740. pmDemandUpdate.setRealDeliverTime(pmProjectConstructionReqVo.getUpdateTime());
  1741. pmDemandUpdate.setWarnStatus(WarnStatus.NORMAL.getCode());
  1742. pmDemandUpdate.setUpdateTime(pmProjectConstructionReqVo.getUpdateTime());
  1743. pmDemandUpdate.setUpdateBy(pmProjectConstructionReqVo.getUpdateBy());
  1744. return this.updateById(pmDemandUpdate);
  1745. } else {
  1746. return false;
  1747. }
  1748. }
  1749. /**
  1750. * 更新需求预警状态
  1751. *
  1752. * @param demnadId
  1753. * @return
  1754. */
  1755. @Override
  1756. @Transactional(rollbackFor = Exception.class)
  1757. public void updateDemandWarnStatus(Long demnadId) {
  1758. PmDemand pmDemand = this.getById(demnadId);
  1759. List<SysDictData> data = iSysDictTypeService.selectDictDataByType("alert_time_setting");
  1760. int setting1 = Integer.parseInt(data.stream().filter(item -> item.getDictLabel().equals("计划提报时间")).collect(Collectors.toList()).get(0).getDictValue());
  1761. log.info("******** setting1 == " + setting1);
  1762. //需求提报时间:根据数据阈值中设置的提报时间进行判断,进行预警
  1763. int diff1 = DateUtils.differentDaysByMillisecond(pmDemand.getPlanDemandSubTime(), DateUtils.parseDate(DateUtils.getDate()));
  1764. if (ObjectUtils.isEmpty(pmDemand.getRealDemandCommitTime()) && diff1 > 0 && diff1 <= setting1) {
  1765. PmDemand pmDemandUpdate = new PmDemand();
  1766. pmDemandUpdate.setDemandId(demnadId);
  1767. pmDemandUpdate.setWarnStatus(WarnStatus.DEMAND_COMMT_WARNING.getCode());
  1768. this.updateById(pmDemandUpdate);
  1769. } else if (ObjectUtils.isEmpty(pmDemand.getRealDemandCommitTime()) && pmDemand.getPlanDemandSubTime().getTime() < System.currentTimeMillis()) {
  1770. PmDemand pmDemandUpdate = new PmDemand();
  1771. pmDemandUpdate.setDemandId(demnadId);
  1772. pmDemandUpdate.setWarnStatus(WarnStatus.DEMAND_COMMT_EX.getCode());
  1773. this.updateById(pmDemandUpdate);
  1774. }
  1775. }
  1776. /**
  1777. * 通过需求ID列表 查询采购执行列表 sunhh
  1778. *
  1779. * @param demandIdList
  1780. * @return
  1781. */
  1782. @Override
  1783. public List<PmDemand> selectByDemandIdList(List<Integer> demandIdList) {
  1784. return this.baseMapper.selectByDemandIdList(demandIdList);
  1785. }
  1786. /**
  1787. * 专家库--查询抽取专家列表 非必传条件:专家名称,开始结束时间 sunhh
  1788. *
  1789. * @param baseExpertVo
  1790. * @return
  1791. */
  1792. @Override
  1793. public List<PmDemand> selectExtractionExpert(BaseExpertVo baseExpertVo) {
  1794. return pmDemandMapper.selectExtractionExpert(baseExpertVo);
  1795. }
  1796. @Override
  1797. public List<PmDemand> demandWaitCommit() {
  1798. List<PmDemand> byStatus = getListByStatus(PmProjectStatus.DEMAND_WAIT_FILL.getCode());
  1799. byStatus.addAll(getListByStatus(PmProjectStatus.DEMAND_WAIT_COMMIT.getCode()));
  1800. return (byStatus);
  1801. }
  1802. @Override
  1803. public List<PmDemand> contractWaitFilled() {
  1804. List<PmDemand> byStatus = getListByStatus(PmProjectStatus.CONTRACT_WAIT_FILL.getCode());
  1805. return (byStatus);
  1806. }
  1807. @Override
  1808. public List<PmDemand> projectWaitFinish() {
  1809. List<PmDemand> byStatus = getListByStatus(PmProjectStatus.UNDER_CONSTRUCTION.getCode());
  1810. return (byStatus);
  1811. }
  1812. @Override
  1813. public List<PmDemand> demandWaitExamine() {
  1814. return getListByStatus(PmProjectStatus.DEMAND_WAIT_AUDIT.getCode());
  1815. }
  1816. @Override
  1817. public List<PmDemand> taskWaitRelease() {
  1818. return getListByStatus(PmProjectStatus.TASK_WAIT_RELEASE.getCode());
  1819. }
  1820. @Override
  1821. public List<PmDemandResVo> purchaseDemandDocking() {
  1822. List<PmDemand> byStatus = getListByStatusCGB(PmProjectStatus.PURCHASE_DEMAND_DOCKING.getCode());
  1823. return listToVoList(byStatus);
  1824. }
  1825. @Override
  1826. public List<PmDemandResVo> expertFeedback() {
  1827. List<PmDemand> byStatus = getListByStatusCGB(PmProjectStatus.EXPERT_FEEDBACK.getCode());
  1828. return listToVoList(byStatus);
  1829. }
  1830. @Override
  1831. public List<PmDemandResVo> procurementDocumentsReview() {
  1832. List<PmDemand> byStatus = getListByStatusCGB(PmProjectStatus.PROCUREMENT_DOCUMENTS_REVIEW.getCode());
  1833. return listToVoList(byStatus);
  1834. }
  1835. @Override
  1836. public List<PmDemandResVo> procurementAnnouncement() {
  1837. List<PmDemand> byStatus = getListByStatusCGB(PmProjectStatus.PROCUREMENT_ANNOUNCEMENT.getCode());
  1838. return listToVoList(byStatus);
  1839. }
  1840. @Override
  1841. public List<PmDemandResVo> preBidQuery() {
  1842. List<PmDemand> byStatus = getListByStatusCGB(PmProjectStatus.PRE_BID_QUERY.getCode());
  1843. return listToVoList(byStatus);
  1844. }
  1845. @Override
  1846. public List<PmDemandResVo> waitOpenBid() {
  1847. List<PmDemand> byStatus = getListByStatusCGB(PmProjectStatus.WAIT_OPEN_BID.getCode());
  1848. return listToVoList(byStatus);
  1849. }
  1850. @Override
  1851. public List<PmDemandResVo> bidResultAnnouncement() {
  1852. List<PmDemand> byStatus = getListByStatusCGB(PmProjectStatus.BID_RESULT_ANNOUNCEMENT.getCode());
  1853. return listToVoList(byStatus);
  1854. }
  1855. @Override
  1856. public List<PmDemandResVo> wasteBidHandle() {
  1857. List<PmDemand> byStatus = getListByStatusCGB(PmProjectStatus.WASTE_BID_HANDLE.getCode());
  1858. return listToVoList(byStatus);
  1859. }
  1860. @Override
  1861. public List<PmDemandResVo> postBidQuery() {
  1862. List<PmDemand> byStatus = getListByStatusCGB(PmProjectStatus.POST_BID_QUERY.getCode());
  1863. return listToVoList(byStatus);
  1864. }
  1865. @Override
  1866. public AjaxResult procurementOfficeWillManipulateTotal() {
  1867. List<HomeToDoQueryResVo> homeRes = new ArrayList<>();
  1868. // 采购需求对接,专家意见反馈,采购文件编制审核,采购公告发布,标前质疑投诉,待开标,评标结果公告,流废标处置,标后质疑
  1869. List<PmDemandResVo> demandRes = new ArrayList<>();
  1870. List<String> projectStatus = new ArrayList<>();
  1871. projectStatus.add(PmProjectStatus.PURCHASE_DEMAND_DOCKING.getCode());
  1872. projectStatus.add(PmProjectStatus.EXPERT_FEEDBACK.getCode());
  1873. projectStatus.add(PmProjectStatus.PROCUREMENT_DOCUMENTS_REVIEW.getCode());
  1874. projectStatus.add(PmProjectStatus.PROCUREMENT_ANNOUNCEMENT.getCode());
  1875. projectStatus.add(PmProjectStatus.PRE_BID_QUERY.getCode());
  1876. projectStatus.add(PmProjectStatus.WAIT_OPEN_BID.getCode());
  1877. projectStatus.add(PmProjectStatus.BID_RESULT_ANNOUNCEMENT.getCode());
  1878. projectStatus.add(PmProjectStatus.WASTE_BID_HANDLE.getCode());
  1879. projectStatus.add(PmProjectStatus.POST_BID_QUERY.getCode());
  1880. demandRes = listToVoList(getListByStatusTotalCGB(projectStatus));
  1881. //计划数据--发函催告
  1882. List<PlanQuarterResponseVo> planRes = planYearsService.willSendLetter();
  1883. //转为首页table展示数据
  1884. if (!ObjectUtils.isEmpty(demandRes) && demandRes.size() > 0) {
  1885. for (PmDemandResVo demandResVo : demandRes) {
  1886. HomeToDoQueryResVo home = new HomeToDoQueryResVo();
  1887. home.setEvaluation(BigDecimal.valueOf(demandResVo.getEvaluation()));
  1888. BeanUtils.copyProperties(demandResVo, home);
  1889. homeRes.add(home);
  1890. }
  1891. }
  1892. if (!ObjectUtils.isEmpty(planRes) && planRes.size() > 0) {
  1893. for (PlanQuarterResponseVo planVo : planRes) {
  1894. HomeToDoQueryResVo home = new HomeToDoQueryResVo();
  1895. BeanUtils.copyProperties(planVo, home);
  1896. homeRes.add(home);
  1897. }
  1898. }
  1899. return AjaxResult.success(homeRes);
  1900. }
  1901. @Override
  1902. public AjaxResult procurementOfficeWillManipulateTotalNum() {
  1903. List<StatisticalChartsResVo> result = new ArrayList<>();
  1904. // 采购需求对接,专家意见反馈,采购文件编制审核,采购公告发布,标前质疑投诉,待开标,评标结果公告,流废标处置,标后质疑
  1905. Integer numByStatus = getNumByStatusCGB(PmProjectStatus.PURCHASE_DEMAND_DOCKING.getCode());
  1906. StatisticalChartsResVo chartsResVo = new StatisticalChartsResVo();
  1907. chartsResVo.setNum(numByStatus);
  1908. chartsResVo.setColumnName("采购需求对接");
  1909. result.add(chartsResVo);
  1910. Integer numByStatus1 = getNumByStatusCGB(PmProjectStatus.EXPERT_FEEDBACK.getCode());
  1911. StatisticalChartsResVo chartsResVo1 = new StatisticalChartsResVo();
  1912. chartsResVo1.setColumnName("专家意见反馈");
  1913. chartsResVo1.setNum(numByStatus1);
  1914. result.add(chartsResVo1);
  1915. Integer numByStatus2 = getNumByStatusCGB(PmProjectStatus.PROCUREMENT_DOCUMENTS_REVIEW.getCode());
  1916. StatisticalChartsResVo chartsResVo2 = new StatisticalChartsResVo();
  1917. chartsResVo2.setColumnName("采购文件编制审核");
  1918. chartsResVo2.setNum(numByStatus2);
  1919. result.add(chartsResVo2);
  1920. Integer numByStatus3 = getNumByStatusCGB(PmProjectStatus.PROCUREMENT_ANNOUNCEMENT.getCode());
  1921. StatisticalChartsResVo chartsResVo3 = new StatisticalChartsResVo();
  1922. chartsResVo3.setColumnName("采购公告发布");
  1923. chartsResVo3.setNum(numByStatus3);
  1924. result.add(chartsResVo3);
  1925. Integer numByStatus4 = getNumByStatusCGB(PmProjectStatus.PRE_BID_QUERY.getCode());
  1926. StatisticalChartsResVo chartsResVo4 = new StatisticalChartsResVo();
  1927. chartsResVo4.setColumnName("标前质疑投诉");
  1928. chartsResVo4.setNum(numByStatus4);
  1929. result.add(chartsResVo4);
  1930. Integer numByStatus5 = getNumByStatusCGB(PmProjectStatus.WAIT_OPEN_BID.getCode());
  1931. StatisticalChartsResVo chartsResVo5 = new StatisticalChartsResVo();
  1932. chartsResVo5.setColumnName("待开标");
  1933. chartsResVo5.setNum(numByStatus5);
  1934. result.add(chartsResVo5);
  1935. Integer numByStatus6 = getNumByStatusCGB(PmProjectStatus.BID_RESULT_ANNOUNCEMENT.getCode());
  1936. StatisticalChartsResVo chartsResVo6 = new StatisticalChartsResVo();
  1937. chartsResVo6.setColumnName("评标结果公告");
  1938. chartsResVo6.setNum(numByStatus6);
  1939. result.add(chartsResVo6);
  1940. Integer numByStatus7 = getNumByStatusCGB(PmProjectStatus.WASTE_BID_HANDLE.getCode());
  1941. StatisticalChartsResVo chartsResVo7 = new StatisticalChartsResVo();
  1942. chartsResVo7.setColumnName("流废标处置");
  1943. chartsResVo7.setNum(numByStatus7);
  1944. result.add(chartsResVo7);
  1945. Integer numByStatus8 = getNumByStatusCGB(PmProjectStatus.POST_BID_QUERY.getCode());
  1946. StatisticalChartsResVo chartsResVo8 = new StatisticalChartsResVo();
  1947. chartsResVo8.setColumnName("标后质疑");
  1948. chartsResVo8.setNum(numByStatus8);
  1949. result.add(chartsResVo8);
  1950. //计划数据--发函催告
  1951. Integer letterNum = planYearsService.willSendLetterNum();
  1952. StatisticalChartsResVo chartsResVo9 = new StatisticalChartsResVo();
  1953. chartsResVo9.setColumnName("发函催告");
  1954. chartsResVo9.setNum(letterNum);
  1955. result.add(chartsResVo9);
  1956. StatisticalChartsResVo chartsResVoT = new StatisticalChartsResVo();
  1957. chartsResVoT.setColumnName("全部");
  1958. chartsResVoT.setNum(willTotal(result));
  1959. result.add(chartsResVoT);
  1960. return AjaxResult.success(result);
  1961. }
  1962. public Integer willTotal(List<StatisticalChartsResVo> result) {
  1963. Integer re = 0;
  1964. if (!ObjectUtils.isEmpty(result)) {
  1965. for (StatisticalChartsResVo resVo : result) {
  1966. re += resVo.getNum();
  1967. }
  1968. }
  1969. return re;
  1970. }
  1971. /**
  1972. * 统计分析-采购项目信息统计
  1973. *
  1974. * @param pmDemandReqVo
  1975. * @return
  1976. */
  1977. @Override
  1978. public Map<String, Integer> purchaseProjectStatistical(PmDemandReqVo pmDemandReqVo) {
  1979. //是-1就是查询自己及子孙级以下,否则只查询指定部门
  1980. pmDemandReqVo.setDeptList(isQueryAll(pmDemandReqVo.getPurchaseDeptId()));
  1981. Map<String, Integer> mapReturn = new HashMap<>();
  1982. // 查询项目总数量
  1983. Map<String, Integer> mapCount = pmDemandMapper.purchaseProjectStatistical(pmDemandReqVo);
  1984. // 查询已完成项目数量,预算(合同)金额数量
  1985. Map<String, Integer> mapYWC = pmDemandMapper.purchaseProjectStatisticalYWC(pmDemandReqVo);
  1986. // 查询新创建项目数量,预算金额数量
  1987. Map<String, Integer> mapXCJ = pmDemandMapper.purchaseProjectStatisticalXCJ(pmDemandReqVo);
  1988. // 查询去年完成项目数量,预算(合同)金额数量
  1989. Map<String, Integer> mapQNWC = pmDemandMapper.purchaseProjectStatisticalQNWC(pmDemandReqVo);
  1990. mapReturn.putAll(mapCount);
  1991. mapReturn.putAll(mapYWC);
  1992. mapReturn.putAll(mapXCJ);
  1993. mapReturn.putAll(mapQNWC);
  1994. return mapReturn;
  1995. }
  1996. @Override
  1997. public List<StatisticalChartsResVo> countByProjectAttr(PmDemandReqVo pmDemandReqVo) {
  1998. //是-1就是查询自己及子孙级以下,否则只查询指定部门
  1999. if (pmDemandReqVo.getPurchaseDeptId().equals(-1)) {
  2000. pmDemandReqVo.setDeptList(isQueryAll(pmDemandReqVo.getPurchaseDeptId()));
  2001. } else {
  2002. pmDemandReqVo.setDemandIdAll(isQueryZD(pmDemandReqVo.getPurchaseDeptId()));
  2003. }
  2004. List<StatisticalChartsResVo> resVos = new ArrayList<>();
  2005. //直接获取每个属性的数量
  2006. //重点采购项目
  2007. pmDemandReqVo.setProjectAttr(ProjectAttribute.emergency.getCode());
  2008. StatisticalChartsResVo vo1 = pmDemandMapper.countByProjectAttr(pmDemandReqVo);
  2009. vo1.setColumnName("重点采购项目");
  2010. resVos.add(vo1);
  2011. //重大规划任务项目
  2012. pmDemandReqVo.setProjectAttr(ProjectAttribute.majorPlan.getCode());
  2013. StatisticalChartsResVo vo2 = pmDemandMapper.countByProjectAttr(pmDemandReqVo);
  2014. vo2.setColumnName("重大规划任务项目");
  2015. resVos.add(vo2);
  2016. //规划任务项目
  2017. pmDemandReqVo.setProjectAttr(ProjectAttribute.plan.getCode());
  2018. StatisticalChartsResVo vo3 = pmDemandMapper.countByProjectAttr(pmDemandReqVo);
  2019. vo3.setColumnName("规划任务项目");
  2020. resVos.add(vo3);
  2021. //一般采购项目
  2022. pmDemandReqVo.setProjectAttr(ProjectAttribute.commonly.getCode());
  2023. StatisticalChartsResVo vo4 = pmDemandMapper.countByProjectAttr(pmDemandReqVo);
  2024. vo4.setColumnName("一般采购项目");
  2025. resVos.add(vo4);
  2026. return resVos;
  2027. }
  2028. @Override
  2029. public List<StatisticalChartsResVo> countByTaskAttr(PmDemandReqVo pmDemandReqVo) {
  2030. //是-1就是查询自己及子孙级以下,否则只查询指定部门
  2031. if (pmDemandReqVo.getPurchaseDeptId().equals(-1)) {
  2032. pmDemandReqVo.setDeptList(isQueryAll(pmDemandReqVo.getPurchaseDeptId()));
  2033. } else {
  2034. pmDemandReqVo.setDemandIdAll(isQueryZD(pmDemandReqVo.getPurchaseDeptId()));
  2035. }
  2036. //状态为“任务待下达”以后的数据
  2037. pmDemandReqVo.setProjectStatus(Long.valueOf(PmProjectStatus.TASK_WAIT_RELEASE.getCode()));
  2038. List<StatisticalChartsResVo> resVos = new ArrayList<>();
  2039. //重点采购项目
  2040. pmDemandReqVo.setProjectAttr(ProjectAttribute.emergency.getCode());
  2041. StatisticalChartsResVo vo1 = pmDemandMapper.countByTaskAttr(pmDemandReqVo);
  2042. vo1.setColumnName("重点采购项目");
  2043. resVos.add(vo1);
  2044. //重大规划任务项目
  2045. pmDemandReqVo.setProjectAttr(ProjectAttribute.majorPlan.getCode());
  2046. StatisticalChartsResVo vo2 = pmDemandMapper.countByTaskAttr(pmDemandReqVo);
  2047. vo2.setColumnName("重大规划任务项目");
  2048. resVos.add(vo2);
  2049. //规划任务项目
  2050. pmDemandReqVo.setProjectAttr(ProjectAttribute.plan.getCode());
  2051. StatisticalChartsResVo vo3 = pmDemandMapper.countByTaskAttr(pmDemandReqVo);
  2052. vo3.setColumnName("规划任务项目");
  2053. resVos.add(vo3);
  2054. //一般采购项目
  2055. pmDemandReqVo.setProjectAttr(ProjectAttribute.commonly.getCode());
  2056. StatisticalChartsResVo vo4 = pmDemandMapper.countByTaskAttr(pmDemandReqVo);
  2057. vo4.setColumnName("一般采购项目");
  2058. resVos.add(vo4);
  2059. return resVos;
  2060. }
  2061. @Override
  2062. public List<StatisticalChartsResVo> countByPurchaseMode(PmDemandReqVo pmDemandReqVo) {
  2063. //是-1就是查询自己及子孙级以下,否则只查询指定部门
  2064. if (pmDemandReqVo.getPurchaseDeptId().equals(-1)) {
  2065. pmDemandReqVo.setDeptList(isQueryAll(pmDemandReqVo.getPurchaseDeptId()));
  2066. } else {
  2067. pmDemandReqVo.setDemandIdAll(isQueryZD(pmDemandReqVo.getPurchaseDeptId()));
  2068. }
  2069. //状态为“任务待下达”以后的数据
  2070. pmDemandReqVo.setProjectStatus(Long.valueOf(PmProjectStatus.TASK_WAIT_RELEASE.getCode()));
  2071. List<StatisticalChartsResVo> resVos = new ArrayList<>();
  2072. //公开招标
  2073. pmDemandReqVo.setPurchaseMode(ProcurementMethodSuggest.OPEN_BIDDING.getCode());
  2074. StatisticalChartsResVo chartsR = pmDemandMapper.countByPurchaseMode(pmDemandReqVo);
  2075. chartsR.setColumnName("公开招标");
  2076. resVos.add(chartsR);
  2077. //邀请招标
  2078. pmDemandReqVo.setPurchaseMode(ProcurementMethodSuggest.SELECTED_BIDDING.getCode());
  2079. StatisticalChartsResVo chartsR1 = pmDemandMapper.countByPurchaseMode(pmDemandReqVo);
  2080. chartsR1.setColumnName("邀请招标");
  2081. resVos.add(chartsR1);
  2082. //竞争性谈判
  2083. pmDemandReqVo.setPurchaseMode(ProcurementMethodSuggest.COMPETITIVE_NEGOTIATION.getCode());
  2084. StatisticalChartsResVo chartsR2 = pmDemandMapper.countByPurchaseMode(pmDemandReqVo);
  2085. chartsR2.setColumnName("竞争性谈判");
  2086. resVos.add(chartsR2);
  2087. //询价
  2088. pmDemandReqVo.setPurchaseMode(ProcurementMethodSuggest.ENQUIRY.getCode());
  2089. StatisticalChartsResVo chartsR3 = pmDemandMapper.countByPurchaseMode(pmDemandReqVo);
  2090. chartsR3.setColumnName("询价");
  2091. resVos.add(chartsR3);
  2092. //单一来源
  2093. pmDemandReqVo.setPurchaseMode(ProcurementMethodSuggest.SINGLE_SOURCE.getCode());
  2094. StatisticalChartsResVo chartsR4 = pmDemandMapper.countByPurchaseMode(pmDemandReqVo);
  2095. chartsR4.setColumnName("单一来源");
  2096. resVos.add(chartsR4);
  2097. return resVos;
  2098. }
  2099. @Override
  2100. public List<StatisticalChartsResVo> countByEvaluation(PmDemandReqVo pmDemandReqVo) {
  2101. //是-1就是查询自己及子孙级以下,否则只查询指定部门
  2102. if (pmDemandReqVo.getPurchaseDeptId().equals(-1)) {
  2103. pmDemandReqVo.setDeptList(isQueryAll(pmDemandReqVo.getPurchaseDeptId()));
  2104. } else {
  2105. pmDemandReqVo.setDemandIdAll(isQueryZD(pmDemandReqVo.getPurchaseDeptId()));
  2106. }
  2107. //状态为“任务待下达”以后的数据
  2108. pmDemandReqVo.setProjectStatus(Long.valueOf(PmProjectStatus.TASK_WAIT_RELEASE.getCode()));
  2109. List<StatisticalChartsResVo> resVos = new ArrayList<>();
  2110. //概算金额包括:100万以下采购任务、100至500万元采购任务、500至1000万元采购任务、1000至5000万元采购任务、5000至1亿元采购任务、1亿元及以上采购任务
  2111. pmDemandReqVo.setEvaluation(100);
  2112. StatisticalChartsResVo resVo = pmDemandMapper.countByEvaluationLt(pmDemandReqVo);
  2113. resVo.setColumnName("100万以下采购任务");
  2114. resVos.add(resVo);
  2115. pmDemandReqVo.setEvaluation(100);
  2116. pmDemandReqVo.setEvaluationEnd(500);
  2117. StatisticalChartsResVo resVo1 = pmDemandMapper.countByEvaluationBet(pmDemandReqVo);
  2118. resVo1.setColumnName("100至500万元采购任务");
  2119. resVos.add(resVo1);
  2120. pmDemandReqVo.setEvaluation(500);
  2121. pmDemandReqVo.setEvaluationEnd(1000);
  2122. StatisticalChartsResVo resVo2 = pmDemandMapper.countByEvaluationBet(pmDemandReqVo);
  2123. resVo2.setColumnName("500至1000万元采购任务");
  2124. resVos.add(resVo2);
  2125. pmDemandReqVo.setEvaluation(1000);
  2126. pmDemandReqVo.setEvaluationEnd(5000);
  2127. StatisticalChartsResVo resVo3 = pmDemandMapper.countByEvaluationBet(pmDemandReqVo);
  2128. resVo3.setColumnName("1000至5000万元采购任务");
  2129. resVos.add(resVo3);
  2130. pmDemandReqVo.setEvaluation(5000);
  2131. pmDemandReqVo.setEvaluationEnd(10000);
  2132. StatisticalChartsResVo resVo4 = pmDemandMapper.countByEvaluationBet(pmDemandReqVo);
  2133. resVo4.setColumnName("5000至1亿元采购任务");
  2134. resVos.add(resVo4);
  2135. pmDemandReqVo.setEvaluation(10000);
  2136. StatisticalChartsResVo resVo5 = pmDemandMapper.countByEvaluationGt(pmDemandReqVo);
  2137. resVo5.setColumnName("1亿元及以上采购任务");
  2138. resVos.add(resVo5);
  2139. return resVos;
  2140. }
  2141. @Override
  2142. public AjaxResult countProjectExceed(PmDemandReqVo pmDemandReqVo) {
  2143. //是-1就是查询自己及子孙级以下,否则只查询指定部门
  2144. if (pmDemandReqVo.getPurchaseDeptId().equals(-1)) {
  2145. pmDemandReqVo.setDeptList(isQueryAll(pmDemandReqVo.getPurchaseDeptId()));
  2146. } else {
  2147. pmDemandReqVo.setDemandIdAll(isQueryZD(pmDemandReqVo.getPurchaseDeptId()));
  2148. }
  2149. List<StatisticalChartsResVo> resVos = new ArrayList<>();
  2150. //执行滞后采购项目:本年度所有的逾期项目数
  2151. //预算金额:本年度所有逾期项目累加的预算金额
  2152. StatisticalChartsResVo resVo = pmDemandMapper.countProjectExceedThisYear(pmDemandReqVo);
  2153. resVo.setColumnName("本年度执行滞后任务");
  2154. resVo.setColumnNamePlus("任务新增数量");
  2155. resVos.add(resVo);
  2156. StatisticalChartsResVo resVo2 = pmDemandMapper.countProjectExceedThisQua(pmDemandReqVo);
  2157. resVo2.setColumnName("本季度执行滞后任务");
  2158. resVo2.setColumnNamePlus("任务新增数量");
  2159. resVos.add(resVo2);
  2160. StatisticalChartsResVo resVo3 = pmDemandMapper.countProjectExceedThisMonth(pmDemandReqVo);
  2161. resVo3.setColumnName("本月执行滞后任务");
  2162. resVo3.setColumnNamePlus("任务新增数量");
  2163. resVos.add(resVo3);
  2164. StatisticalChartsResVo resVo4 = pmDemandMapper.countProjectExceedAllNum(pmDemandReqVo);
  2165. resVo4.setColumnName("累计执行滞后采购任务");
  2166. resVo4.setColumnNamePlus("采购任务数量");
  2167. resVos.add(resVo4);
  2168. //执行停滞采购任务数量--退回的采购任务数量
  2169. List<String> tzrw = new ArrayList<>();
  2170. tzrw.add(PmProjectStatus.DEMAND_AUDIT_RETURN.getCode());
  2171. pmDemandReqVo.setProjectStatusList(tzrw);
  2172. Map<String, Object> map = pmDemandMapper.purchaseProjectDistribution(pmDemandReqVo);
  2173. StatisticalChartsResVo resVo5 = new StatisticalChartsResVo();
  2174. resVo5.setColumnName("执行停滞");
  2175. resVo5.setColumnNamePlus("采购任务数量");
  2176. resVo5.setNum(Math.toIntExact((Long) map.get("countNumber")));
  2177. resVo5.setEvaluationTotal((BigDecimal) map.get("evaluationTotal"));
  2178. resVos.add(resVo5);
  2179. return AjaxResult.success(resVos);
  2180. }
  2181. /**
  2182. * 统计不同时间维度的逾期项目
  2183. *
  2184. * @return
  2185. */
  2186. @Override
  2187. public AjaxResult exceedAnalysis(PmDemandReqVo pmDemandReqVo) {
  2188. //是-1就是查询自己及子孙级以下,否则只查询指定部门
  2189. pmDemandReqVo.setDeptList(isQueryAll(pmDemandReqVo.getPurchaseDeptId()));
  2190. HashMap<String, List<StatisticalChartsResVo>> resMap = new HashMap<>();
  2191. List<StatisticalChartsResVo> byYear = pmDemandMapper.countProjectExceedYear(pmDemandReqVo);
  2192. if (pmDemandReqVo.getTimeType().equals("1")) {
  2193. resMap.put("年", byYear);
  2194. } else if (pmDemandReqVo.getTimeType().equals("2")) {
  2195. List<StatisticalChartsResVo> byQuarter = new LinkedList<>();
  2196. for (StatisticalChartsResVo chartsResVo : byYear) {
  2197. pmDemandReqVo.setYear(Integer.parseInt(chartsResVo.getColumnName()));
  2198. for (int i = 1; i <= 4; i++) {
  2199. pmDemandReqVo.setQuarter(i);
  2200. StatisticalChartsResVo quarter = pmDemandMapper.countProjectExceedQuarter(pmDemandReqVo);
  2201. if (ObjectUtils.isEmpty(quarter)) {
  2202. StatisticalChartsResVo vo = new StatisticalChartsResVo("", "", 0, BigDecimal.valueOf(0), BigDecimal.valueOf(0));
  2203. quarter = vo;
  2204. quarter.setColumnName(chartsResVo.getColumnName() + "年第" + i + "季度");
  2205. }
  2206. quarter.setColumnName(chartsResVo.getColumnName() + "年第" + i + "季度");
  2207. byQuarter.add(quarter);
  2208. }
  2209. }
  2210. resMap.put("季度", byQuarter);
  2211. } else if (pmDemandReqVo.getTimeType().equals("3")) {
  2212. List<StatisticalChartsResVo> byMonth = new LinkedList<>();
  2213. for (StatisticalChartsResVo chartsResVo : byYear) {
  2214. pmDemandReqVo.setYear(Integer.parseInt(chartsResVo.getColumnName()));
  2215. for (int i = 1; i <= 12; i++) {
  2216. pmDemandReqVo.setMonth(i);
  2217. StatisticalChartsResVo month = pmDemandMapper.countProjectExceedMonth(pmDemandReqVo);
  2218. if (ObjectUtils.isEmpty(month)) {
  2219. StatisticalChartsResVo vo = new StatisticalChartsResVo("", "", 0, BigDecimal.valueOf(0), BigDecimal.valueOf(0));
  2220. month = vo;
  2221. month.setColumnName(chartsResVo.getColumnName() + "年" + i + "月");
  2222. }
  2223. month.setColumnName(chartsResVo.getColumnName() + "年" + i + "月");
  2224. byMonth.add(month);
  2225. }
  2226. }
  2227. resMap.put("月", byMonth);
  2228. }
  2229. return AjaxResult.success(resMap);
  2230. }
  2231. @Override
  2232. public AjaxResult taskQuantityAnalysis(PmDemandReqVo pmDemandReqVo) {
  2233. //是-1就是查询自己及子孙级以下,否则只查询指定部门
  2234. pmDemandReqVo.setDeptList(isQueryAll(pmDemandReqVo.getPurchaseDeptId()));
  2235. HashMap<String, List<StatisticalChartsResVo>> resMap = new HashMap<>();
  2236. //任务数量趋势分析:按照月、季度、年统计“项目属性”字段中“重大规划”属性的项目
  2237. List<StatisticalChartsResVo> byYear = pmDemandMapper.countProjectMajorByYear(pmDemandReqVo);
  2238. if (pmDemandReqVo.getTimeType().equals("1")) {
  2239. resMap.put("年", byYear);
  2240. } else if (pmDemandReqVo.getTimeType().equals("2")) {
  2241. List<StatisticalChartsResVo> byQuarter = new LinkedList<>();
  2242. for (StatisticalChartsResVo chartsResVo : byYear) {
  2243. pmDemandReqVo.setYear(Integer.parseInt(chartsResVo.getColumnName()));
  2244. for (int i = 1; i <= 4; i++) {
  2245. pmDemandReqVo.setQuarter(i);
  2246. StatisticalChartsResVo quarter = pmDemandMapper.countProjectMajorByQuarter(pmDemandReqVo);
  2247. quarter.setColumnName(chartsResVo.getColumnName() + "年第" + i + "季度");
  2248. byQuarter.add(quarter);
  2249. }
  2250. }
  2251. resMap.put("季度", byQuarter);
  2252. } else if (pmDemandReqVo.getTimeType().equals("3")) {
  2253. List<StatisticalChartsResVo> byMonth = pmDemandMapper.countProjectMajorByMonth(pmDemandReqVo);
  2254. resMap.put("月", byMonth);
  2255. }
  2256. return AjaxResult.success(resMap);
  2257. }
  2258. @Override
  2259. public AjaxResult countEveryStatusNum(PmDemandReqVo pmDemandReqVo) {
  2260. //阶段包括:采购需求对接,专家意见反馈,采购文件编制审核,采购公告发布,标前质疑投诉,待开标,评标结果公告,流废标处置,标后质疑
  2261. //是-1就是查询自己及子孙级以下,否则只查询指定部门
  2262. if (pmDemandReqVo.getPurchaseDeptId().equals(-1)) {
  2263. pmDemandReqVo.setDeptList(isQueryAll(pmDemandReqVo.getPurchaseDeptId()));
  2264. } else {
  2265. pmDemandReqVo.setDemandIdAll(isQueryZD(pmDemandReqVo.getPurchaseDeptId()));
  2266. }
  2267. List<StatisticalChartsResVo> everyStatusNum = new ArrayList<>();
  2268. //项目进行到各个阶段的数量
  2269. pmDemandReqVo.setProjectStatus(Long.valueOf(PmProjectStatus.PURCHASE_DEMAND_DOCKING.getCode()));
  2270. StatisticalChartsResVo everyStatusNum9 = pmDemandMapper.countEveryStatusNum(pmDemandReqVo);
  2271. everyStatusNum9.setColumnName(PmProjectStatus.PURCHASE_DEMAND_DOCKING.getInfo());
  2272. everyStatusNum.add(everyStatusNum9);
  2273. pmDemandReqVo.setProjectStatus(Long.valueOf(PmProjectStatus.EXPERT_FEEDBACK.getCode()));
  2274. StatisticalChartsResVo everyStatusNum10 = pmDemandMapper.countEveryStatusNum(pmDemandReqVo);
  2275. everyStatusNum10.setColumnName(PmProjectStatus.EXPERT_FEEDBACK.getInfo());
  2276. everyStatusNum.add(everyStatusNum10);
  2277. pmDemandReqVo.setProjectStatus(Long.valueOf(PmProjectStatus.PROCUREMENT_DOCUMENTS_REVIEW.getCode()));
  2278. StatisticalChartsResVo everyStatusNum11 = pmDemandMapper.countEveryStatusNum(pmDemandReqVo);
  2279. everyStatusNum11.setColumnName(PmProjectStatus.PROCUREMENT_DOCUMENTS_REVIEW.getInfo());
  2280. everyStatusNum.add(everyStatusNum11);
  2281. pmDemandReqVo.setProjectStatus(Long.valueOf(PmProjectStatus.PROCUREMENT_ANNOUNCEMENT.getCode()));
  2282. StatisticalChartsResVo everyStatusNum12 = pmDemandMapper.countEveryStatusNum(pmDemandReqVo);
  2283. everyStatusNum12.setColumnName(PmProjectStatus.PROCUREMENT_ANNOUNCEMENT.getInfo());
  2284. everyStatusNum.add(everyStatusNum12);
  2285. pmDemandReqVo.setProjectStatus(Long.valueOf(PmProjectStatus.PRE_BID_QUERY.getCode()));
  2286. StatisticalChartsResVo everyStatusNum13 = pmDemandMapper.countEveryStatusNum(pmDemandReqVo);
  2287. everyStatusNum13.setColumnName(PmProjectStatus.PRE_BID_QUERY.getInfo());
  2288. everyStatusNum.add(everyStatusNum13);
  2289. pmDemandReqVo.setProjectStatus(Long.valueOf(PmProjectStatus.WAIT_OPEN_BID.getCode()));
  2290. StatisticalChartsResVo everyStatusNum14 = pmDemandMapper.countEveryStatusNum(pmDemandReqVo);
  2291. everyStatusNum14.setColumnName(PmProjectStatus.WAIT_OPEN_BID.getInfo());
  2292. everyStatusNum.add(everyStatusNum14);
  2293. pmDemandReqVo.setProjectStatus(Long.valueOf(PmProjectStatus.BID_RESULT_ANNOUNCEMENT.getCode()));
  2294. StatisticalChartsResVo everyStatusNum15 = pmDemandMapper.countEveryStatusNum(pmDemandReqVo);
  2295. everyStatusNum15.setColumnName(PmProjectStatus.BID_RESULT_ANNOUNCEMENT.getInfo());
  2296. everyStatusNum.add(everyStatusNum15);
  2297. pmDemandReqVo.setProjectStatus(Long.valueOf(PmProjectStatus.WASTE_BID_HANDLE.getCode()));
  2298. StatisticalChartsResVo everyStatusNum16 = pmDemandMapper.countEveryStatusNum(pmDemandReqVo);
  2299. everyStatusNum16.setColumnName(PmProjectStatus.WASTE_BID_HANDLE.getInfo());
  2300. everyStatusNum.add(everyStatusNum16);
  2301. pmDemandReqVo.setProjectStatus(Long.valueOf(PmProjectStatus.POST_BID_QUERY.getCode()));
  2302. StatisticalChartsResVo everyStatusNum17 = pmDemandMapper.countEveryStatusNum(pmDemandReqVo);
  2303. everyStatusNum17.setColumnName(PmProjectStatus.POST_BID_QUERY.getInfo());
  2304. everyStatusNum.add(everyStatusNum17);
  2305. return AjaxResult.success(everyStatusNum);
  2306. }
  2307. @Override
  2308. public AjaxResult exceedMarketAnalysis(PmDemandReqVo pmDemandReqVo) {
  2309. //是-1就是查询自己及子孙级以下,否则只查询指定部门
  2310. if (pmDemandReqVo.getPurchaseDeptId().equals(-1)) {
  2311. pmDemandReqVo.setDeptList(isQueryAll(pmDemandReqVo.getPurchaseDeptId()));
  2312. } else {
  2313. pmDemandReqVo.setDemandIdAll(isQueryZD(pmDemandReqVo.getPurchaseDeptId()));
  2314. }
  2315. //所有滞后
  2316. List<PmDemand> demandList = pmDemandMapper.countProjectExceedAll(pmDemandReqVo);
  2317. Date now = new Date();
  2318. //滞后时长包括:滞后1个月以内的采购任务、滞后1至3个月采购任务、滞后3至6个月采购任务、滞后6个月至1年采购任务、滞后1年以上采购任务
  2319. HashMap<String, Integer> map = new LinkedHashMap<>();
  2320. map.put("滞后1个月以内的采购任务", 0);
  2321. map.put("滞后1至3个月采购任务", 0);
  2322. map.put("滞后3至6个月采购任务", 0);
  2323. map.put("滞后6个月至1年采购任务", 0);
  2324. map.put("滞后1年以上采购任务", 0);
  2325. if (!ObjectUtils.isEmpty(demandList) && demandList.size() > 0) {
  2326. for (PmDemand demand : demandList) {
  2327. //滞后时间
  2328. Long exTime = 0L;
  2329. if (!ObjectUtils.isEmpty(demand.getRealPurchaseFinishTime()) && demand.getRealPurchaseFinishTime().getTime() - demand.getPlanPurchaseFinishTime().getTime() > 0) {
  2330. exTime = demand.getRealPurchaseFinishTime().getTime() - demand.getPlanPurchaseFinishTime().getTime();
  2331. } else {
  2332. exTime = now.getTime() - demand.getPlanPurchaseFinishTime().getTime();
  2333. }
  2334. if (exTime < Long.valueOf("2592000000")) {
  2335. map.put("滞后1个月以内的采购任务", map.get("滞后1个月以内的采购任务") + 1);
  2336. }
  2337. if (exTime >= Long.valueOf("2592000000") && exTime < Long.valueOf("7776000000")) {
  2338. map.put("滞后1至3个月采购任务", map.get("滞后1至3个月采购任务") + 1);
  2339. }
  2340. if (exTime >= Long.valueOf("7776000000") && exTime < Long.valueOf("15552000000")) {
  2341. map.put("滞后3至6个月采购任务", map.get("滞后3至6个月采购任务") + 1);
  2342. }
  2343. if (exTime >= Long.valueOf("15552000000") && exTime < Long.valueOf("31104000000")) {
  2344. map.put("滞后6个月至1年采购任务", map.get("滞后6个月至1年采购任务") + 1);
  2345. }
  2346. if (exTime > Long.valueOf("31104000000")) {
  2347. map.put("滞后1年以上采购任务", map.get("滞后1年以上采购任务") + 1);
  2348. }
  2349. }
  2350. }
  2351. return AjaxResult.success(map);
  2352. }
  2353. @Override
  2354. public AjaxResult countMajorProject(PmDemandReqVo pmDemandReqVo) {
  2355. //是-1就是查询自己及子孙级以下,否则只查询指定部门
  2356. if (pmDemandReqVo.getPurchaseDeptId().equals(-1)) {
  2357. pmDemandReqVo.setDeptList(isQueryAll(pmDemandReqVo.getPurchaseDeptId()));
  2358. } else {
  2359. pmDemandReqVo.setDemandIdAll(isQueryZD(pmDemandReqVo.getPurchaseDeptId()));
  2360. }
  2361. List<StatisticalChartsResVo> resVos = new ArrayList<>();
  2362. //本月度新提报重大规划采购任务数量
  2363. pmDemandReqVo.setProjectStatus(Long.valueOf(PmProjectStatus.DEMAND_WAIT_COMMIT.getCode()));
  2364. StatisticalChartsResVo resVo = pmDemandMapper.majorProjectByStatusThisMonthSub(pmDemandReqVo);
  2365. resVo.setColumnName("本月度新提报");
  2366. resVo.setColumnNamePlus("重大规划采购任务数量");
  2367. resVos.add(resVo);
  2368. //本季度新提报重大规划采购任务数量
  2369. pmDemandReqVo.setProjectStatus(Long.valueOf(PmProjectStatus.DEMAND_WAIT_COMMIT.getCode()));
  2370. StatisticalChartsResVo resVo2 = pmDemandMapper.majorProjectByStatusThisQuaSub(pmDemandReqVo);
  2371. resVo2.setColumnName("本季度新提报");
  2372. resVo2.setColumnNamePlus("重大规划采购任务数量");
  2373. resVos.add(resVo2);
  2374. //本年度新提报重大规划采购任务数量
  2375. pmDemandReqVo.setProjectStatus(Long.valueOf(PmProjectStatus.DEMAND_WAIT_COMMIT.getCode()));
  2376. StatisticalChartsResVo resVo3 = pmDemandMapper.majorProjectByStatusThisYearSub(pmDemandReqVo);
  2377. resVo3.setColumnName("本年度新提报");
  2378. resVo3.setColumnNamePlus("重大规划采购任务数量");
  2379. resVos.add(resVo3);
  2380. //本月度完成重大规划采购任务数量
  2381. pmDemandReqVo.setProjectStatus(Long.valueOf(PmProjectStatus.CONTRACT_WAIT_FILL.getCode()));
  2382. StatisticalChartsResVo resVo4 = pmDemandMapper.majorProjectByStatusThisMonthFi(pmDemandReqVo);
  2383. resVo4.setColumnName("本月度完成");
  2384. resVo4.setColumnNamePlus("重大规划采购任务数量");
  2385. resVos.add(resVo4);
  2386. //本季度完成重大规划采购任务数量
  2387. pmDemandReqVo.setProjectStatus(Long.valueOf(PmProjectStatus.CONTRACT_WAIT_FILL.getCode()));
  2388. StatisticalChartsResVo resVo5 = pmDemandMapper.majorProjectByStatusThisQuaFi(pmDemandReqVo);
  2389. resVo5.setColumnName("本季度完成");
  2390. resVo5.setColumnNamePlus("重大规划采购任务数量");
  2391. resVos.add(resVo5);
  2392. //本年度完成重大规划采购任务数量
  2393. pmDemandReqVo.setProjectStatus(Long.valueOf(PmProjectStatus.CONTRACT_WAIT_FILL.getCode()));
  2394. StatisticalChartsResVo resVo6 = pmDemandMapper.majorProjectByStatusThisYearFi(pmDemandReqVo);
  2395. resVo6.setColumnName("本年度完成");
  2396. resVo6.setColumnNamePlus("重大规划采购任务数量");
  2397. resVos.add(resVo6);
  2398. //上年度结转和本年度新提报重大规划采购任务累计项目数量
  2399. List<String> yearLastZ = new ArrayList<>();
  2400. yearLastZ.add(PmProjectStatus.DEMAND_WAIT_AUDIT.getCode());
  2401. yearLastZ.add(PmProjectStatus.DEMAND_AUDIT_RETURN.getCode());
  2402. yearLastZ.add(PmProjectStatus.TASK_WAIT_RELEASE.getCode());
  2403. yearLastZ.add(PmProjectStatus.PURCHASE_DEMAND_DOCKING.getCode());
  2404. yearLastZ.add(PmProjectStatus.EXPERT_FEEDBACK.getCode());
  2405. yearLastZ.add(PmProjectStatus.PROCUREMENT_DOCUMENTS_REVIEW.getCode());
  2406. yearLastZ.add(PmProjectStatus.PROCUREMENT_ANNOUNCEMENT.getCode());
  2407. yearLastZ.add(PmProjectStatus.PRE_BID_QUERY.getCode());
  2408. yearLastZ.add(PmProjectStatus.WAIT_OPEN_BID.getCode());
  2409. yearLastZ.add(PmProjectStatus.BID_RESULT_ANNOUNCEMENT.getCode());
  2410. yearLastZ.add(PmProjectStatus.WASTE_BID_HANDLE.getCode());
  2411. yearLastZ.add(PmProjectStatus.POST_BID_QUERY.getCode());
  2412. yearLastZ.add(PmProjectStatus.WASTE_BID_RETURN.getCode());
  2413. pmDemandReqVo.setProjectStatusList(yearLastZ);
  2414. StatisticalChartsResVo resVo7 = pmDemandMapper.majorProjectByStatusLastYear(pmDemandReqVo);
  2415. if (ObjectUtils.isEmpty(resVo7)) {
  2416. resVo7 = new StatisticalChartsResVo();
  2417. resVo7.setNum(0);
  2418. resVo7.setEvaluationTotal(BigDecimal.ZERO);
  2419. resVo7.setEvaluationContractTotal(BigDecimal.ZERO);
  2420. }
  2421. resVo7.setNum(resVo7.getNum() + resVo3.getNum());
  2422. resVo7.setEvaluationTotal(resVo7.getEvaluationTotal().add(resVo3.getEvaluationTotal()));
  2423. resVo7.setColumnName("上年度结转和本年度新提报");
  2424. resVo7.setColumnNamePlus("重大规划采购任务累计数量");
  2425. resVos.add(resVo7);
  2426. //今年以来累计完成数量
  2427. pmDemandReqVo.setProjectStatus(Long.valueOf(PmProjectStatus.CONTRACT_WAIT_FILL.getCode()));
  2428. StatisticalChartsResVo resVo8 = pmDemandMapper.majorProjectByStatusToThisYear(pmDemandReqVo);
  2429. resVo8.setColumnName("今年以来累计");
  2430. resVo8.setColumnNamePlus("累计完成数量");
  2431. resVos.add(resVo8);
  2432. //正常推进周期内的重大规划采购任务数量
  2433. StatisticalChartsResVo resVo9 = pmDemandMapper.majorProjectByStatusWei(pmDemandReqVo);
  2434. resVo9.setColumnName("正常推进周期内");
  2435. resVo9.setColumnNamePlus("重大规划采购任务数量");
  2436. resVos.add(resVo9);
  2437. //执行滞后的重大规划采购任务数量
  2438. StatisticalChartsResVo resVo10 = pmDemandMapper.majorProjectByStatusChao(pmDemandReqVo);
  2439. resVo10.setColumnName("执行滞后");
  2440. resVo10.setColumnNamePlus("重大规划采购任务数量");
  2441. resVos.add(resVo10);
  2442. return AjaxResult.success(resVos);
  2443. }
  2444. @Override
  2445. public AjaxResult countMajorProjectCGB(PmDemandReqVo pmDemandReqVo) {
  2446. //是-1就是查询自己及子孙级以下,否则只查询指定部门
  2447. if (pmDemandReqVo.getPurchaseDeptId().equals(-1)) {
  2448. pmDemandReqVo.setDeptList(isQueryAll(pmDemandReqVo.getPurchaseDeptId()));
  2449. } else {
  2450. pmDemandReqVo.setDemandIdAll(isQueryZD(pmDemandReqVo.getPurchaseDeptId()));
  2451. }
  2452. List<StatisticalChartsResVo> resVos = new ArrayList<>();
  2453. //本月度新受领重大规划采购任务数量
  2454. pmDemandReqVo.setProjectStatus(Long.valueOf(PmProjectStatus.TASK_WAIT_RELEASE.getCode()));
  2455. StatisticalChartsResVo resVo = pmDemandMapper.majorProjectByStatusThisMonthNew(pmDemandReqVo);
  2456. resVo.setColumnName("本月度新受领");
  2457. resVo.setColumnNamePlus("重大规划采购任务数量");
  2458. resVos.add(resVo);
  2459. //本季度新受领重大规划采购任务数量
  2460. pmDemandReqVo.setProjectStatus(Long.valueOf(PmProjectStatus.TASK_WAIT_RELEASE.getCode()));
  2461. StatisticalChartsResVo resVo2 = pmDemandMapper.majorProjectByStatusThisQuaNew(pmDemandReqVo);
  2462. resVo2.setColumnName("本季度新受领");
  2463. resVo2.setColumnNamePlus("重大规划采购任务数量");
  2464. resVos.add(resVo2);
  2465. //本年度新受领重大规划采购任务数量
  2466. pmDemandReqVo.setProjectStatus(Long.valueOf(PmProjectStatus.TASK_WAIT_RELEASE.getCode()));
  2467. StatisticalChartsResVo resVo3 = pmDemandMapper.majorProjectByStatusThisYearNew(pmDemandReqVo);
  2468. resVo3.setColumnName("本年度新受领");
  2469. resVo3.setColumnNamePlus("重大规划采购任务数量");
  2470. resVos.add(resVo3);
  2471. //上年度结转重大规划采购任务累计项目数量
  2472. List<String> yearLastZ = new ArrayList<>();
  2473. yearLastZ.add(PmProjectStatus.PURCHASE_DEMAND_DOCKING.getCode());
  2474. yearLastZ.add(PmProjectStatus.EXPERT_FEEDBACK.getCode());
  2475. yearLastZ.add(PmProjectStatus.PROCUREMENT_DOCUMENTS_REVIEW.getCode());
  2476. yearLastZ.add(PmProjectStatus.PROCUREMENT_ANNOUNCEMENT.getCode());
  2477. yearLastZ.add(PmProjectStatus.PRE_BID_QUERY.getCode());
  2478. yearLastZ.add(PmProjectStatus.WAIT_OPEN_BID.getCode());
  2479. yearLastZ.add(PmProjectStatus.BID_RESULT_ANNOUNCEMENT.getCode());
  2480. yearLastZ.add(PmProjectStatus.WASTE_BID_HANDLE.getCode());
  2481. yearLastZ.add(PmProjectStatus.POST_BID_QUERY.getCode());
  2482. yearLastZ.add(PmProjectStatus.WASTE_BID_RETURN.getCode());
  2483. pmDemandReqVo.setProjectStatusList(yearLastZ);
  2484. StatisticalChartsResVo resVo7 = pmDemandMapper.majorProjectByStatusLastYear(pmDemandReqVo);
  2485. if (ObjectUtils.isEmpty(resVo7)) {
  2486. resVo7 = new StatisticalChartsResVo();
  2487. resVo7.setNum(0);
  2488. resVo7.setEvaluationTotal(BigDecimal.ZERO);
  2489. resVo7.setEvaluationContractTotal(BigDecimal.ZERO);
  2490. }
  2491. resVo7.setColumnName("上年度结转和本年度新提报");
  2492. resVo7.setColumnNamePlus("累计项目数量");
  2493. //上年度结转和本月度新受领重大规划采购任务累计项目数量预算金额
  2494. pmDemandReqVo.setProjectStatus(Long.valueOf(PmProjectStatus.DEMAND_WAIT_COMMIT.getCode()));
  2495. StatisticalChartsResVo resVo4 = pmDemandMapper.majorProjectByStatusThisMonthFiCGB(pmDemandReqVo);
  2496. if (ObjectUtils.isEmpty(resVo4)) {
  2497. resVo4 = new StatisticalChartsResVo();
  2498. resVo4.setNum(0);
  2499. resVo4.setEvaluationTotal(BigDecimal.ZERO);
  2500. resVo4.setEvaluationContractTotal(BigDecimal.ZERO);
  2501. }
  2502. resVo4.setNum(resVo4.getNum() + resVo7.getNum());
  2503. resVo4.setEvaluationTotal(resVo4.getEvaluationTotal().add(resVo7.getEvaluationTotal()));
  2504. resVo4.setColumnName("上年度结转和本月度新受领");
  2505. resVo4.setColumnNamePlus("累计项目数量");
  2506. resVos.add(resVo4);
  2507. //上年度结转和本季度新受领重大规划采购任务累计项目数量预算金额
  2508. pmDemandReqVo.setProjectStatus(Long.valueOf(PmProjectStatus.DEMAND_WAIT_COMMIT.getCode()));
  2509. StatisticalChartsResVo resVo5 = pmDemandMapper.majorProjectByStatusThisQuaFiCGB(pmDemandReqVo);
  2510. if (ObjectUtils.isEmpty(resVo5)) {
  2511. resVo5 = new StatisticalChartsResVo();
  2512. resVo5.setNum(0);
  2513. resVo5.setEvaluationTotal(BigDecimal.ZERO);
  2514. resVo5.setEvaluationContractTotal(BigDecimal.ZERO);
  2515. }
  2516. resVo5.setNum(resVo5.getNum() + resVo7.getNum());
  2517. resVo5.setEvaluationTotal(resVo5.getEvaluationTotal().add(resVo7.getEvaluationTotal()));
  2518. resVo5.setColumnName("上年度结转和本季度新受领");
  2519. resVo5.setColumnNamePlus("累计项目数量");
  2520. resVos.add(resVo5);
  2521. //上年度结转和本年度新受领重大规划采购任务累计项目数量预算金额
  2522. pmDemandReqVo.setProjectStatus(Long.valueOf(PmProjectStatus.DEMAND_WAIT_COMMIT.getCode()));
  2523. StatisticalChartsResVo resVo6 = pmDemandMapper.majorProjectByStatusThisYearFiCGB(pmDemandReqVo);
  2524. if (ObjectUtils.isEmpty(resVo6)) {
  2525. resVo6 = new StatisticalChartsResVo();
  2526. resVo6.setNum(0);
  2527. resVo6.setEvaluationTotal(BigDecimal.ZERO);
  2528. resVo6.setEvaluationContractTotal(BigDecimal.ZERO);
  2529. }
  2530. resVo6.setNum(resVo6.getNum() + resVo7.getNum());
  2531. resVo6.setEvaluationTotal(resVo6.getEvaluationTotal().add(resVo7.getEvaluationTotal()));
  2532. resVo6.setColumnName("上年度结转和本年度新受领");
  2533. resVo6.setColumnNamePlus("累计项目数量");
  2534. resVos.add(resVo6);
  2535. //本月度完成重大规划采购任务数量
  2536. pmDemandReqVo.setProjectStatus(Long.valueOf(PmProjectStatus.CONTRACT_WAIT_FILL.getCode()));
  2537. StatisticalChartsResVo resVoA = pmDemandMapper.majorProjectByStatusThisMonthFi(pmDemandReqVo);
  2538. resVoA.setColumnName("本月度完成");
  2539. resVoA.setColumnNamePlus("重大规划采购任务数量");
  2540. resVos.add(resVoA);
  2541. //本季度完成重大规划采购任务数量
  2542. pmDemandReqVo.setProjectStatus(Long.valueOf(PmProjectStatus.CONTRACT_WAIT_FILL.getCode()));
  2543. StatisticalChartsResVo resVoB = pmDemandMapper.majorProjectByStatusThisQuaFi(pmDemandReqVo);
  2544. resVoB.setColumnName("本季度完成");
  2545. resVoB.setColumnNamePlus("重大规划采购任务数量");
  2546. resVos.add(resVoB);
  2547. //本年度完成重大规划采购任务数量
  2548. pmDemandReqVo.setProjectStatus(Long.valueOf(PmProjectStatus.CONTRACT_WAIT_FILL.getCode()));
  2549. StatisticalChartsResVo resVoC = pmDemandMapper.majorProjectByStatusThisYearFi(pmDemandReqVo);
  2550. resVoC.setColumnName("本年度完成");
  2551. resVoC.setColumnNamePlus("重大规划采购任务数量");
  2552. resVos.add(resVoC);
  2553. //今年以来累计完成数量
  2554. pmDemandReqVo.setProjectStatus(Long.valueOf(PmProjectStatus.CONTRACT_WAIT_FILL.getCode()));
  2555. StatisticalChartsResVo resVo8 = pmDemandMapper.majorProjectByStatusToThisYear(pmDemandReqVo);
  2556. resVo8.setColumnName("今年以来累计");
  2557. resVo8.setColumnNamePlus("累计完成数量");
  2558. resVos.add(resVo8);
  2559. //正常推进周期内的重大规划采购任务数量
  2560. StatisticalChartsResVo resVo9 = pmDemandMapper.majorProjectByStatusWei(pmDemandReqVo);
  2561. resVo9.setColumnName("正常推进周期内");
  2562. resVo9.setColumnNamePlus("重大规划采购任务数量");
  2563. resVos.add(resVo9);
  2564. //执行滞后的重大规划采购任务数量
  2565. StatisticalChartsResVo resVo10 = pmDemandMapper.majorProjectByStatusChao(pmDemandReqVo);
  2566. resVo10.setColumnName("执行滞后");
  2567. resVo10.setColumnNamePlus("重大规划采购任务数量");
  2568. resVos.add(resVo10);
  2569. return AjaxResult.success(resVos);
  2570. }
  2571. /**
  2572. * 通过计划ID查询项目数据
  2573. *
  2574. * @param planId
  2575. * @return
  2576. */
  2577. @Override
  2578. public PmDemand selectByPlanId(Long planId) {
  2579. return pmDemandMapper.selectByPlanId(planId);
  2580. }
  2581. /**
  2582. * 项目执行进度统计
  2583. * 1、正常推进项目数量:指未完成并且没有逾期的项目
  2584. * 预算金额:指未完成并且没有逾期的项目累加的预算金额
  2585. * 2、未完成采购任务:“合同待填制”状态之前的项目
  2586. * 预算金额:“合同待填制”状态之前的项目累加的预算金额
  2587. *
  2588. * @param pmDemandReqVo
  2589. * @return
  2590. */
  2591. @Override
  2592. public List<StatisticalChartsResVo> purchaseProjectExecute(PmDemandReqVo pmDemandReqVo) {
  2593. List<StatisticalChartsResVo> resVos = new ArrayList<>();
  2594. //是-1就是查询自己及子孙级以下,否则只查询指定部门
  2595. if (pmDemandReqVo.getPurchaseDeptId().equals(-1)) {
  2596. pmDemandReqVo.setDeptList(isQueryAll(pmDemandReqVo.getPurchaseDeptId()));
  2597. } else {
  2598. pmDemandReqVo.setDemandIdAll(isQueryZD(pmDemandReqVo.getPurchaseDeptId()));
  2599. }
  2600. //累计完成采购任务数量 预算金额(万元) 合同金额(万元)
  2601. StatisticalChartsResVo tThisYear = pmDemandMapper.selectFInishAll(pmDemandReqVo);
  2602. tThisYear.setColumnName("累计完成采购任务数量");
  2603. resVos.add(tThisYear);
  2604. // 正常推进项目数量、预算金额
  2605. StatisticalChartsResVo mapNormalPropulsion = pmDemandMapper.purchaseProjectExecuteNormalPropulsion(pmDemandReqVo);
  2606. mapNormalPropulsion.setColumnName("正常推进项目数量");
  2607. resVos.add(mapNormalPropulsion);
  2608. // 未完成采购任务,预算金额
  2609. StatisticalChartsResVo mapIncomplete = pmDemandMapper.purchaseProjectExecuteIncomplete(pmDemandReqVo);
  2610. mapIncomplete.setColumnName("未完成采购任务");
  2611. resVos.add(mapIncomplete);
  2612. return resVos;
  2613. }
  2614. /**
  2615. * 已完成项目数量统计
  2616. *
  2617. * @param pmDemandReqVo
  2618. * @return
  2619. */
  2620. @Override
  2621. public List<Map<String, Integer>> purchaseProjectCompleteNumber(PmDemandReqVo pmDemandReqVo) {
  2622. //是-1就是查询自己及子孙级以下,否则只查询指定部门
  2623. pmDemandReqVo.setDeptList(isQueryAll(pmDemandReqVo.getPurchaseDeptId()));
  2624. List<Map<String, Integer>> mapReturn = new ArrayList<>();
  2625. // 统计时间类型 1:年度,2:季度,3:月份
  2626. if ("1".equals(pmDemandReqVo.getTimeType())) {
  2627. // 查询数据库中最小的年份
  2628. int minYear = pmDemandMapper.selectMinYear();
  2629. // 获取当前年份
  2630. Calendar calendar = Calendar.getInstance();
  2631. int year = calendar.get(Calendar.YEAR);
  2632. // 获取统计数据
  2633. List<Map<String, Integer>> listMap = pmDemandMapper.selectpurchaseProjectCompleteNumberYear(pmDemandReqVo);
  2634. mapReturn.addAll(listMap);
  2635. for (int i = minYear; i <= year; i++) {
  2636. boolean isYear = false;
  2637. for (Map<String, Integer> map : listMap) {
  2638. if (i == Integer.parseInt(String.valueOf(map.get("yy")))) {
  2639. isYear = true;
  2640. }
  2641. }
  2642. if (!isYear) {
  2643. Map<String, Integer> map1 = new HashMap<>();
  2644. map1.put("yy", i);
  2645. map1.put("evaluation", 0);
  2646. map1.put("contractAmount", 0);
  2647. map1.put("countNum", 0);
  2648. mapReturn.add(map1);
  2649. }
  2650. }
  2651. } else if ("2".equals(pmDemandReqVo.getTimeType())) {
  2652. // 当前年份季度统计
  2653. // 获取统计数据
  2654. List<Map<String, Integer>> listMap = pmDemandMapper.selectpurchaseProjectCompleteNumberQuarter(pmDemandReqVo);
  2655. mapReturn.addAll(listMap);
  2656. for (int i = 1; i <= 4; i++) {
  2657. boolean isYear = false;
  2658. for (Map<String, Integer> map : listMap) {
  2659. if (i == Integer.parseInt(String.valueOf(map.get("yy")))) {
  2660. isYear = true;
  2661. }
  2662. }
  2663. if (!isYear) {
  2664. Map<String, Integer> map1 = new HashMap<>();
  2665. map1.put("yy", i);
  2666. map1.put("evaluation", 0);
  2667. map1.put("contractAmount", 0);
  2668. map1.put("countNum", 0);
  2669. mapReturn.add(map1);
  2670. }
  2671. }
  2672. } else if ("3".equals(pmDemandReqVo.getTimeType())) {
  2673. // 当前年份月份统计
  2674. // 获取统计数据
  2675. List<Map<String, Integer>> listMap = pmDemandMapper.selectpurchaseProjectCompleteNumberMonth(pmDemandReqVo);
  2676. mapReturn.addAll(listMap);
  2677. for (int i = 1; i <= 12; i++) {
  2678. boolean isYear = false;
  2679. for (Map<String, Integer> map : listMap) {
  2680. if (i == Integer.parseInt(String.valueOf(map.get("yy")))) {
  2681. isYear = true;
  2682. }
  2683. }
  2684. if (!isYear) {
  2685. Map<String, Integer> map1 = new HashMap<>();
  2686. map1.put("yy", i);
  2687. map1.put("evaluation", 0);
  2688. map1.put("contractAmount", 0);
  2689. map1.put("countNum", 0);
  2690. mapReturn.add(map1);
  2691. }
  2692. }
  2693. }
  2694. return mapReturn;
  2695. }
  2696. /**
  2697. * 已完成采购任务数量统计
  2698. *
  2699. * @param pmDemandReqVo
  2700. * @return
  2701. */
  2702. @Override
  2703. public List<Map<String, Integer>> purchaseTaskFinish(PmDemandReqVo pmDemandReqVo) {
  2704. //是-1就是查询自己及子孙级以下,否则只查询指定部门
  2705. if (pmDemandReqVo.getPurchaseDeptId().equals(-1)) {
  2706. pmDemandReqVo.setDeptList(isQueryAll(pmDemandReqVo.getPurchaseDeptId()));
  2707. } else {
  2708. pmDemandReqVo.setDemandIdAll(isQueryZD(pmDemandReqVo.getPurchaseDeptId()));
  2709. }
  2710. List<Map<String, Integer>> mapReturn = new ArrayList<>();
  2711. // 统计时间类型 1:年度,2:季度,3:月份
  2712. if ("1".equals(pmDemandReqVo.getTimeType())) {
  2713. // 查询数据库中最小的年份
  2714. int minYear = pmDemandMapper.selectMinYear();
  2715. // 获取当前年份
  2716. Calendar calendar = Calendar.getInstance();
  2717. int year = calendar.get(Calendar.YEAR);
  2718. // 获取统计数据
  2719. List<Map<String, Integer>> listMap = pmDemandMapper.selectPurchaseTaskFinishYear(pmDemandReqVo);
  2720. //mapReturn.addAll(listMap);
  2721. for (int i = minYear; i <= year; i++) {
  2722. boolean isYear = false;
  2723. for (Map<String, Integer> map : listMap) {
  2724. if (i == Integer.parseInt(String.valueOf(map.get("yy")))) {
  2725. isYear = true;
  2726. map.put("yy", i);
  2727. mapReturn.add(map);
  2728. }
  2729. }
  2730. if (!isYear) {
  2731. Map<String, Integer> map1 = new HashMap<>();
  2732. map1.put("yy", i);
  2733. map1.put("evaluation", 0);
  2734. map1.put("contractAmount", 0);
  2735. map1.put("countNum", 0);
  2736. mapReturn.add(map1);
  2737. }
  2738. }
  2739. } else if ("2".equals(pmDemandReqVo.getTimeType())) {
  2740. // 当前年份季度统计
  2741. // 获取统计数据
  2742. List<Map<String, Integer>> listMap = pmDemandMapper.selectPurchaseTaskFinishQuarter(pmDemandReqVo);
  2743. //mapReturn.addAll(listMap);
  2744. for (int i = 1; i <= 4; i++) {
  2745. boolean isYear = false;
  2746. for (Map<String, Integer> map : listMap) {
  2747. if (i == Integer.parseInt(String.valueOf(map.get("yy")))) {
  2748. isYear = true;
  2749. map.put("yy", i);
  2750. mapReturn.add(map);
  2751. }
  2752. }
  2753. if (!isYear) {
  2754. Map<String, Integer> map1 = new HashMap<>();
  2755. map1.put("yy", i);
  2756. map1.put("evaluation", 0);
  2757. map1.put("contractAmount", 0);
  2758. map1.put("countNum", 0);
  2759. mapReturn.add(map1);
  2760. }
  2761. }
  2762. } else if ("3".equals(pmDemandReqVo.getTimeType())) {
  2763. // 当前年份月份统计
  2764. // 获取统计数据
  2765. List<Map<String, Integer>> listMap = pmDemandMapper.selectPurchaseTaskFinishMonth(pmDemandReqVo);
  2766. //mapReturn.addAll(listMap);
  2767. for (int i = 1; i <= 12; i++) {
  2768. boolean isYear = false;
  2769. for (Map<String, Integer> map : listMap) {
  2770. if (i == Integer.parseInt(String.valueOf(map.get("yy")))) {
  2771. isYear = true;
  2772. map.put("yy", i);
  2773. map.put("countNum", 0);
  2774. mapReturn.add(map);
  2775. }
  2776. }
  2777. if (!isYear) {
  2778. Map<String, Integer> map1 = new HashMap<>();
  2779. map1.put("yy", i);
  2780. map1.put("evaluation", 0);
  2781. map1.put("contractAmount", 0);
  2782. map1.put("countNum", 0);
  2783. mapReturn.add(map1);
  2784. }
  2785. }
  2786. }
  2787. return mapReturn;
  2788. }
  2789. /**
  2790. * 项目数量分析---------年度的同比和环比不展示-----------
  2791. *
  2792. * @param pmDemandReqVo
  2793. * @return
  2794. */
  2795. @Override
  2796. public List<Map<String, String>> purchaseProjectNumberAnalysis(PmDemandReqVo pmDemandReqVo) {
  2797. //是-1就是查询自己及子孙级以下,否则只查询指定部门
  2798. if (pmDemandReqVo.getPurchaseDeptId().equals(-1)) {
  2799. pmDemandReqVo.setDeptList(isQueryAll(pmDemandReqVo.getPurchaseDeptId()));
  2800. } else {
  2801. pmDemandReqVo.setDemandIdAll(isQueryZD(pmDemandReqVo.getPurchaseDeptId()));
  2802. }
  2803. List<Map<String, String>> mapReturn = new ArrayList<>();
  2804. // 统计时间类型 1:年度,2:季度,3:月份
  2805. if ("1".equals(pmDemandReqVo.getTimeType())) {
  2806. // 查询数据库中最小的年份
  2807. int minYear = pmDemandMapper.selectMinYear();
  2808. // 获取当前年份
  2809. Calendar calendar = Calendar.getInstance();
  2810. int year = calendar.get(Calendar.YEAR);
  2811. // 获取统计数据
  2812. // 获取项目统计
  2813. List<Map<String, String>> listMap = pmDemandMapper.purchaseProjectNumberAnalysisYear(pmDemandReqVo);
  2814. mapReturn.addAll(listMap);
  2815. for (int i = minYear; i <= year; i++) {
  2816. boolean isYear = false;
  2817. for (Map<String, String> map : listMap) {
  2818. if (i == Integer.parseInt(String.valueOf(map.get("yy")))) {
  2819. isYear = true;
  2820. }
  2821. }
  2822. if (!isYear) {
  2823. Map<String, String> map1 = new HashMap<>();
  2824. map1.put("yy", i + "");
  2825. map1.put("countNum", 0 + "");
  2826. map1.put("evaluationSum", 0 + "");
  2827. mapReturn.add(map1);
  2828. }
  2829. }
  2830. } else if ("2".equals(pmDemandReqVo.getTimeType())) {
  2831. // 当前年份季度统计
  2832. // 获取统计数据
  2833. List<Map<String, String>> listMap = pmDemandMapper.purchaseProjectNumberAnalysisQuarter(pmDemandReqVo);
  2834. List<Map<String, String>> mapList = new ArrayList<>();
  2835. mapList.addAll(listMap);
  2836. for (int i = 1; i <= 4; i++) {
  2837. boolean isYear = false;
  2838. for (Map<String, String> map : listMap) {
  2839. if (i == Integer.parseInt(String.valueOf(map.get("yy")))) {
  2840. isYear = true;
  2841. }
  2842. }
  2843. if (!isYear) {
  2844. Map<String, String> map1 = new HashMap<>();
  2845. map1.put("yy", i + "");
  2846. map1.put("countNum", 0 + "");
  2847. map1.put("evaluationSum", 0 + "");
  2848. mapList.add(map1);
  2849. }
  2850. }
  2851. Map<String, String> map1 = new HashMap<>();
  2852. Map<String, String> map2 = new HashMap<>();
  2853. Map<String, String> map3 = new HashMap<>();
  2854. Map<String, String> map4 = new HashMap<>();
  2855. for (Map<String, String> map : mapList) {
  2856. String yy = String.valueOf(map.get("yy"));
  2857. if ("1".equals(yy)) {
  2858. map1.putAll(map);
  2859. } else if ("2".equals(yy)) {
  2860. map2.putAll(map);
  2861. } else if ("3".equals(yy)) {
  2862. map3.putAll(map);
  2863. } else if ("4".equals(yy)) {
  2864. map4.putAll(map);
  2865. }
  2866. }
  2867. String countNum1 = String.valueOf(map1.get("countNum"));
  2868. String countNum2 = String.valueOf(map2.get("countNum"));
  2869. String countNum3 = String.valueOf(map3.get("countNum"));
  2870. String countNum4 = String.valueOf(map4.get("countNum"));
  2871. String evaluationSum1 = String.valueOf(map1.get("evaluationSum"));
  2872. String evaluationSum2 = String.valueOf(map2.get("evaluationSum"));
  2873. String evaluationSum3 = String.valueOf(map3.get("evaluationSum"));
  2874. String evaluationSum4 = String.valueOf(map4.get("evaluationSum"));
  2875. // 查询上一年四季度数据
  2876. List<Map<String, String>> listMapOldYear = pmDemandMapper.purchaseProjectNumberAnalysisOldYearQuarter(pmDemandReqVo);
  2877. List<Map<String, String>> mapListOld = new ArrayList<>();
  2878. mapListOld.addAll(listMapOldYear);
  2879. for (int i = 1; i <= 4; i++) {
  2880. boolean isYear = false;
  2881. for (Map<String, String> map : listMapOldYear) {
  2882. if (i == Integer.parseInt(String.valueOf(map.get("yy")))) {
  2883. isYear = true;
  2884. }
  2885. }
  2886. if (!isYear) {
  2887. Map<String, String> map11 = new HashMap<>();
  2888. map11.put("yy", i + "");
  2889. map11.put("countNum", 0 + "");
  2890. map11.put("evaluationSum", 0 + "");
  2891. mapListOld.add(map11);
  2892. }
  2893. }
  2894. Map<String, String> mapOld1 = new HashMap<>();
  2895. Map<String, String> mapOld2 = new HashMap<>();
  2896. Map<String, String> mapOld3 = new HashMap<>();
  2897. Map<String, String> mapOld4 = new HashMap<>();
  2898. for (Map<String, String> mapOld : mapListOld) {
  2899. String yy = String.valueOf(mapOld.get("yy"));
  2900. if ("1".equals(yy)) {
  2901. mapOld1.putAll(mapOld);
  2902. } else if ("2".equals(yy)) {
  2903. mapOld2.putAll(mapOld);
  2904. } else if ("3".equals(yy)) {
  2905. mapOld3.putAll(mapOld);
  2906. } else if ("4".equals(yy)) {
  2907. mapOld4.putAll(mapOld);
  2908. }
  2909. }
  2910. String countNumOld1 = String.valueOf(mapOld1.get("countNum"));
  2911. String countNumOld2 = String.valueOf(mapOld2.get("countNum"));
  2912. String countNumOld3 = String.valueOf(mapOld3.get("countNum"));
  2913. String countNumOld4 = String.valueOf(mapOld4.get("countNum"));
  2914. String evaluationSumOld1 = String.valueOf(mapOld1.get("evaluationSum"));
  2915. String evaluationSumOld2 = String.valueOf(mapOld2.get("evaluationSum"));
  2916. String evaluationSumOld3 = String.valueOf(mapOld3.get("evaluationSum"));
  2917. String evaluationSumOld4 = String.valueOf(mapOld4.get("evaluationSum"));
  2918. BigDecimal countNum11 = new BigDecimal(countNum1);
  2919. BigDecimal countNum22 = new BigDecimal(countNum2);
  2920. BigDecimal countNum33 = new BigDecimal(countNum3);
  2921. BigDecimal countNum44 = new BigDecimal(countNum4);
  2922. BigDecimal countNumOld11 = new BigDecimal(countNumOld1);
  2923. BigDecimal countNumOld22 = new BigDecimal(countNumOld2);
  2924. BigDecimal countNumOld33 = new BigDecimal(countNumOld3);
  2925. BigDecimal countNumOld44 = new BigDecimal(countNumOld4);
  2926. BigDecimal evaluationSum11 = new BigDecimal(evaluationSum1);
  2927. BigDecimal evaluationSum22 = new BigDecimal(evaluationSum2);
  2928. BigDecimal evaluationSum33 = new BigDecimal(evaluationSum3);
  2929. BigDecimal evaluationSum44 = new BigDecimal(evaluationSum4);
  2930. BigDecimal evaluationSumOld11 = new BigDecimal(evaluationSumOld1);
  2931. BigDecimal evaluationSumOld22 = new BigDecimal(evaluationSumOld2);
  2932. BigDecimal evaluationSumOld33 = new BigDecimal(evaluationSumOld3);
  2933. BigDecimal evaluationSumOld44 = new BigDecimal(evaluationSumOld4);
  2934. // 项目数量环比 对比
  2935. BigDecimal monthonmonthNum1 = new BigDecimal(0.00);
  2936. BigDecimal monthonmonthNum2 = new BigDecimal(0.00);
  2937. BigDecimal monthonmonthNum3 = new BigDecimal(0.00);
  2938. BigDecimal monthonmonthNum4 = new BigDecimal(0.00);
  2939. if (!"0".equals(countNumOld4)) {
  2940. monthonmonthNum1 = (countNum11.subtract(countNumOld44)).divide(countNumOld44, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2941. }
  2942. if (!"0".equals(countNum1)) {
  2943. monthonmonthNum2 = (countNum22.subtract(countNum11)).divide(countNum11, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2944. }
  2945. if (!"0".equals(countNum2)) {
  2946. monthonmonthNum3 = (countNum33.subtract(countNum22)).divide(countNum22, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2947. }
  2948. if (!"0".equals(countNum3)) {
  2949. monthonmonthNum4 = (countNum44.subtract(countNum33)).divide(countNum33, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2950. }
  2951. map1.put("monthonmonthNum", monthonmonthNum1.toString());
  2952. map2.put("monthonmonthNum", monthonmonthNum2.toString());
  2953. map3.put("monthonmonthNum", monthonmonthNum3.toString());
  2954. map4.put("monthonmonthNum", monthonmonthNum4.toString());
  2955. // 项目数量同比 对比
  2956. BigDecimal yearonyearNum1 = new BigDecimal(0.00);
  2957. BigDecimal yearonyearNum2 = new BigDecimal(0.00);
  2958. BigDecimal yearonyearNum3 = new BigDecimal(0.00);
  2959. BigDecimal yearonyearNum4 = new BigDecimal(0.00);
  2960. if (!"0".equals(countNumOld1)) {
  2961. yearonyearNum1 = (countNum11.subtract(countNumOld11)).divide(countNumOld11, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2962. }
  2963. if (!"0".equals(countNumOld2)) {
  2964. yearonyearNum2 = (countNum22.subtract(countNumOld22)).divide(countNumOld22, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2965. }
  2966. if (!"0".equals(countNumOld3)) {
  2967. yearonyearNum3 = (countNum33.subtract(countNumOld33)).divide(countNumOld33, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2968. }
  2969. if (!"0".equals(countNumOld4)) {
  2970. yearonyearNum4 = (countNum44.subtract(countNumOld44)).divide(countNumOld44, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2971. }
  2972. map1.put("yearonyearNum", yearonyearNum1.toString());
  2973. map2.put("yearonyearNum", yearonyearNum2.toString());
  2974. map3.put("yearonyearNum", yearonyearNum3.toString());
  2975. map4.put("yearonyearNum", yearonyearNum4.toString());
  2976. // 预算金额环比 对比
  2977. BigDecimal monthonmonthAmount1 = new BigDecimal(0.00);
  2978. BigDecimal monthonmonthAmount2 = new BigDecimal(0.00);
  2979. BigDecimal monthonmonthAmount3 = new BigDecimal(0.00);
  2980. BigDecimal monthonmonthAmount4 = new BigDecimal(0.00);
  2981. if (!"0".equals(evaluationSumOld4)) {
  2982. monthonmonthAmount1 = (evaluationSum11.subtract(evaluationSumOld44)).divide(evaluationSumOld44, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2983. }
  2984. if (!"0".equals(evaluationSum1)) {
  2985. monthonmonthAmount2 = (evaluationSum22.subtract(evaluationSum11)).divide(evaluationSum11, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2986. }
  2987. if (!"0".equals(evaluationSum2)) {
  2988. monthonmonthAmount3 = (evaluationSum33.subtract(evaluationSum22)).divide(evaluationSum22, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2989. }
  2990. if (!"0".equals(evaluationSum3)) {
  2991. monthonmonthAmount4 = (evaluationSum44.subtract(evaluationSum33)).divide(evaluationSum33, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2992. }
  2993. map1.put("monthonmonthAmount", monthonmonthAmount1.toString());
  2994. map2.put("monthonmonthAmount", monthonmonthAmount2.toString());
  2995. map3.put("monthonmonthAmount", monthonmonthAmount3.toString());
  2996. map4.put("monthonmonthAmount", monthonmonthAmount4.toString());
  2997. // 预算金额同比比 对比
  2998. BigDecimal yearonyearAmount1 = new BigDecimal(0.00);
  2999. BigDecimal yearonyearAmount2 = new BigDecimal(0.00);
  3000. BigDecimal yearonyearAmount3 = new BigDecimal(0.00);
  3001. BigDecimal yearonyearAmount4 = new BigDecimal(0.00);
  3002. if (!"0".equals(evaluationSumOld1)) {
  3003. yearonyearAmount1 = (evaluationSum11.subtract(evaluationSumOld11)).divide(evaluationSumOld11, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  3004. }
  3005. if (!"0".equals(evaluationSumOld2)) {
  3006. yearonyearAmount2 = (evaluationSum22.subtract(evaluationSumOld22)).divide(evaluationSumOld22, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  3007. }
  3008. if (!"0".equals(evaluationSumOld3)) {
  3009. yearonyearAmount3 = (evaluationSum33.subtract(evaluationSumOld33)).divide(evaluationSumOld33, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  3010. }
  3011. if (!"0".equals(evaluationSumOld4)) {
  3012. yearonyearAmount4 = (evaluationSum44.subtract(evaluationSumOld44)).divide(evaluationSumOld44, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  3013. }
  3014. map1.put("yearonyearAmount", yearonyearAmount1.toString());
  3015. map2.put("yearonyearAmount", yearonyearAmount2.toString());
  3016. map3.put("yearonyearAmount", yearonyearAmount3.toString());
  3017. map4.put("yearonyearAmount", yearonyearAmount4.toString());
  3018. // 存入集合
  3019. mapReturn.add(map1);
  3020. mapReturn.add(map2);
  3021. mapReturn.add(map3);
  3022. mapReturn.add(map4);
  3023. } else if ("3".equals(pmDemandReqVo.getTimeType())) {
  3024. // 当前年份月份统计
  3025. // 获取统计数据
  3026. List<Map<String, String>> listMap = pmDemandMapper.purchaseProjectNumberAnalysisMonth(pmDemandReqVo);
  3027. List<Map<String, String>> mapList = new ArrayList<>();
  3028. mapList.addAll(listMap);
  3029. for (int i = 1; i <= 12; i++) {
  3030. boolean isYear = false;
  3031. for (Map<String, String> map : listMap) {
  3032. String yy = String.valueOf(map.get("yy"));
  3033. String yyNew = yy.replaceAll("^0*", "");
  3034. if (i == Integer.valueOf(yyNew)) {
  3035. isYear = true;
  3036. }
  3037. }
  3038. if (!isYear) {
  3039. Map<String, String> map1 = new HashMap<>();
  3040. String yy = String.format("%02d", i);
  3041. map1.put("yy", yy);
  3042. map1.put("countNum", 0 + "");
  3043. map1.put("evaluationSum", 0 + "");
  3044. mapList.add(map1);
  3045. }
  3046. }
  3047. Map<String, String> map1 = new HashMap<>();
  3048. Map<String, String> map2 = new HashMap<>();
  3049. Map<String, String> map3 = new HashMap<>();
  3050. Map<String, String> map4 = new HashMap<>();
  3051. Map<String, String> map5 = new HashMap<>();
  3052. Map<String, String> map6 = new HashMap<>();
  3053. Map<String, String> map7 = new HashMap<>();
  3054. Map<String, String> map8 = new HashMap<>();
  3055. Map<String, String> map9 = new HashMap<>();
  3056. Map<String, String> map10 = new HashMap<>();
  3057. Map<String, String> map11 = new HashMap<>();
  3058. Map<String, String> map12 = new HashMap<>();
  3059. for (Map<String, String> map : mapList) {
  3060. String yy = String.valueOf(map.get("yy"));
  3061. if ("01".equals(yy)) {
  3062. map1.putAll(map);
  3063. } else if ("02".equals(yy)) {
  3064. map2.putAll(map);
  3065. } else if ("03".equals(yy)) {
  3066. map3.putAll(map);
  3067. } else if ("04".equals(yy)) {
  3068. map4.putAll(map);
  3069. } else if ("05".equals(yy)) {
  3070. map5.putAll(map);
  3071. } else if ("06".equals(yy)) {
  3072. map6.putAll(map);
  3073. } else if ("07".equals(yy)) {
  3074. map7.putAll(map);
  3075. } else if ("08".equals(yy)) {
  3076. map8.putAll(map);
  3077. } else if ("09".equals(yy)) {
  3078. map9.putAll(map);
  3079. } else if ("10".equals(yy)) {
  3080. map10.putAll(map);
  3081. } else if ("11".equals(yy)) {
  3082. map11.putAll(map);
  3083. } else if ("12".equals(yy)) {
  3084. map12.putAll(map);
  3085. }
  3086. }
  3087. String countNum1 = String.valueOf(map1.get("countNum"));
  3088. String countNum2 = String.valueOf(map2.get("countNum"));
  3089. String countNum3 = String.valueOf(map3.get("countNum"));
  3090. String countNum4 = String.valueOf(map4.get("countNum"));
  3091. String countNum5 = String.valueOf(map5.get("countNum"));
  3092. String countNum6 = String.valueOf(map6.get("countNum"));
  3093. String countNum7 = String.valueOf(map7.get("countNum"));
  3094. String countNum8 = String.valueOf(map8.get("countNum"));
  3095. String countNum9 = String.valueOf(map9.get("countNum"));
  3096. String countNum10 = String.valueOf(map10.get("countNum"));
  3097. String countNum11 = String.valueOf(map11.get("countNum"));
  3098. String countNum12 = String.valueOf(map12.get("countNum"));
  3099. String evaluationSum1 = String.valueOf(map1.get("evaluationSum"));
  3100. String evaluationSum2 = String.valueOf(map2.get("evaluationSum"));
  3101. String evaluationSum3 = String.valueOf(map3.get("evaluationSum"));
  3102. String evaluationSum4 = String.valueOf(map4.get("evaluationSum"));
  3103. String evaluationSum5 = String.valueOf(map5.get("evaluationSum"));
  3104. String evaluationSum6 = String.valueOf(map6.get("evaluationSum"));
  3105. String evaluationSum7 = String.valueOf(map7.get("evaluationSum"));
  3106. String evaluationSum8 = String.valueOf(map8.get("evaluationSum"));
  3107. String evaluationSum9 = String.valueOf(map9.get("evaluationSum"));
  3108. String evaluationSum10 = String.valueOf(map10.get("evaluationSum"));
  3109. String evaluationSum11 = String.valueOf(map11.get("evaluationSum"));
  3110. String evaluationSum12 = String.valueOf(map12.get("evaluationSum"));
  3111. // 查询上一年月份数据
  3112. List<Map<String, String>> listMapOldMonth = pmDemandMapper.purchaseProjectNumberAnalysisOldYearMonth(pmDemandReqVo);
  3113. List<Map<String, String>> mapListOld = new ArrayList<>();
  3114. mapListOld.addAll(listMapOldMonth);
  3115. for (int i = 1; i <= 12; i++) {
  3116. boolean isYear = false;
  3117. for (Map<String, String> map : listMapOldMonth) {
  3118. String yy = String.valueOf(map.get("yy"));
  3119. String yyNew = yy.replaceAll("^0*", "");
  3120. if (i == Integer.valueOf(yyNew)) {
  3121. isYear = true;
  3122. }
  3123. }
  3124. if (!isYear) {
  3125. Map<String, String> map111 = new HashMap<>();
  3126. String yy = String.format("%02d", i);
  3127. map111.put("yy", yy);
  3128. map111.put("countNum", 0 + "");
  3129. map111.put("evaluationSum", 0 + "");
  3130. mapListOld.add(map111);
  3131. }
  3132. }
  3133. Map<String, String> mapOld1 = new HashMap<>();
  3134. Map<String, String> mapOld2 = new HashMap<>();
  3135. Map<String, String> mapOld3 = new HashMap<>();
  3136. Map<String, String> mapOld4 = new HashMap<>();
  3137. Map<String, String> mapOld5 = new HashMap<>();
  3138. Map<String, String> mapOld6 = new HashMap<>();
  3139. Map<String, String> mapOld7 = new HashMap<>();
  3140. Map<String, String> mapOld8 = new HashMap<>();
  3141. Map<String, String> mapOld9 = new HashMap<>();
  3142. Map<String, String> mapOld10 = new HashMap<>();
  3143. Map<String, String> mapOld11 = new HashMap<>();
  3144. Map<String, String> mapOld12 = new HashMap<>();
  3145. for (Map<String, String> mapOld : mapListOld) {
  3146. String yy = String.valueOf(mapOld.get("yy"));
  3147. if ("01".equals(yy)) {
  3148. mapOld1.putAll(mapOld);
  3149. } else if ("02".equals(yy)) {
  3150. mapOld2.putAll(mapOld);
  3151. } else if ("03".equals(yy)) {
  3152. mapOld3.putAll(mapOld);
  3153. } else if ("04".equals(yy)) {
  3154. mapOld4.putAll(mapOld);
  3155. } else if ("05".equals(yy)) {
  3156. mapOld5.putAll(mapOld);
  3157. } else if ("06".equals(yy)) {
  3158. mapOld6.putAll(mapOld);
  3159. } else if ("07".equals(yy)) {
  3160. mapOld7.putAll(mapOld);
  3161. } else if ("08".equals(yy)) {
  3162. mapOld8.putAll(mapOld);
  3163. } else if ("09".equals(yy)) {
  3164. mapOld9.putAll(mapOld);
  3165. } else if ("10".equals(yy)) {
  3166. mapOld10.putAll(mapOld);
  3167. } else if ("11".equals(yy)) {
  3168. mapOld11.putAll(mapOld);
  3169. } else if ("12".equals(yy)) {
  3170. mapOld12.putAll(mapOld);
  3171. }
  3172. }
  3173. String countNumOld1 = String.valueOf(mapOld1.get("countNum"));
  3174. String countNumOld2 = String.valueOf(mapOld2.get("countNum"));
  3175. String countNumOld3 = String.valueOf(mapOld3.get("countNum"));
  3176. String countNumOld4 = String.valueOf(mapOld4.get("countNum"));
  3177. String countNumOld5 = String.valueOf(mapOld5.get("countNum"));
  3178. String countNumOld6 = String.valueOf(mapOld6.get("countNum"));
  3179. String countNumOld7 = String.valueOf(mapOld7.get("countNum"));
  3180. String countNumOld8 = String.valueOf(mapOld8.get("countNum"));
  3181. String countNumOld9 = String.valueOf(mapOld9.get("countNum"));
  3182. String countNumOld10 = String.valueOf(mapOld10.get("countNum"));
  3183. String countNumOld11 = String.valueOf(mapOld11.get("countNum"));
  3184. String countNumOld12 = String.valueOf(mapOld12.get("countNum"));
  3185. String evaluationSumOld1 = String.valueOf(mapOld1.get("evaluationSum"));
  3186. String evaluationSumOld2 = String.valueOf(mapOld2.get("evaluationSum"));
  3187. String evaluationSumOld3 = String.valueOf(mapOld3.get("evaluationSum"));
  3188. String evaluationSumOld4 = String.valueOf(mapOld4.get("evaluationSum"));
  3189. String evaluationSumOld5 = String.valueOf(mapOld5.get("evaluationSum"));
  3190. String evaluationSumOld6 = String.valueOf(mapOld6.get("evaluationSum"));
  3191. String evaluationSumOld7 = String.valueOf(mapOld7.get("evaluationSum"));
  3192. String evaluationSumOld8 = String.valueOf(mapOld8.get("evaluationSum"));
  3193. String evaluationSumOld9 = String.valueOf(mapOld9.get("evaluationSum"));
  3194. String evaluationSumOld10 = String.valueOf(mapOld10.get("evaluationSum"));
  3195. String evaluationSumOld11 = String.valueOf(mapOld11.get("evaluationSum"));
  3196. String evaluationSumOld12 = String.valueOf(mapOld12.get("evaluationSum"));
  3197. BigDecimal countNum111 = new BigDecimal(countNum1);
  3198. BigDecimal countNum22 = new BigDecimal(countNum2);
  3199. BigDecimal countNum33 = new BigDecimal(countNum3);
  3200. BigDecimal countNum44 = new BigDecimal(countNum4);
  3201. BigDecimal countNum55 = new BigDecimal(countNum5);
  3202. BigDecimal countNum66 = new BigDecimal(countNum6);
  3203. BigDecimal countNum77 = new BigDecimal(countNum7);
  3204. BigDecimal countNum88 = new BigDecimal(countNum8);
  3205. BigDecimal countNum99 = new BigDecimal(countNum9);
  3206. BigDecimal countNum1010 = new BigDecimal(countNum10);
  3207. BigDecimal countNum1111 = new BigDecimal(countNum11);
  3208. BigDecimal countNum1212 = new BigDecimal(countNum12);
  3209. BigDecimal countNumOld111 = new BigDecimal(countNumOld1);
  3210. BigDecimal countNumOld22 = new BigDecimal(countNumOld2);
  3211. BigDecimal countNumOld33 = new BigDecimal(countNumOld3);
  3212. BigDecimal countNumOld44 = new BigDecimal(countNumOld4);
  3213. BigDecimal countNumOld55 = new BigDecimal(countNumOld5);
  3214. BigDecimal countNumOld66 = new BigDecimal(countNumOld6);
  3215. BigDecimal countNumOld77 = new BigDecimal(countNumOld7);
  3216. BigDecimal countNumOld88 = new BigDecimal(countNumOld8);
  3217. BigDecimal countNumOld99 = new BigDecimal(countNumOld9);
  3218. BigDecimal countNumOld1010 = new BigDecimal(countNumOld10);
  3219. BigDecimal countNumOld1111 = new BigDecimal(countNumOld11);
  3220. BigDecimal countNumOld1212 = new BigDecimal(countNumOld12);
  3221. BigDecimal evaluationSum111 = new BigDecimal(evaluationSum1);
  3222. BigDecimal evaluationSum22 = new BigDecimal(evaluationSum2);
  3223. BigDecimal evaluationSum33 = new BigDecimal(evaluationSum3);
  3224. BigDecimal evaluationSum44 = new BigDecimal(evaluationSum4);
  3225. BigDecimal evaluationSum55 = new BigDecimal(evaluationSum5);
  3226. BigDecimal evaluationSum66 = new BigDecimal(evaluationSum6);
  3227. BigDecimal evaluationSum77 = new BigDecimal(evaluationSum7);
  3228. BigDecimal evaluationSum88 = new BigDecimal(evaluationSum8);
  3229. BigDecimal evaluationSum99 = new BigDecimal(evaluationSum9);
  3230. BigDecimal evaluationSum1010 = new BigDecimal(evaluationSum10);
  3231. BigDecimal evaluationSum1111 = new BigDecimal(evaluationSum11);
  3232. BigDecimal evaluationSum1212 = new BigDecimal(evaluationSum12);
  3233. BigDecimal evaluationSumOld111 = new BigDecimal(evaluationSumOld1);
  3234. BigDecimal evaluationSumOld22 = new BigDecimal(evaluationSumOld2);
  3235. BigDecimal evaluationSumOld33 = new BigDecimal(evaluationSumOld3);
  3236. BigDecimal evaluationSumOld44 = new BigDecimal(evaluationSumOld4);
  3237. BigDecimal evaluationSumOld55 = new BigDecimal(evaluationSumOld5);
  3238. BigDecimal evaluationSumOld66 = new BigDecimal(evaluationSumOld6);
  3239. BigDecimal evaluationSumOld77 = new BigDecimal(evaluationSumOld7);
  3240. BigDecimal evaluationSumOld88 = new BigDecimal(evaluationSumOld8);
  3241. BigDecimal evaluationSumOld99 = new BigDecimal(evaluationSumOld9);
  3242. BigDecimal evaluationSumOld1010 = new BigDecimal(evaluationSumOld10);
  3243. BigDecimal evaluationSumOld1111 = new BigDecimal(evaluationSumOld11);
  3244. BigDecimal evaluationSumOld1212 = new BigDecimal(evaluationSumOld12);
  3245. // 项目数量环比 对比
  3246. BigDecimal monthonmonthNum1 = new BigDecimal(0.00);
  3247. BigDecimal monthonmonthNum2 = new BigDecimal(0.00);
  3248. BigDecimal monthonmonthNum3 = new BigDecimal(0.00);
  3249. BigDecimal monthonmonthNum4 = new BigDecimal(0.00);
  3250. BigDecimal monthonmonthNum5 = new BigDecimal(0.00);
  3251. BigDecimal monthonmonthNum6 = new BigDecimal(0.00);
  3252. BigDecimal monthonmonthNum7 = new BigDecimal(0.00);
  3253. BigDecimal monthonmonthNum8 = new BigDecimal(0.00);
  3254. BigDecimal monthonmonthNum9 = new BigDecimal(0.00);
  3255. BigDecimal monthonmonthNum10 = new BigDecimal(0.00);
  3256. BigDecimal monthonmonthNum11 = new BigDecimal(0.00);
  3257. BigDecimal monthonmonthNum12 = new BigDecimal(0.00);
  3258. if (!"0".equals(countNumOld12)) {
  3259. monthonmonthNum1 = (countNum111.subtract(countNumOld1212)).divide(countNumOld1212, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  3260. }
  3261. if (!"0".equals(countNum1)) {
  3262. monthonmonthNum2 = (countNum22.subtract(countNum111)).divide(countNum111, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  3263. }
  3264. if (!"0".equals(countNum2)) {
  3265. monthonmonthNum3 = (countNum33.subtract(countNum22)).divide(countNum22, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  3266. }
  3267. if (!"0".equals(countNum3)) {
  3268. monthonmonthNum4 = (countNum44.subtract(countNum33)).divide(countNum33, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  3269. }
  3270. if (!"0".equals(countNum4)) {
  3271. monthonmonthNum5 = (countNum55.subtract(countNum44)).divide(countNum44, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  3272. }
  3273. if (!"0".equals(countNum5)) {
  3274. monthonmonthNum6 = (countNum66.subtract(countNum55)).divide(countNum55, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  3275. }
  3276. if (!"0".equals(countNum6)) {
  3277. monthonmonthNum7 = (countNum77.subtract(countNum66)).divide(countNum66, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  3278. }
  3279. if (!"0".equals(countNum7)) {
  3280. monthonmonthNum8 = (countNum88.subtract(countNum77)).divide(countNum77, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  3281. }
  3282. if (!"0".equals(countNum8)) {
  3283. monthonmonthNum9 = (countNum99.subtract(countNum88)).divide(countNum88, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  3284. }
  3285. if (!"0".equals(countNum9)) {
  3286. monthonmonthNum10 = (countNum1010.subtract(countNum99)).divide(countNum99, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  3287. }
  3288. if (!"0".equals(countNum10)) {
  3289. monthonmonthNum11 = (countNum1111.subtract(countNum1010)).divide(countNum1010, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  3290. }
  3291. if (!"0".equals(countNum11)) {
  3292. monthonmonthNum12 = (countNum1212.subtract(countNum1111)).divide(countNum1111, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  3293. }
  3294. map1.put("monthonmonthNum", monthonmonthNum1.toString());
  3295. map2.put("monthonmonthNum", monthonmonthNum2.toString());
  3296. map3.put("monthonmonthNum", monthonmonthNum3.toString());
  3297. map4.put("monthonmonthNum", monthonmonthNum4.toString());
  3298. map5.put("monthonmonthNum", monthonmonthNum5.toString());
  3299. map6.put("monthonmonthNum", monthonmonthNum6.toString());
  3300. map7.put("monthonmonthNum", monthonmonthNum7.toString());
  3301. map8.put("monthonmonthNum", monthonmonthNum8.toString());
  3302. map9.put("monthonmonthNum", monthonmonthNum9.toString());
  3303. map10.put("monthonmonthNum", monthonmonthNum10.toString());
  3304. map11.put("monthonmonthNum", monthonmonthNum11.toString());
  3305. map12.put("monthonmonthNum", monthonmonthNum12.toString());
  3306. // 项目数量同比 对比
  3307. BigDecimal yearonyearNum1 = new BigDecimal(0.00);
  3308. BigDecimal yearonyearNum2 = new BigDecimal(0.00);
  3309. BigDecimal yearonyearNum3 = new BigDecimal(0.00);
  3310. BigDecimal yearonyearNum4 = new BigDecimal(0.00);
  3311. BigDecimal yearonyearNum5 = new BigDecimal(0.00);
  3312. BigDecimal yearonyearNum6 = new BigDecimal(0.00);
  3313. BigDecimal yearonyearNum7 = new BigDecimal(0.00);
  3314. BigDecimal yearonyearNum8 = new BigDecimal(0.00);
  3315. BigDecimal yearonyearNum9 = new BigDecimal(0.00);
  3316. BigDecimal yearonyearNum10 = new BigDecimal(0.00);
  3317. BigDecimal yearonyearNum11 = new BigDecimal(0.00);
  3318. BigDecimal yearonyearNum12 = new BigDecimal(0.00);
  3319. if (!"0".equals(countNumOld1)) {
  3320. yearonyearNum1 = (countNum111.subtract(countNumOld111)).divide(countNumOld111, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  3321. }
  3322. if (!"0".equals(countNumOld2)) {
  3323. yearonyearNum2 = (countNum22.subtract(countNumOld22)).divide(countNumOld22, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  3324. }
  3325. if (!"0".equals(countNumOld3)) {
  3326. yearonyearNum3 = (countNum33.subtract(countNumOld33)).divide(countNumOld33, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  3327. }
  3328. if (!"0".equals(countNumOld4)) {
  3329. yearonyearNum4 = (countNum44.subtract(countNumOld44)).divide(countNumOld44, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  3330. }
  3331. if (!"0".equals(countNumOld5)) {
  3332. yearonyearNum5 = (countNum55.subtract(countNumOld55)).divide(countNumOld55, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  3333. }
  3334. if (!"0".equals(countNumOld6)) {
  3335. yearonyearNum6 = (countNum66.subtract(countNumOld66)).divide(countNumOld66, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  3336. }
  3337. if (!"0".equals(countNumOld7)) {
  3338. yearonyearNum7 = (countNum77.subtract(countNumOld77)).divide(countNumOld77, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  3339. }
  3340. if (!"0".equals(countNumOld8)) {
  3341. yearonyearNum8 = (countNum88.subtract(countNumOld88)).divide(countNumOld88, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  3342. }
  3343. if (!"0".equals(countNumOld9)) {
  3344. yearonyearNum9 = (countNum99.subtract(countNumOld99)).divide(countNumOld99, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  3345. }
  3346. if (!"0".equals(countNumOld10)) {
  3347. yearonyearNum10 = (countNum1010.subtract(countNumOld1010)).divide(countNumOld1010, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  3348. }
  3349. if (!"0".equals(countNumOld11)) {
  3350. yearonyearNum11 = (countNum1111.subtract(countNumOld1111)).divide(countNumOld1111, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  3351. }
  3352. if (!"0".equals(countNumOld12)) {
  3353. yearonyearNum12 = (countNum1212.subtract(countNumOld1212)).divide(countNumOld1212, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  3354. }
  3355. map1.put("yearonyearNum", yearonyearNum1.toString());
  3356. map2.put("yearonyearNum", yearonyearNum2.toString());
  3357. map3.put("yearonyearNum", yearonyearNum3.toString());
  3358. map4.put("yearonyearNum", yearonyearNum4.toString());
  3359. map5.put("yearonyearNum", yearonyearNum5.toString());
  3360. map6.put("yearonyearNum", yearonyearNum6.toString());
  3361. map7.put("yearonyearNum", yearonyearNum7.toString());
  3362. map8.put("yearonyearNum", yearonyearNum8.toString());
  3363. map9.put("yearonyearNum", yearonyearNum9.toString());
  3364. map10.put("yearonyearNum", yearonyearNum10.toString());
  3365. map11.put("yearonyearNum", yearonyearNum11.toString());
  3366. map12.put("yearonyearNum", yearonyearNum12.toString());
  3367. // 预算金额环比 对比
  3368. BigDecimal monthonmonthAmount1 = new BigDecimal(0.00);
  3369. BigDecimal monthonmonthAmount2 = new BigDecimal(0.00);
  3370. BigDecimal monthonmonthAmount3 = new BigDecimal(0.00);
  3371. BigDecimal monthonmonthAmount4 = new BigDecimal(0.00);
  3372. BigDecimal monthonmonthAmount5 = new BigDecimal(0.00);
  3373. BigDecimal monthonmonthAmount6 = new BigDecimal(0.00);
  3374. BigDecimal monthonmonthAmount7 = new BigDecimal(0.00);
  3375. BigDecimal monthonmonthAmount8 = new BigDecimal(0.00);
  3376. BigDecimal monthonmonthAmount9 = new BigDecimal(0.00);
  3377. BigDecimal monthonmonthAmount10 = new BigDecimal(0.00);
  3378. BigDecimal monthonmonthAmount11 = new BigDecimal(0.00);
  3379. BigDecimal monthonmonthAmount12 = new BigDecimal(0.00);
  3380. if (!"0".equals(evaluationSumOld12)) {
  3381. monthonmonthAmount1 = (evaluationSum111.subtract(evaluationSumOld1212)).divide(evaluationSumOld1212, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  3382. }
  3383. if (!"0".equals(evaluationSum1)) {
  3384. monthonmonthAmount2 = (evaluationSum22.subtract(evaluationSum111)).divide(evaluationSum111, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  3385. }
  3386. if (!"0".equals(evaluationSum2)) {
  3387. monthonmonthAmount3 = (evaluationSum33.subtract(evaluationSum22)).divide(evaluationSum22, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  3388. }
  3389. if (!"0".equals(evaluationSum3)) {
  3390. monthonmonthAmount4 = (evaluationSum44.subtract(evaluationSum33)).divide(evaluationSum33, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  3391. }
  3392. if (!"0".equals(evaluationSum4)) {
  3393. monthonmonthAmount5 = (evaluationSum55.subtract(evaluationSum44)).divide(evaluationSum44, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  3394. }
  3395. if (!"0".equals(evaluationSum5)) {
  3396. monthonmonthAmount6 = (evaluationSum66.subtract(evaluationSum55)).divide(evaluationSum55, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  3397. }
  3398. if (!"0".equals(evaluationSum6)) {
  3399. monthonmonthAmount7 = (evaluationSum77.subtract(evaluationSum66)).divide(evaluationSum66, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  3400. }
  3401. if (!"0".equals(evaluationSum7)) {
  3402. monthonmonthAmount8 = (evaluationSum88.subtract(evaluationSum77)).divide(evaluationSum77, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  3403. }
  3404. if (!"0".equals(evaluationSum8)) {
  3405. monthonmonthAmount9 = (evaluationSum99.subtract(evaluationSum88)).divide(evaluationSum88, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  3406. }
  3407. if (!"0".equals(evaluationSum9)) {
  3408. monthonmonthAmount10 = (evaluationSum1010.subtract(evaluationSum99)).divide(evaluationSum99, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  3409. }
  3410. if (!"0".equals(evaluationSum10)) {
  3411. monthonmonthAmount11 = (evaluationSum1111.subtract(evaluationSum1010)).divide(evaluationSum1010, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  3412. }
  3413. if (!"0".equals(evaluationSum11)) {
  3414. monthonmonthAmount12 = (evaluationSum1212.subtract(evaluationSum1111)).divide(evaluationSum1111, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  3415. }
  3416. map1.put("monthonmonthAmount", monthonmonthAmount1.toString());
  3417. map2.put("monthonmonthAmount", monthonmonthAmount2.toString());
  3418. map3.put("monthonmonthAmount", monthonmonthAmount3.toString());
  3419. map4.put("monthonmonthAmount", monthonmonthAmount4.toString());
  3420. map5.put("monthonmonthAmount", monthonmonthAmount5.toString());
  3421. map6.put("monthonmonthAmount", monthonmonthAmount6.toString());
  3422. map7.put("monthonmonthAmount", monthonmonthAmount7.toString());
  3423. map8.put("monthonmonthAmount", monthonmonthAmount8.toString());
  3424. map9.put("monthonmonthAmount", monthonmonthAmount9.toString());
  3425. map10.put("monthonmonthAmount", monthonmonthAmount10.toString());
  3426. map11.put("monthonmonthAmount", monthonmonthAmount11.toString());
  3427. map12.put("monthonmonthAmount", monthonmonthAmount12.toString());
  3428. // 预算金额同比比 对比
  3429. BigDecimal yearonyearAmount1 = new BigDecimal(0.00);
  3430. BigDecimal yearonyearAmount2 = new BigDecimal(0.00);
  3431. BigDecimal yearonyearAmount3 = new BigDecimal(0.00);
  3432. BigDecimal yearonyearAmount4 = new BigDecimal(0.00);
  3433. BigDecimal yearonyearAmount5 = new BigDecimal(0.00);
  3434. BigDecimal yearonyearAmount6 = new BigDecimal(0.00);
  3435. BigDecimal yearonyearAmount7 = new BigDecimal(0.00);
  3436. BigDecimal yearonyearAmount8 = new BigDecimal(0.00);
  3437. BigDecimal yearonyearAmount9 = new BigDecimal(0.00);
  3438. BigDecimal yearonyearAmount10 = new BigDecimal(0.00);
  3439. BigDecimal yearonyearAmount11 = new BigDecimal(0.00);
  3440. BigDecimal yearonyearAmount12 = new BigDecimal(0.00);
  3441. if (!"0".equals(evaluationSumOld1)) {
  3442. yearonyearAmount1 = (evaluationSum111.subtract(evaluationSumOld111)).divide(evaluationSumOld1111, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  3443. }
  3444. if (!"0".equals(evaluationSumOld2)) {
  3445. yearonyearAmount2 = (evaluationSum22.subtract(evaluationSumOld22)).divide(evaluationSumOld22, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  3446. }
  3447. if (!"0".equals(evaluationSumOld3)) {
  3448. yearonyearAmount3 = (evaluationSum33.subtract(evaluationSumOld33)).divide(evaluationSumOld33, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  3449. }
  3450. if (!"0".equals(evaluationSumOld4)) {
  3451. yearonyearAmount4 = (evaluationSum44.subtract(evaluationSumOld44)).divide(evaluationSumOld44, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  3452. }
  3453. if (!"0".equals(evaluationSumOld5)) {
  3454. yearonyearAmount5 = (evaluationSum55.subtract(evaluationSumOld55)).divide(evaluationSumOld44, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  3455. }
  3456. if (!"0".equals(evaluationSumOld6)) {
  3457. yearonyearAmount6 = (evaluationSum66.subtract(evaluationSumOld66)).divide(evaluationSumOld44, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  3458. }
  3459. if (!"0".equals(evaluationSumOld7)) {
  3460. yearonyearAmount7 = (evaluationSum77.subtract(evaluationSumOld77)).divide(evaluationSumOld44, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  3461. }
  3462. if (!"0".equals(evaluationSumOld8)) {
  3463. yearonyearAmount8 = (evaluationSum88.subtract(evaluationSumOld88)).divide(evaluationSumOld44, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  3464. }
  3465. if (!"0".equals(evaluationSumOld9)) {
  3466. yearonyearAmount9 = (evaluationSum99.subtract(evaluationSumOld99)).divide(evaluationSumOld44, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  3467. }
  3468. if (!"0".equals(evaluationSumOld10)) {
  3469. yearonyearAmount10 = (evaluationSum1010.subtract(evaluationSumOld1010)).divide(evaluationSumOld44, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  3470. }
  3471. if (!"0".equals(evaluationSumOld11)) {
  3472. yearonyearAmount11 = (evaluationSum1111.subtract(evaluationSumOld1111)).divide(evaluationSumOld44, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  3473. }
  3474. if (!"0".equals(evaluationSumOld12)) {
  3475. yearonyearAmount12 = (evaluationSum1212.subtract(evaluationSumOld1212)).divide(evaluationSumOld44, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  3476. }
  3477. map1.put("yearonyearAmount", yearonyearAmount1.toString());
  3478. map2.put("yearonyearAmount", yearonyearAmount2.toString());
  3479. map3.put("yearonyearAmount", yearonyearAmount3.toString());
  3480. map4.put("yearonyearAmount", yearonyearAmount4.toString());
  3481. map5.put("yearonyearAmount", yearonyearAmount5.toString());
  3482. map6.put("yearonyearAmount", yearonyearAmount6.toString());
  3483. map7.put("yearonyearAmount", yearonyearAmount7.toString());
  3484. map8.put("yearonyearAmount", yearonyearAmount8.toString());
  3485. map9.put("yearonyearAmount", yearonyearAmount9.toString());
  3486. map10.put("yearonyearAmount", yearonyearAmount10.toString());
  3487. map11.put("yearonyearAmount", yearonyearAmount11.toString());
  3488. map12.put("yearonyearAmount", yearonyearAmount12.toString());
  3489. // 存入集合
  3490. mapReturn.add(map1);
  3491. mapReturn.add(map2);
  3492. mapReturn.add(map3);
  3493. mapReturn.add(map4);
  3494. mapReturn.add(map5);
  3495. mapReturn.add(map6);
  3496. mapReturn.add(map7);
  3497. mapReturn.add(map8);
  3498. mapReturn.add(map9);
  3499. mapReturn.add(map10);
  3500. mapReturn.add(map11);
  3501. mapReturn.add(map12);
  3502. }
  3503. return mapReturn;
  3504. }
  3505. @Override
  3506. public List<StatisticalChartsResVo> demandSubCount(PmDemandReqVo pmDemandReqVo) {
  3507. //是-1就是查询自己及子孙级以下,否则只查询指定部门
  3508. if (pmDemandReqVo.getPurchaseDeptId().equals(-1)) {
  3509. pmDemandReqVo.setDeptList(isQueryAll(pmDemandReqVo.getPurchaseDeptId()));
  3510. } else {
  3511. pmDemandReqVo.setDemandIdAll(isQueryZD(pmDemandReqVo.getPurchaseDeptId()));
  3512. }
  3513. List<StatisticalChartsResVo> resVos = new ArrayList<>();
  3514. //本级和所属采购单位新提报采购需求数量--本年度中本级及下级审核的“需求待提交”之后状态的数据
  3515. StatisticalChartsResVo selectSTS = pmDemandMapper.selectSTS(pmDemandReqVo);
  3516. selectSTS.setColumnName("本级和所属采购单位新提报");
  3517. selectSTS.setColumnNamePlus("采购需求数量");
  3518. resVos.add(selectSTS);
  3519. //上年度结转和本年度提报的采购需求累计数量
  3520. //1.上年度结转:上年度“需求待提交”之后,“合同待填制”之前状态的数据
  3521. //2.本年度提报:指本年度“需求待提交”之后状态的数据
  3522. StatisticalChartsResVo lastYear = pmDemandMapper.selectSTSLastYear(pmDemandReqVo);
  3523. StatisticalChartsResVo thisYear = pmDemandMapper.selectSTSThisYear(pmDemandReqVo);
  3524. if (ObjectUtils.isEmpty(lastYear.getNum())) {
  3525. lastYear = new StatisticalChartsResVo();
  3526. lastYear.setNum(0);
  3527. lastYear.setEvaluationTotal(BigDecimal.ZERO);
  3528. lastYear.setEvaluationContractTotal(BigDecimal.ZERO);
  3529. }
  3530. if (ObjectUtils.isEmpty(thisYear.getNum())) {
  3531. thisYear = new StatisticalChartsResVo();
  3532. thisYear.setNum(0);
  3533. thisYear.setEvaluationTotal(BigDecimal.ZERO);
  3534. thisYear.setEvaluationContractTotal(BigDecimal.ZERO);
  3535. }
  3536. lastYear.setNum(lastYear.getNum() + thisYear.getNum());
  3537. lastYear.setEvaluationTotal(lastYear.getEvaluationTotal().add(thisYear.getEvaluationTotal()));
  3538. lastYear.setColumnName("上年度结转和本年度提报");
  3539. lastYear.setColumnNamePlus("采购需求累计数量");
  3540. resVos.add(lastYear);
  3541. //未按季度采购明细计划提报或调整延迟的数量--超过计划需求提报时间的项目
  3542. StatisticalChartsResVo meiJiDu = pmDemandMapper.selectmeiJiDu(pmDemandReqVo);
  3543. meiJiDu.setColumnName("未按季度采购明细计划提报或调整延迟");
  3544. meiJiDu.setColumnNamePlus("采购需求数量");
  3545. resVos.add(meiJiDu);
  3546. return resVos;
  3547. }
  3548. @Override
  3549. public List<StatisticalChartsResVo> countByProjectType(PmDemandReqVo pmDemandReqVo) {
  3550. //是-1就是查询自己及子孙级以下,否则只查询指定部门
  3551. if (pmDemandReqVo.getPurchaseDeptId().equals(-1)) {
  3552. pmDemandReqVo.setDeptList(isQueryAll(pmDemandReqVo.getPurchaseDeptId()));
  3553. } else {
  3554. pmDemandReqVo.setDemandIdAll(isQueryZD(pmDemandReqVo.getPurchaseDeptId()));
  3555. }
  3556. List<StatisticalChartsResVo> resultList = new ArrayList<>();
  3557. //项目类型情况统计--根据项目类型:物资类、服务类、工程类、装备类统计项目数量及预算金额
  3558. pmDemandReqVo.setProjectType(ProjectTypes.EQUIPMENTTYPE.getCode());
  3559. StatisticalChartsResVo res1 = pmDemandMapper.selectByProjectType(pmDemandReqVo);
  3560. res1.setColumnName(ProjectTypes.EQUIPMENTTYPE.getInfo());
  3561. resultList.add(res1);
  3562. pmDemandReqVo.setProjectType(ProjectTypes.MATERIALTYPE.getCode());
  3563. StatisticalChartsResVo res2 = pmDemandMapper.selectByProjectType(pmDemandReqVo);
  3564. res2.setColumnName(ProjectTypes.MATERIALTYPE.getInfo());
  3565. resultList.add(res2);
  3566. pmDemandReqVo.setProjectType(ProjectTypes.SERVICESTYPE.getCode());
  3567. StatisticalChartsResVo res3 = pmDemandMapper.selectByProjectType(pmDemandReqVo);
  3568. res3.setColumnName(ProjectTypes.SERVICESTYPE.getInfo());
  3569. resultList.add(res3);
  3570. pmDemandReqVo.setProjectType(ProjectTypes.PLANTOEXAMINETYPE.getCode());
  3571. StatisticalChartsResVo res4 = pmDemandMapper.selectByProjectType(pmDemandReqVo);
  3572. res4.setColumnName(ProjectTypes.PLANTOEXAMINETYPE.getInfo());
  3573. resultList.add(res4);
  3574. return resultList;
  3575. }
  3576. @Override
  3577. public List<StatisticalChartsResVo> countByPurchaseChange(PmDemandReqVo pmDemandReqVo) {
  3578. //是-1就是查询自己及子孙级以下,否则只查询指定部门
  3579. if (pmDemandReqVo.getPurchaseDeptId().equals(-1)) {
  3580. pmDemandReqVo.setDeptList(isQueryAll(pmDemandReqVo.getPurchaseDeptId()));
  3581. } else {
  3582. pmDemandReqVo.setDemandIdAll(isQueryZD(pmDemandReqVo.getPurchaseDeptId()));
  3583. }
  3584. List<StatisticalChartsResVo> byChange = new ArrayList<>();
  3585. //本月相关采购机构完成采购任务--状态为“标后质疑”后的数据
  3586. StatisticalChartsResVo thisMonth = pmDemandMapper.selectCGThisMonth(pmDemandReqVo);
  3587. thisMonth.setColumnName("本月相关采购机构");
  3588. thisMonth.setColumnNamePlus("完成采购任务数量");
  3589. byChange.add(thisMonth);
  3590. //本季度相关采购机构完成采购任务--状态为“标后质疑”后的数据
  3591. StatisticalChartsResVo thisQua = pmDemandMapper.selectCGThisQua(pmDemandReqVo);
  3592. thisQua.setColumnName("本季度相关采购机构");
  3593. thisQua.setColumnNamePlus("完成采购任务数量");
  3594. byChange.add(thisQua);
  3595. //上年度结转和本年度提报的采购需求中累计已完成的采购任务
  3596. //上年度结转:上年度“标后质疑”之后,“合同待填制”之前状态的数据
  3597. //本年度提报:状态为“标后质疑”后的数据
  3598. StatisticalChartsResVo zLastYear = pmDemandMapper.selectZJLastYear(pmDemandReqVo);
  3599. StatisticalChartsResVo tThisYear = pmDemandMapper.selectTBThisYear(pmDemandReqVo);
  3600. if (ObjectUtils.isEmpty(zLastYear.getNum())) {
  3601. zLastYear = new StatisticalChartsResVo();
  3602. zLastYear.setNum(0);
  3603. zLastYear.setEvaluationTotal(BigDecimal.ZERO);
  3604. zLastYear.setEvaluationContractTotal(BigDecimal.ZERO);
  3605. }
  3606. if (ObjectUtils.isEmpty(tThisYear.getNum())) {
  3607. tThisYear = new StatisticalChartsResVo();
  3608. tThisYear.setNum(0);
  3609. tThisYear.setEvaluationTotal(BigDecimal.ZERO);
  3610. tThisYear.setEvaluationContractTotal(BigDecimal.ZERO);
  3611. }
  3612. //tThisYear.setNum(ObjectUtils.isEmpty(tThisYear.getNum()) ? 0 : tThisYear.getNum() + (ObjectUtils.isEmpty(zLastYear.getNum()) ? 0 : zLastYear.getNum()));
  3613. //tThisYear.setEvaluationTotal((ObjectUtils.isEmpty(tThisYear.getEvaluationTotal()) ? BigDecimal.ZERO : tThisYear.getEvaluationTotal()).add((ObjectUtils.isEmpty(zLastYear.getEvaluationTotal()) ? BigDecimal.ZERO : zLastYear.getEvaluationTotal())));
  3614. //tThisYear.setEvaluationContractTotal((ObjectUtils.isEmpty(tThisYear.getEvaluationContractTotal()) ? BigDecimal.ZERO : tThisYear.getEvaluationContractTotal()).add(ObjectUtils.isEmpty(zLastYear.getEvaluationContractTotal()) ? BigDecimal.ZERO : zLastYear.getEvaluationContractTotal()));
  3615. tThisYear.setColumnName("上年度结转和本年度提报的采购需求");
  3616. tThisYear.setColumnNamePlus("累计完成采购任务数量");
  3617. byChange.add(tThisYear);
  3618. //正常推进周期内的采购任务--本年度项目未超过计划完成采购时间的数据
  3619. StatisticalChartsResVo cThisYear = pmDemandMapper.selectCCThisYear(pmDemandReqVo);
  3620. cThisYear.setColumnName("正常推进周期内");
  3621. cThisYear.setColumnNamePlus("采购任务数量");
  3622. byChange.add(cThisYear);
  3623. return byChange;
  3624. }
  3625. @Override
  3626. public AjaxResult exceedReason(PmDemandReqVo pmDemandReqVo) {
  3627. List<StatisticalChartsResVo> resVos = new ArrayList<>();
  3628. //是-1就是查询自己及子孙级以下,否则只查询指定部门
  3629. if (pmDemandReqVo.getPurchaseDeptId().equals(-1)) {
  3630. pmDemandReqVo.setDeptList(isQueryAll(pmDemandReqVo.getPurchaseDeptId()));
  3631. } else {
  3632. pmDemandReqVo.setDemandIdAll(isQueryZD(pmDemandReqVo.getPurchaseDeptId()));
  3633. }
  3634. //统计超过计划完成采购时间的项目中,处在各阶段的数据包括以下内容:
  3635. //1、需求编制对接数量/涉及金额:状态为“采购需求对接”的数量及预算金额
  3636. List<String> xqdj = new ArrayList<>();
  3637. xqdj.add(PmProjectStatus.PURCHASE_DEMAND_DOCKING.getCode());
  3638. pmDemandReqVo.setProjectStatusList(xqdj);
  3639. StatisticalChartsResVo resVo = pmDemandMapper.countProjectExceedAndStatus(pmDemandReqVo);
  3640. resVo.setColumnName("需求编制对接数量");
  3641. resVos.add(resVo);
  3642. //2、采购文件编制审核数量/涉及金额:状态为“采购文件编制审核“的数量及预算金额
  3643. List<String> wjsh = new ArrayList<>();
  3644. wjsh.add(PmProjectStatus.PROCUREMENT_DOCUMENTS_REVIEW.getCode());
  3645. pmDemandReqVo.setProjectStatusList(wjsh);
  3646. StatisticalChartsResVo resVo2 = pmDemandMapper.countProjectExceedAndStatus(pmDemandReqVo);
  3647. resVo2.setColumnName("采购文件编制审核数量");
  3648. resVos.add(resVo2);
  3649. //3、质疑、投诉、复议、信访举报数量/涉及金额:按钮”质疑投诉”进行质疑过的项目及预算金额
  3650. List<Long> demandIdAll = questionHisService.selectDemandIdAll();
  3651. pmDemandReqVo.setDemandIdAll(demandIdAll);
  3652. StatisticalChartsResVo resVo3 = pmDemandMapper.countProjectExceedAndStatus(pmDemandReqVo);
  3653. resVo3.setColumnName("质疑、投诉、复议、信访举报数量");
  3654. resVos.add(resVo3);
  3655. //4、流标废标数量/涉及金额:状态为“流废标处置”的项目及预算金额
  3656. List<String> fblb = new ArrayList<>();
  3657. fblb.add(PmProjectStatus.WASTE_BID_HANDLE.getCode());
  3658. pmDemandReqVo.setProjectStatusList(fblb);
  3659. StatisticalChartsResVo resVo4 = pmDemandMapper.countProjectExceedAndStatus(pmDemandReqVo);
  3660. resVo4.setColumnName("流标废标数量");
  3661. resVos.add(resVo4);
  3662. //5、其他原因项目数量/涉及金额:统计“专家意见反馈”、“采购公告发布”、”待开标“、”评标结果公告“、“标后质疑”状态的数据
  3663. List<String> qtyy = new ArrayList<>();
  3664. qtyy.add(PmProjectStatus.EXPERT_FEEDBACK.getCode());
  3665. qtyy.add(PmProjectStatus.PROCUREMENT_ANNOUNCEMENT.getCode());
  3666. qtyy.add(PmProjectStatus.WAIT_OPEN_BID.getCode());
  3667. qtyy.add(PmProjectStatus.BID_RESULT_ANNOUNCEMENT.getCode());
  3668. qtyy.add(PmProjectStatus.POST_BID_QUERY.getCode());
  3669. pmDemandReqVo.setProjectStatusList(qtyy);
  3670. StatisticalChartsResVo resVo5 = pmDemandMapper.countProjectExceedAndStatus(pmDemandReqVo);
  3671. resVo5.setColumnName("其他原因项目数量");
  3672. resVos.add(resVo5);
  3673. return AjaxResult.success(resVos);
  3674. }
  3675. @Override
  3676. public AjaxResult exceedReasonZj(PmDemandReqVo pmDemandReqVo) {
  3677. List<StatisticalChartsResVo> resVos = new ArrayList<>();
  3678. //是-1就是查询自己及子孙级以下,否则只查询指定部门
  3679. if (pmDemandReqVo.getPurchaseDeptId().equals(-1)) {
  3680. pmDemandReqVo.setDeptList(isQueryAll(pmDemandReqVo.getPurchaseDeptId()));
  3681. } else {
  3682. pmDemandReqVo.setDemandIdAll(isQueryZD(pmDemandReqVo.getPurchaseDeptId()));
  3683. }
  3684. //统计超过计划完成采购时间的项目中,处在各阶段的数据包括以下内容:
  3685. //1、需求编制对接数量/涉及金额:状态为“采购需求对接”的数量及预算金额
  3686. List<String> xqdj = new ArrayList<>();
  3687. xqdj.add(PmProjectStatus.PURCHASE_DEMAND_DOCKING.getCode());
  3688. pmDemandReqVo.setProjectStatusList(xqdj);
  3689. StatisticalChartsResVo resVo = pmDemandMapper.countProjectExceedAndStatus(pmDemandReqVo);
  3690. resVo.setColumnName("需求编制对接数量");
  3691. resVos.add(resVo);
  3692. //2、采购文件编制审核数量/涉及金额:状态为“采购文件编制审核“的数量及预算金额
  3693. List<String> wjsh = new ArrayList<>();
  3694. wjsh.add(PmProjectStatus.PROCUREMENT_DOCUMENTS_REVIEW.getCode());
  3695. pmDemandReqVo.setProjectStatusList(wjsh);
  3696. StatisticalChartsResVo resVo2 = pmDemandMapper.countProjectExceedAndStatus(pmDemandReqVo);
  3697. resVo2.setColumnName("采购文件编制审核数量");
  3698. resVos.add(resVo2);
  3699. //3、质疑、投诉、复议、信访举报数量/涉及金额:按钮”质疑投诉”进行质疑过的项目及预算金额
  3700. List<Long> demandIdAll = questionHisService.selectDemandIdAll();
  3701. pmDemandReqVo.setDemandIdAll(demandIdAll);
  3702. StatisticalChartsResVo resVo3 = pmDemandMapper.countProjectExceedAndStatus(pmDemandReqVo);
  3703. resVo3.setColumnName("质疑、投诉、复议、信访举报数量");
  3704. resVos.add(resVo3);
  3705. //5、其他原因项目数量/涉及金额:统计“专家意见反馈”、“采购公告发布”、”待开标“、”评标结果公告“、“标后质疑”状态的数据
  3706. List<String> qtyy = new ArrayList<>();
  3707. qtyy.add(PmProjectStatus.EXPERT_FEEDBACK.getCode());
  3708. qtyy.add(PmProjectStatus.PROCUREMENT_ANNOUNCEMENT.getCode());
  3709. qtyy.add(PmProjectStatus.WAIT_OPEN_BID.getCode());
  3710. qtyy.add(PmProjectStatus.BID_RESULT_ANNOUNCEMENT.getCode());
  3711. qtyy.add(PmProjectStatus.POST_BID_QUERY.getCode());
  3712. pmDemandReqVo.setProjectStatusList(qtyy);
  3713. StatisticalChartsResVo resVo5 = pmDemandMapper.countProjectExceedAndStatus(pmDemandReqVo);
  3714. resVo5.setColumnName("其他原因项目数量");
  3715. resVos.add(resVo5);
  3716. return AjaxResult.success(resVos);
  3717. }
  3718. @Override
  3719. public AjaxResult exceedLink(PmDemandReqVo pmDemandReqVo) {
  3720. List<StatisticalChartsResVo> resVos = new ArrayList<>();
  3721. //是-1就是查询自己及子孙级以下,否则只查询指定部门
  3722. if (pmDemandReqVo.getPurchaseDeptId().equals(-1)) {
  3723. pmDemandReqVo.setDeptList(isQueryAll(pmDemandReqVo.getPurchaseDeptId()));
  3724. } else {
  3725. pmDemandReqVo.setDemandIdAll(isQueryZD(pmDemandReqVo.getPurchaseDeptId()));
  3726. }
  3727. //滞留环节
  3728. //超过计划完成采购时间的各状态数量及占比统计,包括:采购需求对接、采购文件编制审核、标签质疑投诉、待开标、流废标处置、标后质疑
  3729. //1、 状态为“采购需求对接”的数量及预算金额
  3730. List<String> xqdj = new ArrayList<>();
  3731. xqdj.add(PmProjectStatus.PURCHASE_DEMAND_DOCKING.getCode());
  3732. pmDemandReqVo.setProjectStatusList(xqdj);
  3733. StatisticalChartsResVo resVo = pmDemandMapper.countProjectExceedAndStatus(pmDemandReqVo);
  3734. resVo.setColumnName("采购需求对接");
  3735. resVos.add(resVo);
  3736. //2、 状态为“采购文件编制审核“的数量及预算金额
  3737. List<String> wjsh = new ArrayList<>();
  3738. wjsh.add(PmProjectStatus.PROCUREMENT_DOCUMENTS_REVIEW.getCode());
  3739. pmDemandReqVo.setProjectStatusList(wjsh);
  3740. StatisticalChartsResVo resVo2 = pmDemandMapper.countProjectExceedAndStatus(pmDemandReqVo);
  3741. resVo2.setColumnName("采购文件编制审核");
  3742. resVos.add(resVo2);
  3743. //3.标前质疑
  3744. List<String> bqzy = new ArrayList<>();
  3745. bqzy.add(PmProjectStatus.PRE_BID_QUERY.getCode());
  3746. pmDemandReqVo.setProjectStatusList(bqzy);
  3747. StatisticalChartsResVo resVo3 = pmDemandMapper.countProjectExceedAndStatus(pmDemandReqVo);
  3748. resVo3.setColumnName("标前质疑投诉");
  3749. resVos.add(resVo3);
  3750. //4、 待开标
  3751. List<String> dkb = new ArrayList<>();
  3752. dkb.add(PmProjectStatus.WAIT_OPEN_BID.getCode());
  3753. pmDemandReqVo.setProjectStatusList(dkb);
  3754. StatisticalChartsResVo resVo4 = pmDemandMapper.countProjectExceedAndStatus(pmDemandReqVo);
  3755. resVo4.setColumnName("待开标");
  3756. resVos.add(resVo4);
  3757. //5、 流废标处置
  3758. List<String> lfb = new ArrayList<>();
  3759. lfb.add(PmProjectStatus.WASTE_BID_HANDLE.getCode());
  3760. pmDemandReqVo.setProjectStatusList(lfb);
  3761. StatisticalChartsResVo resVo5 = pmDemandMapper.countProjectExceedAndStatus(pmDemandReqVo);
  3762. resVo5.setColumnName("流废标处置");
  3763. resVos.add(resVo5);
  3764. //6、 标后质疑
  3765. List<String> bhzy = new ArrayList<>();
  3766. bhzy.add(PmProjectStatus.POST_BID_QUERY.getCode());
  3767. pmDemandReqVo.setProjectStatusList(bhzy);
  3768. StatisticalChartsResVo resVo6 = pmDemandMapper.countProjectExceedAndStatus(pmDemandReqVo);
  3769. resVo6.setColumnName("标后质疑");
  3770. resVos.add(resVo6);
  3771. return AjaxResult.success(resVos);
  3772. }
  3773. @Override
  3774. public AjaxResult countPurTask(PmDemandReqVo pmDemandReqVo) {
  3775. List<StatisticalChartsResVo> resVos = new ArrayList<>();
  3776. //是-1就是查询自己及子孙级以下,否则只查询指定部门
  3777. if (pmDemandReqVo.getPurchaseDeptId().equals(-1)) {
  3778. pmDemandReqVo.setDeptList(isQueryAll(pmDemandReqVo.getPurchaseDeptId()));
  3779. } else {
  3780. pmDemandReqVo.setDemandIdAll(isQueryZD(pmDemandReqVo.getPurchaseDeptId()));
  3781. }
  3782. //1、所属采购服务站数量
  3783. //查询现有的采购服务站
  3784. SysDictData dictData = new SysDictData();
  3785. dictData.setDictType("purchase_services");
  3786. List<SysDictData> servicesData = dictDataService.selectDictDataList(dictData);
  3787. StatisticalChartsResVo resVo = new StatisticalChartsResVo();
  3788. resVo.setColumnName("所属采购服务站数量");
  3789. resVo.setNum(servicesData.size());
  3790. resVos.add(resVo);
  3791. //2、所属采购机构--根据招标代理机构管理中的白名单数据显示
  3792. StatisticalChartsResVo resVo2 = pmDemandMapper.countBaseAgencyWithWhite();
  3793. resVo2.setColumnName("所属采购机构");
  3794. resVos.add(resVo2);
  3795. //3、新受领集中采购数量--状态为“任务待下达”之后的数据
  3796. StatisticalChartsResVo resVo3 = pmDemandMapper.JZCGnum(pmDemandReqVo);
  3797. resVo3.setColumnName("新受领集中采购数量");
  3798. resVos.add(resVo3);
  3799. //4、上年度结转任务数量 上年度“任务待下达”之后,“合同待填制”之前的状态的数据
  3800. List<String> snzj = new ArrayList<>();
  3801. snzj.add(PmProjectStatus.TASK_WAIT_RELEASE.getCode());
  3802. snzj.add(PmProjectStatus.PURCHASE_DEMAND_DOCKING.getCode());
  3803. snzj.add(PmProjectStatus.EXPERT_FEEDBACK.getCode());
  3804. snzj.add(PmProjectStatus.PROCUREMENT_DOCUMENTS_REVIEW.getCode());
  3805. snzj.add(PmProjectStatus.PROCUREMENT_ANNOUNCEMENT.getCode());
  3806. snzj.add(PmProjectStatus.PRE_BID_QUERY.getCode());
  3807. snzj.add(PmProjectStatus.WAIT_OPEN_BID.getCode());
  3808. snzj.add(PmProjectStatus.BID_RESULT_ANNOUNCEMENT.getCode());
  3809. snzj.add(PmProjectStatus.WASTE_BID_HANDLE.getCode());
  3810. pmDemandReqVo.setProjectStatusList(snzj);
  3811. StatisticalChartsResVo resVo4 = pmDemandMapper.countProjecReaAndStatus(pmDemandReqVo);
  3812. resVo4.setColumnName("上年度结转任务数量");
  3813. resVos.add(resVo4);
  3814. return AjaxResult.success(resVos);
  3815. }
  3816. @Override
  3817. public AjaxResult countMajorProjectNumCGB(PmDemandReqVo pmDemandReqVo) {
  3818. //新增执行滞后采购任务数量分析 所有的超过计划完成采购时间的数据
  3819. //是-1就是查询自己及子孙级以下,否则只查询指定部门
  3820. if (pmDemandReqVo.getPurchaseDeptId().equals(-1)) {
  3821. pmDemandReqVo.setDeptList(isQueryAll(pmDemandReqVo.getPurchaseDeptId()));
  3822. } else {
  3823. pmDemandReqVo.setDemandIdAll(isQueryZD(pmDemandReqVo.getPurchaseDeptId()));
  3824. }
  3825. HashMap<String, List<StatisticalChartsResVo>> resMap = new HashMap<>();
  3826. // 查询数据库中最小的年份
  3827. int minYear = pmDemandMapper.selectMinYear();
  3828. // 获取当前年份
  3829. Calendar calendar = Calendar.getInstance();
  3830. int thisYear = calendar.get(Calendar.YEAR);
  3831. List<StatisticalChartsResVo> resVos = new LinkedList<>();
  3832. for (int i = minYear; i <= thisYear; i++) {
  3833. pmDemandReqVo.setYear(i);
  3834. StatisticalChartsResVo byYear = pmDemandMapper.countProjectACT_Year(pmDemandReqVo);
  3835. resVos.add(byYear);
  3836. }
  3837. if (pmDemandReqVo.getTimeType().equals("1")) {
  3838. resMap.put("年", resVos);
  3839. } else if (pmDemandReqVo.getTimeType().equals("2")) {
  3840. List<StatisticalChartsResVo> byQuarter = new LinkedList<>();
  3841. for (StatisticalChartsResVo chartsResVo : resVos) {
  3842. pmDemandReqVo.setYear(Integer.parseInt(chartsResVo.getColumnName()));
  3843. for (int i = 1; i <= 4; i++) {
  3844. pmDemandReqVo.setQuarter(i);
  3845. StatisticalChartsResVo quarter = pmDemandMapper.countProjectACT_Qua(pmDemandReqVo);
  3846. if (ObjectUtils.isEmpty(quarter)) {
  3847. StatisticalChartsResVo vo = new StatisticalChartsResVo("", "", 0, BigDecimal.valueOf(0), BigDecimal.valueOf(0));
  3848. quarter = vo;
  3849. quarter.setColumnName(chartsResVo.getColumnName() + "年第" + i + "季度");
  3850. }
  3851. quarter.setColumnName(chartsResVo.getColumnName() + "年第" + i + "季度");
  3852. byQuarter.add(quarter);
  3853. }
  3854. }
  3855. resMap.put("季度", byQuarter);
  3856. } else if (pmDemandReqVo.getTimeType().equals("3")) {
  3857. List<StatisticalChartsResVo> byMonth = new LinkedList<>();
  3858. for (StatisticalChartsResVo chartsResVo : resVos) {
  3859. pmDemandReqVo.setYear(Integer.parseInt(chartsResVo.getColumnName()));
  3860. for (int i = 1; i <= 12; i++) {
  3861. pmDemandReqVo.setMonth(i);
  3862. StatisticalChartsResVo month = pmDemandMapper.countProjectACT_Mon(pmDemandReqVo);
  3863. if (ObjectUtils.isEmpty(month)) {
  3864. StatisticalChartsResVo vo = new StatisticalChartsResVo("", "", 0, BigDecimal.valueOf(0), BigDecimal.valueOf(0));
  3865. month = vo;
  3866. month.setColumnName(chartsResVo.getColumnName() + "年" + i + "月");
  3867. }
  3868. month.setColumnName(chartsResVo.getColumnName() + "年" + i + "月");
  3869. byMonth.add(month);
  3870. }
  3871. }
  3872. resMap.put("月", byMonth);
  3873. }
  3874. return AjaxResult.success(resMap);
  3875. }
  3876. //查询不同状态下的项目数据
  3877. public List<PmDemand> getListByStatus(String projectStatus) {
  3878. LoginUser user = SecurityUtils.getLoginUser();
  3879. LambdaQueryWrapper<PmDemand> lw = new LambdaQueryWrapper<PmDemand>();
  3880. // 通过用户ID查询角色
  3881. List<SysRole> sysRoles = sysRoleMapper.selectRolePermissionByUserId(user.getUserId());
  3882. //需求单位只能查看和操作个人数据
  3883. List<SysRole> sysRoleList = sysRoles.stream().filter(tdto -> tdto.getRoleKey().equals("demand_unit")).collect(Collectors.toList());
  3884. if (!ObjectUtils.isEmpty(sysRoleList)) {
  3885. lw.eq(PmDemand::getCreateBy, user.getUserId());
  3886. } else if (!projectStatus.equals("5") && !projectStatus.equals("4")) {
  3887. //需求待提交时不用查审核
  3888. List<PmAuditDeptRef> list = new ArrayList<>();
  3889. LambdaQueryWrapper<PmAuditDeptRef> l = new LambdaQueryWrapper<>();
  3890. l.eq(PmAuditDeptRef::getDeptId, SecurityUtils.getDeptId());
  3891. l.eq(PmAuditDeptRef::getRefType, "2");
  3892. list = pmAuditDeptRefService.list(l);
  3893. if (!ObjectUtils.isEmpty(list) && !SysUser.isAdmin(SecurityUtils.getUserId())) {
  3894. lw.in(PmDemand::getDemandId, list.stream().map(PmAuditDeptRef::getRefId).collect(Collectors.toList()));
  3895. }
  3896. }
  3897. lw.in(PmDemand::getProjectStatus, projectStatus);
  3898. lw.eq(PmDemand::getPurchaseDeptId, SecurityUtils.getDeptId());
  3899. lw.last(" order by project_status, plan_demand_sub_time");
  3900. return this.baseMapper.selectList(lw);
  3901. }
  3902. /**
  3903. * 查询不同状态下的项目数据(采购办)
  3904. * 采购执行管理中,本单位超额项目交给上级处理,本单位不处理。
  3905. *
  3906. * @param projectStatus
  3907. * @return
  3908. */
  3909. public List<PmDemand> getListByStatusCGB(String projectStatus) {
  3910. //登录用户的部门
  3911. Long deptId = SecurityUtils.getDeptId();
  3912. SysDept sysDept = deptMapper.selectDeptById(deptId);
  3913. LambdaQueryWrapper<PmDemand> lw = new LambdaQueryWrapper<PmDemand>();
  3914. List<PmAuditDeptRef> list = new ArrayList<>();
  3915. LambdaQueryWrapper<PmAuditDeptRef> l = new LambdaQueryWrapper<>();
  3916. l.eq(PmAuditDeptRef::getDeptId, deptId);
  3917. l.eq(PmAuditDeptRef::getRefType, "2");
  3918. list = pmAuditDeptRefService.list(l);
  3919. //本单位所有参与审核的项目id
  3920. List<Long> refList = list.stream().map(PmAuditDeptRef::getRefId).collect(Collectors.toList());
  3921. //上级参与审核的项目
  3922. List<Long> refListf = new ArrayList<>();
  3923. List<PmAuditDeptRef> listf = new ArrayList<>();
  3924. if (sysDept.getParentId() != 0) {
  3925. LambdaQueryWrapper<PmAuditDeptRef> lf = new LambdaQueryWrapper<>();
  3926. lf.eq(PmAuditDeptRef::getDeptId, sysDept.getParentId());
  3927. lf.eq(PmAuditDeptRef::getRefType, "2");
  3928. listf = pmAuditDeptRefService.list(lf);
  3929. //上级参与审核的项目id
  3930. refListf = listf.stream().map(PmAuditDeptRef::getRefId).collect(Collectors.toList());
  3931. }
  3932. //取集合差集,只处理差集中的数据
  3933. if (!ObjectUtils.isEmpty(refListf)) {
  3934. refList.removeAll(refListf);
  3935. }
  3936. lw.in(PmDemand::getProjectStatus, projectStatus);
  3937. lw.last(" order by project_status, plan_demand_sub_time");
  3938. return this.baseMapper.selectList(lw);
  3939. }
  3940. /**
  3941. * 查询不同状态下的项目数据
  3942. * 待办事项--全部
  3943. *
  3944. * @param projectStatus
  3945. * @return
  3946. */
  3947. public List<PmDemand> getListByStatusTotal(List<String> projectStatus) {
  3948. LambdaQueryWrapper<PmDemand> lw = new LambdaQueryWrapper<PmDemand>();
  3949. List<PmAuditDeptRef> list = new ArrayList<>();
  3950. LambdaQueryWrapper<PmAuditDeptRef> l = new LambdaQueryWrapper<>();
  3951. l.eq(PmAuditDeptRef::getDeptId, SecurityUtils.getDeptId());
  3952. l.eq(PmAuditDeptRef::getRefType, "2");
  3953. list = pmAuditDeptRefService.list(l);
  3954. if (!ObjectUtils.isEmpty(list) && !SysUser.isAdmin(SecurityUtils.getUserId())) {
  3955. lw.in(PmDemand::getDemandId, list.stream().map(PmAuditDeptRef::getRefId).collect(Collectors.toList()));
  3956. }
  3957. lw.in(PmDemand::getProjectStatus, projectStatus);
  3958. lw.eq(PmDemand::getPurchaseDeptId, SecurityUtils.getDeptId());
  3959. lw.last(" order by project_status, plan_demand_sub_time");
  3960. return this.baseMapper.selectList(lw);
  3961. }
  3962. /**
  3963. * 查询不同状态下的项目数据(采购办)
  3964. * 采购执行管理中,本单位超额项目交给上级处理,本单位不处理。
  3965. * 待办事项--全部
  3966. *
  3967. * @param projectStatus
  3968. * @return
  3969. */
  3970. public List<PmDemand> getListByStatusTotalCGB(List<String> projectStatus) {
  3971. //登录用户的部门
  3972. Long deptId = SecurityUtils.getDeptId();
  3973. SysDept sysDept = deptMapper.selectDeptById(deptId);
  3974. LambdaQueryWrapper<PmDemand> lw = new LambdaQueryWrapper<PmDemand>();
  3975. List<PmAuditDeptRef> list = new ArrayList<>();
  3976. LambdaQueryWrapper<PmAuditDeptRef> l = new LambdaQueryWrapper<>();
  3977. l.eq(PmAuditDeptRef::getDeptId, deptId);
  3978. l.eq(PmAuditDeptRef::getRefType, "2");
  3979. list = pmAuditDeptRefService.list(l);
  3980. //本单位所有参与审核的项目id
  3981. List<Long> refList = list.stream().map(PmAuditDeptRef::getRefId).collect(Collectors.toList());
  3982. //上级参与审核的项目
  3983. List<Long> refListf = new ArrayList<>();
  3984. List<PmAuditDeptRef> listf = new ArrayList<>();
  3985. if (sysDept.getParentId() != 0) {
  3986. LambdaQueryWrapper<PmAuditDeptRef> lf = new LambdaQueryWrapper<>();
  3987. lf.eq(PmAuditDeptRef::getDeptId, sysDept.getParentId());
  3988. lf.eq(PmAuditDeptRef::getRefType, "2");
  3989. listf = pmAuditDeptRefService.list(lf);
  3990. //上级参与审核的项目id
  3991. refListf = listf.stream().map(PmAuditDeptRef::getRefId).collect(Collectors.toList());
  3992. }
  3993. //取集合差集,只处理差集中的数据
  3994. if (!ObjectUtils.isEmpty(refListf)) {
  3995. refList.removeAll(refListf);
  3996. }
  3997. //为空就返回空
  3998. if (ObjectUtils.isEmpty(refList) && !SysUser.isAdmin(SecurityUtils.getUserId())) {
  3999. lw.in(PmDemand::getDemandId, -1);
  4000. } else if (!ObjectUtils.isEmpty(refList) && !SysUser.isAdmin(SecurityUtils.getUserId())) {
  4001. lw.in(PmDemand::getDemandId, refList);
  4002. }
  4003. lw.in(PmDemand::getProjectStatus, projectStatus);
  4004. lw.last(" order by project_status, plan_demand_sub_time");
  4005. return this.baseMapper.selectList(lw);
  4006. }
  4007. //数据转换
  4008. @Override
  4009. public List<PmDemandResVo> listToVoList(List<PmDemand> demandList) {
  4010. List<PmDemandResVo> pmDemandResponseVoList = new ArrayList<>();
  4011. if (!ObjectUtils.isEmpty(demandList) && demandList.size() > 0) {
  4012. pmDemandResponseVoList = demandChangeTo(demandList);
  4013. }
  4014. return pmDemandResponseVoList;
  4015. }
  4016. //查询不同状态下的项目数据的数量
  4017. @Override
  4018. public Integer getNumByStatus(String projectStatus) {
  4019. LoginUser user = SecurityUtils.getLoginUser();
  4020. LambdaQueryWrapper<PmDemand> lw = new LambdaQueryWrapper<PmDemand>();
  4021. // 通过用户ID查询角色
  4022. List<SysRole> sysRoles = sysRoleMapper.selectRolePermissionByUserId(user.getUserId());
  4023. //需求单位只能查看和操作个人数据
  4024. List<SysRole> sysRoleList = sysRoles.stream().filter(tdto -> tdto.getRoleKey().equals("demand_unit")).collect(Collectors.toList());
  4025. if (!ObjectUtils.isEmpty(sysRoleList)) {
  4026. lw.eq(PmDemand::getCreateBy, user.getUserId());
  4027. } else if (!projectStatus.equals("5") && !projectStatus.equals("4")) {
  4028. ///需求待提交时不用查审核
  4029. List<PmAuditDeptRef> list = new ArrayList<>();
  4030. LambdaQueryWrapper<PmAuditDeptRef> l = new LambdaQueryWrapper<>();
  4031. l.eq(PmAuditDeptRef::getDeptId, SecurityUtils.getDeptId());
  4032. l.eq(PmAuditDeptRef::getRefType, "2");
  4033. list = pmAuditDeptRefService.list(l);
  4034. if (!ObjectUtils.isEmpty(list) && !SysUser.isAdmin(SecurityUtils.getUserId())) {
  4035. lw.in(PmDemand::getDemandId, list.stream().map(PmAuditDeptRef::getRefId).collect(Collectors.toList()));
  4036. }
  4037. }
  4038. lw.eq(PmDemand::getProjectStatus, projectStatus);
  4039. lw.eq(PmDemand::getPurchaseDeptId, SecurityUtils.getDeptId());
  4040. lw.last(" order by project_status, plan_demand_sub_time");
  4041. Long count = this.baseMapper.selectCount(lw);
  4042. return Math.toIntExact(count);
  4043. }
  4044. /**
  4045. * 查询不同状态下的项目数据的数量(采购办首页)
  4046. * 采购执行管理中,本单位超额项目交给上级处理,本单位不处理。
  4047. */
  4048. @Override
  4049. public Integer getNumByStatusCGB(String projectStatus) {
  4050. //登录用户的部门
  4051. Long deptId = SecurityUtils.getDeptId();
  4052. SysDept sysDept = deptMapper.selectDeptById(deptId);
  4053. LambdaQueryWrapper<PmDemand> lw = new LambdaQueryWrapper<PmDemand>();
  4054. List<PmAuditDeptRef> list = new ArrayList<>();
  4055. LambdaQueryWrapper<PmAuditDeptRef> l = new LambdaQueryWrapper<>();
  4056. l.eq(PmAuditDeptRef::getDeptId, deptId);
  4057. l.eq(PmAuditDeptRef::getRefType, "2");
  4058. list = pmAuditDeptRefService.list(l);
  4059. //本单位所有参与审核的项目id
  4060. List<Long> refList = list.stream().map(PmAuditDeptRef::getRefId).collect(Collectors.toList());
  4061. //上级参与审核的项目
  4062. List<Long> refListf = new ArrayList<>();
  4063. List<PmAuditDeptRef> listf = new ArrayList<>();
  4064. if (sysDept.getParentId() != 0) {
  4065. LambdaQueryWrapper<PmAuditDeptRef> lf = new LambdaQueryWrapper<>();
  4066. lf.eq(PmAuditDeptRef::getDeptId, sysDept.getParentId());
  4067. lf.eq(PmAuditDeptRef::getRefType, "2");
  4068. listf = pmAuditDeptRefService.list(lf);
  4069. //上级参与审核的项目id
  4070. refListf = listf.stream().map(PmAuditDeptRef::getRefId).collect(Collectors.toList());
  4071. }
  4072. //取集合差集,只处理差集中的数据
  4073. if (!ObjectUtils.isEmpty(refListf)) {
  4074. refList.removeAll(refListf);
  4075. }
  4076. //为空就返回空
  4077. if (ObjectUtils.isEmpty(refList) && !SysUser.isAdmin(SecurityUtils.getUserId())) {
  4078. lw.in(PmDemand::getDemandId, -1);
  4079. } else if (!ObjectUtils.isEmpty(refList) && !SysUser.isAdmin(SecurityUtils.getUserId())) {
  4080. lw.in(PmDemand::getDemandId, refList);
  4081. }
  4082. lw.eq(PmDemand::getProjectStatus, projectStatus);
  4083. lw.last(" order by project_status, plan_demand_sub_time");
  4084. Long count = this.baseMapper.selectCount(lw);
  4085. return Math.toIntExact(count);
  4086. }
  4087. //字段转换and赋值
  4088. public List<PmDemandResVo> demandChangeTo(List<PmDemand> pmDemandList) {
  4089. List<PmDemandResVo> pmDemandResponseVoList = new ArrayList<>();
  4090. //获取字典数据
  4091. HashMap<String, HashMap<String, String>> planEnums = dictTypeService.getAboutEnums();
  4092. //项目属性
  4093. HashMap<String, String> projectAttributes = planEnums.get("projectAttributes");
  4094. //提前或延后*天进行提醒
  4095. List<SysDictData> alertTime = dictTypeService.selectDictDataByType("alert_time_setting");
  4096. HashMap<String, String> alertTimeMap = new LinkedHashMap<>();
  4097. //根据时间类别设定的提醒时间
  4098. for (SysDictData dictData : alertTime) {
  4099. // 字段名称----阈值
  4100. alertTimeMap.put(dictData.getDictLabel(), dictData.getDictValue());
  4101. }
  4102. for (PmDemand pmDemand1 : pmDemandList) {
  4103. PmDemandResVo vo = new PmDemandResVo();
  4104. BeanUtils.copyProperties(pmDemand1, vo);
  4105. if (vo.getPurchaseDeptId() != null) {
  4106. Map<String, Object> deptMap = deptService.selectDeptById(vo.getPurchaseDeptId());
  4107. if (deptMap != null) {
  4108. SysDeptResponseVo sysDeptResponseVo = (SysDeptResponseVo) deptMap.get("sysDept");
  4109. if (sysDeptResponseVo != null) {
  4110. vo.setPurchaseDeptName(sysDeptResponseVo.getDeptName());
  4111. }
  4112. }
  4113. }
  4114. String purchaseServicesName = dictDataService.selectDictLabel("purchase_services", vo.getPurchaseServices());
  4115. if (StringUtils.isNotEmpty(purchaseServicesName)) {
  4116. vo.setPurchaseServicesName(purchaseServicesName);
  4117. }
  4118. //项目类型
  4119. for (ProjectTypes value : ProjectTypes.values()) {
  4120. if (vo.getProjectType() != null && vo.getProjectType().equals(value.getCode())) {
  4121. vo.setProjectTypeName(value.getInfo());
  4122. break;
  4123. }
  4124. }
  4125. //是否为超限额计划
  4126. for (IsExcess value : IsExcess.values()) {
  4127. if (vo.getIsExcess() != null && vo.getIsExcess().equals(value.getCode())) {
  4128. vo.setIsExcessName(value.getInfo());
  4129. break;
  4130. }
  4131. }
  4132. //采购方式
  4133. for (PlanPurchaseMode value : PlanPurchaseMode.values()) {
  4134. if (vo.getPurchaseMode() != null && vo.getPurchaseMode().equals(value.getCode())) {
  4135. vo.setPurchaseModeName(value.getInfo());
  4136. break;
  4137. }
  4138. }
  4139. //项目属性为value拼接
  4140. if (!ObjectUtils.isEmpty(vo.getProjectAttr())) {
  4141. if (vo.getProjectAttr().length() > 1) {
  4142. StringBuilder builder = new StringBuilder();
  4143. String[] split = vo.getProjectAttr().split(",");
  4144. for (String s : split) {
  4145. for (Map.Entry<String, String> entry : projectAttributes.entrySet()) {
  4146. if (s.equals(entry.getValue())) {
  4147. if (!vo.getProjectAttr().endsWith(s)) {
  4148. builder.append(entry.getKey() + ",");
  4149. } else {
  4150. builder.append(entry.getKey());
  4151. }
  4152. break;
  4153. }
  4154. }
  4155. }
  4156. vo.setProjectAttrName(builder.toString());
  4157. } else {
  4158. for (Map.Entry<String, String> entry : projectAttributes.entrySet()) {
  4159. if (vo.getProjectAttr().equals(entry.getValue())) {
  4160. vo.setProjectAttrName(entry.getKey());
  4161. break;
  4162. }
  4163. }
  4164. }
  4165. }
  4166. //预警状态
  4167. for (WarnStatus value : WarnStatus.values()) {
  4168. if (vo.getWarnStatus() != null && vo.getWarnStatus().equals(value.getCode())) {
  4169. vo.setWarnStatusName(value.getInfo());
  4170. break;
  4171. }
  4172. }
  4173. //项目状态
  4174. for (PmProjectStatus value : PmProjectStatus.values()) {
  4175. if (vo.getProjectStatus() != null && vo.getProjectStatus().equals(value.getCode())) {
  4176. vo.setProjectStatusName(value.getInfo());
  4177. break;
  4178. }
  4179. }
  4180. try {
  4181. vo.setTipsMessage(pmDemandGetTips(vo, alertTimeMap));
  4182. if (vo.getTipsMessage().contains("超过")) {
  4183. vo.setIsExceedProject("1");
  4184. if (ObjectUtils.isEmpty(pmDemand1.getDelayReason())) {
  4185. //没有原因就可以填写滞后原因
  4186. vo.setIsWriteExceed("1");
  4187. }
  4188. }
  4189. } catch (ParseException e) {
  4190. e.printStackTrace();
  4191. }
  4192. pmDemandResponseVoList.add(vo);
  4193. }
  4194. return pmDemandResponseVoList;
  4195. }
  4196. /**
  4197. * 根据年度计划提报时间的阈值进行提示
  4198. *
  4199. * @return
  4200. */
  4201. public String pmDemandGetTips(PmDemandResVo vo, HashMap<String, String> alertTimeMap) throws ParseException {
  4202. //首页待办事项--计划完成采购时间提醒
  4203. if (ObjectUtils.isEmpty(vo.getRealDemandCommitTime())) {
  4204. int alertDay2 = Integer.parseInt(alertTimeMap.get("计划提报时间"));
  4205. Integer alertTime = 1000 * 60 * 60 * 24 * alertDay2;
  4206. double surplusTwo = vo.getPlanDemandSubTime().getTime() - System.currentTimeMillis();
  4207. //少于设定阈值便提醒
  4208. if (surplusTwo < alertTime) {
  4209. //剩余天数(向上取整)
  4210. int i = (int) Math.ceil(surplusTwo / 1000 / 60 / 60 / 24);
  4211. if (i > 0) {
  4212. return "距离计划提报时间不足" + i + "天";
  4213. } else {
  4214. return "已超过计划提报时间" + Math.abs(i) + "天";
  4215. }
  4216. }
  4217. }
  4218. //首页待办事项--计划完成采购时间提醒
  4219. if (ObjectUtils.isEmpty(vo.getRealPurchaseFinishTime())) {
  4220. int alertDay2 = Integer.parseInt(alertTimeMap.get("计划完成时间"));
  4221. Integer alertTime = 1000 * 60 * 60 * 24 * alertDay2;
  4222. double surplusTwo = vo.getPlanPurchaseFinishTime().getTime() - System.currentTimeMillis();
  4223. //少于设定阈值便提醒
  4224. if (surplusTwo < alertTime) {
  4225. //剩余天数(向上取整)
  4226. int i = (int) Math.ceil(surplusTwo / 1000 / 60 / 60 / 24);
  4227. if (i > 0) {
  4228. return "距离计划完成采购时间不足" + i + "天";
  4229. } else {
  4230. return "已超过计划完成采购时间" + Math.abs(i) + "天";
  4231. }
  4232. }
  4233. }
  4234. //首页待办事项--计划交付时间提醒
  4235. if (ObjectUtils.isEmpty(vo.getRealDeliverTime())) {
  4236. Date deliverTime = vo.getPlanDeliverTime();
  4237. int alertDay = Integer.parseInt(alertTimeMap.get("计划交付(实施)时间"));
  4238. Integer remindTine = 1000 * 60 * 60 * 24 * alertDay;
  4239. double surplus = deliverTime.getTime() - System.currentTimeMillis();
  4240. if (surplus < remindTine) {
  4241. //剩余天数(向上取整)
  4242. int i = (int) Math.ceil(surplus / 1000 / 60 / 60 / 24);
  4243. if (i > 0) {
  4244. return "距离计划交付时间不足" + i + "天";
  4245. } else {
  4246. return "已超过计划交付时间" + Math.abs(i) + "天";
  4247. }
  4248. }
  4249. }
  4250. return "";
  4251. }
  4252. /**
  4253. * 计算百分比:使用java.text.DecimalFormat实现
  4254. *
  4255. * @param x
  4256. * @param y
  4257. * @return
  4258. */
  4259. public static String getPercent(int x, int y) {
  4260. double d1 = x * 1.0;
  4261. double d2 = y * 1.0;
  4262. // 设置保留几位小数, “.”后面几个零就保留几位小数,这里设置保留2位小数
  4263. DecimalFormat decimalFormat = new DecimalFormat("##.00%");
  4264. return decimalFormat.format(d1 / d2);
  4265. }
  4266. //查询本单位及本级一下全部
  4267. public List<Long> isQueryAll(Integer queryAll) {
  4268. List<Long> deptList = new ArrayList<>();
  4269. Long deptId = SecurityUtils.getDeptId();
  4270. //查询全部
  4271. if (queryAll.equals(-1)) {
  4272. //获取到子孙级部门id
  4273. if (deptService.hasChildByDeptId(SecurityUtils.getDeptId())) {
  4274. List<Long> children = deptService.getDeptChildren(deptId);
  4275. System.err.println(children.size());
  4276. deptList.addAll(children);
  4277. }
  4278. deptList.add(deptId);
  4279. }
  4280. return deptList;
  4281. }
  4282. //查询本单位还是本单位及子孙级----要查询子单位的超额数据
  4283. @Override
  4284. public List<Long> isQueryZD(Integer queryZd) {
  4285. //指定部门--以及子单位的超额数据
  4286. List<Long> demandId = new ArrayList<>();
  4287. //先获取本部门的项目
  4288. LambdaQueryWrapper<PmDemand> ld = new LambdaQueryWrapper<>();
  4289. ld.eq(PmDemand::getPurchaseDeptId, queryZd);
  4290. //本部门的项目
  4291. List<PmDemand> deList = pmDemandMapper.selectList(ld);
  4292. for (PmDemand demand : deList) {
  4293. demandId.add(demand.getDemandId());
  4294. }
  4295. if (deptService.hasChildByDeptId(Long.valueOf(queryZd))) {
  4296. //获取子级部门d
  4297. List<Long> childByDeptId = deptService.getChildIdByDeptId(Long.valueOf(queryZd));
  4298. //取出所有可以进行统计的项目id
  4299. for (Long cid : childByDeptId) {
  4300. LambdaQueryWrapper<PmAuditDeptRef> ll = new LambdaQueryWrapper<>();
  4301. ll.eq(PmAuditDeptRef::getDeptId, cid);
  4302. ll.eq(PmAuditDeptRef::getRefType, "2");
  4303. //子部门参加审核的项目
  4304. List<PmAuditDeptRef> refList = pmAuditDeptRefService.list(ll);
  4305. //同一个数据有上级参与说明是超额
  4306. for (PmAuditDeptRef ref : refList) {
  4307. //获取上级并查询是否参与审核
  4308. SysDept dept = deptService.selectByCid(ref.getDeptId());
  4309. //是否参与审核
  4310. LambdaQueryWrapper<PmAuditDeptRef> pp = new LambdaQueryWrapper<>();
  4311. ll.eq(PmAuditDeptRef::getDeptId, dept.getDeptId());
  4312. ll.eq(PmAuditDeptRef::getRefId, ref.getRefId());
  4313. //取出父级部门参加审核的项目(超额项目)
  4314. List<PmAuditDeptRef> refListP = pmAuditDeptRefService.list(pp);
  4315. if (!ObjectUtils.isEmpty(refListP)) {
  4316. demandId.add(ref.getRefId());
  4317. }
  4318. }
  4319. }
  4320. }
  4321. return demandId;
  4322. }
  4323. }