PmDemandServiceImpl.java 257 KB

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