PmDemandServiceImpl.java 102 KB

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