PmDemandServiceImpl.java 163 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167
  1. package com.ozs.pm.service.impl;
  2. import java.lang.invoke.LambdaConversionException;
  3. import java.math.BigDecimal;
  4. import java.text.DecimalFormat;
  5. import java.text.ParseException;
  6. import java.util.*;
  7. import java.util.stream.Collectors;
  8. import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
  9. import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
  10. import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
  11. import com.baomidou.mybatisplus.core.metadata.IPage;
  12. import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
  13. import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
  14. import com.ozs.base.domain.*;
  15. import com.ozs.base.domain.vo.BaseExpertVo;
  16. import com.ozs.base.mapper.BaseExpertMapper;
  17. import com.ozs.base.service.*;
  18. import com.ozs.common.core.domain.AjaxResult;
  19. import com.ozs.common.core.domain.entity.*;
  20. import com.ozs.common.enums.*;
  21. import com.ozs.common.utils.DateUtils;
  22. import com.ozs.common.utils.RandomUtil;
  23. import com.ozs.common.utils.SecurityUtils;
  24. import com.ozs.common.utils.StringUtils;
  25. import com.ozs.common.utils.bean.BeanUtils;
  26. import com.ozs.home.domain.vo.HomeToDoQueryResVo;
  27. import com.ozs.plan.doman.vo.responseVo.PlanQuarterResponseVo;
  28. import com.ozs.plan.service.PlanYearsService;
  29. import com.ozs.pm.doman.*;
  30. import com.ozs.pm.doman.vo.requestVo.*;
  31. import com.ozs.pm.doman.vo.responseVo.*;
  32. import com.ozs.pm.mapper.PmDemandMapper;
  33. import com.ozs.pm.service.*;
  34. import com.ozs.system.domain.SysFileInfo;
  35. import com.ozs.system.domain.SysFileRef;
  36. import com.ozs.system.domain.vo.SysRegionVO;
  37. import com.ozs.system.domain.vo.responseVo.SysDeptResponseVo;
  38. import com.ozs.system.mapper.SysDeptMapper;
  39. import com.ozs.system.mapper.SysRoleMapper;
  40. import com.ozs.system.service.*;
  41. import lombok.extern.slf4j.Slf4j;
  42. import org.springframework.beans.factory.annotation.Autowired;
  43. import org.springframework.stereotype.Service;
  44. import org.springframework.transaction.annotation.Transactional;
  45. import org.springframework.util.CollectionUtils;
  46. import org.springframework.util.ObjectUtils;
  47. /**
  48. * 采购需求Service业务层处理
  49. *
  50. * @author ruoyi
  51. * @date 2023-01-16
  52. */
  53. @Service
  54. @Slf4j
  55. public class PmDemandServiceImpl extends ServiceImpl<PmDemandMapper, PmDemand> implements IPmDemandService {
  56. @Autowired
  57. private PmDemandMapper pmDemandMapper;
  58. @Autowired
  59. private ISysDeptService deptService;
  60. @Autowired
  61. private ISysDictDataService dictDataService;
  62. @Autowired
  63. private SysFileService fileService;
  64. @Autowired
  65. private SysFileRefService sysFileRefService;
  66. @Autowired
  67. private IPmFlowChartService iPmFlowChartService;
  68. @Autowired
  69. private PmReleaseAnnouncementService pmReleaseAnnouncementService;
  70. @Autowired
  71. private BaseExpertService baseExpertService;
  72. @Autowired
  73. private PmDemandExpertRefService pmDemandExpertRefService;
  74. @Autowired
  75. private PmBidOpeningService pmBidOpeningService;
  76. @Autowired
  77. private PmBookBuildingService pmBookBuildingService;
  78. @Autowired
  79. private PmBidWinningService pmBidWinningService;
  80. @Autowired
  81. private ISysDictTypeService iSysDictTypeService;
  82. @Autowired
  83. private PmBidFailureService pmBidFailureService;
  84. @Autowired
  85. private PmBidWinningOpeningRefService pmBidWinningOpeningRefService;
  86. @Autowired
  87. private PmContractInfoService pmContractInfoService;
  88. @Autowired
  89. private BaseAgencyService baseAgencyService;
  90. @Autowired
  91. private PmProjectConstructionService pmProjectConstructionService;
  92. @Autowired
  93. private BaseNoticeTypeService baseNoticeTypeService;
  94. @Autowired
  95. private BaseNoticeService baseNoticeService;
  96. @Autowired
  97. private PlanYearsService planYearsService;
  98. @Autowired
  99. private ISysRegionService iSysRegionService;
  100. @Autowired
  101. private SysRoleMapper sysRoleMapper;
  102. @Autowired
  103. private ISysUserService userService;
  104. @Autowired
  105. private SysDeptMapper deptMapper;
  106. @Autowired
  107. private BaseExpertMapper baseExpertMapper;
  108. @Autowired
  109. private SysProcurementStandardService sysProcurementStandardService;
  110. @Autowired
  111. private PmAuditDeptRefService pmAuditDeptRefService;
  112. /**
  113. * 查询采购需求
  114. *
  115. * @param demandId 采购需求主键
  116. * @return 采购需求
  117. */
  118. @Override
  119. public PmDemandResVo selectPmDemandByDemandId(Long demandId, String detailType) {
  120. PmDemand pmDemand = this.getById(demandId);
  121. if (pmDemand != null) {
  122. PmDemandResVo vo = new PmDemandResVo();
  123. vo.setProjectName(pmDemand.getProjectName());
  124. vo.setDemandId(demandId);
  125. if ("1".equals(detailType)) { //项目计划
  126. BeanUtils.copyProperties(pmDemand, vo);
  127. SysDeptResponseVo sysDeptResponseVo = (SysDeptResponseVo) deptService.selectDeptById(vo.getPurchaseDeptId()).get("sysDept");
  128. if (sysDeptResponseVo != null) {
  129. vo.setPurchaseDeptName(sysDeptResponseVo.getDeptName());
  130. }
  131. String purchaseServicesName = dictDataService.selectDictLabel("purchase_services", vo.getPurchaseServices());
  132. if (StringUtils.isNotEmpty(purchaseServicesName)) {
  133. vo.setPurchaseServicesName(purchaseServicesName);
  134. }
  135. //采购需求附件
  136. List<SysFileInfo> demandFileInfos = getSysFileInfoList(vo.getDemandId(), SysFileRefEnum.PM_DEMAND.getType());
  137. if (!ObjectUtils.isEmpty(demandFileInfos)) {
  138. List<SysFileInfo> sysFileInfoList = getSysFileInfoList(vo.getDemandId(), SysFileRefEnum.PM_DEMAND_EXAMINE.getType());
  139. if (!ObjectUtils.isEmpty(sysFileInfoList)) {
  140. demandFileInfos.addAll(sysFileInfoList);
  141. }
  142. vo.setDemandFileInfos(demandFileInfos);
  143. }
  144. //项目类型
  145. for (ProjectTypes value : ProjectTypes.values()) {
  146. if (vo.getProjectType() != null && vo.getProjectType().equals(value.getCode())) {
  147. vo.setProjectTypeName(value.getInfo());
  148. break;
  149. }
  150. }
  151. //是否为超限额计划
  152. for (IsExcess value : IsExcess.values()) {
  153. if (vo.getIsExcess() != null && vo.getIsExcess().equals(value.getCode())) {
  154. vo.setIsExcessName(value.getInfo());
  155. break;
  156. }
  157. }
  158. //采购方式
  159. for (PlanPurchaseMode value : PlanPurchaseMode.values()) {
  160. if (vo.getPurchaseMode() != null && vo.getPurchaseMode().equals(value.getCode())) {
  161. vo.setPurchaseModeName(value.getInfo());
  162. break;
  163. }
  164. }
  165. //项目属性
  166. for (ProjectAttribute value : ProjectAttribute.values()) {
  167. if (vo.getProjectAttr() != null && vo.getProjectAttr().equals(value.getCode())) {
  168. vo.setProjectAttrName(value.getInfo());
  169. break;
  170. }
  171. }
  172. //预警状态
  173. for (WarnStatus value : WarnStatus.values()) {
  174. if (vo.getWarnStatus() != null && vo.getWarnStatus().equals(value.getCode())) {
  175. vo.setWarnStatusName(value.getInfo());
  176. break;
  177. }
  178. }
  179. //项目状态
  180. for (PmProjectStatus value : PmProjectStatus.values()) {
  181. if (vo.getProjectStatus() != null && vo.getProjectStatus().equals(value.getCode())) {
  182. vo.setProjectStatusName(value.getInfo());
  183. break;
  184. }
  185. }
  186. } else if ("2".equals(detailType)) { //需求建档
  187. //采购需求审核文件
  188. List<SysFileInfo> auditFileInfos = getSysFileInfoList(vo.getDemandId(), SysFileRefEnum.PM_DEMAND_EXAMINE.getType());
  189. if (!ObjectUtils.isEmpty(auditFileInfos)) {
  190. vo.setAuditFileInfos(auditFileInfos);
  191. }
  192. LambdaQueryWrapper<PmBookBuilding> lambdaQueryWrapper = new LambdaQueryWrapper<>();
  193. lambdaQueryWrapper.eq(PmBookBuilding::getDemandId, demandId);
  194. PmBookBuilding pmBookBuilding = pmBookBuildingService.getOne(lambdaQueryWrapper);
  195. if (pmBookBuilding != null) {
  196. PmBookBuildingResVo responseVo = new PmBookBuildingResVo();
  197. BeanUtils.copyProperties(pmBookBuilding, responseVo);
  198. List<SysFileInfo> fileInfos = getSysFileInfoList(pmBookBuilding.getId(), SysFileRefEnum.PM_BOOK_BUILDING.getType());
  199. if (!ObjectUtils.isEmpty(fileInfos)) {
  200. if (!ObjectUtils.isEmpty(auditFileInfos)) {
  201. fileInfos.addAll(auditFileInfos);
  202. }
  203. responseVo.setFileInfos(fileInfos);
  204. }
  205. vo.setPmBookBuildingResVo(responseVo);
  206. }
  207. } else if ("3".equals(detailType)) { //任务下达
  208. //任务下达文件
  209. List<SysFileInfo> taskReleaseFileInfos = getSysFileInfoList(vo.getDemandId(), SysFileRefEnum.PM_TAST_RELEASE.getType());
  210. if (!ObjectUtils.isEmpty(taskReleaseFileInfos)) {
  211. vo.setTaskReleaseFileInfos(taskReleaseFileInfos);
  212. }
  213. } else if ("4".equals(detailType)) { //中标信息
  214. PmPurchaseExecutionResVo pmPurchaseExecutionResVo = new PmPurchaseExecutionResVo();
  215. List<SysFileInfo> fileInfosAll = new ArrayList<>();
  216. //代理商信息
  217. BaseAgency baseAgency = this.baseAgencyService.getById(pmDemand.getAgencyId());
  218. pmPurchaseExecutionResVo.setBaseAgency(baseAgency);
  219. //发布公告列表
  220. LambdaQueryWrapper<PmReleaseAnnouncement> lambdaQueryWrapper = new LambdaQueryWrapper<>();
  221. lambdaQueryWrapper.eq(PmReleaseAnnouncement::getDemandId, demandId);
  222. List<PmReleaseAnnouncement> pmReleaseAnnouncementList = this.pmReleaseAnnouncementService.list(lambdaQueryWrapper);
  223. if (!ObjectUtils.isEmpty(pmReleaseAnnouncementList)) {
  224. List<PmReleaseAnnouncementResVo> pmReleaseAnnouncementResVoList = new ArrayList<>();
  225. for (PmReleaseAnnouncement pmReleaseAnnouncement : pmReleaseAnnouncementList) {
  226. PmReleaseAnnouncementResVo pmReleaseAnnouncementResVo = new PmReleaseAnnouncementResVo();
  227. BeanUtils.copyProperties(pmReleaseAnnouncement, pmReleaseAnnouncementResVo);
  228. List<SysFileInfo> fileInfos = getSysFileInfoList(pmReleaseAnnouncement.getId(), SysFileRefEnum.PM_ANNOUNCEMENT_FILE.getType());
  229. if (!ObjectUtils.isEmpty(fileInfos)) {
  230. fileInfosAll.addAll(fileInfos);
  231. }
  232. pmReleaseAnnouncementResVoList.add(pmReleaseAnnouncementResVo);
  233. }
  234. pmPurchaseExecutionResVo.setPmReleaseAnnouncementResVoList(pmReleaseAnnouncementResVoList);
  235. }
  236. //专家信息列表
  237. List<PmBaseExpertResVo> pmBaseExpertResVoList = this.pmDemandExpertRefService.getPmBaseExpertResVoList(demandId);
  238. pmPurchaseExecutionResVo.setPmBaseExpertResVoList(pmBaseExpertResVoList);
  239. //开标信息列表
  240. List<PmBidOpeningResVo> pmBidOpeningResVoList = this.pmBidOpeningService.getPmBidOpeningResVoList(demandId);
  241. pmPurchaseExecutionResVo.setPmBidOpeningResVoList(pmBidOpeningResVoList);
  242. //中标信息列表
  243. LambdaQueryWrapper<PmBidWinning> lambdaQueryWrapper1 = new LambdaQueryWrapper<>();
  244. lambdaQueryWrapper1.eq(PmBidWinning::getDemandId, demandId)
  245. .eq(PmBidWinning::getStatus, BidWinningStatus.NORMAL.getCode());
  246. PmBidWinning pmBidWinning = this.pmBidWinningService.getOne(lambdaQueryWrapper1);
  247. if (!ObjectUtils.isEmpty(pmBidWinning)) {
  248. LambdaQueryWrapper<PmBidWinningOpeningRef> lambdaQueryWrapper2 = new LambdaQueryWrapper<>();
  249. lambdaQueryWrapper2.eq(PmBidWinningOpeningRef::getWinningId, pmBidWinning.getId())
  250. .eq(PmBidWinningOpeningRef::getStatus, BidWinningStatus.NORMAL.getCode());
  251. List<PmBidWinningOpeningRef> pmBidWinningOpeningRefList = this.pmBidWinningOpeningRefService.list(lambdaQueryWrapper2);
  252. if (!ObjectUtils.isEmpty(pmBidWinningOpeningRefList)) {
  253. List<PmBidWinningResVo> pmBidWinningResVoList = new ArrayList<>();
  254. for (PmBidWinningOpeningRef pmBidWinningOpeningRef : pmBidWinningOpeningRefList) {
  255. PmBidOpening pmBidOpening = this.pmBidOpeningService.getById(pmBidWinningOpeningRef.getOpeningId());
  256. if (pmBidOpening != null) {
  257. PmBidWinningResVo pmBidWinningResVo = new PmBidWinningResVo();
  258. BeanUtils.copyProperties(pmBidWinning, pmBidWinningResVo);
  259. pmBidWinningResVo.setBidWinningName(pmBidOpening.getBidderName());
  260. List<SysFileInfo> fileInfos = getSysFileInfoList(pmBidWinning.getId(), SysFileRefEnum.PM_BID_WINNING_FILE.getType());
  261. if (!ObjectUtils.isEmpty(fileInfos)) {
  262. fileInfosAll.addAll(fileInfos);
  263. }
  264. pmBidWinningResVoList.add(pmBidWinningResVo);
  265. }
  266. }
  267. pmPurchaseExecutionResVo.setPmBidWinningResVoList(pmBidWinningResVoList);
  268. }
  269. }
  270. pmPurchaseExecutionResVo.setCallQuestion(pmDemand.getCallQuestion());
  271. //质疑情况
  272. List<SysFileInfo> callRequestFileInfos = getSysFileInfoList(vo.getDemandId(), SysFileRefEnum.PM_BID_CALL_QEUSTION_FILE.getType());
  273. if (!ObjectUtils.isEmpty(callRequestFileInfos)) {
  274. pmPurchaseExecutionResVo.setCallRequestFileInfos(callRequestFileInfos);
  275. }
  276. //流标情况
  277. LambdaQueryWrapper<PmBidFailure> lambdaQueryWrapper2 = new LambdaQueryWrapper<>();
  278. lambdaQueryWrapper2.eq(PmBidFailure::getDemandId, demandId).orderByDesc(PmBidFailure::getBidFailureTime);
  279. List<PmBidFailure> pmBidFailureList = this.pmBidFailureService.list(lambdaQueryWrapper2);
  280. if (!ObjectUtils.isEmpty(pmBidFailureList)) {
  281. List<PmBidFailureResVo> pmBidFailureResVoList = new ArrayList<>();
  282. for (PmBidFailure pmBidFailure : pmBidFailureList) {
  283. PmBidFailureResVo pmBidFailureResVo = new PmBidFailureResVo();
  284. BeanUtils.copyProperties(pmBidFailure, pmBidFailureResVo);
  285. List<SysFileInfo> fileInfos = getSysFileInfoList(pmBidFailure.getId(), SysFileRefEnum.PM_BID_FAILURE_FILE.getType());
  286. if (!ObjectUtils.isEmpty(fileInfos)) {
  287. fileInfosAll.addAll(fileInfos);
  288. }
  289. pmBidFailureResVoList.add(pmBidFailureResVo);
  290. }
  291. pmPurchaseExecutionResVo.setPmBidFailureResVoList(pmBidFailureResVoList);
  292. }
  293. //中标通知书
  294. List<SysFileInfo> pmBidWinningNotificationFileInfos = getSysFileInfoList(vo.getDemandId(), SysFileRefEnum.PM_BID_WINNING_NOTIFICATION.getType());
  295. if (!ObjectUtils.isEmpty(pmBidWinningNotificationFileInfos)) {
  296. fileInfosAll.addAll(pmBidWinningNotificationFileInfos);
  297. }
  298. pmPurchaseExecutionResVo.setFileInfos(fileInfosAll);
  299. vo.setPmPurchaseExecutionResVo(pmPurchaseExecutionResVo);
  300. } else if ("5".equals(detailType)) { //合同信息
  301. LambdaQueryWrapper<PmContractInfo> lambdaQueryWrapper = new LambdaQueryWrapper<>();
  302. lambdaQueryWrapper.eq(PmContractInfo::getDemandId, demandId);
  303. PmContractInfo pmContractInfo = pmContractInfoService.getOne(lambdaQueryWrapper);
  304. if (pmContractInfo != null) {
  305. PmContractInfoResVo pmContractInfoResVo = new PmContractInfoResVo();
  306. BeanUtils.copyProperties(pmContractInfo, pmContractInfoResVo);
  307. //合同信息文件
  308. List<SysFileInfo> fileInfos = getSysFileInfoList(pmContractInfo.getId(), SysFileRefEnum.PM_CONTRACT_INFO.getType());
  309. if (!ObjectUtils.isEmpty(fileInfos)) {
  310. pmContractInfoResVo.setFileInfos(fileInfos);
  311. }
  312. vo.setPmContractInfoResVo(pmContractInfoResVo);
  313. }
  314. } else if ("6".equals(detailType)) { //建设情况
  315. LambdaQueryWrapper<PmProjectConstruction> lambdaQueryWrapper = new LambdaQueryWrapper<>();
  316. lambdaQueryWrapper.eq(PmProjectConstruction::getDemandId, demandId);
  317. PmProjectConstruction pmProjectConstruction = pmProjectConstructionService.getOne(lambdaQueryWrapper);
  318. if (pmProjectConstruction != null) {
  319. PmProjectConstructionResVo pmProjectConstructionResVo = new PmProjectConstructionResVo();
  320. BeanUtils.copyProperties(pmProjectConstruction, pmProjectConstructionResVo);
  321. //建设情况文件
  322. List<SysFileInfo> fileInfos = getSysFileInfoList(pmProjectConstruction.getId(), SysFileRefEnum.PM_PROJECT_CONSTRUCTION.getType());
  323. if (!ObjectUtils.isEmpty(fileInfos)) {
  324. pmProjectConstructionResVo.setFileInfos(fileInfos);
  325. }
  326. vo.setPmProjectConstructionResVo(pmProjectConstructionResVo);
  327. }
  328. }
  329. return vo;
  330. } else {
  331. return null;
  332. }
  333. }
  334. /**
  335. * 查询采购需求列表
  336. *
  337. * @param pmDemandReqVo
  338. * @return 采购需求
  339. */
  340. @Override
  341. public IPage<PmDemandResVo> selectPmDemandList(PmDemandReqVo pmDemandReqVo, int reqType) {
  342. LambdaQueryWrapper<PmDemand> lw = new LambdaQueryWrapper<>();
  343. // 4 (合同信息管理)、 0(需求单位管理) 、 5(项目建设管理) 需求单位
  344. // 1(需求需求审核) 、2 (任务下达管理) 采购管理部门
  345. // 3(采购执行管理) 采购办
  346. List<PmAuditDeptRef> list = new ArrayList<>();
  347. LambdaQueryWrapper<PmAuditDeptRef> l = new LambdaQueryWrapper<>();
  348. l.eq(PmAuditDeptRef::getDeptId, SecurityUtils.getDeptId());
  349. l.eq(PmAuditDeptRef::getRefType, "2");
  350. list = pmAuditDeptRefService.list(l);
  351. if (!pmDemandReqVo.getIsAdmin()) {
  352. if (Arrays.asList(1, 2, 3).contains(reqType)) {
  353. if (!ObjectUtils.isEmpty(list) && !SecurityUtils.getUserId().equals(Integer.parseInt("1"))) {
  354. lw.in(PmDemand::getDemandId, list.stream().map(PmAuditDeptRef::getRefId).collect(Collectors.toList()));
  355. }
  356. } else {
  357. lw.eq(PmDemand::getPurchaseDeptId, SecurityUtils.getDeptId());
  358. }
  359. }
  360. if (!StringUtils.isBlank(pmDemandReqVo.getProjectName())) {
  361. lw.like(PmDemand::getProjectName, "%" + pmDemandReqVo.getProjectName() + "%");
  362. }
  363. if (!StringUtils.isBlank(pmDemandReqVo.getPurchaseServices())) {
  364. lw.eq(PmDemand::getPurchaseServices, pmDemandReqVo.getPurchaseServices());
  365. }
  366. if (!ObjectUtils.isEmpty(pmDemandReqVo.getProjectStatus())) {
  367. lw.eq(PmDemand::getProjectStatus, pmDemandReqVo.getProjectStatus());
  368. }
  369. if (!ObjectUtils.isEmpty(pmDemandReqVo.getWarnStatus())) {
  370. lw.eq(PmDemand::getWarnStatus, pmDemandReqVo.getWarnStatus());
  371. }
  372. if (!ObjectUtils.isEmpty(pmDemandReqVo.getIsExcess())) {
  373. lw.eq(PmDemand::getIsExcess, pmDemandReqVo.getIsExcess());
  374. }
  375. if (!StringUtils.isBlank(pmDemandReqVo.getBeginDate())) {
  376. lw.apply("(plan_demand_sub_time >= '" + pmDemandReqVo.getBeginDate() + "' or plan_purchase_finish_time >= '" + pmDemandReqVo.getBeginDate() + "' or plan_deliver_time >= '" + pmDemandReqVo.getBeginDate() + "' )");
  377. }
  378. if (!StringUtils.isBlank(pmDemandReqVo.getEndDate())) {
  379. lw.apply("(plan_demand_sub_time <= '" + pmDemandReqVo.getEndDate() + "' or plan_purchase_finish_time <= '" + pmDemandReqVo.getEndDate() + "' or plan_deliver_time <= '" + pmDemandReqVo.getEndDate() + "' )");
  380. }
  381. if (reqType == 1) { //需求审核单位列表
  382. lw.apply("(project_status = 6 or project_status = 8 )");
  383. } else if (reqType == 2) { //任务下达列表
  384. lw.apply("(project_status = 8 or project_status = 9 )");
  385. } else if (reqType == 3) { //采购执行列表
  386. lw.apply("(project_status = 9 or project_status = 10 or project_status = 11 or project_status = 12 or project_status = 13 or project_status = 14 or project_status = 15)");
  387. } else if (reqType == 4) { //合同信息列表
  388. lw.apply("(project_status = 15 or project_status = 16 )");
  389. } else if (reqType == 5) { //项目建设列表
  390. lw.apply("(project_status = 16 or project_status = 17 )");
  391. }
  392. lw.last(" order by project_status, plan_demand_sub_time");
  393. IPage<PmDemand> pageRes = this.page(new Page<>(pmDemandReqVo.getPageNum(), pmDemandReqVo.getPageSize()), lw);
  394. IPage<PmDemandResVo> results = new Page<>(pageRes.getCurrent(), pageRes.getSize(), pageRes.getTotal());
  395. if (pageRes.getRecords() != null && pageRes.getRecords().size() > 0) {
  396. List<PmDemandResVo> pmDemandResVos = demandChangeTo(pageRes.getRecords());
  397. for (PmDemandResVo vo : pmDemandResVos) {
  398. if (Arrays.asList(1, 2, 3).contains(reqType)) {
  399. // 根据项目id 和 部门id 和 参数类型 获取 部门级别
  400. List<PmAuditDeptRef> collect = list.stream()
  401. .filter(o -> o.getRefId().equals(vo.getDemandId()))
  402. .collect(Collectors.toList());
  403. if (!ObjectUtils.isEmpty(collect)) {
  404. String deptLevel = collect.get(0).getDeptLevel();
  405. // 根据项目id 和 参数类型 获取 所有审核数据
  406. LambdaQueryWrapper<PmAuditDeptRef> ll = new LambdaQueryWrapper<>();
  407. ll.eq(PmAuditDeptRef::getRefId, vo.getDemandId());
  408. ll.eq(PmAuditDeptRef::getRefType, "2");
  409. List<PmAuditDeptRef> listl = pmAuditDeptRefService.list(l);
  410. // 判断当前用户是否有审核权限
  411. boolean flay = true;
  412. List<PmAuditDeptRef> collect1 = listl.stream()
  413. .filter(pmAuditDeptRef -> pmAuditDeptRef.getRefId().equals(vo.getDemandId()))
  414. .collect(Collectors.toList());
  415. for (PmAuditDeptRef pmAuditDeptRef : collect1) {
  416. if (pmAuditDeptRef.getDeptLevel().compareTo(deptLevel) > 0
  417. && pmAuditDeptRef.getStatus().equals(Integer.parseInt("0"))) {
  418. flay = false;
  419. } else if (pmAuditDeptRef.getDeptLevel().compareTo(deptLevel) == 0
  420. && pmAuditDeptRef.getStatus().equals(Integer.parseInt("1"))) {
  421. flay = false;
  422. }
  423. }
  424. vo.setFlay(flay);
  425. }
  426. }
  427. }
  428. results.setRecords(pmDemandResVos);
  429. }
  430. return results;
  431. }
  432. /**
  433. * 需求建档
  434. *
  435. * @param vo 采购需求
  436. * @return 结果
  437. */
  438. @Override
  439. @Transactional(rollbackFor = Exception.class)
  440. public boolean bookBuilding(PmBookBuildingReqVo vo) throws Exception {
  441. PmDemand pmDemand = this.getById(vo.getDemandId());
  442. LambdaQueryWrapper<PmBookBuilding> lambdaQueryWrapper = new LambdaQueryWrapper<>();
  443. lambdaQueryWrapper.eq(PmBookBuilding::getDemandId, vo.getDemandId());
  444. PmBookBuilding pmBookBuilding = pmBookBuildingService.getOne(lambdaQueryWrapper);
  445. if (pmBookBuilding != null) {
  446. vo.setId(pmBookBuilding.getId());
  447. BeanUtils.copyProperties(vo, pmBookBuilding);
  448. pmBookBuilding.setUpdateBy(vo.getUpdateBy());
  449. pmBookBuilding.setUpdateTime(new Date());
  450. } else {
  451. pmBookBuilding = new PmBookBuilding();
  452. BeanUtils.copyProperties(vo, pmBookBuilding);
  453. pmBookBuilding.setCreateBy(vo.getUpdateBy());
  454. pmBookBuilding.setCreateTime(new Date());
  455. pmBookBuilding.setUpdateBy(vo.getUpdateBy());
  456. pmBookBuilding.setUpdateTime(pmBookBuilding.getCreateTime());
  457. }
  458. if (pmBookBuildingService.saveOrUpdate(pmBookBuilding)) {
  459. List<SysFileRef> sysFileRefs = vo.getSysFileRefs();
  460. uploadFile(pmBookBuilding.getId(), SysFileRefEnum.PM_BOOK_BUILDING.getType(), sysFileRefs, vo.getUpdateBy());
  461. pmDemand.setProjectStatus(PmProjectStatus.DEMAND_WAIT_COMMIT.getCode());
  462. pmDemand.setUpdateBy(vo.getUpdateBy());
  463. pmDemand.setUpdateTime(DateUtils.getNowDate());
  464. return this.updateById(pmDemand);
  465. } else {
  466. return false;
  467. }
  468. }
  469. private List<SysFileInfo> getSysFileInfoList(Long redId, Integer type) {
  470. HashMap<String, Object> map = new HashMap<>();
  471. map.put("red_id", redId);
  472. map.put("type", type);
  473. List<SysFileRef> fileRefs = sysFileRefService.listByMap(map);
  474. if (!ObjectUtils.isEmpty(fileRefs)) {
  475. List<SysFileInfo> fileInfos = new ArrayList<>();
  476. for (SysFileRef ref : fileRefs) {
  477. SysFileInfo fileInfo = fileService.getById(ref.getFileId());
  478. fileInfos.add(fileInfo);
  479. }
  480. return fileInfos;
  481. } else {
  482. return null;
  483. }
  484. }
  485. /**
  486. * 查看流程图
  487. *
  488. * @param demandId 采购需求主键
  489. * @return 采购需求
  490. */
  491. @Override
  492. public Object viewFlowChart(Long demandId) {
  493. PmDemand pmDemand = this.getById(demandId);
  494. String projectStatus = String.valueOf(pmDemand.getProjectStatus());
  495. String moduleName = null;
  496. if (PmProjectStatus.DEMAND_WAIT_FILL.getCode().equals(projectStatus) || PmProjectStatus.DEMAND_AUDIT_RETURN.getCode().equals(projectStatus)) {
  497. moduleName = "需求填制";
  498. } else if (PmProjectStatus.DEMAND_WAIT_COMMIT.getCode().equals(projectStatus)) {
  499. moduleName = "需求提交";
  500. } else if (PmProjectStatus.DEMAND_WAIT_AUDIT.getCode().equals(projectStatus)) {
  501. moduleName = "需求审核";
  502. } else if (PmProjectStatus.TASK_WAIT_RELEASE.getCode().equals(projectStatus)) {
  503. moduleName = "任务下达";
  504. } else if (PmProjectStatus.WAIT_SELECT_AGENT.getCode().equals(projectStatus)) {
  505. moduleName = "选取代理";
  506. } else if (PmProjectStatus.WAIT_UPLOAD_BID_FILE.getCode().equals(projectStatus)) {
  507. moduleName = "上传招标文件";
  508. } else if (PmProjectStatus.WAIT_ANNOUNCEMENT.getCode().equals(projectStatus)) {
  509. moduleName = "发布公告";
  510. } else if (PmProjectStatus.WAIT_OPEN_BID.getCode().equals(projectStatus)) {
  511. moduleName = "填写专家信息,填写开标信息";
  512. } else if (PmProjectStatus.WAIT_BID_ANNOUNCEMENT.getCode().equals(projectStatus)) {
  513. moduleName = "填写中标信息";
  514. } else if (PmProjectStatus.BIDDING_PUBLICITY.getCode().equals(projectStatus)) {
  515. moduleName = "质疑处理,上传中标通知书";
  516. } else if (PmProjectStatus.CONTRACT_WAIT_FILL.getCode().equals(projectStatus)) {
  517. moduleName = "合同填制";
  518. } else if (PmProjectStatus.UNDER_CONSTRUCTION.getCode().equals(projectStatus)) {
  519. moduleName = "建设文档填制";
  520. } else if (PmProjectStatus.COMPLETION_CONSTRUCTION.getCode().equals(projectStatus)) {
  521. moduleName = "项目归档";
  522. }
  523. return moduleName;
  524. }
  525. @Override
  526. public PmFlowChartResVo getModuleInfo(Long demandId, String moduleName) {
  527. LambdaQueryWrapper<PmFlowChart> lambdaQueryWrapper = new LambdaQueryWrapper<>();
  528. lambdaQueryWrapper.eq(PmFlowChart::getModuleName, moduleName);
  529. PmFlowChart pmFlowChart = iPmFlowChartService.getOne(lambdaQueryWrapper);
  530. if (pmFlowChart == null) {
  531. return null;
  532. }
  533. PmFlowChartResVo vo = new PmFlowChartResVo();
  534. BeanUtils.copyProperties(pmFlowChart, vo);
  535. if ("需求填制".equals(moduleName)) {
  536. List<SysFileInfo> fileInfos = getSysFileInfoList(demandId, SysFileRefEnum.PM_DEMAND.getType());
  537. if (!ObjectUtils.isEmpty(fileInfos)) {
  538. vo.setFileInfos(fileInfos);
  539. }
  540. } else if ("需求提交".equals(moduleName)) {
  541. LambdaQueryWrapper<PmBookBuilding> pmBookBuildingLambdaQueryWrapper = new LambdaQueryWrapper<>();
  542. pmBookBuildingLambdaQueryWrapper.eq(PmBookBuilding::getDemandId, demandId);
  543. PmBookBuilding pmBookBuilding = pmBookBuildingService.getOne(pmBookBuildingLambdaQueryWrapper);
  544. if (pmBookBuilding != null) {
  545. List<SysFileInfo> fileInfos = getSysFileInfoList(pmBookBuilding.getId(), SysFileRefEnum.PM_BOOK_BUILDING.getType());
  546. if (!ObjectUtils.isEmpty(fileInfos)) {
  547. vo.setFileInfos(fileInfos);
  548. }
  549. }
  550. } else if ("需求审核".equals(moduleName)) {
  551. List<SysFileInfo> fileInfos = getSysFileInfoList(demandId, SysFileRefEnum.PM_DEMAND_EXAMINE.getType());
  552. if (!ObjectUtils.isEmpty(fileInfos)) {
  553. vo.setFileInfos(fileInfos);
  554. }
  555. } else if ("任务下达".equals(moduleName)) {
  556. List<SysFileInfo> fileInfos = getSysFileInfoList(demandId, SysFileRefEnum.PM_TAST_RELEASE.getType());
  557. if (!ObjectUtils.isEmpty(fileInfos)) {
  558. vo.setFileInfos(fileInfos);
  559. }
  560. } else if ("选取代理".equals(moduleName)) {
  561. //do nothing
  562. } else if ("上传招标文件".equals(moduleName)) {
  563. List<SysFileInfo> fileInfos = getSysFileInfoList(demandId, SysFileRefEnum.PM_BID_FILE.getType());
  564. if (!ObjectUtils.isEmpty(fileInfos)) {
  565. vo.setFileInfos(fileInfos);
  566. }
  567. } else if ("发布公告".equals(moduleName)) {
  568. LambdaQueryWrapper<PmReleaseAnnouncement> pmReleaseAnnouncementLambdaQueryWrapper = new LambdaQueryWrapper<>();
  569. pmReleaseAnnouncementLambdaQueryWrapper.eq(PmReleaseAnnouncement::getDemandId, demandId);
  570. List<PmReleaseAnnouncement> pmReleaseAnnouncementList = pmReleaseAnnouncementService.list(pmReleaseAnnouncementLambdaQueryWrapper);
  571. if (!ObjectUtils.isEmpty(pmReleaseAnnouncementList)) {
  572. List<SysFileInfo> listAll = new ArrayList<>();
  573. for (PmReleaseAnnouncement pmReleaseAnnouncement : pmReleaseAnnouncementList) {
  574. List<SysFileInfo> fileInfos = getSysFileInfoList(pmReleaseAnnouncement.getId(), SysFileRefEnum.PM_ANNOUNCEMENT_FILE.getType());
  575. if (!ObjectUtils.isEmpty(fileInfos)) {
  576. listAll.addAll(fileInfos);
  577. }
  578. }
  579. if (!ObjectUtils.isEmpty(listAll)) {
  580. vo.setFileInfos(listAll);
  581. }
  582. }
  583. } else if ("填写专家信息".equals(moduleName)) {
  584. //do nothing
  585. } else if ("填写开标信息".equals(moduleName)) {
  586. //do nothing
  587. } else if ("填写中标信息".equals(moduleName)) {
  588. List<SysFileInfo> listAll = new ArrayList<>();
  589. LambdaQueryWrapper<PmBidWinning> pmBidWinningLambdaQueryWrapper = new LambdaQueryWrapper<>();
  590. pmBidWinningLambdaQueryWrapper.eq(PmBidWinning::getDemandId, demandId);
  591. List<PmBidWinning> pmBidWinningList = pmBidWinningService.list(pmBidWinningLambdaQueryWrapper);
  592. if (!ObjectUtils.isEmpty(pmBidWinningList)) {
  593. for (PmBidWinning pmBidWinning : pmBidWinningList) {
  594. List<SysFileInfo> fileInfos = getSysFileInfoList(pmBidWinning.getId(), SysFileRefEnum.PM_BID_WINNING_FILE.getType());
  595. if (!ObjectUtils.isEmpty(fileInfos)) {
  596. listAll.addAll(fileInfos);
  597. }
  598. }
  599. }
  600. LambdaQueryWrapper<PmBidFailure> pmBidFailureLambdaQueryWrapper = new LambdaQueryWrapper<>();
  601. pmBidFailureLambdaQueryWrapper.eq(PmBidFailure::getDemandId, demandId);
  602. List<PmBidFailure> pmBidFailureList = pmBidFailureService.list(pmBidFailureLambdaQueryWrapper);
  603. if (!ObjectUtils.isEmpty(pmBidFailureService)) {
  604. for (PmBidFailure pmBidFailure : pmBidFailureList) {
  605. List<SysFileInfo> fileInfos = getSysFileInfoList(pmBidFailure.getId(), SysFileRefEnum.PM_BID_FAILURE_FILE.getType());
  606. if (!ObjectUtils.isEmpty(fileInfos)) {
  607. listAll.addAll(fileInfos);
  608. }
  609. }
  610. }
  611. if (!ObjectUtils.isEmpty(listAll)) {
  612. vo.setFileInfos(listAll);
  613. }
  614. } else if ("质疑处理".equals(moduleName)) {
  615. List<SysFileInfo> fileInfos = getSysFileInfoList(demandId, SysFileRefEnum.PM_BID_CALL_QEUSTION_FILE.getType());
  616. if (!ObjectUtils.isEmpty(fileInfos)) {
  617. vo.setFileInfos(fileInfos);
  618. }
  619. } else if ("上传中标通知书".equals(moduleName)) {
  620. List<SysFileInfo> fileInfos = getSysFileInfoList(demandId, SysFileRefEnum.PM_BID_WINNING_NOTIFICATION.getType());
  621. if (!ObjectUtils.isEmpty(fileInfos)) {
  622. vo.setFileInfos(fileInfos);
  623. }
  624. } else if ("合同填制".equals(moduleName)) {
  625. LambdaQueryWrapper<PmContractInfo> pmContractInfoLambdaQueryWrapper = new LambdaQueryWrapper<>();
  626. pmContractInfoLambdaQueryWrapper.eq(PmContractInfo::getDemandId, demandId);
  627. PmContractInfo pmContractInfo = pmContractInfoService.getOne(pmContractInfoLambdaQueryWrapper);
  628. if (pmContractInfo != null) {
  629. List<SysFileInfo> fileInfos = getSysFileInfoList(pmContractInfo.getId(), SysFileRefEnum.PM_CONTRACT_INFO.getType());
  630. if (!ObjectUtils.isEmpty(fileInfos)) {
  631. vo.setFileInfos(fileInfos);
  632. }
  633. }
  634. } else if ("建设文档填制".equals(moduleName)) {
  635. LambdaQueryWrapper<PmProjectConstruction> pmProjectConstructionLambdaQueryWrapper = new LambdaQueryWrapper<>();
  636. pmProjectConstructionLambdaQueryWrapper.eq(PmProjectConstruction::getDemandId, demandId);
  637. PmProjectConstruction pmProjectConstruction = pmProjectConstructionService.getOne(pmProjectConstructionLambdaQueryWrapper);
  638. if (pmProjectConstruction != null) {
  639. List<SysFileInfo> fileInfos = getSysFileInfoList(pmProjectConstruction.getId(), SysFileRefEnum.PM_PROJECT_CONSTRUCTION.getType());
  640. if (!ObjectUtils.isEmpty(fileInfos)) {
  641. vo.setFileInfos(fileInfos);
  642. }
  643. }
  644. } else if ("项目归档".equals(moduleName)) {
  645. //do nothing
  646. }
  647. return vo;
  648. }
  649. /**
  650. * 提交采购需求
  651. *
  652. * @param pmDemandReqVo
  653. * @return 结果
  654. */
  655. @Override
  656. @Transactional(rollbackFor = Exception.class)
  657. public boolean commit(PmDemandReqVo pmDemandReqVo) {
  658. PmDemand pmDemand = this.getById(pmDemandReqVo.getDemandId());
  659. SysUser sysUser = userService.selectUserById(SecurityUtils.getUserId());
  660. Long deptId = sysUser.getDeptId();
  661. SysDept sysDept = deptMapper.selectDeptById(deptId);
  662. pmAuditDeptRefService.insertPmAuditDeptRefs(pmDemandReqVo.getDemandId()
  663. , "2"
  664. , deptId
  665. , BigDecimal.valueOf(pmDemand.getEvaluation())
  666. , sysUser.getUserId()
  667. , pmDemand.getProjectType());
  668. PmDemand pmDemandUpdate = new PmDemand();
  669. pmDemandUpdate.setDemandId(pmDemand.getDemandId());
  670. pmDemandUpdate.setProjectStatus(PmProjectStatus.DEMAND_WAIT_AUDIT.getCode());
  671. pmDemandUpdate.setRealDemandCommitTime(DateUtils.getNowDate());
  672. pmDemandUpdate.setUpdateBy(pmDemandReqVo.getUpdateBy());
  673. pmDemandUpdate.setUpdateTime(DateUtils.getNowDate());
  674. return this.updateById(pmDemandUpdate);
  675. }
  676. /**
  677. * 审核采购需求通过
  678. *
  679. * @param pmDemandReqVo
  680. * @return 结果
  681. */
  682. @Override
  683. @Transactional(rollbackFor = Exception.class)
  684. public boolean reviewTo(PmDemandReqVo pmDemandReqVo) {
  685. PmDemand pmDemand = this.getById(pmDemandReqVo.getDemandId());
  686. PmDemand pmDemandUpdate = new PmDemand();
  687. pmDemandUpdate.setDemandId(pmDemand.getDemandId());
  688. SysUser sysUser = userService.selectUserById(SecurityUtils.getUserId());
  689. Long deptId = sysUser.getDeptId();
  690. SysDept sysDept = deptMapper.selectDeptById(deptId);
  691. String[] ancestors = sysDept.getAncestors().split(",");
  692. String deptLevel = null;
  693. if (ancestors.length == 2) { //C级
  694. deptLevel = "C";
  695. } else if (ancestors.length == 3) { //B级
  696. deptLevel = "B";
  697. } else if (ancestors.length == 4) { //A级
  698. deptLevel = "A";
  699. }
  700. LambdaQueryWrapper<PmAuditDeptRef> lw = new LambdaQueryWrapper();
  701. lw.eq(PmAuditDeptRef::getRefId, pmDemandReqVo.getDemandId());
  702. lw.eq(PmAuditDeptRef::getRefType, "2");
  703. List<PmAuditDeptRef> list = pmAuditDeptRefService.list(lw);
  704. boolean flay = true;
  705. if (!ObjectUtils.isEmpty(list)) {
  706. for (PmAuditDeptRef pmAuditDeptRef : list) {
  707. // 判断 deptLevel 是否还有更高的 且是 待审核的数据
  708. if (pmAuditDeptRef.getDeptLevel().compareTo(deptLevel) > 0
  709. && pmAuditDeptRef.getStatus().equals(Integer.parseInt("0"))) {
  710. flay = false;
  711. }
  712. // 更新当前 deptLevel 级别的审核状态
  713. if (pmAuditDeptRef.getDeptLevel().compareTo(deptLevel) == 0) {
  714. pmAuditDeptRef.setStatus(1);
  715. pmAuditDeptRefService.updateById(pmAuditDeptRef);
  716. }
  717. }
  718. }
  719. if (flay) {
  720. pmDemandUpdate.setProjectStatus(PmProjectStatus.TASK_WAIT_RELEASE.getCode());
  721. }
  722. List<SysFileRef> sysFileRefs = pmDemandReqVo.getSysFileRefs();
  723. uploadFile(pmDemandReqVo.getDemandId(), SysFileRefEnum.PM_DEMAND_EXAMINE.getType(), sysFileRefs, pmDemandReqVo.getUpdateBy());
  724. pmDemandUpdate.setUpdateBy(pmDemandReqVo.getUpdateBy());
  725. pmDemandUpdate.setUpdateTime(DateUtils.getNowDate());
  726. pmDemandUpdate.setAuditTime(DateUtils.getNowDate());
  727. return this.updateById(pmDemandUpdate);
  728. }
  729. /**
  730. * 审核采购需求退回
  731. *
  732. * @param pmDemandReqVo
  733. * @return 结果
  734. */
  735. @Override
  736. @Transactional(rollbackFor = Exception.class)
  737. public boolean reviewReturn(PmDemandReqVo pmDemandReqVo) {
  738. UpdateWrapper<PmDemand> updateWrapper = new UpdateWrapper<>();
  739. updateWrapper.lambda().eq(PmDemand::getDemandId, pmDemandReqVo.getDemandId())
  740. .set(PmDemand::getProjectStatus, PmProjectStatus.DEMAND_AUDIT_RETURN.getCode())
  741. .set(PmDemand::getAdjustReason, pmDemandReqVo.getRefuseReason())
  742. .set(PmDemand::getRealDemandCommitTime, null)
  743. .set(PmDemand::getUpdateBy, pmDemandReqVo.getUpdateBy())
  744. .set(PmDemand::getUpdateTime, DateUtils.getNowDate())
  745. .set(PmDemand::getAuditTime, DateUtils.getNowDate());
  746. LambdaQueryWrapper<PmAuditDeptRef> lw = new LambdaQueryWrapper();
  747. lw.eq(PmAuditDeptRef::getRefId, pmDemandReqVo.getDemandId());
  748. lw.eq(PmAuditDeptRef::getRefType, "2");
  749. pmAuditDeptRefService.remove(lw);
  750. return this.update(updateWrapper);
  751. }
  752. /**
  753. * 下达任务
  754. *
  755. * @param pmDemandReqVo
  756. * @return 结果
  757. */
  758. @Override
  759. @Transactional(rollbackFor = Exception.class)
  760. public boolean releaseTask(PmDemandReqVo pmDemandReqVo) {
  761. PmDemand pmDemand = new PmDemand();
  762. pmDemand.setDemandId(pmDemandReqVo.getDemandId());
  763. pmDemand.setProjectStatus(PmProjectStatus.WAIT_SELECT_AGENT.getCode());
  764. List<SysFileRef> sysFileRefs = pmDemandReqVo.getSysFileRefs();
  765. uploadFile(pmDemandReqVo.getDemandId(), SysFileRefEnum.PM_TAST_RELEASE.getType(), sysFileRefs, pmDemandReqVo.getUpdateBy());
  766. pmDemand.setUpdateBy(pmDemandReqVo.getUpdateBy());
  767. pmDemand.setUpdateTime(DateUtils.getNowDate());
  768. pmDemand.setAuditTime(DateUtils.getNowDate());
  769. return this.updateById(pmDemand);
  770. }
  771. @Override
  772. @Transactional(rollbackFor = Exception.class)
  773. public boolean uploadFile(Long redId, Integer fileType, List<SysFileRef> sysFileRefs, String upateBy) {
  774. if (!ObjectUtils.isEmpty(sysFileRefs)) {
  775. //删除老的
  776. // QueryWrapper<SysFileRef> queryWrapper = new QueryWrapper<>();
  777. // queryWrapper.lambda().eq(SysFileRef::getRedId, redId)
  778. // .eq(SysFileRef::getType, fileType);
  779. // List<SysFileRef> sysFileRefList = sysFileRefService.list(queryWrapper);
  780. // if (!CollectionUtils.isEmpty(sysFileRefList)) {
  781. // sysFileRefService.remove(queryWrapper);
  782. // }
  783. //添加新的
  784. for (SysFileRef ref : sysFileRefs) {
  785. if (ref.getFileId() == null) {
  786. continue;
  787. }
  788. ref.setRedId(redId);
  789. ref.setType(fileType);
  790. ref.setCreated(upateBy);
  791. ref.setCreateTime(new Date());
  792. ref.setUpdated(upateBy);
  793. ref.setUpdateTime(ref.getCreateTime());
  794. sysFileRefService.save(ref);
  795. }
  796. return true;
  797. } else {
  798. return false;
  799. }
  800. }
  801. @Override
  802. @Transactional(rollbackFor = Exception.class)
  803. public boolean insertPmReleaseAnnouncement(PmReleaseAnnouncementReqVo pmReleaseAnnouncementReqVo) throws Exception {
  804. PmDemand pmDemand = this.getById(pmReleaseAnnouncementReqVo.getDemandId());
  805. if (ObjectUtils.isEmpty(pmDemand)) {
  806. throw new Exception("参数错误");
  807. }
  808. if (ObjectUtils.isEmpty(pmReleaseAnnouncementReqVo.getSysFileRefs())) {
  809. throw new Exception("上传附件不能为空");
  810. }
  811. PmReleaseAnnouncement pmReleaseAnnouncement = new PmReleaseAnnouncement();
  812. BeanUtils.copyProperties(pmReleaseAnnouncementReqVo, pmReleaseAnnouncement);
  813. if (pmReleaseAnnouncementService.saveOrUpdate(pmReleaseAnnouncement)) {
  814. uploadFile(pmReleaseAnnouncement.getId(), SysFileRefEnum.PM_ANNOUNCEMENT_FILE.getType(), pmReleaseAnnouncementReqVo.getSysFileRefs(), pmReleaseAnnouncementReqVo.getUpdateBy());
  815. PmDemand pmDemandUpdate = new PmDemand();
  816. pmDemandUpdate.setDemandId(pmReleaseAnnouncementReqVo.getDemandId());
  817. pmDemandUpdate.setProjectStatus(PmProjectStatus.WAIT_OPEN_BID.getCode());
  818. pmDemandUpdate.setUpdateTime(pmReleaseAnnouncementReqVo.getUpdateTime());
  819. pmDemandUpdate.setUpdateBy(pmReleaseAnnouncementReqVo.getUpdateBy());
  820. if (this.updateById(pmDemandUpdate)) {
  821. //发布公告生成后,会默认将该数据同步到公告管理和首页中
  822. BaseNotice baseNotice = new BaseNotice();
  823. baseNotice.setName(pmDemand.getProjectName());
  824. baseNotice.setTitle(pmDemand.getProjectName() + "招标公告");
  825. LambdaQueryWrapper<BaseNoticeType> lambdaQueryWrapper = new LambdaQueryWrapper<>();
  826. lambdaQueryWrapper.eq(BaseNoticeType::getName, "招标公告");
  827. BaseNoticeType baseNoticeType = baseNoticeTypeService.getOne(lambdaQueryWrapper);
  828. if (baseNoticeType == null) {
  829. throw new Exception("招标公告 公告类型不存在");
  830. }
  831. baseNotice.setDemandId(pmDemand.getDemandId());
  832. baseNotice.setDeptId(pmDemand.getPurchaseDeptId());
  833. baseNotice.setIsExcess(pmDemand.getIsExcess());
  834. baseNotice.setType(baseNoticeType.getId());
  835. baseNotice.setReleaseTime(pmReleaseAnnouncement.getReleaseTime());
  836. baseNotice.setCreated(pmReleaseAnnouncementReqVo.getCreateBy());
  837. baseNotice.setCreateTime(pmReleaseAnnouncementReqVo.getCreateTime());
  838. baseNotice.setUpdated(pmReleaseAnnouncementReqVo.getUpdateBy());
  839. baseNotice.setUpdateTime(pmReleaseAnnouncementReqVo.getUpdateTime());
  840. return this.baseNoticeService.saveOrUpdate(baseNotice);
  841. } else {
  842. return false;
  843. }
  844. } else {
  845. return false;
  846. }
  847. }
  848. @Override
  849. @Transactional(rollbackFor = Exception.class)
  850. public boolean insertExpertBatch(PmBaseExpertFillReqVo pmBaseExpertFillReqVo) throws Exception {
  851. PmDemand pmDemand = this.getById(pmBaseExpertFillReqVo.getDemandId());
  852. if (ObjectUtils.isEmpty(pmDemand)) {
  853. throw new Exception("参数错误");
  854. }
  855. List<BaseExpert> baseExpertList = pmBaseExpertFillReqVo.getBaseExpertList();
  856. if (ObjectUtils.isEmpty(baseExpertList)) {
  857. throw new Exception("参数错误");
  858. }
  859. Date now = new Date();
  860. for (BaseExpert baseExpert : baseExpertList) {
  861. if (NameListType.BLACK.getCode().equals(baseExpert.getStatus())) {
  862. throw new Exception("该专家(身份证号:" + baseExpert.getIdNumber() + ")属于黑名单");
  863. } else {
  864. if (ObjectUtils.isEmpty(baseExpert.getStatus())) {
  865. baseExpert.setStatus(NameListType.WHITE.getCode());
  866. }
  867. }
  868. if (ObjectUtils.isEmpty(baseExpert.getVarietyPurchase()) || !baseExpert.getVarietyPurchase().contains(pmDemand.getProjectType())) {
  869. throw new Exception("该专家(身份证号:" + baseExpert.getIdNumber() + ")所属采购品种和项目类型不匹配");
  870. }
  871. if (ObjectUtils.isEmpty(baseExpert.getCreated())) {
  872. baseExpert.setCreated(pmBaseExpertFillReqVo.getCreateBy());
  873. baseExpert.setCreateTime(now);
  874. }
  875. if (ObjectUtils.isEmpty(baseExpert.getUpdated())) {
  876. baseExpert.setUpdated(pmBaseExpertFillReqVo.getUpdateBy());
  877. baseExpert.setUpdateTime(now);
  878. }
  879. if (baseExpertService.saveOrUpdate(baseExpert)) {
  880. LambdaQueryWrapper<PmDemandExpertRef> pmDemandExpertRefLambdaQueryWrapper = new LambdaQueryWrapper<>();
  881. pmDemandExpertRefLambdaQueryWrapper.eq(PmDemandExpertRef::getDemandId, pmDemand.getDemandId())
  882. .eq(PmDemandExpertRef::getExpertId, baseExpert.getId().longValue())
  883. .eq(PmDemandExpertRef::getAccessTime, pmBaseExpertFillReqVo.getAccessTime());
  884. PmDemandExpertRef pmDemandExpertRef = pmDemandExpertRefService.getOne(pmDemandExpertRefLambdaQueryWrapper);
  885. if (pmDemandExpertRef == null) {
  886. pmDemandExpertRef = new PmDemandExpertRef();
  887. pmDemandExpertRef.setCreateBy(pmBaseExpertFillReqVo.getCreateBy());
  888. pmDemandExpertRef.setCreateTime(now);
  889. }
  890. pmDemandExpertRef.setDemandId(pmDemand.getDemandId());
  891. pmDemandExpertRef.setExpertId(baseExpert.getId().longValue());
  892. pmDemandExpertRef.setAccessTime(DateUtils.parseDate(pmBaseExpertFillReqVo.getAccessTime()));
  893. pmDemandExpertRef.setUpdateBy(pmBaseExpertFillReqVo.getCreateBy());
  894. pmDemandExpertRef.setUpdateTime(pmDemandExpertRef.getCreateTime());
  895. pmDemandExpertRefService.saveOrUpdate(pmDemandExpertRef);
  896. //专家单位
  897. if (StringUtils.isNotNull(baseExpert.getUnitInformation())) {
  898. List<BaseUnitInformation> baseUnitInformationList = baseExpertMapper.selectByUnitInformation(baseExpert.getUnitInformation());
  899. if (baseUnitInformationList.size() <= 0) {
  900. BaseUnitInformation baseUnitInformation = new BaseUnitInformation();
  901. baseUnitInformation.setUnitName(baseExpert.getUnitInformation());
  902. baseUnitInformation.setCreated(baseExpert.getExpertName());
  903. baseUnitInformation.setCreateTime(new Date());
  904. Integer i = baseExpertMapper.insertBaseUnitInformation(baseUnitInformation);
  905. }
  906. }
  907. }
  908. }
  909. PmDemand pmDemandUpdate = new PmDemand();
  910. pmDemandUpdate.setDemandId(pmDemand.getDemandId());
  911. pmDemandUpdate.setHasExpert("1");
  912. this.updateById(pmDemandUpdate);
  913. return true;
  914. }
  915. @Override
  916. @Transactional(rollbackFor = Exception.class)
  917. public boolean extractExpertBatch(PmBaseExpertExtractReqVo pmBaseExpertExtractReqVo) throws Exception {
  918. PmDemand pmDemand = this.getById(pmBaseExpertExtractReqVo.getDemandId());
  919. if (ObjectUtils.isEmpty(pmDemand)) {
  920. throw new Exception("参数错误");
  921. }
  922. String professional = pmBaseExpertExtractReqVo.getProfessional();
  923. if (ObjectUtils.isEmpty(professional)) {
  924. throw new Exception("必须选择专家专业");
  925. }
  926. String localArea = pmBaseExpertExtractReqVo.getLocalArea();
  927. if (ObjectUtils.isEmpty(localArea)) {
  928. throw new Exception("必须选择地域");
  929. }
  930. if (!StringUtils.isNumeric(localArea)) {
  931. throw new Exception("地域必须传数字代码");
  932. }
  933. Integer technicalExpertNumber = pmBaseExpertExtractReqVo.getTechnicalExpertNumber();
  934. if (technicalExpertNumber == null) {
  935. technicalExpertNumber = 0;
  936. }
  937. Integer economicExpertNumber = pmBaseExpertExtractReqVo.getEconomicExpertNumber();
  938. if (economicExpertNumber == null) {
  939. economicExpertNumber = 0;
  940. }
  941. Integer legalAffairsExpertNumber = pmBaseExpertExtractReqVo.getLegalAffairsExpertNumber();
  942. if (legalAffairsExpertNumber == null) {
  943. legalAffairsExpertNumber = 0;
  944. }
  945. Integer spareExpertNumber = pmBaseExpertExtractReqVo.getSpareExpertNumber();
  946. if (spareExpertNumber == null) {
  947. spareExpertNumber = 0;
  948. }
  949. if (technicalExpertNumber + economicExpertNumber + legalAffairsExpertNumber + spareExpertNumber == 0) {
  950. throw new Exception("必须至少填写一个数量");
  951. }
  952. String needAvoidUnit = pmBaseExpertExtractReqVo.getNeedAvoidUnit();
  953. List<String> needAvoidUnitList = null;
  954. if (!ObjectUtils.isEmpty(needAvoidUnit)) {
  955. String[] arr = needAvoidUnit.split(",");
  956. needAvoidUnitList = Arrays.asList(arr);
  957. }
  958. List<String> sysRegionCodeList = new ArrayList<>();
  959. if (!ObjectUtils.isEmpty(localArea)) {
  960. sysRegionCodeList.add(localArea);
  961. //找到该地域code对应的子列表
  962. List<SysRegionVO> sysRegionVOList = iSysRegionService.findChildDivisions(localArea);
  963. if (!ObjectUtils.isEmpty(sysRegionVOList)) {
  964. for (SysRegionVO vo : sysRegionVOList) {
  965. sysRegionCodeList.add(vo.getCode());
  966. }
  967. }
  968. }
  969. //从专家库中查询符合项目类型的以及是白名单的全部列表
  970. LambdaQueryWrapper<BaseExpert> lw = new LambdaQueryWrapper<>();
  971. lw.eq(BaseExpert::getVarietyPurchase, pmDemand.getProjectType())
  972. .eq(BaseExpert::getStatus, NameListType.WHITE.getCode())
  973. .notIn(!ObjectUtils.isEmpty(needAvoidUnitList), BaseExpert::getUnitInformation, needAvoidUnitList)
  974. .in(!ObjectUtils.isEmpty(sysRegionCodeList), BaseExpert::getLocalArea, sysRegionCodeList); //地域
  975. List<BaseExpert> baseExpertList = baseExpertService.list(lw);
  976. if (ObjectUtils.isEmpty(baseExpertList)) {
  977. throw new Exception("没抽取到符合条件的专家");
  978. }
  979. //从列表中挑出来各个类型的子列表
  980. List<BaseExpert> technicalExpertList = new ArrayList<>();
  981. List<BaseExpert> economicExpertList = new ArrayList<>();
  982. List<BaseExpert> legalAffairsExpertList = new ArrayList<>();
  983. List<BaseExpert> spareExpertList = new ArrayList<>();
  984. String[] arr = professional.split(",");
  985. List<String> professionalList = Arrays.asList(arr);
  986. for (BaseExpert baseExpert : baseExpertList) {
  987. //专业类型判断
  988. String majorType = baseExpert.getMajorType();
  989. if (!ObjectUtils.isEmpty(majorType)) {
  990. String[] arr2 = majorType.split(",");
  991. List<String> majorTypeList = Arrays.asList(arr2);
  992. if (!hasIntersection(professionalList, majorTypeList)) { //不符合专业类型
  993. continue;
  994. }
  995. }
  996. //备用专家
  997. if (spareExpertNumber > 0) { //都加进去
  998. spareExpertList.add(baseExpert);
  999. }
  1000. if (technicalExpertNumber > 0) {
  1001. if (baseExpert.getExpertType().contains(ExpertType.TECHNICAL_EXPERT.getCode())) {
  1002. technicalExpertList.add(baseExpert);
  1003. continue;
  1004. }
  1005. }
  1006. if (economicExpertNumber > 0) {
  1007. if (baseExpert.getExpertType().contains(ExpertType.ECONOMIC_EXPERT.getCode())) {
  1008. economicExpertList.add(baseExpert);
  1009. continue;
  1010. }
  1011. }
  1012. if (legalAffairsExpertNumber > 0) {
  1013. if (baseExpert.getExpertType().contains(ExpertType.LEGALAFFAIRS_EXPERT.getCode())) {
  1014. legalAffairsExpertList.add(baseExpert);
  1015. continue;
  1016. }
  1017. }
  1018. }
  1019. //从子列表中随机抽取符合数据量的
  1020. List<BaseExpert> alltExpertList = new ArrayList<>();
  1021. if(technicalExpertNumber > 0 && technicalExpertList.size() < technicalExpertNumber){
  1022. throw new Exception("抽取到符合条件的技术专家数量不够");
  1023. }
  1024. if (!ObjectUtils.isEmpty(technicalExpertList)) {
  1025. alltExpertList.addAll(RandomUtil.getRandomList(technicalExpertList, technicalExpertNumber));
  1026. }
  1027. if(economicExpertNumber > 0 && economicExpertList.size() < economicExpertNumber){
  1028. throw new Exception("抽取到符合条件的经济专家数量不够");
  1029. }
  1030. if (!ObjectUtils.isEmpty(economicExpertList)) {
  1031. alltExpertList.addAll(RandomUtil.getRandomList(economicExpertList, economicExpertNumber));
  1032. }
  1033. if(legalAffairsExpertNumber > 0 && legalAffairsExpertList.size() < legalAffairsExpertNumber){
  1034. throw new Exception("抽取到符合条件的法务专家数量不够");
  1035. }
  1036. if (!ObjectUtils.isEmpty(legalAffairsExpertList)) {
  1037. alltExpertList.addAll(RandomUtil.getRandomList(legalAffairsExpertList, legalAffairsExpertNumber));
  1038. }
  1039. List<BaseExpert> spareExpertListNew = new ArrayList<>();
  1040. if (!ObjectUtils.isEmpty(spareExpertList)) {
  1041. //获取全部IDlist
  1042. List<Integer> allExpertIdList = new ArrayList<>();
  1043. if (!ObjectUtils.isEmpty(alltExpertList)) {
  1044. for (BaseExpert baseExpert : alltExpertList) {
  1045. allExpertIdList.add(baseExpert.getId());
  1046. }
  1047. }
  1048. //遍历全部IDlist
  1049. if (!ObjectUtils.isEmpty(allExpertIdList)) { //去重
  1050. for (BaseExpert baseExpert : spareExpertList) {
  1051. if (!allExpertIdList.contains(baseExpert.getId())) {
  1052. spareExpertListNew.add(baseExpert);
  1053. }
  1054. }
  1055. } else {
  1056. spareExpertListNew = spareExpertList;
  1057. }
  1058. if (!ObjectUtils.isEmpty(spareExpertListNew)) {
  1059. alltExpertList.addAll(RandomUtil.getRandomList(spareExpertListNew, spareExpertNumber));
  1060. }
  1061. }
  1062. if(spareExpertNumber > 0 && spareExpertListNew.size() < spareExpertNumber){
  1063. throw new Exception("抽取到符合条件的备用专家数量不够");
  1064. }
  1065. if (ObjectUtils.isEmpty(alltExpertList)) {
  1066. throw new Exception("没抽取到符合条件的专家");
  1067. } else {
  1068. List<PmDemandExpertRef> pmDemandExpertRefList = new ArrayList<>();
  1069. for (BaseExpert baseExpert : alltExpertList) {
  1070. LambdaQueryWrapper<PmDemandExpertRef> baseExpertLambdaQueryWrapper = new LambdaQueryWrapper<>();
  1071. baseExpertLambdaQueryWrapper.eq(PmDemandExpertRef::getExpertId, baseExpert.getId().longValue())
  1072. .eq(PmDemandExpertRef::getDemandId, pmDemand.getDemandId())
  1073. .eq(PmDemandExpertRef::getAccessTime, pmBaseExpertExtractReqVo.getAccessTime());
  1074. PmDemandExpertRef pmDemandExpertRef = pmDemandExpertRefService.getOne(baseExpertLambdaQueryWrapper);
  1075. if (pmDemandExpertRef == null) {
  1076. pmDemandExpertRef = new PmDemandExpertRef();
  1077. pmDemandExpertRef.setCreateBy(pmBaseExpertExtractReqVo.getCreateBy());
  1078. pmDemandExpertRef.setCreateTime(new Date());
  1079. }
  1080. pmDemandExpertRef.setDemandId(pmDemand.getDemandId());
  1081. pmDemandExpertRef.setExpertId(baseExpert.getId().longValue());
  1082. pmDemandExpertRef.setAccessTime(DateUtils.parseDate(pmBaseExpertExtractReqVo.getAccessTime()));
  1083. pmDemandExpertRef.setUpdateBy(pmBaseExpertExtractReqVo.getCreateBy());
  1084. pmDemandExpertRef.setUpdateTime(pmDemandExpertRef.getCreateTime());
  1085. pmDemandExpertRefList.add(pmDemandExpertRef);
  1086. }
  1087. PmDemand pmDemandUpdate = new PmDemand();
  1088. pmDemandUpdate.setDemandId(pmDemand.getDemandId());
  1089. pmDemandUpdate.setHasExpert("1");
  1090. this.updateById(pmDemandUpdate);
  1091. return pmDemandExpertRefService.saveOrUpdateBatch(pmDemandExpertRefList);
  1092. }
  1093. }
  1094. //二个列表是否有交集
  1095. private boolean hasIntersection(List<String> professionalList, List<String> majorTypeList) {
  1096. for (String professiona : professionalList) {
  1097. for (String majorType : majorTypeList) {
  1098. if (professiona.equals(majorType)) {
  1099. return true;
  1100. }
  1101. }
  1102. }
  1103. return false;
  1104. }
  1105. @Override
  1106. @Transactional(rollbackFor = Exception.class)
  1107. public boolean insertBidOpeningBatch(PmBidOpeningFillReqVo pmBidOpeningFillReqVo) throws Exception {
  1108. PmDemand pmDemand = this.getById(pmBidOpeningFillReqVo.getDemandId());
  1109. if (ObjectUtils.isEmpty(pmDemand)) {
  1110. throw new Exception("参数错误");
  1111. }
  1112. //从发布公告里获取开标时间
  1113. LambdaQueryWrapper<PmReleaseAnnouncement> lw = new LambdaQueryWrapper<>();
  1114. lw.eq(PmReleaseAnnouncement::getDemandId, pmDemand.getDemandId()).orderByDesc(PmReleaseAnnouncement::getReleaseTime)
  1115. .last(" limit 1 ");
  1116. PmReleaseAnnouncement pmReleaseAnnouncement = this.pmReleaseAnnouncementService.getOne(lw);
  1117. if (pmReleaseAnnouncement == null) {
  1118. throw new Exception("发布公告不存在");
  1119. }
  1120. Date tenderOpenTime = pmReleaseAnnouncement.getTenderOpenTime();
  1121. Date now = new Date();
  1122. List<PmBidOpening> pmBidOpeningList = pmBidOpeningFillReqVo.getPmBidOpeningList();
  1123. for (PmBidOpening pmBidOpening : pmBidOpeningList) {
  1124. if (ObjectUtils.isEmpty(pmBidOpening.getBidderName())) {
  1125. throw new Exception("投标人名称不能为空");
  1126. }
  1127. if (ObjectUtils.isEmpty(pmBidOpening.getScore())) {
  1128. throw new Exception("分数不能为空");
  1129. }
  1130. pmBidOpening.setOpenBidTime(tenderOpenTime);
  1131. pmBidOpening.setDemandId(pmBidOpeningFillReqVo.getDemandId());
  1132. pmBidOpening.setCreateBy(pmBidOpeningFillReqVo.getCreateBy());
  1133. pmBidOpening.setCreateTime(now);
  1134. pmBidOpening.setUpdateBy(pmBidOpeningFillReqVo.getUpdateBy());
  1135. pmBidOpening.setUpdateTime(now);
  1136. }
  1137. if (pmBidOpeningService.saveOrUpdateBatch(pmBidOpeningList)) {
  1138. PmDemand pmDemandUpdate = new PmDemand();
  1139. pmDemandUpdate.setDemandId(pmDemand.getDemandId());
  1140. pmDemandUpdate.setProjectStatus(PmProjectStatus.WAIT_BID_ANNOUNCEMENT.getCode());
  1141. pmDemandUpdate.setUpdateTime(now);
  1142. pmDemandUpdate.setUpdateBy(pmBidOpeningFillReqVo.getUpdateBy());
  1143. return this.updateById(pmDemandUpdate);
  1144. } else {
  1145. return false;
  1146. }
  1147. }
  1148. /**
  1149. * 填写中标
  1150. *
  1151. * @param pmBidWinningReqVo
  1152. * @return
  1153. * @throws Exception
  1154. */
  1155. @Override
  1156. @Transactional(rollbackFor = Exception.class)
  1157. public boolean insertPmBidWinning(PmBidWinningReqVo pmBidWinningReqVo) throws Exception {
  1158. List<Long> pmBidOpeningIdList = pmBidWinningReqVo.getPmBidOpeningIdList();
  1159. if (ObjectUtils.isEmpty(pmBidWinningReqVo.getBidWinningAmount())) {
  1160. throw new Exception("中标金额不能为空");
  1161. }
  1162. if (ObjectUtils.isEmpty(pmBidOpeningIdList)) {
  1163. throw new Exception("中标单位信息列表不能为空");
  1164. }
  1165. if (ObjectUtils.isEmpty(pmBidWinningReqVo.getSysFileRefs())) {
  1166. throw new Exception("上传附件不能为空");
  1167. }
  1168. PmBidWinning pmBidWinning = new PmBidWinning();
  1169. BeanUtils.copyProperties(pmBidWinningReqVo, pmBidWinning);
  1170. //修改老的中标信息状态
  1171. if (ObjectUtils.isEmpty(pmBidWinningReqVo.getId())) { //属于新增
  1172. LambdaQueryWrapper<PmBidWinning> pmBidWinningLambdaQueryWrapper = new LambdaQueryWrapper<>();
  1173. pmBidWinningLambdaQueryWrapper.eq(PmBidWinning::getDemandId, pmBidWinningReqVo.getDemandId())
  1174. .eq(PmBidWinning::getStatus, BidWinningStatus.NORMAL.getCode());
  1175. List<PmBidWinning> pmBidWinninglist = pmBidWinningService.list(pmBidWinningLambdaQueryWrapper);
  1176. if (!ObjectUtils.isEmpty(pmBidWinninglist)) {
  1177. for (PmBidWinning item : pmBidWinninglist) {
  1178. UpdateWrapper<PmBidWinning> updateWrapper1 = new UpdateWrapper<>();
  1179. updateWrapper1.lambda().set(PmBidWinning::getStatus, BidWinningStatus.BE_REPLACED.getCode())
  1180. .eq(PmBidWinning::getId, item.getId());
  1181. pmBidWinningService.update(updateWrapper1);
  1182. UpdateWrapper<PmBidWinningOpeningRef> updateWrapper2 = new UpdateWrapper<>();
  1183. updateWrapper2.lambda().set(PmBidWinningOpeningRef::getStatus, BidWinningStatus.BE_REPLACED.getCode())
  1184. .eq(PmBidWinningOpeningRef::getWinningId, item.getId())
  1185. .eq(PmBidWinningOpeningRef::getStatus, BidWinningStatus.NORMAL.getCode());
  1186. pmBidWinningOpeningRefService.update(updateWrapper2);
  1187. }
  1188. }
  1189. }
  1190. if (pmBidWinningService.saveOrUpdate(pmBidWinning)) {
  1191. List<PmBidWinningOpeningRef> pmBidWinningOpeningRefList = new ArrayList<>();
  1192. for (Long pmBidOpeningId : pmBidOpeningIdList) {
  1193. LambdaQueryWrapper<PmBidWinningOpeningRef> pmBidWinningOpeningRefLambdaQueryWrapper = new LambdaQueryWrapper<>();
  1194. pmBidWinningOpeningRefLambdaQueryWrapper.eq(PmBidWinningOpeningRef::getOpeningId, pmBidOpeningId)
  1195. .eq(PmBidWinningOpeningRef::getWinningId, pmBidWinning.getId());
  1196. PmBidWinningOpeningRef pmBidWinningOpeningRef = pmBidWinningOpeningRefService.getOne(pmBidWinningOpeningRefLambdaQueryWrapper);
  1197. if (pmBidWinningOpeningRef == null) {
  1198. pmBidWinningOpeningRef = new PmBidWinningOpeningRef();
  1199. pmBidWinningOpeningRef.setCreateBy(pmBidWinningReqVo.getCreateBy());
  1200. pmBidWinningOpeningRef.setCreateTime(pmBidWinningReqVo.getCreateTime());
  1201. }
  1202. pmBidWinningOpeningRef.setOpeningId(pmBidOpeningId);
  1203. pmBidWinningOpeningRef.setWinningId(pmBidWinning.getId());
  1204. pmBidWinningOpeningRef.setUpdateBy(pmBidWinningReqVo.getUpdateBy());
  1205. pmBidWinningOpeningRef.setUpdateTime(pmBidWinningReqVo.getUpdateTime());
  1206. pmBidWinningOpeningRefList.add(pmBidWinningOpeningRef);
  1207. }
  1208. if (pmBidWinningOpeningRefService.saveOrUpdateBatch(pmBidWinningOpeningRefList)) {
  1209. uploadFile(pmBidWinning.getId(), SysFileRefEnum.PM_BID_WINNING_FILE.getType(), pmBidWinningReqVo.getSysFileRefs(), pmBidWinningReqVo.getUpdateBy());
  1210. //发布公告生成后,会默认将该数据同步到公告管理和首页中
  1211. PmDemand pmDemand = this.getById(pmBidWinningReqVo.getDemandId());
  1212. BaseNotice baseNotice = new BaseNotice();
  1213. baseNotice.setName(pmDemand.getProjectName());
  1214. baseNotice.setTitle(pmDemand.getProjectName() + "中标公告");
  1215. LambdaQueryWrapper<BaseNoticeType> lambdaQueryWrapper = new LambdaQueryWrapper<>();
  1216. lambdaQueryWrapper.eq(BaseNoticeType::getName, "中标公告");
  1217. BaseNoticeType baseNoticeType = baseNoticeTypeService.getOne(lambdaQueryWrapper);
  1218. if (baseNoticeType == null) {
  1219. throw new Exception("中标公告 公告类型不存在");
  1220. }
  1221. baseNotice.setDemandId(pmDemand.getDemandId());
  1222. baseNotice.setDeptId(pmDemand.getPurchaseDeptId());
  1223. baseNotice.setIsExcess(pmDemand.getIsExcess());
  1224. baseNotice.setType(baseNoticeType.getId());
  1225. baseNotice.setReleaseTime(pmBidWinningReqVo.getBidAnnouncementTime());
  1226. baseNotice.setCreated(pmBidWinningReqVo.getCreateBy());
  1227. baseNotice.setCreateTime(pmBidWinningReqVo.getCreateTime());
  1228. baseNotice.setUpdated(pmBidWinningReqVo.getUpdateBy());
  1229. baseNotice.setUpdateTime(pmBidWinningReqVo.getUpdateTime());
  1230. this.baseNoticeService.saveOrUpdate(baseNotice);
  1231. PmDemand pmDemandUpdate = new PmDemand();
  1232. pmDemandUpdate.setDemandId(pmBidWinningReqVo.getDemandId());
  1233. pmDemandUpdate.setProjectStatus(PmProjectStatus.BIDDING_PUBLICITY.getCode());
  1234. pmDemandUpdate.setUpdateTime(pmBidWinningReqVo.getUpdateTime());
  1235. pmDemandUpdate.setUpdateBy(pmBidWinningReqVo.getUpdateBy());
  1236. return this.updateById(pmDemandUpdate);
  1237. } else {
  1238. return false;
  1239. }
  1240. } else {
  1241. return false;
  1242. }
  1243. }
  1244. @Override
  1245. @Transactional(rollbackFor = Exception.class)
  1246. public boolean updatePmBidWinning(PmBidWinningReqVo pmBidWinningReqVo) throws Exception {
  1247. List<Long> pmBidOpeningIdList = pmBidWinningReqVo.getPmBidOpeningIdList();
  1248. if (ObjectUtils.isEmpty(pmBidOpeningIdList)) {
  1249. throw new Exception("中标单位信息列表不能为空");
  1250. }
  1251. if (ObjectUtils.isEmpty(pmBidWinningReqVo.getBidWinningAmount())) {
  1252. throw new Exception("中标金额不能为空");
  1253. }
  1254. if (ObjectUtils.isEmpty(pmBidWinningReqVo.getSysFileRefs())) {
  1255. throw new Exception("上传附件不能为空");
  1256. }
  1257. LambdaQueryWrapper<PmBidWinning> lw = new LambdaQueryWrapper<>();
  1258. lw.eq(PmBidWinning::getDemandId, pmBidWinningReqVo.getDemandId()).eq(PmBidWinning::getStatus, BidWinningStatus.NORMAL.getCode());
  1259. List<PmBidWinning> pmBidWinninglist = pmBidWinningService.list(lw);
  1260. if (ObjectUtils.isEmpty(pmBidWinninglist)) {
  1261. throw new Exception("原中标信息不存在");
  1262. }
  1263. //修改老的状态
  1264. for (PmBidWinning item : pmBidWinninglist) {
  1265. UpdateWrapper<PmBidWinning> updateWrapper1 = new UpdateWrapper<>();
  1266. updateWrapper1.lambda().set(PmBidWinning::getStatus, BidWinningStatus.BE_REPLACED.getCode())
  1267. .eq(PmBidWinning::getId, item.getId());
  1268. pmBidWinningService.update(updateWrapper1);
  1269. UpdateWrapper<PmBidWinningOpeningRef> updateWrapper2 = new UpdateWrapper<>();
  1270. updateWrapper2.lambda().set(PmBidWinningOpeningRef::getStatus, BidWinningStatus.BE_REPLACED.getCode())
  1271. .eq(PmBidWinningOpeningRef::getWinningId, item.getId())
  1272. .eq(PmBidWinningOpeningRef::getStatus, BidWinningStatus.NORMAL.getCode());
  1273. pmBidWinningOpeningRefService.update(updateWrapper2);
  1274. }
  1275. //新增
  1276. PmBidWinning pmBidWinning = new PmBidWinning();
  1277. BeanUtils.copyProperties(pmBidWinninglist.get(0), pmBidWinning);
  1278. pmBidWinning.setId(null);
  1279. pmBidWinning.setBidWinningAmount(pmBidWinningReqVo.getBidWinningAmount());
  1280. pmBidWinning.setStatus(BidWinningStatus.NORMAL.getCode());
  1281. pmBidWinning.setUpdateBy(pmBidWinningReqVo.getUpdateBy());
  1282. pmBidWinning.setUpdateTime(pmBidWinningReqVo.getUpdateTime());
  1283. if (pmBidWinningService.save(pmBidWinning)) {
  1284. List<PmBidWinningOpeningRef> pmBidWinningOpeningRefList = new ArrayList<>();
  1285. for (Long pmBidOpeningId : pmBidOpeningIdList) {
  1286. PmBidWinningOpeningRef pmBidWinningOpeningRef = new PmBidWinningOpeningRef();
  1287. pmBidWinningOpeningRef.setOpeningId(pmBidOpeningId);
  1288. pmBidWinningOpeningRef.setWinningId(pmBidWinning.getId());
  1289. pmBidWinningOpeningRef.setStatus(BidWinningStatus.NORMAL.getCode());
  1290. pmBidWinningOpeningRef.setCreateBy(pmBidWinningReqVo.getCreateBy());
  1291. pmBidWinningOpeningRef.setCreateTime(pmBidWinningReqVo.getCreateTime());
  1292. pmBidWinningOpeningRef.setUpdateBy(pmBidWinningReqVo.getUpdateBy());
  1293. pmBidWinningOpeningRef.setUpdateTime(pmBidWinningReqVo.getUpdateTime());
  1294. pmBidWinningOpeningRefList.add(pmBidWinningOpeningRef);
  1295. }
  1296. LambdaQueryWrapper<SysFileRef> sysFileRefLambdaQueryWrapper = new LambdaQueryWrapper<>();
  1297. sysFileRefLambdaQueryWrapper.eq(SysFileRef::getType, SysFileRefEnum.PM_BID_WINNING_FILE.getType())
  1298. .eq(SysFileRef::getRedId, pmBidWinninglist.get(0));
  1299. List<SysFileRef> sysFileRefs = sysFileRefService.list(sysFileRefLambdaQueryWrapper);
  1300. uploadFile(pmBidWinning.getId(), SysFileRefEnum.PM_BID_WINNING_FILE.getType(), sysFileRefs, pmBidWinningReqVo.getUpdateBy());
  1301. return pmBidWinningOpeningRefService.saveBatch(pmBidWinningOpeningRefList);
  1302. } else {
  1303. return false;
  1304. }
  1305. }
  1306. /**
  1307. * 流标
  1308. *
  1309. * @param pmBidFailureReqVo
  1310. * @return
  1311. * @throws Exception
  1312. */
  1313. @Override
  1314. @Transactional(rollbackFor = Exception.class)
  1315. public boolean insertPmBidFailure(PmBidFailureReqVo pmBidFailureReqVo) throws Exception {
  1316. PmBidFailure pmBidFailure = new PmBidFailure();
  1317. BeanUtils.copyProperties(pmBidFailureReqVo, pmBidFailure);
  1318. if (pmBidFailureService.saveOrUpdate(pmBidFailure)) {
  1319. //把中标信息修改状态
  1320. LambdaQueryWrapper<PmBidWinning> lw = new LambdaQueryWrapper<>();
  1321. lw.eq(PmBidWinning::getDemandId, pmBidFailureReqVo.getDemandId()).eq(PmBidWinning::getStatus, BidWinningStatus.NORMAL.getCode());
  1322. List<PmBidWinning> pmBidWinninglist = pmBidWinningService.list(lw);
  1323. if (!ObjectUtils.isEmpty(pmBidWinninglist)) {
  1324. for (PmBidWinning item : pmBidWinninglist) {
  1325. UpdateWrapper<PmBidWinning> updateWrapper1 = new UpdateWrapper<>();
  1326. updateWrapper1.lambda().set(PmBidWinning::getStatus, BidWinningStatus.BE_BID_FAILURE.getCode())
  1327. .eq(PmBidWinning::getId, item.getId());
  1328. pmBidWinningService.update(updateWrapper1);
  1329. UpdateWrapper<PmBidWinningOpeningRef> updateWrapper2 = new UpdateWrapper<>();
  1330. updateWrapper2.lambda().set(PmBidWinningOpeningRef::getStatus, BidWinningStatus.BE_BID_FAILURE.getCode())
  1331. .eq(PmBidWinningOpeningRef::getWinningId, item.getId())
  1332. .eq(PmBidWinningOpeningRef::getStatus, BidWinningStatus.NORMAL.getCode());
  1333. pmBidWinningOpeningRefService.update(updateWrapper2);
  1334. }
  1335. }
  1336. uploadFile(pmBidFailure.getId(), SysFileRefEnum.PM_BID_FAILURE_FILE.getType(), pmBidFailureReqVo.getSysFileRefs(), pmBidFailureReqVo.getUpdateBy());
  1337. //发布公告生成后,会默认将该数据同步到公告管理和首页中
  1338. PmDemand pmDemand = this.getById(pmBidFailureReqVo.getDemandId());
  1339. BaseNotice baseNotice = new BaseNotice();
  1340. baseNotice.setName(pmDemand.getProjectName());
  1341. baseNotice.setTitle(pmDemand.getProjectName() + "流标公告");
  1342. LambdaQueryWrapper<BaseNoticeType> lambdaQueryWrapper = new LambdaQueryWrapper<>();
  1343. lambdaQueryWrapper.eq(BaseNoticeType::getName, "流标公告");
  1344. BaseNoticeType baseNoticeType = baseNoticeTypeService.getOne(lambdaQueryWrapper);
  1345. if (baseNoticeType == null) {
  1346. throw new Exception("流标公告 公告类型不存在");
  1347. }
  1348. baseNotice.setDemandId(pmDemand.getDemandId());
  1349. baseNotice.setDeptId(pmDemand.getPurchaseDeptId());
  1350. baseNotice.setIsExcess(pmDemand.getIsExcess());
  1351. baseNotice.setType(baseNoticeType.getId());
  1352. baseNotice.setReleaseTime(pmBidFailureReqVo.getBidFailureTime());
  1353. baseNotice.setCreated(pmBidFailureReqVo.getCreateBy());
  1354. baseNotice.setCreateTime(pmBidFailureReqVo.getCreateTime());
  1355. baseNotice.setUpdated(pmBidFailureReqVo.getUpdateBy());
  1356. baseNotice.setUpdateTime(pmBidFailureReqVo.getUpdateTime());
  1357. this.baseNoticeService.saveOrUpdate(baseNotice);
  1358. PmDemand pmDemandUpdate = new PmDemand();
  1359. pmDemandUpdate.setDemandId(pmBidFailureReqVo.getDemandId());
  1360. pmDemandUpdate.setProjectStatus(PmProjectStatus.WAIT_ANNOUNCEMENT.getCode());
  1361. pmDemandUpdate.setHasExpert("0");
  1362. pmDemandUpdate.setUpdateTime(pmBidFailureReqVo.getUpdateTime());
  1363. pmDemandUpdate.setUpdateBy(pmBidFailureReqVo.getUpdateBy());
  1364. return this.updateById(pmDemandUpdate);
  1365. } else {
  1366. return false;
  1367. }
  1368. }
  1369. @Override
  1370. @Transactional(rollbackFor = Exception.class)
  1371. public boolean insertContractInfo(PmContractInfoReqVo pmContractInfoReqVo) throws Exception {
  1372. Long demandId = pmContractInfoReqVo.getDemandId();
  1373. if (ObjectUtils.isEmpty(demandId)) {
  1374. throw new Exception("采购需求ID不能为空");
  1375. }
  1376. PmDemand pmDemand = this.getById(demandId);
  1377. if (ObjectUtils.isEmpty(pmDemand)) {
  1378. throw new Exception("采购需求ID错误");
  1379. }
  1380. List<SysFileRef> sysFileRefs = pmContractInfoReqVo.getSysFileRefs();
  1381. if (ObjectUtils.isEmpty(sysFileRefs)) {
  1382. throw new Exception("上传附件不能为空");
  1383. }
  1384. LambdaQueryWrapper<PmContractInfo> lambdaQueryWrapper = new LambdaQueryWrapper<>();
  1385. lambdaQueryWrapper.eq(PmContractInfo::getDemandId, demandId);
  1386. PmContractInfo pmContractInfo = pmContractInfoService.getOne(lambdaQueryWrapper);
  1387. if (pmContractInfo != null) {
  1388. pmContractInfoReqVo.setId(pmContractInfo.getId());
  1389. BeanUtils.copyProperties(pmContractInfoReqVo, pmContractInfo);
  1390. pmContractInfo.setUpdateTime(pmContractInfoReqVo.getUpdateTime());
  1391. pmContractInfo.setUpdateBy(pmContractInfoReqVo.getUpdateBy());
  1392. } else {
  1393. pmContractInfo = new PmContractInfo();
  1394. BeanUtils.copyProperties(pmContractInfoReqVo, pmContractInfo);
  1395. pmContractInfo.setCreateBy(pmContractInfoReqVo.getCreateBy());
  1396. pmContractInfo.setCreateTime(pmContractInfoReqVo.getCreateTime());
  1397. pmContractInfo.setUpdateTime(pmContractInfoReqVo.getUpdateTime());
  1398. pmContractInfo.setUpdateBy(pmContractInfoReqVo.getUpdateBy());
  1399. }
  1400. if (pmContractInfoService.saveOrUpdate(pmContractInfo)) {
  1401. this.uploadFile(pmContractInfo.getId(), SysFileRefEnum.PM_CONTRACT_INFO.getType(), sysFileRefs, pmContractInfoReqVo.getUpdateBy());
  1402. PmDemand pmDemandUpdate = new PmDemand();
  1403. pmDemandUpdate.setDemandId(demandId);
  1404. pmDemandUpdate.setProjectStatus(PmProjectStatus.UNDER_CONSTRUCTION.getCode());
  1405. pmDemandUpdate.setUpdateTime(pmContractInfoReqVo.getUpdateTime());
  1406. pmDemandUpdate.setUpdateBy(pmContractInfoReqVo.getUpdateBy());
  1407. return this.updateById(pmDemandUpdate);
  1408. } else {
  1409. return false;
  1410. }
  1411. }
  1412. @Override
  1413. @Transactional(rollbackFor = Exception.class)
  1414. public boolean insertProjectConstruction(PmProjectConstructionReqVo pmProjectConstructionReqVo) throws Exception {
  1415. Long demandId = pmProjectConstructionReqVo.getDemandId();
  1416. if (ObjectUtils.isEmpty(demandId)) {
  1417. throw new Exception("采购需求ID不能为空");
  1418. }
  1419. PmDemand pmDemand = this.getById(demandId);
  1420. if (ObjectUtils.isEmpty(pmDemand)) {
  1421. throw new Exception("采购需求ID错误");
  1422. }
  1423. List<SysFileRef> sysFileRefs = pmProjectConstructionReqVo.getSysFileRefs();
  1424. if (ObjectUtils.isEmpty(sysFileRefs)) {
  1425. throw new Exception("上传附件不能为空");
  1426. }
  1427. LambdaQueryWrapper<PmProjectConstruction> lambdaQueryWrapper = new LambdaQueryWrapper<>();
  1428. lambdaQueryWrapper.eq(PmProjectConstruction::getDemandId, demandId);
  1429. PmProjectConstruction pmProjectConstruction = pmProjectConstructionService.getOne(lambdaQueryWrapper);
  1430. if (pmProjectConstruction != null) {
  1431. pmProjectConstructionReqVo.setId(pmProjectConstruction.getId());
  1432. BeanUtils.copyProperties(pmProjectConstructionReqVo, pmProjectConstruction);
  1433. pmProjectConstruction.setUpdateBy(pmProjectConstructionReqVo.getUpdateBy());
  1434. pmProjectConstruction.setUpdateTime(pmProjectConstructionReqVo.getUpdateTime());
  1435. } else {
  1436. pmProjectConstruction = new PmProjectConstruction();
  1437. BeanUtils.copyProperties(pmProjectConstructionReqVo, pmProjectConstruction);
  1438. pmProjectConstruction.setCreateBy(pmProjectConstructionReqVo.getCreateBy());
  1439. pmProjectConstruction.setCreateTime(pmProjectConstructionReqVo.getCreateTime());
  1440. pmProjectConstruction.setUpdateBy(pmProjectConstructionReqVo.getUpdateBy());
  1441. pmProjectConstruction.setUpdateTime(pmProjectConstructionReqVo.getUpdateTime());
  1442. }
  1443. if (pmProjectConstructionService.saveOrUpdate(pmProjectConstruction)) {
  1444. this.uploadFile(pmProjectConstruction.getId(), SysFileRefEnum.PM_PROJECT_CONSTRUCTION.getType(), sysFileRefs, pmProjectConstructionReqVo.getUpdateBy());
  1445. PmDemand pmDemandUpdate = new PmDemand();
  1446. pmDemandUpdate.setDemandId(demandId);
  1447. pmDemandUpdate.setProjectStatus(PmProjectStatus.COMPLETION_CONSTRUCTION.getCode());
  1448. pmDemandUpdate.setRealDeliverTime(pmProjectConstructionReqVo.getUpdateTime());
  1449. pmDemandUpdate.setUpdateTime(pmProjectConstructionReqVo.getUpdateTime());
  1450. pmDemandUpdate.setUpdateBy(pmProjectConstructionReqVo.getUpdateBy());
  1451. return this.updateById(pmDemandUpdate);
  1452. } else {
  1453. return false;
  1454. }
  1455. }
  1456. /**
  1457. * 更新需求预警状态
  1458. *
  1459. * @param demnadId
  1460. * @return
  1461. */
  1462. @Override
  1463. @Transactional(rollbackFor = Exception.class)
  1464. public void updateDemandWarnStatus(Long demnadId) {
  1465. PmDemand pmDemand = this.getById(demnadId);
  1466. List<SysDictData> data = iSysDictTypeService.selectDictDataByType("alert_time_setting");
  1467. int setting1 = Integer.parseInt(data.stream().filter(item -> item.getDictLabel().equals("计划提报时间")).collect(Collectors.toList()).get(0).getDictValue());
  1468. log.info("******** setting1 == " + setting1);
  1469. //需求提报时间:根据数据阈值中设置的提报时间进行判断,进行预警
  1470. int diff1 = DateUtils.differentDaysByMillisecond(pmDemand.getPlanDemandSubTime(), DateUtils.parseDate(DateUtils.getDate()));
  1471. if (ObjectUtils.isEmpty(pmDemand.getRealDemandCommitTime()) && diff1 >= setting1) {
  1472. PmDemand pmDemandUpdate = new PmDemand();
  1473. pmDemandUpdate.setDemandId(demnadId);
  1474. pmDemandUpdate.setWarnStatus(WarnStatus.DEMAND_COMMT_WARNING.getCode());
  1475. this.updateById(pmDemandUpdate);
  1476. }
  1477. }
  1478. /**
  1479. * 通过需求ID列表 查询采购执行列表 sunhh
  1480. *
  1481. * @param demandIdList
  1482. * @return
  1483. */
  1484. @Override
  1485. public List<PmDemand> selectByDemandIdList(List<Integer> demandIdList) {
  1486. return this.baseMapper.selectByDemandIdList(demandIdList);
  1487. }
  1488. /**
  1489. * 专家库--查询抽取专家列表 非必传条件:专家名称,开始结束时间 sunhh
  1490. *
  1491. * @param baseExpertVo
  1492. * @return
  1493. */
  1494. @Override
  1495. public List<PmDemand> selectExtractionExpert(BaseExpertVo baseExpertVo) {
  1496. return this.baseMapper.selectExtractionExpert(baseExpertVo);
  1497. }
  1498. @Override
  1499. public List<PmDemandResVo> demandWaitCommit() {
  1500. return getListByStatus(PmProjectStatus.DEMAND_WAIT_COMMIT.getCode());
  1501. }
  1502. @Override
  1503. public List<PmDemandResVo> contractWaitFilled() {
  1504. return getListByStatus(PmProjectStatus.CONTRACT_WAIT_FILL.getCode());
  1505. }
  1506. @Override
  1507. public List<PmDemandResVo> projectWaitFinish() {
  1508. return getListByStatus(PmProjectStatus.UNDER_CONSTRUCTION.getCode());
  1509. }
  1510. @Override
  1511. public List<PmDemandResVo> demandWaitExamine() {
  1512. return getListByStatus(PmProjectStatus.DEMAND_WAIT_AUDIT.getCode());
  1513. }
  1514. @Override
  1515. public List<PmDemandResVo> taskWaitRelease() {
  1516. return getListByStatus(PmProjectStatus.TASK_WAIT_RELEASE.getCode());
  1517. }
  1518. @Override
  1519. public List<PmDemandResVo> waitSelectAgent() {
  1520. return getListByStatus(PmProjectStatus.WAIT_SELECT_AGENT.getCode());
  1521. }
  1522. @Override
  1523. public List<PmDemandResVo> waitUpBidFile() {
  1524. return getListByStatus(PmProjectStatus.WAIT_UPLOAD_BID_FILE.getCode());
  1525. }
  1526. @Override
  1527. public List<PmDemandResVo> waitAnnouncement() {
  1528. return getListByStatus(PmProjectStatus.WAIT_ANNOUNCEMENT.getCode());
  1529. }
  1530. @Override
  1531. public List<PmDemandResVo> waitOpenBid() {
  1532. return getListByStatus(PmProjectStatus.WAIT_OPEN_BID.getCode());
  1533. }
  1534. @Override
  1535. public List<PmDemandResVo> waitBidAnnouncement() {
  1536. return getListByStatus(PmProjectStatus.WAIT_BID_ANNOUNCEMENT.getCode());
  1537. }
  1538. @Override
  1539. public List<PmDemandResVo> biddingPublicity() {
  1540. return getListByStatus(PmProjectStatus.BIDDING_PUBLICITY.getCode());
  1541. }
  1542. @Override
  1543. public AjaxResult procurementOfficeWillManipulateTotal() {
  1544. List<HomeToDoQueryResVo> homeRes = new ArrayList<>();
  1545. // 待选取代理, 待上传招标文件, 待发布公告, 待开标, 待发布中标公告, 中标公示中
  1546. List<PmDemandResVo> demandRes = new ArrayList<>();
  1547. demandRes.addAll(getListByStatus(PmProjectStatus.WAIT_SELECT_AGENT.getCode()));
  1548. demandRes.addAll(getListByStatus(PmProjectStatus.WAIT_UPLOAD_BID_FILE.getCode()));
  1549. demandRes.addAll(getListByStatus(PmProjectStatus.WAIT_ANNOUNCEMENT.getCode()));
  1550. demandRes.addAll(getListByStatus(PmProjectStatus.WAIT_OPEN_BID.getCode()));
  1551. demandRes.addAll(getListByStatus(PmProjectStatus.WAIT_BID_ANNOUNCEMENT.getCode()));
  1552. demandRes.addAll(getListByStatus(PmProjectStatus.BIDDING_PUBLICITY.getCode()));
  1553. //计划数据--发函催告
  1554. List<PlanQuarterResponseVo> planRes = planYearsService.willSendLetter();
  1555. //转为首页table展示数据
  1556. if (!ObjectUtils.isEmpty(demandRes) && demandRes.size() > 0) {
  1557. for (PmDemandResVo demandResVo : demandRes) {
  1558. HomeToDoQueryResVo home = new HomeToDoQueryResVo();
  1559. home.setEvaluation(BigDecimal.valueOf(demandResVo.getEvaluation()));
  1560. BeanUtils.copyProperties(demandResVo, home);
  1561. homeRes.add(home);
  1562. }
  1563. }
  1564. if (!ObjectUtils.isEmpty(planRes) && planRes.size() > 0) {
  1565. for (PlanQuarterResponseVo planVo : planRes) {
  1566. HomeToDoQueryResVo home = new HomeToDoQueryResVo();
  1567. BeanUtils.copyProperties(planVo, home);
  1568. homeRes.add(home);
  1569. }
  1570. }
  1571. return AjaxResult.success(homeRes);
  1572. }
  1573. /**
  1574. * 统计分析-采购项目信息统计
  1575. *
  1576. * @param pmDemandReqVo
  1577. * @return
  1578. */
  1579. @Override
  1580. public Map<String, Integer> purchaseProjectStatistical(PmDemandReqVo pmDemandReqVo) {
  1581. Map<String, Integer> mapReturn = new HashMap<>();
  1582. // 查询项目总数量
  1583. Map<String, Integer> mapCount = pmDemandMapper.purchaseProjectStatistical(pmDemandReqVo);
  1584. // 查询已完成项目数量,预算(合同)金额数量
  1585. Map<String, Integer> mapYWC = pmDemandMapper.purchaseProjectStatisticalYWC(pmDemandReqVo);
  1586. // 查询新创建项目数量,预算金额数量
  1587. Map<String, Integer> mapXCJ = pmDemandMapper.purchaseProjectStatisticalXCJ(pmDemandReqVo);
  1588. // 查询去年完成项目数量,预算(合同)金额数量
  1589. Map<String, Integer> mapQNWC = pmDemandMapper.purchaseProjectStatisticalQNWC(pmDemandReqVo);
  1590. mapReturn.putAll(mapCount);
  1591. mapReturn.putAll(mapYWC);
  1592. mapReturn.putAll(mapXCJ);
  1593. mapReturn.putAll(mapQNWC);
  1594. return mapReturn;
  1595. }
  1596. @Override
  1597. public List<StatisticalChartsResVo> countByProjectAttr(PmDemandReqVo pmDemandReqVo) {
  1598. List<StatisticalChartsResVo> resVos = pmDemandMapper.countByProjectAttr(pmDemandReqVo);
  1599. for (StatisticalChartsResVo chartsResVo : resVos) {
  1600. for (PmProjectStatus value : PmProjectStatus.values()) {
  1601. if (value.getCode().equals(chartsResVo.getColumnName())) {
  1602. chartsResVo.setColumnName(value.getInfo());
  1603. break;
  1604. }
  1605. }
  1606. }
  1607. return resVos;
  1608. }
  1609. @Override
  1610. public List<StatisticalChartsResVo> countByPurchaseMode(PmDemandReqVo pmDemandReqVo) {
  1611. List<StatisticalChartsResVo> resVos = pmDemandMapper.countByPurchaseMode(pmDemandReqVo);
  1612. for (StatisticalChartsResVo chartsResVo : resVos) {
  1613. for (ProcurementMethodSuggest value : ProcurementMethodSuggest.values()) {
  1614. if (value.getCode().equals(chartsResVo.getColumnName())) {
  1615. chartsResVo.setColumnName(value.getInfo());
  1616. break;
  1617. }
  1618. }
  1619. }
  1620. return resVos;
  1621. }
  1622. @Override
  1623. public List<StatisticalChartsResVo> countByEvaluation(PmDemandReqVo pmDemandReqVo) {
  1624. List<StatisticalChartsResVo> resVos = new ArrayList<>();
  1625. //概算金额包括:100万以下采购任务、100至500万元采购任务、500至1000万元采购任务、1000至5000万元采购任务、5000至1亿元采购任务、1亿元及以上采购任务
  1626. pmDemandReqVo.setEvaluation(100);
  1627. StatisticalChartsResVo resVo = pmDemandMapper.countByEvaluationLt(pmDemandReqVo);
  1628. resVo.setColumnName("100万以下采购任务");
  1629. resVos.add(resVo);
  1630. pmDemandReqVo.setEvaluation(100);
  1631. pmDemandReqVo.setEvaluationEnd(500);
  1632. StatisticalChartsResVo resVo1 = pmDemandMapper.countByEvaluationBet(pmDemandReqVo);
  1633. resVo1.setColumnName("100至500万元采购任务");
  1634. resVos.add(resVo1);
  1635. pmDemandReqVo.setEvaluation(500);
  1636. pmDemandReqVo.setEvaluationEnd(1000);
  1637. StatisticalChartsResVo resVo2 = pmDemandMapper.countByEvaluationBet(pmDemandReqVo);
  1638. resVo2.setColumnName("500至1000万元采购任务");
  1639. resVos.add(resVo2);
  1640. pmDemandReqVo.setEvaluation(1000);
  1641. pmDemandReqVo.setEvaluationEnd(5000);
  1642. StatisticalChartsResVo resVo3 = pmDemandMapper.countByEvaluationBet(pmDemandReqVo);
  1643. resVo3.setColumnName("1000至5000万元采购任务");
  1644. resVos.add(resVo3);
  1645. pmDemandReqVo.setEvaluation(5000);
  1646. pmDemandReqVo.setEvaluationEnd(10000);
  1647. StatisticalChartsResVo resVo4 = pmDemandMapper.countByEvaluationBet(pmDemandReqVo);
  1648. resVo4.setColumnName("5000至1亿元采购任务");
  1649. resVos.add(resVo4);
  1650. pmDemandReqVo.setEvaluation(10000);
  1651. StatisticalChartsResVo resVo5 = pmDemandMapper.countByEvaluationGt(pmDemandReqVo);
  1652. resVo5.setColumnName("1亿元及以上采购任务");
  1653. resVos.add(resVo5);
  1654. return resVos;
  1655. }
  1656. @Override
  1657. public AjaxResult countProjectExceed(PmDemandReqVo pmDemandReqVo) {
  1658. HashMap<String, String> resMap = new HashMap<>();
  1659. //执行滞后采购项目:本年度所有的逾期项目数
  1660. //预算金额:本年度所有逾期项目累加的预算金额
  1661. StatisticalChartsResVo resVo = pmDemandMapper.countProjectExceed(pmDemandReqVo);
  1662. resMap.put("执行滞后采购项目", resVo.getNum());
  1663. resMap.put("预算金额", resVo.getEvaluationTotal());
  1664. //滞后项目数量占比:指本年度逾期项目数量/本年度所有项目数量
  1665. Integer thisYear = pmDemandMapper.countThisYear(pmDemandReqVo);
  1666. resMap.put("滞后项目数量占比", getPercent(Integer.parseInt(resVo.getNum()), thisYear));
  1667. return AjaxResult.success(resMap);
  1668. }
  1669. /**
  1670. * 统计不同时间维度的逾期项目
  1671. *
  1672. * @return
  1673. */
  1674. @Override
  1675. public AjaxResult exceedAnalysis(PmDemandReqVo pmDemandReqVo) {
  1676. HashMap<String, List<StatisticalChartsResVo>> resMap = new HashMap<>();
  1677. List<StatisticalChartsResVo> byYear = pmDemandMapper.countProjectExceedYear(pmDemandReqVo);
  1678. if (pmDemandReqVo.getTimeType().equals("1")) {
  1679. resMap.put("年", byYear);
  1680. } else if (pmDemandReqVo.getTimeType().equals("2")) {
  1681. List<StatisticalChartsResVo> byQuarter = new LinkedList<>();
  1682. for (StatisticalChartsResVo chartsResVo : byYear) {
  1683. pmDemandReqVo.setYear(Integer.parseInt(chartsResVo.getColumnName()));
  1684. for (int i = 1; i <= 4; i++) {
  1685. pmDemandReqVo.setQuarter(i);
  1686. StatisticalChartsResVo quarter = pmDemandMapper.countProjectExceedQuarter(pmDemandReqVo);
  1687. if (ObjectUtils.isEmpty(quarter)) {
  1688. StatisticalChartsResVo vo = new StatisticalChartsResVo("", "0", "0");
  1689. quarter = vo;
  1690. quarter.setColumnName(chartsResVo.getColumnName() + "年第" + i + "季度");
  1691. }
  1692. quarter.setColumnName(chartsResVo.getColumnName() + "年第" + i + "季度");
  1693. byQuarter.add(quarter);
  1694. }
  1695. }
  1696. resMap.put("季度", byQuarter);
  1697. } else if (pmDemandReqVo.getTimeType().equals("3")) {
  1698. List<StatisticalChartsResVo> byMonth = new LinkedList<>();
  1699. for (StatisticalChartsResVo chartsResVo : byYear) {
  1700. pmDemandReqVo.setYear(Integer.parseInt(chartsResVo.getColumnName()));
  1701. for (int i = 1; i <= 12; i++) {
  1702. pmDemandReqVo.setMonth(i);
  1703. StatisticalChartsResVo month = pmDemandMapper.countProjectExceedMonth(pmDemandReqVo);
  1704. if (ObjectUtils.isEmpty(month)) {
  1705. StatisticalChartsResVo vo = new StatisticalChartsResVo("", "0", "0");
  1706. month = vo;
  1707. month.setColumnName(chartsResVo.getColumnName() + "年" + i + "月");
  1708. }
  1709. month.setColumnName(chartsResVo.getColumnName() + "年" + i + "月");
  1710. byMonth.add(month);
  1711. }
  1712. }
  1713. resMap.put("月", byMonth);
  1714. }
  1715. return AjaxResult.success(resMap);
  1716. }
  1717. @Override
  1718. public AjaxResult taskQuantityAnalysis(PmDemandReqVo pmDemandReqVo) {
  1719. HashMap<String, List<StatisticalChartsResVo>> resMap = new HashMap<>();
  1720. //任务数量趋势分析:按照月、季度、年统计“项目属性”字段中“重大规划”属性的项目
  1721. List<StatisticalChartsResVo> byYear = pmDemandMapper.countProjectMajorByYear();
  1722. if (pmDemandReqVo.getTimeType().equals("1")) {
  1723. resMap.put("年", byYear);
  1724. } else if (pmDemandReqVo.getTimeType().equals("2")) {
  1725. List<StatisticalChartsResVo> byQuarter = new LinkedList<>();
  1726. for (StatisticalChartsResVo chartsResVo : byYear) {
  1727. pmDemandReqVo.setYear(Integer.parseInt(chartsResVo.getColumnName()));
  1728. for (int i = 1; i <= 4; i++) {
  1729. pmDemandReqVo.setQuarter(i);
  1730. StatisticalChartsResVo quarter = pmDemandMapper.countProjectMajorByQuarter(pmDemandReqVo);
  1731. quarter.setColumnName(chartsResVo.getColumnName() + "年第" + i + "季度");
  1732. byQuarter.add(quarter);
  1733. }
  1734. }
  1735. resMap.put("季度", byQuarter);
  1736. } else if (pmDemandReqVo.getTimeType().equals("3")) {
  1737. List<StatisticalChartsResVo> byMonth = pmDemandMapper.countProjectMajorByMonth(pmDemandReqVo);
  1738. resMap.put("月", byMonth);
  1739. }
  1740. return AjaxResult.success(resMap);
  1741. }
  1742. @Override
  1743. public AjaxResult countEveryStatusNum(PmDemandReqVo pmDemandReqVo) {
  1744. //指项目进行到各个阶段的数量
  1745. //阶段包括:待选取代理、待上传招标文件、待发布公告、待开标、待发布中标公告、中标公式中
  1746. List<StatisticalChartsResVo> everyStatusNum = pmDemandMapper.countEveryStatusNum(pmDemandReqVo);
  1747. if (!ObjectUtils.isEmpty(everyStatusNum) && everyStatusNum.size() > 0) {
  1748. for (StatisticalChartsResVo vo : everyStatusNum) {
  1749. switch (vo.getColumnName()) {
  1750. case "9":
  1751. vo.setColumnName(PmProjectStatus.WAIT_SELECT_AGENT.getInfo());
  1752. break;
  1753. case "10":
  1754. vo.setColumnName(PmProjectStatus.WAIT_UPLOAD_BID_FILE.getInfo());
  1755. break;
  1756. case "11":
  1757. vo.setColumnName(PmProjectStatus.WAIT_ANNOUNCEMENT.getInfo());
  1758. break;
  1759. case "12":
  1760. vo.setColumnName(PmProjectStatus.WAIT_OPEN_BID.getInfo());
  1761. break;
  1762. case "13":
  1763. vo.setColumnName(PmProjectStatus.WAIT_BID_ANNOUNCEMENT.getInfo());
  1764. break;
  1765. case "14":
  1766. vo.setColumnName(PmProjectStatus.BIDDING_PUBLICITY.getInfo());
  1767. break;
  1768. default: {
  1769. }
  1770. }
  1771. }
  1772. }
  1773. return AjaxResult.success(everyStatusNum);
  1774. }
  1775. @Override
  1776. public AjaxResult exceedMarketAnalysis(PmDemandReqVo pmDemandReqVo) {
  1777. //所有滞后
  1778. List<PmDemand> demandList = pmDemandMapper.countProjectExceedAll(pmDemandReqVo);
  1779. //滞后时长包括:滞后1个月以内的采购任务、滞后1至3个月采购任务、滞后3至6个月采购任务、滞后6个月至1年采购任务、滞后1年以上采购任务
  1780. HashMap<String, Integer> map = new LinkedHashMap<>();
  1781. map.put("滞后1个月以内的采购任务", 0);
  1782. map.put("滞后1至3个月采购任务", 0);
  1783. map.put("滞后3至6个月采购任务", 0);
  1784. map.put("滞后6个月至1年采购任务", 0);
  1785. map.put("滞后1年以上采购任务", 0);
  1786. if (!ObjectUtils.isEmpty(demandList) && demandList.size() > 0) {
  1787. for (PmDemand demand : demandList) {
  1788. //滞后时间
  1789. Long exTime = null;
  1790. if (!ObjectUtils.isEmpty(demand.getRealDemandCommitTime()) && demand.getRealDemandCommitTime().getTime() - demand.getPlanDemandSubTime().getTime() > 0) {
  1791. exTime = demand.getRealDemandCommitTime().getTime() - demand.getPlanDemandSubTime().getTime();
  1792. } else if (!ObjectUtils.isEmpty(demand.getRealPurchaseFinishTime()) && demand.getRealPurchaseFinishTime().getTime() - demand.getPlanPurchaseFinishTime().getTime() > 0) {
  1793. exTime = demand.getRealPurchaseFinishTime().getTime() - demand.getPlanPurchaseFinishTime().getTime();
  1794. } else if (!ObjectUtils.isEmpty(demand.getRealDeliverTime()) && demand.getRealDeliverTime().getTime() - demand.getPlanDeliverTime().getTime() > 0) {
  1795. exTime = demand.getRealDeliverTime().getTime() - demand.getPlanDeliverTime().getTime();
  1796. }
  1797. if (exTime < Long.valueOf("2592000000")) {
  1798. map.put("滞后1个月以内的采购任务", map.get("滞后1个月以内的采购任务") + 1);
  1799. }
  1800. if (exTime >= Long.valueOf("2592000000") && exTime < Long.valueOf("7776000000")) {
  1801. map.put("滞后1至3个月采购任务", map.get("滞后1至3个月采购任务") + 1);
  1802. }
  1803. if (exTime >= Long.valueOf("7776000000") && exTime < Long.valueOf("15552000000")) {
  1804. map.put("滞后3至6个月采购任务", map.get("滞后3至6个月采购任务") + 1);
  1805. }
  1806. if (exTime >= Long.valueOf("15552000000") && exTime < Long.valueOf("31104000000")) {
  1807. map.put("滞后6个月至1年采购任务", map.get("滞后6个月至1年采购任务") + 1);
  1808. }
  1809. if (exTime > Long.valueOf("31104000000")) {
  1810. map.put("滞后1年以上采购任务", map.get("滞后1年以上采购任务") + 1);
  1811. }
  1812. }
  1813. }
  1814. return AjaxResult.success(map);
  1815. }
  1816. @Override
  1817. public AjaxResult countMajorProject(PmDemandReqVo pmDemandReqVo) {
  1818. List<StatisticalChartsResVo> resVos = new ArrayList<>();
  1819. //数量:指本年度状态为“项目建设完成”的项目属性为“重大规划”的项目数
  1820. //预算金额:指本年度状态为“项目建设完成”的项目属性为“重大规划”的项目累加的预算金额
  1821. StatisticalChartsResVo resVo = new StatisticalChartsResVo();
  1822. pmDemandReqVo.setProjectStatus(Long.valueOf(PmProjectStatus.COMPLETION_CONSTRUCTION.getCode()));
  1823. resVo = pmDemandMapper.majorProjectByStatus(pmDemandReqVo);
  1824. resVo.setColumnName("今年已完成数量");
  1825. resVos.add(resVo);
  1826. //正常推进项目:指本年度正在进行中的项目属性为“重大规划”的项目数
  1827. //预算金额:指本年度正在进行中的项目属性为“重大规划”的项目累加的预算金额
  1828. StatisticalChartsResVo resVo1 = new StatisticalChartsResVo();
  1829. pmDemandReqVo.setProjectStatus(Long.valueOf(PmProjectStatus.UNDER_CONSTRUCTION.getCode()));
  1830. resVo1 = pmDemandMapper.majorProjectByStatus(pmDemandReqVo);
  1831. resVo1.setColumnName("正常推进数量");
  1832. resVos.add(resVo1);
  1833. //执行滞后数量:指本年度逾期项目中,项目属性为“重大规划”的项目数
  1834. //预算金额:指本年度正在进行中的项目属性为“重大规划”的项目累加的预算金额
  1835. StatisticalChartsResVo resVo2 = new StatisticalChartsResVo();
  1836. resVo2 = pmDemandMapper.countMajorProjectExceed(pmDemandReqVo);
  1837. resVo2.setColumnName("执行滞后数量");
  1838. resVos.add(resVo2);
  1839. //上年度重大规划采购任务数量:指上年度项目中,项目属性为“重大规划”的项目数
  1840. //预算金额:指上年度项目中,项目属性为“重大规划”的项目累加的预算(合同)金额
  1841. StatisticalChartsResVo resVo3 = new StatisticalChartsResVo();
  1842. resVo3 = pmDemandMapper.countMajorProjectLastYear(pmDemandReqVo);
  1843. resVo3.setColumnName("上年度重大规划采购任务数量");
  1844. resVos.add(resVo3);
  1845. //resVo2=pmDemandMapper.majorProjectByStatus(PmProjectStatus.COMPLETION_CONSTRUCTION.getCode());
  1846. return AjaxResult.success(resVos);
  1847. }
  1848. /**
  1849. * 通过计划ID查询项目数据
  1850. *
  1851. * @param planId
  1852. * @return
  1853. */
  1854. @Override
  1855. public PmDemand selectByPlanId(Long planId) {
  1856. return pmDemandMapper.selectByPlanId(planId);
  1857. }
  1858. /**
  1859. * 项目执行进度统计
  1860. * 1、正常推进项目数量:指未完成并且没有逾期的项目
  1861. * 预算金额:指未完成并且没有逾期的项目累加的预算金额
  1862. * 2、未完成采购任务:“合同待填制”状态之前的项目
  1863. * 预算金额:“合同待填制”状态之前的项目累加的预算金额
  1864. *
  1865. * @param pmDemandReqVo
  1866. * @return
  1867. */
  1868. @Override
  1869. public Map<String, Integer> purchaseProjectExecute(PmDemandReqVo pmDemandReqVo) {
  1870. Map<String, Integer> mapReturn = new HashMap<>();
  1871. // 正常推进项目数量、预算金额
  1872. Map<String, Integer> mapNormalPropulsion = pmDemandMapper.purchaseProjectExecuteNormalPropulsion(pmDemandReqVo);
  1873. // 未完成采购任务,预算金额
  1874. Map<String, Integer> mapIncomplete = pmDemandMapper.purchaseProjectExecuteIncomplete(pmDemandReqVo);
  1875. mapReturn.putAll(mapNormalPropulsion);
  1876. mapReturn.putAll(mapIncomplete);
  1877. return mapReturn;
  1878. }
  1879. /**
  1880. * 已完成项目数量统计
  1881. *
  1882. * @param pmDemandReqVo
  1883. * @return
  1884. */
  1885. @Override
  1886. public List<Map<String, Integer>> purchaseProjectCompleteNumber(PmDemandReqVo pmDemandReqVo) {
  1887. List<Map<String, Integer>> mapReturn = new ArrayList<>();
  1888. // 统计时间类型 1:年度,2:季度,3:月份
  1889. if ("1".equals(pmDemandReqVo.getTimeType())) {
  1890. // 查询数据库中最小的年份
  1891. int minYear = pmDemandMapper.selectMinYear();
  1892. // 获取当前年份
  1893. Calendar calendar = Calendar.getInstance();
  1894. int year = calendar.get(Calendar.YEAR);
  1895. // 获取统计数据
  1896. List<Map<String, Integer>> listMap = pmDemandMapper.selectpurchaseProjectCompleteNumberYear(pmDemandReqVo);
  1897. mapReturn.addAll(listMap);
  1898. for (int i = minYear; i <= year; i++) {
  1899. boolean isYear = false;
  1900. for (Map<String, Integer> map : listMap) {
  1901. if (i == Integer.parseInt(String.valueOf(map.get("yy")))) {
  1902. isYear = true;
  1903. }
  1904. }
  1905. if (!isYear) {
  1906. Map<String, Integer> map1 = new HashMap<>();
  1907. map1.put("yy", i);
  1908. map1.put("evaluation", 0);
  1909. map1.put("contractAmount", 0);
  1910. map1.put("countNum", 0);
  1911. mapReturn.add(map1);
  1912. }
  1913. }
  1914. } else if ("2".equals(pmDemandReqVo.getTimeType())) {
  1915. // 当前年份季度统计
  1916. // 获取统计数据
  1917. List<Map<String, Integer>> listMap = pmDemandMapper.selectpurchaseProjectCompleteNumberQuarter(pmDemandReqVo);
  1918. mapReturn.addAll(listMap);
  1919. for (int i = 1; i <= 4; i++) {
  1920. boolean isYear = false;
  1921. for (Map<String, Integer> map : listMap) {
  1922. if (i == Integer.parseInt(String.valueOf(map.get("yy")))) {
  1923. isYear = true;
  1924. }
  1925. }
  1926. if (!isYear) {
  1927. Map<String, Integer> map1 = new HashMap<>();
  1928. map1.put("yy", i);
  1929. map1.put("evaluation", 0);
  1930. map1.put("contractAmount", 0);
  1931. map1.put("countNum", 0);
  1932. mapReturn.add(map1);
  1933. }
  1934. }
  1935. } else if ("3".equals(pmDemandReqVo.getTimeType())) {
  1936. // 当前年份月份统计
  1937. // 获取统计数据
  1938. List<Map<String, Integer>> listMap = pmDemandMapper.selectpurchaseProjectCompleteNumberMonth(pmDemandReqVo);
  1939. mapReturn.addAll(listMap);
  1940. for (int i = 1; i <= 12; i++) {
  1941. boolean isYear = false;
  1942. for (Map<String, Integer> map : listMap) {
  1943. if (i == Integer.parseInt(String.valueOf(map.get("yy")))) {
  1944. isYear = true;
  1945. }
  1946. }
  1947. if (!isYear) {
  1948. Map<String, Integer> map1 = new HashMap<>();
  1949. map1.put("yy", i);
  1950. map1.put("evaluation", 0);
  1951. map1.put("contractAmount", 0);
  1952. map1.put("countNum", 0);
  1953. mapReturn.add(map1);
  1954. }
  1955. }
  1956. }
  1957. return mapReturn;
  1958. }
  1959. /**
  1960. * 已完成采购任务数量统计
  1961. *
  1962. * @param pmDemandReqVo
  1963. * @return
  1964. */
  1965. @Override
  1966. public List<Map<String, Integer>> purchaseTaskFinish(PmDemandReqVo pmDemandReqVo) {
  1967. List<Map<String, Integer>> mapReturn = new ArrayList<>();
  1968. // 统计时间类型 1:年度,2:季度,3:月份
  1969. if ("1".equals(pmDemandReqVo.getTimeType())) {
  1970. // 查询数据库中最小的年份
  1971. int minYear = pmDemandMapper.selectMinYear();
  1972. // 获取当前年份
  1973. Calendar calendar = Calendar.getInstance();
  1974. int year = calendar.get(Calendar.YEAR);
  1975. // 获取统计数据
  1976. List<Map<String, Integer>> listMap = pmDemandMapper.selectPurchaseTaskFinishYear(pmDemandReqVo);
  1977. mapReturn.addAll(listMap);
  1978. for (int i = minYear; i <= year; i++) {
  1979. boolean isYear = false;
  1980. for (Map<String, Integer> map : listMap) {
  1981. if (i == Integer.parseInt(String.valueOf(map.get("yy")))) {
  1982. isYear = true;
  1983. }
  1984. }
  1985. if (!isYear) {
  1986. Map<String, Integer> map1 = new HashMap<>();
  1987. map1.put("yy", i);
  1988. map1.put("evaluation", 0);
  1989. map1.put("contractAmount", 0);
  1990. map1.put("countNum", 0);
  1991. mapReturn.add(map1);
  1992. }
  1993. }
  1994. } else if ("2".equals(pmDemandReqVo.getTimeType())) {
  1995. // 当前年份季度统计
  1996. // 获取统计数据
  1997. List<Map<String, Integer>> listMap = pmDemandMapper.selectPurchaseTaskFinishQuarter(pmDemandReqVo);
  1998. mapReturn.addAll(listMap);
  1999. for (int i = 1; i <= 4; i++) {
  2000. boolean isYear = false;
  2001. for (Map<String, Integer> map : listMap) {
  2002. if (i == Integer.parseInt(String.valueOf(map.get("yy")))) {
  2003. isYear = true;
  2004. }
  2005. }
  2006. if (!isYear) {
  2007. Map<String, Integer> map1 = new HashMap<>();
  2008. map1.put("yy", i);
  2009. map1.put("evaluation", 0);
  2010. map1.put("contractAmount", 0);
  2011. map1.put("countNum", 0);
  2012. mapReturn.add(map1);
  2013. }
  2014. }
  2015. } else if ("3".equals(pmDemandReqVo.getTimeType())) {
  2016. // 当前年份月份统计
  2017. // 获取统计数据
  2018. List<Map<String, Integer>> listMap = pmDemandMapper.selectPurchaseTaskFinishMonth(pmDemandReqVo);
  2019. mapReturn.addAll(listMap);
  2020. for (int i = 1; i <= 12; i++) {
  2021. boolean isYear = false;
  2022. for (Map<String, Integer> map : listMap) {
  2023. if (i == Integer.parseInt(String.valueOf(map.get("yy")))) {
  2024. isYear = true;
  2025. }
  2026. }
  2027. if (!isYear) {
  2028. Map<String, Integer> map1 = new HashMap<>();
  2029. map1.put("yy", i);
  2030. map1.put("evaluation", 0);
  2031. map1.put("contractAmount", 0);
  2032. map1.put("countNum", 0);
  2033. mapReturn.add(map1);
  2034. }
  2035. }
  2036. }
  2037. return mapReturn;
  2038. }
  2039. /**
  2040. * 各阶段项目数量分布
  2041. *
  2042. * @param pmDemandReqVo
  2043. * @return
  2044. */
  2045. @Override
  2046. public List<Map<String, String>> purchaseProjectDistribution(PmDemandReqVo pmDemandReqVo) {
  2047. // 项目计划 4之前(包括4)
  2048. List<String> xmjh = new ArrayList<>();
  2049. xmjh.add("4");
  2050. pmDemandReqVo.setProjectStatusList(xmjh);
  2051. Map<String, String> returnMapxmjh = pmDemandMapper.purchaseProjectDistribution(pmDemandReqVo);
  2052. returnMapxmjh.put("name", "计划管理");
  2053. // 需求建党 4之后(不包括4)
  2054. List<String> xqjd = new ArrayList<>();
  2055. xqjd.add("5");
  2056. xqjd.add("6");
  2057. xqjd.add("7");
  2058. xqjd.add("8");
  2059. pmDemandReqVo.setProjectStatusList(xqjd);
  2060. Map<String, String> returnMapxqjd = pmDemandMapper.purchaseProjectDistribution(pmDemandReqVo);
  2061. returnMapxqjd.put("name", "需求管理");
  2062. // 任务下达 8之后(不包括8)
  2063. List<String> rwxd = new ArrayList<>();
  2064. rwxd.add("9");
  2065. pmDemandReqVo.setProjectStatusList(rwxd);
  2066. Map<String, String> returnMaprwxd = pmDemandMapper.purchaseProjectDistribution(pmDemandReqVo);
  2067. returnMaprwxd.put("name", "任务下达");
  2068. // 采购执行 9之后(不包括9)
  2069. List<String> cgzx = new ArrayList<>();
  2070. cgzx.add("10");
  2071. cgzx.add("11");
  2072. cgzx.add("12");
  2073. cgzx.add("13");
  2074. cgzx.add("14");
  2075. cgzx.add("15");
  2076. pmDemandReqVo.setProjectStatusList(cgzx);
  2077. Map<String, String> returnMapcgzx = pmDemandMapper.purchaseProjectDistribution(pmDemandReqVo);
  2078. returnMapcgzx.put("name", "采购执行");
  2079. // 合同管理 15之后(不包括15)
  2080. List<String> htxx = new ArrayList<>();
  2081. htxx.add("16");
  2082. pmDemandReqVo.setProjectStatusList(htxx);
  2083. Map<String, String> returnMaphtxx = pmDemandMapper.purchaseProjectDistribution(pmDemandReqVo);
  2084. returnMaphtxx.put("name", "合同管理");
  2085. // 项目建设 17
  2086. List<String> xmjs = new ArrayList<>();
  2087. xmjs.add("16");
  2088. pmDemandReqVo.setProjectStatusList(xmjs);
  2089. Map<String, String> returnMapxmjs = pmDemandMapper.purchaseProjectDistribution(pmDemandReqVo);
  2090. returnMapxmjs.put("name", "合同管理");
  2091. List<Map<String, String>> returnMap = new ArrayList<>();
  2092. returnMap.add(returnMapxmjh);
  2093. returnMap.add(returnMapxqjd);
  2094. returnMap.add(returnMaprwxd);
  2095. returnMap.add(returnMapcgzx);
  2096. returnMap.add(returnMaphtxx);
  2097. returnMap.add(returnMapxmjs);
  2098. return returnMap;
  2099. }
  2100. /**
  2101. * 项目数量分析---------年度的同比和环比不展示-----------
  2102. *
  2103. * @param pmDemandReqVo
  2104. * @return
  2105. */
  2106. @Override
  2107. public List<Map<String, String>> purchaseProjectNumberAnalysis(PmDemandReqVo pmDemandReqVo) {
  2108. List<Map<String, String>> mapReturn = new ArrayList<>();
  2109. // 统计时间类型 1:年度,2:季度,3:月份
  2110. if ("1".equals(pmDemandReqVo.getTimeType())) {
  2111. // 查询数据库中最小的年份
  2112. int minYear = pmDemandMapper.selectMinYear();
  2113. // 获取当前年份
  2114. Calendar calendar = Calendar.getInstance();
  2115. int year = calendar.get(Calendar.YEAR);
  2116. // 获取统计数据
  2117. // 获取项目统计
  2118. List<Map<String, String>> listMap = pmDemandMapper.purchaseProjectNumberAnalysisYear(pmDemandReqVo);
  2119. mapReturn.addAll(listMap);
  2120. for (int i = minYear; i <= year; i++) {
  2121. boolean isYear = false;
  2122. for (Map<String, String> map : listMap) {
  2123. if (i == Integer.parseInt(String.valueOf(map.get("yy")))) {
  2124. isYear = true;
  2125. }
  2126. }
  2127. if (!isYear) {
  2128. Map<String, String> map1 = new HashMap<>();
  2129. map1.put("yy", i + "");
  2130. map1.put("countNum", 0 + "");
  2131. map1.put("evaluationSum", 0 + "");
  2132. mapReturn.add(map1);
  2133. }
  2134. }
  2135. } else if ("2".equals(pmDemandReqVo.getTimeType())) {
  2136. // 当前年份季度统计
  2137. // 获取统计数据
  2138. List<Map<String, String>> listMap = pmDemandMapper.purchaseProjectNumberAnalysisQuarter(pmDemandReqVo);
  2139. List<Map<String, String>> mapList = new ArrayList<>();
  2140. mapList.addAll(listMap);
  2141. for (int i = 1; i <= 4; i++) {
  2142. boolean isYear = false;
  2143. for (Map<String, String> map : listMap) {
  2144. if (i == Integer.parseInt(String.valueOf(map.get("yy")))) {
  2145. isYear = true;
  2146. }
  2147. }
  2148. if (!isYear) {
  2149. Map<String, String> map1 = new HashMap<>();
  2150. map1.put("yy", i + "");
  2151. map1.put("countNum", 0 + "");
  2152. map1.put("evaluationSum", 0 + "");
  2153. mapList.add(map1);
  2154. }
  2155. }
  2156. Map<String, String> map1 = new HashMap<>();
  2157. Map<String, String> map2 = new HashMap<>();
  2158. Map<String, String> map3 = new HashMap<>();
  2159. Map<String, String> map4 = new HashMap<>();
  2160. for (Map<String, String> map : mapList) {
  2161. String yy = String.valueOf(map.get("yy"));
  2162. if ("1".equals(yy)) {
  2163. map1.putAll(map);
  2164. } else if ("2".equals(yy)) {
  2165. map2.putAll(map);
  2166. } else if ("3".equals(yy)) {
  2167. map3.putAll(map);
  2168. } else if ("4".equals(yy)) {
  2169. map4.putAll(map);
  2170. }
  2171. }
  2172. String countNum1 = String.valueOf(map1.get("countNum"));
  2173. String countNum2 = String.valueOf(map2.get("countNum"));
  2174. String countNum3 = String.valueOf(map3.get("countNum"));
  2175. String countNum4 = String.valueOf(map4.get("countNum"));
  2176. String evaluationSum1 = String.valueOf(map1.get("evaluationSum"));
  2177. String evaluationSum2 = String.valueOf(map2.get("evaluationSum"));
  2178. String evaluationSum3 = String.valueOf(map3.get("evaluationSum"));
  2179. String evaluationSum4 = String.valueOf(map4.get("evaluationSum"));
  2180. // 查询上一年四季度数据
  2181. List<Map<String, String>> listMapOldYear = pmDemandMapper.purchaseProjectNumberAnalysisOldYearQuarter(pmDemandReqVo);
  2182. List<Map<String, String>> mapListOld = new ArrayList<>();
  2183. mapListOld.addAll(listMapOldYear);
  2184. for (int i = 1; i <= 4; i++) {
  2185. boolean isYear = false;
  2186. for (Map<String, String> map : listMapOldYear) {
  2187. if (i == Integer.parseInt(String.valueOf(map.get("yy")))) {
  2188. isYear = true;
  2189. }
  2190. }
  2191. if (!isYear) {
  2192. Map<String, String> map11 = new HashMap<>();
  2193. map11.put("yy", i + "");
  2194. map11.put("countNum", 0 + "");
  2195. map11.put("evaluationSum", 0 + "");
  2196. mapListOld.add(map11);
  2197. }
  2198. }
  2199. Map<String, String> mapOld1 = new HashMap<>();
  2200. Map<String, String> mapOld2 = new HashMap<>();
  2201. Map<String, String> mapOld3 = new HashMap<>();
  2202. Map<String, String> mapOld4 = new HashMap<>();
  2203. for (Map<String, String> mapOld : mapListOld) {
  2204. String yy = String.valueOf(mapOld.get("yy"));
  2205. if ("1".equals(yy)) {
  2206. mapOld1.putAll(mapOld);
  2207. } else if ("2".equals(yy)) {
  2208. mapOld2.putAll(mapOld);
  2209. } else if ("3".equals(yy)) {
  2210. mapOld3.putAll(mapOld);
  2211. } else if ("4".equals(yy)) {
  2212. mapOld4.putAll(mapOld);
  2213. }
  2214. }
  2215. String countNumOld1 = String.valueOf(mapOld1.get("countNum"));
  2216. String countNumOld2 = String.valueOf(mapOld2.get("countNum"));
  2217. String countNumOld3 = String.valueOf(mapOld3.get("countNum"));
  2218. String countNumOld4 = String.valueOf(mapOld4.get("countNum"));
  2219. String evaluationSumOld1 = String.valueOf(mapOld1.get("evaluationSum"));
  2220. String evaluationSumOld2 = String.valueOf(mapOld2.get("evaluationSum"));
  2221. String evaluationSumOld3 = String.valueOf(mapOld3.get("evaluationSum"));
  2222. String evaluationSumOld4 = String.valueOf(mapOld4.get("evaluationSum"));
  2223. BigDecimal countNum11 = new BigDecimal(countNum1);
  2224. BigDecimal countNum22 = new BigDecimal(countNum2);
  2225. BigDecimal countNum33 = new BigDecimal(countNum3);
  2226. BigDecimal countNum44 = new BigDecimal(countNum4);
  2227. BigDecimal countNumOld11 = new BigDecimal(countNumOld1);
  2228. BigDecimal countNumOld22 = new BigDecimal(countNumOld2);
  2229. BigDecimal countNumOld33 = new BigDecimal(countNumOld3);
  2230. BigDecimal countNumOld44 = new BigDecimal(countNumOld4);
  2231. BigDecimal evaluationSum11 = new BigDecimal(evaluationSum1);
  2232. BigDecimal evaluationSum22 = new BigDecimal(evaluationSum2);
  2233. BigDecimal evaluationSum33 = new BigDecimal(evaluationSum3);
  2234. BigDecimal evaluationSum44 = new BigDecimal(evaluationSum4);
  2235. BigDecimal evaluationSumOld11 = new BigDecimal(evaluationSumOld1);
  2236. BigDecimal evaluationSumOld22 = new BigDecimal(evaluationSumOld2);
  2237. BigDecimal evaluationSumOld33 = new BigDecimal(evaluationSumOld3);
  2238. BigDecimal evaluationSumOld44 = new BigDecimal(evaluationSumOld4);
  2239. // 项目数量环比 对比
  2240. BigDecimal monthonmonthNum1 = new BigDecimal(0.00);
  2241. BigDecimal monthonmonthNum2 = new BigDecimal(0.00);
  2242. BigDecimal monthonmonthNum3 = new BigDecimal(0.00);
  2243. BigDecimal monthonmonthNum4 = new BigDecimal(0.00);
  2244. if (!"0".equals(countNumOld4)) {
  2245. monthonmonthNum1 = (countNum11.subtract(countNumOld44)).divide(countNumOld44, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2246. }
  2247. if (!"0".equals(countNum1)) {
  2248. monthonmonthNum2 = (countNum22.subtract(countNum11)).divide(countNum11, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2249. }
  2250. if (!"0".equals(countNum2)) {
  2251. monthonmonthNum3 = (countNum33.subtract(countNum22)).divide(countNum22, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2252. }
  2253. if (!"0".equals(countNum3)) {
  2254. monthonmonthNum4 = (countNum44.subtract(countNum33)).divide(countNum33, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2255. }
  2256. map1.put("monthonmonthNum", monthonmonthNum1.toString());
  2257. map2.put("monthonmonthNum", monthonmonthNum2.toString());
  2258. map3.put("monthonmonthNum", monthonmonthNum3.toString());
  2259. map4.put("monthonmonthNum", monthonmonthNum4.toString());
  2260. // 项目数量同比 对比
  2261. BigDecimal yearonyearNum1 = new BigDecimal(0.00);
  2262. BigDecimal yearonyearNum2 = new BigDecimal(0.00);
  2263. BigDecimal yearonyearNum3 = new BigDecimal(0.00);
  2264. BigDecimal yearonyearNum4 = new BigDecimal(0.00);
  2265. if (!"0".equals(countNumOld1)) {
  2266. yearonyearNum1 = (countNum11.subtract(countNumOld11)).divide(countNumOld11, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2267. }
  2268. if (!"0".equals(countNumOld2)) {
  2269. yearonyearNum2 = (countNum22.subtract(countNumOld22)).divide(countNumOld22, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2270. }
  2271. if (!"0".equals(countNumOld3)) {
  2272. yearonyearNum3 = (countNum33.subtract(countNumOld33)).divide(countNumOld33, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2273. }
  2274. if (!"0".equals(countNumOld4)) {
  2275. yearonyearNum4 = (countNum44.subtract(countNumOld44)).divide(countNumOld44, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2276. }
  2277. map1.put("yearonyearNum", yearonyearNum1.toString());
  2278. map2.put("yearonyearNum", yearonyearNum2.toString());
  2279. map3.put("yearonyearNum", yearonyearNum3.toString());
  2280. map4.put("yearonyearNum", yearonyearNum4.toString());
  2281. // 预算金额环比 对比
  2282. BigDecimal monthonmonthAmount1 = new BigDecimal(0.00);
  2283. BigDecimal monthonmonthAmount2 = new BigDecimal(0.00);
  2284. BigDecimal monthonmonthAmount3 = new BigDecimal(0.00);
  2285. BigDecimal monthonmonthAmount4 = new BigDecimal(0.00);
  2286. if (!"0".equals(evaluationSumOld4)) {
  2287. monthonmonthAmount1 = (evaluationSum11.subtract(evaluationSumOld44)).divide(evaluationSumOld44, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2288. }
  2289. if (!"0".equals(evaluationSum1)) {
  2290. monthonmonthAmount2 = (evaluationSum22.subtract(evaluationSum11)).divide(evaluationSum11, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2291. }
  2292. if (!"0".equals(evaluationSum2)) {
  2293. monthonmonthAmount3 = (evaluationSum33.subtract(evaluationSum22)).divide(evaluationSum22, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2294. }
  2295. if (!"0".equals(evaluationSum3)) {
  2296. monthonmonthAmount4 = (evaluationSum44.subtract(evaluationSum33)).divide(evaluationSum33, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2297. }
  2298. map1.put("monthonmonthAmount", monthonmonthAmount1.toString());
  2299. map2.put("monthonmonthAmount", monthonmonthAmount2.toString());
  2300. map3.put("monthonmonthAmount", monthonmonthAmount3.toString());
  2301. map4.put("monthonmonthAmount", monthonmonthAmount4.toString());
  2302. // 预算金额同比比 对比
  2303. BigDecimal yearonyearAmount1 = new BigDecimal(0.00);
  2304. BigDecimal yearonyearAmount2 = new BigDecimal(0.00);
  2305. BigDecimal yearonyearAmount3 = new BigDecimal(0.00);
  2306. BigDecimal yearonyearAmount4 = new BigDecimal(0.00);
  2307. if (!"0".equals(evaluationSumOld1)) {
  2308. yearonyearAmount1 = (evaluationSum11.subtract(evaluationSumOld11)).divide(evaluationSumOld11, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2309. }
  2310. if (!"0".equals(evaluationSumOld2)) {
  2311. yearonyearAmount2 = (evaluationSum22.subtract(evaluationSumOld22)).divide(evaluationSumOld22, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2312. }
  2313. if (!"0".equals(evaluationSumOld3)) {
  2314. yearonyearAmount3 = (evaluationSum33.subtract(evaluationSumOld33)).divide(evaluationSumOld33, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2315. }
  2316. if (!"0".equals(evaluationSumOld4)) {
  2317. yearonyearAmount4 = (evaluationSum44.subtract(evaluationSumOld44)).divide(evaluationSumOld44, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2318. }
  2319. map1.put("yearonyearAmount", yearonyearAmount1.toString());
  2320. map2.put("yearonyearAmount", yearonyearAmount2.toString());
  2321. map3.put("yearonyearAmount", yearonyearAmount3.toString());
  2322. map4.put("yearonyearAmount", yearonyearAmount4.toString());
  2323. // 存入集合
  2324. mapReturn.add(map1);
  2325. mapReturn.add(map2);
  2326. mapReturn.add(map3);
  2327. mapReturn.add(map4);
  2328. } else if ("3".equals(pmDemandReqVo.getTimeType())) {
  2329. // 当前年份月份统计
  2330. // 获取统计数据
  2331. List<Map<String, String>> listMap = pmDemandMapper.purchaseProjectNumberAnalysisMonth(pmDemandReqVo);
  2332. List<Map<String, String>> mapList = new ArrayList<>();
  2333. mapList.addAll(listMap);
  2334. for (int i = 1; i <= 12; i++) {
  2335. boolean isYear = false;
  2336. for (Map<String, String> map : listMap) {
  2337. String yy = String.valueOf(map.get("yy"));
  2338. String yyNew = yy.replaceAll("^0*", "");
  2339. if (i == Integer.valueOf(yyNew)) {
  2340. isYear = true;
  2341. }
  2342. }
  2343. if (!isYear) {
  2344. Map<String, String> map1 = new HashMap<>();
  2345. String yy = String.format("%02d", i);
  2346. map1.put("yy", yy);
  2347. map1.put("countNum", 0 + "");
  2348. map1.put("evaluationSum", 0 + "");
  2349. mapList.add(map1);
  2350. }
  2351. }
  2352. Map<String, String> map1 = new HashMap<>();
  2353. Map<String, String> map2 = new HashMap<>();
  2354. Map<String, String> map3 = new HashMap<>();
  2355. Map<String, String> map4 = new HashMap<>();
  2356. Map<String, String> map5 = new HashMap<>();
  2357. Map<String, String> map6 = new HashMap<>();
  2358. Map<String, String> map7 = new HashMap<>();
  2359. Map<String, String> map8 = new HashMap<>();
  2360. Map<String, String> map9 = new HashMap<>();
  2361. Map<String, String> map10 = new HashMap<>();
  2362. Map<String, String> map11 = new HashMap<>();
  2363. Map<String, String> map12 = new HashMap<>();
  2364. for (Map<String, String> map : mapList) {
  2365. String yy = String.valueOf(map.get("yy"));
  2366. if ("01".equals(yy)) {
  2367. map1.putAll(map);
  2368. } else if ("02".equals(yy)) {
  2369. map2.putAll(map);
  2370. } else if ("03".equals(yy)) {
  2371. map3.putAll(map);
  2372. } else if ("04".equals(yy)) {
  2373. map4.putAll(map);
  2374. } else if ("05".equals(yy)) {
  2375. map5.putAll(map);
  2376. } else if ("06".equals(yy)) {
  2377. map6.putAll(map);
  2378. } else if ("07".equals(yy)) {
  2379. map7.putAll(map);
  2380. } else if ("08".equals(yy)) {
  2381. map8.putAll(map);
  2382. } else if ("09".equals(yy)) {
  2383. map9.putAll(map);
  2384. } else if ("10".equals(yy)) {
  2385. map10.putAll(map);
  2386. } else if ("11".equals(yy)) {
  2387. map11.putAll(map);
  2388. } else if ("12".equals(yy)) {
  2389. map12.putAll(map);
  2390. }
  2391. }
  2392. String countNum1 = String.valueOf(map1.get("countNum"));
  2393. String countNum2 = String.valueOf(map2.get("countNum"));
  2394. String countNum3 = String.valueOf(map3.get("countNum"));
  2395. String countNum4 = String.valueOf(map4.get("countNum"));
  2396. String countNum5 = String.valueOf(map5.get("countNum"));
  2397. String countNum6 = String.valueOf(map6.get("countNum"));
  2398. String countNum7 = String.valueOf(map7.get("countNum"));
  2399. String countNum8 = String.valueOf(map8.get("countNum"));
  2400. String countNum9 = String.valueOf(map9.get("countNum"));
  2401. String countNum10 = String.valueOf(map10.get("countNum"));
  2402. String countNum11 = String.valueOf(map11.get("countNum"));
  2403. String countNum12 = String.valueOf(map12.get("countNum"));
  2404. String evaluationSum1 = String.valueOf(map1.get("evaluationSum"));
  2405. String evaluationSum2 = String.valueOf(map2.get("evaluationSum"));
  2406. String evaluationSum3 = String.valueOf(map3.get("evaluationSum"));
  2407. String evaluationSum4 = String.valueOf(map4.get("evaluationSum"));
  2408. String evaluationSum5 = String.valueOf(map5.get("evaluationSum"));
  2409. String evaluationSum6 = String.valueOf(map6.get("evaluationSum"));
  2410. String evaluationSum7 = String.valueOf(map7.get("evaluationSum"));
  2411. String evaluationSum8 = String.valueOf(map8.get("evaluationSum"));
  2412. String evaluationSum9 = String.valueOf(map9.get("evaluationSum"));
  2413. String evaluationSum10 = String.valueOf(map10.get("evaluationSum"));
  2414. String evaluationSum11 = String.valueOf(map11.get("evaluationSum"));
  2415. String evaluationSum12 = String.valueOf(map12.get("evaluationSum"));
  2416. // 查询上一年月份数据
  2417. List<Map<String, String>> listMapOldMonth = pmDemandMapper.purchaseProjectNumberAnalysisOldYearMonth(pmDemandReqVo);
  2418. List<Map<String, String>> mapListOld = new ArrayList<>();
  2419. mapListOld.addAll(listMapOldMonth);
  2420. for (int i = 1; i <= 12; i++) {
  2421. boolean isYear = false;
  2422. for (Map<String, String> map : listMapOldMonth) {
  2423. String yy = String.valueOf(map.get("yy"));
  2424. String yyNew = yy.replaceAll("^0*", "");
  2425. if (i == Integer.valueOf(yyNew)) {
  2426. isYear = true;
  2427. }
  2428. }
  2429. if (!isYear) {
  2430. Map<String, String> map111 = new HashMap<>();
  2431. String yy = String.format("%02d", i);
  2432. map111.put("yy", yy);
  2433. map111.put("countNum", 0 + "");
  2434. map111.put("evaluationSum", 0 + "");
  2435. mapListOld.add(map111);
  2436. }
  2437. }
  2438. Map<String, String> mapOld1 = new HashMap<>();
  2439. Map<String, String> mapOld2 = new HashMap<>();
  2440. Map<String, String> mapOld3 = new HashMap<>();
  2441. Map<String, String> mapOld4 = new HashMap<>();
  2442. Map<String, String> mapOld5 = new HashMap<>();
  2443. Map<String, String> mapOld6 = new HashMap<>();
  2444. Map<String, String> mapOld7 = new HashMap<>();
  2445. Map<String, String> mapOld8 = new HashMap<>();
  2446. Map<String, String> mapOld9 = new HashMap<>();
  2447. Map<String, String> mapOld10 = new HashMap<>();
  2448. Map<String, String> mapOld11 = new HashMap<>();
  2449. Map<String, String> mapOld12 = new HashMap<>();
  2450. for (Map<String, String> mapOld : mapListOld) {
  2451. String yy = String.valueOf(mapOld.get("yy"));
  2452. if ("01".equals(yy)) {
  2453. mapOld1.putAll(mapOld);
  2454. } else if ("02".equals(yy)) {
  2455. mapOld2.putAll(mapOld);
  2456. } else if ("03".equals(yy)) {
  2457. mapOld3.putAll(mapOld);
  2458. } else if ("04".equals(yy)) {
  2459. mapOld4.putAll(mapOld);
  2460. } else if ("05".equals(yy)) {
  2461. mapOld5.putAll(mapOld);
  2462. } else if ("06".equals(yy)) {
  2463. mapOld6.putAll(mapOld);
  2464. } else if ("07".equals(yy)) {
  2465. mapOld7.putAll(mapOld);
  2466. } else if ("08".equals(yy)) {
  2467. mapOld8.putAll(mapOld);
  2468. } else if ("09".equals(yy)) {
  2469. mapOld9.putAll(mapOld);
  2470. } else if ("10".equals(yy)) {
  2471. mapOld10.putAll(mapOld);
  2472. } else if ("11".equals(yy)) {
  2473. mapOld11.putAll(mapOld);
  2474. } else if ("12".equals(yy)) {
  2475. mapOld12.putAll(mapOld);
  2476. }
  2477. }
  2478. String countNumOld1 = String.valueOf(mapOld1.get("countNum"));
  2479. String countNumOld2 = String.valueOf(mapOld2.get("countNum"));
  2480. String countNumOld3 = String.valueOf(mapOld3.get("countNum"));
  2481. String countNumOld4 = String.valueOf(mapOld4.get("countNum"));
  2482. String countNumOld5 = String.valueOf(mapOld5.get("countNum"));
  2483. String countNumOld6 = String.valueOf(mapOld6.get("countNum"));
  2484. String countNumOld7 = String.valueOf(mapOld7.get("countNum"));
  2485. String countNumOld8 = String.valueOf(mapOld8.get("countNum"));
  2486. String countNumOld9 = String.valueOf(mapOld9.get("countNum"));
  2487. String countNumOld10 = String.valueOf(mapOld10.get("countNum"));
  2488. String countNumOld11 = String.valueOf(mapOld11.get("countNum"));
  2489. String countNumOld12 = String.valueOf(mapOld12.get("countNum"));
  2490. String evaluationSumOld1 = String.valueOf(mapOld1.get("evaluationSum"));
  2491. String evaluationSumOld2 = String.valueOf(mapOld2.get("evaluationSum"));
  2492. String evaluationSumOld3 = String.valueOf(mapOld3.get("evaluationSum"));
  2493. String evaluationSumOld4 = String.valueOf(mapOld4.get("evaluationSum"));
  2494. String evaluationSumOld5 = String.valueOf(mapOld5.get("evaluationSum"));
  2495. String evaluationSumOld6 = String.valueOf(mapOld6.get("evaluationSum"));
  2496. String evaluationSumOld7 = String.valueOf(mapOld7.get("evaluationSum"));
  2497. String evaluationSumOld8 = String.valueOf(mapOld8.get("evaluationSum"));
  2498. String evaluationSumOld9 = String.valueOf(mapOld9.get("evaluationSum"));
  2499. String evaluationSumOld10 = String.valueOf(mapOld10.get("evaluationSum"));
  2500. String evaluationSumOld11 = String.valueOf(mapOld11.get("evaluationSum"));
  2501. String evaluationSumOld12 = String.valueOf(mapOld12.get("evaluationSum"));
  2502. BigDecimal countNum111 = new BigDecimal(countNum1);
  2503. BigDecimal countNum22 = new BigDecimal(countNum2);
  2504. BigDecimal countNum33 = new BigDecimal(countNum3);
  2505. BigDecimal countNum44 = new BigDecimal(countNum4);
  2506. BigDecimal countNum55 = new BigDecimal(countNum5);
  2507. BigDecimal countNum66 = new BigDecimal(countNum6);
  2508. BigDecimal countNum77 = new BigDecimal(countNum7);
  2509. BigDecimal countNum88 = new BigDecimal(countNum8);
  2510. BigDecimal countNum99 = new BigDecimal(countNum9);
  2511. BigDecimal countNum1010 = new BigDecimal(countNum10);
  2512. BigDecimal countNum1111 = new BigDecimal(countNum11);
  2513. BigDecimal countNum1212 = new BigDecimal(countNum12);
  2514. BigDecimal countNumOld111 = new BigDecimal(countNumOld1);
  2515. BigDecimal countNumOld22 = new BigDecimal(countNumOld2);
  2516. BigDecimal countNumOld33 = new BigDecimal(countNumOld3);
  2517. BigDecimal countNumOld44 = new BigDecimal(countNumOld4);
  2518. BigDecimal countNumOld55 = new BigDecimal(countNumOld5);
  2519. BigDecimal countNumOld66 = new BigDecimal(countNumOld6);
  2520. BigDecimal countNumOld77 = new BigDecimal(countNumOld7);
  2521. BigDecimal countNumOld88 = new BigDecimal(countNumOld8);
  2522. BigDecimal countNumOld99 = new BigDecimal(countNumOld9);
  2523. BigDecimal countNumOld1010 = new BigDecimal(countNumOld10);
  2524. BigDecimal countNumOld1111 = new BigDecimal(countNumOld11);
  2525. BigDecimal countNumOld1212 = new BigDecimal(countNumOld12);
  2526. BigDecimal evaluationSum111 = new BigDecimal(evaluationSum1);
  2527. BigDecimal evaluationSum22 = new BigDecimal(evaluationSum2);
  2528. BigDecimal evaluationSum33 = new BigDecimal(evaluationSum3);
  2529. BigDecimal evaluationSum44 = new BigDecimal(evaluationSum4);
  2530. BigDecimal evaluationSum55 = new BigDecimal(evaluationSum5);
  2531. BigDecimal evaluationSum66 = new BigDecimal(evaluationSum6);
  2532. BigDecimal evaluationSum77 = new BigDecimal(evaluationSum7);
  2533. BigDecimal evaluationSum88 = new BigDecimal(evaluationSum8);
  2534. BigDecimal evaluationSum99 = new BigDecimal(evaluationSum9);
  2535. BigDecimal evaluationSum1010 = new BigDecimal(evaluationSum10);
  2536. BigDecimal evaluationSum1111 = new BigDecimal(evaluationSum11);
  2537. BigDecimal evaluationSum1212 = new BigDecimal(evaluationSum12);
  2538. BigDecimal evaluationSumOld111 = new BigDecimal(evaluationSumOld1);
  2539. BigDecimal evaluationSumOld22 = new BigDecimal(evaluationSumOld2);
  2540. BigDecimal evaluationSumOld33 = new BigDecimal(evaluationSumOld3);
  2541. BigDecimal evaluationSumOld44 = new BigDecimal(evaluationSumOld4);
  2542. BigDecimal evaluationSumOld55 = new BigDecimal(evaluationSumOld5);
  2543. BigDecimal evaluationSumOld66 = new BigDecimal(evaluationSumOld6);
  2544. BigDecimal evaluationSumOld77 = new BigDecimal(evaluationSumOld7);
  2545. BigDecimal evaluationSumOld88 = new BigDecimal(evaluationSumOld8);
  2546. BigDecimal evaluationSumOld99 = new BigDecimal(evaluationSumOld9);
  2547. BigDecimal evaluationSumOld1010 = new BigDecimal(evaluationSumOld10);
  2548. BigDecimal evaluationSumOld1111 = new BigDecimal(evaluationSumOld11);
  2549. BigDecimal evaluationSumOld1212 = new BigDecimal(evaluationSumOld12);
  2550. // 项目数量环比 对比
  2551. BigDecimal monthonmonthNum1 = new BigDecimal(0.00);
  2552. BigDecimal monthonmonthNum2 = new BigDecimal(0.00);
  2553. BigDecimal monthonmonthNum3 = new BigDecimal(0.00);
  2554. BigDecimal monthonmonthNum4 = new BigDecimal(0.00);
  2555. BigDecimal monthonmonthNum5 = new BigDecimal(0.00);
  2556. BigDecimal monthonmonthNum6 = new BigDecimal(0.00);
  2557. BigDecimal monthonmonthNum7 = new BigDecimal(0.00);
  2558. BigDecimal monthonmonthNum8 = new BigDecimal(0.00);
  2559. BigDecimal monthonmonthNum9 = new BigDecimal(0.00);
  2560. BigDecimal monthonmonthNum10 = new BigDecimal(0.00);
  2561. BigDecimal monthonmonthNum11 = new BigDecimal(0.00);
  2562. BigDecimal monthonmonthNum12 = new BigDecimal(0.00);
  2563. if (!"0".equals(countNumOld12)) {
  2564. monthonmonthNum1 = (countNum111.subtract(countNumOld1212)).divide(countNumOld1212, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2565. }
  2566. if (!"0".equals(countNum1)) {
  2567. monthonmonthNum2 = (countNum22.subtract(countNum111)).divide(countNum111, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2568. }
  2569. if (!"0".equals(countNum2)) {
  2570. monthonmonthNum3 = (countNum33.subtract(countNum22)).divide(countNum22, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2571. }
  2572. if (!"0".equals(countNum3)) {
  2573. monthonmonthNum4 = (countNum44.subtract(countNum33)).divide(countNum33, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2574. }
  2575. if (!"0".equals(countNum4)) {
  2576. monthonmonthNum5 = (countNum55.subtract(countNum44)).divide(countNum44, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2577. }
  2578. if (!"0".equals(countNum5)) {
  2579. monthonmonthNum6 = (countNum66.subtract(countNum55)).divide(countNum55, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2580. }
  2581. if (!"0".equals(countNum6)) {
  2582. monthonmonthNum7 = (countNum77.subtract(countNum66)).divide(countNum66, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2583. }
  2584. if (!"0".equals(countNum7)) {
  2585. monthonmonthNum8 = (countNum88.subtract(countNum77)).divide(countNum77, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2586. }
  2587. if (!"0".equals(countNum8)) {
  2588. monthonmonthNum9 = (countNum99.subtract(countNum88)).divide(countNum88, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2589. }
  2590. if (!"0".equals(countNum9)) {
  2591. monthonmonthNum10 = (countNum1010.subtract(countNum99)).divide(countNum99, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2592. }
  2593. if (!"0".equals(countNum10)) {
  2594. monthonmonthNum11 = (countNum1111.subtract(countNum1010)).divide(countNum1010, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2595. }
  2596. if (!"0".equals(countNum11)) {
  2597. monthonmonthNum12 = (countNum1212.subtract(countNum1111)).divide(countNum1111, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2598. }
  2599. map1.put("monthonmonthNum", monthonmonthNum1.toString());
  2600. map2.put("monthonmonthNum", monthonmonthNum2.toString());
  2601. map3.put("monthonmonthNum", monthonmonthNum3.toString());
  2602. map4.put("monthonmonthNum", monthonmonthNum4.toString());
  2603. map5.put("monthonmonthNum", monthonmonthNum5.toString());
  2604. map6.put("monthonmonthNum", monthonmonthNum6.toString());
  2605. map7.put("monthonmonthNum", monthonmonthNum7.toString());
  2606. map8.put("monthonmonthNum", monthonmonthNum8.toString());
  2607. map9.put("monthonmonthNum", monthonmonthNum9.toString());
  2608. map10.put("monthonmonthNum", monthonmonthNum10.toString());
  2609. map11.put("monthonmonthNum", monthonmonthNum11.toString());
  2610. map12.put("monthonmonthNum", monthonmonthNum12.toString());
  2611. // 项目数量同比 对比
  2612. BigDecimal yearonyearNum1 = new BigDecimal(0.00);
  2613. BigDecimal yearonyearNum2 = new BigDecimal(0.00);
  2614. BigDecimal yearonyearNum3 = new BigDecimal(0.00);
  2615. BigDecimal yearonyearNum4 = new BigDecimal(0.00);
  2616. BigDecimal yearonyearNum5 = new BigDecimal(0.00);
  2617. BigDecimal yearonyearNum6 = new BigDecimal(0.00);
  2618. BigDecimal yearonyearNum7 = new BigDecimal(0.00);
  2619. BigDecimal yearonyearNum8 = new BigDecimal(0.00);
  2620. BigDecimal yearonyearNum9 = new BigDecimal(0.00);
  2621. BigDecimal yearonyearNum10 = new BigDecimal(0.00);
  2622. BigDecimal yearonyearNum11 = new BigDecimal(0.00);
  2623. BigDecimal yearonyearNum12 = new BigDecimal(0.00);
  2624. if (!"0".equals(countNumOld1)) {
  2625. yearonyearNum1 = (countNum111.subtract(countNumOld111)).divide(countNumOld111, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2626. }
  2627. if (!"0".equals(countNumOld2)) {
  2628. yearonyearNum2 = (countNum22.subtract(countNumOld22)).divide(countNumOld22, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2629. }
  2630. if (!"0".equals(countNumOld3)) {
  2631. yearonyearNum3 = (countNum33.subtract(countNumOld33)).divide(countNumOld33, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2632. }
  2633. if (!"0".equals(countNumOld4)) {
  2634. yearonyearNum4 = (countNum44.subtract(countNumOld44)).divide(countNumOld44, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2635. }
  2636. if (!"0".equals(countNumOld5)) {
  2637. yearonyearNum5 = (countNum55.subtract(countNumOld55)).divide(countNumOld55, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2638. }
  2639. if (!"0".equals(countNumOld6)) {
  2640. yearonyearNum6 = (countNum66.subtract(countNumOld66)).divide(countNumOld66, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2641. }
  2642. if (!"0".equals(countNumOld7)) {
  2643. yearonyearNum7 = (countNum77.subtract(countNumOld77)).divide(countNumOld77, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2644. }
  2645. if (!"0".equals(countNumOld8)) {
  2646. yearonyearNum8 = (countNum88.subtract(countNumOld88)).divide(countNumOld88, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2647. }
  2648. if (!"0".equals(countNumOld9)) {
  2649. yearonyearNum9 = (countNum99.subtract(countNumOld99)).divide(countNumOld99, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2650. }
  2651. if (!"0".equals(countNumOld10)) {
  2652. yearonyearNum10 = (countNum1010.subtract(countNumOld1010)).divide(countNumOld1010, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2653. }
  2654. if (!"0".equals(countNumOld11)) {
  2655. yearonyearNum11 = (countNum1111.subtract(countNumOld1111)).divide(countNumOld1111, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2656. }
  2657. if (!"0".equals(countNumOld12)) {
  2658. yearonyearNum12 = (countNum1212.subtract(countNumOld1212)).divide(countNumOld1212, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2659. }
  2660. map1.put("yearonyearNum", yearonyearNum1.toString());
  2661. map2.put("yearonyearNum", yearonyearNum2.toString());
  2662. map3.put("yearonyearNum", yearonyearNum3.toString());
  2663. map4.put("yearonyearNum", yearonyearNum4.toString());
  2664. map5.put("yearonyearNum", yearonyearNum5.toString());
  2665. map6.put("yearonyearNum", yearonyearNum6.toString());
  2666. map7.put("yearonyearNum", yearonyearNum7.toString());
  2667. map8.put("yearonyearNum", yearonyearNum8.toString());
  2668. map9.put("yearonyearNum", yearonyearNum9.toString());
  2669. map10.put("yearonyearNum", yearonyearNum10.toString());
  2670. map11.put("yearonyearNum", yearonyearNum11.toString());
  2671. map12.put("yearonyearNum", yearonyearNum12.toString());
  2672. // 预算金额环比 对比
  2673. BigDecimal monthonmonthAmount1 = new BigDecimal(0.00);
  2674. BigDecimal monthonmonthAmount2 = new BigDecimal(0.00);
  2675. BigDecimal monthonmonthAmount3 = new BigDecimal(0.00);
  2676. BigDecimal monthonmonthAmount4 = new BigDecimal(0.00);
  2677. BigDecimal monthonmonthAmount5 = new BigDecimal(0.00);
  2678. BigDecimal monthonmonthAmount6 = new BigDecimal(0.00);
  2679. BigDecimal monthonmonthAmount7 = new BigDecimal(0.00);
  2680. BigDecimal monthonmonthAmount8 = new BigDecimal(0.00);
  2681. BigDecimal monthonmonthAmount9 = new BigDecimal(0.00);
  2682. BigDecimal monthonmonthAmount10 = new BigDecimal(0.00);
  2683. BigDecimal monthonmonthAmount11 = new BigDecimal(0.00);
  2684. BigDecimal monthonmonthAmount12 = new BigDecimal(0.00);
  2685. if (!"0".equals(evaluationSumOld12)) {
  2686. monthonmonthAmount1 = (evaluationSum111.subtract(evaluationSumOld1212)).divide(evaluationSumOld1212, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2687. }
  2688. if (!"0".equals(evaluationSum1)) {
  2689. monthonmonthAmount2 = (evaluationSum22.subtract(evaluationSum111)).divide(evaluationSum111, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2690. }
  2691. if (!"0".equals(evaluationSum2)) {
  2692. monthonmonthAmount3 = (evaluationSum33.subtract(evaluationSum22)).divide(evaluationSum22, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2693. }
  2694. if (!"0".equals(evaluationSum3)) {
  2695. monthonmonthAmount4 = (evaluationSum44.subtract(evaluationSum33)).divide(evaluationSum33, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2696. }
  2697. if (!"0".equals(evaluationSum4)) {
  2698. monthonmonthAmount5 = (evaluationSum55.subtract(evaluationSum44)).divide(evaluationSum44, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2699. }
  2700. if (!"0".equals(evaluationSum5)) {
  2701. monthonmonthAmount6 = (evaluationSum66.subtract(evaluationSum55)).divide(evaluationSum55, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2702. }
  2703. if (!"0".equals(evaluationSum6)) {
  2704. monthonmonthAmount7 = (evaluationSum77.subtract(evaluationSum66)).divide(evaluationSum66, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2705. }
  2706. if (!"0".equals(evaluationSum7)) {
  2707. monthonmonthAmount8 = (evaluationSum88.subtract(evaluationSum77)).divide(evaluationSum77, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2708. }
  2709. if (!"0".equals(evaluationSum8)) {
  2710. monthonmonthAmount9 = (evaluationSum99.subtract(evaluationSum88)).divide(evaluationSum88, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2711. }
  2712. if (!"0".equals(evaluationSum9)) {
  2713. monthonmonthAmount10 = (evaluationSum1010.subtract(evaluationSum99)).divide(evaluationSum99, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2714. }
  2715. if (!"0".equals(evaluationSum10)) {
  2716. monthonmonthAmount11 = (evaluationSum1111.subtract(evaluationSum1010)).divide(evaluationSum1010, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2717. }
  2718. if (!"0".equals(evaluationSum11)) {
  2719. monthonmonthAmount12 = (evaluationSum1212.subtract(evaluationSum1111)).divide(evaluationSum1111, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2720. }
  2721. map1.put("monthonmonthAmount", monthonmonthAmount1.toString());
  2722. map2.put("monthonmonthAmount", monthonmonthAmount2.toString());
  2723. map3.put("monthonmonthAmount", monthonmonthAmount3.toString());
  2724. map4.put("monthonmonthAmount", monthonmonthAmount4.toString());
  2725. map5.put("monthonmonthAmount", monthonmonthAmount5.toString());
  2726. map6.put("monthonmonthAmount", monthonmonthAmount6.toString());
  2727. map7.put("monthonmonthAmount", monthonmonthAmount7.toString());
  2728. map8.put("monthonmonthAmount", monthonmonthAmount8.toString());
  2729. map9.put("monthonmonthAmount", monthonmonthAmount9.toString());
  2730. map10.put("monthonmonthAmount", monthonmonthAmount10.toString());
  2731. map11.put("monthonmonthAmount", monthonmonthAmount11.toString());
  2732. map12.put("monthonmonthAmount", monthonmonthAmount12.toString());
  2733. // 预算金额同比比 对比
  2734. BigDecimal yearonyearAmount1 = new BigDecimal(0.00);
  2735. BigDecimal yearonyearAmount2 = new BigDecimal(0.00);
  2736. BigDecimal yearonyearAmount3 = new BigDecimal(0.00);
  2737. BigDecimal yearonyearAmount4 = new BigDecimal(0.00);
  2738. BigDecimal yearonyearAmount5 = new BigDecimal(0.00);
  2739. BigDecimal yearonyearAmount6 = new BigDecimal(0.00);
  2740. BigDecimal yearonyearAmount7 = new BigDecimal(0.00);
  2741. BigDecimal yearonyearAmount8 = new BigDecimal(0.00);
  2742. BigDecimal yearonyearAmount9 = new BigDecimal(0.00);
  2743. BigDecimal yearonyearAmount10 = new BigDecimal(0.00);
  2744. BigDecimal yearonyearAmount11 = new BigDecimal(0.00);
  2745. BigDecimal yearonyearAmount12 = new BigDecimal(0.00);
  2746. if (!"0".equals(evaluationSumOld1)) {
  2747. yearonyearAmount1 = (evaluationSum111.subtract(evaluationSumOld111)).divide(evaluationSumOld1111, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2748. }
  2749. if (!"0".equals(evaluationSumOld2)) {
  2750. yearonyearAmount2 = (evaluationSum22.subtract(evaluationSumOld22)).divide(evaluationSumOld22, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2751. }
  2752. if (!"0".equals(evaluationSumOld3)) {
  2753. yearonyearAmount3 = (evaluationSum33.subtract(evaluationSumOld33)).divide(evaluationSumOld33, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2754. }
  2755. if (!"0".equals(evaluationSumOld4)) {
  2756. yearonyearAmount4 = (evaluationSum44.subtract(evaluationSumOld44)).divide(evaluationSumOld44, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2757. }
  2758. if (!"0".equals(evaluationSumOld5)) {
  2759. yearonyearAmount5 = (evaluationSum55.subtract(evaluationSumOld55)).divide(evaluationSumOld44, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2760. }
  2761. if (!"0".equals(evaluationSumOld6)) {
  2762. yearonyearAmount6 = (evaluationSum66.subtract(evaluationSumOld66)).divide(evaluationSumOld44, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2763. }
  2764. if (!"0".equals(evaluationSumOld7)) {
  2765. yearonyearAmount7 = (evaluationSum77.subtract(evaluationSumOld77)).divide(evaluationSumOld44, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2766. }
  2767. if (!"0".equals(evaluationSumOld8)) {
  2768. yearonyearAmount8 = (evaluationSum88.subtract(evaluationSumOld88)).divide(evaluationSumOld44, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2769. }
  2770. if (!"0".equals(evaluationSumOld9)) {
  2771. yearonyearAmount9 = (evaluationSum99.subtract(evaluationSumOld99)).divide(evaluationSumOld44, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2772. }
  2773. if (!"0".equals(evaluationSumOld10)) {
  2774. yearonyearAmount10 = (evaluationSum1010.subtract(evaluationSumOld1010)).divide(evaluationSumOld44, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2775. }
  2776. if (!"0".equals(evaluationSumOld11)) {
  2777. yearonyearAmount11 = (evaluationSum1111.subtract(evaluationSumOld1111)).divide(evaluationSumOld44, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2778. }
  2779. if (!"0".equals(evaluationSumOld12)) {
  2780. yearonyearAmount12 = (evaluationSum1212.subtract(evaluationSumOld1212)).divide(evaluationSumOld44, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2781. }
  2782. map1.put("yearonyearAmount", yearonyearAmount1.toString());
  2783. map2.put("yearonyearAmount", yearonyearAmount2.toString());
  2784. map3.put("yearonyearAmount", yearonyearAmount3.toString());
  2785. map4.put("yearonyearAmount", yearonyearAmount4.toString());
  2786. map5.put("yearonyearAmount", yearonyearAmount5.toString());
  2787. map6.put("yearonyearAmount", yearonyearAmount6.toString());
  2788. map7.put("yearonyearAmount", yearonyearAmount7.toString());
  2789. map8.put("yearonyearAmount", yearonyearAmount8.toString());
  2790. map9.put("yearonyearAmount", yearonyearAmount9.toString());
  2791. map10.put("yearonyearAmount", yearonyearAmount10.toString());
  2792. map11.put("yearonyearAmount", yearonyearAmount11.toString());
  2793. map12.put("yearonyearAmount", yearonyearAmount12.toString());
  2794. // 存入集合
  2795. mapReturn.add(map1);
  2796. mapReturn.add(map2);
  2797. mapReturn.add(map3);
  2798. mapReturn.add(map4);
  2799. mapReturn.add(map5);
  2800. mapReturn.add(map6);
  2801. mapReturn.add(map7);
  2802. mapReturn.add(map8);
  2803. mapReturn.add(map9);
  2804. mapReturn.add(map10);
  2805. mapReturn.add(map11);
  2806. mapReturn.add(map12);
  2807. }
  2808. return mapReturn;
  2809. }
  2810. //查询不同状态下的项目数据
  2811. public List<PmDemandResVo> getListByStatus(String projectStatus) {
  2812. LambdaQueryWrapper<PmDemand> lw = new LambdaQueryWrapper<PmDemand>();
  2813. lw.eq(PmDemand::getProjectStatus, projectStatus);
  2814. List<PmDemand> demandList = this.baseMapper.selectList(lw);
  2815. //数据转换
  2816. List<PmDemandResVo> pmDemandResponseVoList = new ArrayList<>();
  2817. if (!ObjectUtils.isEmpty(demandList) && demandList.size() > 0) {
  2818. pmDemandResponseVoList = demandChangeTo(demandList);
  2819. }
  2820. return pmDemandResponseVoList;
  2821. }
  2822. //字段转换and赋值
  2823. public List<PmDemandResVo> demandChangeTo(List<PmDemand> pmDemandList) {
  2824. List<PmDemandResVo> pmDemandResponseVoList = new ArrayList<>();
  2825. for (PmDemand pmDemand1 : pmDemandList) {
  2826. PmDemandResVo vo = new PmDemandResVo();
  2827. BeanUtils.copyProperties(pmDemand1, vo);
  2828. if (vo.getPurchaseDeptId() != null) {
  2829. Map<String, Object> deptMap = deptService.selectDeptById(vo.getPurchaseDeptId());
  2830. if (deptMap != null) {
  2831. SysDeptResponseVo sysDeptResponseVo = (SysDeptResponseVo) deptMap.get("sysDept");
  2832. if (sysDeptResponseVo != null) {
  2833. vo.setPurchaseDeptName(sysDeptResponseVo.getDeptName());
  2834. }
  2835. }
  2836. }
  2837. String purchaseServicesName = dictDataService.selectDictLabel("purchase_services", vo.getPurchaseServices());
  2838. if (StringUtils.isNotEmpty(purchaseServicesName)) {
  2839. vo.setPurchaseServicesName(purchaseServicesName);
  2840. }
  2841. //项目类型
  2842. for (ProjectTypes value : ProjectTypes.values()) {
  2843. if (vo.getProjectType() != null && vo.getProjectType().equals(value.getCode())) {
  2844. vo.setProjectTypeName(value.getInfo());
  2845. break;
  2846. }
  2847. }
  2848. //是否为超限额计划
  2849. for (IsExcess value : IsExcess.values()) {
  2850. if (vo.getIsExcess() != null && vo.getIsExcess().equals(value.getCode())) {
  2851. vo.setIsExcessName(value.getInfo());
  2852. break;
  2853. }
  2854. }
  2855. //采购方式
  2856. for (PlanPurchaseMode value : PlanPurchaseMode.values()) {
  2857. if (vo.getPurchaseMode() != null && vo.getPurchaseMode().equals(value.getCode())) {
  2858. vo.setPurchaseModeName(value.getInfo());
  2859. break;
  2860. }
  2861. }
  2862. //项目属性
  2863. for (ProjectAttribute value : ProjectAttribute.values()) {
  2864. if (vo.getProjectAttr() != null && vo.getProjectAttr().equals(value.getCode())) {
  2865. vo.setProjectAttrName(value.getInfo());
  2866. break;
  2867. }
  2868. }
  2869. //预警状态
  2870. for (WarnStatus value : WarnStatus.values()) {
  2871. if (vo.getWarnStatus() != null && vo.getWarnStatus().equals(value.getCode())) {
  2872. vo.setWarnStatusName(value.getInfo());
  2873. break;
  2874. }
  2875. }
  2876. //项目状态
  2877. for (PmProjectStatus value : PmProjectStatus.values()) {
  2878. if (vo.getProjectStatus() != null && vo.getProjectStatus().equals(value.getCode())) {
  2879. vo.setProjectStatusName(value.getInfo());
  2880. break;
  2881. }
  2882. }
  2883. try {
  2884. vo.setTipsMessage(pmDemandGetTips(vo.getPlanDeliverTime()));
  2885. if (vo.getTipsMessage().contains("超过")) {
  2886. vo.setIsExceedProject("1");
  2887. if (ObjectUtils.isEmpty(pmDemand1.getDelayReason())) {
  2888. //没有原因就可以填写滞后原因
  2889. vo.setIsWriteExceed("1");
  2890. }
  2891. }
  2892. } catch (ParseException e) {
  2893. e.printStackTrace();
  2894. }
  2895. pmDemandResponseVoList.add(vo);
  2896. }
  2897. return pmDemandResponseVoList;
  2898. }
  2899. /**
  2900. * 根据年度计划提报时间的阈值进行提示
  2901. *
  2902. * @return
  2903. */
  2904. public String pmDemandGetTips(Date planDeliverTime) throws ParseException {
  2905. if (!ObjectUtils.isEmpty(planDeliverTime)) {
  2906. //提示信息:定义距离结束时间一周内提示
  2907. Integer remindTine = 1000 * 60 * 60 * 24 * 7;
  2908. //少于一周便提醒
  2909. double surplus = planDeliverTime.getTime() - System.currentTimeMillis();
  2910. if (surplus < remindTine) {
  2911. int i = new Double(Math.ceil(surplus / 1000 / 60 / 60 / 24)).intValue();
  2912. //剩余天数(向上取整)
  2913. if (i > 0) {
  2914. return "距离计划交付时间不足" + i + "天";
  2915. } else {
  2916. return "已超过计划完成时间" + Math.abs(i) + "天";
  2917. }
  2918. }
  2919. }
  2920. return "";
  2921. }
  2922. /**
  2923. * 计算百分比:使用java.text.DecimalFormat实现
  2924. *
  2925. * @param x
  2926. * @param y
  2927. * @return
  2928. */
  2929. public static String getPercent(int x, int y) {
  2930. double d1 = x * 1.0;
  2931. double d2 = y * 1.0;
  2932. // 设置保留几位小数, “.”后面几个零就保留几位小数,这里设置保留2位小数
  2933. DecimalFormat decimalFormat = new DecimalFormat("##.00%");
  2934. return decimalFormat.format(d1 / d2);
  2935. }
  2936. }