From 686bd303ddc68db338fe352c38392194217168a5 Mon Sep 17 00:00:00 2001 From: heheng <475597332@qq.com> Date: 星期二, 11 三月 2025 15:27:59 +0800 Subject: [PATCH] 修改业务逻辑增加项目编码 --- expert-system/src/main/java/com/gkhy/system/service/impl/SysExpertInfoServiceImpl.java | 109 +++++++++++++++++++++++++++++++++++++++--------------- 1 files changed, 78 insertions(+), 31 deletions(-) diff --git a/expert-system/src/main/java/com/gkhy/system/service/impl/SysExpertInfoServiceImpl.java b/expert-system/src/main/java/com/gkhy/system/service/impl/SysExpertInfoServiceImpl.java index fe922cb..7a0f675 100644 --- a/expert-system/src/main/java/com/gkhy/system/service/impl/SysExpertInfoServiceImpl.java +++ b/expert-system/src/main/java/com/gkhy/system/service/impl/SysExpertInfoServiceImpl.java @@ -1,17 +1,21 @@ -package com.gkhy.assess.system.service.impl; +package com.gkhy.system.service.impl; + import cn.hutool.core.util.ObjectUtil; -import com.gkhy.assess.common.api.CommonPage; -import com.gkhy.assess.common.enums.DeleteFlagEnum; -import com.gkhy.assess.common.exception.ApiException; -import com.gkhy.assess.common.utils.PageUtil; -import com.gkhy.assess.system.domain.SysAgency; -import com.gkhy.assess.system.domain.SysExpertInfo; -import com.gkhy.assess.system.domain.SysUser; -import com.gkhy.assess.system.mapper.SysExpertInfoMapper; -import com.gkhy.assess.system.service.SysExpertInfoService; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.gkhy.assess.system.utils.ShiroUtils; +import com.gkhy.common.enums.DeleteFlagEnum; +import com.gkhy.common.exception.ServiceException; +import com.gkhy.common.utils.SecurityUtils; +import com.gkhy.common.utils.StringUtils; +import com.gkhy.system.domain.SysExpertInfo; +import com.gkhy.system.domain.vo.request.ExpertBatchChangeReq; +import com.gkhy.system.domain.vo.request.SysExpertInfoRoundReq; +import com.gkhy.system.domain.vo.request.SysExpertSearchReqDto; +import com.gkhy.system.domain.vo.response.ProjectExpertSectionResp; +import com.gkhy.system.domain.vo.response.SysExpertSearchRep; +import com.gkhy.system.mapper.SysExpertInfoMapper; +import com.gkhy.system.service.SysExpertInfoService; import org.springframework.stereotype.Service; import java.util.List; @@ -28,21 +32,24 @@ public class SysExpertInfoServiceImpl extends ServiceImpl<SysExpertInfoMapper, SysExpertInfo> implements SysExpertInfoService { @Override - public CommonPage exportInfoList(SysExpertInfo expertInfo) { - PageUtil.startPage(); - List<SysExpertInfo> agencyList=baseMapper.expertInfoList(expertInfo); - return CommonPage.restPage(agencyList); + public List<SysExpertInfo> exportInfoList(SysExpertInfo expertInfo) { + // + + return baseMapper.expertInfoListV2(expertInfo); } @Override public int addExpertInfo(SysExpertInfo expertInfo) { - if(!checkIdCardUnique(new SysExpertInfo().setIdCard(expertInfo.getIdCard()))){ - throw new ApiException(expertInfo.getIdCard()+"身份证号码已经存在"); + if(!checkIdCardUnique(expertInfo)){ + throw new ServiceException("该业务处室申请数据已存在"); } - expertInfo.setCreateBy(ShiroUtils.getSysUser().getUsername()); + if(StringUtils.isEmpty(expertInfo.getPersonalOpinionKey()) && StringUtils.isEmpty(expertInfo.getRecommendUnitOpinionKey())){ + throw new ServiceException("专家本人意见和推荐单位意见不能同时为空"); + } + expertInfo.setCreateBy(expertInfo.getName()); boolean b=save(expertInfo); if(!b){ - throw new ApiException("新增专家信息失败"); + throw new ServiceException("新增专家信息失败"); } return 1; } @@ -50,25 +57,28 @@ @Override public int modExpertInfo(SysExpertInfo expertInfo) { if(!checkIdCardUnique(expertInfo)){ - throw new ApiException(expertInfo.getIdCard()+"身份证号码已经存在"); + throw new ServiceException("该业务处室专业领域申请数据已存在"); } - expertInfo.setUpdateBy(ShiroUtils.getSysUser().getUsername()); + checkHavePer(expertInfo.getId()); + expertInfo.setUpdateBy(SecurityUtils.getUsername()); boolean b=updateById(expertInfo); if(!b){ - throw new ApiException("修改专家信息失败"); + throw new ServiceException("修改专家信息失败"); } return 1; } @Override public int delExpertInfo(Long expertId) { + checkHavePer(expertId); + SysExpertInfo expertInfo = new SysExpertInfo(); expertInfo.setId(expertId); - expertInfo.setDelFlag(DeleteFlagEnum.DELETED.getCode()); - expertInfo.setUpdateBy(ShiroUtils.getSysUser().getUsername()); + expertInfo.setDelFlag(DeleteFlagEnum.DELETED.getCode().intValue()); + expertInfo.setUpdateBy(SecurityUtils.getUsername()); boolean b= updateById(expertInfo); if(!b){ - throw new ApiException("删除专家信息失败"); + throw new ServiceException("删除专家信息失败"); } return 1; } @@ -83,16 +93,23 @@ return baseMapper.getExpertInfoById(expertId); } + private void checkHavePer(Long expertId){ + SysExpertInfo sysExpertInfo = checkExpertInfoDataScope(expertId); + if (!SecurityUtils.isAdmin(SecurityUtils.getUserId()) && !sysExpertInfo.getDeptId().toString().equals(SecurityUtils.getDeptId().toString())) + { + throw new ServiceException("没有权限操作该专家信息!"); + } + } public SysExpertInfo checkExpertInfoDataScope(Long expertId) { if(expertId==null){ - throw new ApiException("专家id为空!"); + throw new ServiceException("专家id为空!"); } SysExpertInfo expertInfo = baseMapper.getExpertInfoById(expertId); if (ObjectUtil.isNull(expertInfo)) { - throw new ApiException("专家数据不存在!"); + throw new ServiceException("专家数据不存在!"); } return expertInfo; } @@ -100,14 +117,44 @@ @Override public boolean changeApprove(SysExpertInfo expertInfo) { checkExpertInfoDataScope(expertInfo.getId()); - SysExpertInfo se=new SysExpertInfo().setId(expertInfo.getId()).setState(expertInfo.getState()); - se.setUpdateBy(ShiroUtils.getSysUser().getUsername()); - return updateById(se); + //SysExpertInfo se=new SysExpertInfo().setId(expertInfo.getId()).setState(expertInfo.getState()); + expertInfo.setUpdateBy(SecurityUtils.getUsername()); +// se.setUpdateBy(SecurityUtils.getUsername()); + return updateById(expertInfo); + } + + @Override + public SysExpertSearchRep queryApprove(SysExpertSearchReqDto expertInfo) { + SysExpertSearchRep sysExpertSearchRep = baseMapper.queryApprove(expertInfo); + if (null == sysExpertSearchRep){ + throw new ServiceException("申请记录不存!"); + } + return sysExpertSearchRep; + } + + @Override + public List<ProjectExpertSectionResp> getExpertRound(SysExpertInfoRoundReq req) { + // req.setDeptId(SecurityUtils.getDeptId()); + return baseMapper.getExpertRound(req); + } + + @Override + public void batchChangeEmploymentDate(ExpertBatchChangeReq req) { + if (!SecurityUtils.isAdmin(SecurityUtils.getUserId())){ + throw new ServiceException("无权操作!"); + } + + baseMapper.update(null, Wrappers.<SysExpertInfo>lambdaUpdate() + .set(SysExpertInfo::getUpdateBy,SecurityUtils.getUsername()) + .set(SysExpertInfo::getEmploymentDateStart,req.getEmploymentDateStart()) + .set(SysExpertInfo::getEmploymentDateEnd,req.getEmploymentDateEnd()) + .in(SysExpertInfo::getId,req.getId())); + } public boolean checkIdCardUnique(SysExpertInfo expertInfo){ Long expertId = expertInfo.getId()==null? -1L : expertInfo.getId(); - SysExpertInfo info = baseMapper.checkIdcardUnique(expertInfo.getIdCard()); + SysExpertInfo info = baseMapper.checkIdCardDomainUnique(expertInfo.getPhone(),expertInfo.getIdCard(),expertInfo.getDomain()); if (info!=null && info.getId().longValue() != expertId.longValue()) { return false; -- Gitblit v1.9.2