PmDemandServiceImpl.java 244 KB

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