PmDemandServiceImpl.java 225 KB

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