Browse Source

用户创建的修改

5 năm trước cách đây
mục cha
commit
7b500c0c4a

+ 1 - 1
cloud-model/src/main/java/com/hssx/cloudmodel/controller/MouldOperationDynamicsController.java

@@ -26,7 +26,7 @@ public class MouldOperationDynamicsController {
     /**
      *
      * 项目操作记录列表
-     * projectId 项目id ,belongType 所述文件类型,0-模具文档 1-零件文档 2-试模验收 3-保养方案 4-模具更新 5-模具报废
+     * belongType 所述文件类型,0-模具文档 1-零件文档 2-试模验收 3-保养方案 4-模具更新 5-模具报废,mouldId 模具id
      * @return
      */
     @ApiOperation("项目操作记录列表")

+ 0 - 1
cloud-model/src/main/java/com/hssx/cloudmodel/service/impl/CompanyServiceImpl.java

@@ -126,7 +126,6 @@ public class CompanyServiceImpl extends ServiceImpl<CompanyMapper, Company> impl
             qw.eq("company_type", Constant.ASSETS_COMPANY);
         } else {
             //此时是项目经理创建其他用户
-//            projectMapper.selectList(new QueryWrapper<Project>().eq(""))
             User admin = userMapper.selectOne(new QueryWrapper<User>().eq("id", user.getParentId()));
             qw.eq("company_type", Constant.PRODUCER_COMPANY).or().eq("id", admin.getCompanyId());
         }

+ 64 - 52
cloud-model/src/main/java/com/hssx/cloudmodel/service/impl/UserServiceImpl.java

@@ -56,9 +56,9 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
             //验证密码是否正确
             if (MD5Util.getPassword(userVO.getPassword()).equals(newUser.getPassword())) {
                 newUser.setPassword("");
-                BeanUtils.copyProperties(newUser,userVO);
+                BeanUtils.copyProperties(newUser, userVO);
                 //判断该用户是否为某个项目的项目经理
-                if(projectMapper.selectCount(new QueryWrapper<Project>().eq("manager_id",newUser.getId()))>0){
+                if (projectMapper.selectCount(new QueryWrapper<Project>().eq("manager_id", newUser.getId())) > 0) {
                     userVO.setIsManager(1);
                 }
                 msg.data = userVO;
@@ -94,14 +94,14 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
         }
         //是项目经理不能删除
         Integer countProject = projectMapper.selectCount(new QueryWrapper<Project>().eq("manager_id", user.getId()));
-        if(countProject>0){
+        if (countProject > 0) {
             msg.setError("该用户已被应用到项目,暂不提供删除操作");
             return msg;
         }
         //删除用户
         userMapper.deleteById(user.getId());
         //删除合作的公司
-        userCompanyMapper.delete(new QueryWrapper<UserCompany>().eq("user_id",user.getId()));
+        userCompanyMapper.delete(new QueryWrapper<UserCompany>().eq("user_id", user.getId()));
         return msg;
     }
 
@@ -110,43 +110,43 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
         //获取该账号的创建者
         User parentUser = userMapper.selectById(user.getParentId());
         HttpRespMsg msg = new HttpRespMsg();
-        if(Constant.SYS_PARENT_ID == parentUser.getParentId()) {
+        if (Constant.SYS_PARENT_ID == parentUser.getParentId()) {
             //此时是创建admind,当前创建人是超级管理员
             int count = userMapper.selectCount(new QueryWrapper<User>().eq("company_id", user.getCompanyId()).eq("parent_id", parentUser.getId()));
             if (flag == 0) {
-                if(count>0){
+                if (count > 0) {
                     //所选公司下的admin已存在
                     msg.setError("该公司下的管理员已存在");
                     return msg;
                 }
-                    //添加用户
-                    QueryWrapper<User> qw = new QueryWrapper<>();
-                    qw.eq("account", user.getAccount());
-                    count = userMapper.selectCount(qw);
-                    if (count > 0) {
-                        User existingUser = userMapper.selectOne(qw);
-                        msg.setError("当前账号已存在");
-                        return msg;
-                    } else {
-                        //创建账号默认密码"000000"
-                        user.setPassword(MD5Util.getPassword(Constant.DEFAULT_PWD));
-                        user.setHeadImgurl(UUID.randomUUID().toString().replaceAll("-", ""));
-                        //获取角色所属的团体
-                        Company company = companyMapper.selectById(user.getCompanyId());
-                        if (Constant.ASSETS_COMPANY == company.getCompanyType()) {
-                            user.setSubordinateType(Constant.ASSETS_COMPANY);
-                            user.setTeamName("资产方");
-                        } else if (Constant.PRODUCER_COMPANY == company.getCompanyType()) {
-                            user.setSubordinateType(Constant.PRODUCER_COMPANY);
-                            user.setTeamName("生产方");
-                        }
-                        userMapper.insert(user);
+                //添加用户
+                QueryWrapper<User> qw = new QueryWrapper<>();
+                qw.eq("account", user.getAccount());
+                count = userMapper.selectCount(qw);
+                if (count > 0) {
+                    User existingUser = userMapper.selectOne(qw);
+                    msg.setError("当前账号已存在");
+                    return msg;
+                } else {
+                    //创建账号默认密码"000000"
+                    user.setPassword(MD5Util.getPassword(Constant.DEFAULT_PWD));
+                    user.setHeadImgurl(UUID.randomUUID().toString().replaceAll("-", ""));
+                    //获取角色所属的团体
+                    Company company = companyMapper.selectById(user.getCompanyId());
+                    if (Constant.ASSETS_COMPANY == company.getCompanyType()) {
+                        user.setSubordinateType(Constant.ASSETS_COMPANY);
+                        user.setTeamName("资产方");
+                    } else if (Constant.PRODUCER_COMPANY == company.getCompanyType()) {
+                        user.setSubordinateType(Constant.PRODUCER_COMPANY);
+                        user.setTeamName("生产方");
                     }
-                } else if (flag == 1) {
-                    //更新角色信息
-                    userMapper.updateById(user);
+                    userMapper.insert(user);
                 }
-        }else if(Constant.SYS_ID == parentUser.getParentId()){
+            } else if (flag == 1) {
+                //更新角色信息
+                userMapper.updateById(user);
+            }
+        } else if (Constant.SYS_ID == parentUser.getParentId()) {
             //admin创建用户
             if (flag == 0) {
                 //添加用户
@@ -155,15 +155,20 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
                 int count = userMapper.selectCount(qw);
                 if (count > 0) {
                     User existingUser = userMapper.selectOne(qw);
-                    //此时用户已经有了,则建立一条合作公司的关系
-                    UserCompany userCompany = new UserCompany();
-                    userCompany.setUserId(existingUser.getId());
-                    userCompany.setBelongCompanyId(existingUser.getCompanyId());
-                    userCompany.setCooperationCompanyId(parentUser.getCompanyId());
-                    QueryWrapper<UserCompany> qWra = new QueryWrapper<>(userCompany);
-                    int userCompanyCount = userCompanyMapper.selectCount(qWra);
-                    if (userCompanyCount == 0) {
-                        userCompanyMapper.insert(userCompany);
+                    if (existingUser.getParentId() == parentUser.getId()) {
+                        msg.setError("该账号已存在,请勿重新创建");
+                        return msg;
+                    }else{
+                        //此时用户已经有了,则建立一条合作公司的关系
+                        UserCompany userCompany = new UserCompany();
+                        userCompany.setUserId(existingUser.getId());
+                        userCompany.setBelongCompanyId(existingUser.getCompanyId());
+                        userCompany.setCooperationCompanyId(parentUser.getCompanyId());
+                        QueryWrapper<UserCompany> qWra = new QueryWrapper<>(userCompany);
+                        int userCompanyCount = userCompanyMapper.selectCount(qWra);
+                        if (userCompanyCount == 0) {
+                            userCompanyMapper.insert(userCompany);
+                        }
                     }
                 } else {
                     //创建账号默认密码"000000"
@@ -193,26 +198,33 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
                 //更新角色信息
                 userMapper.updateById(user);
             }
-        }else {
+        } else {
             //此时是项目经理创建人员
             //查询创建该项目经理的人
-            User managerParent = userMapper.selectOne(new QueryWrapper<User>().eq("id",parentUser.getParentId()));
+            User managerParent = userMapper.selectOne(new QueryWrapper<User>().eq("id", parentUser.getParentId()));
             if (flag == 0) {
                 //添加用户
                 QueryWrapper<User> qw = new QueryWrapper<>();
                 qw.eq("account", user.getAccount());
                 int count = userMapper.selectCount(qw);
                 if (count > 0) {
+                    //当前账号已被创建
                     User existingUser = userMapper.selectOne(qw);
-                    //此时用户已经有了,则建立一条合作公司的关系
-                    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);
+                    //判断创建该账号的是admin或者是项目经理自己创建的账号,如果再次创建直接提示创建重复
+                    if(existingUser.getParentId() == managerParent.getId() || existingUser.getParentId() == parentUser.getId()){
+                        msg.setError("该账号已存在,请勿重新创建");
+                        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);
+                        }
                     }
                 } else {
                     //创建账号默认密码"000000"