|
|
@@ -3,6 +3,8 @@ package com.jzg.organization.service.impl;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.jzg.commons.core.base.BaseController;
|
|
|
+import com.jzg.commons.core.base.PageRequest;
|
|
|
import com.jzg.commons.core.page.HttpResult;
|
|
|
import com.jzg.commons.entity.po.*;
|
|
|
import com.jzg.commons.entity.vo.*;
|
|
|
@@ -14,12 +16,18 @@ import com.jzg.organization.mapper.SysUserJzgInfoMapper;
|
|
|
import com.jzg.organization.mapper.SysUserMapper;
|
|
|
import com.jzg.organization.service.*;
|
|
|
import com.jzg.organization.utils.MinioUtils;
|
|
|
+import com.jzg.organization.service.*;
|
|
|
+import com.jzg.organization.state.UserState;
|
|
|
import jakarta.annotation.Resource;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.statemachine.StateMachine;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
+import java.util.Objects;
|
|
|
|
|
|
/**
|
|
|
* @author Administrator
|
|
|
@@ -40,6 +48,48 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
|
|
@Resource
|
|
|
private SysUserJzgInfoMapper sysUserJzgInfoMapper;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private SysAreaService sysAreaService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private SysUserService sysUserService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private StateMachine<UserState.UserStateEnum, UserState.UserStateEvent> stateMachine;
|
|
|
+
|
|
|
+ private String getCurrentAreaCode(String province,String city,String area){
|
|
|
+ String userWorkNumber = "";
|
|
|
+ if (!area.isEmpty()) {
|
|
|
+ userWorkNumber += area; // 使用县
|
|
|
+ } else if (!city.isEmpty()) {
|
|
|
+ userWorkNumber += city.substring(0,4); // 使用市
|
|
|
+ } else if (!province.isEmpty()) {
|
|
|
+ userWorkNumber += province.substring(0,2); // 使用省
|
|
|
+ }
|
|
|
+ return userWorkNumber;
|
|
|
+ }
|
|
|
+
|
|
|
+// /**
|
|
|
+// * 用户工号生成
|
|
|
+// * @return
|
|
|
+// */
|
|
|
+// private String userWorkNumberGenerator(String typeArr,String deptId,String organizationId) {
|
|
|
+// SysDept sysDept = sysDeptService.getById(deptId);
|
|
|
+// String userWorkNumber = "";
|
|
|
+// //后线人员生成
|
|
|
+// if(typeArr.equals("2")){
|
|
|
+// userWorkNumber = getCurrentAreaCode(sysDept.getProvince(),sysDept.getCity(),sysDept.getArea());
|
|
|
+// long count = sysUserJzgInfoService.count(new LambdaQueryWrapper<SysUserJzgInfo>()
|
|
|
+// .eq(SysUserJzgInfo::getDeptId, deptId)
|
|
|
+// .eq(SysUserJzgInfo::getTypeAttr, typeArr));
|
|
|
+// userWorkNumber += String.valueOf(count + 1);
|
|
|
+// }else if(typeArr.equals("1")){
|
|
|
+// //前线人员生成
|
|
|
+// userWorkNumber = getCurrentAreaCode(sysDept.getProvince(),sysDept.getCity(),sysDept.getArea());
|
|
|
+// }
|
|
|
+// return userWorkNumber;
|
|
|
+// }
|
|
|
+
|
|
|
@Resource
|
|
|
private SysUploadFilesMapper sysUploadFilesMapper;
|
|
|
|
|
|
@@ -55,8 +105,8 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public HttpResult getUserSelect(){
|
|
|
- return HttpResult.ok(baseMapper.getUserSelect());
|
|
|
+ public HttpResult getUserSelect(SysUserInfoListVo sysUserInfoListVo){
|
|
|
+ return HttpResult.ok(baseMapper.getUserSelect(sysUserInfoListVo));
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -64,12 +114,48 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
|
|
return sysUserJzgInfoMapper.getUserInfoList(page,sysUserInfoListVo);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public UserTransferInfoVo getTransferInfo(String userId) {
|
|
|
+ SysUserJzgInfo userJzgInfo = sysUserJzgInfoService.getOne(new LambdaQueryWrapper<SysUserJzgInfo>()
|
|
|
+ .eq(SysUserJzgInfo::getUserId,userId));
|
|
|
+ SysDept dept = sysDeptService.getById(userJzgInfo.getDeptId());
|
|
|
+ if(Objects.isNull(dept)){
|
|
|
+ throw new SystemException("人员所属机构不存在");
|
|
|
+ }
|
|
|
+ long count = sysUserJzgInfoService.count(new LambdaQueryWrapper<SysUserJzgInfo>()
|
|
|
+ .eq(SysUserJzgInfo::getLeaderId, userId));
|
|
|
+ return new UserTransferInfoVo(userId,String.valueOf(count),dept.getName());
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public boolean userTransfer(UserTransferVo userTransferVo) {
|
|
|
+ String originalUserId = userTransferVo.getOriginalUserId();
|
|
|
+ //检查用户的业务员数量
|
|
|
+ List<SysUserJzgInfo> list = sysUserJzgInfoService.list(new LambdaQueryWrapper<SysUserJzgInfo>()
|
|
|
+ .eq(SysUserJzgInfo::getLeaderId, originalUserId));
|
|
|
+ list.forEach(item->{
|
|
|
+ item.setLeaderId(userTransferVo.getTransferUserId());
|
|
|
+ });
|
|
|
+ return sysUserJzgInfoService.updateBatchById(list);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<String> getUserRoleName(String userId) {
|
|
|
+ return baseMapper.getUserRoleName(userId);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public boolean userQuitApply(String userId) {
|
|
|
+// sysUserJzgInfoService.getById()
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public HttpResult addUserInfo(SysUserVo sysUserVo) {
|
|
|
SysUser sysUser = baseMapper.getUserByMobile(sysUserVo.getMobile());
|
|
|
if (sysUser != null) {
|
|
|
- verifyUser(sysUserVo.getDeptId(),sysUserVo.getIdentity(),sysUser.getId(),sysUserVo.getLeaderId(),sysUserVo.getReferrerId());
|
|
|
+ verifyUser(sysUserVo.getTypeAttr(),sysUserVo.getDeptId(),sysUserVo.getIdentity(),sysUser.getId(),sysUserVo.getLeaderId(),sysUserVo.getReferrerId());
|
|
|
SysUserJzgInfo sysUserJzgInfo = new SysUserJzgInfo();
|
|
|
BeanUtils.copyProperties(sysUserVo, sysUserJzgInfo);
|
|
|
sysUserJzgInfo.setUserId(sysUser.getId());
|
|
|
@@ -125,7 +211,13 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
|
|
sysUserJzgInfoBankCardService.save(sysUserJzgInfoBankCard);
|
|
|
}
|
|
|
}
|
|
|
- return HttpResult.ok("添加业务员成功");
|
|
|
+ String resultMsg = "";
|
|
|
+ if(sysUserVo.getTypeAttr().equals("2")){
|
|
|
+ resultMsg = "添加成员成功";
|
|
|
+ }else{
|
|
|
+ resultMsg = "添加业务员成功";
|
|
|
+ }
|
|
|
+ return HttpResult.ok(resultMsg);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -207,6 +299,30 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
|
|
if (sysUserJzgInfo == null) {
|
|
|
throw new SystemException("该用户不存在");
|
|
|
}
|
|
|
+ SysUser sysUser = sysUserService.getById(sysUserJzgInfo.getUserId());
|
|
|
+ sysUserJzgInfo.setMobile(sysUser.getMobile());
|
|
|
+ SysDept dept = sysDeptService.getById(sysUserJzgInfo.getDeptId());
|
|
|
+ if(!Objects.isNull(dept)){
|
|
|
+ sysUserJzgInfo.setDeptName(dept.getName());
|
|
|
+ }
|
|
|
+ List<String> areaList = new ArrayList<>();
|
|
|
+ if(!Objects.isNull(sysUserJzgInfo.getProvince()) && !sysUserJzgInfo.getProvince().isEmpty()){
|
|
|
+ areaList.add(sysUserJzgInfo.getProvince());
|
|
|
+ }else if(!Objects.isNull(sysUserJzgInfo.getCity()) && !sysUserJzgInfo.getCity().isEmpty()) {
|
|
|
+ areaList.add(sysUserJzgInfo.getCity());
|
|
|
+ }else if(!Objects.isNull(sysUserJzgInfo.getDistrict()) && !sysUserJzgInfo.getDistrict().isEmpty()){
|
|
|
+ areaList.add(sysUserJzgInfo.getDistrict());
|
|
|
+ }
|
|
|
+ if(areaList.size() == 0){
|
|
|
+ sysUserJzgInfo.setRegion("");
|
|
|
+ }else {
|
|
|
+ List<SysArea> sysAreas = sysAreaService.queryAllByAreaCode(areaList);
|
|
|
+ String region = "";
|
|
|
+ for (int i = 0; i < sysAreas.size(); i++) {
|
|
|
+ region = region + sysAreas.get(i).getAreaCname() + "-";
|
|
|
+ }
|
|
|
+ sysUserJzgInfo.setRegion(region.substring(0, region.length() - 1));
|
|
|
+ }
|
|
|
List<SysUserJzgInfoFile> sysUserJzgInfoFile = sysUserJzgInfoFileService.list
|
|
|
(new LambdaQueryWrapper<SysUserJzgInfoFile>().eq(SysUserJzgInfoFile::getUserJzgInfoId,id));
|
|
|
sysUserJzgInfo.setFileList(sysUserJzgInfoFile);
|
|
|
@@ -214,7 +330,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
|
|
}
|
|
|
|
|
|
|
|
|
- public void verifyUser(String deptId,String identity,String userId,String leaderId,String referrerId){
|
|
|
+ public void verifyUser(String typeAttr,String deptId,String identity,String userId,String leaderId,String referrerId){
|
|
|
SysDept sysDept = sysDeptService.getById(deptId);
|
|
|
List<SysUserJzgInfo> sysUserJzgInfos = sysUserJzgInfoService.getUserInfoByIdentity(identity, userId);
|
|
|
SysUserJzgInfo sysUserJzgInfoByLeaderId = sysUserJzgInfoService.getOne
|
|
|
@@ -227,11 +343,13 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
|
|
if (sysDept == null) {
|
|
|
throw new SystemException("所选机构不存在");
|
|
|
}
|
|
|
- if (sysUserJzgInfoByLeaderId == null) {
|
|
|
- throw new SystemException("所选管理员不存在");
|
|
|
- }
|
|
|
- if (sysUserJzgInfoByReferrerId == null) {
|
|
|
- throw new SystemException("所选推荐人不存在");
|
|
|
+ if(!typeAttr.equals("2")) {
|
|
|
+ if (sysUserJzgInfoByLeaderId == null) {
|
|
|
+ throw new SystemException("所选管理员不存在");
|
|
|
+ }
|
|
|
+ if (sysUserJzgInfoByReferrerId == null) {
|
|
|
+ throw new SystemException("所选推荐人不存在");
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|