Merge remote-tracking branch 'origin/main'

main
yangmengchuan 2 days ago
commit 6a6095784b
  1. 92
      src/main/java/com/keyware/htey/controller/Department/DepartmentController.java
  2. 36
      src/main/java/com/keyware/htey/controller/humanResourceManagement/HumanResourceManagementController.java
  3. 191
      src/main/java/com/keyware/htey/controller/project/ProjectKtController.java
  4. 738
      src/main/java/com/keyware/htey/controller/user/UserController.java
  5. 8
      src/main/java/com/keyware/htey/entity/department/Department.java
  6. 38
      src/main/java/com/keyware/htey/entity/shiro/Role.java
  7. 25
      src/main/java/com/keyware/htey/entity/shiro/RoleMenu.java
  8. 25
      src/main/java/com/keyware/htey/entity/shiro/RolePermission.java
  9. 8
      src/main/java/com/keyware/htey/mybatis/itf/DepartmentMapper.java
  10. 2
      src/main/java/com/keyware/htey/mybatis/itf/UserMapper.java
  11. 3
      src/main/java/com/keyware/htey/service/impl/AuditLogServiceImpl.java
  12. 317
      src/main/java/com/keyware/htey/service/impl/DepartmentServiceImpl.java
  13. 4
      src/main/java/com/keyware/htey/service/impl/NumberBuilderServiceImpl.java
  14. 4
      src/main/java/com/keyware/htey/service/impl/OFourColumServiceImpl.java
  15. 1227
      src/main/java/com/keyware/htey/service/impl/UserServiceImpl.java
  16. 4
      src/main/java/com/keyware/htey/service/impl/UsersecretServiceImpl.java
  17. 22
      src/main/java/com/keyware/htey/service/itf/DepartmentService.java
  18. 41
      src/main/java/com/keyware/htey/service/itf/UserService.java
  19. 17
      src/main/java/com/keyware/htey/utli/IdComposeListUtil.java
  20. 181
      src/main/resources/mapper/DepartmentMapper.xml
  21. 59
      src/main/resources/mapper/UserMapper.xml

@ -2,12 +2,9 @@ package com.keyware.htey.controller.Department;
import java.util.List; import java.util.List;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.keyware.htey.entity.department.Department; 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.service.itf.DepartmentService;
import com.keyware.htey.utli.Constant; import com.keyware.htey.utli.AjaxMessage;
import com.keyware.htey.utli.JsonUtils; import com.keyware.htey.utli.JsonUtils;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.responses.ApiResponse; 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.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping; 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.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
@ -36,8 +34,6 @@ import org.springframework.web.bind.annotation.ResponseBody;
public class DepartmentController { public class DepartmentController {
@Autowired @Autowired
private DepartmentService departmentService; private DepartmentService departmentService;
@Autowired
private AuditLogService auditLogService;
@GetMapping("/selectById") @GetMapping("/selectById")
@ResponseBody @ResponseBody
@ -58,11 +54,6 @@ public class DepartmentController {
@Operation(summary = "新增部门表", description = "返回新增部门信息") @Operation(summary = "新增部门表", description = "返回新增部门信息")
@ApiResponse(responseCode = "200", description = "成功新增部门信息") @ApiResponse(responseCode = "200", description = "成功新增部门信息")
public boolean addDepartment(@RequestBody Department department) { public boolean addDepartment(@RequestBody Department department) {
Department oneDepartment = departmentService.getOne(
new QueryWrapper<Department>().eq("id", department.getId()));
if (oneDepartment != null) {
return false;
}
return departmentService.save(department); return departmentService.save(department);
} }
@ -71,8 +62,7 @@ public class DepartmentController {
* @date 2025/1/7 * @date 2025/1/7
* @description 修改部门 * @description 修改部门
*/ */
@RequestMapping(value = {"/updateDepartment"}, @RequestMapping(value = {"/updateDepartment"}, method = {RequestMethod.POST},
method = {RequestMethod.POST},
produces = {"application/json; charset=utf-8"}) produces = {"application/json; charset=utf-8"})
@ResponseBody @ResponseBody
@Operation(summary = "修改部门", description = "返回修改部门信息") @Operation(summary = "修改部门", description = "返回修改部门信息")
@ -107,65 +97,55 @@ public class DepartmentController {
@ResponseBody @ResponseBody
@Operation(summary = "查询部门父节点信息", description = "返回部门父节点信息") @Operation(summary = "查询部门父节点信息", description = "返回部门父节点信息")
@ApiResponse(responseCode = "200", 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 = ""; String isSys = "";
//if ("sysadmin".equals(this.getUser_idFormSession("userId"))) { //if ("sysadmin".equals(this.getUser_idFormSession("userId"))) {
// isSys = "sysadmin"; // isSys = "sysadmin";
//} //}
List<?> department = this.departmentService.getParentId(id, isSys, projectResource); List<Department> department = this.departmentService.getParentId(id, isSys, projectResource);
return JsonUtils.arrayListToJsonString(department); return JsonUtils.arrayListToJsonString(department);
} }
@RequestMapping( @RequestMapping(value = {"/select"}, method = {RequestMethod.POST}, produces = {"application/json; charset=utf-8"})
value = {"/select"},
method = {RequestMethod.POST},
produces = {"application/json; charset=utf-8"}
)
@ResponseBody @ResponseBody
@Operation(summary = "查询部门列表信息", description = "返回查询部门列表") @Operation(summary = "查询部门列表信息", description = "返回查询部门列表")
@ApiResponse(responseCode = "200", description = "成功返回查询部门列表") @ApiResponse(responseCode = "200", description = "成功返回查询部门列表")
public List<Department> select(@RequestBody Department department, @RequestParam(defaultValue = "0") int pageNum, public List<Department> select(@RequestBody Department department, @RequestParam(defaultValue = "0") int pageNum,
@RequestParam(defaultValue = "10") int pageSize) { @RequestParam(defaultValue = "10") int pageSize) {
AuditLog auditLog = new AuditLog(); return departmentService.selectList(department, pageNum, pageSize);
department.setPageSize(pageSize);
department.setPageNum(pageNum);
if ("请输入部门名称...".equals(department.getDeptName())) {
department.setDeptName(null);
} }
//if ("sysadmin".equals(this.getUser_idFormSession("userId"))) { @RequestMapping(value = {"/checkDepartMentName"}, method = {RequestMethod.POST},
// department.setIsSys("sysadmin"); 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); @RequestMapping(value = {"/add"}, method = {RequestMethod.POST}, produces = {"application/json; charset=utf-8"})
List<Department> departmentList = this.departmentService.selectByDeparmentInfo(department); @ResponseBody
//List<Department> parentNameList = new ArrayList(); @Operation(summary = "部门添加", description = "返回部门添加是否成功")
@ApiResponse(responseCode = "200", description = "部门添加成功")
public AjaxMessage add(@ModelAttribute Department department) {
return departmentService.add(department);
}
//Department vo; @RequestMapping(value = "/edit", method = RequestMethod.POST, produces = "application/json; charset=utf-8")
//for (Iterator var5 = departmentList.iterator(); var5.hasNext(); parentNameList.add(vo)) { @ResponseBody
// vo = (Department)var5.next(); @Operation(summary = "部门修改", description = "返回部门修改是否成功")
// Integer selectUserCountByDeptId = this.userService.selectUserCountByDeptId(vo.getId()); @ApiResponse(responseCode = "200", description = "部门添加修改")
// if (selectUserCountByDeptId != null) { public AjaxMessage edit(@ModelAttribute Department department) {
// vo.setUserCount(selectUserCountByDeptId); return departmentService.edit(department);
// } }
//
// Department selectByPrimaryKey = this.departmentService.selectByPrimaryKey(vo.getParentId()); @RequestMapping(value = "/delete", method = RequestMethod.POST, produces = "application/json; charset=utf-8")
// if (selectByPrimaryKey != null) { @ResponseBody
// vo.setParentName(selectByPrimaryKey.getDeptName()); @Operation(summary = "部门删除", description = "返回部门删除是否成功")
// } @ApiResponse(responseCode = "200", description = "部门删除修改")
//} public String delete(@RequestBody List<Department> departments) {
String logName = "查询部门列表"; return departmentService.delete(departments);
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;
} }
} }

@ -1,16 +1,11 @@
package com.keyware.htey.controller.humanResourceManagement; package com.keyware.htey.controller.humanResourceManagement;
import com.keyware.htey.entity.user.AuditLog; import com.keyware.htey.service.itf.UserService;
import com.keyware.htey.service.itf.AuditLogService;
import com.keyware.htey.utli.AjaxMessage; 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.Operation;
import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j; 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.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
@ -25,7 +20,7 @@ import org.springframework.web.multipart.MultipartFile;
@Slf4j @Slf4j
public class HumanResourceManagementController { public class HumanResourceManagementController {
@Autowired @Autowired
private AuditLogService auditLogService; private UserService userService;
@RequestMapping(value = {"/analysisExcl"}, method = {RequestMethod.POST}, @RequestMapping(value = {"/analysisExcl"}, method = {RequestMethod.POST},
produces = {"application/json; charset=utf-8"}) produces = {"application/json; charset=utf-8"})
@ -33,31 +28,6 @@ public class HumanResourceManagementController {
@Operation(summary = "用户列表导入", description = "返回导入信息") @Operation(summary = "用户列表导入", description = "返回导入信息")
@ApiResponse(responseCode = "200", description = "成功导入信息") @ApiResponse(responseCode = "200", description = "成功导入信息")
public AjaxMessage analysisExcl(@RequestParam MultipartFile multipartfile) { public AjaxMessage analysisExcl(@RequestParam MultipartFile multipartfile) {
AjaxMessage ajaxMessage = new AjaxMessage(); return userService.analysisExcl(multipartfile);
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;
} }
} }

@ -1,29 +1,13 @@
package com.keyware.htey.controller.project; 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.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.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.Operation;
import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
@ -42,14 +26,8 @@ import org.springframework.web.bind.annotation.ResponseBody;
@Tag(name = "项目管理模块 API", description = "部门表数据接口") @Tag(name = "项目管理模块 API", description = "部门表数据接口")
@Slf4j @Slf4j
public class ProjectKtController { public class ProjectKtController {
@Autowired
private OFourColumService fourColumService;
@Resource
private DepartmentService departmentService;
@Autowired @Autowired
private UserService userService; private UserService userService;
@Autowired
private OFourColumService oFourColumService;
@RequestMapping( @RequestMapping(
value = {"/selectDepartUser"}, value = {"/selectDepartUser"},
@ -61,173 +39,6 @@ public class ProjectKtController {
@ApiResponse(responseCode = "200", description = "部门负责人返回成功") @ApiResponse(responseCode = "200", description = "部门负责人返回成功")
public String selectDepartUser(@RequestBody User user, @RequestParam(required = false) String setDocumentDepartId, public String selectDepartUser(@RequestBody User user, @RequestParam(required = false) String setDocumentDepartId,
@RequestParam(required = false) String headId) { @RequestParam(required = false) String headId) {
List<User> list = new ArrayList(); return userService.selectDepartUser(user, setDocumentDepartId, headId);
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<User> 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();
}
} }

@ -1,44 +1,17 @@
package com.keyware.htey.controller.user; 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.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest; 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.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.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.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.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.Operation;
import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j; 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.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping; 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.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody; 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 * @author yangmengchuan
@ -63,16 +33,6 @@ import org.springframework.web.util.WebUtils;
public class UserController { public class UserController {
@Autowired @Autowired
private UserService userService; 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 * @author yangmengchuan
@ -112,27 +72,23 @@ public class UserController {
return userService.getById(id); return userService.getById(id);
} }
/**
* @param id
* @return java.lang.String
* @description 查看用户信息
* @Author daijiajun
* @date 2025/1/17
**/
@GetMapping("/viewInfo") @GetMapping("/viewInfo")
@ResponseBody @ResponseBody
@Operation(summary = "根据id查询用户", description = "返回查询用户信息") @Operation(summary = "查看用户信息", description = "返回查询用户信息")
@ApiResponse(responseCode = "200", description = "成功获取用户信息") @ApiResponse(responseCode = "200", description = "成功获取用户信息")
public String viewInfo(@RequestParam String id) { public String viewInfo(@RequestParam String id) {
AuditLog auditLog = new AuditLog(); return userService.viewInfo(id);
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);
} }
/** /**
* @author yangmengchuan * @author daijiajun
* @date 2025/1/7 * @date 2025/1/7
* @description 新增用户 * @description 新增用户
*/ */
@ -144,97 +100,12 @@ public class UserController {
@ResponseBody @ResponseBody
@Operation(summary = "新增用户", description = "返回新增用户信息") @Operation(summary = "新增用户", description = "返回新增用户信息")
@ApiResponse(responseCode = "200", description = "成功新增用户信息") @ApiResponse(responseCode = "200", description = "成功新增用户信息")
public AjaxMessage addUser(@RequestBody User user) { public AjaxMessage add(@RequestBody User user) {
AjaxMessage ajaxMessage = new AjaxMessage(); return userService.add(user);
try {
AuditLog auditLog = new AuditLog();
List<User> 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<User> 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;
} }
/** /**
* @author yangmengchuan * @author daijiajun
* @date 2025/1/7 * @date 2025/1/7
* @description 用户注销 * @description 用户注销
*/ */
@ -247,71 +118,13 @@ public class UserController {
@Operation(summary = "用户注销还原", description = "返回用户注销信息") @Operation(summary = "用户注销还原", description = "返回用户注销信息")
@ApiResponse(responseCode = "200", description = "成功用户注销信息") @ApiResponse(responseCode = "200", description = "成功用户注销信息")
public String updateUser(@RequestBody List<User> users, String logOut) { public String updateUser(@RequestBody List<User> users, String logOut) {
String userNames = ""; return userService.updateUser(users, logOut);
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<User> 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";
} }
/** /**
* @author yangmengchuan * @author daijiajun
* @date 2025/1/7 * @date 2025/1/7
* @description 解锁 * @description 用户解锁
*/ */
@RequestMapping( @RequestMapping(
value = {"/updateLock"}, value = {"/updateLock"},
@ -322,33 +135,11 @@ public class UserController {
@Operation(summary = "用户解锁", description = "返回用户解锁信息") @Operation(summary = "用户解锁", description = "返回用户解锁信息")
@ApiResponse(responseCode = "200", description = "成功用户解锁信息") @ApiResponse(responseCode = "200", description = "成功用户解锁信息")
public String updateLock(@RequestBody List<User> users) { public String updateLock(@RequestBody List<User> users) {
List<String> listId = IdComposeListUtil.listId(users); return userService.updateLock(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 "解锁成功";
} }
/** /**
* @author yangmengchuan * @author daijiajun
* @date 2025/1/7 * @date 2025/1/7
* @description 启用禁用 * @description 启用禁用
*/ */
@ -361,58 +152,13 @@ public class UserController {
@Operation(summary = "用户启用禁用", description = "返回用户启用禁用信息") @Operation(summary = "用户启用禁用", description = "返回用户启用禁用信息")
@ApiResponse(responseCode = "200", description = "成功用户启用禁用信息") @ApiResponse(responseCode = "200", description = "成功用户启用禁用信息")
public AjaxMessage updateStatus(@RequestBody List<User> users) { public AjaxMessage updateStatus(@RequestBody List<User> users) {
AjaxMessage ajaxMessage = new AjaxMessage(); return userService.updateStatus(users);
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;
} }
/** /**
* @author yangmengchuan * @author daijiajun
* @date 2025/1/7 * @date 2025/1/7
* @description 根据id进行删除 * @description 删除用户
*/ */
@RequestMapping( @RequestMapping(
value = {"/delete"}, value = {"/delete"},
@ -420,46 +166,21 @@ public class UserController {
produces = {"application/json; charset=utf-8"} produces = {"application/json; charset=utf-8"}
) )
@ResponseBody @ResponseBody
@Operation(summary = "根据id删除用户", description = "返回删除用户信息") @Operation(summary = "删除用户", description = "返回删除用户信息")
@ApiResponse(responseCode = "200", description = "成功删除用户信息") @ApiResponse(responseCode = "200", description = "成功删除用户信息")
public String deleteUser(@RequestBody List<User> users) { public String deleteUser(@RequestBody List<User> users) {
try { return userService.deleteUser(users);
List<String> 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;
}
} }
/**
* @param user
* @param pageNum
* @param pageSize
* @return java.util.List<com.keyware.htey.entity.user.User>
* @description 用户列表
* @Author daijiajun
* @date 2025/1/17
**/
@RequestMapping( @RequestMapping(
value = {"/select"}, value = {"/select"},
method = {RequestMethod.POST}, method = {RequestMethod.POST},
@ -470,11 +191,7 @@ public class UserController {
@ApiResponse(responseCode = "200", description = "成功用户列表信息") @ApiResponse(responseCode = "200", description = "成功用户列表信息")
public List<User> selectByUserInfo17suo(User user, @RequestParam(defaultValue = "0") int pageNum, public List<User> selectByUserInfo17suo(User user, @RequestParam(defaultValue = "0") int pageNum,
@RequestParam(defaultValue = "10") int pageSize) { @RequestParam(defaultValue = "10") int pageSize) {
user.setProjectSource(Constant.projectName); return userService.selectByUserInfo17suo(user, pageNum, pageSize);
user.setUserStatus(1L);
user.setPageSize(pageSize);
user.setPageNum(pageNum);
return userService.selectByUserInfo17suo(user);
} }
/** /**
@ -488,41 +205,7 @@ public class UserController {
@Operation(summary = "密码重置", description = "返回密码重置信息") @Operation(summary = "密码重置", description = "返回密码重置信息")
@ApiResponse(responseCode = "200", description = "密码重置成功") @ApiResponse(responseCode = "200", description = "密码重置成功")
public String PwdReset(@RequestParam String userIds) { public String PwdReset(@RequestParam String userIds) {
String[] userIdArr = userIds.split(","); return userService.PwdReset(userIds);
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 "重置成功";
} }
/** /**
@ -539,38 +222,17 @@ public class UserController {
public Page<User> selectLogOutUser(@RequestParam(required = false) String name, public Page<User> selectLogOutUser(@RequestParam(required = false) String name,
@RequestParam(defaultValue = "0") int pageNum, @RequestParam(defaultValue = "0") int pageNum,
@RequestParam(defaultValue = "10") int pageSize) { @RequestParam(defaultValue = "10") int pageSize) {
if ("请输入姓名...".equals(name)) { return userService.selectLogOutUser(name, pageNum, pageSize);
name = null;
}
// 创建分页对象
Page<User> pageParam = new Page<>(pageNum, pageSize);
// 创建查询条件
QueryWrapper<User> 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);
} }
/** /**
* 查询密码重置列表 * 初始密码列表
* *
* @param name * @param name
* @param pageNum * @param pageNum
* @param pageSize * @param pageSize
* @return * @return
* @Author daijiajun
*/ */
@GetMapping("/userPwdResetList") @GetMapping("/userPwdResetList")
@ResponseBody @ResponseBody
@ -579,21 +241,7 @@ public class UserController {
public List<User> userPwdResetList(@RequestParam(required = false) String name, public List<User> userPwdResetList(@RequestParam(required = false) String name,
@RequestParam(defaultValue = "0") int pageNum, @RequestParam(defaultValue = "0") int pageNum,
@RequestParam(defaultValue = "10") int pageSize) { @RequestParam(defaultValue = "10") int pageSize) {
if ("请输入姓名...".equals(name)) { return userService.userPwdResetList(name, pageNum, pageSize);
name = null;
}
List<User> 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;
} }
/** /**
@ -610,46 +258,18 @@ public class UserController {
@ResponseBody @ResponseBody
@Operation(summary = "删除用户", description = "返回删除用户信息") @Operation(summary = "删除用户", description = "返回删除用户信息")
@ApiResponse(responseCode = "200", description = "删除用户成功") @ApiResponse(responseCode = "200", description = "删除用户成功")
public String delPwdResetList(@RequestParam String userIds, HttpServletRequest request) { public String delPwdResetList(@RequestParam String userIds) {
try { return userService.delPwdResetList(userIds);
List<String> 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;
}
} }
/**
* @param user
* @param request
* @return com.keyware.htey.utli.AjaxMessage
* @description 修改人员
* @Author daijiajun
* @date 2025/1/17
**/
@RequestMapping( @RequestMapping(
value = {"/edit"}, value = {"/edit"},
method = {RequestMethod.POST}, method = {RequestMethod.POST},
@ -659,218 +279,7 @@ public class UserController {
@Operation(summary = "修改人员", description = "返回修改人员信息") @Operation(summary = "修改人员", description = "返回修改人员信息")
@ApiResponse(responseCode = "200", description = "修改人员成功") @ApiResponse(responseCode = "200", description = "修改人员成功")
public AjaxMessage edit(@RequestBody User user, HttpServletRequest request) { public AjaxMessage edit(@RequestBody User user, HttpServletRequest request) {
AjaxMessage ajaxMessage = new AjaxMessage(); return userService.edit(user, request);
User oldUser = this.userService.selectByPrimaryKey(user.getId());
byte[] fileData = null;
AuditLog auditLog = new AuditLog();
try {
List<User> 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;
} }
/** /**
@ -889,35 +298,26 @@ public class UserController {
public List<User> selectLoginList(@RequestParam(required = false) String userNameForSerch, public List<User> selectLoginList(@RequestParam(required = false) String userNameForSerch,
@RequestParam(defaultValue = "0") int pageNum, @RequestParam(defaultValue = "0") int pageNum,
@RequestParam(defaultValue = "10") int pageSize) { @RequestParam(defaultValue = "10") int pageSize) {
Collection<Session> sessions = this.sessionDAO.getActiveSessions(); return userService.selectLoginList(userNameForSerch, pageNum, pageSize);
List<String> list = new ArrayList<>();
Map<String, String> maploginIp = new HashMap<>();
Map<String, String> maploginTime = new HashMap<>();
Iterator<Session> 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<>(); * @param user
} * @param setDocumentDepartId
List<User> userList = this.userService.selectAllLogin(list, userNameForSerch, pageNum, * @return java.lang.String
pageSize); * @description 查询部门管理人
Iterator<User> var15 = userList.iterator(); * @Author daijiajun
while (var15.hasNext()) { * @date 2025/1/17
User user = var15.next(); **/
user.setIP(maploginIp.get(user.getId())); @RequestMapping(
user.setLoginTime(maploginTime.get(user.getId())); value = {"/selectDepartUser"},
} method = {RequestMethod.POST},
return userList; 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);
} }
} }

@ -34,6 +34,14 @@ public class Department implements Serializable {
@TableField(exist = false) @TableField(exist = false)
private String parentName; private String parentName;
@TableField(exist = false) @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; private int pageNum;
@TableField(exist = false) @TableField(exist = false)
private int pageSize; private int pageSize;

@ -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;
}

@ -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;
}

@ -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;
}

@ -24,4 +24,12 @@ public interface DepartmentMapper extends BaseMapper<Department> {
List<Department> selectByDeparmentInfo(Department var1); List<Department> selectByDeparmentInfo(Department var1);
List<Department> selectByparentId(@Param("parentId") String var1, @Param("projectSource") String var2); List<Department> selectByparentId(@Param("parentId") String var1, @Param("projectSource") String var2);
List<Department> selectByDeparmentInfoSelect(Department var1);
int insertSelective(Department var1);
int updateByPrimaryKeySelective(Department record);
int deleteByPrimaryKey(List listId);
} }

@ -56,4 +56,6 @@ public interface UserMapper extends BaseMapper<User> {
List<User> selectAllLogin(@Param("list") List<String> var1, @Param("userNameForSerch") String var2, List<User> selectAllLogin(@Param("list") List<String> var1, @Param("userNameForSerch") String var2,
@Param("userName") int userName, @Param("pageNum") int pageNum); @Param("userName") int userName, @Param("pageNum") int pageNum);
int updateByPrimaryKeySelective(User var1);
} }

@ -16,8 +16,7 @@ import org.springframework.stereotype.Service;
@Slf4j @Slf4j
public class AuditLogServiceImpl extends ServiceImpl<AuditLogMapper, AuditLog> implements AuditLogService { public class AuditLogServiceImpl extends ServiceImpl<AuditLogMapper, AuditLog> implements AuditLogService {
@Autowired @Autowired
private AuditLogMapper auditLogMapper; private AuditLogService auditLogService;
public boolean insertLog(AuditLog auditLog) { public boolean insertLog(AuditLog auditLog) {
//todo 登录人信息 //todo 登录人信息
//String userName = (String)session.getAttribute("userName"); //String userName = (String)session.getAttribute("userName");

@ -6,18 +6,31 @@ import java.util.List;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.keyware.htey.entity.department.Department; 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.mybatis.itf.DepartmentMapper;
import com.keyware.htey.service.itf.AuditLogService;
import com.keyware.htey.service.itf.DepartmentService; 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.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 lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
@Service @Service
@Slf4j @Slf4j
public class DepartmentServiceImpl extends ServiceImpl<DepartmentMapper, Department> implements DepartmentService { public class DepartmentServiceImpl extends ServiceImpl<DepartmentMapper, Department> implements DepartmentService {
@Autowired @Autowired
private DepartmentMapper departmentMapper; private DepartmentMapper departmentMapper;
@Autowired
private AuditLogService auditLogService;
@Autowired
private UserService userService;
@Override @Override
public List<Department> selectByDeparmentName(String deptName) { public List<Department> selectByDeparmentName(String deptName) {
@ -66,4 +79,308 @@ public class DepartmentServiceImpl extends ServiceImpl<DepartmentMapper, Departm
return hashSet; return hashSet;
} }
} }
@Override
public List<Department> 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<com.keyware.htey.entity.department.Department>
* @description 查询部门列表信息
* @Author daijiajun
* @date 2025/1/17
**/
@Override
public List<Department> 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<Department> departmentList = this.selectByDeparmentInfo(department);
//List<Department> parentNameList = new ArrayList<Department>();
//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<Department> 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<Department> selectByDeparmentInfo = this.selectByDeparmentInfoSelect(
departmentSelect);
if (selectByDeparmentInfo.size() > 0) {
ajaxMessage.setCode("0");
ajaxMessage.setMessage("部门名称已存在");
return ajaxMessage;
}
Department departmentSelect1 = new Department();
departmentSelect1.setDeptNumber(department.getDeptNumber());
List<Department> 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<Department> departments) {
List<String> 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 "删除成功";
}
} }

@ -2,6 +2,7 @@ package com.keyware.htey.service.impl;
import com.keyware.htey.entity.number.NumberBuilder; import com.keyware.htey.entity.number.NumberBuilder;
import com.keyware.htey.mybatis.itf.number.NumberBuilderMapper; 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.service.itf.number.NumberBuilderService;
import com.keyware.htey.utli.Constant; import com.keyware.htey.utli.Constant;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -17,7 +18,8 @@ import org.springframework.stereotype.Service;
public class NumberBuilderServiceImpl implements NumberBuilderService { public class NumberBuilderServiceImpl implements NumberBuilderService {
@Autowired @Autowired
private NumberBuilderMapper numberBuilderMapper; private NumberBuilderMapper numberBuilderMapper;
@Autowired
private AuditLogService auditLogService;
@Override @Override
public String getUserNumber() { public String getUserNumber() {
Integer userNumber = this.getNumber("user_code"); Integer userNumber = this.getNumber("user_code");

@ -3,6 +3,7 @@ package com.keyware.htey.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.keyware.htey.entity.organizeassets.OFourColum; import com.keyware.htey.entity.organizeassets.OFourColum;
import com.keyware.htey.mybatis.itf.OFourColumMapper; import com.keyware.htey.mybatis.itf.OFourColumMapper;
import com.keyware.htey.service.itf.AuditLogService;
import com.keyware.htey.service.itf.OFourColumService; import com.keyware.htey.service.itf.OFourColumService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -13,7 +14,8 @@ import org.springframework.stereotype.Service;
public class OFourColumServiceImpl extends ServiceImpl<OFourColumMapper, OFourColum> implements OFourColumService { public class OFourColumServiceImpl extends ServiceImpl<OFourColumMapper, OFourColum> implements OFourColumService {
@Autowired @Autowired
private OFourColumMapper oFourColumMapper; private OFourColumMapper oFourColumMapper;
@Autowired
private AuditLogService auditLogService;
@Override @Override
public OFourColum selectByPrimaryKey(String id) { public OFourColum selectByPrimaryKey(String id) {
// OFourColum oFourColum = jedisClientSingle.getObject(FOUR_COLUMN + id); // OFourColum oFourColum = jedisClientSingle.getObject(FOUR_COLUMN + id);

@ -5,6 +5,7 @@ import java.util.List;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.keyware.htey.entity.usersecret.UserSecret; import com.keyware.htey.entity.usersecret.UserSecret;
import com.keyware.htey.mybatis.itf.UsersecretMapper; import com.keyware.htey.mybatis.itf.UsersecretMapper;
import com.keyware.htey.service.itf.AuditLogService;
import com.keyware.htey.service.itf.UsersecretService; import com.keyware.htey.service.itf.UsersecretService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -15,7 +16,8 @@ import org.springframework.stereotype.Service;
public class UsersecretServiceImpl extends ServiceImpl<UsersecretMapper, UserSecret> implements UsersecretService { public class UsersecretServiceImpl extends ServiceImpl<UsersecretMapper, UserSecret> implements UsersecretService {
@Autowired @Autowired
private UsersecretMapper usersecretMapper; private UsersecretMapper usersecretMapper;
@Autowired
private AuditLogService auditLogService;
@Override @Override
public int insertSelective(UserSecret userSecret) { public int insertSelective(UserSecret userSecret) {
return this.usersecretMapper.insertSelective(userSecret); return this.usersecretMapper.insertSelective(userSecret);

@ -5,6 +5,10 @@ import java.util.List;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.keyware.htey.entity.department.Department; 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<Department> { public interface DepartmentService extends IService<Department> {
List<Department> selectByDeparmentName(String var1); List<Department> selectByDeparmentName(String var1);
@ -16,4 +20,22 @@ public interface DepartmentService extends IService<Department> {
List<Department> selectByDeparmentInfo(Department var1); List<Department> selectByDeparmentInfo(Department var1);
HashSet<String> selectByparentId(String var1); HashSet<String> selectByparentId(String var1);
List<Department> selectByDeparmentInfoSelect(Department var1);
int insertSelective(Department var1);
int updateByPrimaryKeySelective(Department record);
int deleteByPrimaryKey(List listId);
List<Department> 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<Department> departments);
} }

@ -2,9 +2,16 @@ package com.keyware.htey.service.itf;
import java.util.List; 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.baomidou.mybatisplus.extension.service.IService;
import com.keyware.htey.entity.user.User; import com.keyware.htey.entity.user.User;
import com.keyware.htey.utli.AjaxMessage;
import org.apache.ibatis.annotations.Param; 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<User> { public interface UserService extends IService<User> {
@ -50,4 +57,38 @@ public interface UserService extends IService<User> {
List<User> selectAllLogin(List<String> var1, String var2, @Param("userName") int userName, List<User> selectAllLogin(List<String> var1, String var2, @Param("userName") int userName,
@Param("pageNum") int pageNum); @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<User> users, String logOut);
String updateLock(List<User> users);
AjaxMessage updateStatus(List<User> users);
String deleteUser(List<User> users);
List<User> selectByUserInfo17suo(User user, int pageNum, int pageSize);
String PwdReset(@RequestParam String userIds);
Page<User> selectLogOutUser(String name, int pageNum, int pageSize);
List<User> userPwdResetList(String name, int pageNum, int pageSize);
String delPwdResetList(String userIds);
AjaxMessage edit(User user, HttpServletRequest request);
List<User> selectLoginList(String userNameForSerch, int pageNum, int pageSize);
String selectDepartUser(User user, String setDocumentDepartId);
} }

@ -4,6 +4,7 @@ import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import com.keyware.htey.entity.department.Department;
import com.keyware.htey.entity.user.User; import com.keyware.htey.entity.user.User;
/** /**
@ -13,17 +14,27 @@ import com.keyware.htey.entity.user.User;
* @date 2025/1/13 17:15 * @date 2025/1/13 17:15
*/ */
public class IdComposeListUtil { public class IdComposeListUtil {
public static List<String> listId(List<User> userList) { public static List<String> listUserId(List<User> userList) {
String userIds = stringId(userList); String userIds = stringUserId(userList);
return Arrays.asList(userIds.split(","));
}
public static List<String> listDepartmentId(List<Department> departmentList) {
String userIds = stringDepartmentListId(departmentList);
return Arrays.asList(userIds.split(",")); return Arrays.asList(userIds.split(","));
} }
public static String stringId(List<User> userList) { public static String stringUserId(List<User> userList) {
return userList.stream() return userList.stream()
.map(User::getId) .map(User::getId)
.map(String::valueOf) // 将ID转换为字符串 .map(String::valueOf) // 将ID转换为字符串
.collect(Collectors.joining(", ")); // 使用逗号分隔 .collect(Collectors.joining(", ")); // 使用逗号分隔
} }
public static String stringDepartmentListId(List<Department> userList) {
return userList.stream()
.map(Department::getId)
.map(String::valueOf) // 将ID转换为字符串
.collect(Collectors.joining(", ")); // 使用逗号分隔
}
public static List<String> listId(String Ids) { public static List<String> listId(String Ids) {
return Arrays.asList(Ids.split(",")); return Arrays.asList(Ids.split(","));

@ -79,7 +79,184 @@
select select
<include refid="Base_Column_List"/> <include refid="Base_Column_List"/>
from DEPARTMENT from DEPARTMENT
where PARENT_ID = #{parentId} where PROJECT_SOURCE=#{projectSource}
and PROJECT_SOURCE=#{projectSource} <if test="parentId != null and parentId != ''">
and PARENT_ID = #{parentId}
</if>
<if test="parentId == null and parentId == ''">
and PARENT_ID = #{parentId}
</if>
</select>
<select id="selectByDeparmentInfoSelect" parameterType="com.keyware.htey.entity.department.Department"
resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from DEPARTMENT
where 1=1
<if test="isSys != 'sysadmin'">
and IS_SYS = '0'
</if>
<if test="deptName != null and deptName != ''">
and DEPT_NAME = #{deptName,jdbcType=VARCHAR}
</if>
<if test="deptNumber != null and deptNumber != ''">
and DEPT_NUMBER = #{deptNumber,jdbcType=VARCHAR}
</if>
order by DEPT_CREATE_TIME DESC
</select> </select>
<insert id="insertSelective" parameterType="com.keyware.htey.entity.department.Department">
insert into DEPARTMENT
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
ID,
</if>
<if test="deptName != null">
DEPT_NAME,
</if>
<if test="parentId != null">
PARENT_ID,
</if>
<if test="orderNo != null">
ORDER_NO,
</if>
<if test="comments != null">
COMMENTS,
</if>
<if test="deptCreateTime != null">
DEPT_CREATE_TIME,
</if>
<if test="deptNumber != null">
DEPT_NUMBER,
</if>
<if test="manager != null">
MANAGER,
</if>
<if test="totalWorkers != null">
TOTAL_WORKERS,
</if>
<if test="superLeader != null">
SUPER_LEADER,
</if>
<if test="interfacePerson != null">
INTERFACE_PERSON,
</if>
<if test="departAbbrevia != null">
DEPART_ABBREVIA,
</if>
<if test="charge != null">
CHARGE,
</if>
<if test="isSys != null">
IS_SYS,
</if>
<if test="projectSource != null">
PROJECT_SOURCE,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=VARCHAR},
</if>
<if test="deptName != null">
#{deptName,jdbcType=VARCHAR},
</if>
<if test="parentId != null">
#{parentId,jdbcType=VARCHAR},
</if>
<if test="orderNo != null">
#{orderNo,jdbcType=DECIMAL},
</if>
<if test="comments != null">
#{comments,jdbcType=VARCHAR},
</if>
<if test="deptCreateTime != null">
#{deptCreateTime,jdbcType=VARCHAR},
</if>
<if test="deptNumber != null">
#{deptNumber,jdbcType=VARCHAR},
</if>
<if test="manager != null">
#{manager,jdbcType=VARCHAR},
</if>
<if test="totalWorkers != null">
#{totalWorkers,jdbcType=DECIMAL},
</if>
<if test="superLeader != null">
#{superLeader,jdbcType=VARCHAR},
</if>
<if test="interfacePerson != null">
#{interfacePerson,jdbcType=VARCHAR},
</if>
<if test="departAbbrevia != null">
#{departAbbrevia,jdbcType=VARCHAR},
</if>
<if test="charge != null">
#{charge,jdbcType=VARCHAR},
</if>
<if test="isSys != null">
#{isSys,jdbcType=VARCHAR},
</if>
<if test="projectSource != null">
#{projectSource,jdbcType=VARCHAR},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.keyware.htey.entity.department.Department">
update DEPARTMENT
<set>
<if test="deptName != null">
DEPT_NAME = #{deptName,jdbcType=VARCHAR},
</if>
<if test="parentId != null">
PARENT_ID = #{parentId,jdbcType=VARCHAR},
</if>
<if test="orderNo != null">
ORDER_NO = #{orderNo,jdbcType=DECIMAL},
</if>
<if test="comments != null">
COMMENTS = #{comments,jdbcType=VARCHAR},
</if>
<if test="deptCreateTime != null">
DEPT_CREATE_TIME = #{deptCreateTime,jdbcType=VARCHAR},
</if>
<if test="deptNumber != null">
DEPT_NUMBER = #{deptNumber,jdbcType=VARCHAR},
</if>
<if test="manager != null">
MANAGER = #{manager,jdbcType=VARCHAR},
</if>
<if test="totalWorkers != null">
TOTAL_WORKERS = #{totalWorkers,jdbcType=DECIMAL},
</if>
<if test="superLeader != null">
SUPER_LEADER = #{superLeader,jdbcType=VARCHAR},
</if>
<if test="interfacePerson != null">
INTERFACE_PERSON = #{interfacePerson,jdbcType=VARCHAR},
</if>
<if test="departAbbrevia != null">
DEPART_ABBREVIA = #{departAbbrevia,jdbcType=VARCHAR},
</if>
<if test="charge != null">
CHARGE = #{charge,jdbcType=VARCHAR},
</if>
<if test="isSys != null">
IS_SYS = #{isSys,jdbcType=VARCHAR},
</if>
<if test="projectSource != null">
PROJECT_SOURCE = #{projectSource,jdbcType=VARCHAR},
</if>
</set>
where ID = #{id,jdbcType=VARCHAR}
</update>
<delete id="deleteByPrimaryKey" parameterType="java.lang.String">
delete from DEPARTMENT
where ID in
<foreach item="item" index="index" collection="list"
open="(" separator="," close=")">
#{item}
</foreach>
</delete>
</mapper> </mapper>

@ -111,7 +111,11 @@
<if test="user.userNumber != null and user.userNumber != ''"> <if test="user.userNumber != null and user.userNumber != ''">
and K_USER.USER_NUMBER = #{user.userNumber,jdbcType=VARCHAR} and K_USER.USER_NUMBER = #{user.userNumber,jdbcType=VARCHAR}
</if> </if>
<if test="user.pageNum != null and user.pageNum != ''
and user.pageSize != null and user.pageSize != ''">
LIMIT #{user.pageNum},#{user.pageSize} LIMIT #{user.pageNum},#{user.pageSize}
</if>
order by SORT asc order by SORT asc
</select> </select>
@ -604,7 +608,7 @@
</if> </if>
</select> </select>
<select id="selectAllLogin" parameterType="java.lang.String" resultMap="BaseResultMap" > <select id="selectAllLogin" parameterType="java.lang.String" resultMap="BaseResultMap">
select select
K_USER.ID, K_USER.ID,
K_USER.USER_ID, K_USER.USER_ID,
@ -629,11 +633,62 @@
<if test="userNameForSerch != null and userNameForSerch != ''"> <if test="userNameForSerch != null and userNameForSerch != ''">
and (K_USER.USER_NAME like '%'||#{userNameForSerch,jdbcType=VARCHAR}||'%' ) and (K_USER.USER_NAME like '%'||#{userNameForSerch,jdbcType=VARCHAR}||'%' )
</if> </if>
and K_USER.ID in <foreach item="item" index="index" collection="list" and K_USER.ID in
<foreach item="item" index="index" collection="list"
open="(" separator="," close=")"> open="(" separator="," close=")">
#{item} #{item}
LIMIT #{pageNum},#{pageSize} LIMIT #{pageNum},#{pageSize}
</foreach> </foreach>
</select> </select>
<update id="updateByPrimaryKeySelective" parameterType="com.keyware.htey.entity.user.User">
update K_USER
<set>
<if test="userId != null">
USER_ID = #{userId,jdbcType=VARCHAR},
</if>
<if test="userName != null">
USER_NAME = #{userName,jdbcType=VARCHAR},
</if>
<if test="password != null">
PASSWORD = #{password,jdbcType=VARCHAR},
</if>
<if test="departId != null">
DEPART_ID = #{departId,jdbcType=VARCHAR},
</if>
<if test="userCreationTime != null">
USER_CREATION_TIME = #{userCreationTime,jdbcType=VARCHAR},
</if>
<if test="userPwdModifTime != null">
USER_PWD_MODIF_TIME = #{userPwdModifTime,jdbcType=VARCHAR},
</if>
<if test="userStatus != null">
USER_STATUS = #{userStatus,jdbcType=DECIMAL},
</if>
<if test="userLock != null">
USER_LOCK = #{userLock,jdbcType=DECIMAL},
</if>
<if test="userPwdError != null">
USER_PWD_ERROR = #{userPwdError,jdbcType=DECIMAL},
</if>
<if test="userPwdErrorDate != null">
USER_PWD_ERROR_DATE = #{userPwdErrorDate,jdbcType=VARCHAR},
</if>
<if test="logoutTime != null">
LOGOUT_TIME = #{logoutTime,jdbcType=VARCHAR},
</if>
<if test="uesrRankId != null">
UESR_RANK_ID = #{uesrRankId,jdbcType=VARCHAR},
</if>
<if test="uesrRankId != null">
UESR_RANK_ID = #{uesrRankId,jdbcType=VARCHAR},
</if>
<if test="imgData != null">
IMG_DATA = #{imgData,jdbcType=VARCHAR},
</if>
</set>
where ID = #{id,jdbcType=VARCHAR}
</update>
</mapper> </mapper>

Loading…
Cancel
Save