From a0af42a6acfc7a0ebbb92bffc1816525e508af70 Mon Sep 17 00:00:00 2001 From: Pu Zhibing <393733352@qq.com> Date: 星期五, 17 十月 2025 16:54:06 +0800 Subject: [PATCH] 修改bug --- management/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/system/UserMgrController.java | 129 ++++++++++++++++++++++++++++++++++++------- 1 files changed, 108 insertions(+), 21 deletions(-) diff --git a/management/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/system/UserMgrController.java b/management/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/system/UserMgrController.java index fbf60a1..b73ed21 100644 --- a/management/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/system/UserMgrController.java +++ b/management/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/system/UserMgrController.java @@ -5,7 +5,9 @@ import com.heredata.hos.model.bucket.Bucket; import com.stylefeng.guns.config.properties.GunsProperties; import com.stylefeng.guns.core.base.controller.BaseController; +import com.stylefeng.guns.core.base.tips.ErrorTip; import com.stylefeng.guns.core.base.tips.Tip; +import com.stylefeng.guns.core.beetl.ShiroExtUtil; import com.stylefeng.guns.core.common.annotion.BussinessLog; import com.stylefeng.guns.core.common.annotion.Permission; import com.stylefeng.guns.core.common.constant.Const; @@ -20,23 +22,24 @@ import com.stylefeng.guns.core.log.LogObjectHolder; import com.stylefeng.guns.core.shiro.ShiroKit; import com.stylefeng.guns.core.shiro.ShiroUser; -import com.stylefeng.guns.core.util.ObsUploadUtil; import com.stylefeng.guns.core.util.SinataUtil; import com.stylefeng.guns.core.util.ToolUtil; -import com.stylefeng.guns.modular.system.controller.util.UUIDUtil; import com.stylefeng.guns.modular.system.dao.UserMapper; import com.stylefeng.guns.modular.system.factory.UserFactory; import com.stylefeng.guns.modular.system.model.TAgent; import com.stylefeng.guns.modular.system.model.TBranchOffice; -import com.stylefeng.guns.modular.system.model.TCompany; import com.stylefeng.guns.modular.system.model.User; import com.stylefeng.guns.modular.system.service.*; import com.stylefeng.guns.modular.system.transfer.UserDto; -import com.stylefeng.guns.modular.system.util.OssUploadUtil; -import com.stylefeng.guns.modular.system.util.huawei.OBSUtil; +import com.stylefeng.guns.modular.system.util.ResultUtil; +import com.stylefeng.guns.modular.system.util.qianyuntong.EmployeeUtil; import com.stylefeng.guns.modular.system.util.qianyuntong.NCOSSUtil; import com.stylefeng.guns.modular.system.util.qianyuntong.QianYunTongConfig; -import org.apache.poi.ss.formula.functions.T; +import com.stylefeng.guns.modular.system.util.qianyuntong.UserUtil; +import com.stylefeng.guns.modular.system.util.qianyuntong.model.DeleteStafNodeRequest; +import com.stylefeng.guns.modular.system.util.qianyuntong.model.QYTUserInfo; +import com.stylefeng.guns.modular.system.util.qianyuntong.model.SaveStaffNode; +import com.stylefeng.guns.modular.system.util.qianyuntong.model.SaveStaffNodeRequest; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; @@ -49,7 +52,6 @@ import javax.servlet.http.HttpServletRequest; import javax.validation.Valid; import java.io.File; -import java.io.InputStream; import java.util.*; import java.util.stream.Collectors; @@ -81,6 +83,9 @@ @Autowired private QianYunTongConfig qianYunTongConfig; + @Autowired + private ShiroExtUtil shiroExtUtil; + /** * 跳转到查看管理员列表的页面 @@ -102,7 +107,6 @@ * 跳转到角色分配页面 */ //@RequiresPermissions("/mgr/role_assign") //利用shiro自带的权限检查 - @Permission @RequestMapping("/role_assign/{userId}") public String roleAssign(@PathVariable Integer userId, Model model) { if (ToolUtil.isEmpty(userId)) { @@ -117,7 +121,6 @@ /** * 跳转到编辑管理员页面 */ - @Permission @RequestMapping("/user_edit/{userId}") public String userEdit(@PathVariable Integer userId, Model model) { if (ToolUtil.isEmpty(userId)) { @@ -137,7 +140,7 @@ */ @RequestMapping("/user_info") public String userInfo(Model model) { - Integer userId = ShiroKit.getUser().getId(); + Integer userId = shiroExtUtil.getUser().getId(); if (ToolUtil.isEmpty(userId)) { throw new GunsException(BizExceptionEnum.REQUEST_NULL); } @@ -166,7 +169,7 @@ if (!newPwd.equals(rePwd)) { throw new GunsException(BizExceptionEnum.TWO_PWD_NOT_MATCH); } - Integer userId = ShiroKit.getUser().getId(); + Integer userId = shiroExtUtil.getUser().getId(); User user = userService.selectById(userId); String oldMd5 = ShiroKit.md5(oldPwd, user.getSalt()); if (user.getPassword().equals(oldMd5)) { @@ -184,7 +187,6 @@ * 查询管理员列表 */ @RequestMapping("/list") - @Permission @ResponseBody public Object list(@RequestParam(required = false) String name, @RequestParam(required = false) String createTime, @RequestParam(required = false) Integer deptid) { //创建日期 @@ -200,8 +202,8 @@ page.setRecords(userService.getUserListPage(page,null, name, beginTime, endTime, deptid)); return super.packForBT(page); } else { - Integer objectId = Objects.requireNonNull(ShiroKit.getUser()).getObjectId(); - Integer roleType = Objects.requireNonNull(ShiroKit.getUser()).getRoleType(); + Integer objectId = Objects.requireNonNull(shiroExtUtil.getUser()).getObjectId(); + Integer roleType = Objects.requireNonNull(shiroExtUtil.getUser()).getRoleType(); if(roleType == 3){ // 查询下级分公司账号 @@ -243,12 +245,44 @@ if (result.hasErrors()) { throw new GunsException(BizExceptionEnum.REQUEST_NULL); } - // 判断账号是否重复 User theUser = userService.getByAccount(user.getAccount()); if (theUser != null) { throw new GunsException(BizExceptionEnum.USER_ALREADY_REG); } + + ShiroUser user1 = shiroExtUtil.getUser(); + User user2 = userService.selectById(user1.getId()); + TBranchOffice tBranchOffice = branchOfficeService.selectById(user2.getObjectId()); + List<QYTUserInfo> userInfoByPhone = UserUtil.getUserInfoByPhone(user.getPhone(), tBranchOffice.getEnterCode()); + Long empId = null; + Integer empnew = null; + if(null == userInfoByPhone || userInfoByPhone.size() == 0){ + SaveStaffNodeRequest request1 = new SaveStaffNodeRequest(); + request1.setMobile(user2.getPhone()); + request1.setEntercode(tBranchOffice.getEnterCode()); + request1.setEmpName(user.getName()); + request1.setEmpNickname(user.getName()); + request1.setLoginNo(user.getAccount()); + request1.setEmpSex(user.getSex() == 1 ? "男" : "女"); + request1.setMphone(user.getPhone()); + request1.setEmail(user.getPhone() + "@qyt.com"); + request1.setDeptId(0); + request1.setPositionId(1); + request1.setSuperLevel(0); + request1.setHideMobile(0); + ResultUtil<SaveStaffNode> resultUtil = EmployeeUtil.saveStaffNode(request1); + if(200 != resultUtil.getStatus()){ + return new ErrorTip(resultUtil.getStatus(), resultUtil.getMsg()); + } + SaveStaffNode saveStaffNode = resultUtil.getData(); + empId = saveStaffNode.getEmpId(); + empnew = 1; + }else{ + empId = userInfoByPhone.get(0).getEmpId(); + empnew = 0; + } + // 完善账号信息 user.setSalt(ShiroKit.getRandomSalt(5)); @@ -257,10 +291,13 @@ user.setCreatetime(new Date()); User objectUser = UserFactory.createUser(user); - ShiroUser user1 = ShiroKit.getUser(); objectUser.setRoleType(user1.getRoleType()); objectUser.setObjectId(user1.getObjectId()); objectUser.setPassWordUpdate(new Date()); + objectUser.setEnterId(empId); + objectUser.setEmpnew(empnew); + objectUser.setEntercode(tBranchOffice.getEnterCode()); + objectUser.setEnterId(Long.valueOf(tBranchOffice.getEnterCode())); this.userService.insert(objectUser); return SUCCESS_TIP; @@ -279,15 +316,49 @@ throw new GunsException(BizExceptionEnum.REQUEST_NULL); } - User oldUser = userService.selectById(user.getId()); - + ShiroUser user1 = shiroExtUtil.getUser(); + User user2 = userService.selectById(user1.getId()); + TBranchOffice tBranchOffice = branchOfficeService.selectById(user2.getObjectId()); + //调用中台接口 + Long empId = null; + Integer empnew = null; + List<QYTUserInfo> userInfoByPhone = UserUtil.getUserInfoByPhone(oldUser.getPhone(), tBranchOffice.getEnterCode()); + if(null == userInfoByPhone || userInfoByPhone.size() == 0){ + SaveStaffNodeRequest request1 = new SaveStaffNodeRequest(); + request1.setMobile(user2.getPhone()); + request1.setEntercode(tBranchOffice.getEnterCode()); + request1.setEmpName(user.getName()); + request1.setEmpNickname(user.getName()); + request1.setLoginNo(user.getAccount()); + request1.setEmpSex(user.getSex() == 1 ? "男" : "女"); + request1.setMphone(user.getPhone()); + request1.setEmail(user.getPhone() + "@qyt.com"); + request1.setDeptId(0); + request1.setPositionId(1); + request1.setSuperLevel(0); + request1.setHideMobile(0); + ResultUtil<SaveStaffNode> resultUtil = EmployeeUtil.saveStaffNode(request1); + if(200 != resultUtil.getStatus()){ + return new ErrorTip(resultUtil.getStatus(), resultUtil.getMsg()); + } + SaveStaffNode saveStaffNode = resultUtil.getData(); + empId = saveStaffNode.getEmpId(); + empnew = 1; + }else{ + empId = userInfoByPhone.get(0).getEmpId(); + empnew = 0; + } + oldUser.setEmpId(empId); + oldUser.setEntercode(tBranchOffice.getEnterCode()); + oldUser.setEnterId(Long.valueOf(tBranchOffice.getEnterCode())); + oldUser.setEmpnew(empnew); if (ShiroKit.hasRole(Const.ADMIN_NAME)) { this.userService.updateById(UserFactory.editUser(user, oldUser)); return SUCCESS_TIP; } else { assertAuth(user.getId()); - ShiroUser shiroUser = ShiroKit.getUser(); + ShiroUser shiroUser = shiroExtUtil.getUser(); if (shiroUser.getId().equals(user.getId())) { this.userService.updateById(UserFactory.editUser(user, oldUser)); return SUCCESS_TIP; @@ -302,7 +373,6 @@ */ @RequestMapping("/delete") @BussinessLog(value = "删除管理员", key = "userId", dict = UserDict.class) - @Permission @ResponseBody public Tip delete(@RequestParam Integer userId) { if (ToolUtil.isEmpty(userId)) { @@ -312,7 +382,24 @@ if (userId.equals(Const.ADMIN_ID)) { throw new GunsException(BizExceptionEnum.CANT_DELETE_ADMIN); } - + User user = userService.selectById(userId); + ShiroUser user1 = shiroExtUtil.getUser(); + User user2 = userService.selectById(user1.getId()); + TBranchOffice tBranchOffice = branchOfficeService.selectById(user2.getObjectId()); + //调用中台接口 + if(1 == user.getEmpnew()){ + List<QYTUserInfo> userInfoByPhone = UserUtil.getUserInfoByPhone(user.getPhone(), tBranchOffice.getEnterCode()); + if (null != userInfoByPhone && 0 < userInfoByPhone.size() && 1 == user.getEmpnew()) { + DeleteStafNodeRequest request1 = new DeleteStafNodeRequest(); + request1.setEmpId(user.getEnterId()); + request1.setMobile(tBranchOffice.getPrincipalPhone()); + request1.setEntercode(tBranchOffice.getEnterCode()); + ResultUtil resultUtil = EmployeeUtil.ecrmDeleteStafNode(request1); + if(200 != resultUtil.getStatus()){ + return new ErrorTip(resultUtil.getStatus(), resultUtil.getMsg()); + } + } + } assertAuth(userId); this.userService.setStatus(userId, ManagerStatus.DELETED.getCode()); -- Gitblit v1.7.1