@@ -22,11 +22,16 @@ import com.ningdatech.pmapi.expert.service.ExpertInfoService; | |||||
import com.ningdatech.pmapi.expert.service.IExpertUserFullInfoService; | import com.ningdatech.pmapi.expert.service.IExpertUserFullInfoService; | ||||
import com.ningdatech.pmapi.meta.constant.DictExpertInfoTypeEnum; | import com.ningdatech.pmapi.meta.constant.DictExpertInfoTypeEnum; | ||||
import com.ningdatech.pmapi.meta.model.ExpertRegionInfo; | 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 com.ningdatech.pmapi.user.util.LoginUserUtil; | ||||
import lombok.RequiredArgsConstructor; | import lombok.RequiredArgsConstructor; | ||||
import org.apache.commons.collections4.CollectionUtils; | import org.apache.commons.collections4.CollectionUtils; | ||||
import org.springframework.stereotype.Component; | import org.springframework.stereotype.Component; | ||||
import org.springframework.transaction.annotation.Transactional; | |||||
import java.time.LocalDateTime; | |||||
import java.util.ArrayList; | import java.util.ArrayList; | ||||
import java.util.List; | import java.util.List; | ||||
import java.util.Objects; | import java.util.Objects; | ||||
@@ -47,6 +52,7 @@ public class ExpertManage { | |||||
private final ExpertInfoCommonHelper expertInfoCommonHelper; | private final ExpertInfoCommonHelper expertInfoCommonHelper; | ||||
private final FileService fileService; | private final FileService fileService; | ||||
private final ExpertUserInfoAssembler expertUserInfoAssembler; | private final ExpertUserInfoAssembler expertUserInfoAssembler; | ||||
private final IUserInfoService iUserInfoService; | |||||
/** | /** | ||||
@@ -56,8 +62,11 @@ public class ExpertManage { | |||||
*/ | */ | ||||
public void expertBasicInfoSubmit(ExpertUserBasicInfoSubmitRequest request) { | public void expertBasicInfoSubmit(ExpertUserBasicInfoSubmitRequest request) { | ||||
// 用户id | // 用户id | ||||
Long userId = LoginUserUtil.getUserId(); | |||||
// Long userId = LoginUserUtil.getUserId(); | |||||
ExpertBasicInfo basicInfo = request.getBasicInfo(); | ExpertBasicInfo basicInfo = request.getBasicInfo(); | ||||
Long userId = generateOrGetUserId(basicInfo); | |||||
// 校验区域编码合法性 校验履职意向编码合法性 | // 校验区域编码合法性 校验履职意向编码合法性 | ||||
ExpertRegionInfo expertRegionInfo = basicInfo.getExpertRegionInfo(); | ExpertRegionInfo expertRegionInfo = basicInfo.getExpertRegionInfo(); | ||||
expertManageHelper.expertRegionInfoCheck(expertRegionInfo); | expertManageHelper.expertRegionInfoCheck(expertRegionInfo); | ||||
@@ -137,4 +146,25 @@ public class ExpertManage { | |||||
List<AttachFileVo> attachFiles = fileService.getByIds(fileIdList); | List<AttachFileVo> attachFiles = fileService.getByIds(fileIdList); | ||||
return expertUserInfoAssembler.buildExpertFullInfoVO(attachFiles, expertUserFullInfoAll); | 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(); | |||||
} | |||||
} | } |
@@ -1,8 +1,8 @@ | |||||
package com.ningdatech.pmapi.sys.service; | package com.ningdatech.pmapi.sys.service; | ||||
import com.baomidou.mybatisplus.extension.service.IService; | 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.dto.RegionDTO; | ||||
import com.ningdatech.pmapi.sys.model.entity.Region; | |||||
import java.util.List; | import java.util.List; | ||||
@@ -52,9 +52,9 @@ public class RegionServiceImpl extends ServiceImpl<RegionMapper, Region> impleme | |||||
@Override | @Override | ||||
public Long getRegionIdByParentIdWithSameRegionCode(Long parentId, String regionCode) { | public Long getRegionIdByParentIdWithSameRegionCode(Long parentId, String regionCode) { | ||||
return baseMapper.selectOne(Wrappers.lambdaQuery(Region.class) | 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(); | .getId(); | ||||
} | } | ||||
@@ -1,7 +1,7 @@ | |||||
package com.ningdatech.pmapi.user.service; | package com.ningdatech.pmapi.user.service; | ||||
import com.ningdatech.pmapi.user.entity.UserInfo; | |||||
import com.baomidou.mybatisplus.extension.service.IService; | import com.baomidou.mybatisplus.extension.service.IService; | ||||
import com.ningdatech.pmapi.user.entity.UserInfo; | |||||
import com.wflow.workflow.bean.dto.ProcessInstanceUserDto; | import com.wflow.workflow.bean.dto.ProcessInstanceUserDto; | ||||
import java.util.Map; | import java.util.Map; | ||||
@@ -9,7 +9,7 @@ import java.util.Set; | |||||
/** | /** | ||||
* <p> | * <p> | ||||
* 服务类 | |||||
* 服务类 | |||||
* </p> | * </p> | ||||
* | * | ||||
* @author Lierbao | * @author Lierbao | ||||
@@ -19,4 +19,7 @@ public interface IUserInfoService extends IService<UserInfo> { | |||||
Map<String, ProcessInstanceUserDto> getUserMapByIds(Set<String> staterUsers); | Map<String, ProcessInstanceUserDto> getUserMapByIds(Set<String> staterUsers); | ||||
ProcessInstanceUserDto getUserInfo(String userId); | ProcessInstanceUserDto getUserInfo(String userId); | ||||
UserInfo getUserInfoByPhoneNo(String phoneNo); | |||||
} | } |
@@ -12,6 +12,7 @@ import com.ningdatech.pmapi.user.mapper.NdUserInfoMapper; | |||||
import com.ningdatech.pmapi.user.service.IUserInfoService; | import com.ningdatech.pmapi.user.service.IUserInfoService; | ||||
import com.wflow.workflow.bean.dto.ProcessInstanceUserDto; | import com.wflow.workflow.bean.dto.ProcessInstanceUserDto; | ||||
import lombok.RequiredArgsConstructor; | import lombok.RequiredArgsConstructor; | ||||
import org.apache.commons.lang3.StringUtils; | |||||
import org.springframework.stereotype.Service; | import org.springframework.stereotype.Service; | ||||
import java.util.List; | import java.util.List; | ||||
@@ -22,7 +23,7 @@ import java.util.stream.Collectors; | |||||
/** | /** | ||||
* <p> | * <p> | ||||
* 服务实现类 | |||||
* 服务实现类 | |||||
* </p> | * </p> | ||||
* | * | ||||
* @author Lierbao | * @author Lierbao | ||||
@@ -36,6 +37,7 @@ public class UserInfoServiceImpl extends ServiceImpl<NdUserInfoMapper, UserInfo> | |||||
private final IDingEmployeeInfoService dingEmployeeInfoService; | private final IDingEmployeeInfoService dingEmployeeInfoService; | ||||
private final IDingOrganizationService dingOrganizationService; | private final IDingOrganizationService dingOrganizationService; | ||||
@Override | @Override | ||||
public Map<String, ProcessInstanceUserDto> getUserMapByIds(Set<String> staterUsers) { | public Map<String, ProcessInstanceUserDto> getUserMapByIds(Set<String> staterUsers) { | ||||
List<UserInfo> userInfos = userInfoMapper.selectBatchIds(staterUsers); | List<UserInfo> userInfos = userInfoMapper.selectBatchIds(staterUsers); | ||||
@@ -44,13 +46,13 @@ public class UserInfoServiceImpl extends ServiceImpl<NdUserInfoMapper, UserInfo> | |||||
userInfo.setUserId(String.valueOf(u.getId())); | userInfo.setUserId(String.valueOf(u.getId())); | ||||
userInfo.setUserName(u.getRealName()); | userInfo.setUserName(u.getRealName()); | ||||
Long accountId = u.getAccountId(); | Long accountId = u.getAccountId(); | ||||
if (Objects.isNull(accountId)){ | |||||
if (Objects.isNull(accountId)) { | |||||
throw new BizException("该用户没有录入浙政钉用户信息!"); | throw new BizException("该用户没有录入浙政钉用户信息!"); | ||||
} | } | ||||
// 根据浙政钉用户ID获取单位code | // 根据浙政钉用户ID获取单位code | ||||
DingEmployeeInfo employeeInfo = dingEmployeeInfoService.getOne(Wrappers.lambdaQuery(DingEmployeeInfo.class) | DingEmployeeInfo employeeInfo = dingEmployeeInfoService.getOne(Wrappers.lambdaQuery(DingEmployeeInfo.class) | ||||
.eq(DingEmployeeInfo::getAccountId, accountId) | .eq(DingEmployeeInfo::getAccountId, accountId) | ||||
.eq(DingEmployeeInfo::getMainJob,String.valueOf(Boolean.TRUE)) | |||||
.eq(DingEmployeeInfo::getMainJob, String.valueOf(Boolean.TRUE)) | |||||
.last("limit 1")); | .last("limit 1")); | ||||
String organizationCode = employeeInfo.getOrganizationCode(); | String organizationCode = employeeInfo.getOrganizationCode(); | ||||
// 根据 单位code获取单位名称 | // 根据 单位code获取单位名称 | ||||
@@ -70,7 +72,7 @@ public class UserInfoServiceImpl extends ServiceImpl<NdUserInfoMapper, UserInfo> | |||||
processInstanceUserDto.setUserId(String.valueOf(userInfo.getId())); | processInstanceUserDto.setUserId(String.valueOf(userInfo.getId())); | ||||
processInstanceUserDto.setUserName(userInfo.getRealName()); | processInstanceUserDto.setUserName(userInfo.getRealName()); | ||||
Long accountId = userInfo.getAccountId(); | Long accountId = userInfo.getAccountId(); | ||||
if (Objects.isNull(accountId)){ | |||||
if (Objects.isNull(accountId)) { | |||||
throw new BizException("该用户没有录入浙政钉用户信息!"); | throw new BizException("该用户没有录入浙政钉用户信息!"); | ||||
} | } | ||||
// 根据浙政钉用户ID获取部门code | // 根据浙政钉用户ID获取部门code | ||||
@@ -85,4 +87,15 @@ public class UserInfoServiceImpl extends ServiceImpl<NdUserInfoMapper, UserInfo> | |||||
processInstanceUserDto.setOrgName(organizationName); | processInstanceUserDto.setOrgName(organizationName); | ||||
return processInstanceUserDto; | 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; | |||||
} | |||||
} | } |