|
@@ -14,7 +14,6 @@ import com.hssx.cloudmodel.util.HttpRespMsg;
|
|
import com.hssx.cloudmodel.util.MD5Util;
|
|
import com.hssx.cloudmodel.util.MD5Util;
|
|
import com.hssx.cloudmodel.util.PageUtil;
|
|
import com.hssx.cloudmodel.util.PageUtil;
|
|
import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.BeanUtils;
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
@@ -24,10 +23,6 @@ import java.util.List;
|
|
import java.util.UUID;
|
|
import java.util.UUID;
|
|
|
|
|
|
/**
|
|
/**
|
|
- * <p>
|
|
|
|
- * 服务实现类
|
|
|
|
- * </p>
|
|
|
|
- *
|
|
|
|
* @author 吴涛涛
|
|
* @author 吴涛涛
|
|
* @since 2019-07-26
|
|
* @since 2019-07-26
|
|
*/
|
|
*/
|
|
@@ -155,12 +150,12 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public HttpRespMsg addAndUpdateUser(User user, Integer flag, Integer addType) {
|
|
|
|
|
|
+ public HttpRespMsg addAndUpdateUser(User user, Integer flag, Integer addType, Integer projectId) {
|
|
//获取该账号的创建者
|
|
//获取该账号的创建者
|
|
User parentUser = userMapper.selectById(user.getParentId());
|
|
User parentUser = userMapper.selectById(user.getParentId());
|
|
HttpRespMsg msg = new HttpRespMsg();
|
|
HttpRespMsg msg = new HttpRespMsg();
|
|
if (Constant.SYS_PARENT_ID == parentUser.getParentId()) {
|
|
if (Constant.SYS_PARENT_ID == parentUser.getParentId()) {
|
|
- //此时是创建admind,当前创建人是超级管理员
|
|
|
|
|
|
+ //此时是创建admind,当前创建人是超级管理员,此时没有项目id
|
|
int count = userMapper.selectCount(new QueryWrapper<User>().eq("company_id", user.getCompanyId()).eq("parent_id", parentUser.getId()));
|
|
int count = userMapper.selectCount(new QueryWrapper<User>().eq("company_id", user.getCompanyId()).eq("parent_id", parentUser.getId()));
|
|
if (flag == 0) {
|
|
if (flag == 0) {
|
|
if (count > 0) {
|
|
if (count > 0) {
|
|
@@ -190,7 +185,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
|
|
user.setTeamName("生产方");
|
|
user.setTeamName("生产方");
|
|
}
|
|
}
|
|
userMapper.insert(user);
|
|
userMapper.insert(user);
|
|
- if(addType != null){
|
|
|
|
|
|
+ if (addType != null) {
|
|
if (addType == 0) {
|
|
if (addType == 0) {
|
|
Company com = new Company();
|
|
Company com = new Company();
|
|
com.setId(user.getCompanyId());
|
|
com.setId(user.getCompanyId());
|
|
@@ -235,6 +230,15 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
|
|
if (userCompanyCount == 0) {
|
|
if (userCompanyCount == 0) {
|
|
userCompanyMapper.insert(userCompany);
|
|
userCompanyMapper.insert(userCompany);
|
|
}
|
|
}
|
|
|
|
+ //添加一条项目参与人记录
|
|
|
|
+ if (projectId != null) {
|
|
|
|
+ ProjectUser projectUser = new ProjectUser();
|
|
|
|
+ projectUser.setProjectId(projectId);
|
|
|
|
+ projectUser.setSubordinate(existingUser.getCompanyId());
|
|
|
|
+ projectUser.setUserId(existingUser.getId());
|
|
|
|
+ projectUser.setSubordinateType(existingUser.getSubordinateType());
|
|
|
|
+ projectUserMapper.insert(projectUser);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
//创建账号默认密码"000000"
|
|
//创建账号默认密码"000000"
|
|
@@ -259,6 +263,15 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
|
|
if (userCompanyCount == 0) {
|
|
if (userCompanyCount == 0) {
|
|
userCompanyMapper.insert(userCompany);
|
|
userCompanyMapper.insert(userCompany);
|
|
}
|
|
}
|
|
|
|
+ //添加一条项目参与人记录
|
|
|
|
+ if (projectId != null) {
|
|
|
|
+ ProjectUser projectUser = new ProjectUser();
|
|
|
|
+ projectUser.setProjectId(projectId);
|
|
|
|
+ projectUser.setSubordinate(user.getCompanyId());
|
|
|
|
+ projectUser.setUserId(user.getId());
|
|
|
|
+ projectUser.setSubordinateType(user.getSubordinateType());
|
|
|
|
+ projectUserMapper.insert(projectUser);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
} else if (flag == 1) {
|
|
} else if (flag == 1) {
|
|
//更新角色信息
|
|
//更新角色信息
|
|
@@ -284,21 +297,42 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
|
|
if (count > 0) {
|
|
if (count > 0) {
|
|
//当前账号已被创建
|
|
//当前账号已被创建
|
|
User existingUser = userMapper.selectOne(qw);
|
|
User existingUser = userMapper.selectOne(qw);
|
|
- //判断创建该账号的是admin或者是项目经理自己创建的账号,如果再次创建直接提示创建重复
|
|
|
|
- if (existingUser.getParentId() == managerParent.getId() || existingUser.getParentId() == parentUser.getId()) {
|
|
|
|
- msg.setError("该账号已存在,请勿重新创建");
|
|
|
|
|
|
+ //查询该账号是否已参与创建项目经理的admin公司下的项目
|
|
|
|
+ //得到admin公司下的所有项目
|
|
|
|
+ List<Project> projects = projectMapper.selectList(new QueryWrapper<Project>().eq("owner_company", managerParent.getCompanyId()));
|
|
|
|
+ List<Integer> ids = new ArrayList<>();
|
|
|
|
+ ids.add(-1);
|
|
|
|
+ for (Project project : projects) {
|
|
|
|
+ ids.add(project.getId());
|
|
|
|
+ }
|
|
|
|
+ List<ProjectUser> projectUsers = projectUserMapper.selectList(new QueryWrapper<ProjectUser>().in("project_id", ids).eq("user_id", existingUser.getId()));
|
|
|
|
+ if (projectUsers.size() > 0) {
|
|
|
|
+ msg.setError("该账号已参与本资产方公司下的其他项目,请前往本项目详情添加即可");
|
|
|
|
+ return msg;
|
|
|
|
+ }
|
|
|
|
+ List<ProjectApprove> projectApproves = projectApproveMapper.selectList(new QueryWrapper<ProjectApprove>().eq("approver_id", existingUser.getId()).in("project_id", ids));
|
|
|
|
+ if (projectApproves.size() > 0) {
|
|
|
|
+ msg.setError("该账号已参与本资产方公司下的其他项目,请前往本项目详情添加即可");
|
|
return msg;
|
|
return msg;
|
|
- } else {
|
|
|
|
- //此时用户已经有了,则建立一条合作公司的关系
|
|
|
|
- UserCompany userCompany = new UserCompany();
|
|
|
|
- userCompany.setUserId(existingUser.getId());
|
|
|
|
- userCompany.setBelongCompanyId(existingUser.getCompanyId());
|
|
|
|
- userCompany.setCooperationCompanyId(managerParent.getCompanyId());
|
|
|
|
- QueryWrapper<UserCompany> qWra = new QueryWrapper<>(userCompany);
|
|
|
|
- int userCompanyCount = userCompanyMapper.selectCount(qWra);
|
|
|
|
- if (userCompanyCount == 0) {
|
|
|
|
- userCompanyMapper.insert(userCompany);
|
|
|
|
- }
|
|
|
|
|
|
+ }
|
|
|
|
+ //此时用户已经有了,创建人不是该忍之前参与过的项目的公司下的项目经理创建,则建立一条合作公司的关系
|
|
|
|
+ UserCompany userCompany = new UserCompany();
|
|
|
|
+ userCompany.setUserId(existingUser.getId());
|
|
|
|
+ userCompany.setBelongCompanyId(existingUser.getCompanyId());
|
|
|
|
+ userCompany.setCooperationCompanyId(managerParent.getCompanyId());
|
|
|
|
+ QueryWrapper<UserCompany> qWra = new QueryWrapper<>(userCompany);
|
|
|
|
+ int userCompanyCount = userCompanyMapper.selectCount(qWra);
|
|
|
|
+ if (userCompanyCount == 0) {
|
|
|
|
+ userCompanyMapper.insert(userCompany);
|
|
|
|
+ }
|
|
|
|
+ //添加一条项目参与人记录
|
|
|
|
+ if (projectId != null) {
|
|
|
|
+ ProjectUser projectUser = new ProjectUser();
|
|
|
|
+ projectUser.setProjectId(projectId);
|
|
|
|
+ projectUser.setSubordinate(existingUser.getCompanyId());
|
|
|
|
+ projectUser.setUserId(existingUser.getId());
|
|
|
|
+ projectUser.setSubordinateType(existingUser.getSubordinateType());
|
|
|
|
+ projectUserMapper.insert(projectUser);
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
//创建账号默认密码"000000"
|
|
//创建账号默认密码"000000"
|
|
@@ -323,6 +357,15 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
|
|
if (userCompanyCount == 0) {
|
|
if (userCompanyCount == 0) {
|
|
userCompanyMapper.insert(userCompany);
|
|
userCompanyMapper.insert(userCompany);
|
|
}
|
|
}
|
|
|
|
+ //添加一条项目参与人记录
|
|
|
|
+ if (projectId != null) {
|
|
|
|
+ ProjectUser projectUser = new ProjectUser();
|
|
|
|
+ projectUser.setProjectId(projectId);
|
|
|
|
+ projectUser.setSubordinate(user.getCompanyId());
|
|
|
|
+ projectUser.setUserId(user.getId());
|
|
|
|
+ projectUser.setSubordinateType(user.getSubordinateType());
|
|
|
|
+ projectUserMapper.insert(projectUser);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
} else if (flag == 1) {
|
|
} else if (flag == 1) {
|
|
//更新角色信息
|
|
//更新角色信息
|
|
@@ -337,7 +380,6 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
|
|
userMapper.updateById(user);
|
|
userMapper.updateById(user);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
return msg;
|
|
return msg;
|
|
}
|
|
}
|
|
|
|
|