From c4e6c8da4fc0d4c5f71dffc8646af1a0e2efc207 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?niohe=C2=B7erbao?= Date: Tue, 14 Mar 2023 10:15:45 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=93=E5=AE=B6=E4=BF=A1=E6=81=AF=E6=8F=90?= =?UTF-8?q?=E4=BA=A4=E6=8E=A5=E5=8F=A3=E8=BD=AC=E4=B8=BA=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E5=91=98=E6=8F=90=E4=BA=A4=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pmapi/expert/manage/ExpertManage.java | 32 +++++++++++++++++++++- .../pmapi/sys/service/IRegionService.java | 2 +- .../pmapi/sys/service/impl/RegionServiceImpl.java | 6 ++-- .../pmapi/user/service/IUserInfoService.java | 7 +++-- .../user/service/impl/UserInfoServiceImpl.java | 21 +++++++++++--- 5 files changed, 57 insertions(+), 11 deletions(-) diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/expert/manage/ExpertManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/expert/manage/ExpertManage.java index 754de97..7556ebd 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/expert/manage/ExpertManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/expert/manage/ExpertManage.java @@ -22,11 +22,16 @@ import com.ningdatech.pmapi.expert.service.ExpertInfoService; import com.ningdatech.pmapi.expert.service.IExpertUserFullInfoService; import com.ningdatech.pmapi.meta.constant.DictExpertInfoTypeEnum; import com.ningdatech.pmapi.meta.model.ExpertRegionInfo; +import com.ningdatech.pmapi.user.constant.UserAvailableEnum; +import com.ningdatech.pmapi.user.entity.UserInfo; +import com.ningdatech.pmapi.user.service.IUserInfoService; import com.ningdatech.pmapi.user.util.LoginUserUtil; import lombok.RequiredArgsConstructor; import org.apache.commons.collections4.CollectionUtils; import org.springframework.stereotype.Component; +import org.springframework.transaction.annotation.Transactional; +import java.time.LocalDateTime; import java.util.ArrayList; import java.util.List; import java.util.Objects; @@ -47,6 +52,7 @@ public class ExpertManage { private final ExpertInfoCommonHelper expertInfoCommonHelper; private final FileService fileService; private final ExpertUserInfoAssembler expertUserInfoAssembler; + private final IUserInfoService iUserInfoService; /** @@ -56,8 +62,11 @@ public class ExpertManage { */ public void expertBasicInfoSubmit(ExpertUserBasicInfoSubmitRequest request) { // 用户id - Long userId = LoginUserUtil.getUserId(); +// Long userId = LoginUserUtil.getUserId(); ExpertBasicInfo basicInfo = request.getBasicInfo(); + Long userId = generateOrGetUserId(basicInfo); + + // 校验区域编码合法性 校验履职意向编码合法性 ExpertRegionInfo expertRegionInfo = basicInfo.getExpertRegionInfo(); expertManageHelper.expertRegionInfoCheck(expertRegionInfo); @@ -137,4 +146,25 @@ public class ExpertManage { List attachFiles = fileService.getByIds(fileIdList); return expertUserInfoAssembler.buildExpertFullInfoVO(attachFiles, expertUserFullInfoAll); } + + @Transactional(rollbackFor = Exception.class) + public Long generateOrGetUserId(ExpertBasicInfo basicInfo) { + String phoneNo = basicInfo.getPhoneNo(); + UserInfo userInfo = iUserInfoService.getUserInfoByPhoneNo(phoneNo); + if (Objects.isNull(userInfo)) { + userInfo = UserInfo.builder() +// .accountId(dingEmployeeInfo.getAccountId()) + .username(basicInfo.getName()) + .realName(basicInfo.getName()) +// .employeeCode(dingEmployeeInfo.getEmployeeCode()) + .available(UserAvailableEnum.DISABLE.name()) + .createBy(LoginUserUtil.getUserId()) + .updateBy(LoginUserUtil.getUserId()) + .createOn(LocalDateTime.now()) + .updateOn(LocalDateTime.now()) + .build(); + iUserInfoService.save(userInfo); + } + return userInfo.getId(); + } } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/sys/service/IRegionService.java b/pmapi/src/main/java/com/ningdatech/pmapi/sys/service/IRegionService.java index 901a498..2aca320 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/sys/service/IRegionService.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/sys/service/IRegionService.java @@ -1,8 +1,8 @@ package com.ningdatech.pmapi.sys.service; import com.baomidou.mybatisplus.extension.service.IService; -import com.ningdatech.pmapi.sys.model.entity.Region; import com.ningdatech.pmapi.sys.model.dto.RegionDTO; +import com.ningdatech.pmapi.sys.model.entity.Region; import java.util.List; diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/sys/service/impl/RegionServiceImpl.java b/pmapi/src/main/java/com/ningdatech/pmapi/sys/service/impl/RegionServiceImpl.java index 0a2e2ae..7b5f4bd 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/sys/service/impl/RegionServiceImpl.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/sys/service/impl/RegionServiceImpl.java @@ -52,9 +52,9 @@ public class RegionServiceImpl extends ServiceImpl impleme @Override public Long getRegionIdByParentIdWithSameRegionCode(Long parentId, String regionCode) { return baseMapper.selectOne(Wrappers.lambdaQuery(Region.class) - .eq(Region::getParentId, parentId) - .eq(Region::getRegionCode, regionCode) - .eq(Region::getDeleted, false)) + .eq(Region::getParentId, parentId) + .eq(Region::getRegionCode, regionCode) + .eq(Region::getDeleted, false)) .getId(); } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/user/service/IUserInfoService.java b/pmapi/src/main/java/com/ningdatech/pmapi/user/service/IUserInfoService.java index d382b64..c87664f 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/user/service/IUserInfoService.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/user/service/IUserInfoService.java @@ -1,7 +1,7 @@ package com.ningdatech.pmapi.user.service; -import com.ningdatech.pmapi.user.entity.UserInfo; import com.baomidou.mybatisplus.extension.service.IService; +import com.ningdatech.pmapi.user.entity.UserInfo; import com.wflow.workflow.bean.dto.ProcessInstanceUserDto; import java.util.Map; @@ -9,7 +9,7 @@ import java.util.Set; /** *

- * 服务类 + * 服务类 *

* * @author Lierbao @@ -19,4 +19,7 @@ public interface IUserInfoService extends IService { Map getUserMapByIds(Set staterUsers); ProcessInstanceUserDto getUserInfo(String userId); + + UserInfo getUserInfoByPhoneNo(String phoneNo); + } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/user/service/impl/UserInfoServiceImpl.java b/pmapi/src/main/java/com/ningdatech/pmapi/user/service/impl/UserInfoServiceImpl.java index 8630091..bdf3546 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/user/service/impl/UserInfoServiceImpl.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/user/service/impl/UserInfoServiceImpl.java @@ -12,6 +12,7 @@ import com.ningdatech.pmapi.user.mapper.NdUserInfoMapper; import com.ningdatech.pmapi.user.service.IUserInfoService; import com.wflow.workflow.bean.dto.ProcessInstanceUserDto; import lombok.RequiredArgsConstructor; +import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; import java.util.List; @@ -22,7 +23,7 @@ import java.util.stream.Collectors; /** *

- * 服务实现类 + * 服务实现类 *

* * @author Lierbao @@ -36,6 +37,7 @@ public class UserInfoServiceImpl extends ServiceImpl private final IDingEmployeeInfoService dingEmployeeInfoService; private final IDingOrganizationService dingOrganizationService; + @Override public Map getUserMapByIds(Set staterUsers) { List userInfos = userInfoMapper.selectBatchIds(staterUsers); @@ -44,13 +46,13 @@ public class UserInfoServiceImpl extends ServiceImpl userInfo.setUserId(String.valueOf(u.getId())); userInfo.setUserName(u.getRealName()); Long accountId = u.getAccountId(); - if (Objects.isNull(accountId)){ + if (Objects.isNull(accountId)) { throw new BizException("该用户没有录入浙政钉用户信息!"); } // 根据浙政钉用户ID获取单位code DingEmployeeInfo employeeInfo = dingEmployeeInfoService.getOne(Wrappers.lambdaQuery(DingEmployeeInfo.class) .eq(DingEmployeeInfo::getAccountId, accountId) - .eq(DingEmployeeInfo::getMainJob,String.valueOf(Boolean.TRUE)) + .eq(DingEmployeeInfo::getMainJob, String.valueOf(Boolean.TRUE)) .last("limit 1")); String organizationCode = employeeInfo.getOrganizationCode(); // 根据 单位code获取单位名称 @@ -70,7 +72,7 @@ public class UserInfoServiceImpl extends ServiceImpl processInstanceUserDto.setUserId(String.valueOf(userInfo.getId())); processInstanceUserDto.setUserName(userInfo.getRealName()); Long accountId = userInfo.getAccountId(); - if (Objects.isNull(accountId)){ + if (Objects.isNull(accountId)) { throw new BizException("该用户没有录入浙政钉用户信息!"); } // 根据浙政钉用户ID获取部门code @@ -85,4 +87,15 @@ public class UserInfoServiceImpl extends ServiceImpl processInstanceUserDto.setOrgName(organizationName); return processInstanceUserDto; } + + @Override + public UserInfo getUserInfoByPhoneNo(String phoneNo) { + if (StringUtils.isEmpty(phoneNo)) { + return null; + } + UserInfo userInfo = userInfoMapper + .selectOne(Wrappers.lambdaQuery(UserInfo.class) + .eq(UserInfo::getMobile, phoneNo)); + return userInfo; + } }