PmDemandServiceImpl.java 109 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297
  1. package com.ozs.pm.service.impl;
  2. import java.math.BigDecimal;
  3. import java.text.DecimalFormat;
  4. import java.text.ParseException;
  5. import java.util.*;
  6. import java.util.stream.Collectors;
  7. import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
  8. import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
  9. import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
  10. import com.baomidou.mybatisplus.core.metadata.IPage;
  11. import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
  12. import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
  13. import com.ozs.base.domain.*;
  14. import com.ozs.base.domain.vo.BaseExpertVo;
  15. import com.ozs.base.service.*;
  16. import com.ozs.common.core.domain.AjaxResult;
  17. import com.ozs.common.core.domain.entity.SysDept;
  18. import com.ozs.common.core.domain.entity.SysDictData;
  19. import com.ozs.common.core.domain.entity.SysRole;
  20. import com.ozs.common.core.domain.entity.SysUser;
  21. import com.ozs.common.enums.*;
  22. import com.ozs.common.utils.DateUtils;
  23. import com.ozs.common.utils.RandomUtil;
  24. import com.ozs.common.utils.SecurityUtils;
  25. import com.ozs.common.utils.StringUtils;
  26. import com.ozs.common.utils.bean.BeanUtils;
  27. import com.ozs.home.domain.vo.HomeToDoQueryResVo;
  28. import com.ozs.plan.doman.vo.responseVo.PlanQuarterResponseVo;
  29. import com.ozs.plan.service.PlanYearsService;
  30. import com.ozs.pm.doman.*;
  31. import com.ozs.pm.doman.vo.requestVo.*;
  32. import com.ozs.pm.doman.vo.responseVo.*;
  33. import com.ozs.pm.mapper.PmDemandMapper;
  34. import com.ozs.pm.service.*;
  35. import com.ozs.system.domain.SysFileInfo;
  36. import com.ozs.system.domain.SysFileRef;
  37. import com.ozs.system.domain.vo.SysRegionVO;
  38. import com.ozs.system.domain.vo.responseVo.SysDeptResponseVo;
  39. import com.ozs.system.mapper.SysDeptMapper;
  40. import com.ozs.system.mapper.SysRoleMapper;
  41. import com.ozs.system.service.*;
  42. import io.swagger.models.auth.In;
  43. import org.springframework.beans.factory.annotation.Autowired;
  44. import org.springframework.stereotype.Service;
  45. import org.springframework.transaction.annotation.Transactional;
  46. import org.springframework.util.CollectionUtils;
  47. import org.springframework.util.ObjectUtils;
  48. /**
  49. * 采购需求Service业务层处理
  50. *
  51. * @author ruoyi
  52. * @date 2023-01-16
  53. */
  54. @Service
  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. /**
  107. * 查询采购需求
  108. *
  109. * @param demandId 采购需求主键
  110. * @return 采购需求
  111. */
  112. @Override
  113. public PmDemandResVo selectPmDemandByDemandId(Long demandId, String detailType) {
  114. PmDemand pmDemand = this.getById(demandId);
  115. if (pmDemand != null) {
  116. PmDemandResVo vo = new PmDemandResVo();
  117. vo.setProjectName(pmDemand.getProjectName());
  118. vo.setDemandId(demandId);
  119. if ("1".equals(detailType)) { //项目计划
  120. BeanUtils.copyProperties(pmDemand, vo);
  121. SysDeptResponseVo sysDeptResponseVo = (SysDeptResponseVo) deptService.selectDeptById(vo.getPurchaseDeptId()).get("sysDept");
  122. if (sysDeptResponseVo != null) {
  123. vo.setPurchaseDeptName(sysDeptResponseVo.getDeptName());
  124. }
  125. String purchaseServicesName = dictDataService.selectDictLabel("purchase_services", vo.getPurchaseServices());
  126. if (StringUtils.isNotEmpty(purchaseServicesName)) {
  127. vo.setPurchaseServicesName(purchaseServicesName);
  128. }
  129. //采购需求附件
  130. List<SysFileInfo> demandFileInfos = getSysFileInfoList(vo.getDemandId(), SysFileRefEnum.PM_DEMAND.getType());
  131. if (!ObjectUtils.isEmpty(demandFileInfos)) {
  132. vo.setDemandFileInfos(demandFileInfos);
  133. }
  134. //项目类型
  135. for (ProjectTypes value : ProjectTypes.values()) {
  136. if (vo.getProjectType() != null && vo.getProjectType().equals(value.getCode())) {
  137. vo.setProjectTypeName(value.getInfo());
  138. break;
  139. }
  140. }
  141. //是否为超限额计划
  142. for (IsExcess value : IsExcess.values()) {
  143. if (vo.getIsExcess() != null && vo.getIsExcess().equals(value.getCode())) {
  144. vo.setIsExcessName(value.getInfo());
  145. break;
  146. }
  147. }
  148. //采购方式
  149. for (PlanPurchaseMode value : PlanPurchaseMode.values()) {
  150. if (vo.getPurchaseMode() != null && vo.getPurchaseMode().equals(value.getCode())) {
  151. vo.setPurchaseModeName(value.getInfo());
  152. break;
  153. }
  154. }
  155. //项目属性
  156. for (ProjectAttribute value : ProjectAttribute.values()) {
  157. if (vo.getProjectAttr() != null && vo.getProjectAttr().equals(value.getCode())) {
  158. vo.setProjectAttrName(value.getInfo());
  159. break;
  160. }
  161. }
  162. //预警状态
  163. for (WarnStatus value : WarnStatus.values()) {
  164. if (vo.getWarnStatus() != null && vo.getWarnStatus().equals(value.getCode())) {
  165. vo.setWarnStatusName(value.getInfo());
  166. break;
  167. }
  168. }
  169. //项目状态
  170. for (PmProjectStatus value : PmProjectStatus.values()) {
  171. if (vo.getProjectStatus() != null && vo.getProjectStatus().equals(value.getCode())) {
  172. vo.setProjectStatusName(value.getInfo());
  173. break;
  174. }
  175. }
  176. } else if ("2".equals(detailType)) { //需求建档
  177. //采购需求审核文件
  178. List<SysFileInfo> auditFileInfos = getSysFileInfoList(vo.getDemandId(), SysFileRefEnum.PM_DEMAND_EXAMINE.getType());
  179. if (!ObjectUtils.isEmpty(auditFileInfos)) {
  180. vo.setAuditFileInfos(auditFileInfos);
  181. }
  182. LambdaQueryWrapper<PmBookBuilding> lambdaQueryWrapper = new LambdaQueryWrapper<>();
  183. lambdaQueryWrapper.eq(PmBookBuilding::getDemandId, demandId);
  184. PmBookBuilding pmBookBuilding = pmBookBuildingService.getOne(lambdaQueryWrapper);
  185. if (pmBookBuilding != null) {
  186. PmBookBuildingResVo responseVo = new PmBookBuildingResVo();
  187. BeanUtils.copyProperties(pmBookBuilding, responseVo);
  188. List<SysFileInfo> fileInfos = getSysFileInfoList(pmBookBuilding.getId(), SysFileRefEnum.PM_BOOK_BUILDING.getType());
  189. if (!ObjectUtils.isEmpty(fileInfos)) {
  190. responseVo.setFileInfos(fileInfos);
  191. }
  192. vo.setPmBookBuildingResVo(responseVo);
  193. }
  194. } else if ("3".equals(detailType)) { //任务下达
  195. //任务下达文件
  196. List<SysFileInfo> taskReleaseFileInfos = getSysFileInfoList(vo.getDemandId(), SysFileRefEnum.PM_TAST_RELEASE.getType());
  197. if (!ObjectUtils.isEmpty(taskReleaseFileInfos)) {
  198. vo.setTaskReleaseFileInfos(taskReleaseFileInfos);
  199. }
  200. } else if ("4".equals(detailType)) { //中标信息
  201. PmPurchaseExecutionResVo pmPurchaseExecutionResVo = new PmPurchaseExecutionResVo();
  202. //代理商信息
  203. BaseAgency baseAgency = this.baseAgencyService.getById(pmDemand.getAgencyId());
  204. pmPurchaseExecutionResVo.setBaseAgency(baseAgency);
  205. //发布公告列表
  206. LambdaQueryWrapper<PmReleaseAnnouncement> lambdaQueryWrapper = new LambdaQueryWrapper<>();
  207. lambdaQueryWrapper.eq(PmReleaseAnnouncement::getDemandId, demandId);
  208. List<PmReleaseAnnouncement> pmReleaseAnnouncementList = this.pmReleaseAnnouncementService.list(lambdaQueryWrapper);
  209. if (!ObjectUtils.isEmpty(pmReleaseAnnouncementList)) {
  210. List<PmReleaseAnnouncementResVo> pmReleaseAnnouncementResVoList = new ArrayList<>();
  211. for (PmReleaseAnnouncement pmReleaseAnnouncement : pmReleaseAnnouncementList) {
  212. PmReleaseAnnouncementResVo pmReleaseAnnouncementResVo = new PmReleaseAnnouncementResVo();
  213. BeanUtils.copyProperties(pmReleaseAnnouncement, pmReleaseAnnouncementResVo);
  214. List<SysFileInfo> fileInfos = getSysFileInfoList(pmReleaseAnnouncement.getId(), SysFileRefEnum.PM_ANNOUNCEMENT_FILE.getType());
  215. if (!ObjectUtils.isEmpty(fileInfos)) {
  216. pmReleaseAnnouncementResVo.setFileInfos(fileInfos);
  217. }
  218. pmReleaseAnnouncementResVoList.add(pmReleaseAnnouncementResVo);
  219. }
  220. pmPurchaseExecutionResVo.setPmReleaseAnnouncementResVoList(pmReleaseAnnouncementResVoList);
  221. }
  222. //专家信息列表
  223. List<PmBaseExpertResVo> pmBaseExpertResVoList = this.pmDemandExpertRefService.getPmBaseExpertResVoList(demandId);
  224. pmPurchaseExecutionResVo.setPmBaseExpertResVoList(pmBaseExpertResVoList);
  225. //开标信息列表
  226. List<PmBidOpeningResVo> pmBidOpeningResVoList = this.pmBidOpeningService.getPmBidOpeningResVoList(demandId);
  227. pmPurchaseExecutionResVo.setPmBidOpeningResVoList(pmBidOpeningResVoList);
  228. //中标信息列表
  229. LambdaQueryWrapper<PmBidWinning> lambdaQueryWrapper1 = new LambdaQueryWrapper<>();
  230. lambdaQueryWrapper1.eq(PmBidWinning::getDemandId, demandId)
  231. .eq(PmBidWinning::getStatus, BidWinningStatus.NORMAL.getCode());
  232. PmBidWinning pmBidWinning = this.pmBidWinningService.getOne(lambdaQueryWrapper1);
  233. if (!ObjectUtils.isEmpty(pmBidWinning)) {
  234. LambdaQueryWrapper<PmBidWinningOpeningRef> lambdaQueryWrapper2 = new LambdaQueryWrapper<>();
  235. lambdaQueryWrapper2.eq(PmBidWinningOpeningRef::getWinningId, pmBidWinning.getId())
  236. .eq(PmBidWinningOpeningRef::getStatus, BidWinningStatus.NORMAL.getCode());
  237. List<PmBidWinningOpeningRef> pmBidWinningOpeningRefList = this.pmBidWinningOpeningRefService.list(lambdaQueryWrapper2);
  238. if (!ObjectUtils.isEmpty(pmBidWinningOpeningRefList)) {
  239. List<PmBidWinningResVo> pmBidWinningResVoList = new ArrayList<>();
  240. for (PmBidWinningOpeningRef pmBidWinningOpeningRef : pmBidWinningOpeningRefList) {
  241. PmBidOpening pmBidOpening = this.pmBidOpeningService.getById(pmBidWinningOpeningRef.getOpeningId());
  242. if (pmBidOpening != null) {
  243. PmBidWinningResVo pmBidWinningResVo = new PmBidWinningResVo();
  244. BeanUtils.copyProperties(pmBidWinning, pmBidWinningResVo);
  245. pmBidWinningResVo.setBidWinningName(pmBidOpening.getBidderName());
  246. List<SysFileInfo> fileInfos = getSysFileInfoList(pmBidWinning.getId(), SysFileRefEnum.PM_BID_WINNING_FILE.getType());
  247. if (!ObjectUtils.isEmpty(fileInfos)) {
  248. pmBidWinningResVo.setFileInfos(fileInfos);
  249. }
  250. pmBidWinningResVoList.add(pmBidWinningResVo);
  251. }
  252. }
  253. pmPurchaseExecutionResVo.setPmBidWinningResVoList(pmBidWinningResVoList);
  254. }
  255. }
  256. pmPurchaseExecutionResVo.setCallQuestion(pmDemand.getCallQuestion());
  257. //质疑情况
  258. List<SysFileInfo> callRequestFileInfos = getSysFileInfoList(vo.getDemandId(), SysFileRefEnum.PM_BID_CALL_QEUSTION_FILE.getType());
  259. if (!ObjectUtils.isEmpty(callRequestFileInfos)) {
  260. pmPurchaseExecutionResVo.setCallRequestFileInfos(callRequestFileInfos);
  261. }
  262. //流标情况
  263. LambdaQueryWrapper<PmBidFailure> lambdaQueryWrapper2 = new LambdaQueryWrapper<>();
  264. lambdaQueryWrapper2.eq(PmBidFailure::getDemandId, demandId).orderByDesc(PmBidFailure::getBidFailureTime);
  265. List<PmBidFailure> pmBidFailureList = this.pmBidFailureService.list(lambdaQueryWrapper2);
  266. if (!ObjectUtils.isEmpty(pmBidFailureList)) {
  267. List<PmBidFailureResVo> pmBidFailureResVoList = new ArrayList<>();
  268. for (PmBidFailure pmBidFailure : pmBidFailureList) {
  269. PmBidFailureResVo pmBidFailureResVo = new PmBidFailureResVo();
  270. BeanUtils.copyProperties(pmBidFailure, pmBidFailureResVo);
  271. List<SysFileInfo> fileInfos = getSysFileInfoList(pmBidFailure.getId(), SysFileRefEnum.PM_BID_FAILURE_FILE.getType());
  272. if (!ObjectUtils.isEmpty(fileInfos)) {
  273. pmPurchaseExecutionResVo.setFileInfos(fileInfos);
  274. }
  275. pmBidFailureResVoList.add(pmBidFailureResVo);
  276. }
  277. pmPurchaseExecutionResVo.setPmBidFailureResVoList(pmBidFailureResVoList);
  278. }
  279. //中标通知书
  280. List<SysFileInfo> pmBidWinningNotificationFileInfos = getSysFileInfoList(vo.getDemandId(), SysFileRefEnum.PM_BID_WINNING_NOTIFICATION.getType());
  281. if (!ObjectUtils.isEmpty(pmBidWinningNotificationFileInfos)) {
  282. pmPurchaseExecutionResVo.setPmBidWinningNotificationFileInfos(pmBidWinningNotificationFileInfos);
  283. }
  284. vo.setPmPurchaseExecutionResVo(pmPurchaseExecutionResVo);
  285. } else if ("5".equals(detailType)) { //合同信息
  286. LambdaQueryWrapper<PmContractInfo> lambdaQueryWrapper = new LambdaQueryWrapper<>();
  287. lambdaQueryWrapper.eq(PmContractInfo::getDemandId, demandId);
  288. PmContractInfo pmContractInfo = pmContractInfoService.getOne(lambdaQueryWrapper);
  289. if (pmContractInfo != null) {
  290. PmContractInfoResVo pmContractInfoResVo = new PmContractInfoResVo();
  291. BeanUtils.copyProperties(pmContractInfo, pmContractInfoResVo);
  292. //合同信息文件
  293. List<SysFileInfo> fileInfos = getSysFileInfoList(pmContractInfo.getId(), SysFileRefEnum.PM_CONTRACT_INFO.getType());
  294. if (!ObjectUtils.isEmpty(fileInfos)) {
  295. pmContractInfoResVo.setFileInfos(fileInfos);
  296. }
  297. vo.setPmContractInfoResVo(pmContractInfoResVo);
  298. }
  299. } else if ("6".equals(detailType)) { //建设情况
  300. LambdaQueryWrapper<PmProjectConstruction> lambdaQueryWrapper = new LambdaQueryWrapper<>();
  301. lambdaQueryWrapper.eq(PmProjectConstruction::getDemandId, demandId);
  302. PmProjectConstruction pmProjectConstruction = pmProjectConstructionService.getOne(lambdaQueryWrapper);
  303. if (pmProjectConstruction != null) {
  304. PmProjectConstructionResVo pmProjectConstructionResVo = new PmProjectConstructionResVo();
  305. BeanUtils.copyProperties(pmProjectConstruction, pmProjectConstructionResVo);
  306. //建设情况文件
  307. List<SysFileInfo> fileInfos = getSysFileInfoList(pmProjectConstruction.getId(), SysFileRefEnum.PM_PROJECT_CONSTRUCTION.getType());
  308. if (!ObjectUtils.isEmpty(fileInfos)) {
  309. pmProjectConstructionResVo.setFileInfos(fileInfos);
  310. }
  311. vo.setPmProjectConstructionResVo(pmProjectConstructionResVo);
  312. }
  313. }
  314. return vo;
  315. } else {
  316. return null;
  317. }
  318. }
  319. /**
  320. * 查询采购需求列表
  321. *
  322. * @param pmDemandReqVo
  323. * @return 采购需求
  324. */
  325. @Override
  326. public IPage<PmDemandResVo> selectPmDemandList(PmDemandReqVo pmDemandReqVo, int reqType) {
  327. LambdaQueryWrapper<PmDemand> lw = new LambdaQueryWrapper<>();
  328. /*******************权限代码***********************/
  329. SysUser sysUser = userService.selectUserById(SecurityUtils.getUserId());
  330. Long deptId = sysUser.getDeptId();
  331. //获取登录用户的角色
  332. List<SysRole> sysRoles = sysRoleMapper.selectRolePermissionByUserId(SecurityUtils.getUserId());
  333. //获取属于求单位管理员的列表
  334. List<SysRole> sysRoleList2 = sysRoles.stream().filter(tdto -> tdto.getRoleKey().equals(SysRoleKey.DEMAND_UNIT.getCode())).collect(Collectors.toList());
  335. if (!ObjectUtils.isEmpty(sysRoleList2)) { //属于需求单位管理员
  336. lw.apply("(purchase_dept_id = " + deptId + ")");
  337. } else {
  338. //获取属于采购管理部门管理员 或 采购办管理员的列表
  339. List<SysRole> sysRoleList = sysRoles.stream().filter(tdto -> (tdto.getRoleKey().equals(SysRoleKey.PURCHASING_MANAGEMENT.getCode())
  340. || tdto.getRoleKey().equals(SysRoleKey.PROCUREMENT_OFFICE.getCode()))).collect(Collectors.toList());
  341. if (!ObjectUtils.isEmpty(sysRoleList)) { //属于采购管理部门管理员 或 采购办管理员
  342. //获取子部门列表
  343. List<SysDept> sysDeptSubs = deptMapper.selectChildrenDeptById(sysUser.getDeptId());
  344. String sysDeptSubStr = null;
  345. if (!ObjectUtils.isEmpty(sysDeptSubs)) {
  346. List<String> sysDeptSubIds = sysDeptSubs.stream().map(SysDept::getDeptId).collect(Collectors.toList())
  347. .stream().map(x -> x + "").collect(Collectors.toList());
  348. sysDeptSubStr = String.join(",", sysDeptSubIds);
  349. }
  350. String condtionSql = null;
  351. if (ObjectUtils.isEmpty(sysDeptSubStr)) {
  352. condtionSql = "(purchase_dept_id = " + deptId + " AND is_excess = 0) ";
  353. } else {
  354. condtionSql = "((purchase_dept_id = " + deptId + " AND is_excess = 0) " +
  355. " OR (purchase_dept_id IN (" + sysDeptSubStr + ") AND is_excess = 1))";
  356. }
  357. lw.apply(condtionSql);
  358. }
  359. }
  360. /*******************权限代码end***********************/
  361. if (!StringUtils.isBlank(pmDemandReqVo.getProjectName())) {
  362. lw.like(PmDemand::getProjectName, "%" + pmDemandReqVo.getProjectName() + "%");
  363. }
  364. if (!StringUtils.isBlank(pmDemandReqVo.getPurchaseServices())) {
  365. lw.eq(PmDemand::getPurchaseServices, pmDemandReqVo.getPurchaseServices());
  366. }
  367. if (!ObjectUtils.isEmpty(pmDemandReqVo.getProjectStatus())) {
  368. lw.eq(PmDemand::getProjectStatus, pmDemandReqVo.getProjectStatus());
  369. }
  370. if (!ObjectUtils.isEmpty(pmDemandReqVo.getWarnStatus())) {
  371. lw.eq(PmDemand::getWarnStatus, pmDemandReqVo.getWarnStatus());
  372. }
  373. if (!ObjectUtils.isEmpty(pmDemandReqVo.getIsExcess())) {
  374. lw.eq(PmDemand::getIsExcess, pmDemandReqVo.getIsExcess());
  375. }
  376. if (!StringUtils.isBlank(pmDemandReqVo.getBeginDate())) {
  377. lw.apply("(plan_demand_sub_time >= '" + pmDemandReqVo.getBeginDate() + "' or plan_purchase_finish_time >= '" + pmDemandReqVo.getBeginDate() + "' or plan_deliver_time >= '" + pmDemandReqVo.getBeginDate() + "' )");
  378. }
  379. if (!StringUtils.isBlank(pmDemandReqVo.getEndDate())) {
  380. lw.apply("(plan_demand_sub_time <= '" + pmDemandReqVo.getEndDate() + "' or plan_purchase_finish_time <= '" + pmDemandReqVo.getEndDate() + "' or plan_deliver_time <= '" + pmDemandReqVo.getEndDate() + "' )");
  381. }
  382. if (reqType == 1) { //需求审核单位列表
  383. lw.apply("(project_status = 6 or project_status = 8 )");
  384. } else if (reqType == 2) { //任务下达列表
  385. lw.apply("(project_status = 8 or project_status = 9 )");
  386. } else if (reqType == 3) { //采购执行列表
  387. 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)");
  388. } else if (reqType == 4) { //合同信息列表
  389. lw.apply("(project_status = 15 or project_status = 16 )");
  390. } else if (reqType == 5) { //项目建设列表
  391. lw.apply("(project_status = 16 or project_status = 17 )");
  392. }
  393. lw.last(" order by project_status, plan_demand_sub_time");
  394. IPage<PmDemand> pageRes = this.page(new Page<>(pmDemandReqVo.getPageNum(), pmDemandReqVo.getPageSize()), lw);
  395. IPage<PmDemandResVo> results = new Page<>(pageRes.getCurrent(), pageRes.getSize(), pageRes.getTotal());
  396. if (pageRes.getRecords() != null && pageRes.getRecords().size() > 0) {
  397. List<PmDemandResVo> pmDemandResVos = demandChangeTo(pageRes.getRecords());
  398. results.setRecords(pmDemandResVos);
  399. }
  400. return results;
  401. }
  402. /**
  403. * 需求建档
  404. *
  405. * @param vo 采购需求
  406. * @return 结果
  407. */
  408. @Override
  409. @Transactional(rollbackFor = Exception.class)
  410. public boolean bookBuilding(PmBookBuildingReqVo vo) throws Exception {
  411. PmDemand pmDemand = this.getById(vo.getDemandId());
  412. LambdaQueryWrapper<PmBookBuilding> lambdaQueryWrapper = new LambdaQueryWrapper<>();
  413. lambdaQueryWrapper.eq(PmBookBuilding::getDemandId, vo.getDemandId());
  414. PmBookBuilding pmBookBuilding = pmBookBuildingService.getOne(lambdaQueryWrapper);
  415. if (pmBookBuilding != null) {
  416. vo.setId(pmBookBuilding.getId());
  417. BeanUtils.copyProperties(vo, pmBookBuilding);
  418. pmBookBuilding.setUpdateBy(vo.getUpdateBy());
  419. pmBookBuilding.setUpdateTime(new Date());
  420. } else {
  421. pmBookBuilding = new PmBookBuilding();
  422. BeanUtils.copyProperties(vo, pmBookBuilding);
  423. pmBookBuilding.setCreateBy(vo.getUpdateBy());
  424. pmBookBuilding.setCreateTime(new Date());
  425. pmBookBuilding.setUpdateBy(vo.getUpdateBy());
  426. pmBookBuilding.setUpdateTime(pmBookBuilding.getCreateTime());
  427. }
  428. if (pmBookBuildingService.saveOrUpdate(pmBookBuilding)) {
  429. List<SysFileRef> sysFileRefs = vo.getSysFileRefs();
  430. uploadFile(pmBookBuilding.getId(), SysFileRefEnum.PM_BOOK_BUILDING.getType(), sysFileRefs, vo.getUpdateBy());
  431. pmDemand.setProjectStatus(PmProjectStatus.DEMAND_WAIT_COMMIT.getCode());
  432. pmDemand.setUpdateBy(vo.getUpdateBy());
  433. pmDemand.setUpdateTime(DateUtils.getNowDate());
  434. return this.updateById(pmDemand);
  435. } else {
  436. return false;
  437. }
  438. }
  439. private List<SysFileInfo> getSysFileInfoList(Long redId, Integer type) {
  440. HashMap<String, Object> map = new HashMap<>();
  441. map.put("red_id", redId);
  442. map.put("type", type);
  443. List<SysFileRef> fileRefs = sysFileRefService.listByMap(map);
  444. if (!ObjectUtils.isEmpty(fileRefs)) {
  445. List<SysFileInfo> fileInfos = new ArrayList<>();
  446. for (SysFileRef ref : fileRefs) {
  447. SysFileInfo fileInfo = fileService.getById(ref.getFileId());
  448. fileInfos.add(fileInfo);
  449. }
  450. return fileInfos;
  451. } else {
  452. return null;
  453. }
  454. }
  455. /**
  456. * 查看流程图
  457. *
  458. * @param demandId 采购需求主键
  459. * @return 采购需求
  460. */
  461. @Override
  462. public Object viewFlowChart(Long demandId) {
  463. PmDemand pmDemand = this.getById(demandId);
  464. String projectStatus = String.valueOf(pmDemand.getProjectStatus());
  465. String moduleName = null;
  466. if (PmProjectStatus.DEMAND_WAIT_FILL.getCode().equals(projectStatus) || PmProjectStatus.DEMAND_AUDIT_RETURN.getCode().equals(projectStatus)) {
  467. moduleName = "需求填制";
  468. } else if (PmProjectStatus.DEMAND_WAIT_COMMIT.getCode().equals(projectStatus)) {
  469. moduleName = "需求提交";
  470. } else if (PmProjectStatus.DEMAND_WAIT_AUDIT.getCode().equals(projectStatus)) {
  471. moduleName = "需求审核";
  472. } else if (PmProjectStatus.TASK_WAIT_RELEASE.getCode().equals(projectStatus)) {
  473. moduleName = "任务下达";
  474. } else if (PmProjectStatus.WAIT_SELECT_AGENT.getCode().equals(projectStatus)) {
  475. moduleName = "选取代理";
  476. } else if (PmProjectStatus.WAIT_UPLOAD_BID_FILE.getCode().equals(projectStatus)) {
  477. moduleName = "上传招标文件";
  478. } else if (PmProjectStatus.WAIT_ANNOUNCEMENT.getCode().equals(projectStatus)) {
  479. moduleName = "发布公告";
  480. } else if (PmProjectStatus.WAIT_OPEN_BID.getCode().equals(projectStatus)) {
  481. moduleName = "填写专家信息,填写开标信息";
  482. } else if (PmProjectStatus.WAIT_BID_ANNOUNCEMENT.getCode().equals(projectStatus)) {
  483. moduleName = "填写中标信息";
  484. } else if (PmProjectStatus.BIDDING_PUBLICITY.getCode().equals(projectStatus)) {
  485. moduleName = "质疑处理,上传中标通知书";
  486. } else if (PmProjectStatus.CONTRACT_WAIT_FILL.getCode().equals(projectStatus)) {
  487. moduleName = "合同填制";
  488. } else if (PmProjectStatus.UNDER_CONSTRUCTION.getCode().equals(projectStatus)) {
  489. moduleName = "建设文档填制";
  490. } else if (PmProjectStatus.COMPLETION_CONSTRUCTION.getCode().equals(projectStatus)) {
  491. moduleName = "项目归档";
  492. }
  493. return moduleName;
  494. }
  495. @Override
  496. public PmFlowChartResVo getModuleInfo(Long demandId, String moduleName) {
  497. LambdaQueryWrapper<PmFlowChart> lambdaQueryWrapper = new LambdaQueryWrapper<>();
  498. lambdaQueryWrapper.eq(PmFlowChart::getModuleName, moduleName);
  499. PmFlowChart pmFlowChart = iPmFlowChartService.getOne(lambdaQueryWrapper);
  500. if (pmFlowChart == null) {
  501. return null;
  502. }
  503. PmFlowChartResVo vo = new PmFlowChartResVo();
  504. BeanUtils.copyProperties(pmFlowChart, vo);
  505. if ("需求填制".equals(moduleName)) {
  506. List<SysFileInfo> fileInfos = getSysFileInfoList(demandId, SysFileRefEnum.PM_DEMAND.getType());
  507. if (!ObjectUtils.isEmpty(fileInfos)) {
  508. vo.setFileInfos(fileInfos);
  509. }
  510. } else if ("需求提交".equals(moduleName)) {
  511. LambdaQueryWrapper<PmBookBuilding> pmBookBuildingLambdaQueryWrapper = new LambdaQueryWrapper<>();
  512. pmBookBuildingLambdaQueryWrapper.eq(PmBookBuilding::getDemandId, demandId);
  513. PmBookBuilding pmBookBuilding = pmBookBuildingService.getOne(pmBookBuildingLambdaQueryWrapper);
  514. if (pmBookBuilding != null) {
  515. List<SysFileInfo> fileInfos = getSysFileInfoList(pmBookBuilding.getId(), SysFileRefEnum.PM_BOOK_BUILDING.getType());
  516. if (!ObjectUtils.isEmpty(fileInfos)) {
  517. vo.setFileInfos(fileInfos);
  518. }
  519. }
  520. } else if ("需求审核".equals(moduleName)) {
  521. List<SysFileInfo> fileInfos = getSysFileInfoList(demandId, SysFileRefEnum.PM_DEMAND_EXAMINE.getType());
  522. if (!ObjectUtils.isEmpty(fileInfos)) {
  523. vo.setFileInfos(fileInfos);
  524. }
  525. } else if ("任务下达".equals(moduleName)) {
  526. List<SysFileInfo> fileInfos = getSysFileInfoList(demandId, SysFileRefEnum.PM_TAST_RELEASE.getType());
  527. if (!ObjectUtils.isEmpty(fileInfos)) {
  528. vo.setFileInfos(fileInfos);
  529. }
  530. } else if ("选取代理".equals(moduleName)) {
  531. //do nothing
  532. } else if ("上传招标文件".equals(moduleName)) {
  533. List<SysFileInfo> fileInfos = getSysFileInfoList(demandId, SysFileRefEnum.PM_BID_FILE.getType());
  534. if (!ObjectUtils.isEmpty(fileInfos)) {
  535. vo.setFileInfos(fileInfos);
  536. }
  537. } else if ("发布公告".equals(moduleName)) {
  538. LambdaQueryWrapper<PmReleaseAnnouncement> pmReleaseAnnouncementLambdaQueryWrapper = new LambdaQueryWrapper<>();
  539. pmReleaseAnnouncementLambdaQueryWrapper.eq(PmReleaseAnnouncement::getDemandId, demandId);
  540. List<PmReleaseAnnouncement> pmReleaseAnnouncementList = pmReleaseAnnouncementService.list(pmReleaseAnnouncementLambdaQueryWrapper);
  541. if (!ObjectUtils.isEmpty(pmReleaseAnnouncementList)) {
  542. List<SysFileInfo> listAll = new ArrayList<>();
  543. for (PmReleaseAnnouncement pmReleaseAnnouncement : pmReleaseAnnouncementList) {
  544. List<SysFileInfo> fileInfos = getSysFileInfoList(pmReleaseAnnouncement.getId(), SysFileRefEnum.PM_ANNOUNCEMENT_FILE.getType());
  545. if (!ObjectUtils.isEmpty(fileInfos)) {
  546. listAll.addAll(fileInfos);
  547. }
  548. }
  549. if (!ObjectUtils.isEmpty(listAll)) {
  550. vo.setFileInfos(listAll);
  551. }
  552. }
  553. } else if ("填写专家信息".equals(moduleName)) {
  554. //do nothing
  555. } else if ("填写开标信息".equals(moduleName)) {
  556. //do nothing
  557. } else if ("填写中标信息".equals(moduleName)) {
  558. List<SysFileInfo> listAll = new ArrayList<>();
  559. LambdaQueryWrapper<PmBidWinning> pmBidWinningLambdaQueryWrapper = new LambdaQueryWrapper<>();
  560. pmBidWinningLambdaQueryWrapper.eq(PmBidWinning::getDemandId, demandId);
  561. List<PmBidWinning> pmBidWinningList = pmBidWinningService.list(pmBidWinningLambdaQueryWrapper);
  562. if (!ObjectUtils.isEmpty(pmBidWinningList)) {
  563. for (PmBidWinning pmBidWinning : pmBidWinningList) {
  564. List<SysFileInfo> fileInfos = getSysFileInfoList(pmBidWinning.getId(), SysFileRefEnum.PM_BID_WINNING_FILE.getType());
  565. if (!ObjectUtils.isEmpty(fileInfos)) {
  566. listAll.addAll(fileInfos);
  567. }
  568. }
  569. }
  570. LambdaQueryWrapper<PmBidFailure> pmBidFailureLambdaQueryWrapper = new LambdaQueryWrapper<>();
  571. pmBidFailureLambdaQueryWrapper.eq(PmBidFailure::getDemandId, demandId);
  572. List<PmBidFailure> pmBidFailureList = pmBidFailureService.list(pmBidFailureLambdaQueryWrapper);
  573. if (!ObjectUtils.isEmpty(pmBidFailureService)) {
  574. for (PmBidFailure pmBidFailure : pmBidFailureList) {
  575. List<SysFileInfo> fileInfos = getSysFileInfoList(pmBidFailure.getId(), SysFileRefEnum.PM_BID_FAILURE_FILE.getType());
  576. if (!ObjectUtils.isEmpty(fileInfos)) {
  577. listAll.addAll(fileInfos);
  578. }
  579. }
  580. }
  581. if (!ObjectUtils.isEmpty(listAll)) {
  582. vo.setFileInfos(listAll);
  583. }
  584. } else if ("质疑处理".equals(moduleName)) {
  585. List<SysFileInfo> fileInfos = getSysFileInfoList(demandId, SysFileRefEnum.PM_BID_CALL_QEUSTION_FILE.getType());
  586. if (!ObjectUtils.isEmpty(fileInfos)) {
  587. vo.setFileInfos(fileInfos);
  588. }
  589. } else if ("上传中标通知书".equals(moduleName)) {
  590. List<SysFileInfo> fileInfos = getSysFileInfoList(demandId, SysFileRefEnum.PM_BID_WINNING_NOTIFICATION.getType());
  591. if (!ObjectUtils.isEmpty(fileInfos)) {
  592. vo.setFileInfos(fileInfos);
  593. }
  594. } else if ("合同填制".equals(moduleName)) {
  595. LambdaQueryWrapper<PmContractInfo> pmContractInfoLambdaQueryWrapper = new LambdaQueryWrapper<>();
  596. pmContractInfoLambdaQueryWrapper.eq(PmContractInfo::getDemandId, demandId);
  597. PmContractInfo pmContractInfo = pmContractInfoService.getOne(pmContractInfoLambdaQueryWrapper);
  598. if (pmContractInfo != null) {
  599. List<SysFileInfo> fileInfos = getSysFileInfoList(pmContractInfo.getId(), SysFileRefEnum.PM_CONTRACT_INFO.getType());
  600. if (!ObjectUtils.isEmpty(fileInfos)) {
  601. vo.setFileInfos(fileInfos);
  602. }
  603. }
  604. } else if ("建设文档填制".equals(moduleName)) {
  605. LambdaQueryWrapper<PmProjectConstruction> pmProjectConstructionLambdaQueryWrapper = new LambdaQueryWrapper<>();
  606. pmProjectConstructionLambdaQueryWrapper.eq(PmProjectConstruction::getDemandId, demandId);
  607. PmProjectConstruction pmProjectConstruction = pmProjectConstructionService.getOne(pmProjectConstructionLambdaQueryWrapper);
  608. if (pmProjectConstruction != null) {
  609. List<SysFileInfo> fileInfos = getSysFileInfoList(pmProjectConstruction.getId(), SysFileRefEnum.PM_PROJECT_CONSTRUCTION.getType());
  610. if (!ObjectUtils.isEmpty(fileInfos)) {
  611. vo.setFileInfos(fileInfos);
  612. }
  613. }
  614. } else if ("项目归档".equals(moduleName)) {
  615. //do nothing
  616. }
  617. return vo;
  618. }
  619. /**
  620. * 提交采购需求
  621. *
  622. * @param pmDemandReqVo
  623. * @return 结果
  624. */
  625. @Override
  626. @Transactional(rollbackFor = Exception.class)
  627. public boolean commit(PmDemandReqVo pmDemandReqVo) {
  628. PmDemand pmDemand = new PmDemand();
  629. pmDemand.setDemandId(pmDemandReqVo.getDemandId());
  630. pmDemand.setProjectStatus(PmProjectStatus.DEMAND_WAIT_AUDIT.getCode());
  631. pmDemand.setRealDemandCommitTime(DateUtils.getNowDate());
  632. pmDemand.setUpdateBy(pmDemandReqVo.getUpdateBy());
  633. pmDemand.setUpdateTime(DateUtils.getNowDate());
  634. return this.updateById(pmDemand);
  635. }
  636. /**
  637. * 审核采购需求通过
  638. *
  639. * @param pmDemandReqVo
  640. * @return 结果
  641. */
  642. @Override
  643. @Transactional(rollbackFor = Exception.class)
  644. public boolean reviewTo(PmDemandReqVo pmDemandReqVo) {
  645. PmDemand pmDemand = new PmDemand();
  646. pmDemand.setDemandId(pmDemandReqVo.getDemandId());
  647. pmDemand.setProjectStatus(PmProjectStatus.TASK_WAIT_RELEASE.getCode());
  648. List<SysFileRef> sysFileRefs = pmDemandReqVo.getSysFileRefs();
  649. uploadFile(pmDemandReqVo.getDemandId(), SysFileRefEnum.PM_DEMAND_EXAMINE.getType(), sysFileRefs, pmDemandReqVo.getUpdateBy());
  650. pmDemand.setUpdateBy(pmDemandReqVo.getUpdateBy());
  651. pmDemand.setUpdateTime(DateUtils.getNowDate());
  652. pmDemand.setAuditTime(DateUtils.getNowDate());
  653. return this.updateById(pmDemand);
  654. }
  655. /**
  656. * 审核采购需求退回
  657. *
  658. * @param pmDemandReqVo
  659. * @return 结果
  660. */
  661. @Override
  662. @Transactional(rollbackFor = Exception.class)
  663. public boolean reviewReturn(PmDemandReqVo pmDemandReqVo) {
  664. UpdateWrapper<PmDemand> updateWrapper = new UpdateWrapper<>();
  665. updateWrapper.lambda().eq(PmDemand::getDemandId, pmDemandReqVo.getDemandId())
  666. .set(PmDemand::getProjectStatus, PmProjectStatus.DEMAND_AUDIT_RETURN.getCode())
  667. .set(PmDemand::getAdjustReason, pmDemandReqVo.getRefuseReason())
  668. .set(PmDemand::getRealDemandCommitTime, null)
  669. .set(PmDemand::getUpdateBy, pmDemandReqVo.getUpdateBy())
  670. .set(PmDemand::getUpdateTime, DateUtils.getNowDate())
  671. .set(PmDemand::getAuditTime, DateUtils.getNowDate());
  672. return this.update(updateWrapper);
  673. }
  674. /**
  675. * 下达任务
  676. *
  677. * @param pmDemandReqVo
  678. * @return 结果
  679. */
  680. @Override
  681. @Transactional(rollbackFor = Exception.class)
  682. public boolean releaseTask(PmDemandReqVo pmDemandReqVo) {
  683. PmDemand pmDemand = new PmDemand();
  684. pmDemand.setDemandId(pmDemandReqVo.getDemandId());
  685. pmDemand.setProjectStatus(PmProjectStatus.WAIT_SELECT_AGENT.getCode());
  686. List<SysFileRef> sysFileRefs = pmDemandReqVo.getSysFileRefs();
  687. uploadFile(pmDemandReqVo.getDemandId(), SysFileRefEnum.PM_TAST_RELEASE.getType(), sysFileRefs, pmDemandReqVo.getUpdateBy());
  688. pmDemand.setUpdateBy(pmDemandReqVo.getUpdateBy());
  689. pmDemand.setUpdateTime(DateUtils.getNowDate());
  690. pmDemand.setAuditTime(DateUtils.getNowDate());
  691. return this.updateById(pmDemand);
  692. }
  693. @Override
  694. @Transactional(rollbackFor = Exception.class)
  695. public boolean uploadFile(Long redId, Integer fileType, List<SysFileRef> sysFileRefs, String upateBy) {
  696. if (!ObjectUtils.isEmpty(sysFileRefs)) {
  697. //删除老的
  698. QueryWrapper<SysFileRef> queryWrapper = new QueryWrapper<>();
  699. queryWrapper.lambda().eq(SysFileRef::getRedId, redId)
  700. .eq(SysFileRef::getType, fileType);
  701. List<SysFileRef> sysFileRefList = sysFileRefService.list(queryWrapper);
  702. if (!CollectionUtils.isEmpty(sysFileRefList)) {
  703. sysFileRefService.remove(queryWrapper);
  704. }
  705. //添加新的
  706. for (SysFileRef ref : sysFileRefs) {
  707. if (ref.getFileId() == null) {
  708. continue;
  709. }
  710. ref.setRedId(redId);
  711. ref.setType(fileType);
  712. ref.setCreated(upateBy);
  713. ref.setCreateTime(new Date());
  714. ref.setUpdated(upateBy);
  715. ref.setUpdateTime(ref.getCreateTime());
  716. sysFileRefService.save(ref);
  717. }
  718. return true;
  719. } else {
  720. return false;
  721. }
  722. }
  723. @Override
  724. @Transactional(rollbackFor = Exception.class)
  725. public boolean insertPmReleaseAnnouncement(PmReleaseAnnouncementReqVo pmReleaseAnnouncementReqVo) throws Exception {
  726. PmDemand pmDemand = this.getById(pmReleaseAnnouncementReqVo.getDemandId());
  727. if (ObjectUtils.isEmpty(pmDemand)) {
  728. throw new Exception("参数错误");
  729. }
  730. if (ObjectUtils.isEmpty(pmReleaseAnnouncementReqVo.getSysFileRefs())) {
  731. throw new Exception("上传附件不能为空");
  732. }
  733. PmReleaseAnnouncement pmReleaseAnnouncement = new PmReleaseAnnouncement();
  734. BeanUtils.copyProperties(pmReleaseAnnouncementReqVo, pmReleaseAnnouncement);
  735. if (pmReleaseAnnouncementService.saveOrUpdate(pmReleaseAnnouncement)) {
  736. uploadFile(pmReleaseAnnouncement.getId(), SysFileRefEnum.PM_ANNOUNCEMENT_FILE.getType(), pmReleaseAnnouncementReqVo.getSysFileRefs(), pmReleaseAnnouncementReqVo.getUpdateBy());
  737. PmDemand pmDemandUpdate = new PmDemand();
  738. pmDemandUpdate.setDemandId(pmReleaseAnnouncementReqVo.getDemandId());
  739. pmDemandUpdate.setProjectStatus(PmProjectStatus.WAIT_OPEN_BID.getCode());
  740. pmDemandUpdate.setUpdateTime(pmReleaseAnnouncementReqVo.getUpdateTime());
  741. pmDemandUpdate.setUpdateBy(pmReleaseAnnouncementReqVo.getUpdateBy());
  742. if (this.updateById(pmDemandUpdate)) {
  743. //发布公告生成后,会默认将该数据同步到公告管理和首页中
  744. BaseNotice baseNotice = new BaseNotice();
  745. baseNotice.setName(pmDemand.getProjectName());
  746. baseNotice.setTitle(pmDemand.getProjectName() + "招标公告");
  747. LambdaQueryWrapper<BaseNoticeType> lambdaQueryWrapper = new LambdaQueryWrapper<>();
  748. lambdaQueryWrapper.eq(BaseNoticeType::getName, "招标公告");
  749. BaseNoticeType baseNoticeType = baseNoticeTypeService.getOne(lambdaQueryWrapper);
  750. if (baseNoticeType == null) {
  751. throw new Exception("招标公告 公告类型不存在");
  752. }
  753. baseNotice.setType(baseNoticeType.getId());
  754. baseNotice.setReleaseTime(pmReleaseAnnouncement.getReleaseTime());
  755. return this.baseNoticeService.saveOrUpdate(baseNotice);
  756. } else {
  757. return false;
  758. }
  759. } else {
  760. return false;
  761. }
  762. }
  763. @Override
  764. @Transactional(rollbackFor = Exception.class)
  765. public boolean insertExpertBatch(PmBaseExpertFillReqVo pmBaseExpertFillReqVo) throws Exception {
  766. PmDemand pmDemand = this.getById(pmBaseExpertFillReqVo.getDemandId());
  767. if (ObjectUtils.isEmpty(pmDemand)) {
  768. throw new Exception("参数错误");
  769. }
  770. List<BaseExpert> baseExpertList = pmBaseExpertFillReqVo.getBaseExpertList();
  771. if (ObjectUtils.isEmpty(baseExpertList)) {
  772. throw new Exception("参数错误");
  773. }
  774. Date now = new Date();
  775. for (BaseExpert baseExpert : baseExpertList) {
  776. if (NameListType.BLACK.getCode().equals(baseExpert.getStatus())) {
  777. throw new Exception("该专家(身份证号:" + baseExpert.getIdNumber() + ")属于黑名单");
  778. } else {
  779. if (ObjectUtils.isEmpty(baseExpert.getStatus())) {
  780. baseExpert.setStatus(NameListType.WHITE.getCode());
  781. }
  782. }
  783. if (ObjectUtils.isEmpty(baseExpert.getVarietyPurchase()) || !baseExpert.getVarietyPurchase().contains(pmDemand.getProjectType())) {
  784. throw new Exception("该专家(身份证号:" + baseExpert.getIdNumber() + ")所属采购品种和项目类型不匹配");
  785. }
  786. if (ObjectUtils.isEmpty(baseExpert.getCreated())) {
  787. baseExpert.setCreated(pmBaseExpertFillReqVo.getCreateBy());
  788. baseExpert.setCreateTime(now);
  789. }
  790. if (ObjectUtils.isEmpty(baseExpert.getUpdated())) {
  791. baseExpert.setUpdated(pmBaseExpertFillReqVo.getUpdateBy());
  792. baseExpert.setUpdateTime(now);
  793. }
  794. if (baseExpertService.saveOrUpdate(baseExpert)) {
  795. LambdaQueryWrapper<PmDemandExpertRef> pmDemandExpertRefLambdaQueryWrapper = new LambdaQueryWrapper<>();
  796. pmDemandExpertRefLambdaQueryWrapper.eq(PmDemandExpertRef::getDemandId, pmDemand.getDemandId())
  797. .eq(PmDemandExpertRef::getExpertId, baseExpert.getId().longValue())
  798. .eq(PmDemandExpertRef::getAccessTime, pmBaseExpertFillReqVo.getAccessTime());
  799. PmDemandExpertRef pmDemandExpertRef = pmDemandExpertRefService.getOne(pmDemandExpertRefLambdaQueryWrapper);
  800. if (pmDemandExpertRef == null) {
  801. pmDemandExpertRef = new PmDemandExpertRef();
  802. pmDemandExpertRef.setCreateBy(pmBaseExpertFillReqVo.getCreateBy());
  803. pmDemandExpertRef.setCreateTime(now);
  804. }
  805. pmDemandExpertRef.setDemandId(pmDemand.getDemandId());
  806. pmDemandExpertRef.setExpertId(baseExpert.getId().longValue());
  807. pmDemandExpertRef.setAccessTime(DateUtils.parseDate(pmBaseExpertFillReqVo.getAccessTime()));
  808. pmDemandExpertRef.setUpdateBy(pmBaseExpertFillReqVo.getCreateBy());
  809. pmDemandExpertRef.setUpdateTime(pmDemandExpertRef.getCreateTime());
  810. pmDemandExpertRefService.saveOrUpdate(pmDemandExpertRef);
  811. }
  812. }
  813. return true;
  814. }
  815. @Override
  816. @Transactional(rollbackFor = Exception.class)
  817. public boolean extractExpertBatch(PmBaseExpertExtractReqVo pmBaseExpertExtractReqVo) throws Exception {
  818. Integer technicalExpertNumber = pmBaseExpertExtractReqVo.getTechnicalExpertNumber();
  819. if (technicalExpertNumber == null) {
  820. technicalExpertNumber = 0;
  821. }
  822. Integer economicExpertNumber = pmBaseExpertExtractReqVo.getEconomicExpertNumber();
  823. if (economicExpertNumber == null) {
  824. economicExpertNumber = 0;
  825. }
  826. Integer legalAffairsExpertNumber = pmBaseExpertExtractReqVo.getLegalAffairsExpertNumber();
  827. if (legalAffairsExpertNumber == null) {
  828. legalAffairsExpertNumber = 0;
  829. }
  830. Integer spareExpertNumber = pmBaseExpertExtractReqVo.getSpareExpertNumber();
  831. if (spareExpertNumber == null) {
  832. spareExpertNumber = 0;
  833. }
  834. String professional = pmBaseExpertExtractReqVo.getProfessional();
  835. if (spareExpertNumber > 0 && ObjectUtils.isEmpty(professional)) {
  836. throw new Exception("抽取备用专家必须选择专家专业");
  837. }
  838. PmDemand pmDemand = this.getById(pmBaseExpertExtractReqVo.getDemandId());
  839. if (ObjectUtils.isEmpty(pmDemand)) {
  840. throw new Exception("参数错误");
  841. }
  842. String needAvoidUnit = pmBaseExpertExtractReqVo.getNeedAvoidUnit();
  843. List<String> needAvoidUnitList = null;
  844. if (!ObjectUtils.isEmpty(needAvoidUnit)) {
  845. String[] arr = needAvoidUnit.split(",");
  846. needAvoidUnitList = Arrays.asList(arr);
  847. }
  848. String localArea = pmBaseExpertExtractReqVo.getLocalArea();
  849. List<String> sysRegionCodeList = new ArrayList<>();
  850. if (!ObjectUtils.isEmpty(localArea)) {
  851. if (!StringUtils.isNumeric(localArea)) {
  852. throw new Exception("地域必须传数字代码");
  853. }
  854. sysRegionCodeList.add(localArea);
  855. //找到该地域code对应的子列表
  856. List<SysRegionVO> sysRegionVOList = iSysRegionService.findChildDivisions(localArea);
  857. if (!ObjectUtils.isEmpty(sysRegionVOList)) {
  858. for (SysRegionVO vo : sysRegionVOList) {
  859. sysRegionCodeList.add(vo.getCode());
  860. }
  861. }
  862. }
  863. //从专家库中查询符合项目类型的以及是白名单的全部列表
  864. LambdaQueryWrapper<BaseExpert> lw = new LambdaQueryWrapper<>();
  865. lw.eq(BaseExpert::getVarietyPurchase, pmDemand.getProjectType())
  866. .eq(BaseExpert::getStatus, NameListType.WHITE.getCode())
  867. .notIn(!ObjectUtils.isEmpty(needAvoidUnitList), BaseExpert::getUnitInformation, needAvoidUnitList)
  868. .in(!ObjectUtils.isEmpty(sysRegionCodeList), BaseExpert::getLocalArea, sysRegionCodeList);
  869. List<BaseExpert> baseExpertList = baseExpertService.list(lw);
  870. if (ObjectUtils.isEmpty(baseExpertList)) {
  871. throw new Exception("没抽取到符合条件的专家");
  872. }
  873. //从列表中挑出来各个类型的子列表
  874. List<BaseExpert> technicalExpertList = new ArrayList<>();
  875. List<BaseExpert> economicExpertList = new ArrayList<>();
  876. List<BaseExpert> legalAffairsExpertList = new ArrayList<>();
  877. List<BaseExpert> spareExpertList = new ArrayList<>();
  878. for (BaseExpert baseExpert : baseExpertList) {
  879. if (technicalExpertNumber > 0) {
  880. if (baseExpert.getExpertType().contains(ExpertType.TECHNICAL_EXPERT.getCode())) {
  881. technicalExpertList.add(baseExpert);
  882. }
  883. }
  884. if (economicExpertNumber > 0) {
  885. if (baseExpert.getExpertType().contains(ExpertType.ECONOMIC_EXPERT.getCode())) {
  886. economicExpertList.add(baseExpert);
  887. }
  888. }
  889. if (legalAffairsExpertNumber > 0) {
  890. if (baseExpert.getExpertType().contains(ExpertType.LEGALAFFAIRS_EXPERT.getCode())) {
  891. legalAffairsExpertList.add(baseExpert);
  892. }
  893. }
  894. if (spareExpertNumber > 0) {
  895. String[] arr = professional.split(",");
  896. List<String> professionalList = Arrays.asList(arr);
  897. String majorType = baseExpert.getMajorType();
  898. if (!ObjectUtils.isEmpty(majorType)) {
  899. String[] arr2 = majorType.split(",");
  900. List<String> majorTypeList = Arrays.asList(arr2);
  901. if (hasIntersection(professionalList, majorTypeList)) {
  902. spareExpertList.add(baseExpert);
  903. }
  904. }
  905. }
  906. }
  907. //从子列表中随机抽取符合数据量的
  908. List<BaseExpert> alltExpertList = new ArrayList<>();
  909. if (!ObjectUtils.isEmpty(technicalExpertList)) {
  910. alltExpertList.addAll(RandomUtil.getRandomList(technicalExpertList, technicalExpertNumber));
  911. }
  912. if (!ObjectUtils.isEmpty(economicExpertList)) {
  913. alltExpertList.addAll(RandomUtil.getRandomList(economicExpertList, economicExpertNumber));
  914. }
  915. if (!ObjectUtils.isEmpty(legalAffairsExpertList)) {
  916. alltExpertList.addAll(RandomUtil.getRandomList(legalAffairsExpertList, legalAffairsExpertNumber));
  917. }
  918. if (!ObjectUtils.isEmpty(spareExpertList)) {
  919. alltExpertList.addAll(RandomUtil.getRandomList(spareExpertList, spareExpertNumber));
  920. }
  921. if (ObjectUtils.isEmpty(alltExpertList)) {
  922. throw new Exception("没抽取到符合条件的专家");
  923. } else {
  924. List<PmDemandExpertRef> pmDemandExpertRefList = new ArrayList<>();
  925. for (BaseExpert baseExpert : alltExpertList) {
  926. LambdaQueryWrapper<PmDemandExpertRef> baseExpertLambdaQueryWrapper = new LambdaQueryWrapper<>();
  927. baseExpertLambdaQueryWrapper.eq(PmDemandExpertRef::getExpertId, baseExpert.getId().longValue())
  928. .eq(PmDemandExpertRef::getDemandId, pmDemand.getDemandId())
  929. .eq(PmDemandExpertRef::getAccessTime, pmBaseExpertExtractReqVo.getAccessTime());
  930. PmDemandExpertRef pmDemandExpertRef = pmDemandExpertRefService.getOne(baseExpertLambdaQueryWrapper);
  931. if (pmDemandExpertRef == null) {
  932. pmDemandExpertRef = new PmDemandExpertRef();
  933. pmDemandExpertRef.setCreateBy(pmBaseExpertExtractReqVo.getCreateBy());
  934. pmDemandExpertRef.setCreateTime(new Date());
  935. }
  936. pmDemandExpertRef.setDemandId(pmDemand.getDemandId());
  937. pmDemandExpertRef.setExpertId(baseExpert.getId().longValue());
  938. pmDemandExpertRef.setAccessTime(DateUtils.parseDate(pmBaseExpertExtractReqVo.getAccessTime()));
  939. pmDemandExpertRef.setUpdateBy(pmBaseExpertExtractReqVo.getCreateBy());
  940. pmDemandExpertRef.setUpdateTime(pmDemandExpertRef.getCreateTime());
  941. pmDemandExpertRefList.add(pmDemandExpertRef);
  942. }
  943. return pmDemandExpertRefService.saveOrUpdateBatch(pmDemandExpertRefList);
  944. }
  945. }
  946. //二个列表是否有交集
  947. private boolean hasIntersection(List<String> professionalList, List<String> majorTypeList) {
  948. for (String professiona : professionalList) {
  949. for (String majorType : majorTypeList) {
  950. if (professiona.equals(majorType)) {
  951. return true;
  952. }
  953. }
  954. }
  955. return false;
  956. }
  957. @Override
  958. @Transactional(rollbackFor = Exception.class)
  959. public boolean insertBidOpeningBatch(PmBidOpeningFillReqVo pmBidOpeningFillReqVo) throws Exception {
  960. PmDemand pmDemand = this.getById(pmBidOpeningFillReqVo.getDemandId());
  961. if (ObjectUtils.isEmpty(pmDemand)) {
  962. throw new Exception("参数错误");
  963. }
  964. //从发布公告里获取开标时间
  965. LambdaQueryWrapper<PmReleaseAnnouncement> lw = new LambdaQueryWrapper<>();
  966. lw.eq(PmReleaseAnnouncement::getDemandId, pmDemand.getDemandId()).orderByDesc(PmReleaseAnnouncement::getReleaseTime)
  967. .last(" limit 1 ");
  968. PmReleaseAnnouncement pmReleaseAnnouncement = this.pmReleaseAnnouncementService.getOne(lw);
  969. if (pmReleaseAnnouncement == null) {
  970. throw new Exception("发布公告不存在");
  971. }
  972. Date tenderOpenTime = pmReleaseAnnouncement.getTenderOpenTime();
  973. Date now = new Date();
  974. List<PmBidOpening> pmBidOpeningList = pmBidOpeningFillReqVo.getPmBidOpeningList();
  975. for (PmBidOpening pmBidOpening : pmBidOpeningList) {
  976. if (ObjectUtils.isEmpty(pmBidOpening.getBidderName())) {
  977. throw new Exception("投标人名称不能为空");
  978. }
  979. if (ObjectUtils.isEmpty(pmBidOpening.getScore())) {
  980. throw new Exception("分数不能为空");
  981. }
  982. pmBidOpening.setOpenBidTime(tenderOpenTime);
  983. pmBidOpening.setDemandId(pmBidOpeningFillReqVo.getDemandId());
  984. pmBidOpening.setCreateBy(pmBidOpeningFillReqVo.getCreateBy());
  985. pmBidOpening.setCreateTime(now);
  986. pmBidOpening.setUpdateBy(pmBidOpeningFillReqVo.getUpdateBy());
  987. pmBidOpening.setUpdateTime(now);
  988. }
  989. if (pmBidOpeningService.saveOrUpdateBatch(pmBidOpeningList)) {
  990. PmDemand pmDemandUpdate = new PmDemand();
  991. pmDemandUpdate.setDemandId(pmDemand.getDemandId());
  992. pmDemandUpdate.setProjectStatus(PmProjectStatus.WAIT_BID_ANNOUNCEMENT.getCode());
  993. pmDemandUpdate.setUpdateTime(now);
  994. pmDemandUpdate.setUpdateBy(pmBidOpeningFillReqVo.getUpdateBy());
  995. return this.updateById(pmDemandUpdate);
  996. } else {
  997. return false;
  998. }
  999. }
  1000. /**
  1001. * 填写中标
  1002. *
  1003. * @param pmBidWinningReqVo
  1004. * @return
  1005. * @throws Exception
  1006. */
  1007. @Override
  1008. @Transactional(rollbackFor = Exception.class)
  1009. public boolean insertPmBidWinning(PmBidWinningReqVo pmBidWinningReqVo) throws Exception {
  1010. List<Long> pmBidOpeningIdList = pmBidWinningReqVo.getPmBidOpeningIdList();
  1011. if (ObjectUtils.isEmpty(pmBidWinningReqVo.getBidWinningAmount())) {
  1012. throw new Exception("中标金额不能为空");
  1013. }
  1014. if (ObjectUtils.isEmpty(pmBidOpeningIdList)) {
  1015. throw new Exception("中标单位信息列表不能为空");
  1016. }
  1017. if (ObjectUtils.isEmpty(pmBidWinningReqVo.getSysFileRefs())) {
  1018. throw new Exception("上传附件不能为空");
  1019. }
  1020. PmBidWinning pmBidWinning = new PmBidWinning();
  1021. BeanUtils.copyProperties(pmBidWinningReqVo, pmBidWinning);
  1022. //修改老的中标信息状态
  1023. if (ObjectUtils.isEmpty(pmBidWinningReqVo.getId())) { //属于新增
  1024. LambdaQueryWrapper<PmBidWinning> pmBidWinningLambdaQueryWrapper = new LambdaQueryWrapper<>();
  1025. pmBidWinningLambdaQueryWrapper.eq(PmBidWinning::getDemandId, pmBidWinningReqVo.getDemandId())
  1026. .eq(PmBidWinning::getStatus, BidWinningStatus.NORMAL.getCode());
  1027. List<PmBidWinning> pmBidWinninglist = pmBidWinningService.list(pmBidWinningLambdaQueryWrapper);
  1028. if (!ObjectUtils.isEmpty(pmBidWinninglist)) {
  1029. for (PmBidWinning item : pmBidWinninglist) {
  1030. UpdateWrapper<PmBidWinning> updateWrapper1 = new UpdateWrapper<>();
  1031. updateWrapper1.lambda().set(PmBidWinning::getStatus, BidWinningStatus.BE_REPLACED.getCode())
  1032. .eq(PmBidWinning::getId, item.getId());
  1033. pmBidWinningService.update(updateWrapper1);
  1034. UpdateWrapper<PmBidWinningOpeningRef> updateWrapper2 = new UpdateWrapper<>();
  1035. updateWrapper2.lambda().set(PmBidWinningOpeningRef::getStatus, BidWinningStatus.BE_REPLACED.getCode())
  1036. .eq(PmBidWinningOpeningRef::getWinningId, item.getId())
  1037. .eq(PmBidWinningOpeningRef::getStatus, BidWinningStatus.NORMAL.getCode());
  1038. pmBidWinningOpeningRefService.update(updateWrapper2);
  1039. }
  1040. }
  1041. }
  1042. if (pmBidWinningService.saveOrUpdate(pmBidWinning)) {
  1043. List<PmBidWinningOpeningRef> pmBidWinningOpeningRefList = new ArrayList<>();
  1044. for (Long pmBidOpeningId : pmBidOpeningIdList) {
  1045. LambdaQueryWrapper<PmBidWinningOpeningRef> pmBidWinningOpeningRefLambdaQueryWrapper = new LambdaQueryWrapper<>();
  1046. pmBidWinningOpeningRefLambdaQueryWrapper.eq(PmBidWinningOpeningRef::getOpeningId, pmBidOpeningId)
  1047. .eq(PmBidWinningOpeningRef::getWinningId, pmBidWinning.getId());
  1048. PmBidWinningOpeningRef pmBidWinningOpeningRef = pmBidWinningOpeningRefService.getOne(pmBidWinningOpeningRefLambdaQueryWrapper);
  1049. if (pmBidWinningOpeningRef == null) {
  1050. pmBidWinningOpeningRef = new PmBidWinningOpeningRef();
  1051. pmBidWinningOpeningRef.setCreateBy(pmBidWinningReqVo.getCreateBy());
  1052. pmBidWinningOpeningRef.setCreateTime(pmBidWinningReqVo.getCreateTime());
  1053. }
  1054. pmBidWinningOpeningRef.setOpeningId(pmBidOpeningId);
  1055. pmBidWinningOpeningRef.setWinningId(pmBidWinning.getId());
  1056. pmBidWinningOpeningRef.setUpdateBy(pmBidWinningReqVo.getUpdateBy());
  1057. pmBidWinningOpeningRef.setUpdateTime(pmBidWinningReqVo.getUpdateTime());
  1058. pmBidWinningOpeningRefList.add(pmBidWinningOpeningRef);
  1059. }
  1060. if (pmBidWinningOpeningRefService.saveOrUpdateBatch(pmBidWinningOpeningRefList)) {
  1061. uploadFile(pmBidWinning.getId(), SysFileRefEnum.PM_BID_WINNING_FILE.getType(), pmBidWinningReqVo.getSysFileRefs(), pmBidWinningReqVo.getUpdateBy());
  1062. //发布公告生成后,会默认将该数据同步到公告管理和首页中
  1063. PmDemand pmDemand = this.getById(pmBidWinningReqVo.getDemandId());
  1064. BaseNotice baseNotice = new BaseNotice();
  1065. baseNotice.setName(pmDemand.getProjectName());
  1066. baseNotice.setTitle(pmDemand.getProjectName() + "中标公告");
  1067. LambdaQueryWrapper<BaseNoticeType> lambdaQueryWrapper = new LambdaQueryWrapper<>();
  1068. lambdaQueryWrapper.eq(BaseNoticeType::getName, "中标公告");
  1069. BaseNoticeType baseNoticeType = baseNoticeTypeService.getOne(lambdaQueryWrapper);
  1070. if (baseNoticeType == null) {
  1071. throw new Exception("中标公告 公告类型不存在");
  1072. }
  1073. baseNotice.setType(baseNoticeType.getId());
  1074. baseNotice.setReleaseTime(pmBidWinningReqVo.getBidAnnouncementTime());
  1075. this.baseNoticeService.saveOrUpdate(baseNotice);
  1076. PmDemand pmDemandUpdate = new PmDemand();
  1077. pmDemandUpdate.setDemandId(pmBidWinningReqVo.getDemandId());
  1078. pmDemandUpdate.setProjectStatus(PmProjectStatus.BIDDING_PUBLICITY.getCode());
  1079. pmDemandUpdate.setUpdateTime(pmBidWinningReqVo.getUpdateTime());
  1080. pmDemandUpdate.setUpdateBy(pmBidWinningReqVo.getUpdateBy());
  1081. return this.updateById(pmDemandUpdate);
  1082. } else {
  1083. return false;
  1084. }
  1085. } else {
  1086. return false;
  1087. }
  1088. }
  1089. @Override
  1090. @Transactional(rollbackFor = Exception.class)
  1091. public boolean updatePmBidWinning(PmBidWinningReqVo pmBidWinningReqVo) throws Exception {
  1092. List<Long> pmBidOpeningIdList = pmBidWinningReqVo.getPmBidOpeningIdList();
  1093. if (ObjectUtils.isEmpty(pmBidOpeningIdList)) {
  1094. throw new Exception("中标单位信息列表不能为空");
  1095. }
  1096. if (ObjectUtils.isEmpty(pmBidWinningReqVo.getBidWinningAmount())) {
  1097. throw new Exception("中标金额不能为空");
  1098. }
  1099. if (ObjectUtils.isEmpty(pmBidWinningReqVo.getSysFileRefs())) {
  1100. throw new Exception("上传附件不能为空");
  1101. }
  1102. LambdaQueryWrapper<PmBidWinning> lw = new LambdaQueryWrapper<>();
  1103. lw.eq(PmBidWinning::getDemandId, pmBidWinningReqVo.getDemandId()).eq(PmBidWinning::getStatus, BidWinningStatus.NORMAL.getCode());
  1104. List<PmBidWinning> pmBidWinninglist = pmBidWinningService.list(lw);
  1105. if (ObjectUtils.isEmpty(pmBidWinninglist)) {
  1106. throw new Exception("原中标信息不存在");
  1107. }
  1108. //修改老的状态
  1109. for (PmBidWinning item : pmBidWinninglist) {
  1110. UpdateWrapper<PmBidWinning> updateWrapper1 = new UpdateWrapper<>();
  1111. updateWrapper1.lambda().set(PmBidWinning::getStatus, BidWinningStatus.BE_REPLACED.getCode())
  1112. .eq(PmBidWinning::getId, item.getId());
  1113. pmBidWinningService.update(updateWrapper1);
  1114. UpdateWrapper<PmBidWinningOpeningRef> updateWrapper2 = new UpdateWrapper<>();
  1115. updateWrapper2.lambda().set(PmBidWinningOpeningRef::getStatus, BidWinningStatus.BE_REPLACED.getCode())
  1116. .eq(PmBidWinningOpeningRef::getWinningId, item.getId())
  1117. .eq(PmBidWinningOpeningRef::getStatus, BidWinningStatus.NORMAL.getCode());
  1118. pmBidWinningOpeningRefService.update(updateWrapper2);
  1119. }
  1120. //新增
  1121. PmBidWinning pmBidWinning = new PmBidWinning();
  1122. BeanUtils.copyProperties(pmBidWinninglist.get(0), pmBidWinning);
  1123. pmBidWinning.setId(null);
  1124. pmBidWinning.setBidWinningAmount(pmBidWinningReqVo.getBidWinningAmount());
  1125. pmBidWinning.setStatus(BidWinningStatus.NORMAL.getCode());
  1126. pmBidWinning.setUpdateBy(pmBidWinningReqVo.getUpdateBy());
  1127. pmBidWinning.setUpdateTime(pmBidWinningReqVo.getUpdateTime());
  1128. if (pmBidWinningService.save(pmBidWinning)) {
  1129. List<PmBidWinningOpeningRef> pmBidWinningOpeningRefList = new ArrayList<>();
  1130. for (Long pmBidOpeningId : pmBidOpeningIdList) {
  1131. PmBidWinningOpeningRef pmBidWinningOpeningRef = new PmBidWinningOpeningRef();
  1132. pmBidWinningOpeningRef.setOpeningId(pmBidOpeningId);
  1133. pmBidWinningOpeningRef.setWinningId(pmBidWinning.getId());
  1134. pmBidWinningOpeningRef.setStatus(BidWinningStatus.NORMAL.getCode());
  1135. pmBidWinningOpeningRef.setCreateBy(pmBidWinningReqVo.getCreateBy());
  1136. pmBidWinningOpeningRef.setCreateTime(pmBidWinningReqVo.getCreateTime());
  1137. pmBidWinningOpeningRef.setUpdateBy(pmBidWinningReqVo.getUpdateBy());
  1138. pmBidWinningOpeningRef.setUpdateTime(pmBidWinningReqVo.getUpdateTime());
  1139. pmBidWinningOpeningRefList.add(pmBidWinningOpeningRef);
  1140. }
  1141. LambdaQueryWrapper<SysFileRef> sysFileRefLambdaQueryWrapper = new LambdaQueryWrapper<>();
  1142. sysFileRefLambdaQueryWrapper.eq(SysFileRef::getType, SysFileRefEnum.PM_BID_WINNING_FILE.getType())
  1143. .eq(SysFileRef::getRedId, pmBidWinninglist.get(0));
  1144. List<SysFileRef> sysFileRefs = sysFileRefService.list(sysFileRefLambdaQueryWrapper);
  1145. uploadFile(pmBidWinning.getId(), SysFileRefEnum.PM_BID_WINNING_FILE.getType(), sysFileRefs, pmBidWinningReqVo.getUpdateBy());
  1146. return pmBidWinningOpeningRefService.saveBatch(pmBidWinningOpeningRefList);
  1147. } else {
  1148. return false;
  1149. }
  1150. }
  1151. /**
  1152. * 流标
  1153. *
  1154. * @param pmBidFailureReqVo
  1155. * @return
  1156. * @throws Exception
  1157. */
  1158. @Override
  1159. @Transactional(rollbackFor = Exception.class)
  1160. public boolean insertPmBidFailure(PmBidFailureReqVo pmBidFailureReqVo) throws Exception {
  1161. PmBidFailure pmBidFailure = new PmBidFailure();
  1162. BeanUtils.copyProperties(pmBidFailureReqVo, pmBidFailure);
  1163. if (pmBidFailureService.saveOrUpdate(pmBidFailure)) {
  1164. //把中标信息修改状态
  1165. LambdaQueryWrapper<PmBidWinning> lw = new LambdaQueryWrapper<>();
  1166. lw.eq(PmBidWinning::getDemandId, pmBidFailureReqVo.getDemandId()).eq(PmBidWinning::getStatus, BidWinningStatus.NORMAL.getCode());
  1167. List<PmBidWinning> pmBidWinninglist = pmBidWinningService.list(lw);
  1168. if (!ObjectUtils.isEmpty(pmBidWinninglist)) {
  1169. for (PmBidWinning item : pmBidWinninglist) {
  1170. UpdateWrapper<PmBidWinning> updateWrapper1 = new UpdateWrapper<>();
  1171. updateWrapper1.lambda().set(PmBidWinning::getStatus, BidWinningStatus.BE_BID_FAILURE.getCode())
  1172. .eq(PmBidWinning::getId, item.getId());
  1173. pmBidWinningService.update(updateWrapper1);
  1174. UpdateWrapper<PmBidWinningOpeningRef> updateWrapper2 = new UpdateWrapper<>();
  1175. updateWrapper2.lambda().set(PmBidWinningOpeningRef::getStatus, BidWinningStatus.BE_BID_FAILURE.getCode())
  1176. .eq(PmBidWinningOpeningRef::getWinningId, item.getId())
  1177. .eq(PmBidWinningOpeningRef::getStatus, BidWinningStatus.NORMAL.getCode());
  1178. pmBidWinningOpeningRefService.update(updateWrapper2);
  1179. }
  1180. }
  1181. uploadFile(pmBidFailure.getId(), SysFileRefEnum.PM_BID_FAILURE_FILE.getType(), pmBidFailureReqVo.getSysFileRefs(), pmBidFailureReqVo.getUpdateBy());
  1182. //发布公告生成后,会默认将该数据同步到公告管理和首页中
  1183. PmDemand pmDemand = this.getById(pmBidFailureReqVo.getDemandId());
  1184. BaseNotice baseNotice = new BaseNotice();
  1185. baseNotice.setName(pmDemand.getProjectName());
  1186. baseNotice.setTitle(pmDemand.getProjectName() + "流标公告");
  1187. LambdaQueryWrapper<BaseNoticeType> lambdaQueryWrapper = new LambdaQueryWrapper<>();
  1188. lambdaQueryWrapper.eq(BaseNoticeType::getName, "流标公告");
  1189. BaseNoticeType baseNoticeType = baseNoticeTypeService.getOne(lambdaQueryWrapper);
  1190. if (baseNoticeType == null) {
  1191. throw new Exception("流标公告 公告类型不存在");
  1192. }
  1193. baseNotice.setType(baseNoticeType.getId());
  1194. baseNotice.setReleaseTime(pmBidFailureReqVo.getBidFailureTime());
  1195. this.baseNoticeService.saveOrUpdate(baseNotice);
  1196. PmDemand pmDemandUpdate = new PmDemand();
  1197. pmDemandUpdate.setDemandId(pmBidFailureReqVo.getDemandId());
  1198. pmDemandUpdate.setProjectStatus(PmProjectStatus.WAIT_ANNOUNCEMENT.getCode());
  1199. pmDemandUpdate.setUpdateTime(pmBidFailureReqVo.getUpdateTime());
  1200. pmDemandUpdate.setUpdateBy(pmBidFailureReqVo.getUpdateBy());
  1201. return this.updateById(pmDemandUpdate);
  1202. } else {
  1203. return false;
  1204. }
  1205. }
  1206. @Override
  1207. @Transactional(rollbackFor = Exception.class)
  1208. public boolean insertContractInfo(PmContractInfoReqVo pmContractInfoReqVo) throws Exception {
  1209. Long demandId = pmContractInfoReqVo.getDemandId();
  1210. if (ObjectUtils.isEmpty(demandId)) {
  1211. throw new Exception("采购需求ID不能为空");
  1212. }
  1213. PmDemand pmDemand = this.getById(demandId);
  1214. if (ObjectUtils.isEmpty(pmDemand)) {
  1215. throw new Exception("采购需求ID错误");
  1216. }
  1217. List<SysFileRef> sysFileRefs = pmContractInfoReqVo.getSysFileRefs();
  1218. if (ObjectUtils.isEmpty(sysFileRefs)) {
  1219. throw new Exception("上传附件不能为空");
  1220. }
  1221. LambdaQueryWrapper<PmContractInfo> lambdaQueryWrapper = new LambdaQueryWrapper<>();
  1222. lambdaQueryWrapper.eq(PmContractInfo::getDemandId, demandId);
  1223. PmContractInfo pmContractInfo = pmContractInfoService.getOne(lambdaQueryWrapper);
  1224. if (pmContractInfo != null) {
  1225. pmContractInfoReqVo.setId(pmContractInfo.getId());
  1226. BeanUtils.copyProperties(pmContractInfoReqVo, pmContractInfo);
  1227. pmContractInfo.setUpdateTime(pmContractInfoReqVo.getUpdateTime());
  1228. pmContractInfo.setUpdateBy(pmContractInfoReqVo.getUpdateBy());
  1229. } else {
  1230. pmContractInfo = new PmContractInfo();
  1231. BeanUtils.copyProperties(pmContractInfoReqVo, pmContractInfo);
  1232. pmContractInfo.setCreateBy(pmContractInfoReqVo.getCreateBy());
  1233. pmContractInfo.setCreateTime(pmContractInfoReqVo.getCreateTime());
  1234. pmContractInfo.setUpdateTime(pmContractInfoReqVo.getUpdateTime());
  1235. pmContractInfo.setUpdateBy(pmContractInfoReqVo.getUpdateBy());
  1236. }
  1237. if (pmContractInfoService.saveOrUpdate(pmContractInfo)) {
  1238. this.uploadFile(pmContractInfo.getId(), SysFileRefEnum.PM_CONTRACT_INFO.getType(), sysFileRefs, pmContractInfoReqVo.getUpdateBy());
  1239. PmDemand pmDemandUpdate = new PmDemand();
  1240. pmDemandUpdate.setDemandId(demandId);
  1241. pmDemandUpdate.setProjectStatus(PmProjectStatus.UNDER_CONSTRUCTION.getCode());
  1242. pmDemandUpdate.setUpdateTime(pmContractInfoReqVo.getUpdateTime());
  1243. pmDemandUpdate.setUpdateBy(pmContractInfoReqVo.getUpdateBy());
  1244. return this.updateById(pmDemandUpdate);
  1245. } else {
  1246. return false;
  1247. }
  1248. }
  1249. @Override
  1250. @Transactional(rollbackFor = Exception.class)
  1251. public boolean insertProjectConstruction(PmProjectConstructionReqVo pmProjectConstructionReqVo) throws Exception {
  1252. Long demandId = pmProjectConstructionReqVo.getDemandId();
  1253. if (ObjectUtils.isEmpty(demandId)) {
  1254. throw new Exception("采购需求ID不能为空");
  1255. }
  1256. PmDemand pmDemand = this.getById(demandId);
  1257. if (ObjectUtils.isEmpty(pmDemand)) {
  1258. throw new Exception("采购需求ID错误");
  1259. }
  1260. List<SysFileRef> sysFileRefs = pmProjectConstructionReqVo.getSysFileRefs();
  1261. if (ObjectUtils.isEmpty(sysFileRefs)) {
  1262. throw new Exception("上传附件不能为空");
  1263. }
  1264. LambdaQueryWrapper<PmProjectConstruction> lambdaQueryWrapper = new LambdaQueryWrapper<>();
  1265. lambdaQueryWrapper.eq(PmProjectConstruction::getDemandId, demandId);
  1266. PmProjectConstruction pmProjectConstruction = pmProjectConstructionService.getOne(lambdaQueryWrapper);
  1267. if (pmProjectConstruction != null) {
  1268. pmProjectConstructionReqVo.setId(pmProjectConstruction.getId());
  1269. BeanUtils.copyProperties(pmProjectConstructionReqVo, pmProjectConstruction);
  1270. pmProjectConstruction.setUpdateBy(pmProjectConstructionReqVo.getUpdateBy());
  1271. pmProjectConstruction.setUpdateTime(pmProjectConstructionReqVo.getUpdateTime());
  1272. } else {
  1273. pmProjectConstruction = new PmProjectConstruction();
  1274. BeanUtils.copyProperties(pmProjectConstructionReqVo, pmProjectConstruction);
  1275. pmProjectConstruction.setCreateBy(pmProjectConstructionReqVo.getCreateBy());
  1276. pmProjectConstruction.setCreateTime(pmProjectConstructionReqVo.getCreateTime());
  1277. pmProjectConstruction.setUpdateBy(pmProjectConstructionReqVo.getUpdateBy());
  1278. pmProjectConstruction.setUpdateTime(pmProjectConstructionReqVo.getUpdateTime());
  1279. }
  1280. if (pmProjectConstructionService.saveOrUpdate(pmProjectConstruction)) {
  1281. this.uploadFile(pmProjectConstruction.getId(), SysFileRefEnum.PM_PROJECT_CONSTRUCTION.getType(), sysFileRefs, pmProjectConstructionReqVo.getUpdateBy());
  1282. PmDemand pmDemandUpdate = new PmDemand();
  1283. pmDemandUpdate.setDemandId(demandId);
  1284. pmDemandUpdate.setProjectStatus(PmProjectStatus.COMPLETION_CONSTRUCTION.getCode());
  1285. pmDemandUpdate.setRealDeliverTime(pmProjectConstructionReqVo.getUpdateTime());
  1286. pmDemandUpdate.setUpdateTime(pmProjectConstructionReqVo.getUpdateTime());
  1287. pmDemandUpdate.setUpdateBy(pmProjectConstructionReqVo.getUpdateBy());
  1288. return this.updateById(pmDemandUpdate);
  1289. } else {
  1290. return false;
  1291. }
  1292. }
  1293. /**
  1294. * 更新需求预警状态
  1295. *
  1296. * @param demnadId
  1297. * @return
  1298. */
  1299. @Override
  1300. public void updateDemandWarnStatus(Long demnadId) {
  1301. PmDemand pmDemand = this.getById(demnadId);
  1302. List<SysDictData> data = iSysDictTypeService.selectDictDataByType("alert_time_setting");
  1303. int setting1 = Integer.parseInt(data.stream().filter(item -> item.getDictLabel().equals("计划提报时间")).collect(Collectors.toList()).get(0).getDictValue());
  1304. //需求提报时间:根据数据阈值中设置的提报时间进行判断,进行预警
  1305. int diff1 = DateUtils.differentDaysByMillisecond(pmDemand.getPlanDemandSubTime(), DateUtils.parseDate(DateUtils.getDate()));
  1306. if (ObjectUtils.isEmpty(pmDemand.getRealDemandCommitTime()) && diff1 >= setting1) {
  1307. PmDemand pmDemandUpdate = new PmDemand();
  1308. pmDemandUpdate.setDemandId(demnadId);
  1309. pmDemandUpdate.setWarnStatus(WarnStatus.DEMAND_COMMT_WARNING.getCode());
  1310. this.updateById(pmDemand);
  1311. }
  1312. }
  1313. /**
  1314. * 通过需求ID列表 查询采购执行列表 sunhh
  1315. *
  1316. * @param demandIdList
  1317. * @return
  1318. */
  1319. @Override
  1320. public List<PmDemand> selectByDemandIdList(List<Integer> demandIdList) {
  1321. return this.baseMapper.selectByDemandIdList(demandIdList);
  1322. }
  1323. /**
  1324. * 专家库--查询抽取专家列表 非必传条件:专家名称,开始结束时间 sunhh
  1325. *
  1326. * @param baseExpertVo
  1327. * @return
  1328. */
  1329. @Override
  1330. public List<PmDemand> selectExtractionExpert(BaseExpertVo baseExpertVo) {
  1331. return this.baseMapper.selectExtractionExpert(baseExpertVo);
  1332. }
  1333. @Override
  1334. public List<PmDemandResVo> demandWaitCommit() {
  1335. return getListByStatus(PmProjectStatus.DEMAND_WAIT_COMMIT.getCode());
  1336. }
  1337. @Override
  1338. public List<PmDemandResVo> contractWaitFilled() {
  1339. return getListByStatus(PmProjectStatus.CONTRACT_WAIT_FILL.getCode());
  1340. }
  1341. @Override
  1342. public List<PmDemandResVo> projectWaitFinish() {
  1343. return getListByStatus(PmProjectStatus.UNDER_CONSTRUCTION.getCode());
  1344. }
  1345. @Override
  1346. public List<PmDemandResVo> demandWaitExamine() {
  1347. return getListByStatus(PmProjectStatus.DEMAND_WAIT_AUDIT.getCode());
  1348. }
  1349. @Override
  1350. public List<PmDemandResVo> taskWaitRelease() {
  1351. return getListByStatus(PmProjectStatus.TASK_WAIT_RELEASE.getCode());
  1352. }
  1353. @Override
  1354. public List<PmDemandResVo> waitSelectAgent() {
  1355. return getListByStatus(PmProjectStatus.WAIT_SELECT_AGENT.getCode());
  1356. }
  1357. @Override
  1358. public List<PmDemandResVo> waitUpBidFile() {
  1359. return getListByStatus(PmProjectStatus.WAIT_UPLOAD_BID_FILE.getCode());
  1360. }
  1361. @Override
  1362. public List<PmDemandResVo> waitAnnouncement() {
  1363. return getListByStatus(PmProjectStatus.WAIT_ANNOUNCEMENT.getCode());
  1364. }
  1365. @Override
  1366. public List<PmDemandResVo> waitOpenBid() {
  1367. return getListByStatus(PmProjectStatus.WAIT_OPEN_BID.getCode());
  1368. }
  1369. @Override
  1370. public List<PmDemandResVo> waitBidAnnouncement() {
  1371. return getListByStatus(PmProjectStatus.WAIT_BID_ANNOUNCEMENT.getCode());
  1372. }
  1373. @Override
  1374. public List<PmDemandResVo> biddingPublicity() {
  1375. return getListByStatus(PmProjectStatus.BIDDING_PUBLICITY.getCode());
  1376. }
  1377. @Override
  1378. public AjaxResult procurementOfficeWillManipulateTotal() {
  1379. List<HomeToDoQueryResVo> homeRes = new ArrayList<>();
  1380. // 待选取代理, 待上传招标文件, 待发布公告, 待开标, 待发布中标公告, 中标公示中
  1381. List<PmDemandResVo> demandRes = new ArrayList<>();
  1382. demandRes.addAll(getListByStatus(PmProjectStatus.WAIT_SELECT_AGENT.getCode()));
  1383. demandRes.addAll(getListByStatus(PmProjectStatus.WAIT_UPLOAD_BID_FILE.getCode()));
  1384. demandRes.addAll(getListByStatus(PmProjectStatus.WAIT_ANNOUNCEMENT.getCode()));
  1385. demandRes.addAll(getListByStatus(PmProjectStatus.WAIT_OPEN_BID.getCode()));
  1386. demandRes.addAll(getListByStatus(PmProjectStatus.WAIT_BID_ANNOUNCEMENT.getCode()));
  1387. demandRes.addAll(getListByStatus(PmProjectStatus.BIDDING_PUBLICITY.getCode()));
  1388. //计划数据--发函催告
  1389. List<PlanQuarterResponseVo> planRes = planYearsService.willSendLetter();
  1390. //转为首页table展示数据
  1391. if (!ObjectUtils.isEmpty(demandRes) && demandRes.size() > 0) {
  1392. for (PmDemandResVo demandResVo : demandRes) {
  1393. HomeToDoQueryResVo home = new HomeToDoQueryResVo();
  1394. home.setEvaluation(BigDecimal.valueOf(demandResVo.getEvaluation()));
  1395. BeanUtils.copyProperties(demandResVo, home);
  1396. homeRes.add(home);
  1397. }
  1398. }
  1399. if (!ObjectUtils.isEmpty(planRes) && planRes.size() > 0) {
  1400. for (PlanQuarterResponseVo planVo : planRes) {
  1401. HomeToDoQueryResVo home = new HomeToDoQueryResVo();
  1402. BeanUtils.copyProperties(planVo, home);
  1403. homeRes.add(home);
  1404. }
  1405. }
  1406. return AjaxResult.success(homeRes);
  1407. }
  1408. /**
  1409. * 统计分析-采购项目信息统计
  1410. *
  1411. * @param pmDemandReqVo
  1412. * @return
  1413. */
  1414. @Override
  1415. public Map<String, Integer> purchaseProjectStatistical(PmDemandReqVo pmDemandReqVo) {
  1416. Map<String, Integer> mapReturn = new HashMap<>();
  1417. // 查询项目总数量
  1418. Map<String, Integer> mapCount = pmDemandMapper.purchaseProjectStatistical(pmDemandReqVo);
  1419. // 查询已完成项目数量,预算金额数量
  1420. Map<String, Integer> mapYWC = pmDemandMapper.purchaseProjectStatisticalYWC(pmDemandReqVo);
  1421. // 查询新创建项目数量,预算金额数量
  1422. Map<String, Integer> mapXCJ = pmDemandMapper.purchaseProjectStatisticalXCJ(pmDemandReqVo);
  1423. // 查询去年完成项目数量,预算金额数量
  1424. Map<String, Integer> mapQNWC = pmDemandMapper.purchaseProjectStatisticalQNWC(pmDemandReqVo);
  1425. mapReturn.putAll(mapCount);
  1426. mapReturn.putAll(mapYWC);
  1427. mapReturn.putAll(mapXCJ);
  1428. mapReturn.putAll(mapQNWC);
  1429. return mapReturn;
  1430. }
  1431. @Override
  1432. public List<StatisticalChartsResVo> countByProjectAttr() {
  1433. List<StatisticalChartsResVo> resVos = pmDemandMapper.countByProjectAttr();
  1434. for (StatisticalChartsResVo chartsResVo : resVos) {
  1435. for (PmProjectStatus value : PmProjectStatus.values()) {
  1436. if (value.getCode().equals(chartsResVo.getColumnName())) {
  1437. chartsResVo.setColumnName(value.getInfo());
  1438. break;
  1439. }
  1440. }
  1441. }
  1442. return resVos;
  1443. }
  1444. @Override
  1445. public List<StatisticalChartsResVo> countByPurchaseMode() {
  1446. List<StatisticalChartsResVo> resVos = pmDemandMapper.countByPurchaseMode();
  1447. for (StatisticalChartsResVo chartsResVo : resVos) {
  1448. for (ProcurementMethodSuggest value : ProcurementMethodSuggest.values()) {
  1449. if (value.getCode().equals(chartsResVo.getColumnName())) {
  1450. chartsResVo.setColumnName(value.getInfo());
  1451. break;
  1452. }
  1453. }
  1454. }
  1455. return resVos;
  1456. }
  1457. @Override
  1458. public List<StatisticalChartsResVo> countByEvaluation(PmDemandReqVo pmDemandReqVo) {
  1459. List<StatisticalChartsResVo> resVos = new ArrayList<>();
  1460. //概算金额包括:100万以下采购任务、100至500万元采购任务、500至1000万元采购任务、1000至5000万元采购任务、5000至1亿元采购任务、1亿元及以上采购任务
  1461. StatisticalChartsResVo resVo = pmDemandMapper.countByEvaluationLt(100);
  1462. resVo.setColumnName("100万以下采购任务");
  1463. resVos.add(resVo);
  1464. StatisticalChartsResVo resVo1 = pmDemandMapper.countByEvaluationBet(100, 500);
  1465. resVo1.setColumnName("100至500万元采购任务");
  1466. resVos.add(resVo1);
  1467. StatisticalChartsResVo resVo2 = pmDemandMapper.countByEvaluationBet(500, 1000);
  1468. resVo2.setColumnName("500至1000万元采购任务");
  1469. resVos.add(resVo2);
  1470. StatisticalChartsResVo resVo3 = pmDemandMapper.countByEvaluationBet(1000, 5000);
  1471. resVo3.setColumnName("1000至5000万元采购任务");
  1472. resVos.add(resVo3);
  1473. StatisticalChartsResVo resVo4 = pmDemandMapper.countByEvaluationBet(5000, 10000);
  1474. resVo4.setColumnName("5000至1亿元采购任务");
  1475. resVos.add(resVo4);
  1476. StatisticalChartsResVo resVo5 = pmDemandMapper.countByEvaluationGt(10000);
  1477. resVo5.setColumnName("1亿元及以上采购任务");
  1478. resVos.add(resVo5);
  1479. return resVos;
  1480. }
  1481. @Override
  1482. public AjaxResult countProjectExceed(PmDemandReqVo pmDemandReqVo) {
  1483. HashMap<String, String> resMap = new HashMap<>();
  1484. //执行滞后采购项目:本年度所有的逾期项目数
  1485. //预算金额:本年度所有逾期项目累加的预算金额
  1486. StatisticalChartsResVo resVo = pmDemandMapper.countProjectExceed();
  1487. resMap.put("执行滞后采购项目", resVo.getNum());
  1488. resMap.put("预算金额", resVo.getEvaluationTotal());
  1489. //滞后项目数量占比:指本年度逾期项目数量/本年度所有项目数量
  1490. Integer thisYear = pmDemandMapper.countThisYear();
  1491. resMap.put("滞后项目数量占比", getPercent(Integer.parseInt(resVo.getNum()), thisYear));
  1492. return AjaxResult.success(resMap);
  1493. }
  1494. /**
  1495. * 统计不同时间维度的逾期项目
  1496. *
  1497. * @return
  1498. */
  1499. @Override
  1500. public AjaxResult exceedAnalysis(PmDemandReqVo pmDemandReqVo) {
  1501. HashMap<String, List<StatisticalChartsResVo>> resMap = new HashMap<>();
  1502. List<StatisticalChartsResVo> byYear = pmDemandMapper.countProjectExceedYear();
  1503. if (pmDemandReqVo.getTimeType().equals("1")) {
  1504. resMap.put("年", byYear);
  1505. } else if (pmDemandReqVo.getTimeType().equals("2")) {
  1506. List<StatisticalChartsResVo> byQuarter = new LinkedList<>();
  1507. for (StatisticalChartsResVo chartsResVo : byYear) {
  1508. for (int i = 1; i <= 4; i++) {
  1509. StatisticalChartsResVo quarter = pmDemandMapper.countProjectExceedQuarter(i, Integer.parseInt(chartsResVo.getColumnName()));
  1510. if (ObjectUtils.isEmpty(quarter)) {
  1511. StatisticalChartsResVo vo = new StatisticalChartsResVo("", "0", "0");
  1512. quarter = vo;
  1513. quarter.setColumnName(chartsResVo.getColumnName() + "年第" + i + "季度");
  1514. }
  1515. quarter.setColumnName(chartsResVo.getColumnName() + "年第" + i + "季度");
  1516. byQuarter.add(quarter);
  1517. }
  1518. }
  1519. resMap.put("季度", byQuarter);
  1520. } else if (pmDemandReqVo.getTimeType().equals("3")) {
  1521. List<StatisticalChartsResVo> byMonth = new LinkedList<>();
  1522. for (StatisticalChartsResVo chartsResVo : byYear) {
  1523. for (int i = 1; i <= 12; i++) {
  1524. StatisticalChartsResVo month = pmDemandMapper.countProjectExceedMonth(i, Integer.parseInt(chartsResVo.getColumnName()));
  1525. if (ObjectUtils.isEmpty(month)) {
  1526. StatisticalChartsResVo vo = new StatisticalChartsResVo("", "0", "0");
  1527. month = vo;
  1528. month.setColumnName(chartsResVo.getColumnName() + "年" + i + "月");
  1529. }
  1530. month.setColumnName(chartsResVo.getColumnName() + "年" + i + "月");
  1531. byMonth.add(month);
  1532. }
  1533. }
  1534. resMap.put("月", byMonth);
  1535. }
  1536. return AjaxResult.success(resMap);
  1537. }
  1538. @Override
  1539. public AjaxResult taskQuantityAnalysis(PmDemandReqVo pmDemandReqVo) {
  1540. HashMap<String, List<StatisticalChartsResVo>> resMap = new HashMap<>();
  1541. //任务数量趋势分析:按照月、季度、年统计“项目属性”字段中“重大规划”属性的项目
  1542. List<StatisticalChartsResVo> byYear = pmDemandMapper.countProjectMajorByYear();
  1543. if (pmDemandReqVo.getTimeType().equals("1")) {
  1544. resMap.put("年", byYear);
  1545. } else if (pmDemandReqVo.getTimeType().equals("2")) {
  1546. List<StatisticalChartsResVo> byQuarter = new LinkedList<>();
  1547. for (StatisticalChartsResVo chartsResVo : byYear) {
  1548. for (int i = 1; i <= 4; i++) {
  1549. StatisticalChartsResVo quarter = pmDemandMapper.countProjectMajorByQuarter(i, Integer.parseInt(chartsResVo.getColumnName()));
  1550. quarter.setColumnName(chartsResVo.getColumnName() + "年第" + i + "季度");
  1551. byQuarter.add(quarter);
  1552. }
  1553. }
  1554. resMap.put("季度", byQuarter);
  1555. } else if (pmDemandReqVo.getTimeType().equals("3")) {
  1556. List<StatisticalChartsResVo> byMonth = pmDemandMapper.countProjectMajorByMonth();
  1557. resMap.put("月", byMonth);
  1558. }
  1559. return AjaxResult.success(resMap);
  1560. }
  1561. @Override
  1562. public AjaxResult countEveryStatusNum(PmDemandReqVo pmDemandReqVo) {
  1563. //指项目进行到各个阶段的数量
  1564. //阶段包括:待选取代理、待上传招标文件、待发布公告、待开标、待发布中标公告、中标公式中
  1565. List<StatisticalChartsResVo> everyStatusNum = pmDemandMapper.countEveryStatusNum();
  1566. if (!ObjectUtils.isEmpty(everyStatusNum) && everyStatusNum.size() > 0) {
  1567. for (StatisticalChartsResVo vo : everyStatusNum) {
  1568. switch (vo.getColumnName()) {
  1569. case "9":
  1570. vo.setColumnName(PmProjectStatus.WAIT_SELECT_AGENT.getInfo());
  1571. case "10":
  1572. vo.setColumnName(PmProjectStatus.WAIT_UPLOAD_BID_FILE.getInfo());
  1573. case "11":
  1574. vo.setColumnName(PmProjectStatus.WAIT_ANNOUNCEMENT.getInfo());
  1575. case "12":
  1576. vo.setColumnName(PmProjectStatus.WAIT_OPEN_BID.getInfo());
  1577. case "13":
  1578. vo.setColumnName(PmProjectStatus.WAIT_BID_ANNOUNCEMENT.getInfo());
  1579. case "14":
  1580. vo.setColumnName(PmProjectStatus.BIDDING_PUBLICITY.getInfo());
  1581. }
  1582. }
  1583. }
  1584. return AjaxResult.success(everyStatusNum);
  1585. }
  1586. @Override
  1587. public AjaxResult exceedMarketAnalysis(PmDemandReqVo pmDemandReqVo) {
  1588. //所有滞后
  1589. List<PmDemand> demandList = pmDemandMapper.countProjectExceedAll();
  1590. //滞后时长包括:滞后1个月以内的采购任务、滞后1至3个月采购任务、滞后3至6个月采购任务、滞后6个月至1年采购任务、滞后1年以上采购任务
  1591. HashMap<String, Integer> map = new LinkedHashMap<>();
  1592. map.put("滞后1个月以内的采购任务", 0);
  1593. map.put("滞后1至3个月采购任务", 0);
  1594. map.put("滞后3至6个月采购任务", 0);
  1595. map.put("滞后6个月至1年采购任务", 0);
  1596. map.put("滞后1年以上采购任务", 0);
  1597. if (!ObjectUtils.isEmpty(demandList) && demandList.size() > 0) {
  1598. for (PmDemand demand : demandList) {
  1599. //滞后时间
  1600. Long exTime = null;
  1601. if (!ObjectUtils.isEmpty(demand.getRealDemandCommitTime()) && demand.getRealDemandCommitTime().getTime() - demand.getPlanDemandSubTime().getTime() > 0) {
  1602. exTime = demand.getRealDemandCommitTime().getTime() - demand.getPlanDemandSubTime().getTime();
  1603. } else if (!ObjectUtils.isEmpty(demand.getRealPurchaseFinishTime()) && demand.getRealPurchaseFinishTime().getTime() - demand.getPlanPurchaseFinishTime().getTime() > 0) {
  1604. exTime = demand.getRealPurchaseFinishTime().getTime() - demand.getPlanPurchaseFinishTime().getTime();
  1605. } else if (!ObjectUtils.isEmpty(demand.getRealDeliverTime()) && demand.getRealDeliverTime().getTime() - demand.getPlanDeliverTime().getTime() > 0) {
  1606. exTime = demand.getRealDeliverTime().getTime() - demand.getPlanDeliverTime().getTime();
  1607. }
  1608. if (exTime < Long.valueOf("2592000000")) {
  1609. map.put("滞后1个月以内的采购任务", map.get("滞后1个月以内的采购任务") + 1);
  1610. }
  1611. if (exTime >= Long.valueOf("2592000000") && exTime < Long.valueOf("7776000000")) {
  1612. map.put("滞后1至3个月采购任务", map.get("滞后1至3个月采购任务") + 1);
  1613. }
  1614. if (exTime >= Long.valueOf("7776000000") && exTime < Long.valueOf("15552000000")) {
  1615. map.put("滞后3至6个月采购任务", map.get("滞后3至6个月采购任务") + 1);
  1616. }
  1617. if (exTime >= Long.valueOf("15552000000") && exTime < Long.valueOf("31104000000")) {
  1618. map.put("滞后6个月至1年采购任务", map.get("滞后6个月至1年采购任务") + 1);
  1619. }
  1620. if (exTime > Long.valueOf("31104000000")) {
  1621. map.put("滞后1年以上采购任务", map.get("滞后1年以上采购任务") + 1);
  1622. }
  1623. }
  1624. }
  1625. return AjaxResult.success(map);
  1626. }
  1627. @Override
  1628. public AjaxResult countMajorProject(PmDemandReqVo pmDemandReqVo) {
  1629. List<StatisticalChartsResVo> resVos = new ArrayList<>();
  1630. //数量:指本年度状态为“项目建设完成”的项目属性为“重大规划”的项目数
  1631. //预算金额:指本年度状态为“项目建设完成”的项目属性为“重大规划”的项目累加的预算金额
  1632. StatisticalChartsResVo resVo = new StatisticalChartsResVo();
  1633. resVo = pmDemandMapper.majorProjectByStatus(PmProjectStatus.COMPLETION_CONSTRUCTION.getCode());
  1634. resVo.setColumnName("今年已完成数量");
  1635. resVos.add(resVo);
  1636. //正常推进项目:指本年度正在进行中的项目属性为“重大规划”的项目数
  1637. //预算金额:指本年度正在进行中的项目属性为“重大规划”的项目累加的预算金额
  1638. StatisticalChartsResVo resVo1 = new StatisticalChartsResVo();
  1639. resVo1 = pmDemandMapper.majorProjectByStatus(PmProjectStatus.UNDER_CONSTRUCTION.getCode());
  1640. resVo1.setColumnName("正常推进数量");
  1641. resVos.add(resVo1);
  1642. //执行滞后数量:指本年度逾期项目中,项目属性为“重大规划”的项目数
  1643. //预算金额:指本年度正在进行中的项目属性为“重大规划”的项目累加的预算金额
  1644. StatisticalChartsResVo resVo2 = new StatisticalChartsResVo();
  1645. resVo2 = pmDemandMapper.countMajorProjectExceed();
  1646. resVo2.setColumnName("执行滞后数量");
  1647. resVos.add(resVo2);
  1648. //上年度重大规划采购任务数量:指上年度项目中,项目属性为“重大规划”的项目数
  1649. //预算金额:指上年度项目中,项目属性为“重大规划”的项目累加的预算金额
  1650. StatisticalChartsResVo resVo3 = new StatisticalChartsResVo();
  1651. resVo3 = pmDemandMapper.countMajorProjectLastYear();
  1652. resVo3.setColumnName("上年度重大规划采购任务数量");
  1653. resVos.add(resVo3);
  1654. //resVo2=pmDemandMapper.majorProjectByStatus(PmProjectStatus.COMPLETION_CONSTRUCTION.getCode());
  1655. return AjaxResult.success(resVos);
  1656. }
  1657. /**
  1658. * 通过计划ID查询项目数据
  1659. *
  1660. * @param planId
  1661. * @return
  1662. */
  1663. @Override
  1664. public PmDemand selectByPlanId(Integer planId) {
  1665. return pmDemandMapper.selectByPlanId(planId);
  1666. }
  1667. /**
  1668. * 采购项目--项目数量分析
  1669. *
  1670. * @param pmDemandReqVo
  1671. * @return
  1672. */
  1673. @Override
  1674. public Map<String, Integer> purchaseProjectNumber(PmDemandReqVo pmDemandReqVo) {
  1675. return null;
  1676. }
  1677. /**
  1678. * 项目执行进度统计
  1679. * 1、正常推进项目数量:指未完成并且没有逾期的项目
  1680. * 预算金额:指未完成并且没有逾期的项目累加的预算金额
  1681. * 2、未完成采购任务:“合同待填制”状态之前的项目
  1682. * 预算金额:“合同待填制”状态之前的项目累加的预算金额
  1683. *
  1684. * @param pmDemandReqVo
  1685. * @return
  1686. */
  1687. @Override
  1688. public Map<String, Integer> purchaseProjectExecute(PmDemandReqVo pmDemandReqVo) {
  1689. Map<String, Integer> mapReturn = new HashMap<>();
  1690. // 正常推进项目数量、预算金额
  1691. Map<String, Integer> mapNormalPropulsion = pmDemandMapper.purchaseProjectExecuteNormalPropulsion(pmDemandReqVo);
  1692. // 未完成采购任务,预算金额
  1693. Map<String, Integer> mapIncomplete = pmDemandMapper.purchaseProjectExecuteIncomplete(pmDemandReqVo);
  1694. mapReturn.putAll(mapNormalPropulsion);
  1695. mapReturn.putAll(mapIncomplete);
  1696. return mapReturn;
  1697. }
  1698. /**
  1699. * 已完成项目数量统计
  1700. *
  1701. * @param pmDemandReqVo
  1702. * @return
  1703. */
  1704. @Override
  1705. public List<Map<String, Integer>> purchaseProjectCompleteNumber(PmDemandReqVo pmDemandReqVo) {
  1706. List<Map<String, Integer>> mapReturn = new ArrayList<>();
  1707. // 统计时间类型 1:年度,2:季度,3:月份
  1708. if ("1".equals(pmDemandReqVo.getTimeType())) {
  1709. // 查询数据库中最小的年份
  1710. int minYear = pmDemandMapper.selectMinYear();
  1711. // 获取当前年份
  1712. Calendar calendar = Calendar.getInstance();
  1713. int year = calendar.get(Calendar.YEAR);
  1714. // 获取统计数据
  1715. List<Map<String, Integer>> listMap = pmDemandMapper.selectpurchaseProjectCompleteNumberYear(pmDemandReqVo);
  1716. mapReturn.addAll(listMap);
  1717. for (int i = minYear; i <= year; i++) {
  1718. for (Map<String, Integer> map : listMap) {
  1719. if (i != Integer.valueOf(map.get("yy"))) {
  1720. Map<String, Integer> map1 = new HashMap<>();
  1721. map1.put("yy", i);
  1722. map1.put("evaluation", 0);
  1723. map1.put("contractAmount", 0);
  1724. map1.put("countNum", 0);
  1725. mapReturn.add(map1);
  1726. }
  1727. }
  1728. }
  1729. } else if ("2".equals(pmDemandReqVo.getTimeType())) {
  1730. // 当前年份季度统计
  1731. // 获取统计数据
  1732. List<Map<String, Integer>> listMap = pmDemandMapper.selectpurchaseProjectCompleteNumberQuarter(pmDemandReqVo);
  1733. mapReturn.addAll(listMap);
  1734. for (int i = 1; i <= 4; i++) {
  1735. for (Map<String, Integer> map : listMap) {
  1736. if (i != map.get("yy")) {
  1737. Map<String, Integer> map1 = new HashMap<>();
  1738. map1.put("yy", i);
  1739. map1.put("evaluation", 0);
  1740. map1.put("contractAmount", 0);
  1741. map1.put("countNum", 0);
  1742. mapReturn.add(map1);
  1743. }
  1744. }
  1745. }
  1746. } else if ("3".equals(pmDemandReqVo.getTimeType())) {
  1747. // 当前年份月份统计
  1748. // 获取统计数据
  1749. List<Map<String, Integer>> listMap = pmDemandMapper.selectpurchaseProjectCompleteNumberMonth(pmDemandReqVo);
  1750. mapReturn.addAll(listMap);
  1751. for (int i = 1; i <= 12; i++) {
  1752. for (Map<String, Integer> map : listMap) {
  1753. int ii = Integer.parseInt(String.valueOf(map.get("yy")));
  1754. map.put("yy", ii);
  1755. if (i != ii) {
  1756. Map<String, Integer> map1 = new HashMap<>();
  1757. map1.put("yy", i);
  1758. map1.put("evaluation", 0);
  1759. map1.put("contractAmount", 0);
  1760. map1.put("countNum", 0);
  1761. mapReturn.add(map1);
  1762. }
  1763. }
  1764. }
  1765. }
  1766. return mapReturn;
  1767. }
  1768. /**
  1769. * 已完成采购任务数量统计
  1770. *
  1771. * @param pmDemandReqVo
  1772. * @return
  1773. */
  1774. @Override
  1775. public List<Map<String, Integer>> purchaseTaskFinish(PmDemandReqVo pmDemandReqVo) {
  1776. List<Map<String, Integer>> mapReturn = new ArrayList<>();
  1777. // 统计时间类型 1:年度,2:季度,3:月份
  1778. if ("1".equals(pmDemandReqVo.getTimeType())) {
  1779. // 查询数据库中最小的年份
  1780. int minYear = pmDemandMapper.selectMinYear();
  1781. // 获取当前年份
  1782. Calendar calendar = Calendar.getInstance();
  1783. int year = calendar.get(Calendar.YEAR);
  1784. // 获取统计数据
  1785. List<Map<String, Integer>> listMap = pmDemandMapper.selectPurchaseTaskFinishYear(pmDemandReqVo);
  1786. mapReturn.addAll(listMap);
  1787. for (int i = minYear; i <= year; i++) {
  1788. for (Map<String, Integer> map : listMap) {
  1789. if (i != Integer.valueOf(map.get("yy"))) {
  1790. Map<String, Integer> map1 = new HashMap<>();
  1791. map1.put("yy", i);
  1792. map1.put("evaluation", 0);
  1793. map1.put("contractAmount", 0);
  1794. map1.put("countNum", 0);
  1795. mapReturn.add(map1);
  1796. }
  1797. }
  1798. }
  1799. } else if ("2".equals(pmDemandReqVo.getTimeType())) {
  1800. // 当前年份季度统计
  1801. // 获取统计数据
  1802. List<Map<String, Integer>> listMap = pmDemandMapper.selectPurchaseTaskFinishQuarter(pmDemandReqVo);
  1803. mapReturn.addAll(listMap);
  1804. for (int i = 1; i <= 4; i++) {
  1805. for (Map<String, Integer> map : listMap) {
  1806. if (i != map.get("yy")) {
  1807. Map<String, Integer> map1 = new HashMap<>();
  1808. map1.put("yy", i);
  1809. map1.put("evaluation", 0);
  1810. map1.put("contractAmount", 0);
  1811. map1.put("countNum", 0);
  1812. mapReturn.add(map1);
  1813. }
  1814. }
  1815. }
  1816. } else if ("3".equals(pmDemandReqVo.getTimeType())) {
  1817. // 当前年份月份统计
  1818. // 获取统计数据
  1819. List<Map<String, Integer>> listMap = pmDemandMapper.selectPurchaseTaskFinishMonth(pmDemandReqVo);
  1820. mapReturn.addAll(listMap);
  1821. for (int i = 1; i <= 12; i++) {
  1822. for (Map<String, Integer> map : listMap) {
  1823. int ii = Integer.parseInt(String.valueOf(map.get("yy")));
  1824. map.put("yy", ii);
  1825. if (i != ii) {
  1826. Map<String, Integer> map1 = new HashMap<>();
  1827. map1.put("yy", i);
  1828. map1.put("evaluation", 0);
  1829. map1.put("contractAmount", 0);
  1830. map1.put("countNum", 0);
  1831. mapReturn.add(map1);
  1832. }
  1833. }
  1834. }
  1835. }
  1836. return mapReturn;
  1837. }
  1838. /**
  1839. * 各阶段项目数量分布
  1840. *
  1841. * @param pmDemandReqVo
  1842. * @return
  1843. */
  1844. @Override
  1845. public List<Map<String, String>> purchaseProjectDistribution(PmDemandReqVo pmDemandReqVo) {
  1846. // 项目计划 4之前(包括4)
  1847. List<String> xmjh = new ArrayList<>();
  1848. xmjh.add("4");
  1849. pmDemandReqVo.setProjectStatusList(xmjh);
  1850. Map<String, String> returnMapxmjh = pmDemandMapper.purchaseProjectDistribution(pmDemandReqVo);
  1851. returnMapxmjh.put("name", "计划管理");
  1852. // 需求建党 4之后(不包括4)
  1853. List<String> xqjd = new ArrayList<>();
  1854. xqjd.add("5");
  1855. xqjd.add("6");
  1856. xqjd.add("7");
  1857. xqjd.add("8");
  1858. pmDemandReqVo.setProjectStatusList(xqjd);
  1859. Map<String, String> returnMapxqjd = pmDemandMapper.purchaseProjectDistribution(pmDemandReqVo);
  1860. returnMapxqjd.put("name", "需求管理");
  1861. // 任务下达 8之后(不包括8)
  1862. List<String> rwxd = new ArrayList<>();
  1863. rwxd.add("9");
  1864. pmDemandReqVo.setProjectStatusList(rwxd);
  1865. Map<String, String> returnMaprwxd = pmDemandMapper.purchaseProjectDistribution(pmDemandReqVo);
  1866. returnMaprwxd.put("name", "任务下达");
  1867. // 采购执行 9之后(不包括9)
  1868. List<String> cgzx = new ArrayList<>();
  1869. cgzx.add("10");
  1870. cgzx.add("11");
  1871. cgzx.add("12");
  1872. cgzx.add("13");
  1873. cgzx.add("14");
  1874. cgzx.add("15");
  1875. pmDemandReqVo.setProjectStatusList(cgzx);
  1876. Map<String, String> returnMapcgzx = pmDemandMapper.purchaseProjectDistribution(pmDemandReqVo);
  1877. returnMapcgzx.put("name", "采购执行");
  1878. // 合同管理 15之后(不包括15)
  1879. List<String> htxx = new ArrayList<>();
  1880. htxx.add("16");
  1881. pmDemandReqVo.setProjectStatusList(htxx);
  1882. Map<String, String> returnMaphtxx = pmDemandMapper.purchaseProjectDistribution(pmDemandReqVo);
  1883. returnMaphtxx.put("name", "合同管理");
  1884. // 项目建设 17
  1885. List<String> xmjs = new ArrayList<>();
  1886. xmjs.add("16");
  1887. pmDemandReqVo.setProjectStatusList(xmjs);
  1888. Map<String, String> returnMapxmjs = pmDemandMapper.purchaseProjectDistribution(pmDemandReqVo);
  1889. returnMapxmjs.put("name", "合同管理");
  1890. List<Map<String, String>> returnMap = new ArrayList<>();
  1891. returnMap.add(returnMapxmjh);
  1892. returnMap.add(returnMapxqjd);
  1893. returnMap.add(returnMaprwxd);
  1894. returnMap.add(returnMapcgzx);
  1895. returnMap.add(returnMaphtxx);
  1896. returnMap.add(returnMapxmjs);
  1897. return returnMap;
  1898. }
  1899. /**
  1900. * 项目数量分析
  1901. *
  1902. * @param pmDemandReqVo
  1903. * @return
  1904. */
  1905. @Override
  1906. public List<Map<String, String>> purchaseProjectNumberAnalysis(PmDemandReqVo pmDemandReqVo) {
  1907. List<Map<String, String>> mapReturn = new ArrayList<>();
  1908. // 统计时间类型 1:年度,2:季度,3:月份
  1909. if ("1".equals(pmDemandReqVo.getTimeType())) {
  1910. // *** 年度的同比和环比不展示 *** //
  1911. // 查询数据库中最小的年份
  1912. int minYear = pmDemandMapper.selectMinYear();
  1913. // 获取当前年份
  1914. Calendar calendar = Calendar.getInstance();
  1915. int year = calendar.get(Calendar.YEAR);
  1916. // 获取统计数据
  1917. // 获取项目统计
  1918. List<Map<String, String>> listMap = pmDemandMapper.purchaseProjectNumberAnalysisYear(pmDemandReqVo);
  1919. mapReturn.addAll(listMap);
  1920. for (int i = minYear; i <= year; i++) {
  1921. for (Map<String, String> map : listMap) {
  1922. if (i != Integer.valueOf(map.get("yy"))) {
  1923. Map<String, String> map1 = new HashMap<>();
  1924. map1.put("yy", i + "");
  1925. map1.put("countNum", 0 + "");
  1926. mapReturn.add(map1);
  1927. }
  1928. }
  1929. }
  1930. } else if ("2".equals(pmDemandReqVo.getTimeType())) {
  1931. // 当前年份季度统计
  1932. // 获取统计数据
  1933. List<Map<String, String>> listMap = pmDemandMapper.purchaseProjectNumberAnalysisQuarter(pmDemandReqVo);
  1934. mapReturn.addAll(listMap);
  1935. for (int i = 1; i <= 4; i++) {
  1936. for (Map<String, String> map : listMap) {
  1937. int ii = Integer.parseInt(String.valueOf(map.get("yy")));
  1938. map.put("yy", ii + "");
  1939. if (i != ii) {
  1940. Map<String, String> map1 = new HashMap<>();
  1941. map1.put("yy", i + "");
  1942. map1.put("countNum", 0 + "");
  1943. mapReturn.add(map1);
  1944. }
  1945. }
  1946. }
  1947. } else if ("3".equals(pmDemandReqVo.getTimeType())) {
  1948. // 当前年份月份统计
  1949. // 获取统计数据
  1950. List<Map<String, String>> listMap = pmDemandMapper.purchaseProjectNumberAnalysisMonth(pmDemandReqVo);
  1951. mapReturn.addAll(listMap);
  1952. for (int i = 1; i <= 12; i++) {
  1953. for (Map<String, String> map : listMap) {
  1954. int ii = Integer.parseInt(String.valueOf(map.get("yy")));
  1955. map.put("yy", ii + "");
  1956. if (i != ii) {
  1957. Map<String, String> map1 = new HashMap<>();
  1958. map1.put("yy", i + "");
  1959. map1.put("countNum", 0 + "");
  1960. mapReturn.add(map1);
  1961. }
  1962. }
  1963. }
  1964. }
  1965. return mapReturn;
  1966. }
  1967. //查询不同状态下的项目数据
  1968. public List<PmDemandResVo> getListByStatus(String projectStatus) {
  1969. LambdaQueryWrapper<PmDemand> lw = new LambdaQueryWrapper<PmDemand>();
  1970. lw.eq(PmDemand::getProjectStatus, projectStatus);
  1971. List<PmDemand> demandList = this.baseMapper.selectList(lw);
  1972. //数据转换
  1973. List<PmDemandResVo> pmDemandResponseVoList = new ArrayList<>();
  1974. if (!ObjectUtils.isEmpty(demandList) && demandList.size() > 0) {
  1975. pmDemandResponseVoList = demandChangeTo(demandList);
  1976. }
  1977. return pmDemandResponseVoList;
  1978. }
  1979. //字段转换and赋值
  1980. public List<PmDemandResVo> demandChangeTo(List<PmDemand> pmDemandList) {
  1981. List<PmDemandResVo> pmDemandResponseVoList = new ArrayList<>();
  1982. for (PmDemand pmDemand1 : pmDemandList) {
  1983. PmDemandResVo vo = new PmDemandResVo();
  1984. BeanUtils.copyProperties(pmDemand1, vo);
  1985. if (vo.getPurchaseDeptId() != null) {
  1986. Map<String, Object> deptMap = deptService.selectDeptById(vo.getPurchaseDeptId());
  1987. if (deptMap != null) {
  1988. SysDeptResponseVo sysDeptResponseVo = (SysDeptResponseVo) deptMap.get("sysDept");
  1989. if (sysDeptResponseVo != null) {
  1990. vo.setPurchaseDeptName(sysDeptResponseVo.getDeptName());
  1991. }
  1992. }
  1993. }
  1994. String purchaseServicesName = dictDataService.selectDictLabel("purchase_services", vo.getPurchaseServices());
  1995. if (StringUtils.isNotEmpty(purchaseServicesName)) {
  1996. vo.setPurchaseServicesName(purchaseServicesName);
  1997. }
  1998. //项目类型
  1999. for (ProjectTypes value : ProjectTypes.values()) {
  2000. if (vo.getProjectType() != null && vo.getProjectType().equals(value.getCode())) {
  2001. vo.setProjectTypeName(value.getInfo());
  2002. break;
  2003. }
  2004. }
  2005. //是否为超限额计划
  2006. for (IsExcess value : IsExcess.values()) {
  2007. if (vo.getIsExcess() != null && vo.getIsExcess().equals(value.getCode())) {
  2008. vo.setIsExcessName(value.getInfo());
  2009. break;
  2010. }
  2011. }
  2012. //采购方式
  2013. for (PlanPurchaseMode value : PlanPurchaseMode.values()) {
  2014. if (vo.getPurchaseMode() != null && vo.getPurchaseMode().equals(value.getCode())) {
  2015. vo.setPurchaseModeName(value.getInfo());
  2016. break;
  2017. }
  2018. }
  2019. //项目属性
  2020. for (ProjectAttribute value : ProjectAttribute.values()) {
  2021. if (vo.getProjectAttr() != null && vo.getProjectAttr().equals(value.getCode())) {
  2022. vo.setProjectAttrName(value.getInfo());
  2023. break;
  2024. }
  2025. }
  2026. //预警状态
  2027. for (WarnStatus value : WarnStatus.values()) {
  2028. if (vo.getWarnStatus() != null && vo.getWarnStatus().equals(value.getCode())) {
  2029. vo.setWarnStatusName(value.getInfo());
  2030. break;
  2031. }
  2032. }
  2033. //项目状态
  2034. for (PmProjectStatus value : PmProjectStatus.values()) {
  2035. if (vo.getProjectStatus() != null && vo.getProjectStatus().equals(value.getCode())) {
  2036. vo.setProjectStatusName(value.getInfo());
  2037. break;
  2038. }
  2039. }
  2040. try {
  2041. vo.setTipsMessage(pmDemandGetTips(vo.getPlanDeliverTime()));
  2042. if (vo.getTipsMessage().contains("超过")) {
  2043. vo.setIsExceedProject("1");
  2044. }
  2045. } catch (ParseException e) {
  2046. e.printStackTrace();
  2047. }
  2048. pmDemandResponseVoList.add(vo);
  2049. }
  2050. return pmDemandResponseVoList;
  2051. }
  2052. /**
  2053. * 根据年度计划提报时间的阈值进行提示
  2054. *
  2055. * @return
  2056. */
  2057. public String pmDemandGetTips(Date planDeliverTime) throws ParseException {
  2058. if (!ObjectUtils.isEmpty(planDeliverTime)) {
  2059. //提示信息:定义距离结束时间一周内提示
  2060. Integer remindTine = 1000 * 60 * 60 * 24 * 7;
  2061. //少于一周便提醒
  2062. double surplus = planDeliverTime.getTime() - System.currentTimeMillis();
  2063. if (surplus < remindTine) {
  2064. int i = new Double(Math.ceil(surplus / 1000 / 60 / 60 / 24)).intValue();
  2065. //剩余天数(向上取整)
  2066. if (i > 0) {
  2067. return "距离计划交付时间不足" + i + "天";
  2068. } else {
  2069. return "已超过计划完成时间" + Math.abs(i) + "天";
  2070. }
  2071. }
  2072. }
  2073. return "";
  2074. }
  2075. /**
  2076. * 计算百分比:使用java.text.DecimalFormat实现
  2077. *
  2078. * @param x
  2079. * @param y
  2080. * @return
  2081. */
  2082. public static String getPercent(int x, int y) {
  2083. double d1 = x * 1.0;
  2084. double d2 = y * 1.0;
  2085. // 设置保留几位小数, “.”后面几个零就保留几位小数,这里设置保留2位小数
  2086. DecimalFormat decimalFormat = new DecimalFormat("##.00%");
  2087. return decimalFormat.format(d1 / d2);
  2088. }
  2089. }