diff --git a/src/main/java/com/keyware/htey/controller/Department/DepartmentController.java b/src/main/java/com/keyware/htey/controller/Department/DepartmentController.java index a2c101a..3e310d8 100644 --- a/src/main/java/com/keyware/htey/controller/Department/DepartmentController.java +++ b/src/main/java/com/keyware/htey/controller/Department/DepartmentController.java @@ -2,12 +2,9 @@ package com.keyware.htey.controller.Department; import java.util.List; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.keyware.htey.entity.department.Department; -import com.keyware.htey.entity.user.AuditLog; -import com.keyware.htey.service.itf.AuditLogService; import com.keyware.htey.service.itf.DepartmentService; -import com.keyware.htey.utli.Constant; +import com.keyware.htey.utli.AjaxMessage; import com.keyware.htey.utli.JsonUtils; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.responses.ApiResponse; @@ -16,6 +13,7 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.ModelAttribute; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; @@ -36,8 +34,6 @@ import org.springframework.web.bind.annotation.ResponseBody; public class DepartmentController { @Autowired private DepartmentService departmentService; - @Autowired - private AuditLogService auditLogService; @GetMapping("/selectById") @ResponseBody @@ -58,11 +54,6 @@ public class DepartmentController { @Operation(summary = "新增部门表", description = "返回新增部门信息") @ApiResponse(responseCode = "200", description = "成功新增部门信息") public boolean addDepartment(@RequestBody Department department) { - Department oneDepartment = departmentService.getOne( - new QueryWrapper().eq("id", department.getId())); - if (oneDepartment != null) { - return false; - } return departmentService.save(department); } @@ -71,8 +62,7 @@ public class DepartmentController { * @date 2025/1/7 * @description 修改部门 */ - @RequestMapping(value = {"/updateDepartment"}, - method = {RequestMethod.POST}, + @RequestMapping(value = {"/updateDepartment"}, method = {RequestMethod.POST}, produces = {"application/json; charset=utf-8"}) @ResponseBody @Operation(summary = "修改部门", description = "返回修改部门信息") @@ -107,65 +97,55 @@ public class DepartmentController { @ResponseBody @Operation(summary = "查询部门父节点信息", description = "返回部门父节点信息") @ApiResponse(responseCode = "200", description = "成功部门父节点信息") - public String getParentId(@RequestParam String id, @RequestParam String projectResource) { + public String getParentId(@RequestParam String id, @RequestParam(required = false) String projectResource) { String isSys = ""; //if ("sysadmin".equals(this.getUser_idFormSession("userId"))) { // isSys = "sysadmin"; //} - List department = this.departmentService.getParentId(id, isSys, projectResource); + List department = this.departmentService.getParentId(id, isSys, projectResource); return JsonUtils.arrayListToJsonString(department); } - @RequestMapping( - value = {"/select"}, - method = {RequestMethod.POST}, - produces = {"application/json; charset=utf-8"} - ) + @RequestMapping(value = {"/select"}, method = {RequestMethod.POST}, produces = {"application/json; charset=utf-8"}) @ResponseBody @Operation(summary = "查询部门列表信息", description = "返回查询部门列表") @ApiResponse(responseCode = "200", description = "成功返回查询部门列表") public List select(@RequestBody Department department, @RequestParam(defaultValue = "0") int pageNum, @RequestParam(defaultValue = "10") int pageSize) { - AuditLog auditLog = new AuditLog(); - department.setPageSize(pageSize); - department.setPageNum(pageNum); - if ("请输入部门名称...".equals(department.getDeptName())) { - department.setDeptName(null); - } + return departmentService.selectList(department, pageNum, pageSize); + } - //if ("sysadmin".equals(this.getUser_idFormSession("userId"))) { - // department.setIsSys("sysadmin"); - //} + @RequestMapping(value = {"/checkDepartMentName"}, method = {RequestMethod.POST}, + produces = {"application/json; charset=utf-8"}) + @ResponseBody + @Operation(summary = "部门校验", description = "返回部门校验是否成功") + @ApiResponse(responseCode = "200", description = "部门校验成功") + public AjaxMessage checkDepartMentName(String name) { + return departmentService.checkDepartMentName(name); + } - department.setProjectSource(Constant.projectName); - List departmentList = this.departmentService.selectByDeparmentInfo(department); - //List parentNameList = new ArrayList(); + @RequestMapping(value = {"/add"}, method = {RequestMethod.POST}, produces = {"application/json; charset=utf-8"}) + @ResponseBody + @Operation(summary = "部门添加", description = "返回部门添加是否成功") + @ApiResponse(responseCode = "200", description = "部门添加成功") + public AjaxMessage add(@ModelAttribute Department department) { + return departmentService.add(department); + } - //Department vo; - //for (Iterator var5 = departmentList.iterator(); var5.hasNext(); parentNameList.add(vo)) { - // vo = (Department)var5.next(); - // Integer selectUserCountByDeptId = this.userService.selectUserCountByDeptId(vo.getId()); - // if (selectUserCountByDeptId != null) { - // vo.setUserCount(selectUserCountByDeptId); - // } - // - // Department selectByPrimaryKey = this.departmentService.selectByPrimaryKey(vo.getParentId()); - // if (selectByPrimaryKey != null) { - // vo.setParentName(selectByPrimaryKey.getDeptName()); - // } - //} - String logName = "查询部门列表"; - String logNameType = "部门管理"; - //String comments = this.getUser_idFormSession("userName") + "查询部门列表,查询关键字为:" + department.getDeptName() == - // null ? "" : department.getDeptName(); - //todo 获取登录人信息 - String comments = "查询部门列表,查询关键字为:" + department.getDeptName() == null ? "" - : department.getDeptName(); - auditLog.setLogName(logName); - auditLog.setLogNameType(logNameType); - auditLog.setComments(comments); - auditLogService.addAuditLog(auditLog); - return departmentList; + @RequestMapping(value = "/edit", method = RequestMethod.POST, produces = "application/json; charset=utf-8") + @ResponseBody + @Operation(summary = "部门修改", description = "返回部门修改是否成功") + @ApiResponse(responseCode = "200", description = "部门添加修改") + public AjaxMessage edit(@ModelAttribute Department department) { + return departmentService.edit(department); + } + + @RequestMapping(value = "/delete", method = RequestMethod.POST, produces = "application/json; charset=utf-8") + @ResponseBody + @Operation(summary = "部门删除", description = "返回部门删除是否成功") + @ApiResponse(responseCode = "200", description = "部门删除修改") + public String delete(@RequestBody List departments) { + return departmentService.delete(departments); } } diff --git a/src/main/java/com/keyware/htey/controller/humanResourceManagement/HumanResourceManagementController.java b/src/main/java/com/keyware/htey/controller/humanResourceManagement/HumanResourceManagementController.java index 6cebcd7..d8e9e04 100644 --- a/src/main/java/com/keyware/htey/controller/humanResourceManagement/HumanResourceManagementController.java +++ b/src/main/java/com/keyware/htey/controller/humanResourceManagement/HumanResourceManagementController.java @@ -1,16 +1,11 @@ package com.keyware.htey.controller.humanResourceManagement; -import com.keyware.htey.entity.user.AuditLog; -import com.keyware.htey.service.itf.AuditLogService; +import com.keyware.htey.service.itf.UserService; import com.keyware.htey.utli.AjaxMessage; -import com.keyware.htey.utli.ExcelUtils; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.tags.Tag; import lombok.extern.slf4j.Slf4j; -import org.apache.poi.ss.usermodel.Sheet; -import org.apache.poi.ss.usermodel.Workbook; -import org.apache.poi.ss.usermodel.WorkbookFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; @@ -25,7 +20,7 @@ import org.springframework.web.multipart.MultipartFile; @Slf4j public class HumanResourceManagementController { @Autowired - private AuditLogService auditLogService; + private UserService userService; @RequestMapping(value = {"/analysisExcl"}, method = {RequestMethod.POST}, produces = {"application/json; charset=utf-8"}) @@ -33,31 +28,6 @@ public class HumanResourceManagementController { @Operation(summary = "用户列表导入", description = "返回导入信息") @ApiResponse(responseCode = "200", description = "成功导入信息") public AjaxMessage analysisExcl(@RequestParam MultipartFile multipartfile) { - AjaxMessage ajaxMessage = new AjaxMessage(); - try { - Workbook workbook = WorkbookFactory.create(multipartfile.getInputStream()); - Sheet sheet = workbook.getSheetAt(0); - ExcelUtils.checkFirstRowName(ajaxMessage, sheet); - if ("0".equals(ajaxMessage.getCode())) { - return ajaxMessage; - } - AuditLog auditLog = new AuditLog(); - String message = new ExcelUtils().insertUser(auditLog, sheet); - ajaxMessage.setCode("1"); - ajaxMessage.setMessage(message); - // String comments = this.getUser_idFormSession("userName") + message; - String comments = message; - String logName = "批量导入"; - String logNameType = "用户列表"; - auditLog.setLogName(logName); - auditLog.setLogNameType(logNameType); - auditLog.setComments(comments); - auditLogService.addAuditLog(auditLog); - } catch (Exception var8) { - log.error("导入失败", var8); - var8.printStackTrace(); - ajaxMessage.setCode("0"); - } - return ajaxMessage; + return userService.analysisExcl(multipartfile); } } diff --git a/src/main/java/com/keyware/htey/controller/project/ProjectKtController.java b/src/main/java/com/keyware/htey/controller/project/ProjectKtController.java index 9267ea5..ea54235 100644 --- a/src/main/java/com/keyware/htey/controller/project/ProjectKtController.java +++ b/src/main/java/com/keyware/htey/controller/project/ProjectKtController.java @@ -1,29 +1,13 @@ package com.keyware.htey.controller.project; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Objects; -import java.util.stream.Collectors; - -import javax.annotation.Resource; - -import com.keyware.htey.entity.department.Department; -import com.keyware.htey.entity.organizeassets.OFourColum; import com.keyware.htey.entity.user.User; -import com.keyware.htey.service.itf.DepartmentService; -import com.keyware.htey.service.itf.OFourColumService; import com.keyware.htey.service.itf.UserService; -import com.keyware.htey.utli.Constant; -import com.keyware.htey.utli.JsonUtils; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.tags.Tag; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; -import org.springframework.util.StringUtils; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; @@ -42,14 +26,8 @@ import org.springframework.web.bind.annotation.ResponseBody; @Tag(name = "项目管理模块 API", description = "部门表数据接口") @Slf4j public class ProjectKtController { - @Autowired - private OFourColumService fourColumService; - @Resource - private DepartmentService departmentService; @Autowired private UserService userService; - @Autowired - private OFourColumService oFourColumService; @RequestMapping( value = {"/selectDepartUser"}, @@ -61,173 +39,6 @@ public class ProjectKtController { @ApiResponse(responseCode = "200", description = "部门负责人返回成功") public String selectDepartUser(@RequestBody User user, @RequestParam(required = false) String setDocumentDepartId, @RequestParam(required = false) String headId) { - List list = new ArrayList(); - String departId = user.getDepartId() == null ? "" : user.getDepartId(); - String set_document_departId = setDocumentDepartId == null ? "" : setDocumentDepartId; - String source = user.getSecret() == null ? "" : user.getSecret(); - String userName = user.getUserNameForSerch(); - if (user.getSystemLevel() != "" && user.getSystemLevel() != null) { - user.setSystemLevel(getSeq(user.getSystemLevel()).toString()); - } - log.info("查询条件=" + userName); - String projectClassIficationName = user.getUesrRankName() == null ? "" : user.getUesrRankName(); - String projectClassIfication = user.getUesrRankId() == null ? "" : user.getUesrRankId(); - String customer = Constant.customer; - if ("sysadmin".equals(Constant.userId)) { - user.setIsSys("sysadmin"); - } - user.setFlag("1"); - List users; - Iterator userIterator; - if (!"".equals(set_document_departId)) { - Department department = this.departmentService.selectByPrimaryKey(set_document_departId); - if (department != null) { - users = null; - if (customer != null && customer.equals("siyuan17suo")) { - if (userName != null && !"搜索您想寻找的...".equals(userName)) { - user.setUserNameForSerch(userName); - user.setDepartId(department.getParentId()); - user.setProjectSource(Constant.projectName); - users = this.userService.selectByUserInfo17suo(user); - } else { - users = this.userService.selectDepartUser17suo(department.getParentId()); - } - - userIterator = users.iterator(); - - while (userIterator.hasNext()) { - User u = (User)userIterator.next(); - if (("内部".equals(projectClassIficationName) || "秘密".equals(projectClassIficationName)) - && !"10".equals(u.getSecret()) && !"20".equals(u.getSecret()) && !"30".equals( - u.getSecret())) { - userIterator.remove(); - } - - if ("机密".equals(projectClassIficationName) && !"20".equals(u.getSecret()) && !"30".equals( - u.getSecret())) { - userIterator.remove(); - } - } - } - return JsonUtils.arrayListToJsonString(users); - } - } else { - HashSet selectByparentId; - String deptId; - if (customer == null || !customer.equals("siyuan17suo") && !customer.equals("guiyangshiyuan")) { - if (StringUtils.hasText(userName)) { - if (!"搜索您想寻找的...".equals(userName)) { - user.setUserNameForSerch(userName); - } - - users = this.userService.selectByUserInfo(user); - list.addAll(users); - } else if (!"".equals(source)) { - user.setDepartId(departId); - users = this.userService.selectByUserInfo(user); - list.addAll(users); - } else { - selectByparentId = this.departmentService.selectByparentId(departId); - user.setDepartId(departId); - users = this.userService.selectByUserInfo(user); - list.addAll(users); - userIterator = selectByparentId.iterator(); - - while (userIterator.hasNext()) { - deptId = (String)userIterator.next(); - user.setDepartId(deptId); - users = this.userService.selectByUserInfo(user); - list.addAll(users); - } - } - } else { - if (StringUtils.hasText(userName)) { - if (!"搜索您想寻找的...".equals(userName)) { - user.setUserNameForSerch(userName); - } - - users = this.userService.selectByUserInfo17suo(user); - list.addAll(users); - } else if (!"".equals(source)) { - user.setDepartId(departId); - // users = this.userService.selectByUserInfo17suo(user); - users = userService.selectByUser(user); - list.addAll(users); - } else { - selectByparentId = this.departmentService.selectByparentId(departId); - user.setDepartId(departId); - // users = this.userService.selectByUserInfo17suo(user); - users = userService.selectByUser(user); - list.addAll(users); - userIterator = selectByparentId.iterator(); - - while (userIterator.hasNext()) { - deptId = (String)userIterator.next(); - if (deptId != "" && deptId != null) { - user.setDepartId(deptId); - users = userService.selectByUser(user); - list.addAll(users); - } - } - } - - Iterator iterator = list.iterator(); - - while (iterator.hasNext()) { - User u = (User)iterator.next(); - if (("内部".equals(projectClassIficationName) || "秘密".equals(projectClassIficationName)) - && !"10".equals(u.getSecret()) && !"20".equals(u.getSecret()) && !"30".equals(u.getSecret())) { - iterator.remove(); - } - - if ("机密".equals(projectClassIficationName) && !"20".equals(u.getSecret()) && !"30".equals( - u.getSecret())) { - iterator.remove(); - } - } - } - } - List listnew = new ArrayList(); - Iterator var21 = list.iterator(); - - while (var21.hasNext()) { - User user1 = (User)var21.next(); - if (!listnew.contains(user1)) { - listnew.add(user1); - } - } - if (!StringUtils.isEmpty(projectClassIfication)) { - OFourColum oFourColum = oFourColumService.selectByPrimaryKey(projectClassIfication); - if (oFourColum != null) { - Iterator iterator = listnew.iterator(); - while (iterator.hasNext()) { - User next = (User)iterator.next(); - if (!StringUtils.isEmpty(next.getSecret())) { - OFourColum oFourColum1 = oFourColumService.selectByPrimaryKey(next.getSecret()); - if (oFourColum1 != null && oFourColum.getSeq() > oFourColum1.getSeq() || oFourColum1 == null) { - iterator.remove(); - } - } - } - } - } - if (!StringUtils.isEmpty(headId)) { - listnew = (List)listnew.stream().filter(o -> !((User)o).getId().equals(headId)).collect( - Collectors.toList()); - } - - return JsonUtils.toJson(listnew); - } - - public Integer getSeq(String id) { - OFourColum OFourColum = null; - if (!StringUtils.isEmpty(id)) { - OFourColum = fourColumService.selectByPrimaryKey(id); - } - if (Objects.isNull(OFourColum)) { - return null; - } - return OFourColum.getSeq(); + return userService.selectDepartUser(user, setDocumentDepartId, headId); } - } diff --git a/src/main/java/com/keyware/htey/controller/user/UserController.java b/src/main/java/com/keyware/htey/controller/user/UserController.java index 063515a..ffc8afc 100644 --- a/src/main/java/com/keyware/htey/controller/user/UserController.java +++ b/src/main/java/com/keyware/htey/controller/user/UserController.java @@ -1,44 +1,17 @@ package com.keyware.htey.controller.user; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Base64; -import java.util.Collection; -import java.util.Date; -import java.util.HashMap; -import java.util.Iterator; import java.util.List; -import java.util.Map; import javax.servlet.http.HttpServletRequest; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.keyware.htey.entity.department.Department; -import com.keyware.htey.entity.user.AuditLog; import com.keyware.htey.entity.user.User; -import com.keyware.htey.entity.usersecret.UserSecret; -import com.keyware.htey.listener.SessionCounter; -import com.keyware.htey.service.itf.AuditLogService; -import com.keyware.htey.service.itf.DepartmentService; import com.keyware.htey.service.itf.UserService; -import com.keyware.htey.service.itf.UsersecretService; -import com.keyware.htey.service.itf.number.NumberBuilderService; import com.keyware.htey.utli.AjaxMessage; -import com.keyware.htey.utli.Constant; -import com.keyware.htey.utli.DateUtils; -import com.keyware.htey.utli.EncryptUtil; -import com.keyware.htey.utli.IdComposeListUtil; -import com.keyware.htey.utli.IdGenerator; -import com.keyware.htey.utli.JsonUtils; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.tags.Tag; import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.StringUtils; -import org.apache.ibatis.annotations.Param; -import org.apache.shiro.session.Session; -import org.apache.shiro.session.mgt.eis.SessionDAO; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.GetMapping; @@ -47,9 +20,6 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; -import org.springframework.web.multipart.MultipartFile; -import org.springframework.web.multipart.MultipartHttpServletRequest; -import org.springframework.web.util.WebUtils; /** * @author yangmengchuan @@ -63,16 +33,6 @@ import org.springframework.web.util.WebUtils; public class UserController { @Autowired private UserService userService; - @Autowired - private AuditLogService auditLogService; - @Autowired - private NumberBuilderService numberBuilderService; - @Autowired - private DepartmentService departmentService; - @Autowired - private UsersecretService usersecretService; - @Autowired - private SessionDAO sessionDAO; /** * @author yangmengchuan @@ -112,27 +72,23 @@ public class UserController { return userService.getById(id); } + /** + * @param id + * @return java.lang.String + * @description 查看用户信息 + * @Author daijiajun + * @date 2025/1/17 + **/ @GetMapping("/viewInfo") @ResponseBody - @Operation(summary = "根据id查询用户", description = "返回查询用户信息") + @Operation(summary = "查看用户信息", description = "返回查询用户信息") @ApiResponse(responseCode = "200", description = "成功获取用户信息") public String viewInfo(@RequestParam String id) { - AuditLog auditLog = new AuditLog(); - User user = this.userService.getById(id); - String logName = "查看用户信息"; - String logNameType = "用户密级"; - //todo this.getUser_idFormSession("userName")登录人的用户名 - //String comments = this.getUser_idFormSession("userName") + "查看了" + user.getUserName() + "的用户信息"; - String comments = "查看了" + user.getUserName() + "的用户信息"; - auditLog.setLogName(logName); - auditLog.setLogNameType(logNameType); - auditLog.setComments(comments); - this.auditLogService.addAuditLog(auditLog); - return JsonUtils.objectToJsonString(user); + return userService.viewInfo(id); } /** - * @author yangmengchuan + * @author daijiajun * @date 2025/1/7 * @description 新增用户 */ @@ -144,97 +100,12 @@ public class UserController { @ResponseBody @Operation(summary = "新增用户", description = "返回新增用户信息") @ApiResponse(responseCode = "200", description = "成功新增用户信息") - public AjaxMessage addUser(@RequestBody User user) { - AjaxMessage ajaxMessage = new AjaxMessage(); - try { - AuditLog auditLog = new AuditLog(); - List selectByUserNumber = this.userService.selectByUserNumber(user.getUserNumber()); - if (selectByUserNumber.size() > 0) { - ajaxMessage.setCode("0"); - ajaxMessage.setMessage("员工编号已存在"); - return ajaxMessage; - } - Integer userCount = Constant.userCount; - if (0 != userCount) { - List selectAll = this.userService.selectAll((String)null); - if (userCount <= selectAll.size()) { - ajaxMessage.setCode("0"); - ajaxMessage.setMessage("当前版本只允许新建" + Constant.userCount + "个用户"); - return ajaxMessage; - } - } - user.setPasswordOld(user.getPassword()); - user.setPassword(EncryptUtil.md5(user.getPassword())); - user.setUserCreationTime(DateUtils.getDate()); - user.setUserPwdModifTime(DateUtils.getDate("yyyy-MM-dd HH:mm:ss")); - user.setUserStatus(0L); - user.setUserLock(0L); - user.setLogout(0L); - user.setId(IdGenerator.uuid32()); - String sort = DateUtils.getDateTimeInt(); - user.setSort(sort); - this.userService.insertSelective(user); - this.numberBuilderService.updateNumber("user_code"); - //todo 获取登录用户信息 - //HttpSession session = this.request.getSession(); - //String userName = (String)session.getAttribute("userName"); - //String comments = userName + "添加了用户" + user.getUserName(); - String comments = "添加了用户" + user.getUserName(); - StringBuilder info = new StringBuilder(); - info.append("员工编号:" + user.getUserNumber() + ";"); - info.append("姓名:" + user.getUserName() + ";"); - info.append("身份证号码:" + user.getUserNumber() + ";"); - info.append("电子邮件:" + user.getUserNumber() + ";"); - Department department1 = this.departmentService.selectByPrimaryKey(user.getDepartId()); - info.append("所属部门:" + department1.getDeptName() + ";"); - String sex = "女"; - if ("0".equals(user.getSex())) { - sex = "男"; - } - - info.append("性别:" + sex + ";"); - info.append("手机:" + user.getMobilePhone() + ";"); - info.append("办公电话:" + user.getOfficeTelephone() + ";"); - info.append("家庭电话:" + user.getHomePhone() + ";"); - String userRankId = "普通"; - if ("d453bf52e571451996a8f5c251f7eb8d".equals(user.getUesrRankId())) { - userRankId = "秘密"; - } - info.append("密码密级:" + userRankId + ";"); - String leves = user.getSecretName(); - info.append("人员密级:" + leves + ";"); - String logName = "添加人员"; - String logNameType = "用户列表"; - //todo 登录人的用户名 userName - auditLog.setLogName(logName); - auditLog.setLogNameType(logNameType); - auditLog.setComments(comments); - auditLogService.addAuditLog(auditLog); - //todo 添加MESSAGE_TABLE表 - //String numCode = this.getUser_idFormSession("customCode"); - //if (numCode != null && numCode.equals("tianjin712suo")) { - // User safeUser = this.userService.selectUserByUserId("safesecret"); - // this.messageService.insertMessage("添加用户" + user.getUserName() + "", "用户管理", (String)null, safeUser - // .getId(), "", "0", "K"); - //} - //if (numCode != null && (numCode.equals("siyuan17suo") || numCode.equals("guiyangshiyuan"))) { - UserSecret userSecret = new UserSecret(); - userSecret.setId(user.getId()); - userSecret.setSecret(user.getSecret()); - this.usersecretService.insertSelective(userSecret); - //} - ajaxMessage.setCode("1"); - ajaxMessage.setMessage("保存成功"); - } catch (Exception var16) { - log.error("新增用户失败", var16); - ajaxMessage.setCode("0"); - ajaxMessage.setMessage(Constant.ERROE_MESSAGE); - } - return ajaxMessage; + public AjaxMessage add(@RequestBody User user) { + return userService.add(user); } /** - * @author yangmengchuan + * @author daijiajun * @date 2025/1/7 * @description 用户注销 */ @@ -247,71 +118,13 @@ public class UserController { @Operation(summary = "用户注销还原", description = "返回用户注销信息") @ApiResponse(responseCode = "200", description = "成功用户注销信息") public String updateUser(@RequestBody List users, String logOut) { - String userNames = ""; - AuditLog auditLog = new AuditLog(); - if (1L == new Long(logOut)) { - for (User user : users) { - User oneUser = userService.selectByPrimaryKey(user.getUserId()); - oneUser.setLogout(1L); - oneUser.setLogoutTime(DateUtils.getDateTime()); - userService.updateById(oneUser); - if ("".equals(userNames)) { - userNames = oneUser.getUserName(); - } else { - userNames = userNames + "," + oneUser.getUserName(); - } - } - String logName = "注销人员"; - String logNameType = "用户列表"; - //todo 登录人的用户名 userName - //String comments = userName + "注销了用户" + userNames; - String comments = "注销了用户" + userNames; - auditLog.setLogName(logName); - auditLog.setLogNameType(logNameType); - auditLog.setComments(comments); - auditLogService.addAuditLog(auditLog); - } - if (!"1".equals(logOut)) { - Integer userCount = Constant.userCount; - if (0 != userCount) { - List selectAll = this.userService.selectAll((String)null); - if (userCount < selectAll.size() + users.size()) { - return "当前版本只允许新建" + Constant.userCount + "个用户"; - } - } - this.userService.recovery(IdComposeListUtil.listId(users)); - userNames = ""; - for (User user : users) { - User u = this.userService.selectByPrimaryKey(user.getId()); - String logName = "还原人员"; - String logNameType = "注销用户列表"; - //String comments = userName + "还原了用户" + u.getUserName(); - //todo 获取登录人信息 - String comments = "还原了用户" + u.getUserName(); - auditLog.setLogName(logName); - auditLog.setLogNameType(logNameType); - auditLog.setComments(comments); - auditLogService.addAuditLog(auditLog); - if ("".equals(userNames)) { - userNames = u.getUserName(); - } else { - userNames = userNames + "," + u.getUserName(); - } - //todo 添加MESSAGE_TABLE表 - //if (numCode != null && numCode.equals("tianjin712suo")) { - // User safeUser = this.userService.selectUserByUserId("safesecret"); - // this.messageService.insertMessage("还原用户" + userNames + "", "用户管理", (String)null, safeUser.getId - // (), "", "0", "K"); - //} - } - } - return "0"; + return userService.updateUser(users, logOut); } /** - * @author yangmengchuan + * @author daijiajun * @date 2025/1/7 - * @description 解锁 + * @description 用户解锁 */ @RequestMapping( value = {"/updateLock"}, @@ -322,33 +135,11 @@ public class UserController { @Operation(summary = "用户解锁", description = "返回用户解锁信息") @ApiResponse(responseCode = "200", description = "成功用户解锁信息") public String updateLock(@RequestBody List users) { - List listId = IdComposeListUtil.listId(users); - userService.unlock(listId); - String userNames = ""; - AuditLog auditLog = new AuditLog(); - for (User user : users) { - User oneUser = userService.selectByPrimaryKey(user.getId()); - if ("".equals(userNames)) { - userNames = oneUser.getUserName(); - } else { - userNames = userNames + "," + oneUser.getUserName(); - } - String logName = "解锁"; - String logNameType = "用户列表"; - //todo 登录人的用户名 userName - //String comments = userName + "将用户" + userNames + "解锁"; - String comments = "将用户" + userNames + "解锁"; - auditLog.setLogName(logName); - auditLog.setLogNameType(logNameType); - auditLog.setComments(comments); - auditLogService.addAuditLog(auditLog); - //todo 添加MESSAGE_TABLE表 - } - return "解锁成功"; + return userService.updateLock(users); } /** - * @author yangmengchuan + * @author daijiajun * @date 2025/1/7 * @description 启用禁用 */ @@ -361,58 +152,13 @@ public class UserController { @Operation(summary = "用户启用禁用", description = "返回用户启用禁用信息") @ApiResponse(responseCode = "200", description = "成功用户启用禁用信息") public AjaxMessage updateStatus(@RequestBody List users) { - AjaxMessage ajaxMessage = new AjaxMessage(); - String userNames = ""; - String status = ""; - AuditLog auditLog = new AuditLog(); - if (users.size() > 0) { - for (User user : users) { - User oneUser = userService.selectByPrimaryKey(user.getId()); - oneUser.setUserStatus(user.getUserStatus()); - userService.updateStatus(user); - if ("".equals(userNames)) { - userNames = oneUser.getUserName(); - } else { - userNames = userNames + "," + oneUser.getUserName(); - } - status = "open"; - if (user.getUserStatus() == 1L) { - status = "close"; - } - } - if ("open".equals(status)) { - String logName = "启用"; - String logNameType = "用户列表"; - //todo 登录人的用户名 userName - //String comments = userName + "启用了用户" + userNames; - String comments = "启用了用户" + userNames; - auditLog.setLogName(logName); - auditLog.setLogNameType(logNameType); - auditLog.setComments(comments); - auditLogService.addAuditLog(auditLog); - //todo 添加MESSAGE_TABLE表 - ajaxMessage.setMessage("启用成功"); - } else if ("close".equals(status)) { - String logName = "禁用"; - String logNameType = "用户列表"; - //todo 登录人的用户名 userName - //String comments = userName + "禁用了用户" + userNames; - String comments = "禁用了用户" + userNames; - auditLog.setLogName(logName); - auditLog.setLogNameType(logNameType); - auditLog.setComments(comments); - auditLogService.addAuditLog(auditLog); - //todo 添加MESSAGE_TABLE表 - ajaxMessage.setMessage("禁用成功"); - } - } - return ajaxMessage; + return userService.updateStatus(users); } /** - * @author yangmengchuan + * @author daijiajun * @date 2025/1/7 - * @description 根据id进行删除 + * @description 删除用户 */ @RequestMapping( value = {"/delete"}, @@ -420,46 +166,21 @@ public class UserController { produces = {"application/json; charset=utf-8"} ) @ResponseBody - @Operation(summary = "根据id删除用户", description = "返回删除用户信息") + @Operation(summary = "删除用户", description = "返回删除用户信息") @ApiResponse(responseCode = "200", description = "成功删除用户信息") public String deleteUser(@RequestBody List users) { - try { - List listId = IdComposeListUtil.listId(users); - AuditLog auditLog = new AuditLog(); - String userNames = ""; - for (User user : users) { - User safeUser = this.userService.selectByPrimaryKey(user.getId()); - if ("".equals(userNames)) { - userNames = safeUser.getUserName(); - } else { - userNames = userNames + "," + safeUser.getUserName(); - } - } - this.userService.deleteByPrimaryKey(listId); - String logName = "删除人员"; - String logNameType = "用户列表"; - //todo 登录人的用户名 userName - // String comments = userName + "删除了用户" + userNames; - String comments = "删除了用户" + userNames; - auditLog.setLogName(logName); - auditLog.setLogNameType(logNameType); - auditLog.setComments(comments); - auditLogService.addAuditLog(auditLog); - //todo 添加MESSAGE_TABLE表 - - //if (numCode != null && (numCode.equals("siyuan17suo") || numCode.equals("guiyangshiyuan"))) { - this.usersecretService.deleteByPrimaryKey(listId); - //} - for (String id : listId) { - this.userService.deleteUserRoleByUserId(id); - } - return "删除成功"; - } catch (Exception var9) { - log.error("删除用户失败", var9); - return Constant.ERROE_MESSAGE; - } + return userService.deleteUser(users); } + /** + * @param user + * @param pageNum + * @param pageSize + * @return java.util.List + * @description 用户列表 + * @Author daijiajun + * @date 2025/1/17 + **/ @RequestMapping( value = {"/select"}, method = {RequestMethod.POST}, @@ -470,11 +191,7 @@ public class UserController { @ApiResponse(responseCode = "200", description = "成功用户列表信息") public List selectByUserInfo17suo(User user, @RequestParam(defaultValue = "0") int pageNum, @RequestParam(defaultValue = "10") int pageSize) { - user.setProjectSource(Constant.projectName); - user.setUserStatus(1L); - user.setPageSize(pageSize); - user.setPageNum(pageNum); - return userService.selectByUserInfo17suo(user); + return userService.selectByUserInfo17suo(user, pageNum, pageSize); } /** @@ -488,41 +205,7 @@ public class UserController { @Operation(summary = "密码重置", description = "返回密码重置信息") @ApiResponse(responseCode = "200", description = "密码重置成功") public String PwdReset(@RequestParam String userIds) { - String[] userIdArr = userIds.split(","); - String userNames = ""; - AuditLog auditLog = new AuditLog(); - for (String userId : userIdArr) { - User user = new User(); - String passsword = IdGenerator.random10Str(); - user.setPassword(EncryptUtil.md5(passsword)); - user.setPasswordOld(passsword); - user.setUserPwdModifTime(DateUtils.getDate("yyyy-MM-dd HH:mm:ss")); - user.setInitPwdTime(DateUtils.formatDateTime(new Date())); - user.setExitTime(DateUtils.getDate("yyyy-MM-dd HH:mm:ss")); - user.setId(userId); - userService.updateByPrimaryKey(user); - User oneUser = userService.selectByPrimaryKey(userId); - if (oneUser == null) { - log.error("不存在id为[" + userId + "]"); - return Constant.ERROE_MESSAGE; - } - if ("".equals(userNames)) { - userNames = oneUser.getUserName(); - } else { - userNames = userNames + "," + oneUser.getUserName(); - } - } - String logName = "重置密码"; - String logNameType = "用户列表"; - //todo 登录人的用户名 userName - //String comments = userName + "将" + userNames + "用户的密码重置"; - String comments = "将" + userNames + "用户的密码重置"; - auditLog.setLogName(logName); - auditLog.setLogNameType(logNameType); - auditLog.setComments(comments); - auditLogService.addAuditLog(auditLog); - //todo 添加MESSAGE_TABLE表 - return "重置成功"; + return userService.PwdReset(userIds); } /** @@ -539,38 +222,17 @@ public class UserController { public Page selectLogOutUser(@RequestParam(required = false) String name, @RequestParam(defaultValue = "0") int pageNum, @RequestParam(defaultValue = "10") int pageSize) { - if ("请输入姓名...".equals(name)) { - name = null; - } - // 创建分页对象 - Page pageParam = new Page<>(pageNum, pageSize); - // 创建查询条件 - QueryWrapper queryWrapper = new QueryWrapper<>(); - if (!StringUtils.isEmpty(name)) { - queryWrapper = queryWrapper.like("USER_NAME", name).orderByDesc("LOGOUT_TIME");// 模糊查询 - } else { - queryWrapper = queryWrapper.orderByDesc("LOGOUT_TIME"); // 模糊查询 - } - AuditLog auditLog = new AuditLog(); - String logName = "查询注销用户列表"; - String logNameType = "用户管理"; - //todo 登录人的用户名 userName - //String comments = this.getUser_idFormSession("userName") + "查询注销用户列表,查询关键字为:" + name == null ? "" : name; - String comments = "查询注销用户列表,查询关键字为:" + name == null ? "" : name; - auditLog.setLogName(logName); - auditLog.setLogNameType(logNameType); - auditLog.setComments(comments); - auditLogService.addAuditLog(auditLog); - return userService.page(pageParam, queryWrapper); + return userService.selectLogOutUser(name, pageNum, pageSize); } /** - * 查询密码重置列表 + * 初始密码列表 * * @param name * @param pageNum * @param pageSize * @return + * @Author daijiajun */ @GetMapping("/userPwdResetList") @ResponseBody @@ -579,21 +241,7 @@ public class UserController { public List userPwdResetList(@RequestParam(required = false) String name, @RequestParam(defaultValue = "0") int pageNum, @RequestParam(defaultValue = "10") int pageSize) { - if ("请输入姓名...".equals(name)) { - name = null; - } - List userList = userService.pwdResetList(name, pageNum, pageSize); - AuditLog auditLog = new AuditLog(); - String logName = "查询密码重置列表"; - String logNameType = "用户管理"; - //todo 登录人的用户名 userName - //String comments = this.getUser_idFormSession("userName") + "查询密码重置列表,查询关键字为:" + name == null ? "" : name; - String comments = "查询密码重置列表,查询关键字为:" + name == null ? "" : name; - auditLog.setLogName(logName); - auditLog.setLogNameType(logNameType); - auditLog.setComments(comments); - auditLogService.addAuditLog(auditLog); - return userList; + return userService.userPwdResetList(name, pageNum, pageSize); } /** @@ -610,46 +258,18 @@ public class UserController { @ResponseBody @Operation(summary = "删除用户", description = "返回删除用户信息") @ApiResponse(responseCode = "200", description = "删除用户成功") - public String delPwdResetList(@RequestParam String userIds, HttpServletRequest request) { - try { - List listId = IdComposeListUtil.listId(userIds); - String userNames = ""; - AuditLog auditLog = new AuditLog(); - for (String userId : listId) { - User user = this.userService.selectByPrimaryKey(userId); - if (user == null) { - log.error("不存在id为[" + userId + "]"); - return Constant.ERROE_MESSAGE; - } - if ("".equals(userNames)) { - userNames = user.getUserName(); - } else { - userNames = userNames + "," + user.getUserName(); - } - } - this.userService.delPwdResetList(listId); - String logName = "删除"; - String logNameType = "初始密码"; - //todo 登录人的用户名 userName - //String comments = userName + "删除了用户" + userNames + "初始密码信息"; - String comments = "删除了用户" + userNames + "初始密码信息"; - auditLog.setLogName(logName); - auditLog.setLogNameType(logNameType); - auditLog.setComments(comments); - auditLogService.addAuditLog(auditLog); - //todo 添加MESSAGE_TABLE表 - //if (numCode != null && numCode.equals("tianjin712suo")) { - // safeUser = this.userService.selectUserByUserId("safesecret"); - // this.messageService.insertMessage("删除用户" + userNames + "的重置密码", "用户管理", (String)null, safeUser - // .getId(), "", "0", "K"); - //} - return "删除成功"; - } catch (Exception var8) { - log.error("删除失败", var8); - return Constant.ERROE_MESSAGE; - } + public String delPwdResetList(@RequestParam String userIds) { + return userService.delPwdResetList(userIds); } + /** + * @param user + * @param request + * @return com.keyware.htey.utli.AjaxMessage + * @description 修改人员 + * @Author daijiajun + * @date 2025/1/17 + **/ @RequestMapping( value = {"/edit"}, method = {RequestMethod.POST}, @@ -659,218 +279,7 @@ public class UserController { @Operation(summary = "修改人员", description = "返回修改人员信息") @ApiResponse(responseCode = "200", description = "修改人员成功") public AjaxMessage edit(@RequestBody User user, HttpServletRequest request) { - AjaxMessage ajaxMessage = new AjaxMessage(); - User oldUser = this.userService.selectByPrimaryKey(user.getId()); - byte[] fileData = null; - AuditLog auditLog = new AuditLog(); - try { - List selectByUserNumber = this.userService.selectByUserNumber(user.getUserNumber()); - if (selectByUserNumber.size() > 0) { - if (selectByUserNumber.size() != 1) { - ajaxMessage.setCode("0"); - ajaxMessage.setMessage("员工编号已存在"); - return ajaxMessage; - } - - User user2 = (User)selectByUserNumber.get(0); - if (!user2.getId().equals(user.getId())) { - ajaxMessage.setCode("0"); - ajaxMessage.setMessage("员工编号已存在"); - return ajaxMessage; - } - String contentType = request.getContentType(); - String comments; - if (contentType != null && contentType.toLowerCase().startsWith("multipart/")) { - MultipartHttpServletRequest multipartRequest - = (MultipartHttpServletRequest)WebUtils.getNativeRequest(request, - MultipartHttpServletRequest.class); - MultipartFile file = multipartRequest.getFile("multipartfile"); - comments = request.getParameter("changeFlg"); - if (comments.equals("1")) { - if (file != null) { - fileData = file.getBytes(); - } else { - String signatureUrl = request.getParameter("signatureUrl"); - Base64.Decoder decoder = Base64.getDecoder(); - signatureUrl = signatureUrl.substring(signatureUrl.indexOf(",", 1) + 1, - signatureUrl.length()); - fileData = decoder.decode(signatureUrl); - - for (int i = 0; i < fileData.length; ++i) { - if (fileData[i] < 0) { - fileData[i] = (byte)(fileData[i] + 256); - } - } - } - - user.setImgData(fileData); - } - } - this.userService.updateByPrimaryKey(user); - StringBuilder info = new StringBuilder(); - if (oldUser.getUserNumber() == null) { - oldUser.setUserNumber(""); - } - - if (!oldUser.getUserNumber().equals(user.getUserNumber())) { - info.append("员工编号从" + oldUser.getUserNumber() + "修改为" + user.getUserNumber() + ";"); - } - - if (oldUser.getUserName() == null) { - oldUser.setUserName(""); - } - - if (!oldUser.getUserName().equals(user.getUserName())) { - info.append("姓名从" + oldUser.getUserName() + "修改为" + user.getUserName() + ";"); - } - - if (oldUser.getIdCard() == null) { - oldUser.setIdCard(""); - } - - if (!oldUser.getIdCard().equals(user.getIdCard())) { - info.append("身份证号码从" + oldUser.getUserNumber() + "修改为" + user.getUserNumber() + ";"); - } - - if (oldUser.getEmail() == null) { - oldUser.setEmail(""); - } - - if (!oldUser.getEmail().equals(user.getEmail())) { - info.append("电子邮件从" + oldUser.getUserNumber() + "修改为" + user.getUserNumber() + ";"); - } - - if (oldUser.getDepartId() == null) { - oldUser.setDepartId(""); - } - if (!oldUser.getDepartId().equals(user.getDepartId())) { - Department department; - if (org.springframework.util.StringUtils.hasText(oldUser.getDepartId()) - && org.springframework.util.StringUtils.hasText(user.getDepartId())) { - department = this.departmentService.selectByPrimaryKey(oldUser.getDepartId()); - Department department1 = this.departmentService.selectByPrimaryKey(user.getDepartId()); - if (department != null && department1 != null) { - info.append( - "所属部门从" + department.getDeptName() + "修改为" + department1.getDeptName() + ";"); - } - } else if (!org.springframework.util.StringUtils.hasText(oldUser.getDepartId()) - && org.springframework.util.StringUtils.hasText(user.getDepartId())) { - department = this.departmentService.selectByPrimaryKey(user.getDepartId()); - if (department != null) { - info.append("所属部门从空修改为" + department.getDeptName() + ";"); - } - } else if ( - org.springframework.util.StringUtils.hasText(oldUser.getDepartId()) - && !org.springframework.util.StringUtils.hasText(user.getDepartId())) { - department = this.departmentService.selectByPrimaryKey(oldUser.getDepartId()); - if (department != null) { - info.append("所属部门从" + department.getDeptName() + "修改为空;"); - } - } - } - - if (oldUser.getSex() == null) { - oldUser.setSex(0L); - } - - String oldUserRankId; - String userRankId; - if (!oldUser.getSex().equals(user.getSex())) { - oldUserRankId = "女"; - userRankId = "女"; - if (Constant.UESR_SEX_MAN.equals(oldUser.getSex())) { - oldUserRankId = "男"; - } - - if (Constant.UESR_SEX_MAN.equals(user.getSex())) { - userRankId = "男"; - } - - info.append("性别从" + oldUserRankId + "修改为" + userRankId + ";"); - } - - if (oldUser.getMobilePhone() == null) { - oldUser.setMobilePhone(""); - } - - if (!oldUser.getMobilePhone().equals(user.getMobilePhone())) { - info.append("手机从" + oldUser.getMobilePhone() + "修改为" + user.getMobilePhone() + ";"); - } - - if (oldUser.getOfficeTelephone() == null) { - oldUser.setOfficeTelephone(""); - } - - if (!oldUser.getOfficeTelephone().equals(user.getOfficeTelephone())) { - info.append( - "办公电话从" + oldUser.getOfficeTelephone() + "修改为" + user.getOfficeTelephone() + ";"); - } - - if (oldUser.getHomePhone() == null) { - oldUser.setHomePhone(""); - } - - if (!oldUser.getHomePhone().equals(user.getHomePhone())) { - info.append("家庭电话从" + oldUser.getHomePhone() + "修改为" + user.getHomePhone() + ";"); - } - - if (oldUser.getUesrRankId() == null) { - oldUser.setUesrRankId(""); - } - - if (!oldUser.getUesrRankId().equals(user.getUesrRankId())) { - oldUserRankId = "普通"; - userRankId = "普通"; - if (Constant.UESR_RANK_ID_SECRET.equals(oldUser.getUesrRankId())) { - oldUserRankId = "秘密"; - } - - if (Constant.UESR_RANK_ID_SECRET.equals(user.getUesrRankId())) { - userRankId = "秘密"; - } - - info.append("密码密级从" + oldUserRankId + "修改为" + userRankId + ";"); - } - oldUserRankId = user.getSecret(); - info.append("人员密级设置为" + oldUserRankId); - String logName = "修改人员"; - String logNameType = "用户列表"; - //todo 登录人的用户名 userName - //String comments = userName + "修改了用户" + user.getUserName() + "的信息"; - comments = "修改了用户" + user.getUserName() + "的信息"; - auditLog.setLogName(logName); - auditLog.setLogNameType(logNameType); - auditLog.setComments(comments + ";" + info); - auditLogService.addAuditLog(auditLog); - //todo 添加MESSAGE_TABLE表 - //if (userRankId != null && userRankId.equals("tianjin712suo")) { - // User safeUser = this.userService.selectUserByUserId("safesecret"); - // this.messageService.insertMessage("修改用户" + user.getUserName() + "", "用户管理", (String)null, - // safeUser.getId(), "", "0", "K"); - //} - - //todo customCode从Session中获取进行判断 - //if (userRankId != null && (userRankId.equals("siyuan17suo") || userRankId.equals("guiyangshiyuan"))) { - UserSecret userSecret = this.usersecretService.selectByPrimaryKey(user.getId()); - if (userSecret == null) { - UserSecret secret = new UserSecret(); - secret.setId(user.getId()); - secret.setSecret(user.getSecret()); - this.usersecretService.insertSelective(secret); - } else { - userSecret.setSecret(user.getSecret()); - this.usersecretService.updateByPrimaryKey(userSecret); - } - //} - ajaxMessage.setCode("1"); - ajaxMessage.setMessage("保存成功"); - } - } catch (Exception var16) { - log.error("修改用户失败", var16); - ajaxMessage.setCode("0"); - ajaxMessage.setMessage(Constant.ERROE_MESSAGE); - } - return ajaxMessage; + return userService.edit(user, request); } /** @@ -889,35 +298,26 @@ public class UserController { public List selectLoginList(@RequestParam(required = false) String userNameForSerch, @RequestParam(defaultValue = "0") int pageNum, @RequestParam(defaultValue = "10") int pageSize) { - Collection sessions = this.sessionDAO.getActiveSessions(); - List list = new ArrayList<>(); - Map maploginIp = new HashMap<>(); - Map maploginTime = new HashMap<>(); - Iterator var7 = sessions.iterator(); - while (var7.hasNext()) { - Session session = var7.next(); - Date date = session.getStartTimestamp(); - String loginIp = SessionCounter.sessionIpMap.get(session.getId()); - SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - String loginTime = formatter.format(date); - String userId = (String)session.getAttribute("user_id"); - if (userId != null) { - maploginIp.put(userId, loginIp); - maploginTime.put(userId, loginTime); - list.add(userId); - } - } - if (list.size() == 0) { - return new ArrayList<>(); - } - List userList = this.userService.selectAllLogin(list, userNameForSerch, pageNum, - pageSize); - Iterator var15 = userList.iterator(); - while (var15.hasNext()) { - User user = var15.next(); - user.setIP(maploginIp.get(user.getId())); - user.setLoginTime(maploginTime.get(user.getId())); - } - return userList; + return userService.selectLoginList(userNameForSerch, pageNum, pageSize); + } + + /** + * @param user + * @param setDocumentDepartId + * @return java.lang.String + * @description 查询部门管理人 + * @Author daijiajun + * @date 2025/1/17 + **/ + @RequestMapping( + value = {"/selectDepartUser"}, + method = {RequestMethod.POST}, + produces = {"application/json; charset=utf-8"} + ) + @ResponseBody + @Operation(summary = "查询部门管理人", description = "返回查询部门管理人信息") + @ApiResponse(responseCode = "200", description = "查询部门管理人成功") + public String selectDepartUser(@RequestBody User user, @RequestParam(required = false) String setDocumentDepartId) { + return userService.selectDepartUser(user, setDocumentDepartId); } } diff --git a/src/main/java/com/keyware/htey/entity/department/Department.java b/src/main/java/com/keyware/htey/entity/department/Department.java index f447451..f82a86d 100644 --- a/src/main/java/com/keyware/htey/entity/department/Department.java +++ b/src/main/java/com/keyware/htey/entity/department/Department.java @@ -34,6 +34,14 @@ public class Department implements Serializable { @TableField(exist = false) private String parentName; @TableField(exist = false) + private String chargeName; + @TableField(exist = false) + private String interfacePersonName; + @TableField(exist = false) + private String superLeaderName; + @TableField(exist = false) + private String managerName; + @TableField(exist = false) private int pageNum; @TableField(exist = false) private int pageSize; diff --git a/src/main/java/com/keyware/htey/entity/shiro/Role.java b/src/main/java/com/keyware/htey/entity/shiro/Role.java new file mode 100644 index 0000000..664c39f --- /dev/null +++ b/src/main/java/com/keyware/htey/entity/shiro/Role.java @@ -0,0 +1,38 @@ +package com.keyware.htey.entity.shiro; + +import java.io.Serializable; +import java.util.List; + +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @author daijiajun + * @version V1.0 + * @description + * @Package com.keyware.htey.entity.shiro + * @date 2025/1/17 10:49 + */ +@Data +@NoArgsConstructor +@AllArgsConstructor +@TableName("ROLE") +public class Role implements Serializable { + private static final long serialVersionUID = -6794098867242678694L; + + private String roleId; + + private String roleCode; + + private String roleName; + + private String createTime; + + private String isSys; + + private String projectSource; + //责任描述,20171121测试管理添加字段 + private String roleDescribe; +} diff --git a/src/main/java/com/keyware/htey/entity/shiro/RoleMenu.java b/src/main/java/com/keyware/htey/entity/shiro/RoleMenu.java new file mode 100644 index 0000000..029886e --- /dev/null +++ b/src/main/java/com/keyware/htey/entity/shiro/RoleMenu.java @@ -0,0 +1,25 @@ +package com.keyware.htey.entity.shiro; + +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @author daijiajun + * @version V1.0 + * @description + * @Package com.keyware.htey.entity.shiro + * @date 2025/1/17 10:50 + */ +@Data +@NoArgsConstructor +@AllArgsConstructor +@TableName("ROLE_MENU") +public class RoleMenu { + //角色ID + private String roleId; + + //菜单ID + private String menuId; +} diff --git a/src/main/java/com/keyware/htey/entity/shiro/RolePermission.java b/src/main/java/com/keyware/htey/entity/shiro/RolePermission.java new file mode 100644 index 0000000..54c180c --- /dev/null +++ b/src/main/java/com/keyware/htey/entity/shiro/RolePermission.java @@ -0,0 +1,25 @@ +package com.keyware.htey.entity.shiro; + +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @author daijiajun + * @version V1.0 + * @description + * @Package com.keyware.htey.entity.shiro + * @date 2025/1/17 10:51 + */ +@Data +@NoArgsConstructor +@AllArgsConstructor +@TableName("ROLE_PERMISSON") +public class RolePermission { + //角色ID + private String roleId; + + //权限点ID + private String permissionId; +} diff --git a/src/main/java/com/keyware/htey/mybatis/itf/DepartmentMapper.java b/src/main/java/com/keyware/htey/mybatis/itf/DepartmentMapper.java index f9f2eaf..baf35d7 100644 --- a/src/main/java/com/keyware/htey/mybatis/itf/DepartmentMapper.java +++ b/src/main/java/com/keyware/htey/mybatis/itf/DepartmentMapper.java @@ -24,4 +24,12 @@ public interface DepartmentMapper extends BaseMapper { List selectByDeparmentInfo(Department var1); List selectByparentId(@Param("parentId") String var1, @Param("projectSource") String var2); + + List selectByDeparmentInfoSelect(Department var1); + + int insertSelective(Department var1); + + int updateByPrimaryKeySelective(Department record); + + int deleteByPrimaryKey(List listId); } diff --git a/src/main/java/com/keyware/htey/mybatis/itf/UserMapper.java b/src/main/java/com/keyware/htey/mybatis/itf/UserMapper.java index 033cad0..35c7abd 100644 --- a/src/main/java/com/keyware/htey/mybatis/itf/UserMapper.java +++ b/src/main/java/com/keyware/htey/mybatis/itf/UserMapper.java @@ -56,4 +56,6 @@ public interface UserMapper extends BaseMapper { List selectAllLogin(@Param("list") List var1, @Param("userNameForSerch") String var2, @Param("userName") int userName, @Param("pageNum") int pageNum); + + int updateByPrimaryKeySelective(User var1); } diff --git a/src/main/java/com/keyware/htey/service/impl/AuditLogServiceImpl.java b/src/main/java/com/keyware/htey/service/impl/AuditLogServiceImpl.java index f36867f..7546712 100644 --- a/src/main/java/com/keyware/htey/service/impl/AuditLogServiceImpl.java +++ b/src/main/java/com/keyware/htey/service/impl/AuditLogServiceImpl.java @@ -16,8 +16,7 @@ import org.springframework.stereotype.Service; @Slf4j public class AuditLogServiceImpl extends ServiceImpl implements AuditLogService { @Autowired - private AuditLogMapper auditLogMapper; - + private AuditLogService auditLogService; public boolean insertLog(AuditLog auditLog) { //todo 登录人信息 //String userName = (String)session.getAttribute("userName"); diff --git a/src/main/java/com/keyware/htey/service/impl/DepartmentServiceImpl.java b/src/main/java/com/keyware/htey/service/impl/DepartmentServiceImpl.java index cf3fcfb..049867a 100644 --- a/src/main/java/com/keyware/htey/service/impl/DepartmentServiceImpl.java +++ b/src/main/java/com/keyware/htey/service/impl/DepartmentServiceImpl.java @@ -6,18 +6,31 @@ import java.util.List; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.keyware.htey.entity.department.Department; +import com.keyware.htey.entity.user.AuditLog; +import com.keyware.htey.entity.user.User; import com.keyware.htey.mybatis.itf.DepartmentMapper; +import com.keyware.htey.service.itf.AuditLogService; import com.keyware.htey.service.itf.DepartmentService; +import com.keyware.htey.service.itf.UserService; +import com.keyware.htey.utli.AjaxMessage; import com.keyware.htey.utli.Constant; +import com.keyware.htey.utli.DateUtils; +import com.keyware.htey.utli.IdComposeListUtil; +import com.keyware.htey.utli.IdGenerator; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.util.StringUtils; @Service @Slf4j public class DepartmentServiceImpl extends ServiceImpl implements DepartmentService { @Autowired private DepartmentMapper departmentMapper; + @Autowired + private AuditLogService auditLogService; + @Autowired + private UserService userService; @Override public List selectByDeparmentName(String deptName) { @@ -66,4 +79,308 @@ public class DepartmentServiceImpl extends ServiceImpl selectByDeparmentInfoSelect(Department departmentSelect) { + return this.departmentMapper.selectByDeparmentInfoSelect(departmentSelect); + } + + @Override + public int insertSelective(Department record) { + record.setProjectSource(Constant.projectName); + return this.departmentMapper.insertSelective(record); + } + + @Override + public int updateByPrimaryKeySelective(Department record) { + return departmentMapper.updateByPrimaryKeySelective(record); + } + + @Override + public int deleteByPrimaryKey(List listId) { + return departmentMapper.deleteByPrimaryKey(listId); + } + + /** + * @param department + * @param pageNum + * @param pageSize + * @return java.util.List + * @description 查询部门列表信息 + * @Author daijiajun + * @date 2025/1/17 + **/ + @Override + public List selectList(Department department, int pageNum, int pageSize) { + AuditLog auditLog = new AuditLog(); + department.setPageSize(pageSize); + department.setPageNum(pageNum); + if ("请输入部门名称...".equals(department.getDeptName())) { + department.setDeptName(null); + } + + //if ("sysadmin".equals(this.getUser_idFormSession("userId"))) { + // department.setIsSys("sysadmin"); + //} + + department.setProjectSource(Constant.projectName); + List departmentList = this.selectByDeparmentInfo(department); + //List parentNameList = new ArrayList(); + //for(Department vo : departmentList){ + // Integer selectUserCountByDeptId = userService.selectUserCountByDeptId(vo.getId()); + // if(selectUserCountByDeptId != null) + // vo.setUserCount(selectUserCountByDeptId); + // Department selectByPrimaryKey = selectByPrimaryKey(vo.getParentId()); + // if(selectByPrimaryKey != null) + // vo.setParentName(selectByPrimaryKey.getDeptName()); + // parentNameList.add(vo); + // + //} + String logName = "查询部门列表"; + String logNameType = "部门管理"; + //String comments = this.getUser_idFormSession("userName") + "查询部门列表,查询关键字为:" + department.getDeptName() == + // null ? "" : department.getDeptName(); + //todo 获取登录人信息 + String comments = "查询部门列表,查询关键字为:" + department.getDeptName() == null ? "" + : department.getDeptName(); + auditLog.setLogName(logName); + auditLog.setLogNameType(logNameType); + auditLog.setComments(comments); + auditLogService.addAuditLog(auditLog); + return departmentList; + } + + /** + * @param name + * @return com.keyware.htey.utli.AjaxMessage + * @description 部门校验 + * @Author daijiajun + * @date 2025/1/17 + **/ + @Override + public AjaxMessage checkDepartMentName(String name) { + AjaxMessage ajaxMessage = new AjaxMessage(); + if (StringUtils.hasText(name)) { + List selectByDeparmentName = this.selectByDeparmentName(name); + if (selectByDeparmentName.size() > 0) { + ajaxMessage.setCode("1"); + ajaxMessage.setMessage("部门名称已存在"); + } + } + return ajaxMessage; + } + + /** + * @param department + * @return com.keyware.htey.utli.AjaxMessage + * @description 部门添加 + * @Author daijiajun + * @date 2025/1/17 + **/ + @Override + public AjaxMessage add(Department department) { + AjaxMessage ajaxMessage = new AjaxMessage(); + AuditLog auditLog = new AuditLog(); + try { + Department departmentSelect = new Department(); + departmentSelect.setDeptName(department.getDeptName()); + List selectByDeparmentInfo = this.selectByDeparmentInfoSelect( + departmentSelect); + if (selectByDeparmentInfo.size() > 0) { + ajaxMessage.setCode("0"); + ajaxMessage.setMessage("部门名称已存在"); + return ajaxMessage; + } + + Department departmentSelect1 = new Department(); + departmentSelect1.setDeptNumber(department.getDeptNumber()); + List selectByDeparmentInfo1 = this.selectByDeparmentInfoSelect( + departmentSelect1); + if (selectByDeparmentInfo1.size() > 0) { + ajaxMessage.setCode("0"); + ajaxMessage.setMessage("部门编号已存在"); + return ajaxMessage; + } + + String deptId = IdGenerator.uuid32(); + department.setId(deptId); + department.setIsSys("0"); + department.setDeptCreateTime(DateUtils.getDateTime()); + department.setTotalWorkers(0); + this.insertSelective(department); + User user = new User(); + user.setId(department.getCharge()); + user.setDepartId(deptId); + this.userService.updateByPrimaryKeySelective(user); + ajaxMessage.setCode("1"); + ajaxMessage.setMessage("保存成功"); + StringBuilder info = new StringBuilder(); + info.append("部门简称:" + department.getDepartAbbrevia() + ";"); + info.append("上级部门:" + department.getParentName() + ";"); + info.append("部门负责:" + department.getChargeName() + ";"); + info.append("部门接口人:" + department.getInterfacePersonName() + ";"); + info.append("上级主管领导:" + department.getSuperLeaderName() + ";"); + info.append("部门管理人:" + department.getManagerName() + ";"); + info.append("部门描述:" + department.getComments() + ";"); + String logName = "添加部门"; + String logNameType = "部门管理"; + /*String comments = this.getUser_idFormSession("userName") + "添加" + department.getDeptName() + "部门,详细信息:" + + info;*/ + //todo 获取登录人信息 + String comments = "添加" + department.getDeptName() + "部门,详细信息:" + info; + auditLog.setLogName(logName); + auditLog.setLogNameType(logNameType); + auditLog.setComments(comments); + auditLogService.addAuditLog(auditLog); + } catch (Exception var10) { + log.error("部门添加失败", var10); + var10.printStackTrace(); + ajaxMessage.setCode("0"); + ajaxMessage.setMessage(Constant.ERROE_MESSAGE); + } + return ajaxMessage; + } + + /** + * @param department + * @return com.keyware.htey.utli.AjaxMessage + * @description 部门修改 + * @Author daijiajun + * @date 2025/1/17 + **/ + @Override + public AjaxMessage edit(Department department) { + AjaxMessage ajaxMessage = new AjaxMessage(); + AuditLog auditLog = new AuditLog(); + try { + Department oldDepartment = this.selectByPrimaryKey(department.getId()); + this.updateByPrimaryKeySelective(department); + ajaxMessage.setCode("1"); + ajaxMessage.setMessage("保存成功"); + + StringBuilder info = new StringBuilder(); + if (oldDepartment.getDepartAbbrevia() == null) {oldDepartment.setDepartAbbrevia("");} + if (!oldDepartment.getDepartAbbrevia().equals(department.getDepartAbbrevia())) { + info.append( + "部门简称从" + oldDepartment.getDepartAbbrevia() + "修改为" + department.getDepartAbbrevia() + ";"); + } + if (oldDepartment.getParentId() == null) {oldDepartment.setParentId("");} + if (!oldDepartment.getParentId().equals(department.getParentId())) { + String oldName = "空"; + String newName = "空"; + if (StringUtils.hasText(oldDepartment.getParentId())) { + Department department1 = this.selectByPrimaryKey(oldDepartment.getParentId()); + oldName = department1.getDeptName(); + } + if (StringUtils.hasText(department.getParentId())) { + Department department1 = this.selectByPrimaryKey(department.getParentId()); + newName = department1.getDeptName(); + } + info.append("上级部门从" + oldName + "修改为" + newName + ";"); + } + if (oldDepartment.getCharge() == null) {oldDepartment.setCharge("");} + if (!oldDepartment.getCharge().equals(department.getCharge())) { + String oldName = "空"; + if (StringUtils.hasText(oldDepartment.getCharge())) { + User user = userService.selectByPrimaryKey(oldDepartment.getCharge()); + oldName = user.getUserName(); + } + info.append("部门负责人从" + oldName + "修改为" + department.getChargeName() + ";"); + } + if (oldDepartment.getInterfacePerson() == null) {oldDepartment.setInterfacePerson("");} + if (!oldDepartment.getInterfacePerson().equals(department.getInterfacePerson())) { + String oldName = "空"; + if (StringUtils.hasText(oldDepartment.getInterfacePerson())) { + String interfacePerson = oldDepartment.getInterfacePerson(); + String[] split = interfacePerson.split(","); + for (String s : split) { + User user = userService.selectByPrimaryKey(s); + oldName += user.getUserName() + ","; + } + oldName = oldName.substring(0, oldName.length() - 1); + } + info.append("部门接口人从" + oldName + "修改为" + department.getInterfacePersonName() + ";"); + } + if (oldDepartment.getSuperLeader() == null) {oldDepartment.setSuperLeader("");} + if (!oldDepartment.getSuperLeader().equals(department.getSuperLeader())) { + String oldName = "空"; + if (StringUtils.hasText(oldDepartment.getSuperLeader())) { + String interfacePerson = oldDepartment.getSuperLeader(); + String[] split = interfacePerson.split(","); + for (String s : split) { + User user = userService.selectByPrimaryKey(s); + oldName += user.getUserName() + ","; + } + oldName = oldName.substring(0, oldName.length() - 1); + } + info.append("上级主管领导从" + oldName + "修改为" + department.getSuperLeaderName() + ";"); + } + if (oldDepartment.getManager() == null) {oldDepartment.setManager("");} + if (!oldDepartment.getManager().equals(department.getManager())) { + StringBuilder oldName = new StringBuilder("空"); + if (StringUtils.hasText(oldDepartment.getManager())) { + String interfacePerson = oldDepartment.getManager(); + String[] split = interfacePerson.split(","); + for (String s : split) { + User user = userService.selectByPrimaryKey(s); + oldName.append(user.getUserName()).append(","); + } + oldName = new StringBuilder(oldName.substring(0, oldName.length() - 1)); + } + info.append("部门管理人从" + oldName + "修改为" + department.getManagerName() + ";"); + } + if (oldDepartment.getComments() == null) {oldDepartment.setComments("");} + if (!oldDepartment.getComments().equals(department.getComments())) { + info.append("部门描述从" + oldDepartment.getComments() + "修改为" + department.getComments() + ";"); + } + String logName = "修改部门信息"; + String logNameType = "部门管理"; + /*String comments = getUser_idFormSession("userName")+"修改了"+department.getDeptName()+"部门详细信息:" + info;*/ + //todo 获取登录人信息 + String comments = "修改了" + department.getDeptName() + "部门详细信息:" + info; + auditLog.setLogName(logName); + auditLog.setLogNameType(logNameType); + auditLog.setComments(comments); + auditLogService.addAuditLog(auditLog); + } catch (Exception e) { + log.error("修改失败", e); + e.printStackTrace(); + ajaxMessage.setCode("0"); + ajaxMessage.setMessage(Constant.ERROE_MESSAGE); + } + return ajaxMessage; + } + + /** + * @param departments + * @return java.lang.String + * @description 部门删除 + * @Author daijiajun + * @date 2025/1/17 + **/ + @Override + public String delete(List departments) { + List listId = IdComposeListUtil.listDepartmentId(departments); + StringBuilder deparNames = new StringBuilder(); + for (String id : listId) { + Department selectByPrimaryKey = this.selectByPrimaryKey(id); + deparNames.append(selectByPrimaryKey.getDeptName()).append(","); + } + this.deleteByPrimaryKey(listId); + if (deparNames.length() > 0) { + AuditLog auditLog = new AuditLog(); + String logName = "删除部门"; + String logNameType = "部门管理"; + /*String comments = getUser_idFormSession("userName")+"删除了"+deparNames.substring(0, deparNames.length() + -1)+"部门";*/ + //todo 获取登录人信息 + String comments = "删除了" + deparNames.substring(0, deparNames.length() - 1) + "部门"; + auditLog.setLogName(logName); + auditLog.setLogNameType(logNameType); + auditLog.setComments(comments); + auditLogService.addAuditLog(auditLog); + } + + return "删除成功"; + } } diff --git a/src/main/java/com/keyware/htey/service/impl/NumberBuilderServiceImpl.java b/src/main/java/com/keyware/htey/service/impl/NumberBuilderServiceImpl.java index 833f43a..b47c0a2 100644 --- a/src/main/java/com/keyware/htey/service/impl/NumberBuilderServiceImpl.java +++ b/src/main/java/com/keyware/htey/service/impl/NumberBuilderServiceImpl.java @@ -2,6 +2,7 @@ package com.keyware.htey.service.impl; import com.keyware.htey.entity.number.NumberBuilder; import com.keyware.htey.mybatis.itf.number.NumberBuilderMapper; +import com.keyware.htey.service.itf.AuditLogService; import com.keyware.htey.service.itf.number.NumberBuilderService; import com.keyware.htey.utli.Constant; import org.springframework.beans.factory.annotation.Autowired; @@ -17,7 +18,8 @@ import org.springframework.stereotype.Service; public class NumberBuilderServiceImpl implements NumberBuilderService { @Autowired private NumberBuilderMapper numberBuilderMapper; - + @Autowired + private AuditLogService auditLogService; @Override public String getUserNumber() { Integer userNumber = this.getNumber("user_code"); diff --git a/src/main/java/com/keyware/htey/service/impl/OFourColumServiceImpl.java b/src/main/java/com/keyware/htey/service/impl/OFourColumServiceImpl.java index 4eeb661..5d6121f 100644 --- a/src/main/java/com/keyware/htey/service/impl/OFourColumServiceImpl.java +++ b/src/main/java/com/keyware/htey/service/impl/OFourColumServiceImpl.java @@ -3,6 +3,7 @@ package com.keyware.htey.service.impl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.keyware.htey.entity.organizeassets.OFourColum; import com.keyware.htey.mybatis.itf.OFourColumMapper; +import com.keyware.htey.service.itf.AuditLogService; import com.keyware.htey.service.itf.OFourColumService; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; @@ -13,7 +14,8 @@ import org.springframework.stereotype.Service; public class OFourColumServiceImpl extends ServiceImpl implements OFourColumService { @Autowired private OFourColumMapper oFourColumMapper; - + @Autowired + private AuditLogService auditLogService; @Override public OFourColum selectByPrimaryKey(String id) { // OFourColum oFourColum = jedisClientSingle.getObject(FOUR_COLUMN + id); diff --git a/src/main/java/com/keyware/htey/service/impl/UserServiceImpl.java b/src/main/java/com/keyware/htey/service/impl/UserServiceImpl.java index ae9f42d..e2a4418 100644 --- a/src/main/java/com/keyware/htey/service/impl/UserServiceImpl.java +++ b/src/main/java/com/keyware/htey/service/impl/UserServiceImpl.java @@ -1,17 +1,58 @@ package com.keyware.htey.service.impl; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Base64; +import java.util.Collection; +import java.util.Date; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.stream.Collectors; +import javax.annotation.Resource; +import javax.servlet.http.HttpServletRequest; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.keyware.htey.entity.department.Department; +import com.keyware.htey.entity.organizeassets.OFourColum; +import com.keyware.htey.entity.user.AuditLog; import com.keyware.htey.entity.user.User; +import com.keyware.htey.entity.usersecret.UserSecret; +import com.keyware.htey.listener.SessionCounter; import com.keyware.htey.mybatis.itf.UserMapper; import com.keyware.htey.mybatis.itf.UserRoleMapper; +import com.keyware.htey.service.itf.AuditLogService; +import com.keyware.htey.service.itf.DepartmentService; +import com.keyware.htey.service.itf.OFourColumService; import com.keyware.htey.service.itf.UserService; +import com.keyware.htey.service.itf.UsersecretService; +import com.keyware.htey.service.itf.number.NumberBuilderService; +import com.keyware.htey.utli.AjaxMessage; import com.keyware.htey.utli.Constant; +import com.keyware.htey.utli.DateUtils; +import com.keyware.htey.utli.EncryptUtil; +import com.keyware.htey.utli.ExcelUtils; +import com.keyware.htey.utli.IdComposeListUtil; +import com.keyware.htey.utli.IdGenerator; +import com.keyware.htey.utli.JsonUtils; import lombok.extern.slf4j.Slf4j; -import org.apache.ibatis.annotations.Param; +import org.apache.poi.ss.usermodel.Sheet; +import org.apache.poi.ss.usermodel.Workbook; +import org.apache.poi.ss.usermodel.WorkbookFactory; +import org.apache.shiro.session.Session; +import org.apache.shiro.session.mgt.eis.SessionDAO; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.util.StringUtils; +import org.springframework.web.multipart.MultipartFile; +import org.springframework.web.multipart.MultipartHttpServletRequest; +import org.springframework.web.util.WebUtils; @Service @Slf4j @@ -21,6 +62,18 @@ public class UserServiceImpl extends ServiceImpl implements Us private static String projectName = "kdtr"; @Autowired private UserRoleMapper userRoleMapper; + @Autowired + private AuditLogService auditLogService; + @Resource + private DepartmentService departmentService; + @Autowired + private OFourColumService oFourColumService; + @Autowired + private UsersecretService usersecretService; + @Autowired + private NumberBuilderService numberBuilderService; + @Autowired + private SessionDAO sessionDAO; @Override public List selectByUserInfo17suo(User user) { @@ -133,4 +186,1176 @@ public class UserServiceImpl extends ServiceImpl implements Us return this.userMapper.selectAllLogin(list, userNameForSerch, userName, pageNum); } + @Override + public int updateByPrimaryKeySelective(User record) { + return this.userMapper.updateByPrimaryKeySelective(record); + } + + /** + * @param multipartfile + * @return com.keyware.htey.utli.AjaxMessage + * @description 用户列表导入 + * @Author daijiajun + * @date 2025/1/17 + **/ + @Override + public AjaxMessage analysisExcl(MultipartFile multipartfile) { + AjaxMessage ajaxMessage = new AjaxMessage(); + try { + Workbook workbook = WorkbookFactory.create(multipartfile.getInputStream()); + Sheet sheet = workbook.getSheetAt(0); + ExcelUtils.checkFirstRowName(ajaxMessage, sheet); + if ("0".equals(ajaxMessage.getCode())) { + return ajaxMessage; + } + AuditLog auditLog = new AuditLog(); + String message = new ExcelUtils().insertUser(auditLog, sheet); + ajaxMessage.setCode("1"); + ajaxMessage.setMessage(message); + // String comments = this.getUser_idFormSession("userName") + message; + String comments = message; + String logName = "批量导入"; + String logNameType = "用户列表"; + auditLog.setLogName(logName); + auditLog.setLogNameType(logNameType); + auditLog.setComments(comments); + auditLogService.addAuditLog(auditLog); + } catch (Exception var8) { + log.error("导入失败", var8); + var8.printStackTrace(); + ajaxMessage.setCode("0"); + } + return ajaxMessage; + } + + /** + * @param user + * @param setDocumentDepartId + * @param headId + * @return java.lang.String + * @description 查询部门负责人 + * @Author daijiajun + * @date 2025/1/17 + **/ + @Override + public String selectDepartUser(User user, String setDocumentDepartId, String headId) { + List list = new ArrayList<>(); + String departId = user.getDepartId() == null ? "" : user.getDepartId(); + String set_document_departId = setDocumentDepartId == null ? "" : setDocumentDepartId; + String source = user.getSecret() == null ? "" : user.getSecret(); + String userName = user.getUserNameForSerch(); + if (user.getSystemLevel() != "" && user.getSystemLevel() != null) { + user.setSystemLevel(getSeq(user.getSystemLevel()).toString()); + } + log.info("查询条件=" + userName); + String projectClassIficationName = user.getUesrRankName() == null ? "" : user.getUesrRankName(); + String projectClassIfication = user.getUesrRankId() == null ? "" : user.getUesrRankId(); + String customer = Constant.customer; + if ("sysadmin".equals(Constant.userId)) { + user.setIsSys("sysadmin"); + } + user.setFlag("1"); + List users; + Iterator userIterator; + if (!"".equals(set_document_departId)) { + Department department = this.departmentService.selectByPrimaryKey(set_document_departId); + if (department != null) { + users = null; + if (customer != null && customer.equals("siyuan17suo")) { + if (userName != null && !"搜索您想寻找的...".equals(userName)) { + user.setUserNameForSerch(userName); + user.setDepartId(department.getParentId()); + user.setProjectSource(Constant.projectName); + users = this.selectByUserInfo17suo(user); + } else { + users = this.selectDepartUser17suo(department.getParentId()); + } + + userIterator = users.iterator(); + + while (userIterator.hasNext()) { + User u = (User)userIterator.next(); + if (("内部".equals(projectClassIficationName) || "秘密".equals(projectClassIficationName)) + && !"10".equals(u.getSecret()) && !"20".equals(u.getSecret()) && !"30".equals( + u.getSecret())) { + userIterator.remove(); + } + + if ("机密".equals(projectClassIficationName) && !"20".equals(u.getSecret()) && !"30".equals( + u.getSecret())) { + userIterator.remove(); + } + } + } + return JsonUtils.arrayListToJsonString(users); + } + } else { + HashSet selectByparentId; + String deptId; + if (customer == null || !customer.equals("siyuan17suo") && !customer.equals("guiyangshiyuan")) { + if (StringUtils.hasText(userName)) { + if (!"搜索您想寻找的...".equals(userName)) { + user.setUserNameForSerch(userName); + } + + users = this.selectByUserInfo(user); + list.addAll(users); + } else if (!"".equals(source)) { + user.setDepartId(departId); + users = this.selectByUserInfo(user); + list.addAll(users); + } else { + selectByparentId = this.departmentService.selectByparentId(departId); + user.setDepartId(departId); + users = this.selectByUserInfo(user); + list.addAll(users); + userIterator = selectByparentId.iterator(); + + while (userIterator.hasNext()) { + deptId = (String)userIterator.next(); + user.setDepartId(deptId); + users = this.selectByUserInfo(user); + list.addAll(users); + } + } + } else { + if (StringUtils.hasText(userName)) { + if (!"搜索您想寻找的...".equals(userName)) { + user.setUserNameForSerch(userName); + } + + users = this.selectByUserInfo17suo(user); + list.addAll(users); + } else if (!"".equals(source)) { + user.setDepartId(departId); + users = this.selectByUser(user); + list.addAll(users); + } else { + selectByparentId = this.departmentService.selectByparentId(departId); + user.setDepartId(departId); + users = this.selectByUser(user); + list.addAll(users); + userIterator = selectByparentId.iterator(); + + while (userIterator.hasNext()) { + deptId = (String)userIterator.next(); + if (deptId != "" && deptId != null) { + user.setDepartId(deptId); + users = this.selectByUser(user); + list.addAll(users); + } + } + } + + Iterator iterator = list.iterator(); + + while (iterator.hasNext()) { + User u = iterator.next(); + if (("内部".equals(projectClassIficationName) || "秘密".equals(projectClassIficationName)) + && !"10".equals(u.getSecret()) && !"20".equals(u.getSecret()) && !"30".equals(u.getSecret())) { + iterator.remove(); + } + + if ("机密".equals(projectClassIficationName) && !"20".equals(u.getSecret()) && !"30".equals( + u.getSecret())) { + iterator.remove(); + } + } + } + } + List listnew = new ArrayList<>(); + Iterator var21 = list.iterator(); + + while (var21.hasNext()) { + User user1 = var21.next(); + if (!listnew.contains(user1)) { + listnew.add(user1); + } + } + if (!StringUtils.isEmpty(projectClassIfication)) { + OFourColum oFourColum = oFourColumService.selectByPrimaryKey(projectClassIfication); + if (oFourColum != null) { + Iterator iterator = listnew.iterator(); + while (iterator.hasNext()) { + User next = iterator.next(); + if (!StringUtils.isEmpty(next.getSecret())) { + OFourColum oFourColum1 = oFourColumService.selectByPrimaryKey(next.getSecret()); + if (oFourColum1 != null && oFourColum.getSeq() > oFourColum1.getSeq() || oFourColum1 == null) { + iterator.remove(); + } + } + } + } + } + if (!StringUtils.isEmpty(headId)) { + listnew = listnew.stream().filter(o -> !(o).getId().equals(headId)).collect(Collectors.toList()); + } + + return JsonUtils.toJson(listnew); + } + + /** + * @param id + * @return java.lang.String + * @description 查看用户信息 + * @Author daijiajun + * @date 2025/1/17 + **/ + @Override + public String viewInfo(String id) { + AuditLog auditLog = new AuditLog(); + User user = this.getById(id); + String logName = "查看用户信息"; + String logNameType = "用户密级"; + //todo this.getUser_idFormSession("userName")登录人的用户名 + //String comments = this.getUser_idFormSession("userName") + "查看了" + user.getUserName() + "的用户信息"; + String comments = "查看了" + user.getUserName() + "的用户信息"; + auditLog.setLogName(logName); + auditLog.setLogNameType(logNameType); + auditLog.setComments(comments); + this.auditLogService.addAuditLog(auditLog); + return JsonUtils.objectToJsonString(user); + } + + /** + * @param user + * @return com.keyware.htey.utli.AjaxMessage + * @description 新增用户 + * @Author daijiajun + * @date 2025/1/17 + **/ + @Override + public AjaxMessage add(User user) { + AjaxMessage ajaxMessage = new AjaxMessage(); + try { + AuditLog auditLog = new AuditLog(); + List selectByUserNumber = this.selectByUserNumber(user.getUserNumber()); + if (selectByUserNumber.size() > 0) { + ajaxMessage.setCode("0"); + ajaxMessage.setMessage("员工编号已存在"); + return ajaxMessage; + } + Integer userCount = Constant.userCount; + if (0 != userCount) { + List selectAll = this.selectAll((String)null); + if (userCount <= selectAll.size()) { + ajaxMessage.setCode("0"); + ajaxMessage.setMessage("当前版本只允许新建" + Constant.userCount + "个用户"); + return ajaxMessage; + } + } + user.setPasswordOld(user.getPassword()); + user.setPassword(EncryptUtil.md5(user.getPassword())); + user.setUserCreationTime(DateUtils.getDate()); + user.setUserPwdModifTime(DateUtils.getDate("yyyy-MM-dd HH:mm:ss")); + user.setUserStatus(0L); + user.setUserLock(0L); + user.setLogout(0L); + user.setId(IdGenerator.uuid32()); + String sort = DateUtils.getDateTimeInt(); + user.setSort(sort); + this.insertSelective(user); + this.numberBuilderService.updateNumber("user_code"); + //todo 获取登录用户信息 + //HttpSession session = this.request.getSession(); + //String userName = (String)session.getAttribute("userName"); + //String comments = userName + "添加了用户" + user.getUserName(); + String comments = "添加了用户" + user.getUserName(); + StringBuilder info = new StringBuilder(); + info.append("员工编号:" + user.getUserNumber() + ";"); + info.append("姓名:" + user.getUserName() + ";"); + info.append("身份证号码:" + user.getUserNumber() + ";"); + info.append("电子邮件:" + user.getUserNumber() + ";"); + Department department1 = this.departmentService.selectByPrimaryKey(user.getDepartId()); + info.append("所属部门:" + department1.getDeptName() + ";"); + String sex = "女"; + if ("0".equals(user.getSex())) { + sex = "男"; + } + + info.append("性别:" + sex + ";"); + info.append("手机:" + user.getMobilePhone() + ";"); + info.append("办公电话:" + user.getOfficeTelephone() + ";"); + info.append("家庭电话:" + user.getHomePhone() + ";"); + String userRankId = "普通"; + if ("d453bf52e571451996a8f5c251f7eb8d".equals(user.getUesrRankId())) { + userRankId = "秘密"; + } + info.append("密码密级:" + userRankId + ";"); + String leves = user.getSecretName(); + info.append("人员密级:" + leves + ";"); + String logName = "添加人员"; + String logNameType = "用户列表"; + //todo 登录人的用户名 userName + auditLog.setLogName(logName); + auditLog.setLogNameType(logNameType); + auditLog.setComments(comments); + auditLogService.addAuditLog(auditLog); + //todo 添加MESSAGE_TABLE表 + //String numCode = this.getUser_idFormSession("customCode"); + //if (numCode != null && numCode.equals("tianjin712suo")) { + // User safeUser = this.userService.selectUserByUserId("safesecret"); + // this.messageService.insertMessage("添加用户" + user.getUserName() + "", "用户管理", (String)null, safeUser + // .getId(), "", "0", "K"); + //} + //if (numCode != null && (numCode.equals("siyuan17suo") || numCode.equals("guiyangshiyuan"))) { + UserSecret userSecret = new UserSecret(); + userSecret.setId(user.getId()); + userSecret.setSecret(user.getSecret()); + this.usersecretService.insertSelective(userSecret); + //} + ajaxMessage.setCode("1"); + ajaxMessage.setMessage("保存成功"); + } catch (Exception var16) { + log.error("新增用户失败", var16); + ajaxMessage.setCode("0"); + ajaxMessage.setMessage(Constant.ERROE_MESSAGE); + } + return ajaxMessage; + } + + /** + * @param users + * @param logOut + * @return java.lang.String + * @description 用户注销 + * @Author daijiajun + * @date 2025/1/17 + **/ + @Override + public String updateUser(List users, String logOut) { + String userNames = ""; + AuditLog auditLog = new AuditLog(); + if (1L == new Long(logOut)) { + for (User user : users) { + User oneUser = this.selectByPrimaryKey(user.getUserId()); + oneUser.setLogout(1L); + oneUser.setLogoutTime(DateUtils.getDateTime()); + this.updateById(oneUser); + if ("".equals(userNames)) { + userNames = oneUser.getUserName(); + } else { + userNames = userNames + "," + oneUser.getUserName(); + } + } + String logName = "注销人员"; + String logNameType = "用户列表"; + //todo 登录人的用户名 userName + //String comments = userName + "注销了用户" + userNames; + String comments = "注销了用户" + userNames; + auditLog.setLogName(logName); + auditLog.setLogNameType(logNameType); + auditLog.setComments(comments); + auditLogService.addAuditLog(auditLog); + } + if (!"1".equals(logOut)) { + Integer userCount = Constant.userCount; + if (0 != userCount) { + List selectAll = this.selectAll((String)null); + if (userCount < selectAll.size() + users.size()) { + return "当前版本只允许新建" + Constant.userCount + "个用户"; + } + } + this.recovery(IdComposeListUtil.listUserId(users)); + userNames = ""; + for (User user : users) { + User u = this.selectByPrimaryKey(user.getId()); + String logName = "还原人员"; + String logNameType = "注销用户列表"; + //String comments = userName + "还原了用户" + u.getUserName(); + //todo 获取登录人信息 + String comments = "还原了用户" + u.getUserName(); + auditLog.setLogName(logName); + auditLog.setLogNameType(logNameType); + auditLog.setComments(comments); + auditLogService.addAuditLog(auditLog); + if ("".equals(userNames)) { + userNames = u.getUserName(); + } else { + userNames = userNames + "," + u.getUserName(); + } + //todo 添加MESSAGE_TABLE表 + //if (numCode != null && numCode.equals("tianjin712suo")) { + // User safeUser = this.userService.selectUserByUserId("safesecret"); + // this.messageService.insertMessage("还原用户" + userNames + "", "用户管理", (String)null, safeUser.getId + // (), "", "0", "K"); + //} + } + } + return "0"; + } + + /** + * @param users + * @return java.lang.String + * @description 用户解锁 + * @Author daijiajun + * @date 2025/1/17 + **/ + @Override + public String updateLock(List users) { + List listId = IdComposeListUtil.listUserId(users); + this.unlock(listId); + String userNames = ""; + AuditLog auditLog = new AuditLog(); + for (User user : users) { + User oneUser = this.selectByPrimaryKey(user.getId()); + if ("".equals(userNames)) { + userNames = oneUser.getUserName(); + } else { + userNames = userNames + "," + oneUser.getUserName(); + } + String logName = "解锁"; + String logNameType = "用户列表"; + //todo 登录人的用户名 userName + //String comments = userName + "将用户" + userNames + "解锁"; + String comments = "将用户" + userNames + "解锁"; + auditLog.setLogName(logName); + auditLog.setLogNameType(logNameType); + auditLog.setComments(comments); + auditLogService.addAuditLog(auditLog); + //todo 添加MESSAGE_TABLE表 + } + return "解锁成功"; + } + + /** + * @param users + * @return com.keyware.htey.utli.AjaxMessage + * @description 启用禁用 + * @Author daijiajun + * @date 2025/1/17 + **/ + @Override + public AjaxMessage updateStatus(List users) { + AjaxMessage ajaxMessage = new AjaxMessage(); + String userNames = ""; + String status = ""; + AuditLog auditLog = new AuditLog(); + if (users.size() > 0) { + for (User user : users) { + User oneUser = this.selectByPrimaryKey(user.getId()); + oneUser.setUserStatus(user.getUserStatus()); + this.updateStatus(user); + if ("".equals(userNames)) { + userNames = oneUser.getUserName(); + } else { + userNames = userNames + "," + oneUser.getUserName(); + } + status = "open"; + if (user.getUserStatus() == 1L) { + status = "close"; + } + } + if ("open".equals(status)) { + String logName = "启用"; + String logNameType = "用户列表"; + //todo 登录人的用户名 userName + //String comments = userName + "启用了用户" + userNames; + String comments = "启用了用户" + userNames; + auditLog.setLogName(logName); + auditLog.setLogNameType(logNameType); + auditLog.setComments(comments); + auditLogService.addAuditLog(auditLog); + //todo 添加MESSAGE_TABLE表 + ajaxMessage.setMessage("启用成功"); + } else if ("close".equals(status)) { + String logName = "禁用"; + String logNameType = "用户列表"; + //todo 登录人的用户名 userName + //String comments = userName + "禁用了用户" + userNames; + String comments = "禁用了用户" + userNames; + auditLog.setLogName(logName); + auditLog.setLogNameType(logNameType); + auditLog.setComments(comments); + auditLogService.addAuditLog(auditLog); + //todo 添加MESSAGE_TABLE表 + ajaxMessage.setMessage("禁用成功"); + } + } + return ajaxMessage; + } + + /** + * @param users + * @return java.lang.String + * @description 删除用户 + * @Author daijiajun + * @date 2025/1/17 + **/ + @Override + public String deleteUser(List users) { + try { + List listId = IdComposeListUtil.listUserId(users); + AuditLog auditLog = new AuditLog(); + String userNames = ""; + for (User user : users) { + User safeUser = this.selectByPrimaryKey(user.getId()); + if ("".equals(userNames)) { + userNames = safeUser.getUserName(); + } else { + userNames = userNames + "," + safeUser.getUserName(); + } + } + this.deleteByPrimaryKey(listId); + String logName = "删除人员"; + String logNameType = "用户列表"; + //todo 登录人的用户名 userName + // String comments = userName + "删除了用户" + userNames; + String comments = "删除了用户" + userNames; + auditLog.setLogName(logName); + auditLog.setLogNameType(logNameType); + auditLog.setComments(comments); + auditLogService.addAuditLog(auditLog); + //todo 添加MESSAGE_TABLE表 + + //if (numCode != null && (numCode.equals("siyuan17suo") || numCode.equals("guiyangshiyuan"))) { + this.usersecretService.deleteByPrimaryKey(listId); + //} + for (String id : listId) { + this.deleteUserRoleByUserId(id); + } + return "删除成功"; + } catch (Exception var9) { + log.error("删除用户失败", var9); + return Constant.ERROE_MESSAGE; + } + } + + /** + * @param user + * @param pageNum + * @param pageSize + * @return java.util.List + * @description 用户列表 + * @Author daijiajun + * @date 2025/1/17 + **/ + @Override + public List selectByUserInfo17suo(User user, int pageNum, int pageSize) { + //String user_idFormSession = this.getUser_idFormSession("userId"); + //if ("sysadmin".equals(user_idFormSession)) { + // user.setIsSys("sysadmin"); + //} + + if ("请输入姓名...".equals(user.getUserNameForSerch())) { + user.setUserNameForSerch(null); + } + + String searchInfo = ""; + if (org.springframework.util.StringUtils.hasText(user.getUserNameForSerch())) { + searchInfo = searchInfo + "姓名关键字为" + user.getUserNameForSerch() + ","; + } + + if (org.springframework.util.StringUtils.hasText(user.getDepartId())) { + Department department = this.departmentService.selectByPrimaryKey(user.getDepartId()); + searchInfo = searchInfo + "部门为" + department.getDeptName(); + } + + if (org.springframework.util.StringUtils.hasText(user.getPost())) { + searchInfo = searchInfo + "职务为" + user.getPost(); + } + + user.setUserStatus(1L); + user.setProjectSource(Constant.projectName); + user.setProjectSource(Constant.projectName); + user.setUserStatus(1L); + user.setPageSize(pageSize); + user.setPageNum(pageNum); + List userList = this.selectByUserInfo17suo(user); + AuditLog auditLog = new AuditLog(); + String logName = "查询用户列表"; + String logNameType = "用户管理"; + //todo 登录人的用户名 userName + // String comments = this.getUser_idFormSession("userName") + "查询用户列表,查询条件为:" + searchInfo; + String comments = "查询用户列表,查询条件为:" + searchInfo; + auditLog.setLogName(logName); + auditLog.setLogNameType(logNameType); + auditLog.setComments(comments); + auditLogService.addAuditLog(auditLog); + return userList; + } + + /** + * @param userIds + * @return java.lang.String + * @description 密码重置 + * @Author daijiajun + * @date 2025/1/17 + **/ + @Override + public String PwdReset(String userIds) { + String[] userIdArr = userIds.split(","); + String userNames = ""; + AuditLog auditLog = new AuditLog(); + for (String userId : userIdArr) { + User user = new User(); + String passsword = IdGenerator.random10Str(); + user.setPassword(EncryptUtil.md5(passsword)); + user.setPasswordOld(passsword); + user.setUserPwdModifTime(DateUtils.getDate("yyyy-MM-dd HH:mm:ss")); + user.setInitPwdTime(DateUtils.formatDateTime(new Date())); + user.setExitTime(DateUtils.getDate("yyyy-MM-dd HH:mm:ss")); + user.setId(userId); + this.updateByPrimaryKey(user); + User oneUser = this.selectByPrimaryKey(userId); + if (oneUser == null) { + log.error("不存在id为[" + userId + "]"); + return Constant.ERROE_MESSAGE; + } + if ("".equals(userNames)) { + userNames = oneUser.getUserName(); + } else { + userNames = userNames + "," + oneUser.getUserName(); + } + } + String logName = "重置密码"; + String logNameType = "用户列表"; + //todo 登录人的用户名 userName + //String comments = userName + "将" + userNames + "用户的密码重置"; + String comments = "将" + userNames + "用户的密码重置"; + auditLog.setLogName(logName); + auditLog.setLogNameType(logNameType); + auditLog.setComments(comments); + auditLogService.addAuditLog(auditLog); + //todo 添加MESSAGE_TABLE表 + return "重置成功"; + } + + /** + * @param name + * @param pageNum + * @param pageSize + * @return com.baomidou.mybatisplus.extension.plugins.pagination.Page + * @description 注销用户列表 + * @Author daijiajun + * @date 2025/1/17 + **/ + @Override + public Page selectLogOutUser(String name, int pageNum, int pageSize) { + if ("请输入姓名...".equals(name)) { + name = null; + } + // 创建分页对象 + Page pageParam = new Page<>(pageNum, pageSize); + // 创建查询条件 + QueryWrapper queryWrapper = new QueryWrapper<>(); + if (!org.apache.commons.lang3.StringUtils.isEmpty(name)) { + queryWrapper = queryWrapper.like("USER_NAME", name).orderByDesc("LOGOUT_TIME");// 模糊查询 + } else { + queryWrapper = queryWrapper.orderByDesc("LOGOUT_TIME"); // 模糊查询 + } + AuditLog auditLog = new AuditLog(); + String logName = "查询注销用户列表"; + String logNameType = "用户管理"; + //todo 登录人的用户名 userName + //String comments = this.getUser_idFormSession("userName") + "查询注销用户列表,查询关键字为:" + name == null ? "" : name; + String comments = "查询注销用户列表,查询关键字为:" + name == null ? "" : name; + auditLog.setLogName(logName); + auditLog.setLogNameType(logNameType); + auditLog.setComments(comments); + auditLogService.addAuditLog(auditLog); + return this.page(pageParam, queryWrapper); + } + + /** + * @param name + * @param pageNum + * @param pageSize + * @return java.util.List + * @description 初始密码列表 + * @Author daijiajun + * @date 2025/1/17 + **/ + @Override + public List userPwdResetList(String name, int pageNum, int pageSize) { + if ("请输入姓名...".equals(name)) { + name = null; + } + List userList = this.pwdResetList(name, pageNum, pageSize); + AuditLog auditLog = new AuditLog(); + String logName = "查询密码重置列表"; + String logNameType = "用户管理"; + //todo 登录人的用户名 userName + //String comments = this.getUser_idFormSession("userName") + "查询密码重置列表,查询关键字为:" + name == null ? "" : name; + String comments = "查询密码重置列表,查询关键字为:" + name == null ? "" : name; + auditLog.setLogName(logName); + auditLog.setLogNameType(logNameType); + auditLog.setComments(comments); + auditLogService.addAuditLog(auditLog); + return userList; + } + + /** + * @param userIds + * @return java.lang.String + * @description 删除用户 + * @Author daijiajun + * @date 2025/1/17 + **/ + @Override + public String delPwdResetList(String userIds) { + try { + List listId = IdComposeListUtil.listId(userIds); + String userNames = ""; + AuditLog auditLog = new AuditLog(); + for (String userId : listId) { + User user = this.selectByPrimaryKey(userId); + if (user == null) { + log.error("不存在id为[" + userId + "]"); + return Constant.ERROE_MESSAGE; + } + if ("".equals(userNames)) { + userNames = user.getUserName(); + } else { + userNames = userNames + "," + user.getUserName(); + } + } + this.delPwdResetList(listId); + String logName = "删除"; + String logNameType = "初始密码"; + //todo 登录人的用户名 userName + //String comments = userName + "删除了用户" + userNames + "初始密码信息"; + String comments = "删除了用户" + userNames + "初始密码信息"; + auditLog.setLogName(logName); + auditLog.setLogNameType(logNameType); + auditLog.setComments(comments); + auditLogService.addAuditLog(auditLog); + //todo 添加MESSAGE_TABLE表 + //if (numCode != null && numCode.equals("tianjin712suo")) { + // safeUser = this.userService.selectUserByUserId("safesecret"); + // this.messageService.insertMessage("删除用户" + userNames + "的重置密码", "用户管理", (String)null, safeUser + // .getId(), "", "0", "K"); + //} + return "删除成功"; + } catch (Exception var8) { + log.error("删除失败", var8); + return Constant.ERROE_MESSAGE; + } + } + + /** + * @param user + * @param request + * @return com.keyware.htey.utli.AjaxMessage + * @description 修改人员 + * @Author daijiajun + * @date 2025/1/17 + **/ + @Override + public AjaxMessage edit(User user, HttpServletRequest request) { + AjaxMessage ajaxMessage = new AjaxMessage(); + User oldUser = this.selectByPrimaryKey(user.getId()); + byte[] fileData = null; + AuditLog auditLog = new AuditLog(); + try { + List selectByUserNumber = this.selectByUserNumber(user.getUserNumber()); + if (selectByUserNumber.size() > 0) { + if (selectByUserNumber.size() != 1) { + ajaxMessage.setCode("0"); + ajaxMessage.setMessage("员工编号已存在"); + return ajaxMessage; + } + + User user2 = (User)selectByUserNumber.get(0); + if (!user2.getId().equals(user.getId())) { + ajaxMessage.setCode("0"); + ajaxMessage.setMessage("员工编号已存在"); + return ajaxMessage; + } + String contentType = request.getContentType(); + String comments; + if (contentType != null && contentType.toLowerCase().startsWith("multipart/")) { + MultipartHttpServletRequest multipartRequest = WebUtils.getNativeRequest(request, + MultipartHttpServletRequest.class); + MultipartFile file = multipartRequest.getFile("multipartfile"); + comments = request.getParameter("changeFlg"); + if (comments.equals("1")) { + if (file != null) { + fileData = file.getBytes(); + } else { + String signatureUrl = request.getParameter("signatureUrl"); + Base64.Decoder decoder = Base64.getDecoder(); + signatureUrl = signatureUrl.substring(signatureUrl.indexOf(",", 1) + 1, + signatureUrl.length()); + fileData = decoder.decode(signatureUrl); + + for (int i = 0; i < fileData.length; ++i) { + if (fileData[i] < 0) { + fileData[i] = (byte)(fileData[i] + 256); + } + } + } + + user.setImgData(fileData); + } + } + this.updateByPrimaryKey(user); + StringBuilder info = new StringBuilder(); + if (oldUser.getUserNumber() == null) { + oldUser.setUserNumber(""); + } + + if (!oldUser.getUserNumber().equals(user.getUserNumber())) { + info.append("员工编号从" + oldUser.getUserNumber() + "修改为" + user.getUserNumber() + ";"); + } + + if (oldUser.getUserName() == null) { + oldUser.setUserName(""); + } + + if (!oldUser.getUserName().equals(user.getUserName())) { + info.append("姓名从" + oldUser.getUserName() + "修改为" + user.getUserName() + ";"); + } + + if (oldUser.getIdCard() == null) { + oldUser.setIdCard(""); + } + + if (!oldUser.getIdCard().equals(user.getIdCard())) { + info.append("身份证号码从" + oldUser.getUserNumber() + "修改为" + user.getUserNumber() + ";"); + } + + if (oldUser.getEmail() == null) { + oldUser.setEmail(""); + } + + if (!oldUser.getEmail().equals(user.getEmail())) { + info.append("电子邮件从" + oldUser.getUserNumber() + "修改为" + user.getUserNumber() + ";"); + } + + if (oldUser.getDepartId() == null) { + oldUser.setDepartId(""); + } + if (!oldUser.getDepartId().equals(user.getDepartId())) { + Department department; + if (org.springframework.util.StringUtils.hasText(oldUser.getDepartId()) + && org.springframework.util.StringUtils.hasText(user.getDepartId())) { + department = this.departmentService.selectByPrimaryKey(oldUser.getDepartId()); + Department department1 = this.departmentService.selectByPrimaryKey(user.getDepartId()); + if (department != null && department1 != null) { + info.append( + "所属部门从" + department.getDeptName() + "修改为" + department1.getDeptName() + ";"); + } + } else if (!org.springframework.util.StringUtils.hasText(oldUser.getDepartId()) + && org.springframework.util.StringUtils.hasText(user.getDepartId())) { + department = this.departmentService.selectByPrimaryKey(user.getDepartId()); + if (department != null) { + info.append("所属部门从空修改为" + department.getDeptName() + ";"); + } + } else if ( + org.springframework.util.StringUtils.hasText(oldUser.getDepartId()) + && !org.springframework.util.StringUtils.hasText(user.getDepartId())) { + department = this.departmentService.selectByPrimaryKey(oldUser.getDepartId()); + if (department != null) { + info.append("所属部门从" + department.getDeptName() + "修改为空;"); + } + } + } + + if (oldUser.getSex() == null) { + oldUser.setSex(0L); + } + + String oldUserRankId; + String userRankId; + if (!oldUser.getSex().equals(user.getSex())) { + oldUserRankId = "女"; + userRankId = "女"; + if (Constant.UESR_SEX_MAN.equals(oldUser.getSex())) { + oldUserRankId = "男"; + } + + if (Constant.UESR_SEX_MAN.equals(user.getSex())) { + userRankId = "男"; + } + + info.append("性别从" + oldUserRankId + "修改为" + userRankId + ";"); + } + + if (oldUser.getMobilePhone() == null) { + oldUser.setMobilePhone(""); + } + + if (!oldUser.getMobilePhone().equals(user.getMobilePhone())) { + info.append("手机从" + oldUser.getMobilePhone() + "修改为" + user.getMobilePhone() + ";"); + } + + if (oldUser.getOfficeTelephone() == null) { + oldUser.setOfficeTelephone(""); + } + + if (!oldUser.getOfficeTelephone().equals(user.getOfficeTelephone())) { + info.append( + "办公电话从" + oldUser.getOfficeTelephone() + "修改为" + user.getOfficeTelephone() + ";"); + } + + if (oldUser.getHomePhone() == null) { + oldUser.setHomePhone(""); + } + + if (!oldUser.getHomePhone().equals(user.getHomePhone())) { + info.append("家庭电话从" + oldUser.getHomePhone() + "修改为" + user.getHomePhone() + ";"); + } + + if (oldUser.getUesrRankId() == null) { + oldUser.setUesrRankId(""); + } + + if (!oldUser.getUesrRankId().equals(user.getUesrRankId())) { + oldUserRankId = "普通"; + userRankId = "普通"; + if (Constant.UESR_RANK_ID_SECRET.equals(oldUser.getUesrRankId())) { + oldUserRankId = "秘密"; + } + + if (Constant.UESR_RANK_ID_SECRET.equals(user.getUesrRankId())) { + userRankId = "秘密"; + } + + info.append("密码密级从" + oldUserRankId + "修改为" + userRankId + ";"); + } + oldUserRankId = user.getSecret(); + info.append("人员密级设置为" + oldUserRankId); + String logName = "修改人员"; + String logNameType = "用户列表"; + //todo 登录人的用户名 userName + //String comments = userName + "修改了用户" + user.getUserName() + "的信息"; + comments = "修改了用户" + user.getUserName() + "的信息"; + auditLog.setLogName(logName); + auditLog.setLogNameType(logNameType); + auditLog.setComments(comments + ";" + info); + auditLogService.addAuditLog(auditLog); + //todo 添加MESSAGE_TABLE表 + //if (userRankId != null && userRankId.equals("tianjin712suo")) { + // User safeUser = this.userService.selectUserByUserId("safesecret"); + // this.messageService.insertMessage("修改用户" + user.getUserName() + "", "用户管理", (String)null, + // safeUser.getId(), "", "0", "K"); + //} + + //todo customCode从Session中获取进行判断 + //if (userRankId != null && (userRankId.equals("siyuan17suo") || userRankId.equals("guiyangshiyuan"))) { + UserSecret userSecret = this.usersecretService.selectByPrimaryKey(user.getId()); + if (userSecret == null) { + UserSecret secret = new UserSecret(); + secret.setId(user.getId()); + secret.setSecret(user.getSecret()); + this.usersecretService.insertSelective(secret); + } else { + userSecret.setSecret(user.getSecret()); + this.usersecretService.updateByPrimaryKey(userSecret); + } + //} + ajaxMessage.setCode("1"); + ajaxMessage.setMessage("保存成功"); + } + } catch (Exception var16) { + log.error("修改用户失败", var16); + ajaxMessage.setCode("0"); + ajaxMessage.setMessage(Constant.ERROE_MESSAGE); + } + return ajaxMessage; + } + + /** + * @param userNameForSerch + * @param pageNum + * @param pageSize + * @return java.util.List + * @description 查询已登录用户 + * @Author daijiajun + * @date 2025/1/16 + **/ + @Override + public List selectLoginList(String userNameForSerch, int pageNum, int pageSize) { + Collection sessions = this.sessionDAO.getActiveSessions(); + List list = new ArrayList<>(); + Map maploginIp = new HashMap<>(); + Map maploginTime = new HashMap<>(); + Iterator var7 = sessions.iterator(); + while (var7.hasNext()) { + Session session = var7.next(); + Date date = session.getStartTimestamp(); + String loginIp = SessionCounter.sessionIpMap.get(session.getId()); + SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + String loginTime = formatter.format(date); + String userId = (String)session.getAttribute("user_id"); + if (userId != null) { + maploginIp.put(userId, loginIp); + maploginTime.put(userId, loginTime); + list.add(userId); + } + } + if (list.size() == 0) { + return new ArrayList<>(); + } + List userList = this.selectAllLogin(list, userNameForSerch, pageNum, + pageSize); + Iterator var15 = userList.iterator(); + while (var15.hasNext()) { + User user = var15.next(); + user.setIP(maploginIp.get(user.getId())); + user.setLoginTime(maploginTime.get(user.getId())); + } + return userList; + } + + /** + * @param user + * @param setDocumentDepartId + * @return java.lang.String + * @description 查询部门管理人 + * @Author daijiajun + * @date 2025/1/17 + **/ + @Override + public String selectDepartUser(User user, String setDocumentDepartId) { + List list = new ArrayList(); + String departId = user.getDepartId() == null ? "" : user.getDepartId(); + String set_document_departId = setDocumentDepartId == null ? "" : setDocumentDepartId; + String source = user.getSecret() == null ? "" : user.getSecret(); + String userName = user.getUserNameForSerch(); + log.info("查询条件=" + userName); + String projectClassIficationName = user.getUesrRankName() == null ? "" : user.getUesrRankName(); + String customer = Constant.customer; + if ("sysadmin".equals(Constant.userId)) { + user.setIsSys("sysadmin"); + } + user.setFlag("1"); + List users; + Iterator userIterator; + if (!"".equals(set_document_departId)) { + Department department = this.departmentService.selectByPrimaryKey(set_document_departId); + if (department != null) { + users = null; + if (customer != null && customer.equals("siyuan17suo")) { + if (userName != null && !"搜索您想寻找的...".equals(userName)) { + user.setUserNameForSerch(userName); + user.setDepartId(department.getParentId()); + user.setProjectSource(Constant.projectName); + users = this.selectByUserInfo17suo(user); + } else { + users = this.selectDepartUser17suo(department.getParentId()); + } + + userIterator = users.iterator(); + + while (userIterator.hasNext()) { + User u = (User)userIterator.next(); + if (("内部".equals(projectClassIficationName) || "秘密".equals(projectClassIficationName)) + && !"10".equals(u.getSecret()) && !"20".equals(u.getSecret()) && !"30".equals( + u.getSecret())) { + userIterator.remove(); + } + + if ("机密".equals(projectClassIficationName) && !"20".equals(u.getSecret()) && !"30".equals( + u.getSecret())) { + userIterator.remove(); + } + } + } else if (userName != null && !"搜索您想寻找的...".equals(userName)) { + user.setUserNameForSerch(userName); + user.setDepartId(department.getParentId()); + user.setProjectSource(Constant.projectName); + users = this.selectByUserInfo(user); + } else { + users = this.selectDepartUser(department.getParentId()); + } + + return JsonUtils.arrayListToJsonString(users); + } + } else { + HashSet selectByparentId; + String deptId; + if (customer == null || !customer.equals("siyuan17suo") && !customer.equals("guiyangshiyuan")) { + if (org.springframework.util.StringUtils.hasText(userName)) { + if (!"搜索您想寻找的...".equals(userName)) { + user.setUserNameForSerch(userName); + } + + users = this.selectByUserInfo(user); + list.addAll(users); + } else if (!"".equals(source)) { + user.setDepartId(departId); + users = this.selectByUserInfo(user); + list.addAll(users); + } else { + selectByparentId = this.departmentService.selectByparentId(departId); + user.setDepartId(departId); + users = this.selectByUserInfo(user); + list.addAll(users); + userIterator = selectByparentId.iterator(); + + while (userIterator.hasNext()) { + deptId = (String)userIterator.next(); + user.setDepartId(deptId); + users = this.selectByUserInfo(user); + list.addAll(users); + } + } + } else { + if (org.springframework.util.StringUtils.hasText(userName)) { + if (!"搜索您想寻找的...".equals(userName)) { + user.setUserNameForSerch(userName); + } + + users = this.selectByUserInfo17suo(user); + list.addAll(users); + } else if (!"".equals(source)) { + user.setDepartId(departId); + users = this.selectByUserInfo17suo(user); + list.addAll(users); + } else { + selectByparentId = this.departmentService.selectByparentId(departId); + user.setDepartId(departId); + users = this.selectByUserInfo17suo(user); + list.addAll(users); + userIterator = selectByparentId.iterator(); + + while (userIterator.hasNext()) { + deptId = (String)userIterator.next(); + user.setDepartId(deptId); + users = this.selectByUserInfo17suo(user); + list.addAll(users); + } + } + + userIterator = list.iterator(); + + while (userIterator.hasNext()) { + User u = (User)userIterator.next(); + if (("内部".equals(projectClassIficationName) || "秘密".equals(projectClassIficationName)) + && !"10".equals(u.getSecret()) && !"20".equals(u.getSecret()) && !"30".equals(u.getSecret())) { + userIterator.remove(); + } + + if ("机密".equals(projectClassIficationName) && !"20".equals(u.getSecret()) && !"30".equals( + u.getSecret())) { + userIterator.remove(); + } + } + } + } + + List listnew = new ArrayList(); + Iterator var21 = list.iterator(); + while (var21.hasNext()) { + User user1 = var21.next(); + if (!listnew.contains(user1)) { + listnew.add(user1); + } + } + return JsonUtils.toJson(listnew); + } + + public Integer getSeq(String id) { + OFourColum OFourColum = null; + if (!StringUtils.isEmpty(id)) { + OFourColum = oFourColumService.selectByPrimaryKey(id); + } + if (Objects.isNull(OFourColum)) { + return null; + } + return OFourColum.getSeq(); + } } diff --git a/src/main/java/com/keyware/htey/service/impl/UsersecretServiceImpl.java b/src/main/java/com/keyware/htey/service/impl/UsersecretServiceImpl.java index b203300..f05b6f6 100644 --- a/src/main/java/com/keyware/htey/service/impl/UsersecretServiceImpl.java +++ b/src/main/java/com/keyware/htey/service/impl/UsersecretServiceImpl.java @@ -5,6 +5,7 @@ import java.util.List; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.keyware.htey.entity.usersecret.UserSecret; import com.keyware.htey.mybatis.itf.UsersecretMapper; +import com.keyware.htey.service.itf.AuditLogService; import com.keyware.htey.service.itf.UsersecretService; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; @@ -15,7 +16,8 @@ import org.springframework.stereotype.Service; public class UsersecretServiceImpl extends ServiceImpl implements UsersecretService { @Autowired private UsersecretMapper usersecretMapper; - + @Autowired + private AuditLogService auditLogService; @Override public int insertSelective(UserSecret userSecret) { return this.usersecretMapper.insertSelective(userSecret); diff --git a/src/main/java/com/keyware/htey/service/itf/DepartmentService.java b/src/main/java/com/keyware/htey/service/itf/DepartmentService.java index cd160bd..9de5ee8 100644 --- a/src/main/java/com/keyware/htey/service/itf/DepartmentService.java +++ b/src/main/java/com/keyware/htey/service/itf/DepartmentService.java @@ -5,6 +5,10 @@ import java.util.List; import com.baomidou.mybatisplus.extension.service.IService; import com.keyware.htey.entity.department.Department; +import com.keyware.htey.utli.AjaxMessage; +import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestParam; public interface DepartmentService extends IService { List selectByDeparmentName(String var1); @@ -16,4 +20,22 @@ public interface DepartmentService extends IService { List selectByDeparmentInfo(Department var1); HashSet selectByparentId(String var1); + + List selectByDeparmentInfoSelect(Department var1); + + int insertSelective(Department var1); + + int updateByPrimaryKeySelective(Department record); + + int deleteByPrimaryKey(List listId); + + List selectList(Department department, int pageNum, int pageSize); + + public AjaxMessage checkDepartMentName(String name); + + public AjaxMessage add(Department department); + + public AjaxMessage edit(Department department); + + public String delete(List departments); } diff --git a/src/main/java/com/keyware/htey/service/itf/UserService.java b/src/main/java/com/keyware/htey/service/itf/UserService.java index f97ebc4..cf983f2 100644 --- a/src/main/java/com/keyware/htey/service/itf/UserService.java +++ b/src/main/java/com/keyware/htey/service/itf/UserService.java @@ -2,9 +2,16 @@ package com.keyware.htey.service.itf; import java.util.List; +import javax.servlet.http.HttpServletRequest; + +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.IService; import com.keyware.htey.entity.user.User; +import com.keyware.htey.utli.AjaxMessage; import org.apache.ibatis.annotations.Param; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.multipart.MultipartFile; public interface UserService extends IService { @@ -50,4 +57,38 @@ public interface UserService extends IService { List selectAllLogin(List var1, String var2, @Param("userName") int userName, @Param("pageNum") int pageNum); + + int updateByPrimaryKeySelective(User var1); + + AjaxMessage analysisExcl(MultipartFile multipartfile); + + String selectDepartUser(User user, String setDocumentDepartId, String headId); + + String viewInfo(String id); + + AjaxMessage add(User user); + + String updateUser(List users, String logOut); + + String updateLock(List users); + + AjaxMessage updateStatus(List users); + + String deleteUser(List users); + + List selectByUserInfo17suo(User user, int pageNum, int pageSize); + + String PwdReset(@RequestParam String userIds); + + Page selectLogOutUser(String name, int pageNum, int pageSize); + + List userPwdResetList(String name, int pageNum, int pageSize); + + String delPwdResetList(String userIds); + + AjaxMessage edit(User user, HttpServletRequest request); + + List selectLoginList(String userNameForSerch, int pageNum, int pageSize); + + String selectDepartUser(User user, String setDocumentDepartId); } diff --git a/src/main/java/com/keyware/htey/utli/IdComposeListUtil.java b/src/main/java/com/keyware/htey/utli/IdComposeListUtil.java index cb91e6a..b8be266 100644 --- a/src/main/java/com/keyware/htey/utli/IdComposeListUtil.java +++ b/src/main/java/com/keyware/htey/utli/IdComposeListUtil.java @@ -4,6 +4,7 @@ import java.util.Arrays; import java.util.List; import java.util.stream.Collectors; +import com.keyware.htey.entity.department.Department; import com.keyware.htey.entity.user.User; /** @@ -13,17 +14,27 @@ import com.keyware.htey.entity.user.User; * @date 2025/1/13 17:15 */ public class IdComposeListUtil { - public static List listId(List userList) { - String userIds = stringId(userList); + public static List listUserId(List userList) { + String userIds = stringUserId(userList); + return Arrays.asList(userIds.split(",")); + } + public static List listDepartmentId(List departmentList) { + String userIds = stringDepartmentListId(departmentList); return Arrays.asList(userIds.split(",")); } - public static String stringId(List userList) { + public static String stringUserId(List userList) { return userList.stream() .map(User::getId) .map(String::valueOf) // 将ID转换为字符串 .collect(Collectors.joining(", ")); // 使用逗号分隔 } + public static String stringDepartmentListId(List userList) { + return userList.stream() + .map(Department::getId) + .map(String::valueOf) // 将ID转换为字符串 + .collect(Collectors.joining(", ")); // 使用逗号分隔 + } public static List listId(String Ids) { return Arrays.asList(Ids.split(",")); diff --git a/src/main/resources/mapper/DepartmentMapper.xml b/src/main/resources/mapper/DepartmentMapper.xml index 00018f6..f7444f8 100644 --- a/src/main/resources/mapper/DepartmentMapper.xml +++ b/src/main/resources/mapper/DepartmentMapper.xml @@ -79,7 +79,184 @@ select from DEPARTMENT - where PARENT_ID = #{parentId} - and PROJECT_SOURCE=#{projectSource} + where PROJECT_SOURCE=#{projectSource} + + and PARENT_ID = #{parentId} + + + and PARENT_ID = #{parentId} + + + + + + insert into DEPARTMENT + + + ID, + + + DEPT_NAME, + + + PARENT_ID, + + + ORDER_NO, + + + COMMENTS, + + + DEPT_CREATE_TIME, + + + DEPT_NUMBER, + + + MANAGER, + + + TOTAL_WORKERS, + + + SUPER_LEADER, + + + INTERFACE_PERSON, + + + DEPART_ABBREVIA, + + + CHARGE, + + + IS_SYS, + + + PROJECT_SOURCE, + + + + + #{id,jdbcType=VARCHAR}, + + + #{deptName,jdbcType=VARCHAR}, + + + #{parentId,jdbcType=VARCHAR}, + + + #{orderNo,jdbcType=DECIMAL}, + + + #{comments,jdbcType=VARCHAR}, + + + #{deptCreateTime,jdbcType=VARCHAR}, + + + #{deptNumber,jdbcType=VARCHAR}, + + + #{manager,jdbcType=VARCHAR}, + + + #{totalWorkers,jdbcType=DECIMAL}, + + + #{superLeader,jdbcType=VARCHAR}, + + + #{interfacePerson,jdbcType=VARCHAR}, + + + #{departAbbrevia,jdbcType=VARCHAR}, + + + #{charge,jdbcType=VARCHAR}, + + + #{isSys,jdbcType=VARCHAR}, + + + #{projectSource,jdbcType=VARCHAR}, + + + + + update DEPARTMENT + + + DEPT_NAME = #{deptName,jdbcType=VARCHAR}, + + + PARENT_ID = #{parentId,jdbcType=VARCHAR}, + + + ORDER_NO = #{orderNo,jdbcType=DECIMAL}, + + + COMMENTS = #{comments,jdbcType=VARCHAR}, + + + DEPT_CREATE_TIME = #{deptCreateTime,jdbcType=VARCHAR}, + + + DEPT_NUMBER = #{deptNumber,jdbcType=VARCHAR}, + + + MANAGER = #{manager,jdbcType=VARCHAR}, + + + TOTAL_WORKERS = #{totalWorkers,jdbcType=DECIMAL}, + + + SUPER_LEADER = #{superLeader,jdbcType=VARCHAR}, + + + INTERFACE_PERSON = #{interfacePerson,jdbcType=VARCHAR}, + + + DEPART_ABBREVIA = #{departAbbrevia,jdbcType=VARCHAR}, + + + CHARGE = #{charge,jdbcType=VARCHAR}, + + + IS_SYS = #{isSys,jdbcType=VARCHAR}, + + + PROJECT_SOURCE = #{projectSource,jdbcType=VARCHAR}, + + + where ID = #{id,jdbcType=VARCHAR} + + + delete from DEPARTMENT + where ID in + + #{item} + + diff --git a/src/main/resources/mapper/UserMapper.xml b/src/main/resources/mapper/UserMapper.xml index 48a949a..4921ce6 100644 --- a/src/main/resources/mapper/UserMapper.xml +++ b/src/main/resources/mapper/UserMapper.xml @@ -111,7 +111,11 @@ and K_USER.USER_NUMBER = #{user.userNumber,jdbcType=VARCHAR} - LIMIT #{user.pageNum},#{user.pageSize} + + LIMIT #{user.pageNum},#{user.pageSize} + + order by SORT asc @@ -604,7 +608,7 @@ - select K_USER.ID, K_USER.USER_ID, @@ -625,15 +629,66 @@ DEPARTMENT.DEPT_NAME from K_USER left join DEPARTMENT on K_USER.DEPART_ID = DEPARTMENT.ID - where 1=1 + where 1=1 and (K_USER.USER_NAME like '%'||#{userNameForSerch,jdbcType=VARCHAR}||'%' ) - and K_USER.ID in - #{item} - LIMIT #{pageNum},#{pageSize} - + and K_USER.ID in + + #{item} + LIMIT #{pageNum},#{pageSize} + + + + update K_USER + + + USER_ID = #{userId,jdbcType=VARCHAR}, + + + USER_NAME = #{userName,jdbcType=VARCHAR}, + + + PASSWORD = #{password,jdbcType=VARCHAR}, + + + DEPART_ID = #{departId,jdbcType=VARCHAR}, + + + USER_CREATION_TIME = #{userCreationTime,jdbcType=VARCHAR}, + + + USER_PWD_MODIF_TIME = #{userPwdModifTime,jdbcType=VARCHAR}, + + + USER_STATUS = #{userStatus,jdbcType=DECIMAL}, + + + USER_LOCK = #{userLock,jdbcType=DECIMAL}, + + + USER_PWD_ERROR = #{userPwdError,jdbcType=DECIMAL}, + + + USER_PWD_ERROR_DATE = #{userPwdErrorDate,jdbcType=VARCHAR}, + + + LOGOUT_TIME = #{logoutTime,jdbcType=VARCHAR}, + + + UESR_RANK_ID = #{uesrRankId,jdbcType=VARCHAR}, + + + UESR_RANK_ID = #{uesrRankId,jdbcType=VARCHAR}, + + + IMG_DATA = #{imgData,jdbcType=VARCHAR}, + + + where ID = #{id,jdbcType=VARCHAR} + +