1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185 |
- package com.ozs.pm.service.impl;
- import java.text.DecimalFormat;
- import java.text.ParseException;
- import java.util.*;
- import java.util.stream.Collectors;
- import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
- import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
- import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
- import com.baomidou.mybatisplus.core.metadata.IPage;
- import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
- import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
- import com.ozs.base.domain.*;
- import com.ozs.base.domain.vo.BaseExpertVo;
- import com.ozs.base.service.*;
- import com.ozs.common.core.domain.AjaxResult;
- import com.ozs.common.core.domain.entity.SysDept;
- import com.ozs.common.core.domain.entity.SysRole;
- import com.ozs.common.core.domain.entity.SysUser;
- import com.ozs.common.enums.*;
- import com.ozs.common.utils.DateUtils;
- import com.ozs.common.utils.RandomUtil;
- import com.ozs.common.utils.SecurityUtils;
- import com.ozs.common.utils.StringUtils;
- import com.ozs.common.utils.bean.BeanUtils;
- import com.ozs.home.domain.vo.HomeToDoQueryResVo;
- import com.ozs.plan.doman.vo.responseVo.PlanQuarterResponseVo;
- import com.ozs.plan.service.PlanYearsService;
- import com.ozs.pm.doman.*;
- import com.ozs.pm.doman.vo.requestVo.*;
- import com.ozs.pm.doman.vo.responseVo.*;
- import com.ozs.pm.mapper.PmDemandMapper;
- import com.ozs.pm.service.*;
- import com.ozs.system.domain.SysFileInfo;
- import com.ozs.system.domain.SysFileRef;
- import com.ozs.system.domain.vo.SysRegionVO;
- import com.ozs.system.domain.vo.responseVo.SysDeptResponseVo;
- import com.ozs.system.mapper.SysDeptMapper;
- import com.ozs.system.mapper.SysRoleMapper;
- import com.ozs.system.service.*;
- import io.swagger.models.auth.In;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Service;
- import org.springframework.transaction.annotation.Transactional;
- import org.springframework.util.CollectionUtils;
- import org.springframework.util.ObjectUtils;
- /**
- * 采购需求Service业务层处理
- *
- * @author ruoyi
- * @date 2023-01-16
- */
- @Service
- public class PmDemandServiceImpl extends ServiceImpl<PmDemandMapper, PmDemand> implements IPmDemandService {
- @Autowired
- private PmDemandMapper pmDemandMapper;
- @Autowired
- private ISysDeptService deptService;
- @Autowired
- private ISysDictDataService dictDataService;
- @Autowired
- private SysFileService fileService;
- @Autowired
- private SysFileRefService sysFileRefService;
- @Autowired
- private IPmFlowChartService iPmFlowChartService;
- @Autowired
- private PmReleaseAnnouncementService pmReleaseAnnouncementService;
- @Autowired
- private BaseExpertService baseExpertService;
- @Autowired
- private PmDemandExpertRefService pmDemandExpertRefService;
- @Autowired
- private PmBidOpeningService pmBidOpeningService;
- @Autowired
- private PmBookBuildingService pmBookBuildingService;
- @Autowired
- private PmBidWinningService pmBidWinningService;
- @Autowired
- private PmBidFailureService pmBidFailureService;
- @Autowired
- private PmBidWinningOpeningRefService pmBidWinningOpeningRefService;
- @Autowired
- private PmContractInfoService pmContractInfoService;
- @Autowired
- private BaseAgencyService baseAgencyService;
- @Autowired
- private PmProjectConstructionService pmProjectConstructionService;
- @Autowired
- private BaseNoticeTypeService baseNoticeTypeService;
- @Autowired
- private BaseNoticeService baseNoticeService;
- @Autowired
- private PlanYearsService planYearsService;
- @Autowired
- private ISysRegionService iSysRegionService;
- @Autowired
- private SysRoleMapper sysRoleMapper;
- @Autowired
- private ISysUserService userService;
- @Autowired
- private SysDeptMapper deptMapper;
- /**
- * 查询采购需求
- *
- * @param demandId 采购需求主键
- * @return 采购需求
- */
- @Override
- public PmDemandResVo selectPmDemandByDemandId(Long demandId, String detailType) {
- PmDemand pmDemand = this.getById(demandId);
- if (pmDemand != null) {
- PmDemandResVo vo = new PmDemandResVo();
- vo.setProjectName(pmDemand.getProjectName());
- vo.setDemandId(demandId);
- if ("1".equals(detailType)) { //项目计划
- BeanUtils.copyProperties(pmDemand, vo);
- SysDeptResponseVo sysDeptResponseVo = (SysDeptResponseVo) deptService.selectDeptById(vo.getPurchaseDeptId()).get("sysDept");
- if (sysDeptResponseVo != null) {
- vo.setPurchaseDeptName(sysDeptResponseVo.getDeptName());
- }
- String purchaseServicesName = dictDataService.selectDictLabel("purchase_services", vo.getPurchaseServices());
- if (StringUtils.isNotEmpty(purchaseServicesName)) {
- vo.setPurchaseServicesName(purchaseServicesName);
- }
- //采购需求附件
- List<SysFileInfo> demandFileInfos = getSysFileInfoList(vo.getDemandId(), SysFileRefEnum.PM_DEMAND.getType());
- if (!ObjectUtils.isEmpty(demandFileInfos)) {
- vo.setDemandFileInfos(demandFileInfos);
- }
- //项目类型
- for (ProjectTypes value : ProjectTypes.values()) {
- if (vo.getProjectType() != null && vo.getProjectType().equals(value.getCode())) {
- vo.setProjectTypeName(value.getInfo());
- break;
- }
- }
- //是否为超限额计划
- for (IsExcess value : IsExcess.values()) {
- if (vo.getIsExcess() != null && vo.getIsExcess().equals(value.getCode())) {
- vo.setIsExcessName(value.getInfo());
- break;
- }
- }
- //采购方式
- for (PlanPurchaseMode value : PlanPurchaseMode.values()) {
- if (vo.getPurchaseMode() != null && vo.getPurchaseMode().equals(value.getCode())) {
- vo.setPurchaseModeName(value.getInfo());
- break;
- }
- }
- //项目属性
- for (ProjectAttribute value : ProjectAttribute.values()) {
- if (vo.getProjectAttr() != null && vo.getProjectAttr().equals(value.getCode())) {
- vo.setProjectAttrName(value.getInfo());
- break;
- }
- }
- //预警状态
- for (WarnStatus value : WarnStatus.values()) {
- if (vo.getWarnStatus() != null && vo.getWarnStatus().equals(value.getCode())) {
- vo.setWarnStatusName(value.getInfo());
- break;
- }
- }
- //项目状态
- for (PmProjectStatus value : PmProjectStatus.values()) {
- if (vo.getProjectStatus() != null && vo.getProjectStatus().equals(value.getCode())) {
- vo.setProjectStatusName(value.getInfo());
- break;
- }
- }
- } else if ("2".equals(detailType)) { //需求建档
- //采购需求审核文件
- List<SysFileInfo> auditFileInfos = getSysFileInfoList(vo.getDemandId(), SysFileRefEnum.PM_DEMAND_EXAMINE.getType());
- if (!ObjectUtils.isEmpty(auditFileInfos)) {
- vo.setAuditFileInfos(auditFileInfos);
- }
- LambdaQueryWrapper<PmBookBuilding> lambdaQueryWrapper = new LambdaQueryWrapper<>();
- lambdaQueryWrapper.eq(PmBookBuilding::getDemandId, demandId);
- PmBookBuilding pmBookBuilding = pmBookBuildingService.getOne(lambdaQueryWrapper);
- if (pmBookBuilding != null) {
- PmBookBuildingResVo responseVo = new PmBookBuildingResVo();
- BeanUtils.copyProperties(pmBookBuilding, responseVo);
- List<SysFileInfo> fileInfos = getSysFileInfoList(pmBookBuilding.getId(), SysFileRefEnum.PM_BOOK_BUILDING.getType());
- if (!ObjectUtils.isEmpty(fileInfos)) {
- responseVo.setFileInfos(fileInfos);
- }
- vo.setPmBookBuildingResVo(responseVo);
- }
- } else if ("3".equals(detailType)) { //任务下达
- //任务下达文件
- List<SysFileInfo> taskReleaseFileInfos = getSysFileInfoList(vo.getDemandId(), SysFileRefEnum.PM_TAST_RELEASE.getType());
- if (!ObjectUtils.isEmpty(taskReleaseFileInfos)) {
- vo.setTaskReleaseFileInfos(taskReleaseFileInfos);
- }
- } else if ("4".equals(detailType)) { //中标信息
- PmPurchaseExecutionResVo pmPurchaseExecutionResVo = new PmPurchaseExecutionResVo();
- //代理商信息
- BaseAgency baseAgency = this.baseAgencyService.getById(pmDemand.getAgencyId());
- pmPurchaseExecutionResVo.setBaseAgency(baseAgency);
- //发布公告列表
- LambdaQueryWrapper<PmReleaseAnnouncement> lambdaQueryWrapper = new LambdaQueryWrapper<>();
- lambdaQueryWrapper.eq(PmReleaseAnnouncement::getDemandId, demandId);
- List<PmReleaseAnnouncement> pmReleaseAnnouncementList = this.pmReleaseAnnouncementService.list(lambdaQueryWrapper);
- if (!ObjectUtils.isEmpty(pmReleaseAnnouncementList)) {
- List<PmReleaseAnnouncementResVo> pmReleaseAnnouncementResVoList = new ArrayList<>();
- for (PmReleaseAnnouncement pmReleaseAnnouncement : pmReleaseAnnouncementList) {
- PmReleaseAnnouncementResVo pmReleaseAnnouncementResVo = new PmReleaseAnnouncementResVo();
- BeanUtils.copyProperties(pmReleaseAnnouncement, pmReleaseAnnouncementResVo);
- List<SysFileInfo> fileInfos = getSysFileInfoList(pmReleaseAnnouncement.getId(), SysFileRefEnum.PM_ANNOUNCEMENT_FILE.getType());
- if (!ObjectUtils.isEmpty(fileInfos)) {
- pmReleaseAnnouncementResVo.setFileInfos(fileInfos);
- }
- pmReleaseAnnouncementResVoList.add(pmReleaseAnnouncementResVo);
- }
- pmPurchaseExecutionResVo.setPmReleaseAnnouncementResVoList(pmReleaseAnnouncementResVoList);
- }
- //专家信息列表
- List<PmBaseExpertResVo> pmBaseExpertResVoList = this.pmDemandExpertRefService.getPmBaseExpertResVoList(demandId);
- pmPurchaseExecutionResVo.setPmBaseExpertResVoList(pmBaseExpertResVoList);
- //开标信息列表
- List<PmBidOpeningResVo> pmBidOpeningResVoList = this.pmBidOpeningService.getPmBidOpeningResVoList(demandId);
- pmPurchaseExecutionResVo.setPmBidOpeningResVoList(pmBidOpeningResVoList);
- //中标信息列表
- LambdaQueryWrapper<PmBidWinning> lambdaQueryWrapper1 = new LambdaQueryWrapper<>();
- lambdaQueryWrapper1.eq(PmBidWinning::getDemandId, demandId)
- .eq(PmBidWinning::getStatus,BidWinningStatus.NORMAL.getCode());
- PmBidWinning pmBidWinning = this.pmBidWinningService.getOne(lambdaQueryWrapper1);
- if (!ObjectUtils.isEmpty(pmBidWinning)) {
- LambdaQueryWrapper<PmBidWinningOpeningRef> lambdaQueryWrapper2 = new LambdaQueryWrapper<>();
- lambdaQueryWrapper2.eq(PmBidWinningOpeningRef::getWinningId,pmBidWinning.getId())
- .eq(PmBidWinningOpeningRef::getStatus,BidWinningStatus.NORMAL.getCode());
- List<PmBidWinningOpeningRef> pmBidWinningOpeningRefList = this.pmBidWinningOpeningRefService.list(lambdaQueryWrapper2);
- if(!ObjectUtils.isEmpty(pmBidWinningOpeningRefList)){
- List<PmBidWinningResVo> pmBidWinningResVoList = new ArrayList<>();
- for (PmBidWinningOpeningRef pmBidWinningOpeningRef : pmBidWinningOpeningRefList) {
- PmBidOpening pmBidOpening = this.pmBidOpeningService.getById(pmBidWinningOpeningRef.getOpeningId());
- if(pmBidOpening != null){
- PmBidWinningResVo pmBidWinningResVo = new PmBidWinningResVo();
- BeanUtils.copyProperties(pmBidWinning, pmBidWinningResVo);
- pmBidWinningResVo.setBidWinningName(pmBidOpening.getBidderName());
- List<SysFileInfo> fileInfos = getSysFileInfoList(pmBidWinning.getId(), SysFileRefEnum.PM_BID_WINNING_FILE.getType());
- if (!ObjectUtils.isEmpty(fileInfos)) {
- pmBidWinningResVo.setFileInfos(fileInfos);
- }
- pmBidWinningResVoList.add(pmBidWinningResVo);
- }
- }
- pmPurchaseExecutionResVo.setPmBidWinningResVoList(pmBidWinningResVoList);
- }
- }
- pmPurchaseExecutionResVo.setCallQuestion(pmDemand.getCallQuestion());
- //质疑情况
- List<SysFileInfo> callRequestFileInfos = getSysFileInfoList(vo.getDemandId(), SysFileRefEnum.PM_BID_CALL_QEUSTION_FILE.getType());
- if (!ObjectUtils.isEmpty(callRequestFileInfos)) {
- pmPurchaseExecutionResVo.setCallRequestFileInfos(callRequestFileInfos);
- }
- //流标情况
- LambdaQueryWrapper<PmBidFailure> lambdaQueryWrapper2 = new LambdaQueryWrapper<>();
- lambdaQueryWrapper2.eq(PmBidFailure::getDemandId, demandId).orderByDesc(PmBidFailure::getBidFailureTime);
- List<PmBidFailure> pmBidFailureList = this.pmBidFailureService.list(lambdaQueryWrapper2);
- if (!ObjectUtils.isEmpty(pmBidFailureList)) {
- List<PmBidFailureResVo> pmBidFailureResVoList = new ArrayList<>();
- for (PmBidFailure pmBidFailure : pmBidFailureList) {
- PmBidFailureResVo pmBidFailureResVo = new PmBidFailureResVo();
- BeanUtils.copyProperties(pmBidFailure, pmBidFailureResVo);
- List<SysFileInfo> fileInfos = getSysFileInfoList(pmBidFailure.getId(), SysFileRefEnum.PM_BID_FAILURE_FILE.getType());
- if (!ObjectUtils.isEmpty(fileInfos)) {
- pmPurchaseExecutionResVo.setFileInfos(fileInfos);
- }
- pmBidFailureResVoList.add(pmBidFailureResVo);
- }
- pmPurchaseExecutionResVo.setPmBidFailureResVoList(pmBidFailureResVoList);
- }
- //中标通知书
- List<SysFileInfo> pmBidWinningNotificationFileInfos = getSysFileInfoList(vo.getDemandId(), SysFileRefEnum.PM_BID_WINNING_NOTIFICATION.getType());
- if (!ObjectUtils.isEmpty(pmBidWinningNotificationFileInfos)) {
- pmPurchaseExecutionResVo.setPmBidWinningNotificationFileInfos(pmBidWinningNotificationFileInfos);
- }
- vo.setPmPurchaseExecutionResVo(pmPurchaseExecutionResVo);
- } else if ("5".equals(detailType)) { //合同信息
- LambdaQueryWrapper<PmContractInfo> lambdaQueryWrapper = new LambdaQueryWrapper<>();
- lambdaQueryWrapper.eq(PmContractInfo::getDemandId, demandId);
- PmContractInfo pmContractInfo = pmContractInfoService.getOne(lambdaQueryWrapper);
- if (pmContractInfo != null) {
- PmContractInfoResVo pmContractInfoResVo = new PmContractInfoResVo();
- BeanUtils.copyProperties(pmContractInfo, pmContractInfoResVo);
- //合同信息文件
- List<SysFileInfo> fileInfos = getSysFileInfoList(pmContractInfo.getId(), SysFileRefEnum.PM_CONTRACT_INFO.getType());
- if (!ObjectUtils.isEmpty(fileInfos)) {
- pmContractInfoResVo.setFileInfos(fileInfos);
- }
- vo.setPmContractInfoResVo(pmContractInfoResVo);
- }
- } else if ("6".equals(detailType)) { //建设情况
- LambdaQueryWrapper<PmProjectConstruction> lambdaQueryWrapper = new LambdaQueryWrapper<>();
- lambdaQueryWrapper.eq(PmProjectConstruction::getDemandId, demandId);
- PmProjectConstruction pmProjectConstruction = pmProjectConstructionService.getOne(lambdaQueryWrapper);
- if (pmProjectConstruction != null) {
- PmProjectConstructionResVo pmProjectConstructionResVo = new PmProjectConstructionResVo();
- BeanUtils.copyProperties(pmProjectConstruction, pmProjectConstructionResVo);
- //建设情况文件
- List<SysFileInfo> fileInfos = getSysFileInfoList(pmProjectConstruction.getId(), SysFileRefEnum.PM_PROJECT_CONSTRUCTION.getType());
- if (!ObjectUtils.isEmpty(fileInfos)) {
- pmProjectConstructionResVo.setFileInfos(fileInfos);
- }
- vo.setPmProjectConstructionResVo(pmProjectConstructionResVo);
- }
- }
- return vo;
- } else {
- return null;
- }
- }
- /**
- * 查询采购需求列表
- *
- * @param pmDemandReqVo
- * @return 采购需求
- */
- @Override
- public IPage<PmDemandResVo> selectPmDemandList(PmDemandReqVo pmDemandReqVo, int reqType) {
- LambdaQueryWrapper<PmDemand> lw = new LambdaQueryWrapper<>();
- /*******************权限代码***********************/
- SysUser sysUser = userService.selectUserById(SecurityUtils.getUserId());
- Long deptId = sysUser.getDeptId();
- //获取登录用户的角色
- List<SysRole> sysRoles = sysRoleMapper.selectRolePermissionByUserId(SecurityUtils.getUserId());
- //获取属于求单位管理员的列表
- List<SysRole> sysRoleList2 = sysRoles.stream().filter(tdto -> tdto.getRoleKey().equals(SysRoleKey.DEMAND_UNIT.getCode())).collect(Collectors.toList());
- if (!ObjectUtils.isEmpty(sysRoleList2)) { //属于需求单位管理员
- lw.apply("(purchase_dept_id = " + deptId + ")" ) ;
- } else {
- //获取属于采购管理部门管理员 或 采购办管理员的列表
- List<SysRole> sysRoleList = sysRoles.stream().filter(tdto -> (tdto.getRoleKey().equals(SysRoleKey.PURCHASING_MANAGEMENT.getCode())
- || tdto.getRoleKey().equals(SysRoleKey.PROCUREMENT_OFFICE.getCode()))).collect(Collectors.toList());
- if (!ObjectUtils.isEmpty(sysRoleList)) { //属于采购管理部门管理员 或 采购办管理员
- //获取子部门列表
- List<SysDept> sysDeptSubs = deptMapper.selectChildrenDeptById(sysUser.getDeptId());
- String sysDeptSubStr = null;
- if(!ObjectUtils.isEmpty(sysDeptSubs)){
- List<String> sysDeptSubIds = sysDeptSubs.stream().map(SysDept::getDeptId).collect(Collectors.toList())
- .stream().map(x -> x + "").collect(Collectors.toList());
- sysDeptSubStr = String.join(",", sysDeptSubIds);
- }
- String condtionSql= null;
- if(ObjectUtils.isEmpty(sysDeptSubStr)){
- condtionSql = "(purchase_dept_id = " + deptId + " AND is_excess = 0) ";
- } else {
- condtionSql = "((purchase_dept_id = " + deptId + " AND is_excess = 0) " +
- " OR (purchase_dept_id IN ("+ sysDeptSubStr +") AND is_excess = 1))";
- }
- lw.apply(condtionSql);
- }
- }
- /*******************权限代码end***********************/
- if (!StringUtils.isBlank(pmDemandReqVo.getProjectName())) {
- lw.like(PmDemand::getProjectName, "%" + pmDemandReqVo.getProjectName() + "%");
- }
- if (!StringUtils.isBlank(pmDemandReqVo.getPurchaseServices())) {
- lw.eq(PmDemand::getPurchaseServices, pmDemandReqVo.getPurchaseServices());
- }
- if (!ObjectUtils.isEmpty(pmDemandReqVo.getProjectStatus() )) {
- lw.eq(PmDemand::getProjectStatus, pmDemandReqVo.getProjectStatus());
- }
- if (!ObjectUtils.isEmpty(pmDemandReqVo.getWarnStatus() )) {
- lw.eq(PmDemand::getWarnStatus, pmDemandReqVo.getWarnStatus());
- }
- if (!ObjectUtils.isEmpty(pmDemandReqVo.getIsExcess() )) {
- lw.eq(PmDemand::getIsExcess, pmDemandReqVo.getIsExcess());
- }
- if (!StringUtils.isBlank(pmDemandReqVo.getBeginDate())) {
- lw.apply("(plan_demand_sub_time >= '" + pmDemandReqVo.getBeginDate() + "' or plan_purchase_finish_time >= '" + pmDemandReqVo.getBeginDate() + "' or plan_deliver_time >= '" + pmDemandReqVo.getBeginDate() + "' )");
- }
- if (!StringUtils.isBlank(pmDemandReqVo.getEndDate())) {
- lw.apply("(plan_demand_sub_time <= '" + pmDemandReqVo.getEndDate() + "' or plan_purchase_finish_time <= '" + pmDemandReqVo.getEndDate() + "' or plan_deliver_time <= '" + pmDemandReqVo.getEndDate() + "' )");
- }
- if (reqType == 1) { //需求审核单位列表
- lw.apply("(project_status = 6 or project_status = 8 )");
- } else if (reqType == 2) { //任务下达列表
- lw.apply("(project_status = 8 or project_status = 9 )");
- } else if (reqType == 3) { //采购执行列表
- 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)");
- } else if (reqType == 4) { //合同信息列表
- lw.apply("(project_status = 15 or project_status = 16 )");
- } else if (reqType == 5) { //项目建设列表
- lw.apply("(project_status = 16 or project_status = 17 )");
- }
- IPage<PmDemand> pageRes = this.page(new Page<>(pmDemandReqVo.getPageNum(), pmDemandReqVo.getPageSize()), lw);
- IPage<PmDemandResVo> results = new Page<>(pageRes.getCurrent(), pageRes.getSize(), pageRes.getTotal());
- if (pageRes.getRecords() != null && pageRes.getRecords().size() > 0) {
- List<PmDemandResVo> pmDemandResVos = demandChangeTo(pageRes.getRecords());
- results.setRecords(pmDemandResVos);
- }
- return results;
- }
- /**
- * 需求建档
- *
- * @param vo 采购需求
- * @return 结果
- */
- @Override
- @Transactional(rollbackFor = Exception.class)
- public boolean bookBuilding(PmBookBuildingReqVo vo) throws Exception {
- PmDemand pmDemand = this.getById(vo.getDemandId());
- LambdaQueryWrapper<PmBookBuilding> lambdaQueryWrapper = new LambdaQueryWrapper<>();
- lambdaQueryWrapper.eq(PmBookBuilding::getDemandId, vo.getDemandId());
- PmBookBuilding pmBookBuilding = pmBookBuildingService.getOne(lambdaQueryWrapper);
- if (pmBookBuilding != null) {
- vo.setId(pmBookBuilding.getId());
- BeanUtils.copyProperties(vo, pmBookBuilding);
- pmBookBuilding.setUpdateBy(vo.getUpdateBy());
- pmBookBuilding.setUpdateTime(new Date());
- } else {
- pmBookBuilding = new PmBookBuilding();
- BeanUtils.copyProperties(vo, pmBookBuilding);
- pmBookBuilding.setCreateBy(vo.getUpdateBy());
- pmBookBuilding.setCreateTime(new Date());
- pmBookBuilding.setUpdateBy(vo.getUpdateBy());
- pmBookBuilding.setUpdateTime(pmBookBuilding.getCreateTime());
- }
- if (pmBookBuildingService.saveOrUpdate(pmBookBuilding)) {
- List<SysFileRef> sysFileRefs = vo.getSysFileRefs();
- uploadFile(pmBookBuilding.getId(), SysFileRefEnum.PM_BOOK_BUILDING.getType(), sysFileRefs, vo.getUpdateBy());
- pmDemand.setProjectStatus(PmProjectStatus.DEMAND_WAIT_COMMIT.getCode());
- pmDemand.setUpdateBy(vo.getUpdateBy());
- pmDemand.setUpdateTime(DateUtils.getNowDate());
- return this.updateById(pmDemand);
- } else {
- return false;
- }
- }
- private List<SysFileInfo> getSysFileInfoList(Long redId, Integer type) {
- HashMap<String, Object> map = new HashMap<>();
- map.put("red_id", redId);
- map.put("type", type);
- List<SysFileRef> fileRefs = sysFileRefService.listByMap(map);
- if (!ObjectUtils.isEmpty(fileRefs)) {
- List<SysFileInfo> fileInfos = new ArrayList<>();
- for (SysFileRef ref : fileRefs) {
- SysFileInfo fileInfo = fileService.getById(ref.getFileId());
- fileInfos.add(fileInfo);
- }
- return fileInfos;
- } else {
- return null;
- }
- }
- /**
- * 查看流程图
- *
- * @param demandId 采购需求主键
- * @return 采购需求
- */
- @Override
- public Object viewFlowChart(Long demandId) {
- PmDemand pmDemand = this.getById(demandId);
- String projectStatus = String.valueOf(pmDemand.getProjectStatus());
- String moduleName = null;
- if (PmProjectStatus.DEMAND_WAIT_FILL.getCode().equals(projectStatus) || PmProjectStatus.DEMAND_AUDIT_RETURN.getCode().equals(projectStatus)) {
- moduleName = "需求填制";
- } else if (PmProjectStatus.DEMAND_WAIT_COMMIT.getCode().equals(projectStatus)) {
- moduleName = "需求提交";
- } else if (PmProjectStatus.DEMAND_WAIT_AUDIT.getCode().equals(projectStatus)) {
- moduleName = "需求审核";
- } else if (PmProjectStatus.TASK_WAIT_RELEASE.getCode().equals(projectStatus)) {
- moduleName = "任务下达";
- } else if (PmProjectStatus.WAIT_SELECT_AGENT.getCode().equals(projectStatus)) {
- moduleName = "选取代理";
- } else if (PmProjectStatus.WAIT_UPLOAD_BID_FILE.getCode().equals(projectStatus)) {
- moduleName = "上传招标文件";
- } else if (PmProjectStatus.WAIT_ANNOUNCEMENT.getCode().equals(projectStatus)) {
- moduleName = "发布公告";
- } else if (PmProjectStatus.WAIT_OPEN_BID.getCode().equals(projectStatus)) {
- moduleName = "填写专家信息,填写开标信息";
- } else if (PmProjectStatus.WAIT_BID_ANNOUNCEMENT.getCode().equals(projectStatus)) {
- moduleName = "填写中标信息";
- } else if (PmProjectStatus.BIDDING_PUBLICITY.getCode().equals(projectStatus)) {
- moduleName = "质疑处理,上传中标通知书";
- } else if (PmProjectStatus.CONTRACT_WAIT_FILL.getCode().equals(projectStatus)) {
- moduleName = "合同填制";
- } else if (PmProjectStatus.UNDER_CONSTRUCTION.getCode().equals(projectStatus)) {
- moduleName = "建设文档填制";
- } else if (PmProjectStatus.COMPLETION_CONSTRUCTION.getCode().equals(projectStatus)) {
- moduleName = "项目归档";
- }
- return moduleName;
- }
- @Override
- public PmFlowChartResVo getModuleInfo(Long demandId, String moduleName) {
- LambdaQueryWrapper<PmFlowChart> lambdaQueryWrapper = new LambdaQueryWrapper<>();
- lambdaQueryWrapper.eq(PmFlowChart::getModuleName, moduleName);
- PmFlowChart pmFlowChart = iPmFlowChartService.getOne(lambdaQueryWrapper);
- if (pmFlowChart == null) {
- return null;
- }
- PmFlowChartResVo vo = new PmFlowChartResVo();
- BeanUtils.copyProperties(pmFlowChart, vo);
- if ("需求填制".equals(moduleName)) {
- List<SysFileInfo> fileInfos = getSysFileInfoList(demandId, SysFileRefEnum.PM_DEMAND.getType());
- if (!ObjectUtils.isEmpty(fileInfos)) {
- vo.setFileInfos(fileInfos);
- }
- } else if ("需求提交".equals(moduleName)) {
- LambdaQueryWrapper<PmBookBuilding> pmBookBuildingLambdaQueryWrapper = new LambdaQueryWrapper<>();
- pmBookBuildingLambdaQueryWrapper.eq(PmBookBuilding::getDemandId, demandId);
- PmBookBuilding pmBookBuilding = pmBookBuildingService.getOne(pmBookBuildingLambdaQueryWrapper);
- if (pmBookBuilding != null) {
- List<SysFileInfo> fileInfos = getSysFileInfoList(pmBookBuilding.getId(), SysFileRefEnum.PM_BOOK_BUILDING.getType());
- if (!ObjectUtils.isEmpty(fileInfos)) {
- vo.setFileInfos(fileInfos);
- }
- }
- } else if ("需求审核".equals(moduleName)) {
- List<SysFileInfo> fileInfos = getSysFileInfoList(demandId, SysFileRefEnum.PM_DEMAND_EXAMINE.getType());
- if (!ObjectUtils.isEmpty(fileInfos)) {
- vo.setFileInfos(fileInfos);
- }
- } else if ("任务下达".equals(moduleName)) {
- List<SysFileInfo> fileInfos = getSysFileInfoList(demandId, SysFileRefEnum.PM_TAST_RELEASE.getType());
- if (!ObjectUtils.isEmpty(fileInfos)) {
- vo.setFileInfos(fileInfos);
- }
- } else if ("选取代理".equals(moduleName)) {
- //do nothing
- } else if ("上传招标文件".equals(moduleName)) {
- List<SysFileInfo> fileInfos = getSysFileInfoList(demandId, SysFileRefEnum.PM_BID_FILE.getType());
- if (!ObjectUtils.isEmpty(fileInfos)) {
- vo.setFileInfos(fileInfos);
- }
- } else if ("发布公告".equals(moduleName)) {
- LambdaQueryWrapper<PmReleaseAnnouncement> pmReleaseAnnouncementLambdaQueryWrapper = new LambdaQueryWrapper<>();
- pmReleaseAnnouncementLambdaQueryWrapper.eq(PmReleaseAnnouncement::getDemandId, demandId);
- List<PmReleaseAnnouncement> pmReleaseAnnouncementList = pmReleaseAnnouncementService.list(pmReleaseAnnouncementLambdaQueryWrapper);
- if (!ObjectUtils.isEmpty(pmReleaseAnnouncementList)) {
- List<SysFileInfo> listAll = new ArrayList<>();
- for (PmReleaseAnnouncement pmReleaseAnnouncement : pmReleaseAnnouncementList) {
- List<SysFileInfo> fileInfos = getSysFileInfoList(pmReleaseAnnouncement.getId(), SysFileRefEnum.PM_ANNOUNCEMENT_FILE.getType());
- if (!ObjectUtils.isEmpty(fileInfos)) {
- listAll.addAll(fileInfos);
- }
- }
- if (!ObjectUtils.isEmpty(listAll)) {
- vo.setFileInfos(listAll);
- }
- }
- } else if ("填写专家信息".equals(moduleName)) {
- //do nothing
- } else if ("填写开标信息".equals(moduleName)) {
- //do nothing
- } else if ("填写中标信息".equals(moduleName)) {
- List<SysFileInfo> listAll = new ArrayList<>();
- LambdaQueryWrapper<PmBidWinning> pmBidWinningLambdaQueryWrapper = new LambdaQueryWrapper<>();
- pmBidWinningLambdaQueryWrapper.eq(PmBidWinning::getDemandId, demandId);
- List<PmBidWinning> pmBidWinningList = pmBidWinningService.list(pmBidWinningLambdaQueryWrapper);
- if (!ObjectUtils.isEmpty(pmBidWinningList)) {
- for (PmBidWinning pmBidWinning : pmBidWinningList) {
- List<SysFileInfo> fileInfos = getSysFileInfoList(pmBidWinning.getId(), SysFileRefEnum.PM_BID_WINNING_FILE.getType());
- if (!ObjectUtils.isEmpty(fileInfos)) {
- listAll.addAll(fileInfos);
- }
- }
- }
- LambdaQueryWrapper<PmBidFailure> pmBidFailureLambdaQueryWrapper = new LambdaQueryWrapper<>();
- pmBidFailureLambdaQueryWrapper.eq(PmBidFailure::getDemandId, demandId);
- List<PmBidFailure> pmBidFailureList = pmBidFailureService.list(pmBidFailureLambdaQueryWrapper);
- if (!ObjectUtils.isEmpty(pmBidFailureService)) {
- for (PmBidFailure pmBidFailure : pmBidFailureList) {
- List<SysFileInfo> fileInfos = getSysFileInfoList(pmBidFailure.getId(), SysFileRefEnum.PM_BID_FAILURE_FILE.getType());
- if (!ObjectUtils.isEmpty(fileInfos)) {
- listAll.addAll(fileInfos);
- }
- }
- }
- if (!ObjectUtils.isEmpty(listAll)) {
- vo.setFileInfos(listAll);
- }
- } else if ("质疑处理".equals(moduleName)) {
- List<SysFileInfo> fileInfos = getSysFileInfoList(demandId, SysFileRefEnum.PM_BID_CALL_QEUSTION_FILE.getType());
- if (!ObjectUtils.isEmpty(fileInfos)) {
- vo.setFileInfos(fileInfos);
- }
- } else if ("上传中标通知书".equals(moduleName)) {
- List<SysFileInfo> fileInfos = getSysFileInfoList(demandId, SysFileRefEnum.PM_BID_WINNING_NOTIFICATION.getType());
- if (!ObjectUtils.isEmpty(fileInfos)) {
- vo.setFileInfos(fileInfos);
- }
- } else if ("合同填制".equals(moduleName)) {
- LambdaQueryWrapper<PmContractInfo> pmContractInfoLambdaQueryWrapper = new LambdaQueryWrapper<>();
- pmContractInfoLambdaQueryWrapper.eq(PmContractInfo::getDemandId, demandId);
- PmContractInfo pmContractInfo = pmContractInfoService.getOne(pmContractInfoLambdaQueryWrapper);
- if (pmContractInfo != null) {
- List<SysFileInfo> fileInfos = getSysFileInfoList(pmContractInfo.getId(), SysFileRefEnum.PM_CONTRACT_INFO.getType());
- if (!ObjectUtils.isEmpty(fileInfos)) {
- vo.setFileInfos(fileInfos);
- }
- }
- } else if ("建设文档填制".equals(moduleName)) {
- LambdaQueryWrapper<PmProjectConstruction> pmProjectConstructionLambdaQueryWrapper = new LambdaQueryWrapper<>();
- pmProjectConstructionLambdaQueryWrapper.eq(PmProjectConstruction::getDemandId, demandId);
- PmProjectConstruction pmProjectConstruction = pmProjectConstructionService.getOne(pmProjectConstructionLambdaQueryWrapper);
- if (pmProjectConstruction != null) {
- List<SysFileInfo> fileInfos = getSysFileInfoList(pmProjectConstruction.getId(), SysFileRefEnum.PM_PROJECT_CONSTRUCTION.getType());
- if (!ObjectUtils.isEmpty(fileInfos)) {
- vo.setFileInfos(fileInfos);
- }
- }
- } else if ("项目归档".equals(moduleName)) {
- //do nothing
- }
- return vo;
- }
- /**
- * 提交采购需求
- *
- * @param pmDemandReqVo
- * @return 结果
- */
- @Override
- @Transactional(rollbackFor = Exception.class)
- public boolean commit(PmDemandReqVo pmDemandReqVo) {
- PmDemand pmDemand = new PmDemand();
- pmDemand.setDemandId(pmDemandReqVo.getDemandId());
- pmDemand.setProjectStatus(PmProjectStatus.DEMAND_WAIT_AUDIT.getCode());
- pmDemand.setRealDemandCommitTime(DateUtils.getNowDate());
- pmDemand.setUpdateBy(pmDemandReqVo.getUpdateBy());
- pmDemand.setUpdateTime(DateUtils.getNowDate());
- return this.updateById(pmDemand);
- }
- /**
- * 审核采购需求通过
- *
- * @param pmDemandReqVo
- * @return 结果
- */
- @Override
- @Transactional(rollbackFor = Exception.class)
- public boolean reviewTo(PmDemandReqVo pmDemandReqVo) {
- PmDemand pmDemand = new PmDemand();
- pmDemand.setDemandId(pmDemandReqVo.getDemandId());
- pmDemand.setProjectStatus(PmProjectStatus.TASK_WAIT_RELEASE.getCode());
- List<SysFileRef> sysFileRefs = pmDemandReqVo.getSysFileRefs();
- uploadFile(pmDemandReqVo.getDemandId(), SysFileRefEnum.PM_DEMAND_EXAMINE.getType(), sysFileRefs, pmDemandReqVo.getUpdateBy());
- pmDemand.setUpdateBy(pmDemandReqVo.getUpdateBy());
- pmDemand.setUpdateTime(DateUtils.getNowDate());
- pmDemand.setAuditTime(DateUtils.getNowDate());
- return this.updateById(pmDemand);
- }
- /**
- * 审核采购需求退回
- *
- * @param pmDemandReqVo
- * @return 结果
- */
- @Override
- @Transactional(rollbackFor = Exception.class)
- public boolean reviewReturn(PmDemandReqVo pmDemandReqVo) {
- UpdateWrapper<PmDemand> updateWrapper = new UpdateWrapper<>();
- updateWrapper.lambda().eq(PmDemand::getDemandId,pmDemandReqVo.getDemandId())
- .set(PmDemand::getProjectStatus,PmProjectStatus.DEMAND_AUDIT_RETURN.getCode())
- .set(PmDemand::getAdjustReason,pmDemandReqVo.getRefuseReason())
- .set(PmDemand::getRealDemandCommitTime,null)
- .set(PmDemand::getUpdateBy,pmDemandReqVo.getUpdateBy())
- .set(PmDemand::getUpdateTime,DateUtils.getNowDate())
- .set(PmDemand::getAuditTime,DateUtils.getNowDate());
- return this.update(updateWrapper);
- }
- /**
- * 下达任务
- *
- * @param pmDemandReqVo
- * @return 结果
- */
- @Override
- @Transactional(rollbackFor = Exception.class)
- public boolean releaseTask(PmDemandReqVo pmDemandReqVo) {
- PmDemand pmDemand = new PmDemand();
- pmDemand.setDemandId(pmDemandReqVo.getDemandId());
- pmDemand.setProjectStatus(PmProjectStatus.WAIT_SELECT_AGENT.getCode());
- List<SysFileRef> sysFileRefs = pmDemandReqVo.getSysFileRefs();
- uploadFile(pmDemandReqVo.getDemandId(), SysFileRefEnum.PM_TAST_RELEASE.getType(), sysFileRefs, pmDemandReqVo.getUpdateBy());
- pmDemand.setUpdateBy(pmDemandReqVo.getUpdateBy());
- pmDemand.setUpdateTime(DateUtils.getNowDate());
- pmDemand.setAuditTime(DateUtils.getNowDate());
- return this.updateById(pmDemand);
- }
- @Override
- @Transactional(rollbackFor = Exception.class)
- public boolean uploadFile(Long redId, Integer fileType, List<SysFileRef> sysFileRefs, String upateBy) {
- if (!ObjectUtils.isEmpty(sysFileRefs)) {
- //删除老的
- QueryWrapper<SysFileRef> queryWrapper = new QueryWrapper<>();
- queryWrapper.lambda().eq(SysFileRef::getRedId, redId)
- .eq(SysFileRef::getType, fileType);
- List<SysFileRef> sysFileRefList = sysFileRefService.list(queryWrapper);
- if (!CollectionUtils.isEmpty(sysFileRefList)) {
- sysFileRefService.remove(queryWrapper);
- }
- //添加新的
- for (SysFileRef ref : sysFileRefs) {
- if (ref.getFileId() == null) {
- continue;
- }
- ref.setRedId(redId);
- ref.setType(fileType);
- ref.setCreated(upateBy);
- ref.setCreateTime(new Date());
- ref.setUpdated(upateBy);
- ref.setUpdateTime(ref.getCreateTime());
- sysFileRefService.save(ref);
- }
- return true;
- } else {
- return false;
- }
- }
- @Override
- @Transactional(rollbackFor = Exception.class)
- public boolean insertPmReleaseAnnouncement(PmReleaseAnnouncementReqVo pmReleaseAnnouncementReqVo) throws Exception {
- PmDemand pmDemand = this.getById(pmReleaseAnnouncementReqVo.getDemandId());
- if (ObjectUtils.isEmpty(pmDemand)) {
- throw new Exception("参数错误");
- }
- if (ObjectUtils.isEmpty(pmReleaseAnnouncementReqVo.getSysFileRefs())) {
- throw new Exception("上传附件不能为空");
- }
- PmReleaseAnnouncement pmReleaseAnnouncement = new PmReleaseAnnouncement();
- BeanUtils.copyProperties(pmReleaseAnnouncementReqVo, pmReleaseAnnouncement);
- if (pmReleaseAnnouncementService.saveOrUpdate(pmReleaseAnnouncement)) {
- uploadFile(pmReleaseAnnouncement.getId(), SysFileRefEnum.PM_ANNOUNCEMENT_FILE.getType(), pmReleaseAnnouncementReqVo.getSysFileRefs(), pmReleaseAnnouncementReqVo.getUpdateBy());
- PmDemand pmDemandUpdate = new PmDemand();
- pmDemandUpdate.setDemandId(pmReleaseAnnouncementReqVo.getDemandId());
- pmDemandUpdate.setProjectStatus(PmProjectStatus.WAIT_OPEN_BID.getCode());
- pmDemandUpdate.setUpdateTime(pmReleaseAnnouncementReqVo.getUpdateTime());
- pmDemandUpdate.setUpdateBy(pmReleaseAnnouncementReqVo.getUpdateBy());
- if (this.updateById(pmDemandUpdate)) {
- //发布公告生成后,会默认将该数据同步到公告管理和首页中
- BaseNotice baseNotice = new BaseNotice();
- baseNotice.setName(pmDemand.getProjectName());
- baseNotice.setTitle(pmDemand.getProjectName() + "招标公告");
- LambdaQueryWrapper<BaseNoticeType> lambdaQueryWrapper = new LambdaQueryWrapper<>();
- lambdaQueryWrapper.eq(BaseNoticeType::getName, "招标公告");
- BaseNoticeType baseNoticeType = baseNoticeTypeService.getOne(lambdaQueryWrapper);
- if (baseNoticeType == null) {
- throw new Exception("招标公告 公告类型不存在");
- }
- baseNotice.setType(baseNoticeType.getId());
- baseNotice.setReleaseTime(pmReleaseAnnouncement.getReleaseTime());
- return this.baseNoticeService.saveOrUpdate(baseNotice);
- } else {
- return false;
- }
- } else {
- return false;
- }
- }
- @Override
- @Transactional(rollbackFor = Exception.class)
- public boolean insertExpertBatch(PmBaseExpertFillReqVo pmBaseExpertFillReqVo) throws Exception {
- PmDemand pmDemand = this.getById(pmBaseExpertFillReqVo.getDemandId());
- if (ObjectUtils.isEmpty(pmDemand)) {
- throw new Exception("参数错误");
- }
- List<BaseExpert> baseExpertList = pmBaseExpertFillReqVo.getBaseExpertList();
- if (ObjectUtils.isEmpty(baseExpertList)) {
- throw new Exception("参数错误");
- }
- Date now = new Date();
- for (BaseExpert baseExpert : baseExpertList) {
- if (NameListType.BLACK.getCode().equals(baseExpert.getStatus())) {
- throw new Exception("该专家(身份证号:" + baseExpert.getIdNumber() + ")属于黑名单");
- } else {
- if (ObjectUtils.isEmpty(baseExpert.getStatus())) {
- baseExpert.setStatus(NameListType.WHITE.getCode());
- }
- }
- if (ObjectUtils.isEmpty(baseExpert.getVarietyPurchase()) || !baseExpert.getVarietyPurchase().contains(pmDemand.getProjectType())) {
- throw new Exception("该专家(身份证号:" + baseExpert.getIdNumber() + ")所属采购品种和项目类型不匹配");
- }
- if (ObjectUtils.isEmpty(baseExpert.getCreated())) {
- baseExpert.setCreated(pmBaseExpertFillReqVo.getCreateBy());
- baseExpert.setCreateTime(now);
- }
- if (ObjectUtils.isEmpty(baseExpert.getUpdated())) {
- baseExpert.setUpdated(pmBaseExpertFillReqVo.getUpdateBy());
- baseExpert.setUpdateTime(now);
- }
- if (baseExpertService.saveOrUpdate(baseExpert)) {
- LambdaQueryWrapper<PmDemandExpertRef> pmDemandExpertRefLambdaQueryWrapper = new LambdaQueryWrapper<>();
- pmDemandExpertRefLambdaQueryWrapper.eq(PmDemandExpertRef::getDemandId, pmDemand.getDemandId())
- .eq(PmDemandExpertRef::getExpertId, baseExpert.getId().longValue())
- .eq(PmDemandExpertRef::getAccessTime, pmBaseExpertFillReqVo.getAccessTime());
- PmDemandExpertRef pmDemandExpertRef = pmDemandExpertRefService.getOne(pmDemandExpertRefLambdaQueryWrapper);
- if (pmDemandExpertRef == null) {
- pmDemandExpertRef = new PmDemandExpertRef();
- pmDemandExpertRef.setCreateBy(pmBaseExpertFillReqVo.getCreateBy());
- pmDemandExpertRef.setCreateTime(now);
- }
- pmDemandExpertRef.setDemandId(pmDemand.getDemandId());
- pmDemandExpertRef.setExpertId(baseExpert.getId().longValue());
- pmDemandExpertRef.setAccessTime(DateUtils.parseDate(pmBaseExpertFillReqVo.getAccessTime()));
- pmDemandExpertRef.setUpdateBy(pmBaseExpertFillReqVo.getCreateBy());
- pmDemandExpertRef.setUpdateTime(pmDemandExpertRef.getCreateTime());
- pmDemandExpertRefService.saveOrUpdate(pmDemandExpertRef);
- }
- }
- return true;
- }
- @Override
- @Transactional(rollbackFor = Exception.class)
- public boolean extractExpertBatch(PmBaseExpertExtractReqVo pmBaseExpertExtractReqVo) throws Exception {
- Integer technicalExpertNumber = pmBaseExpertExtractReqVo.getTechnicalExpertNumber();
- if (technicalExpertNumber == null) {
- technicalExpertNumber = 0;
- }
- Integer economicExpertNumber = pmBaseExpertExtractReqVo.getEconomicExpertNumber();
- if (economicExpertNumber == null) {
- economicExpertNumber = 0;
- }
- Integer legalAffairsExpertNumber = pmBaseExpertExtractReqVo.getLegalAffairsExpertNumber();
- if (legalAffairsExpertNumber == null) {
- legalAffairsExpertNumber = 0;
- }
- Integer spareExpertNumber = pmBaseExpertExtractReqVo.getSpareExpertNumber();
- if (spareExpertNumber == null) {
- spareExpertNumber = 0;
- }
- String professional = pmBaseExpertExtractReqVo.getProfessional();
- if (spareExpertNumber > 0 && ObjectUtils.isEmpty(professional)) {
- throw new Exception("抽取备用专家必须选择专家专业");
- }
- PmDemand pmDemand = this.getById(pmBaseExpertExtractReqVo.getDemandId());
- if (ObjectUtils.isEmpty(pmDemand)) {
- throw new Exception("参数错误");
- }
- String needAvoidUnit = pmBaseExpertExtractReqVo.getNeedAvoidUnit();
- List<String> needAvoidUnitList = null;
- if (!ObjectUtils.isEmpty(needAvoidUnit)) {
- String[] arr = needAvoidUnit.split(",");
- needAvoidUnitList = Arrays.asList(arr);
- }
- String localArea = pmBaseExpertExtractReqVo.getLocalArea();
- List<String> sysRegionCodeList = new ArrayList<>();
- if (!ObjectUtils.isEmpty(localArea)) {
- if (!StringUtils.isNumeric(localArea)) {
- throw new Exception("地域必须传数字代码");
- }
- sysRegionCodeList.add(localArea);
- //找到该地域code对应的子列表
- List<SysRegionVO> sysRegionVOList = iSysRegionService.findChildDivisions(localArea);
- if (!ObjectUtils.isEmpty(sysRegionVOList)) {
- for (SysRegionVO vo : sysRegionVOList) {
- sysRegionCodeList.add(vo.getCode());
- }
- }
- }
- //从专家库中查询符合项目类型的以及是白名单的全部列表
- LambdaQueryWrapper<BaseExpert> lw = new LambdaQueryWrapper<>();
- lw.eq(BaseExpert::getVarietyPurchase, pmDemand.getProjectType())
- .eq(BaseExpert::getStatus, NameListType.WHITE.getCode())
- .notIn(!ObjectUtils.isEmpty(needAvoidUnitList), BaseExpert::getUnitInformation, needAvoidUnitList)
- .in(!ObjectUtils.isEmpty(sysRegionCodeList), BaseExpert::getLocalArea, sysRegionCodeList);
- List<BaseExpert> baseExpertList = baseExpertService.list(lw);
- if (ObjectUtils.isEmpty(baseExpertList)) {
- throw new Exception("没抽取到符合条件的专家");
- }
- //从列表中挑出来各个类型的子列表
- List<BaseExpert> technicalExpertList = new ArrayList<>();
- List<BaseExpert> economicExpertList = new ArrayList<>();
- List<BaseExpert> legalAffairsExpertList = new ArrayList<>();
- List<BaseExpert> spareExpertList = new ArrayList<>();
- for (BaseExpert baseExpert : baseExpertList) {
- if (technicalExpertNumber > 0) {
- if (baseExpert.getExpertType().contains(ExpertType.TECHNICAL_EXPERT.getCode())) {
- technicalExpertList.add(baseExpert);
- }
- }
- if (economicExpertNumber > 0) {
- if (baseExpert.getExpertType().contains(ExpertType.ECONOMIC_EXPERT.getCode())) {
- economicExpertList.add(baseExpert);
- }
- }
- if (legalAffairsExpertNumber > 0) {
- if (baseExpert.getExpertType().contains(ExpertType.LEGALAFFAIRS_EXPERT.getCode())) {
- legalAffairsExpertList.add(baseExpert);
- }
- }
- if (spareExpertNumber > 0) {
- String[] arr = professional.split(",");
- List<String> professionalList = Arrays.asList(arr);
- String majorType = baseExpert.getMajorType();
- if (!ObjectUtils.isEmpty(majorType)) {
- String[] arr2 = majorType.split(",");
- List<String> majorTypeList = Arrays.asList(arr2);
- if (hasIntersection(professionalList, majorTypeList)) {
- spareExpertList.add(baseExpert);
- }
- }
- }
- }
- //从子列表中随机抽取符合数据量的
- List<BaseExpert> alltExpertList = new ArrayList<>();
- if (!ObjectUtils.isEmpty(technicalExpertList)) {
- alltExpertList.addAll(RandomUtil.getRandomList(technicalExpertList, technicalExpertNumber));
- }
- if (!ObjectUtils.isEmpty(economicExpertList)) {
- alltExpertList.addAll(RandomUtil.getRandomList(economicExpertList, economicExpertNumber));
- }
- if (!ObjectUtils.isEmpty(legalAffairsExpertList)) {
- alltExpertList.addAll(RandomUtil.getRandomList(legalAffairsExpertList, legalAffairsExpertNumber));
- }
- if (!ObjectUtils.isEmpty(spareExpertList)) {
- alltExpertList.addAll(RandomUtil.getRandomList(spareExpertList, spareExpertNumber));
- }
- if (ObjectUtils.isEmpty(alltExpertList)) {
- throw new Exception("没抽取到符合条件的专家");
- } else {
- List<PmDemandExpertRef> pmDemandExpertRefList = new ArrayList<>();
- for (BaseExpert baseExpert : alltExpertList) {
- LambdaQueryWrapper<PmDemandExpertRef> baseExpertLambdaQueryWrapper = new LambdaQueryWrapper<>();
- baseExpertLambdaQueryWrapper.eq(PmDemandExpertRef::getExpertId, baseExpert.getId().longValue())
- .eq(PmDemandExpertRef::getDemandId, pmDemand.getDemandId())
- .eq(PmDemandExpertRef::getAccessTime, pmBaseExpertExtractReqVo.getAccessTime());
- PmDemandExpertRef pmDemandExpertRef = pmDemandExpertRefService.getOne(baseExpertLambdaQueryWrapper);
- if (pmDemandExpertRef == null) {
- pmDemandExpertRef = new PmDemandExpertRef();
- pmDemandExpertRef.setCreateBy(pmBaseExpertExtractReqVo.getCreateBy());
- pmDemandExpertRef.setCreateTime(new Date());
- }
- pmDemandExpertRef.setDemandId(pmDemand.getDemandId());
- pmDemandExpertRef.setExpertId(baseExpert.getId().longValue());
- pmDemandExpertRef.setAccessTime(DateUtils.parseDate(pmBaseExpertExtractReqVo.getAccessTime()));
- pmDemandExpertRef.setUpdateBy(pmBaseExpertExtractReqVo.getCreateBy());
- pmDemandExpertRef.setUpdateTime(pmDemandExpertRef.getCreateTime());
- pmDemandExpertRefList.add(pmDemandExpertRef);
- }
- return pmDemandExpertRefService.saveOrUpdateBatch(pmDemandExpertRefList);
- }
- }
- //二个列表是否有交集
- private boolean hasIntersection(List<String> professionalList, List<String> majorTypeList) {
- for (String professiona : professionalList) {
- for (String majorType : majorTypeList) {
- if (professiona.equals(majorType)) {
- return true;
- }
- }
- }
- return false;
- }
- @Override
- @Transactional(rollbackFor = Exception.class)
- public boolean insertBidOpeningBatch(PmBidOpeningFillReqVo pmBidOpeningFillReqVo) throws Exception {
- PmDemand pmDemand = this.getById(pmBidOpeningFillReqVo.getDemandId());
- if (ObjectUtils.isEmpty(pmDemand)) {
- throw new Exception("参数错误");
- }
- //从发布公告里获取开标时间
- LambdaQueryWrapper<PmReleaseAnnouncement> lw = new LambdaQueryWrapper<>();
- lw.eq(PmReleaseAnnouncement::getDemandId, pmDemand.getDemandId()).orderByDesc(PmReleaseAnnouncement::getReleaseTime)
- .last(" limit 1 ");
- PmReleaseAnnouncement pmReleaseAnnouncement = this.pmReleaseAnnouncementService.getOne(lw);
- if (pmReleaseAnnouncement == null) {
- throw new Exception("发布公告不存在");
- }
- Date tenderOpenTime = pmReleaseAnnouncement.getTenderOpenTime();
- Date now = new Date();
- List<PmBidOpening> pmBidOpeningList = pmBidOpeningFillReqVo.getPmBidOpeningList();
- for (PmBidOpening pmBidOpening : pmBidOpeningList) {
- if (ObjectUtils.isEmpty(pmBidOpening.getBidderName())) {
- throw new Exception("投标人名称不能为空");
- }
- if (ObjectUtils.isEmpty(pmBidOpening.getScore())) {
- throw new Exception("分数不能为空");
- }
- pmBidOpening.setOpenBidTime(tenderOpenTime);
- pmBidOpening.setDemandId(pmBidOpeningFillReqVo.getDemandId());
- pmBidOpening.setCreateBy(pmBidOpeningFillReqVo.getCreateBy());
- pmBidOpening.setCreateTime(now);
- pmBidOpening.setUpdateBy(pmBidOpeningFillReqVo.getUpdateBy());
- pmBidOpening.setUpdateTime(now);
- }
- if (pmBidOpeningService.saveOrUpdateBatch(pmBidOpeningList)) {
- PmDemand pmDemandUpdate = new PmDemand();
- pmDemandUpdate.setDemandId(pmDemand.getDemandId());
- pmDemandUpdate.setProjectStatus(PmProjectStatus.WAIT_BID_ANNOUNCEMENT.getCode());
- pmDemandUpdate.setUpdateTime(now);
- pmDemandUpdate.setUpdateBy(pmBidOpeningFillReqVo.getUpdateBy());
- return this.updateById(pmDemandUpdate);
- } else {
- return false;
- }
- }
- /**
- * 填写中标
- * @param pmBidWinningReqVo
- * @return
- * @throws Exception
- */
- @Override
- @Transactional(rollbackFor = Exception.class)
- public boolean insertPmBidWinning(PmBidWinningReqVo pmBidWinningReqVo) throws Exception {
- List<Long> pmBidOpeningIdList = pmBidWinningReqVo.getPmBidOpeningIdList();
- if (ObjectUtils.isEmpty(pmBidWinningReqVo.getBidWinningAmount())) {
- throw new Exception("中标金额不能为空");
- }
- if (ObjectUtils.isEmpty(pmBidOpeningIdList)) {
- throw new Exception("中标单位信息列表不能为空");
- }
- if (ObjectUtils.isEmpty(pmBidWinningReqVo.getSysFileRefs())) {
- throw new Exception("上传附件不能为空");
- }
- PmBidWinning pmBidWinning = new PmBidWinning();
- BeanUtils.copyProperties(pmBidWinningReqVo, pmBidWinning);
- //修改老的中标信息状态
- if(ObjectUtils.isEmpty(pmBidWinningReqVo.getId())){ //属于新增
- LambdaQueryWrapper<PmBidWinning> pmBidWinningLambdaQueryWrapper = new LambdaQueryWrapper<>();
- pmBidWinningLambdaQueryWrapper.eq(PmBidWinning::getDemandId,pmBidWinningReqVo.getDemandId())
- .eq(PmBidWinning::getStatus,BidWinningStatus.NORMAL.getCode());
- List<PmBidWinning> pmBidWinninglist = pmBidWinningService.list(pmBidWinningLambdaQueryWrapper);
- if(!ObjectUtils.isEmpty(pmBidWinninglist)){
- for(PmBidWinning item : pmBidWinninglist) {
- UpdateWrapper<PmBidWinning> updateWrapper1 = new UpdateWrapper<>();
- updateWrapper1.lambda().set(PmBidWinning::getStatus,BidWinningStatus.BE_REPLACED.getCode())
- .eq(PmBidWinning::getId,item.getId());
- pmBidWinningService.update(updateWrapper1);
- UpdateWrapper<PmBidWinningOpeningRef> updateWrapper2 = new UpdateWrapper<>();
- updateWrapper2.lambda().set(PmBidWinningOpeningRef::getStatus,BidWinningStatus.BE_REPLACED.getCode())
- .eq(PmBidWinningOpeningRef::getWinningId,item.getId())
- .eq(PmBidWinningOpeningRef::getStatus,BidWinningStatus.NORMAL.getCode());
- pmBidWinningOpeningRefService.update(updateWrapper2);
- }
- }
- }
- if (pmBidWinningService.saveOrUpdate(pmBidWinning)) {
- List<PmBidWinningOpeningRef> pmBidWinningOpeningRefList = new ArrayList<>();
- for (Long pmBidOpeningId : pmBidOpeningIdList) {
- LambdaQueryWrapper<PmBidWinningOpeningRef> pmBidWinningOpeningRefLambdaQueryWrapper = new LambdaQueryWrapper<>();
- pmBidWinningOpeningRefLambdaQueryWrapper.eq(PmBidWinningOpeningRef::getOpeningId, pmBidOpeningId)
- .eq(PmBidWinningOpeningRef::getWinningId, pmBidWinning.getId());
- PmBidWinningOpeningRef pmBidWinningOpeningRef = pmBidWinningOpeningRefService.getOne(pmBidWinningOpeningRefLambdaQueryWrapper);
- if (pmBidWinningOpeningRef == null) {
- pmBidWinningOpeningRef = new PmBidWinningOpeningRef();
- pmBidWinningOpeningRef.setCreateBy(pmBidWinningReqVo.getCreateBy());
- pmBidWinningOpeningRef.setCreateTime(pmBidWinningReqVo.getCreateTime());
- }
- pmBidWinningOpeningRef.setOpeningId(pmBidOpeningId);
- pmBidWinningOpeningRef.setWinningId(pmBidWinning.getId());
- pmBidWinningOpeningRef.setUpdateBy(pmBidWinningReqVo.getUpdateBy());
- pmBidWinningOpeningRef.setUpdateTime(pmBidWinningReqVo.getUpdateTime());
- pmBidWinningOpeningRefList.add(pmBidWinningOpeningRef);
- }
- if (pmBidWinningOpeningRefService.saveOrUpdateBatch(pmBidWinningOpeningRefList)) {
- uploadFile(pmBidWinning.getId(), SysFileRefEnum.PM_BID_WINNING_FILE.getType(), pmBidWinningReqVo.getSysFileRefs(), pmBidWinningReqVo.getUpdateBy());
- //发布公告生成后,会默认将该数据同步到公告管理和首页中
- PmDemand pmDemand = this.getById(pmBidWinningReqVo.getDemandId());
- BaseNotice baseNotice = new BaseNotice();
- baseNotice.setName(pmDemand.getProjectName());
- baseNotice.setTitle(pmDemand.getProjectName() + "中标公告");
- LambdaQueryWrapper<BaseNoticeType> lambdaQueryWrapper = new LambdaQueryWrapper<>();
- lambdaQueryWrapper.eq(BaseNoticeType::getName, "中标公告");
- BaseNoticeType baseNoticeType = baseNoticeTypeService.getOne(lambdaQueryWrapper);
- if (baseNoticeType == null) {
- throw new Exception("中标公告 公告类型不存在");
- }
- baseNotice.setType(baseNoticeType.getId());
- baseNotice.setReleaseTime(pmBidWinningReqVo.getBidAnnouncementTime());
- this.baseNoticeService.saveOrUpdate(baseNotice);
- PmDemand pmDemandUpdate = new PmDemand();
- pmDemandUpdate.setDemandId(pmBidWinningReqVo.getDemandId());
- pmDemandUpdate.setProjectStatus(PmProjectStatus.BIDDING_PUBLICITY.getCode());
- pmDemandUpdate.setUpdateTime(pmBidWinningReqVo.getUpdateTime());
- pmDemandUpdate.setUpdateBy(pmBidWinningReqVo.getUpdateBy());
- return this.updateById(pmDemandUpdate);
- } else {
- return false;
- }
- } else {
- return false;
- }
- }
- @Override
- @Transactional(rollbackFor = Exception.class)
- public boolean updatePmBidWinning(PmBidWinningReqVo pmBidWinningReqVo) throws Exception {
- List<Long> pmBidOpeningIdList = pmBidWinningReqVo.getPmBidOpeningIdList();
- if (ObjectUtils.isEmpty(pmBidOpeningIdList)) {
- throw new Exception("中标单位信息列表不能为空");
- }
- if (ObjectUtils.isEmpty(pmBidWinningReqVo.getBidWinningAmount())) {
- throw new Exception("中标金额不能为空");
- }
- if (ObjectUtils.isEmpty(pmBidWinningReqVo.getSysFileRefs())) {
- throw new Exception("上传附件不能为空");
- }
- LambdaQueryWrapper<PmBidWinning> lw = new LambdaQueryWrapper<>();
- lw.eq(PmBidWinning::getDemandId, pmBidWinningReqVo.getDemandId()).eq(PmBidWinning::getStatus,BidWinningStatus.NORMAL.getCode());
- List<PmBidWinning> pmBidWinninglist = pmBidWinningService.list(lw);
- if (ObjectUtils.isEmpty(pmBidWinninglist)) {
- throw new Exception("原中标信息不存在");
- }
- //修改老的状态
- for(PmBidWinning item : pmBidWinninglist) {
- UpdateWrapper<PmBidWinning> updateWrapper1 = new UpdateWrapper<>();
- updateWrapper1.lambda().set(PmBidWinning::getStatus,BidWinningStatus.BE_REPLACED.getCode())
- .eq(PmBidWinning::getId,item.getId());
- pmBidWinningService.update(updateWrapper1);
- UpdateWrapper<PmBidWinningOpeningRef> updateWrapper2 = new UpdateWrapper<>();
- updateWrapper2.lambda().set(PmBidWinningOpeningRef::getStatus,BidWinningStatus.BE_REPLACED.getCode())
- .eq(PmBidWinningOpeningRef::getWinningId,item.getId())
- .eq(PmBidWinningOpeningRef::getStatus,BidWinningStatus.NORMAL.getCode());
- pmBidWinningOpeningRefService.update(updateWrapper2);
- }
- //新增
- PmBidWinning pmBidWinning = new PmBidWinning();
- BeanUtils.copyProperties(pmBidWinninglist.get(0),pmBidWinning);
- pmBidWinning.setId(null);
- pmBidWinning.setBidWinningAmount(pmBidWinningReqVo.getBidWinningAmount());
- pmBidWinning.setStatus(BidWinningStatus.NORMAL.getCode());
- pmBidWinning.setUpdateBy(pmBidWinningReqVo.getUpdateBy());
- pmBidWinning.setUpdateTime(pmBidWinningReqVo.getUpdateTime());
- if (pmBidWinningService.save(pmBidWinning)) {
- List<PmBidWinningOpeningRef> pmBidWinningOpeningRefList = new ArrayList<>();
- for (Long pmBidOpeningId : pmBidOpeningIdList) {
- PmBidWinningOpeningRef pmBidWinningOpeningRef = new PmBidWinningOpeningRef();
- pmBidWinningOpeningRef.setOpeningId(pmBidOpeningId);
- pmBidWinningOpeningRef.setWinningId(pmBidWinning.getId());
- pmBidWinningOpeningRef.setStatus(BidWinningStatus.NORMAL.getCode());
- pmBidWinningOpeningRef.setCreateBy(pmBidWinningReqVo.getCreateBy());
- pmBidWinningOpeningRef.setCreateTime(pmBidWinningReqVo.getCreateTime());
- pmBidWinningOpeningRef.setUpdateBy(pmBidWinningReqVo.getUpdateBy());
- pmBidWinningOpeningRef.setUpdateTime(pmBidWinningReqVo.getUpdateTime());
- pmBidWinningOpeningRefList.add(pmBidWinningOpeningRef);
- }
- LambdaQueryWrapper<SysFileRef> sysFileRefLambdaQueryWrapper = new LambdaQueryWrapper<>();
- sysFileRefLambdaQueryWrapper.eq(SysFileRef::getType,SysFileRefEnum.PM_BID_WINNING_FILE.getType())
- .eq(SysFileRef::getRedId,pmBidWinninglist.get(0));
- List<SysFileRef> sysFileRefs = sysFileRefService.list(sysFileRefLambdaQueryWrapper);
- uploadFile(pmBidWinning.getId(), SysFileRefEnum.PM_BID_WINNING_FILE.getType(), sysFileRefs, pmBidWinningReqVo.getUpdateBy());
- return pmBidWinningOpeningRefService.saveBatch(pmBidWinningOpeningRefList);
- } else {
- return false;
- }
- }
- /**
- * 流标
- * @param pmBidFailureReqVo
- * @return
- * @throws Exception
- */
- @Override
- @Transactional(rollbackFor = Exception.class)
- public boolean insertPmBidFailure(PmBidFailureReqVo pmBidFailureReqVo) throws Exception {
- PmBidFailure pmBidFailure = new PmBidFailure();
- BeanUtils.copyProperties(pmBidFailureReqVo, pmBidFailure);
- if (pmBidFailureService.saveOrUpdate(pmBidFailure)) {
- //把中标信息修改状态
- LambdaQueryWrapper<PmBidWinning> lw = new LambdaQueryWrapper<>();
- lw.eq(PmBidWinning::getDemandId, pmBidFailureReqVo.getDemandId()).eq(PmBidWinning::getStatus,BidWinningStatus.NORMAL.getCode());
- List<PmBidWinning> pmBidWinninglist = pmBidWinningService.list(lw);
- if (!ObjectUtils.isEmpty(pmBidWinninglist)) {
- for(PmBidWinning item : pmBidWinninglist) {
- UpdateWrapper<PmBidWinning> updateWrapper1 = new UpdateWrapper<>();
- updateWrapper1.lambda().set(PmBidWinning::getStatus,BidWinningStatus.BE_BID_FAILURE.getCode())
- .eq(PmBidWinning::getId,item.getId());
- pmBidWinningService.update(updateWrapper1);
- UpdateWrapper<PmBidWinningOpeningRef> updateWrapper2 = new UpdateWrapper<>();
- updateWrapper2.lambda().set(PmBidWinningOpeningRef::getStatus,BidWinningStatus.BE_BID_FAILURE.getCode())
- .eq(PmBidWinningOpeningRef::getWinningId,item.getId())
- .eq(PmBidWinningOpeningRef::getStatus,BidWinningStatus.NORMAL.getCode());
- pmBidWinningOpeningRefService.update(updateWrapper2);
- }
- }
- uploadFile(pmBidFailure.getId(), SysFileRefEnum.PM_BID_FAILURE_FILE.getType(), pmBidFailureReqVo.getSysFileRefs(), pmBidFailureReqVo.getUpdateBy());
- //发布公告生成后,会默认将该数据同步到公告管理和首页中
- PmDemand pmDemand = this.getById(pmBidFailureReqVo.getDemandId());
- BaseNotice baseNotice = new BaseNotice();
- baseNotice.setName(pmDemand.getProjectName());
- baseNotice.setTitle(pmDemand.getProjectName() + "流标公告");
- LambdaQueryWrapper<BaseNoticeType> lambdaQueryWrapper = new LambdaQueryWrapper<>();
- lambdaQueryWrapper.eq(BaseNoticeType::getName, "流标公告");
- BaseNoticeType baseNoticeType = baseNoticeTypeService.getOne(lambdaQueryWrapper);
- if (baseNoticeType == null) {
- throw new Exception("流标公告 公告类型不存在");
- }
- baseNotice.setType(baseNoticeType.getId());
- baseNotice.setReleaseTime(pmBidFailureReqVo.getBidFailureTime());
- this.baseNoticeService.saveOrUpdate(baseNotice);
- PmDemand pmDemandUpdate = new PmDemand();
- pmDemandUpdate.setDemandId(pmBidFailureReqVo.getDemandId());
- pmDemandUpdate.setProjectStatus(PmProjectStatus.WAIT_ANNOUNCEMENT.getCode());
- pmDemandUpdate.setUpdateTime(pmBidFailureReqVo.getUpdateTime());
- pmDemandUpdate.setUpdateBy(pmBidFailureReqVo.getUpdateBy());
- return this.updateById(pmDemandUpdate);
- } else {
- return false;
- }
- }
- @Override
- @Transactional(rollbackFor = Exception.class)
- public boolean insertContractInfo(PmContractInfoReqVo pmContractInfoReqVo) throws Exception {
- Long demandId = pmContractInfoReqVo.getDemandId();
- if (ObjectUtils.isEmpty(demandId)) {
- throw new Exception("采购需求ID不能为空");
- }
- PmDemand pmDemand = this.getById(demandId);
- if (ObjectUtils.isEmpty(pmDemand)) {
- throw new Exception("采购需求ID错误");
- }
- List<SysFileRef> sysFileRefs = pmContractInfoReqVo.getSysFileRefs();
- if (ObjectUtils.isEmpty(sysFileRefs)) {
- throw new Exception("上传附件不能为空");
- }
- LambdaQueryWrapper<PmContractInfo> lambdaQueryWrapper = new LambdaQueryWrapper<>();
- lambdaQueryWrapper.eq(PmContractInfo::getDemandId, demandId);
- PmContractInfo pmContractInfo = pmContractInfoService.getOne(lambdaQueryWrapper);
- if (pmContractInfo != null) {
- pmContractInfoReqVo.setId(pmContractInfo.getId());
- BeanUtils.copyProperties(pmContractInfoReqVo, pmContractInfo);
- pmContractInfo.setUpdateTime(pmContractInfoReqVo.getUpdateTime());
- pmContractInfo.setUpdateBy(pmContractInfoReqVo.getUpdateBy());
- } else {
- pmContractInfo = new PmContractInfo();
- BeanUtils.copyProperties(pmContractInfoReqVo, pmContractInfo);
- pmContractInfo.setCreateBy(pmContractInfoReqVo.getCreateBy());
- pmContractInfo.setCreateTime(pmContractInfoReqVo.getCreateTime());
- pmContractInfo.setUpdateTime(pmContractInfoReqVo.getUpdateTime());
- pmContractInfo.setUpdateBy(pmContractInfoReqVo.getUpdateBy());
- }
- if (pmContractInfoService.saveOrUpdate(pmContractInfo)) {
- this.uploadFile(pmContractInfo.getId(), SysFileRefEnum.PM_CONTRACT_INFO.getType(), sysFileRefs, pmContractInfoReqVo.getUpdateBy());
- PmDemand pmDemandUpdate = new PmDemand();
- pmDemandUpdate.setDemandId(demandId);
- pmDemandUpdate.setProjectStatus(PmProjectStatus.UNDER_CONSTRUCTION.getCode());
- pmDemandUpdate.setUpdateTime(pmContractInfoReqVo.getUpdateTime());
- pmDemandUpdate.setUpdateBy(pmContractInfoReqVo.getUpdateBy());
- return this.updateById(pmDemandUpdate);
- } else {
- return false;
- }
- }
- @Override
- @Transactional(rollbackFor = Exception.class)
- public boolean insertProjectConstruction(PmProjectConstructionReqVo pmProjectConstructionReqVo) throws Exception {
- Long demandId = pmProjectConstructionReqVo.getDemandId();
- if (ObjectUtils.isEmpty(demandId)) {
- throw new Exception("采购需求ID不能为空");
- }
- PmDemand pmDemand = this.getById(demandId);
- if (ObjectUtils.isEmpty(pmDemand)) {
- throw new Exception("采购需求ID错误");
- }
- List<SysFileRef> sysFileRefs = pmProjectConstructionReqVo.getSysFileRefs();
- if (ObjectUtils.isEmpty(sysFileRefs)) {
- throw new Exception("上传附件不能为空");
- }
- LambdaQueryWrapper<PmProjectConstruction> lambdaQueryWrapper = new LambdaQueryWrapper<>();
- lambdaQueryWrapper.eq(PmProjectConstruction::getDemandId, demandId);
- PmProjectConstruction pmProjectConstruction = pmProjectConstructionService.getOne(lambdaQueryWrapper);
- if (pmProjectConstruction != null) {
- pmProjectConstructionReqVo.setId(pmProjectConstruction.getId());
- BeanUtils.copyProperties(pmProjectConstructionReqVo, pmProjectConstruction);
- pmProjectConstruction.setUpdateBy(pmProjectConstructionReqVo.getUpdateBy());
- pmProjectConstruction.setUpdateTime(pmProjectConstructionReqVo.getUpdateTime());
- } else {
- pmProjectConstruction = new PmProjectConstruction();
- BeanUtils.copyProperties(pmProjectConstructionReqVo, pmProjectConstruction);
- pmProjectConstruction.setCreateBy(pmProjectConstructionReqVo.getCreateBy());
- pmProjectConstruction.setCreateTime(pmProjectConstructionReqVo.getCreateTime());
- pmProjectConstruction.setUpdateBy(pmProjectConstructionReqVo.getUpdateBy());
- pmProjectConstruction.setUpdateTime(pmProjectConstructionReqVo.getUpdateTime());
- }
- if (pmProjectConstructionService.saveOrUpdate(pmProjectConstruction)) {
- this.uploadFile(pmProjectConstruction.getId(), SysFileRefEnum.PM_PROJECT_CONSTRUCTION.getType(), sysFileRefs, pmProjectConstructionReqVo.getUpdateBy());
- PmDemand pmDemandUpdate = new PmDemand();
- pmDemandUpdate.setDemandId(demandId);
- pmDemandUpdate.setProjectStatus(PmProjectStatus.COMPLETION_CONSTRUCTION.getCode());
- pmDemandUpdate.setRealDeliverTime(pmProjectConstructionReqVo.getUpdateTime());
- pmDemandUpdate.setUpdateTime(pmProjectConstructionReqVo.getUpdateTime());
- pmDemandUpdate.setUpdateBy(pmProjectConstructionReqVo.getUpdateBy());
- return this.updateById(pmDemandUpdate);
- } else {
- return false;
- }
- }
- /**
- * 通过需求ID列表 查询采购执行列表 sunhh
- *
- * @param demandIdList
- * @return
- */
- @Override
- public List<PmDemand> selectByDemandIdList(List<Integer> demandIdList) {
- return this.baseMapper.selectByDemandIdList(demandIdList);
- }
- /**
- * 专家库--查询抽取专家列表 非必传条件:专家名称,开始结束时间 sunhh
- *
- * @param baseExpertVo
- * @return
- */
- @Override
- public List<PmDemand> selectExtractionExpert(BaseExpertVo baseExpertVo) {
- return this.baseMapper.selectExtractionExpert(baseExpertVo);
- }
- @Override
- public List<PmDemandResVo> demandWaitCommit() {
- return getListByStatus(PmProjectStatus.DEMAND_WAIT_COMMIT.getCode());
- }
- @Override
- public List<PmDemandResVo> contractWaitFilled() {
- return getListByStatus(PmProjectStatus.CONTRACT_WAIT_FILL.getCode());
- }
- @Override
- public List<PmDemandResVo> projectWaitFinish() {
- return getListByStatus(PmProjectStatus.UNDER_CONSTRUCTION.getCode());
- }
- @Override
- public List<PmDemandResVo> demandWaitExamine() {
- return getListByStatus(PmProjectStatus.DEMAND_WAIT_AUDIT.getCode());
- }
- @Override
- public List<PmDemandResVo> taskWaitRelease() {
- return getListByStatus(PmProjectStatus.TASK_WAIT_RELEASE.getCode());
- }
- @Override
- public List<PmDemandResVo> waitSelectAgent() {
- return getListByStatus(PmProjectStatus.WAIT_SELECT_AGENT.getCode());
- }
- @Override
- public List<PmDemandResVo> waitUpBidFile() {
- return getListByStatus(PmProjectStatus.WAIT_UPLOAD_BID_FILE.getCode());
- }
- @Override
- public List<PmDemandResVo> waitAnnouncement() {
- return getListByStatus(PmProjectStatus.WAIT_ANNOUNCEMENT.getCode());
- }
- @Override
- public List<PmDemandResVo> waitOpenBid() {
- return getListByStatus(PmProjectStatus.WAIT_OPEN_BID.getCode());
- }
- @Override
- public List<PmDemandResVo> waitBidAnnouncement() {
- return getListByStatus(PmProjectStatus.WAIT_BID_ANNOUNCEMENT.getCode());
- }
- @Override
- public List<PmDemandResVo> biddingPublicity() {
- return getListByStatus(PmProjectStatus.BIDDING_PUBLICITY.getCode());
- }
- @Override
- public AjaxResult procurementOfficeWillManipulateTotal() {
- List<HomeToDoQueryResVo> homeRes = new ArrayList<>();
- // 待选取代理, 待上传招标文件, 待发布公告, 待开标, 待发布中标公告, 中标公示中
- List<PmDemandResVo> demandRes = new ArrayList<>();
- demandRes.addAll(getListByStatus(PmProjectStatus.WAIT_SELECT_AGENT.getCode()));
- demandRes.addAll(getListByStatus(PmProjectStatus.WAIT_UPLOAD_BID_FILE.getCode()));
- demandRes.addAll(getListByStatus(PmProjectStatus.WAIT_ANNOUNCEMENT.getCode()));
- demandRes.addAll(getListByStatus(PmProjectStatus.WAIT_OPEN_BID.getCode()));
- demandRes.addAll(getListByStatus(PmProjectStatus.WAIT_BID_ANNOUNCEMENT.getCode()));
- demandRes.addAll(getListByStatus(PmProjectStatus.BIDDING_PUBLICITY.getCode()));
- //计划数据--发函催告
- List<PlanQuarterResponseVo> planRes = planYearsService.willSendLetter();
- //转为首页table展示数据
- if (!ObjectUtils.isEmpty(demandRes) && demandRes.size() > 0) {
- for (PmDemandResVo demandResVoVo : demandRes) {
- HomeToDoQueryResVo home = new HomeToDoQueryResVo();
- BeanUtils.copyProperties(demandResVoVo, home);
- homeRes.add(home);
- }
- }
- if (!ObjectUtils.isEmpty(planRes) && planRes.size() > 0) {
- for (PlanQuarterResponseVo planVo : planRes) {
- HomeToDoQueryResVo home = new HomeToDoQueryResVo();
- BeanUtils.copyProperties(planVo, home);
- homeRes.add(home);
- }
- }
- return AjaxResult.success(homeRes);
- }
- /**
- * 统计分析-采购项目信息统计
- *
- * @param pmDemandReqVo
- * @return
- */
- @Override
- public Map<String, Integer> purchaseProjectStatistical(PmDemandReqVo pmDemandReqVo) {
- Map<String, Integer> mapReturn = new HashMap<>();
- // 查询项目总数量
- Map<String, Integer> mapCount = pmDemandMapper.purchaseProjectStatistical(pmDemandReqVo);
- // 查询已完成项目数量,预算金额数量
- Map<String, Integer> mapYWC = pmDemandMapper.purchaseProjectStatisticalYWC(pmDemandReqVo);
- // 查询新创建项目数量,预算金额数量
- Map<String, Integer> mapXCJ = pmDemandMapper.purchaseProjectStatisticalXCJ(pmDemandReqVo);
- // 查询去年完成项目数量,预算金额数量
- Map<String, Integer> mapQNWC = pmDemandMapper.purchaseProjectStatisticalQNWC(pmDemandReqVo);
- mapReturn.putAll(mapCount);
- mapReturn.putAll(mapYWC);
- mapReturn.putAll(mapXCJ);
- mapReturn.putAll(mapQNWC);
- return mapReturn;
- }
- @Override
- public List<StatisticalChartsResVo> countByProjectAttr() {
- List<StatisticalChartsResVo> resVos = pmDemandMapper.countByProjectAttr();
- for (StatisticalChartsResVo chartsResVo : resVos) {
- for (PmProjectStatus value : PmProjectStatus.values()) {
- if (value.getCode().equals(chartsResVo.getColumnName())) {
- chartsResVo.setColumnName(value.getInfo());
- break;
- }
- }
- }
- return resVos;
- }
- @Override
- public List<StatisticalChartsResVo> countByEvaluation(PmDemandReqVo pmDemandReqVo) {
- List<StatisticalChartsResVo> resVos = new ArrayList<>();
- //概算金额包括:100万以下采购任务、100至500万元采购任务、500至1000万元采购任务、1000至5000万元采购任务、5000至1亿元采购任务、1亿元及以上采购任务
- StatisticalChartsResVo resVo = pmDemandMapper.countByEvaluationLt(100);
- resVo.setColumnName("100万以下采购任务");
- resVos.add(resVo);
- StatisticalChartsResVo resVo1 = pmDemandMapper.countByEvaluationBet(100, 500);
- resVo1.setColumnName("100至500万元采购任务");
- resVos.add(resVo1);
- StatisticalChartsResVo resVo2 = pmDemandMapper.countByEvaluationBet(500, 1000);
- resVo2.setColumnName("500至1000万元采购任务");
- resVos.add(resVo2);
- StatisticalChartsResVo resVo3 = pmDemandMapper.countByEvaluationBet(1000, 5000);
- resVo3.setColumnName("1000至5000万元采购任务");
- resVos.add(resVo3);
- StatisticalChartsResVo resVo4 = pmDemandMapper.countByEvaluationBet(5000, 10000);
- resVo4.setColumnName("5000至1亿元采购任务");
- resVos.add(resVo4);
- StatisticalChartsResVo resVo5 = pmDemandMapper.countByEvaluationGt(10000);
- resVo5.setColumnName("1亿元及以上采购任务");
- resVos.add(resVo5);
- return resVos;
- }
- @Override
- public AjaxResult countProjectExceed(PmDemandReqVo pmDemandReqVo) {
- HashMap<String, String> resMap = new HashMap<>();
- //执行滞后采购项目:本年度所有的逾期项目数
- //预算金额:本年度所有逾期项目累加的预算金额
- StatisticalChartsResVo resVo = pmDemandMapper.countProjectExceed();
- resMap.put("执行滞后采购项目", resVo.getNum());
- resMap.put("预算金额", resVo.getEvaluationTotal());
- //滞后项目数量占比:指本年度逾期项目数量/本年度所有项目数量
- Integer thisYear = pmDemandMapper.countThisYear();
- resMap.put("滞后项目数量占比", getPercent(Integer.parseInt(resVo.getNum()), thisYear));
- return AjaxResult.success(resMap);
- }
- /**
- * 统计不同时间维度的逾期项目
- *
- * @return
- */
- @Override
- public AjaxResult exceedAnalysis(PmDemandReqVo pmDemandReqVo) {
- HashMap<String, List<StatisticalChartsResVo>> resMap = new HashMap<>();
- List<StatisticalChartsResVo> byYear = pmDemandMapper.countProjectExceedYear();
- if (pmDemandReqVo.getTimeType().equals("1")) {
- resMap.put("年", byYear);
- } else if (pmDemandReqVo.getTimeType().equals("2")) {
- List<StatisticalChartsResVo> byQuarter = new LinkedList<>();
- for (StatisticalChartsResVo chartsResVo : byYear) {
- for (int i = 1; i <= 4; i++) {
- StatisticalChartsResVo quarter = pmDemandMapper.countProjectExceedQuarter(i, Integer.parseInt(chartsResVo.getColumnName()));
- quarter.setColumnName(chartsResVo.getColumnName() + "年第" + i + "季度");
- byQuarter.add(quarter);
- }
- }
- resMap.put("季度", byQuarter);
- } else if (pmDemandReqVo.getTimeType().equals("3")) {
- List<StatisticalChartsResVo> byMonth = pmDemandMapper.countProjectExceedMonth();
- resMap.put("月", byMonth);
- }
- return AjaxResult.success(resMap);
- }
- @Override
- public AjaxResult taskQuantityAnalysis(PmDemandReqVo pmDemandReqVo) {
- HashMap<String, List<StatisticalChartsResVo>> resMap = new HashMap<>();
- //任务数量趋势分析:按照月、季度、年统计“项目属性”字段中“重大规划”属性的项目
- List<StatisticalChartsResVo> byYear = pmDemandMapper.countProjectMajorByYear();
- if (pmDemandReqVo.getTimeType().equals("1")) {
- resMap.put("年", byYear);
- } else if (pmDemandReqVo.getTimeType().equals("2")) {
- List<StatisticalChartsResVo> byQuarter = new LinkedList<>();
- for (StatisticalChartsResVo chartsResVo : byYear) {
- for (int i = 1; i <= 4; i++) {
- StatisticalChartsResVo quarter = pmDemandMapper.countProjectMajorByQuarter(i, Integer.parseInt(chartsResVo.getColumnName()));
- quarter.setColumnName(chartsResVo.getColumnName() + "年第" + i + "季度");
- byQuarter.add(quarter);
- }
- }
- resMap.put("季度", byQuarter);
- } else if (pmDemandReqVo.getTimeType().equals("3")) {
- List<StatisticalChartsResVo> byMonth = pmDemandMapper.countProjectMajorByMonth();
- resMap.put("月", byMonth);
- }
- return AjaxResult.success(resMap);
- }
- @Override
- public AjaxResult newFinishPro() {
- // 新完成采购任务数量:状态为“合同待填制”、“项目建设中”、“项目建设完成”的项目
- // 预算金额:“合同待填制”、“项目建设中”、“项目建设完成”的项目累加的预算金额
- List<StatisticalChartsResVo> everyStatusNum = pmDemandMapper.countEveryStatusNumTwo();
- if (!ObjectUtils.isEmpty(everyStatusNum) && everyStatusNum.size() > 0) {
- for (StatisticalChartsResVo vo : everyStatusNum) {
- switch (vo.getColumnName()) {
- case "15":
- vo.setColumnName(PmProjectStatus.CONTRACT_WAIT_FILL.getInfo());
- case "16":
- vo.setColumnName(PmProjectStatus.UNDER_CONSTRUCTION.getInfo());
- case "17":
- vo.setColumnName(PmProjectStatus.COMPLETION_CONSTRUCTION.getInfo());
- }
- }
- }
- //合同金额:“合同待填制”、“项目建设中”、“项目建设完成”的项目累加的合同金额
- return AjaxResult.success(everyStatusNum);
- }
- @Override
- public AjaxResult countEveryStatusNum(PmDemandReqVo pmDemandReqVo) {
- //指项目进行到各个阶段的数量
- //阶段包括:待选取代理、待上传招标文件、待发布公告、待开标、待发布中标公告、中标公式中
- List<StatisticalChartsResVo> everyStatusNum = pmDemandMapper.countEveryStatusNum();
- if (!ObjectUtils.isEmpty(everyStatusNum) && everyStatusNum.size() > 0) {
- for (StatisticalChartsResVo vo : everyStatusNum) {
- switch (vo.getColumnName()) {
- case "9":
- vo.setColumnName(PmProjectStatus.WAIT_SELECT_AGENT.getInfo());
- case "10":
- vo.setColumnName(PmProjectStatus.WAIT_UPLOAD_BID_FILE.getInfo());
- case "11":
- vo.setColumnName(PmProjectStatus.WAIT_ANNOUNCEMENT.getInfo());
- case "12":
- vo.setColumnName(PmProjectStatus.WAIT_OPEN_BID.getInfo());
- case "13":
- vo.setColumnName(PmProjectStatus.WAIT_BID_ANNOUNCEMENT.getInfo());
- case "14":
- vo.setColumnName(PmProjectStatus.BIDDING_PUBLICITY.getInfo());
- }
- }
- }
- return AjaxResult.success(everyStatusNum);
- }
- @Override
- public AjaxResult exceedMarketAnalysis(PmDemandReqVo pmDemandReqVo) {
- //所有滞后
- List<PmDemand> demandList = pmDemandMapper.countProjectExceedAll();
- //滞后时长包括:滞后1个月以内的采购任务、滞后1至3个月采购任务、滞后3至6个月采购任务、滞后6个月至1年采购任务、滞后1年以上采购任务
- HashMap<String, Integer> map = new LinkedHashMap<>();
- map.put("滞后1个月以内的采购任务", 0);
- map.put("滞后1至3个月采购任务", 0);
- map.put("滞后3至6个月采购任务", 0);
- map.put("滞后6个月至1年采购任务", 0);
- map.put("滞后1年以上采购任务", 0);
- if (!ObjectUtils.isEmpty(demandList) && demandList.size() > 0) {
- for (PmDemand demand : demandList) {
- //滞后时间
- Long exTime = null;
- if (!ObjectUtils.isEmpty(demand.getRealDemandCommitTime()) && demand.getRealDemandCommitTime().getTime() - demand.getPlanDemandSubTime().getTime() > 0) {
- exTime = demand.getRealDemandCommitTime().getTime() - demand.getPlanDemandSubTime().getTime();
- } else if (!ObjectUtils.isEmpty(demand.getRealPurchaseFinishTime()) && demand.getRealPurchaseFinishTime().getTime() - demand.getPlanPurchaseFinishTime().getTime() > 0) {
- exTime = demand.getRealPurchaseFinishTime().getTime() - demand.getPlanPurchaseFinishTime().getTime();
- } else if (!ObjectUtils.isEmpty(demand.getRealDeliverTime()) && demand.getRealDeliverTime().getTime() - demand.getPlanDeliverTime().getTime() > 0) {
- exTime = demand.getRealDeliverTime().getTime() - demand.getPlanDeliverTime().getTime();
- }
- if (exTime < Long.valueOf("2592000000")) {
- map.put("滞后1个月以内的采购任务", map.get("滞后1个月以内的采购任务") + 1);
- }
- if (exTime >= Long.valueOf("2592000000") && exTime < Long.valueOf("7776000000")) {
- map.put("滞后1至3个月采购任务", map.get("滞后1至3个月采购任务") + 1);
- }
- if (exTime >= Long.valueOf("7776000000") && exTime < Long.valueOf("15552000000")) {
- map.put("滞后3至6个月采购任务", map.get("滞后3至6个月采购任务") + 1);
- }
- if (exTime >= Long.valueOf("15552000000") && exTime < Long.valueOf("31104000000")) {
- map.put("滞后6个月至1年采购任务", map.get("滞后6个月至1年采购任务") + 1);
- }
- if (exTime > Long.valueOf("31104000000")) {
- map.put("滞后1年以上采购任务", map.get("滞后1年以上采购任务") + 1);
- }
- }
- }
- return AjaxResult.success(map);
- }
- @Override
- public AjaxResult countMajorProject(PmDemandReqVo pmDemandReqVo) {
- List<StatisticalChartsResVo> resVos = new ArrayList<>();
- //数量:指本年度状态为“项目建设完成”的项目属性为“重大规划”的项目数
- //预算金额:指本年度状态为“项目建设完成”的项目属性为“重大规划”的项目累加的预算金额
- StatisticalChartsResVo resVo = new StatisticalChartsResVo();
- resVo = pmDemandMapper.majorProjectByStatus(PmProjectStatus.COMPLETION_CONSTRUCTION.getCode());
- resVo.setColumnName("今年已完成数量");
- resVos.add(resVo);
- //正常推进项目:指本年度正在进行中的项目属性为“重大规划”的项目数
- //预算金额:指本年度正在进行中的项目属性为“重大规划”的项目累加的预算金额
- StatisticalChartsResVo resVo1 = new StatisticalChartsResVo();
- resVo1 = pmDemandMapper.majorProjectByStatus(PmProjectStatus.UNDER_CONSTRUCTION.getCode());
- resVo1.setColumnName("正常推进数量");
- resVos.add(resVo1);
- //执行滞后数量:指本年度逾期项目中,项目属性为“重大规划”的项目数
- //预算金额:指本年度正在进行中的项目属性为“重大规划”的项目累加的预算金额
- StatisticalChartsResVo resVo2 = new StatisticalChartsResVo();
- resVo2 = pmDemandMapper.countMajorProjectExceed();
- resVo2.setColumnName("执行滞后数量");
- resVos.add(resVo2);
- //上年度重大规划采购任务数量:指上年度项目中,项目属性为“重大规划”的项目数
- //预算金额:指上年度项目中,项目属性为“重大规划”的项目累加的预算金额
- StatisticalChartsResVo resVo3 = new StatisticalChartsResVo();
- resVo3 = pmDemandMapper.countMajorProjectLastYear();
- resVo3.setColumnName("上年度重大规划采购任务数量");
- resVos.add(resVo3);
- //resVo2=pmDemandMapper.majorProjectByStatus(PmProjectStatus.COMPLETION_CONSTRUCTION.getCode());
- return AjaxResult.success(resVos);
- }
- /**
- * 通过计划ID查询项目数据
- *
- * @param planId
- * @return
- */
- @Override
- public PmDemand selectByPlanId(Integer planId) {
- return pmDemandMapper.selectByPlanId(planId);
- }
- /**
- * 采购项目--项目数量分析
- *
- * @param pmDemandReqVo
- * @return
- */
- @Override
- public Map<String, Integer> purchaseProjectNumber(PmDemandReqVo pmDemandReqVo) {
- return null;
- }
- /**
- * 项目执行进度统计
- * 1、正常推进项目数量:指未完成并且没有逾期的项目
- * 预算金额:指未完成并且没有逾期的项目累加的预算金额
- * 2、未完成采购任务:“合同待填制”状态之前的项目
- * 预算金额:“合同待填制”状态之前的项目累加的预算金额
- *
- * @param pmDemandReqVo
- * @return
- */
- @Override
- public Map<String, Integer> purchaseProjectExecute(PmDemandReqVo pmDemandReqVo) {
- Map<String, Integer> mapReturn = new HashMap<>();
- // 正常推进项目数量、预算金额
- Map<String, Integer> mapNormalPropulsion = pmDemandMapper.purchaseProjectExecuteNormalPropulsion(pmDemandReqVo);
- // 未完成采购任务,预算金额
- Map<String, Integer> mapIncomplete = pmDemandMapper.purchaseProjectExecuteIncomplete(pmDemandReqVo);
- mapReturn.putAll(mapNormalPropulsion);
- mapReturn.putAll(mapIncomplete);
- return mapReturn;
- }
- /**
- * 已完成项目数量统计
- *
- * @param pmDemandReqVo
- * @return
- */
- @Override
- public List<Map<String, Integer>> purchaseProjectCompleteNumber(PmDemandReqVo pmDemandReqVo) {
- List<Map<String, Integer>> mapReturn = new ArrayList<>();
- // 统计时间类型 1:年度,2:季度,3:月份
- if ("1".equals(pmDemandReqVo.getTimeType())) {
- // 查询数据库中最小的年份
- int minYear = pmDemandMapper.selectMinYear();
- // 获取当前年份
- Calendar calendar = Calendar.getInstance();
- int year = calendar.get(Calendar.YEAR);
- // 获取统计数据
- List<Map<String, Integer>> listMap = pmDemandMapper.selectpurchaseProjectCompleteNumberYear(pmDemandReqVo);
- mapReturn.addAll(listMap);
- for (int i = minYear; i <= year; i++) {
- for (Map<String, Integer> map : listMap) {
- if (i != Integer.valueOf(map.get("yy"))) {
- Map<String, Integer> map1 = new HashMap<>();
- map1.put("yy", i);
- map1.put("evaluation", 0);
- map1.put("contractAmount", 0);
- map1.put("countNum", 0);
- mapReturn.add(map1);
- }
- }
- }
- } else if ("2".equals(pmDemandReqVo.getTimeType())) {
- // 当前年份季度统计
- // 获取统计数据
- List<Map<String, Integer>> listMap = pmDemandMapper.selectpurchaseProjectCompleteNumberQuarter(pmDemandReqVo);
- mapReturn.addAll(listMap);
- for (int i = 1; i <= 4; i++) {
- for (Map<String, Integer> map : listMap) {
- if (i != map.get("yy")) {
- Map<String, Integer> map1 = new HashMap<>();
- map1.put("yy", i);
- map1.put("evaluation", 0);
- map1.put("contractAmount", 0);
- map1.put("countNum", 0);
- mapReturn.add(map1);
- }
- }
- }
- } else if ("3".equals(pmDemandReqVo.getTimeType())) {
- // 当前年份月份统计
- // 获取统计数据
- List<Map<String, Integer>> listMap = pmDemandMapper.selectpurchaseProjectCompleteNumberMonth(pmDemandReqVo);
- mapReturn.addAll(listMap);
- for (int i = 1; i <= 12; i++) {
- for (Map<String, Integer> map : listMap) {
- int ii = Integer.parseInt(String.valueOf(map.get("yy")));
- map.put("yy", ii);
- if (i != ii) {
- Map<String, Integer> map1 = new HashMap<>();
- map1.put("yy", i);
- map1.put("evaluation", 0);
- map1.put("contractAmount", 0);
- map1.put("countNum", 0);
- mapReturn.add(map1);
- }
- }
- }
- }
- return mapReturn;
- }
- /**
- * 各阶段项目数量分布
- * @param pmDemandReqVo
- * @return
- */
- @Override
- public List<Map<String, String>> purchaseProjectDistribution(PmDemandReqVo pmDemandReqVo) {
- // 项目计划 4之前(包括4)
- List<String> xmjh = new ArrayList<>();
- xmjh.add("4");
- pmDemandReqVo.setProjectStatusList(xmjh);
- Map<String, String> returnMapxmjh = pmDemandMapper.purchaseProjectDistribution(pmDemandReqVo);
- returnMapxmjh.put("name", "计划管理");
- // 需求建党 4之后(不包括4)
- List<String> xqjd = new ArrayList<>();
- xqjd.add("5");
- xqjd.add("6");
- xqjd.add("7");
- xqjd.add("8");
- pmDemandReqVo.setProjectStatusList(xqjd);
- Map<String, String> returnMapxqjd = pmDemandMapper.purchaseProjectDistribution(pmDemandReqVo);
- returnMapxqjd.put("name", "需求管理");
- // 任务下达 8之后(不包括8)
- List<String> rwxd = new ArrayList<>();
- rwxd.add("9");
- pmDemandReqVo.setProjectStatusList(rwxd);
- Map<String, String> returnMaprwxd = pmDemandMapper.purchaseProjectDistribution(pmDemandReqVo);
- returnMaprwxd.put("name", "任务下达");
- // 采购执行 9之后(不包括9)
- List<String> cgzx = new ArrayList<>();
- cgzx.add("10");
- cgzx.add("11");
- cgzx.add("12");
- cgzx.add("13");
- cgzx.add("14");
- cgzx.add("15");
- pmDemandReqVo.setProjectStatusList(cgzx);
- Map<String, String> returnMapcgzx = pmDemandMapper.purchaseProjectDistribution(pmDemandReqVo);
- returnMapcgzx.put("name", "采购执行");
- // 合同管理 15之后(不包括15)
- List<String> htxx = new ArrayList<>();
- htxx.add("16");
- pmDemandReqVo.setProjectStatusList(htxx);
- Map<String, String> returnMaphtxx = pmDemandMapper.purchaseProjectDistribution(pmDemandReqVo);
- returnMaphtxx.put("name", "合同管理");
- // 项目建设 17
- List<String> xmjs = new ArrayList<>();
- xmjs.add("16");
- pmDemandReqVo.setProjectStatusList(xmjs);
- Map<String, String> returnMapxmjs = pmDemandMapper.purchaseProjectDistribution(pmDemandReqVo);
- returnMapxmjs.put("name", "合同管理");
- List<Map<String, String>> returnMap = new ArrayList<>();
- returnMap.add(returnMapxmjh);
- returnMap.add(returnMapxqjd);
- returnMap.add(returnMaprwxd);
- returnMap.add(returnMapcgzx);
- returnMap.add(returnMaphtxx);
- returnMap.add(returnMapxmjs);
- return returnMap;
- }
- /**
- * 项目数量分析
- * @param pmDemandReqVo
- * @return
- */
- @Override
- public List<Map<String, String>> purchaseProjectNumberAnalysis(PmDemandReqVo pmDemandReqVo) {
- List<Map<String, String>> mapReturn = new ArrayList<>();
- // 统计时间类型 1:年度,2:季度,3:月份
- if ("1".equals(pmDemandReqVo.getTimeType())) {
- // *** 年度的同比和环比不展示 *** //
- // 查询数据库中最小的年份
- int minYear = pmDemandMapper.selectMinYear();
- // 获取当前年份
- Calendar calendar = Calendar.getInstance();
- int year = calendar.get(Calendar.YEAR);
- // 获取统计数据
- // 获取项目统计
- List<Map<String, String>> listMap = pmDemandMapper.purchaseProjectNumberAnalysisYear(pmDemandReqVo);
- mapReturn.addAll(listMap);
- for (int i = minYear; i <= year; i++) {
- for (Map<String, String> map : listMap) {
- if (i != Integer.valueOf(map.get("yy"))) {
- Map<String, String> map1 = new HashMap<>();
- map1.put("yy", i + "");
- map1.put("countNum", 0 + "");
- mapReturn.add(map1);
- }
- }
- }
- } else if ("2".equals(pmDemandReqVo.getTimeType())) {
- // 当前年份季度统计
- // 获取统计数据
- List<Map<String, String>> listMap = pmDemandMapper.purchaseProjectNumberAnalysisQuarter(pmDemandReqVo);
- mapReturn.addAll(listMap);
- for (int i = 1; i <= 4; i++) {
- for (Map<String, String> map : listMap) {
- int ii = Integer.parseInt(String.valueOf(map.get("yy")));
- map.put("yy", ii + "");
- if (i != ii) {
- Map<String, String> map1 = new HashMap<>();
- map1.put("yy", i + "");
- map1.put("countNum", 0 + "");
- mapReturn.add(map1);
- }
- }
- }
- } else if ("3".equals(pmDemandReqVo.getTimeType())) {
- // 当前年份月份统计
- // 获取统计数据
- List<Map<String, String>> listMap = pmDemandMapper.purchaseProjectNumberAnalysisMonth(pmDemandReqVo);
- mapReturn.addAll(listMap);
- for (int i = 1; i <= 12; i++) {
- for (Map<String, String> map : listMap) {
- int ii = Integer.parseInt(String.valueOf(map.get("yy")));
- map.put("yy", ii + "");
- if (i != ii) {
- Map<String, String> map1 = new HashMap<>();
- map1.put("yy", i + "");
- map1.put("countNum", 0 + "");
- mapReturn.add(map1);
- }
- }
- }
- }
- return mapReturn;
- }
- //查询不同状态下的项目数据
- public List<PmDemandResVo> getListByStatus(String projectStatus) {
- LambdaQueryWrapper<PmDemand> lw = new LambdaQueryWrapper<PmDemand>();
- lw.eq(PmDemand::getProjectStatus, projectStatus);
- List<PmDemand> demandList = this.baseMapper.selectList(lw);
- //数据转换
- List<PmDemandResVo> pmDemandResponseVoList = new ArrayList<>();
- if (!ObjectUtils.isEmpty(demandList) && demandList.size() > 0) {
- pmDemandResponseVoList = demandChangeTo(demandList);
- }
- return pmDemandResponseVoList;
- }
- //字段转换and赋值
- public List<PmDemandResVo> demandChangeTo(List<PmDemand> pmDemandList) {
- List<PmDemandResVo> pmDemandResponseVoList = new ArrayList<>();
- for (PmDemand pmDemand1 : pmDemandList) {
- PmDemandResVo vo = new PmDemandResVo();
- BeanUtils.copyProperties(pmDemand1, vo);
- if (vo.getPurchaseDeptId() != null) {
- Map<String, Object> deptMap = deptService.selectDeptById(vo.getPurchaseDeptId());
- if (deptMap != null) {
- SysDeptResponseVo sysDeptResponseVo = (SysDeptResponseVo) deptMap.get("sysDept");
- if (sysDeptResponseVo != null) {
- vo.setPurchaseDeptName(sysDeptResponseVo.getDeptName());
- }
- }
- }
- String purchaseServicesName = dictDataService.selectDictLabel("purchase_services", vo.getPurchaseServices());
- if (StringUtils.isNotEmpty(purchaseServicesName)) {
- vo.setPurchaseServicesName(purchaseServicesName);
- }
- //项目类型
- for (ProjectTypes value : ProjectTypes.values()) {
- if (vo.getProjectType() != null && vo.getProjectType().equals(value.getCode())) {
- vo.setProjectTypeName(value.getInfo());
- break;
- }
- }
- //是否为超限额计划
- for (IsExcess value : IsExcess.values()) {
- if (vo.getIsExcess() != null && vo.getIsExcess().equals(value.getCode())) {
- vo.setIsExcessName(value.getInfo());
- break;
- }
- }
- //采购方式
- for (PlanPurchaseMode value : PlanPurchaseMode.values()) {
- if (vo.getPurchaseMode() != null && vo.getPurchaseMode().equals(value.getCode())) {
- vo.setPurchaseModeName(value.getInfo());
- break;
- }
- }
- //项目属性
- for (ProjectAttribute value : ProjectAttribute.values()) {
- if (vo.getProjectAttr() != null && vo.getProjectAttr().equals(value.getCode())) {
- vo.setProjectAttrName(value.getInfo());
- break;
- }
- }
- //预警状态
- for (WarnStatus value : WarnStatus.values()) {
- if (vo.getWarnStatus() != null && vo.getWarnStatus().equals(value.getCode())) {
- vo.setWarnStatusName(value.getInfo());
- break;
- }
- }
- //项目状态
- for (PmProjectStatus value : PmProjectStatus.values()) {
- if (vo.getProjectStatus() != null && vo.getProjectStatus().equals(value.getCode())) {
- vo.setProjectStatusName(value.getInfo());
- break;
- }
- }
- try {
- vo.setTipsMessage(pmDemandGetTips(vo.getPlanDeliverTime()));
- if (vo.getTipsMessage().contains("超过")) {
- vo.setIsExceedProject("1");
- }
- } catch (ParseException e) {
- e.printStackTrace();
- }
- pmDemandResponseVoList.add(vo);
- }
- return pmDemandResponseVoList;
- }
- /**
- * 根据年度计划提报时间的阈值进行提示
- *
- * @return
- */
- public String pmDemandGetTips(Date planDeliverTime) throws ParseException {
- if (!ObjectUtils.isEmpty(planDeliverTime)) {
- //提示信息:定义距离结束时间一周内提示
- Integer remindTine = 1000 * 60 * 60 * 24 * 7;
- //少于一周便提醒
- double surplus = planDeliverTime.getTime() - System.currentTimeMillis();
- if (surplus < remindTine) {
- int i = new Double(Math.ceil(surplus / 1000 / 60 / 60 / 24)).intValue();
- //剩余天数(向上取整)
- if (i > 0) {
- return "距离计划交付时间不足" + i + "天";
- } else {
- return "已超过计划完成时间" + i + "天";
- }
- }
- }
- return "";
- }
- /**
- * 计算百分比:使用java.text.DecimalFormat实现
- *
- * @param x
- * @param y
- * @return
- */
- public static String getPercent(int x, int y) {
- double d1 = x * 1.0;
- double d2 = y * 1.0;
- // 设置保留几位小数, “.”后面几个零就保留几位小数,这里设置保留2位小数
- DecimalFormat decimalFormat = new DecimalFormat("##.00%");
- return decimalFormat.format(d1 / d2);
- }
- }
|