PmDemandServiceImpl.java 219 KB

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