PmDemandServiceImpl.java 102 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140
  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 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.setBidWinningAmount(pmBidWinningReqVo.getBidWinningAmount());
  1094. pmBidWinning.setStatus(BidWinningStatus.NORMAL.getCode());
  1095. pmBidWinning.setUpdateBy(pmBidWinningReqVo.getUpdateBy());
  1096. pmBidWinning.setUpdateTime(pmBidWinningReqVo.getUpdateTime());
  1097. if (pmBidWinningService.save(pmBidWinning)) {
  1098. List<PmBidWinningOpeningRef> pmBidWinningOpeningRefList = new ArrayList<>();
  1099. for (Long pmBidOpeningId : pmBidOpeningIdList) {
  1100. PmBidWinningOpeningRef pmBidWinningOpeningRef = new PmBidWinningOpeningRef();
  1101. pmBidWinningOpeningRef.setOpeningId(pmBidOpeningId);
  1102. pmBidWinningOpeningRef.setWinningId(pmBidWinning.getId());
  1103. pmBidWinningOpeningRef.setStatus(BidWinningStatus.NORMAL.getCode());
  1104. pmBidWinningOpeningRef.setCreateBy(pmBidWinningReqVo.getCreateBy());
  1105. pmBidWinningOpeningRef.setCreateTime(pmBidWinningReqVo.getCreateTime());
  1106. pmBidWinningOpeningRef.setUpdateBy(pmBidWinningReqVo.getUpdateBy());
  1107. pmBidWinningOpeningRef.setUpdateTime(pmBidWinningReqVo.getUpdateTime());
  1108. pmBidWinningOpeningRefList.add(pmBidWinningOpeningRef);
  1109. }
  1110. LambdaQueryWrapper<SysFileRef> sysFileRefLambdaQueryWrapper = new LambdaQueryWrapper<>();
  1111. sysFileRefLambdaQueryWrapper.eq(SysFileRef::getType,SysFileRefEnum.PM_BID_WINNING_FILE.getType())
  1112. .eq(SysFileRef::getRedId,pmBidWinninglist.get(0));
  1113. List<SysFileRef> sysFileRefs = sysFileRefService.list(sysFileRefLambdaQueryWrapper);
  1114. uploadFile(pmBidWinning.getId(), SysFileRefEnum.PM_BID_WINNING_FILE.getType(), sysFileRefs, pmBidWinningReqVo.getUpdateBy());
  1115. return pmBidWinningOpeningRefService.saveBatch(pmBidWinningOpeningRefList);
  1116. } else {
  1117. return false;
  1118. }
  1119. }
  1120. /**
  1121. * 流标
  1122. * @param pmBidFailureReqVo
  1123. * @return
  1124. * @throws Exception
  1125. */
  1126. @Override
  1127. @Transactional(rollbackFor = Exception.class)
  1128. public boolean insertPmBidFailure(PmBidFailureReqVo pmBidFailureReqVo) throws Exception {
  1129. PmBidFailure pmBidFailure = new PmBidFailure();
  1130. BeanUtils.copyProperties(pmBidFailureReqVo, pmBidFailure);
  1131. if (pmBidFailureService.saveOrUpdate(pmBidFailure)) {
  1132. //把中标信息修改状态
  1133. LambdaQueryWrapper<PmBidWinning> lw = new LambdaQueryWrapper<>();
  1134. lw.eq(PmBidWinning::getDemandId, pmBidFailureReqVo.getDemandId()).eq(PmBidWinning::getStatus,BidWinningStatus.NORMAL.getCode());
  1135. List<PmBidWinning> pmBidWinninglist = pmBidWinningService.list(lw);
  1136. if (!ObjectUtils.isEmpty(pmBidWinninglist)) {
  1137. for(PmBidWinning item : pmBidWinninglist) {
  1138. UpdateWrapper<PmBidWinning> updateWrapper1 = new UpdateWrapper<>();
  1139. updateWrapper1.lambda().set(PmBidWinning::getStatus,BidWinningStatus.BE_BID_FAILURE.getCode())
  1140. .eq(PmBidWinning::getId,item.getId());
  1141. pmBidWinningService.update(updateWrapper1);
  1142. UpdateWrapper<PmBidWinningOpeningRef> updateWrapper2 = new UpdateWrapper<>();
  1143. updateWrapper2.lambda().set(PmBidWinningOpeningRef::getStatus,BidWinningStatus.BE_BID_FAILURE.getCode())
  1144. .eq(PmBidWinningOpeningRef::getWinningId,item.getId())
  1145. .eq(PmBidWinningOpeningRef::getStatus,BidWinningStatus.NORMAL.getCode());
  1146. pmBidWinningOpeningRefService.update(updateWrapper2);
  1147. }
  1148. }
  1149. uploadFile(pmBidFailure.getId(), SysFileRefEnum.PM_BID_FAILURE_FILE.getType(), pmBidFailureReqVo.getSysFileRefs(), pmBidFailureReqVo.getUpdateBy());
  1150. PmDemand pmDemandUpdate = new PmDemand();
  1151. pmDemandUpdate.setDemandId(pmBidFailureReqVo.getDemandId());
  1152. pmDemandUpdate.setProjectStatus(PmProjectStatus.WAIT_ANNOUNCEMENT.getCode());
  1153. pmDemandUpdate.setUpdateTime(pmBidFailureReqVo.getUpdateTime());
  1154. pmDemandUpdate.setUpdateBy(pmBidFailureReqVo.getUpdateBy());
  1155. return this.updateById(pmDemandUpdate);
  1156. } else {
  1157. return false;
  1158. }
  1159. }
  1160. @Override
  1161. @Transactional(rollbackFor = Exception.class)
  1162. public boolean insertContractInfo(PmContractInfoReqVo pmContractInfoReqVo) throws Exception {
  1163. Long demandId = pmContractInfoReqVo.getDemandId();
  1164. if (ObjectUtils.isEmpty(demandId)) {
  1165. throw new Exception("采购需求ID不能为空");
  1166. }
  1167. PmDemand pmDemand = this.getById(demandId);
  1168. if (ObjectUtils.isEmpty(pmDemand)) {
  1169. throw new Exception("采购需求ID错误");
  1170. }
  1171. List<SysFileRef> sysFileRefs = pmContractInfoReqVo.getSysFileRefs();
  1172. if (ObjectUtils.isEmpty(sysFileRefs)) {
  1173. throw new Exception("上传附件不能为空");
  1174. }
  1175. LambdaQueryWrapper<PmContractInfo> lambdaQueryWrapper = new LambdaQueryWrapper<>();
  1176. lambdaQueryWrapper.eq(PmContractInfo::getDemandId, demandId);
  1177. PmContractInfo pmContractInfo = pmContractInfoService.getOne(lambdaQueryWrapper);
  1178. if (pmContractInfo != null) {
  1179. pmContractInfoReqVo.setId(pmContractInfo.getId());
  1180. BeanUtils.copyProperties(pmContractInfoReqVo, pmContractInfo);
  1181. pmContractInfo.setUpdateTime(pmContractInfoReqVo.getUpdateTime());
  1182. pmContractInfo.setUpdateBy(pmContractInfoReqVo.getUpdateBy());
  1183. } else {
  1184. pmContractInfo = new PmContractInfo();
  1185. BeanUtils.copyProperties(pmContractInfoReqVo, pmContractInfo);
  1186. pmContractInfo.setCreateBy(pmContractInfoReqVo.getCreateBy());
  1187. pmContractInfo.setCreateTime(pmContractInfoReqVo.getCreateTime());
  1188. pmContractInfo.setUpdateTime(pmContractInfoReqVo.getUpdateTime());
  1189. pmContractInfo.setUpdateBy(pmContractInfoReqVo.getUpdateBy());
  1190. }
  1191. if (pmContractInfoService.saveOrUpdate(pmContractInfo)) {
  1192. this.uploadFile(pmContractInfo.getId(), SysFileRefEnum.PM_CONTRACT_INFO.getType(), sysFileRefs, pmContractInfoReqVo.getUpdateBy());
  1193. PmDemand pmDemandUpdate = new PmDemand();
  1194. pmDemandUpdate.setDemandId(demandId);
  1195. pmDemandUpdate.setProjectStatus(PmProjectStatus.UNDER_CONSTRUCTION.getCode());
  1196. pmDemandUpdate.setUpdateTime(pmContractInfoReqVo.getUpdateTime());
  1197. pmDemandUpdate.setUpdateBy(pmContractInfoReqVo.getUpdateBy());
  1198. return this.updateById(pmDemandUpdate);
  1199. } else {
  1200. return false;
  1201. }
  1202. }
  1203. @Override
  1204. @Transactional(rollbackFor = Exception.class)
  1205. public boolean insertProjectConstruction(PmProjectConstructionReqVo pmProjectConstructionReqVo) throws Exception {
  1206. Long demandId = pmProjectConstructionReqVo.getDemandId();
  1207. if (ObjectUtils.isEmpty(demandId)) {
  1208. throw new Exception("采购需求ID不能为空");
  1209. }
  1210. PmDemand pmDemand = this.getById(demandId);
  1211. if (ObjectUtils.isEmpty(pmDemand)) {
  1212. throw new Exception("采购需求ID错误");
  1213. }
  1214. List<SysFileRef> sysFileRefs = pmProjectConstructionReqVo.getSysFileRefs();
  1215. if (ObjectUtils.isEmpty(sysFileRefs)) {
  1216. throw new Exception("上传附件不能为空");
  1217. }
  1218. LambdaQueryWrapper<PmProjectConstruction> lambdaQueryWrapper = new LambdaQueryWrapper<>();
  1219. lambdaQueryWrapper.eq(PmProjectConstruction::getDemandId, demandId);
  1220. PmProjectConstruction pmProjectConstruction = pmProjectConstructionService.getOne(lambdaQueryWrapper);
  1221. if (pmProjectConstruction != null) {
  1222. pmProjectConstructionReqVo.setId(pmProjectConstruction.getId());
  1223. BeanUtils.copyProperties(pmProjectConstructionReqVo, pmProjectConstruction);
  1224. pmProjectConstruction.setUpdateBy(pmProjectConstructionReqVo.getUpdateBy());
  1225. pmProjectConstruction.setUpdateTime(pmProjectConstructionReqVo.getUpdateTime());
  1226. } else {
  1227. pmProjectConstruction = new PmProjectConstruction();
  1228. BeanUtils.copyProperties(pmProjectConstructionReqVo, pmProjectConstruction);
  1229. pmProjectConstruction.setCreateBy(pmProjectConstructionReqVo.getCreateBy());
  1230. pmProjectConstruction.setCreateTime(pmProjectConstructionReqVo.getCreateTime());
  1231. pmProjectConstruction.setUpdateBy(pmProjectConstructionReqVo.getUpdateBy());
  1232. pmProjectConstruction.setUpdateTime(pmProjectConstructionReqVo.getUpdateTime());
  1233. }
  1234. if (pmProjectConstructionService.saveOrUpdate(pmProjectConstruction)) {
  1235. this.uploadFile(pmProjectConstruction.getId(), SysFileRefEnum.PM_PROJECT_CONSTRUCTION.getType(), sysFileRefs, pmProjectConstructionReqVo.getUpdateBy());
  1236. PmDemand pmDemandUpdate = new PmDemand();
  1237. pmDemandUpdate.setDemandId(demandId);
  1238. pmDemandUpdate.setProjectStatus(PmProjectStatus.COMPLETION_CONSTRUCTION.getCode());
  1239. pmDemandUpdate.setRealDeliverTime(pmProjectConstructionReqVo.getUpdateTime());
  1240. pmDemandUpdate.setUpdateTime(pmProjectConstructionReqVo.getUpdateTime());
  1241. pmDemandUpdate.setUpdateBy(pmProjectConstructionReqVo.getUpdateBy());
  1242. return this.updateById(pmDemandUpdate);
  1243. } else {
  1244. return false;
  1245. }
  1246. }
  1247. /**
  1248. * 通过需求ID列表 查询采购执行列表 sunhh
  1249. *
  1250. * @param demandIdList
  1251. * @return
  1252. */
  1253. @Override
  1254. public List<PmDemand> selectByDemandIdList(List<Integer> demandIdList) {
  1255. return this.baseMapper.selectByDemandIdList(demandIdList);
  1256. }
  1257. /**
  1258. * 专家库--查询抽取专家列表 非必传条件:专家名称,开始结束时间 sunhh
  1259. *
  1260. * @param baseExpertVo
  1261. * @return
  1262. */
  1263. @Override
  1264. public List<PmDemand> selectExtractionExpert(BaseExpertVo baseExpertVo) {
  1265. return this.baseMapper.selectExtractionExpert(baseExpertVo);
  1266. }
  1267. @Override
  1268. public List<PmDemandResVo> demandWaitCommit() {
  1269. return getListByStatus(PmProjectStatus.DEMAND_WAIT_COMMIT.getCode());
  1270. }
  1271. @Override
  1272. public List<PmDemandResVo> contractWaitFilled() {
  1273. return getListByStatus(PmProjectStatus.CONTRACT_WAIT_FILL.getCode());
  1274. }
  1275. @Override
  1276. public List<PmDemandResVo> projectWaitFinish() {
  1277. return getListByStatus(PmProjectStatus.UNDER_CONSTRUCTION.getCode());
  1278. }
  1279. @Override
  1280. public List<PmDemandResVo> demandWaitExamine() {
  1281. return getListByStatus(PmProjectStatus.DEMAND_WAIT_AUDIT.getCode());
  1282. }
  1283. @Override
  1284. public List<PmDemandResVo> taskWaitRelease() {
  1285. return getListByStatus(PmProjectStatus.TASK_WAIT_RELEASE.getCode());
  1286. }
  1287. @Override
  1288. public List<PmDemandResVo> waitSelectAgent() {
  1289. return getListByStatus(PmProjectStatus.WAIT_SELECT_AGENT.getCode());
  1290. }
  1291. @Override
  1292. public List<PmDemandResVo> waitUpBidFile() {
  1293. return getListByStatus(PmProjectStatus.WAIT_UPLOAD_BID_FILE.getCode());
  1294. }
  1295. @Override
  1296. public List<PmDemandResVo> waitAnnouncement() {
  1297. return getListByStatus(PmProjectStatus.WAIT_ANNOUNCEMENT.getCode());
  1298. }
  1299. @Override
  1300. public List<PmDemandResVo> waitOpenBid() {
  1301. return getListByStatus(PmProjectStatus.WAIT_OPEN_BID.getCode());
  1302. }
  1303. @Override
  1304. public List<PmDemandResVo> waitBidAnnouncement() {
  1305. return getListByStatus(PmProjectStatus.WAIT_BID_ANNOUNCEMENT.getCode());
  1306. }
  1307. @Override
  1308. public List<PmDemandResVo> biddingPublicity() {
  1309. return getListByStatus(PmProjectStatus.BIDDING_PUBLICITY.getCode());
  1310. }
  1311. @Override
  1312. public AjaxResult procurementOfficeWillManipulateTotal() {
  1313. List<HomeToDoQueryResVo> homeRes = new ArrayList<>();
  1314. // 待选取代理, 待上传招标文件, 待发布公告, 待开标, 待发布中标公告, 中标公示中
  1315. List<PmDemandResVo> demandRes = new ArrayList<>();
  1316. demandRes.addAll(getListByStatus(PmProjectStatus.WAIT_SELECT_AGENT.getCode()));
  1317. demandRes.addAll(getListByStatus(PmProjectStatus.WAIT_UPLOAD_BID_FILE.getCode()));
  1318. demandRes.addAll(getListByStatus(PmProjectStatus.WAIT_ANNOUNCEMENT.getCode()));
  1319. demandRes.addAll(getListByStatus(PmProjectStatus.WAIT_OPEN_BID.getCode()));
  1320. demandRes.addAll(getListByStatus(PmProjectStatus.WAIT_BID_ANNOUNCEMENT.getCode()));
  1321. demandRes.addAll(getListByStatus(PmProjectStatus.BIDDING_PUBLICITY.getCode()));
  1322. //计划数据--发函催告
  1323. List<PlanQuarterResponseVo> planRes = planYearsService.willSendLetter();
  1324. //转为首页table展示数据
  1325. if (!ObjectUtils.isEmpty(demandRes) && demandRes.size() > 0) {
  1326. for (PmDemandResVo demandResVoVo : demandRes) {
  1327. HomeToDoQueryResVo home = new HomeToDoQueryResVo();
  1328. BeanUtils.copyProperties(demandResVoVo, home);
  1329. homeRes.add(home);
  1330. }
  1331. }
  1332. if (!ObjectUtils.isEmpty(planRes) && planRes.size() > 0) {
  1333. for (PlanQuarterResponseVo planVo : planRes) {
  1334. HomeToDoQueryResVo home = new HomeToDoQueryResVo();
  1335. BeanUtils.copyProperties(planVo, home);
  1336. homeRes.add(home);
  1337. }
  1338. }
  1339. return AjaxResult.success(homeRes);
  1340. }
  1341. /**
  1342. * 统计分析-采购项目信息统计
  1343. *
  1344. * @param pmDemandReqVo
  1345. * @return
  1346. */
  1347. @Override
  1348. public Map<String, Integer> purchaseProjectStatistical(PmDemandReqVo pmDemandReqVo) {
  1349. Map<String, Integer> mapReturn = new HashMap<>();
  1350. // 查询项目总数量
  1351. Map<String, Integer> mapCount = pmDemandMapper.purchaseProjectStatistical(pmDemandReqVo);
  1352. // 查询已完成项目数量,预算金额数量
  1353. Map<String, Integer> mapYWC = pmDemandMapper.purchaseProjectStatisticalYWC(pmDemandReqVo);
  1354. // 查询新创建项目数量,预算金额数量
  1355. Map<String, Integer> mapXCJ = pmDemandMapper.purchaseProjectStatisticalXCJ(pmDemandReqVo);
  1356. // 查询去年完成项目数量,预算金额数量
  1357. Map<String, Integer> mapQNWC = pmDemandMapper.purchaseProjectStatisticalQNWC(pmDemandReqVo);
  1358. mapReturn.putAll(mapCount);
  1359. mapReturn.putAll(mapYWC);
  1360. mapReturn.putAll(mapXCJ);
  1361. mapReturn.putAll(mapQNWC);
  1362. return mapReturn;
  1363. }
  1364. @Override
  1365. public List<StatisticalChartsResVo> countByProjectAttr() {
  1366. List<StatisticalChartsResVo> resVos = pmDemandMapper.countByProjectAttr();
  1367. for (StatisticalChartsResVo chartsResVo : resVos) {
  1368. for (PmProjectStatus value : PmProjectStatus.values()) {
  1369. if (value.getCode().equals(chartsResVo.getColumnName())) {
  1370. chartsResVo.setColumnName(value.getInfo());
  1371. break;
  1372. }
  1373. }
  1374. }
  1375. return resVos;
  1376. }
  1377. @Override
  1378. public List<StatisticalChartsResVo> countByEvaluation(PmDemandReqVo pmDemandReqVo) {
  1379. List<StatisticalChartsResVo> resVos = new ArrayList<>();
  1380. //概算金额包括:100万以下采购任务、100至500万元采购任务、500至1000万元采购任务、1000至5000万元采购任务、5000至1亿元采购任务、1亿元及以上采购任务
  1381. StatisticalChartsResVo resVo = pmDemandMapper.countByEvaluationLt(100);
  1382. resVo.setColumnName("100万以下采购任务");
  1383. resVos.add(resVo);
  1384. StatisticalChartsResVo resVo1 = pmDemandMapper.countByEvaluationBet(100, 500);
  1385. resVo1.setColumnName("100至500万元采购任务");
  1386. resVos.add(resVo1);
  1387. StatisticalChartsResVo resVo2 = pmDemandMapper.countByEvaluationBet(500, 1000);
  1388. resVo2.setColumnName("500至1000万元采购任务");
  1389. resVos.add(resVo2);
  1390. StatisticalChartsResVo resVo3 = pmDemandMapper.countByEvaluationBet(1000, 5000);
  1391. resVo3.setColumnName("1000至5000万元采购任务");
  1392. resVos.add(resVo3);
  1393. StatisticalChartsResVo resVo4 = pmDemandMapper.countByEvaluationBet(5000, 10000);
  1394. resVo4.setColumnName("5000至1亿元采购任务");
  1395. resVos.add(resVo4);
  1396. StatisticalChartsResVo resVo5 = pmDemandMapper.countByEvaluationGt(10000);
  1397. resVo5.setColumnName("1亿元及以上采购任务");
  1398. resVos.add(resVo5);
  1399. return resVos;
  1400. }
  1401. @Override
  1402. public AjaxResult countProjectExceed(PmDemandReqVo pmDemandReqVo) {
  1403. HashMap<String, String> resMap = new HashMap<>();
  1404. //执行滞后采购项目:本年度所有的逾期项目数
  1405. //预算金额:本年度所有逾期项目累加的预算金额
  1406. StatisticalChartsResVo resVo = pmDemandMapper.countProjectExceed();
  1407. resMap.put("执行滞后采购项目", resVo.getNum());
  1408. resMap.put("预算金额", resVo.getEvaluationTotal());
  1409. //滞后项目数量占比:指本年度逾期项目数量/本年度所有项目数量
  1410. Integer thisYear = pmDemandMapper.countThisYear();
  1411. resMap.put("滞后项目数量占比", getPercent(Integer.parseInt(resVo.getNum()), thisYear));
  1412. return AjaxResult.success(resMap);
  1413. }
  1414. /**
  1415. * 统计不同时间维度的逾期项目
  1416. *
  1417. * @return
  1418. */
  1419. @Override
  1420. public AjaxResult exceedAnalysis(PmDemandReqVo pmDemandReqVo) {
  1421. HashMap<String, List<StatisticalChartsResVo>> resMap = new HashMap<>();
  1422. List<StatisticalChartsResVo> byYear = pmDemandMapper.countProjectExceedYear();
  1423. if (pmDemandReqVo.getTimeType().equals("1")) {
  1424. resMap.put("年", byYear);
  1425. } else if (pmDemandReqVo.getTimeType().equals("2")) {
  1426. List<StatisticalChartsResVo> byQuarter = new LinkedList<>();
  1427. for (StatisticalChartsResVo chartsResVo : byYear) {
  1428. for (int i = 1; i <= 4; i++) {
  1429. StatisticalChartsResVo quarter = pmDemandMapper.countProjectExceedQuarter(i, Integer.parseInt(chartsResVo.getColumnName()));
  1430. quarter.setColumnName(chartsResVo.getColumnName() + "年第" + i + "季度");
  1431. byQuarter.add(quarter);
  1432. }
  1433. }
  1434. resMap.put("季度", byQuarter);
  1435. } else if (pmDemandReqVo.getTimeType().equals("3")) {
  1436. List<StatisticalChartsResVo> byMonth = pmDemandMapper.countProjectExceedMonth();
  1437. resMap.put("月", byMonth);
  1438. }
  1439. return AjaxResult.success(resMap);
  1440. }
  1441. @Override
  1442. public AjaxResult taskQuantityAnalysis(PmDemandReqVo pmDemandReqVo) {
  1443. HashMap<String, List<StatisticalChartsResVo>> resMap = new HashMap<>();
  1444. //任务数量趋势分析:按照月、季度、年统计“项目属性”字段中“重大规划”属性的项目
  1445. List<StatisticalChartsResVo> byYear = pmDemandMapper.countProjectMajorByYear();
  1446. if (pmDemandReqVo.getTimeType().equals("1")) {
  1447. resMap.put("年", byYear);
  1448. } else if (pmDemandReqVo.getTimeType().equals("2")) {
  1449. List<StatisticalChartsResVo> byQuarter = new LinkedList<>();
  1450. for (StatisticalChartsResVo chartsResVo : byYear) {
  1451. for (int i = 1; i <= 4; i++) {
  1452. StatisticalChartsResVo quarter = pmDemandMapper.countProjectMajorByQuarter(i, Integer.parseInt(chartsResVo.getColumnName()));
  1453. quarter.setColumnName(chartsResVo.getColumnName() + "年第" + i + "季度");
  1454. byQuarter.add(quarter);
  1455. }
  1456. }
  1457. resMap.put("季度", byQuarter);
  1458. } else if (pmDemandReqVo.getTimeType().equals("3")) {
  1459. List<StatisticalChartsResVo> byMonth = pmDemandMapper.countProjectMajorByMonth();
  1460. resMap.put("月", byMonth);
  1461. }
  1462. return AjaxResult.success(resMap);
  1463. }
  1464. @Override
  1465. public AjaxResult newFinishPro() {
  1466. // 新完成采购任务数量:状态为“合同待填制”、“项目建设中”、“项目建设完成”的项目
  1467. // 预算金额:“合同待填制”、“项目建设中”、“项目建设完成”的项目累加的预算金额
  1468. List<StatisticalChartsResVo> everyStatusNum = pmDemandMapper.countEveryStatusNumTwo();
  1469. if (!ObjectUtils.isEmpty(everyStatusNum) && everyStatusNum.size() > 0) {
  1470. for (StatisticalChartsResVo vo : everyStatusNum) {
  1471. switch (vo.getColumnName()) {
  1472. case "15":
  1473. vo.setColumnName(PmProjectStatus.CONTRACT_WAIT_FILL.getInfo());
  1474. case "16":
  1475. vo.setColumnName(PmProjectStatus.UNDER_CONSTRUCTION.getInfo());
  1476. case "17":
  1477. vo.setColumnName(PmProjectStatus.COMPLETION_CONSTRUCTION.getInfo());
  1478. }
  1479. }
  1480. }
  1481. //合同金额:“合同待填制”、“项目建设中”、“项目建设完成”的项目累加的合同金额
  1482. return AjaxResult.success(everyStatusNum);
  1483. }
  1484. @Override
  1485. public AjaxResult countEveryStatusNum(PmDemandReqVo pmDemandReqVo) {
  1486. //指项目进行到各个阶段的数量
  1487. //阶段包括:待选取代理、待上传招标文件、待发布公告、待开标、待发布中标公告、中标公式中
  1488. List<StatisticalChartsResVo> everyStatusNum = pmDemandMapper.countEveryStatusNum();
  1489. if (!ObjectUtils.isEmpty(everyStatusNum) && everyStatusNum.size() > 0) {
  1490. for (StatisticalChartsResVo vo : everyStatusNum) {
  1491. switch (vo.getColumnName()) {
  1492. case "9":
  1493. vo.setColumnName(PmProjectStatus.WAIT_SELECT_AGENT.getInfo());
  1494. case "10":
  1495. vo.setColumnName(PmProjectStatus.WAIT_UPLOAD_BID_FILE.getInfo());
  1496. case "11":
  1497. vo.setColumnName(PmProjectStatus.WAIT_ANNOUNCEMENT.getInfo());
  1498. case "12":
  1499. vo.setColumnName(PmProjectStatus.WAIT_OPEN_BID.getInfo());
  1500. case "13":
  1501. vo.setColumnName(PmProjectStatus.WAIT_BID_ANNOUNCEMENT.getInfo());
  1502. case "14":
  1503. vo.setColumnName(PmProjectStatus.BIDDING_PUBLICITY.getInfo());
  1504. }
  1505. }
  1506. }
  1507. return AjaxResult.success(everyStatusNum);
  1508. }
  1509. @Override
  1510. public AjaxResult exceedMarketAnalysis(PmDemandReqVo pmDemandReqVo) {
  1511. //所有滞后
  1512. List<PmDemand> demandList = pmDemandMapper.countProjectExceedAll();
  1513. //滞后时长包括:滞后1个月以内的采购任务、滞后1至3个月采购任务、滞后3至6个月采购任务、滞后6个月至1年采购任务、滞后1年以上采购任务
  1514. HashMap<String, Integer> map = new LinkedHashMap<>();
  1515. map.put("滞后1个月以内的采购任务", 0);
  1516. map.put("滞后1至3个月采购任务", 0);
  1517. map.put("滞后3至6个月采购任务", 0);
  1518. map.put("滞后6个月至1年采购任务", 0);
  1519. map.put("滞后1年以上采购任务", 0);
  1520. if (!ObjectUtils.isEmpty(demandList) && demandList.size() > 0) {
  1521. for (PmDemand demand : demandList) {
  1522. //滞后时间
  1523. Long exTime = null;
  1524. if (!ObjectUtils.isEmpty(demand.getRealDemandCommitTime()) && demand.getRealDemandCommitTime().getTime() - demand.getPlanDemandSubTime().getTime() > 0) {
  1525. exTime = demand.getRealDemandCommitTime().getTime() - demand.getPlanDemandSubTime().getTime();
  1526. } else if (!ObjectUtils.isEmpty(demand.getRealPurchaseFinishTime()) && demand.getRealPurchaseFinishTime().getTime() - demand.getPlanPurchaseFinishTime().getTime() > 0) {
  1527. exTime = demand.getRealPurchaseFinishTime().getTime() - demand.getPlanPurchaseFinishTime().getTime();
  1528. } else if (!ObjectUtils.isEmpty(demand.getRealDeliverTime()) && demand.getRealDeliverTime().getTime() - demand.getPlanDeliverTime().getTime() > 0) {
  1529. exTime = demand.getRealDeliverTime().getTime() - demand.getPlanDeliverTime().getTime();
  1530. }
  1531. if (exTime < Long.valueOf("2592000000")) {
  1532. map.put("滞后1个月以内的采购任务", map.get("滞后1个月以内的采购任务") + 1);
  1533. }
  1534. if (exTime >= Long.valueOf("2592000000") && exTime < Long.valueOf("7776000000")) {
  1535. map.put("滞后1至3个月采购任务", map.get("滞后1至3个月采购任务") + 1);
  1536. }
  1537. if (exTime >= Long.valueOf("7776000000") && exTime < Long.valueOf("15552000000")) {
  1538. map.put("滞后3至6个月采购任务", map.get("滞后3至6个月采购任务") + 1);
  1539. }
  1540. if (exTime >= Long.valueOf("15552000000") && exTime < Long.valueOf("31104000000")) {
  1541. map.put("滞后6个月至1年采购任务", map.get("滞后6个月至1年采购任务") + 1);
  1542. }
  1543. if (exTime > Long.valueOf("31104000000")) {
  1544. map.put("滞后1年以上采购任务", map.get("滞后1年以上采购任务") + 1);
  1545. }
  1546. }
  1547. }
  1548. return AjaxResult.success(map);
  1549. }
  1550. @Override
  1551. public AjaxResult countMajorProject(PmDemandReqVo pmDemandReqVo) {
  1552. List<StatisticalChartsResVo> resVos = new ArrayList<>();
  1553. //数量:指本年度状态为“项目建设完成”的项目属性为“重大规划”的项目数
  1554. //预算金额:指本年度状态为“项目建设完成”的项目属性为“重大规划”的项目累加的预算金额
  1555. StatisticalChartsResVo resVo = new StatisticalChartsResVo();
  1556. resVo = pmDemandMapper.majorProjectByStatus(PmProjectStatus.COMPLETION_CONSTRUCTION.getCode());
  1557. resVo.setColumnName("今年已完成数量");
  1558. resVos.add(resVo);
  1559. //正常推进项目:指本年度正在进行中的项目属性为“重大规划”的项目数
  1560. //预算金额:指本年度正在进行中的项目属性为“重大规划”的项目累加的预算金额
  1561. StatisticalChartsResVo resVo1 = new StatisticalChartsResVo();
  1562. resVo1 = pmDemandMapper.majorProjectByStatus(PmProjectStatus.UNDER_CONSTRUCTION.getCode());
  1563. resVo1.setColumnName("正常推进数量");
  1564. resVos.add(resVo1);
  1565. //执行滞后数量:指本年度逾期项目中,项目属性为“重大规划”的项目数
  1566. //预算金额:指本年度正在进行中的项目属性为“重大规划”的项目累加的预算金额
  1567. StatisticalChartsResVo resVo2 = new StatisticalChartsResVo();
  1568. resVo2 = pmDemandMapper.countMajorProjectExceed();
  1569. resVo2.setColumnName("执行滞后数量");
  1570. resVos.add(resVo2);
  1571. //上年度重大规划采购任务数量:指上年度项目中,项目属性为“重大规划”的项目数
  1572. //预算金额:指上年度项目中,项目属性为“重大规划”的项目累加的预算金额
  1573. StatisticalChartsResVo resVo3 = new StatisticalChartsResVo();
  1574. resVo3 = pmDemandMapper.countMajorProjectLastYear();
  1575. resVo3.setColumnName("上年度重大规划采购任务数量");
  1576. resVos.add(resVo3);
  1577. //resVo2=pmDemandMapper.majorProjectByStatus(PmProjectStatus.COMPLETION_CONSTRUCTION.getCode());
  1578. return AjaxResult.success(resVos);
  1579. }
  1580. /**
  1581. * 通过计划ID查询项目数据
  1582. *
  1583. * @param planId
  1584. * @return
  1585. */
  1586. @Override
  1587. public PmDemand selectByPlanId(Integer planId) {
  1588. return pmDemandMapper.selectByPlanId(planId);
  1589. }
  1590. /**
  1591. * 采购项目--项目数量分析
  1592. *
  1593. * @param pmDemandReqVo
  1594. * @return
  1595. */
  1596. @Override
  1597. public Map<String, Integer> purchaseProjectNumber(PmDemandReqVo pmDemandReqVo) {
  1598. return null;
  1599. }
  1600. /**
  1601. * 项目执行进度统计
  1602. * 1、正常推进项目数量:指未完成并且没有逾期的项目
  1603. * 预算金额:指未完成并且没有逾期的项目累加的预算金额
  1604. * 2、未完成采购任务:“合同待填制”状态之前的项目
  1605. * 预算金额:“合同待填制”状态之前的项目累加的预算金额
  1606. *
  1607. * @param pmDemandReqVo
  1608. * @return
  1609. */
  1610. @Override
  1611. public Map<String, Integer> purchaseProjectExecute(PmDemandReqVo pmDemandReqVo) {
  1612. Map<String, Integer> mapReturn = new HashMap<>();
  1613. // 正常推进项目数量、预算金额
  1614. Map<String, Integer> mapNormalPropulsion = pmDemandMapper.purchaseProjectExecuteNormalPropulsion(pmDemandReqVo);
  1615. // 未完成采购任务,预算金额
  1616. Map<String, Integer> mapIncomplete = pmDemandMapper.purchaseProjectExecuteIncomplete(pmDemandReqVo);
  1617. mapReturn.putAll(mapNormalPropulsion);
  1618. mapReturn.putAll(mapIncomplete);
  1619. return mapReturn;
  1620. }
  1621. /**
  1622. * 已完成项目数量统计
  1623. *
  1624. * @param pmDemandReqVo
  1625. * @return
  1626. */
  1627. @Override
  1628. public List<Map<String, Integer>> purchaseProjectCompleteNumber(PmDemandReqVo pmDemandReqVo) {
  1629. List<Map<String, Integer>> mapReturn = new ArrayList<>();
  1630. // 统计时间类型 1:年度,2:季度,3:月份
  1631. if ("1".equals(pmDemandReqVo.getTimeType())) {
  1632. // 查询数据库中最小的年份
  1633. int minYear = pmDemandMapper.selectMinYear();
  1634. // 获取当前年份
  1635. Calendar calendar = Calendar.getInstance();
  1636. int year = calendar.get(Calendar.YEAR);
  1637. // 获取统计数据
  1638. List<Map<String, Integer>> listMap = pmDemandMapper.selectpurchaseProjectCompleteNumberYear(pmDemandReqVo);
  1639. mapReturn.addAll(listMap);
  1640. for (int i = minYear; i <= year; i++) {
  1641. for (Map<String, Integer> map : listMap) {
  1642. if (i != Integer.valueOf(map.get("yy"))) {
  1643. Map<String, Integer> map1 = new HashMap<>();
  1644. map1.put("yy", i);
  1645. map1.put("evaluation", 0);
  1646. map1.put("contractAmount", 0);
  1647. map1.put("countNum", 0);
  1648. mapReturn.add(map1);
  1649. }
  1650. }
  1651. }
  1652. } else if ("2".equals(pmDemandReqVo.getTimeType())) {
  1653. // 当前年份季度统计
  1654. // 获取统计数据
  1655. List<Map<String, Integer>> listMap = pmDemandMapper.selectpurchaseProjectCompleteNumberQuarter(pmDemandReqVo);
  1656. mapReturn.addAll(listMap);
  1657. for (int i = 1; i <= 4; i++) {
  1658. for (Map<String, Integer> map : listMap) {
  1659. if (i != map.get("yy")) {
  1660. Map<String, Integer> map1 = new HashMap<>();
  1661. map1.put("yy", i);
  1662. map1.put("evaluation", 0);
  1663. map1.put("contractAmount", 0);
  1664. map1.put("countNum", 0);
  1665. mapReturn.add(map1);
  1666. }
  1667. }
  1668. }
  1669. } else if ("3".equals(pmDemandReqVo.getTimeType())) {
  1670. // 当前年份月份统计
  1671. // 获取统计数据
  1672. List<Map<String, Integer>> listMap = pmDemandMapper.selectpurchaseProjectCompleteNumberMonth(pmDemandReqVo);
  1673. mapReturn.addAll(listMap);
  1674. for (int i = 1; i <= 12; i++) {
  1675. for (Map<String, Integer> map : listMap) {
  1676. int ii = Integer.parseInt(String.valueOf(map.get("yy")));
  1677. map.put("yy", ii);
  1678. if (i != ii) {
  1679. Map<String, Integer> map1 = new HashMap<>();
  1680. map1.put("yy", i);
  1681. map1.put("evaluation", 0);
  1682. map1.put("contractAmount", 0);
  1683. map1.put("countNum", 0);
  1684. mapReturn.add(map1);
  1685. }
  1686. }
  1687. }
  1688. }
  1689. return mapReturn;
  1690. }
  1691. /**
  1692. * 各阶段项目数量分布
  1693. * @param pmDemandReqVo
  1694. * @return
  1695. */
  1696. @Override
  1697. public List<Map<String, String>> purchaseProjectDistribution(PmDemandReqVo pmDemandReqVo) {
  1698. // 项目计划 4之前(包括4)
  1699. List<String> xmjh = new ArrayList<>();
  1700. xmjh.add("4");
  1701. pmDemandReqVo.setProjectStatusList(xmjh);
  1702. Map<String, String> returnMapxmjh = pmDemandMapper.purchaseProjectDistribution(pmDemandReqVo);
  1703. returnMapxmjh.put("name", "计划管理");
  1704. // 需求建党 4之后(不包括4)
  1705. List<String> xqjd = new ArrayList<>();
  1706. xqjd.add("5");
  1707. xqjd.add("6");
  1708. xqjd.add("7");
  1709. xqjd.add("8");
  1710. pmDemandReqVo.setProjectStatusList(xqjd);
  1711. Map<String, String> returnMapxqjd = pmDemandMapper.purchaseProjectDistribution(pmDemandReqVo);
  1712. returnMapxqjd.put("name", "需求管理");
  1713. // 任务下达 8之后(不包括8)
  1714. List<String> rwxd = new ArrayList<>();
  1715. rwxd.add("9");
  1716. pmDemandReqVo.setProjectStatusList(rwxd);
  1717. Map<String, String> returnMaprwxd = pmDemandMapper.purchaseProjectDistribution(pmDemandReqVo);
  1718. returnMaprwxd.put("name", "任务下达");
  1719. // 采购执行 9之后(不包括9)
  1720. List<String> cgzx = new ArrayList<>();
  1721. cgzx.add("10");
  1722. cgzx.add("11");
  1723. cgzx.add("12");
  1724. cgzx.add("13");
  1725. cgzx.add("14");
  1726. cgzx.add("15");
  1727. pmDemandReqVo.setProjectStatusList(cgzx);
  1728. Map<String, String> returnMapcgzx = pmDemandMapper.purchaseProjectDistribution(pmDemandReqVo);
  1729. returnMapcgzx.put("name", "采购执行");
  1730. // 合同管理 15之后(不包括15)
  1731. List<String> htxx = new ArrayList<>();
  1732. htxx.add("16");
  1733. pmDemandReqVo.setProjectStatusList(htxx);
  1734. Map<String, String> returnMaphtxx = pmDemandMapper.purchaseProjectDistribution(pmDemandReqVo);
  1735. returnMaphtxx.put("name", "合同管理");
  1736. // 项目建设 17
  1737. List<String> xmjs = new ArrayList<>();
  1738. xmjs.add("16");
  1739. pmDemandReqVo.setProjectStatusList(xmjs);
  1740. Map<String, String> returnMapxmjs = pmDemandMapper.purchaseProjectDistribution(pmDemandReqVo);
  1741. returnMapxmjs.put("name", "合同管理");
  1742. List<Map<String, String>> returnMap = new ArrayList<>();
  1743. returnMap.add(returnMapxmjh);
  1744. returnMap.add(returnMapxqjd);
  1745. returnMap.add(returnMaprwxd);
  1746. returnMap.add(returnMapcgzx);
  1747. returnMap.add(returnMaphtxx);
  1748. returnMap.add(returnMapxmjs);
  1749. return returnMap;
  1750. }
  1751. /**
  1752. * 项目数量分析
  1753. * @param pmDemandReqVo
  1754. * @return
  1755. */
  1756. @Override
  1757. public List<Map<String, String>> purchaseProjectNumberAnalysis(PmDemandReqVo pmDemandReqVo) {
  1758. List<Map<String, String>> mapReturn = new ArrayList<>();
  1759. // 统计时间类型 1:年度,2:季度,3:月份
  1760. if ("1".equals(pmDemandReqVo.getTimeType())) {
  1761. // *** 年度的同比和环比不展示 *** //
  1762. // 查询数据库中最小的年份
  1763. int minYear = pmDemandMapper.selectMinYear();
  1764. // 获取当前年份
  1765. Calendar calendar = Calendar.getInstance();
  1766. int year = calendar.get(Calendar.YEAR);
  1767. // 获取统计数据
  1768. // 获取项目统计
  1769. List<Map<String, String>> listMap = pmDemandMapper.purchaseProjectNumberAnalysisYear(pmDemandReqVo);
  1770. mapReturn.addAll(listMap);
  1771. for (int i = minYear; i <= year; i++) {
  1772. for (Map<String, String> map : listMap) {
  1773. if (i != Integer.valueOf(map.get("yy"))) {
  1774. Map<String, String> map1 = new HashMap<>();
  1775. map1.put("yy", i + "");
  1776. map1.put("countNum", 0 + "");
  1777. mapReturn.add(map1);
  1778. }
  1779. }
  1780. }
  1781. } else if ("2".equals(pmDemandReqVo.getTimeType())) {
  1782. // 当前年份季度统计
  1783. // 获取统计数据
  1784. List<Map<String, String>> listMap = pmDemandMapper.purchaseProjectNumberAnalysisQuarter(pmDemandReqVo);
  1785. mapReturn.addAll(listMap);
  1786. for (int i = 1; i <= 4; i++) {
  1787. for (Map<String, String> map : listMap) {
  1788. int ii = Integer.parseInt(String.valueOf(map.get("yy")));
  1789. map.put("yy", ii + "");
  1790. if (i != ii) {
  1791. Map<String, String> map1 = new HashMap<>();
  1792. map1.put("yy", i + "");
  1793. map1.put("countNum", 0 + "");
  1794. mapReturn.add(map1);
  1795. }
  1796. }
  1797. }
  1798. } else if ("3".equals(pmDemandReqVo.getTimeType())) {
  1799. // 当前年份月份统计
  1800. // 获取统计数据
  1801. List<Map<String, String>> listMap = pmDemandMapper.purchaseProjectNumberAnalysisMonth(pmDemandReqVo);
  1802. mapReturn.addAll(listMap);
  1803. for (int i = 1; i <= 12; i++) {
  1804. for (Map<String, String> map : listMap) {
  1805. int ii = Integer.parseInt(String.valueOf(map.get("yy")));
  1806. map.put("yy", ii + "");
  1807. if (i != ii) {
  1808. Map<String, String> map1 = new HashMap<>();
  1809. map1.put("yy", i + "");
  1810. map1.put("countNum", 0 + "");
  1811. mapReturn.add(map1);
  1812. }
  1813. }
  1814. }
  1815. }
  1816. return mapReturn;
  1817. }
  1818. //查询不同状态下的项目数据
  1819. public List<PmDemandResVo> getListByStatus(String projectStatus) {
  1820. LambdaQueryWrapper<PmDemand> lw = new LambdaQueryWrapper<PmDemand>();
  1821. lw.eq(PmDemand::getProjectStatus, projectStatus);
  1822. List<PmDemand> demandList = this.baseMapper.selectList(lw);
  1823. //数据转换
  1824. List<PmDemandResVo> pmDemandResponseVoList = new ArrayList<>();
  1825. if (!ObjectUtils.isEmpty(demandList) && demandList.size() > 0) {
  1826. pmDemandResponseVoList = demandChangeTo(demandList);
  1827. }
  1828. return pmDemandResponseVoList;
  1829. }
  1830. //字段转换and赋值
  1831. public List<PmDemandResVo> demandChangeTo(List<PmDemand> pmDemandList) {
  1832. List<PmDemandResVo> pmDemandResponseVoList = new ArrayList<>();
  1833. for (PmDemand pmDemand1 : pmDemandList) {
  1834. PmDemandResVo vo = new PmDemandResVo();
  1835. BeanUtils.copyProperties(pmDemand1, vo);
  1836. if (vo.getPurchaseDeptId() != null) {
  1837. Map<String, Object> deptMap = deptService.selectDeptById(vo.getPurchaseDeptId());
  1838. if (deptMap != null) {
  1839. SysDeptResponseVo sysDeptResponseVo = (SysDeptResponseVo) deptMap.get("sysDept");
  1840. if (sysDeptResponseVo != null) {
  1841. vo.setPurchaseDeptName(sysDeptResponseVo.getDeptName());
  1842. }
  1843. }
  1844. }
  1845. String purchaseServicesName = dictDataService.selectDictLabel("purchase_services", vo.getPurchaseServices());
  1846. if (StringUtils.isNotEmpty(purchaseServicesName)) {
  1847. vo.setPurchaseServicesName(purchaseServicesName);
  1848. }
  1849. //项目类型
  1850. for (ProjectTypes value : ProjectTypes.values()) {
  1851. if (vo.getProjectType() != null && vo.getProjectType().equals(value.getCode())) {
  1852. vo.setProjectTypeName(value.getInfo());
  1853. break;
  1854. }
  1855. }
  1856. //是否为超限额计划
  1857. for (IsExcess value : IsExcess.values()) {
  1858. if (vo.getIsExcess() != null && vo.getIsExcess().equals(value.getCode())) {
  1859. vo.setIsExcessName(value.getInfo());
  1860. break;
  1861. }
  1862. }
  1863. //采购方式
  1864. for (PlanPurchaseMode value : PlanPurchaseMode.values()) {
  1865. if (vo.getPurchaseMode() != null && vo.getPurchaseMode().equals(value.getCode())) {
  1866. vo.setPurchaseModeName(value.getInfo());
  1867. break;
  1868. }
  1869. }
  1870. //项目属性
  1871. for (ProjectAttribute value : ProjectAttribute.values()) {
  1872. if (vo.getProjectAttr() != null && vo.getProjectAttr().equals(value.getCode())) {
  1873. vo.setProjectAttrName(value.getInfo());
  1874. break;
  1875. }
  1876. }
  1877. //预警状态
  1878. for (WarnStatus value : WarnStatus.values()) {
  1879. if (vo.getWarnStatus() != null && vo.getWarnStatus().equals(value.getCode())) {
  1880. vo.setWarnStatusName(value.getInfo());
  1881. break;
  1882. }
  1883. }
  1884. //项目状态
  1885. for (PmProjectStatus value : PmProjectStatus.values()) {
  1886. if (vo.getProjectStatus() != null && vo.getProjectStatus().equals(value.getCode())) {
  1887. vo.setProjectStatusName(value.getInfo());
  1888. break;
  1889. }
  1890. }
  1891. try {
  1892. vo.setTipsMessage(pmDemandGetTips(vo.getPlanDeliverTime()));
  1893. if (vo.getTipsMessage().contains("超过")) {
  1894. vo.setIsExceedProject("1");
  1895. }
  1896. } catch (ParseException e) {
  1897. e.printStackTrace();
  1898. }
  1899. pmDemandResponseVoList.add(vo);
  1900. }
  1901. return pmDemandResponseVoList;
  1902. }
  1903. /**
  1904. * 根据年度计划提报时间的阈值进行提示
  1905. *
  1906. * @return
  1907. */
  1908. public String pmDemandGetTips(Date planDeliverTime) throws ParseException {
  1909. if (!ObjectUtils.isEmpty(planDeliverTime)) {
  1910. //提示信息:定义距离结束时间一周内提示
  1911. Integer remindTine = 1000 * 60 * 60 * 24 * 7;
  1912. //少于一周便提醒
  1913. double surplus = planDeliverTime.getTime() - System.currentTimeMillis();
  1914. if (surplus < remindTine) {
  1915. int i = new Double(Math.ceil(surplus / 1000 / 60 / 60 / 24)).intValue();
  1916. //剩余天数(向上取整)
  1917. if (i > 0) {
  1918. return "距离计划交付时间不足" + i + "天";
  1919. } else {
  1920. return "已超过计划完成时间" + i + "天";
  1921. }
  1922. }
  1923. }
  1924. return "";
  1925. }
  1926. /**
  1927. * 计算百分比:使用java.text.DecimalFormat实现
  1928. *
  1929. * @param x
  1930. * @param y
  1931. * @return
  1932. */
  1933. public static String getPercent(int x, int y) {
  1934. double d1 = x * 1.0;
  1935. double d2 = y * 1.0;
  1936. // 设置保留几位小数, “.”后面几个零就保留几位小数,这里设置保留2位小数
  1937. DecimalFormat decimalFormat = new DecimalFormat("##.00%");
  1938. return decimalFormat.format(d1 / d2);
  1939. }
  1940. }