From ec839b84e76d9b7f2296f282b4c3f238b5fb4db3 Mon Sep 17 00:00:00 2001 From: admin <1094254749@qq.com> Date: Tue, 14 Jan 2025 15:31:19 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=A8=E6=88=B7=E7=AE=A1=E7=90=86=E4=B8=AD?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E5=88=97=E8=A1=A8=E5=8A=9F=E8=83=BD=E5=8C=85?= =?UTF-8?q?=E6=8B=AC=E9=A1=B5=E9=9D=A2=E5=88=9D=E5=A7=8B=E5=8C=96=EF=BC=8C?= =?UTF-8?q?=E6=9D=A1=E4=BB=B6=E6=9F=A5=E8=AF=A2=EF=BC=8C=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E4=BA=BA=E5=91=98=EF=BC=8C=E6=B3=A8=E9=94=80=E4=BA=BA=E5=91=98?= =?UTF-8?q?=EF=BC=8C=E5=AF=86=E7=A0=81=E9=87=8D=E7=BD=AE=EF=BC=8C=E6=89=B9?= =?UTF-8?q?=E9=87=8F=E5=AF=BC=E5=85=A5=EF=BC=8C=E4=BA=BA=E5=91=98=E7=9A=84?= =?UTF-8?q?=E8=A7=A3=E9=94=81=EF=BC=8C=E4=BA=BA=E5=91=98=E7=9A=84=E5=90=AF?= =?UTF-8?q?=E7=94=A8=EF=BC=8C=E4=BA=BA=E5=91=98=E7=9A=84=E7=A6=81=E7=94=A8?= =?UTF-8?q?=E4=BB=A5=EF=BC=8C=E9=A1=B5=E9=9D=A2=E4=B8=AD=E7=9A=84=E5=88=86?= =?UTF-8?q?=E9=A1=B5=EF=BC=8C=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6=E5=8F=98?= =?UTF-8?q?=E6=9B=B4=E6=95=B0=E6=8D=AE=E5=BA=93=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 32 + .../com/keyware/htey/HteyApplication.java | 2 + .../Department/DepartmentController.java | 104 ++++ .../Usersecret/UsersecretController.java | 41 ++ .../HumanResourceManagementController.java | 62 ++ .../organizeassets/OFourColumController.java | 40 ++ .../controller/user/AuditLogController.java | 47 ++ .../htey/controller/user/UserController.java | 399 ++++++++++++- .../htey/entity/department/Department.java | 31 + .../htey/entity/number/NumberBuilder.java | 18 + .../entity/organizeassets/OFourColum.java | 24 + .../keyware/htey/entity/user/AuditLog.java | 34 ++ .../com/keyware/htey/entity/user/User.java | 44 +- .../htey/entity/usersecret/Usersecret.java | 18 + .../htey/mybatis/itf/AuditLogMapper.java | 15 + .../htey/mybatis/itf/DepartmentMapper.java | 20 + .../htey/mybatis/itf/OFourColumMapper.java | 15 + .../keyware/htey/mybatis/itf/UserMapper.java | 23 + .../htey/mybatis/itf/UsersecretMapper.java | 15 + .../itf/number/NumberBuilderMapper.java | 20 + .../service/impl/AuditLogServiceImpl.java | 41 ++ .../service/impl/DepartmentServiceImpl.java | 29 + .../impl/NumberBuilderServiceImpl.java | 69 +++ .../service/impl/OFourColumServiceImpl.java | 17 + .../htey/service/impl/UserServiceImpl.java | 63 +- .../service/impl/UsersecretServiceImpl.java | 21 + .../htey/service/itf/AuditLogService.java | 8 + .../htey/service/itf/DepartmentService.java | 12 + .../htey/service/itf/OFourColumService.java | 8 + .../keyware/htey/service/itf/UserService.java | 22 + .../htey/service/itf/UsersecretService.java | 8 + .../itf/number/NumberBuilderService.java | 13 + .../com/keyware/htey/utli/AjaxMessage.java | 17 + .../java/com/keyware/htey/utli/Constant.java | 14 + .../java/com/keyware/htey/utli/DateUtils.java | 545 ++++++++++++++++++ .../com/keyware/htey/utli/EncryptUtil.java | 68 +++ .../com/keyware/htey/utli/ExcelUtils.java | 360 ++++++++++++ .../keyware/htey/utli/IdComposeListUtil.java | 26 + .../com/keyware/htey/utli/IdGenerator.java | 63 ++ .../java/com/keyware/htey/utli/IpUtil.java | 25 + .../java/com/keyware/htey/utli/JsonUtils.java | 135 +++++ src/main/resources/application.yml | 4 +- src/main/resources/mapper/AuditLogMapper.xml | 18 + .../resources/mapper/DepartmentMapper.xml | 42 ++ .../resources/mapper/OFourColumMapper.xml | 14 + src/main/resources/mapper/UserMapper.xml | 381 ++++++++++++ .../resources/mapper/UsersecretMapper.xml | 12 + .../mapper/number/NumberBuilderMapper.xml | 46 ++ 48 files changed, 3068 insertions(+), 17 deletions(-) create mode 100644 src/main/java/com/keyware/htey/controller/Department/DepartmentController.java create mode 100644 src/main/java/com/keyware/htey/controller/Usersecret/UsersecretController.java create mode 100644 src/main/java/com/keyware/htey/controller/humanResourceManagement/HumanResourceManagementController.java create mode 100644 src/main/java/com/keyware/htey/controller/organizeassets/OFourColumController.java create mode 100644 src/main/java/com/keyware/htey/controller/user/AuditLogController.java create mode 100644 src/main/java/com/keyware/htey/entity/department/Department.java create mode 100644 src/main/java/com/keyware/htey/entity/number/NumberBuilder.java create mode 100644 src/main/java/com/keyware/htey/entity/organizeassets/OFourColum.java create mode 100644 src/main/java/com/keyware/htey/entity/user/AuditLog.java create mode 100644 src/main/java/com/keyware/htey/entity/usersecret/Usersecret.java create mode 100644 src/main/java/com/keyware/htey/mybatis/itf/AuditLogMapper.java create mode 100644 src/main/java/com/keyware/htey/mybatis/itf/DepartmentMapper.java create mode 100644 src/main/java/com/keyware/htey/mybatis/itf/OFourColumMapper.java create mode 100644 src/main/java/com/keyware/htey/mybatis/itf/UsersecretMapper.java create mode 100644 src/main/java/com/keyware/htey/mybatis/itf/number/NumberBuilderMapper.java create mode 100644 src/main/java/com/keyware/htey/service/impl/AuditLogServiceImpl.java create mode 100644 src/main/java/com/keyware/htey/service/impl/DepartmentServiceImpl.java create mode 100644 src/main/java/com/keyware/htey/service/impl/NumberBuilderServiceImpl.java create mode 100644 src/main/java/com/keyware/htey/service/impl/OFourColumServiceImpl.java create mode 100644 src/main/java/com/keyware/htey/service/impl/UsersecretServiceImpl.java create mode 100644 src/main/java/com/keyware/htey/service/itf/AuditLogService.java create mode 100644 src/main/java/com/keyware/htey/service/itf/DepartmentService.java create mode 100644 src/main/java/com/keyware/htey/service/itf/OFourColumService.java create mode 100644 src/main/java/com/keyware/htey/service/itf/UsersecretService.java create mode 100644 src/main/java/com/keyware/htey/service/itf/number/NumberBuilderService.java create mode 100644 src/main/java/com/keyware/htey/utli/AjaxMessage.java create mode 100644 src/main/java/com/keyware/htey/utli/Constant.java create mode 100644 src/main/java/com/keyware/htey/utli/DateUtils.java create mode 100644 src/main/java/com/keyware/htey/utli/EncryptUtil.java create mode 100644 src/main/java/com/keyware/htey/utli/ExcelUtils.java create mode 100644 src/main/java/com/keyware/htey/utli/IdComposeListUtil.java create mode 100644 src/main/java/com/keyware/htey/utli/IdGenerator.java create mode 100644 src/main/java/com/keyware/htey/utli/IpUtil.java create mode 100644 src/main/java/com/keyware/htey/utli/JsonUtils.java create mode 100644 src/main/resources/mapper/AuditLogMapper.xml create mode 100644 src/main/resources/mapper/DepartmentMapper.xml create mode 100644 src/main/resources/mapper/OFourColumMapper.xml create mode 100644 src/main/resources/mapper/UserMapper.xml create mode 100644 src/main/resources/mapper/UsersecretMapper.xml create mode 100644 src/main/resources/mapper/number/NumberBuilderMapper.xml diff --git a/pom.xml b/pom.xml index daaeebc..124f4df 100644 --- a/pom.xml +++ b/pom.xml @@ -86,6 +86,38 @@ ojdbc8 19.8.0.0 + + commons-lang + commons-lang + 2.6 + + + com.alibaba + fastjson + 1.2.62 + + + com.keyware + HTEY + 0.0.1-SNAPSHOT + + + com.google.code.gson + gson + + + + + org.apache.poi + poi + 5.2.3 + + + + org.apache.poi + poi-ooxml + 5.2.3 + diff --git a/src/main/java/com/keyware/htey/HteyApplication.java b/src/main/java/com/keyware/htey/HteyApplication.java index ae7f2c8..9503628 100644 --- a/src/main/java/com/keyware/htey/HteyApplication.java +++ b/src/main/java/com/keyware/htey/HteyApplication.java @@ -1,9 +1,11 @@ package com.keyware.htey; +import org.mybatis.spring.annotation.MapperScan; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication +@MapperScan({"com.keyware.htey.mybatis.itf"}) public class HteyApplication { public static void main(String[] args) { diff --git a/src/main/java/com/keyware/htey/controller/Department/DepartmentController.java b/src/main/java/com/keyware/htey/controller/Department/DepartmentController.java new file mode 100644 index 0000000..ad74eee --- /dev/null +++ b/src/main/java/com/keyware/htey/controller/Department/DepartmentController.java @@ -0,0 +1,104 @@ +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.service.itf.DepartmentService; +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.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestBody; +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; + +/** + * @author daijj8 + * @version V1.0 + * @description 组织资产4列的所有数据 + * @Package com.keyware.htey.controller.user + * @date 2025/1/10 11:29 + */ +@Controller +@RequestMapping("/Department") +@Tag(name = "DEPARTMENT API", description = "部门表数据接口") +@Slf4j +public class DepartmentController { + @Autowired + private DepartmentService departmentService; + + @GetMapping("/selectById") + @ResponseBody + @Operation(summary = "部门表查询", description = "返回部门表信息") + @ApiResponse(responseCode = "200", description = "成功部门表信息") + public Department selectById(@RequestParam String id) { + return departmentService.getById(id); + } + + /** + * @author yangmengchuan + * @date 2025/1/7 + * @description 新增部门表 + */ + @RequestMapping( + value = {"/addDepartment"}, + method = {RequestMethod.POST}, + produces = {"application/json; charset=utf-8"} + ) + @ResponseBody + @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); + } + + /** + * @author yangmengchuan + * @date 2025/1/7 + * @description 修改部门 + */ + @RequestMapping( + value = {"/updateDepartment"}, + method = {RequestMethod.POST}, + produces = {"application/json; charset=utf-8"} + ) + @ResponseBody + @Operation(summary = "修改部门", description = "返回修改部门信息") + @ApiResponse(responseCode = "200", description = "成功修改部门信息") + public boolean updateDepartment(@RequestBody List departments) { + boolean flag = true; + for (Department department : departments) { + boolean update = departmentService.updateById(department); + if (!update) { + flag = false; + break; + } + } + return flag; + } + + /** + * @author yangmengchuan + * @date 2025/1/7 + * @description 根据id进行删除 + */ + @GetMapping("/deleteDepartment") + @ResponseBody + @Operation(summary = "根据id删除部门", description = "返回删除部门信息") + @ApiResponse(responseCode = "200", description = "成功删除部门信息") + public boolean deleteDepartment(@RequestParam String id) { + return departmentService.removeById(id); + } + +} diff --git a/src/main/java/com/keyware/htey/controller/Usersecret/UsersecretController.java b/src/main/java/com/keyware/htey/controller/Usersecret/UsersecretController.java new file mode 100644 index 0000000..95f5c8b --- /dev/null +++ b/src/main/java/com/keyware/htey/controller/Usersecret/UsersecretController.java @@ -0,0 +1,41 @@ +package com.keyware.htey.controller.Usersecret; + +import com.keyware.htey.entity.usersecret.Usersecret; +import com.keyware.htey.service.itf.UsersecretService; +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.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.ResponseBody; + +/** + * @author daijiajun + * @date 2025/1/7 + * @description 用户登录日志 + */ +@Controller +@RequestMapping("/usersecret") +@Slf4j +@Tag(name = "Usersecret API", description = "用户登录秘密管理接口") +public class UsersecretController { + @Autowired + private UsersecretService usersecretService; + + /** + * @author daijiajun + * @date 2025/1/7 + * @description 根据id获取用户信息 + */ + @GetMapping("/selectById") + @ResponseBody + @Operation(summary = "根据id查询秘密", description = "返回查询秘密信息") + @ApiResponse(responseCode = "200", description = "成功获取用户信息") + public Usersecret selectById(@RequestParam String id) { + return usersecretService.getById(id); + } +} diff --git a/src/main/java/com/keyware/htey/controller/humanResourceManagement/HumanResourceManagementController.java b/src/main/java/com/keyware/htey/controller/humanResourceManagement/HumanResourceManagementController.java new file mode 100644 index 0000000..ed3fb1f --- /dev/null +++ b/src/main/java/com/keyware/htey/controller/humanResourceManagement/HumanResourceManagementController.java @@ -0,0 +1,62 @@ +package com.keyware.htey.controller.humanResourceManagement; + +import com.keyware.htey.entity.user.AuditLog; +import com.keyware.htey.service.itf.AuditLogService; +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; +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; + +@Controller +@RequestMapping("/humanResourceManagement") +@Tag(name = "Excl API", description = "表格接口") +@Slf4j +public class HumanResourceManagementController { + @Autowired + private AuditLogService auditLogService; + + @RequestMapping(value = {"/analysisExcl"},method = {RequestMethod.POST},produces = {"application/json; charset=utf-8"}) + @ResponseBody + @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; + } +} diff --git a/src/main/java/com/keyware/htey/controller/organizeassets/OFourColumController.java b/src/main/java/com/keyware/htey/controller/organizeassets/OFourColumController.java new file mode 100644 index 0000000..97e10eb --- /dev/null +++ b/src/main/java/com/keyware/htey/controller/organizeassets/OFourColumController.java @@ -0,0 +1,40 @@ +package com.keyware.htey.controller.organizeassets; + +import com.keyware.htey.entity.organizeassets.OFourColum; +import com.keyware.htey.service.itf.OFourColumService; +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.beans.factory.annotation.Qualifier; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.ResponseBody; + +/** + * @author daijj8 + * @version V1.0 + * @description 组织资产4列的所有数据 + * @Package com.keyware.htey.controller.user + * @date 2025/1/10 11:29 + */ +@Controller +@RequestMapping("/oFourColum") +@Tag(name = "OFourColum API", description = "组织资产4列的所有数据接口") +@Slf4j +public class OFourColumController { + @Qualifier("newOFourColumService") + @Autowired + private OFourColumService oFourColumService; + + @GetMapping("/selectByUserInfo17suo") + @ResponseBody + @Operation(summary = "用户密级查询", description = "返回用户密级信息") + @ApiResponse(responseCode = "200", description = "成功用户密级信息") + public OFourColum selectOFourColumById(@RequestParam String id) { + return oFourColumService.getById(id); + } +} diff --git a/src/main/java/com/keyware/htey/controller/user/AuditLogController.java b/src/main/java/com/keyware/htey/controller/user/AuditLogController.java new file mode 100644 index 0000000..3d6563b --- /dev/null +++ b/src/main/java/com/keyware/htey/controller/user/AuditLogController.java @@ -0,0 +1,47 @@ +package com.keyware.htey.controller.user; + +import com.keyware.htey.entity.user.AuditLog; +import com.keyware.htey.service.itf.AuditLogService; +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.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestBody; +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; + +/** + * @author daijiajun + * @date 2025/1/7 + * @description 用户登录日志 + */ +@Controller +@RequestMapping("/auditLog") +@Slf4j +@Tag(name = "AuditLog API", description = "用户登录日志管理接口") +public class AuditLogController { + @Autowired + private AuditLogService auditLogService; + + /** + * @author daijiajun + * @date 2025/1/7 + * @description 新增用户登录日志 + */ + @RequestMapping( + value = {"/addAuditLog"}, + method = {RequestMethod.POST}, + produces = {"application/json; charset=utf-8"} + ) + @ResponseBody + @Operation(summary = "新增用户登录日志", description = "返回添加成功失败信息") + @ApiResponse(responseCode = "200", description = "成功用户登录日志信息") + public boolean addAuditLog(@RequestBody AuditLog auditLog) { + return auditLogService.save(auditLog); + } +} 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 f79d3a1..76eccbf 100644 --- a/src/main/java/com/keyware/htey/controller/user/UserController.java +++ b/src/main/java/com/keyware/htey/controller/user/UserController.java @@ -1,15 +1,38 @@ package com.keyware.htey.controller.user; +import java.util.Collections; +import java.util.Date; +import java.util.List; + +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.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.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; +import org.springframework.util.StringUtils; import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestBody; 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; @@ -20,10 +43,20 @@ import org.springframework.web.bind.annotation.ResponseBody; */ @Controller @RequestMapping("/user") +@Slf4j @Tag(name = "User API", description = "用户管理接口") public class UserController { @Autowired private UserService userService; + @Autowired + private AuditLogService auditLogService; + @Autowired + private NumberBuilderService numberBuilderService; + @Autowired + private DepartmentService departmentService; + @Autowired + private UsersecretService usersecretService; + /** * @author yangmengchuan * @date 2025/1/7 @@ -33,7 +66,8 @@ public class UserController { @ResponseBody @Operation(summary = "分页查询用户", description = "返回查询用户信息") @ApiResponse(responseCode = "200", description = "成功获取用户信息") - public Page selectAll(@RequestParam(defaultValue = "1") int pageNum,@RequestParam(defaultValue = "10") int pageSize){ + public Page selectAll(@RequestParam(defaultValue = "1") int pageNum, + @RequestParam(defaultValue = "10") int pageSize) { // 创建分页对象 Page pageParam = new Page<>(pageNum, pageSize); @@ -47,6 +81,7 @@ public class UserController { return userService.page(pageParam, queryWrapper);*/ return userService.page(pageParam); } + /** * @author yangmengchuan * @date 2025/1/7 @@ -56,33 +91,307 @@ public class UserController { @ResponseBody @Operation(summary = "根据id查询用户", description = "返回查询用户信息") @ApiResponse(responseCode = "200", description = "成功获取用户信息") - public User selectById(@RequestParam String id){ + public User selectById(@RequestParam String id) { return userService.getById(id); } + + @GetMapping("/viewInfo") + @ResponseBody + @Operation(summary = "根据id查询用户", 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); + } + /** * @author yangmengchuan * @date 2025/1/7 * @description 新增用户 */ - @GetMapping("/addUser") + @RequestMapping( + value = {"/add"}, + method = {RequestMethod.POST}, + produces = {"application/json; charset=utf-8"} + ) @ResponseBody @Operation(summary = "新增用户", description = "返回新增用户信息") @ApiResponse(responseCode = "200", description = "成功新增用户信息") - public boolean addUser(@RequestParam User user){ - return userService.save(user); + 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; } + /** * @author yangmengchuan * @date 2025/1/7 - * @description 修改用户 + * @description 用户注销 */ - @GetMapping("/updateUser") + @RequestMapping( + value = {"/updateLogout"}, + method = {RequestMethod.POST}, + produces = {"application/json; charset=utf-8"} + ) @ResponseBody - @Operation(summary = "修改用户", description = "返回修改用户信息") - @ApiResponse(responseCode = "200", description = "成功修改用户信息") - public boolean updateUser(@RequestParam User user){ - return userService.updateById(user); + @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.getUserId()); + 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 + * @date 2025/1/7 + * @description 解锁 + */ + @RequestMapping( + value = {"/updateLock"}, + method = {RequestMethod.POST}, + produces = {"application/json; charset=utf-8"} + ) + @ResponseBody + @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 "解锁成功"; + } + + /** + * @author yangmengchuan + * @date 2025/1/7 + * @description 启用禁用 + */ + @RequestMapping( + value = {"/updateStatus"}, + method = {RequestMethod.POST}, + produces = {"application/json; charset=utf-8"} + ) + @ResponseBody + @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; + } + /** * @author yangmengchuan * @date 2025/1/7 @@ -92,7 +401,73 @@ public class UserController { @ResponseBody @Operation(summary = "根据id删除用户", description = "返回删除用户信息") @ApiResponse(responseCode = "200", description = "成功删除用户信息") - public boolean deleteUser(@RequestParam String id){ + public boolean deleteUser(@RequestParam String id) { return userService.removeById(id); } + + @RequestMapping( + value = {"/select"}, + method = {RequestMethod.POST}, + produces = {"application/json; charset=utf-8"} + ) + @ResponseBody + @Operation(summary = "用户列表", description = "返回用户列表信息") + @ApiResponse(responseCode = "200", description = "成功用户列表信息") + public List selectByUserInfo17suo(User user, @RequestParam(defaultValue = "1") int pageNum, + @RequestParam(defaultValue = "10") int pageSize) { + user.setProjectSource(Constant.projectName); + user.setUserStatus(1L); + List userList = userService.selectByUserInfo17suo(user); + int startIndex = (pageNum - 1) * pageSize; + int endIndex = Math.min(startIndex + pageSize, userList.size()); + if (startIndex >= userList.size()) { + return Collections.emptyList(); // 如果起始索引超出列表范围,则返回空列表 + } else { + return userList.subList(startIndex, endIndex); + } + } + + /** + * @return null + * @description 密码重置 + * @Author daijj8 + * @Date 2025/1/13 17:50 + **/ + @GetMapping("/PwdReset") + @ResponseBody + @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 ("".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 "重置成功"; + } } diff --git a/src/main/java/com/keyware/htey/entity/department/Department.java b/src/main/java/com/keyware/htey/entity/department/Department.java new file mode 100644 index 0000000..798d01d --- /dev/null +++ b/src/main/java/com/keyware/htey/entity/department/Department.java @@ -0,0 +1,31 @@ +package com.keyware.htey.entity.department; + +import java.io.Serializable; + +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +@AllArgsConstructor +@TableName("DEPARTMENT") +public class Department implements Serializable { + private static final long serialVersionUID = -1292417487409772488L; + private String id; + private String deptName; + private String parentId; + private Integer orderNo; + private String comments; + private String deptCreateTime; + private String deptNumber; + private String manager; + private Integer totalWorkers; + private String superLeader; + private String interfacePerson; + private String departAbbrevia; + private String charge; + private String isSys; + private String projectSource; +} diff --git a/src/main/java/com/keyware/htey/entity/number/NumberBuilder.java b/src/main/java/com/keyware/htey/entity/number/NumberBuilder.java new file mode 100644 index 0000000..99e9f87 --- /dev/null +++ b/src/main/java/com/keyware/htey/entity/number/NumberBuilder.java @@ -0,0 +1,18 @@ +package com.keyware.htey.entity.number; + +import java.io.Serializable; + +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +@AllArgsConstructor +@TableName("NUMBER_BUILDER") +public class NumberBuilder implements Serializable { + private static final long serialVersionUID = -1292417487409772488L; + private String numberId; + private String number; +} diff --git a/src/main/java/com/keyware/htey/entity/organizeassets/OFourColum.java b/src/main/java/com/keyware/htey/entity/organizeassets/OFourColum.java new file mode 100644 index 0000000..fbd971d --- /dev/null +++ b/src/main/java/com/keyware/htey/entity/organizeassets/OFourColum.java @@ -0,0 +1,24 @@ +package com.keyware.htey.entity.organizeassets; + +import java.io.Serializable; + +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +@AllArgsConstructor +@TableName("KT_O_FOUR_COLUM") +public class OFourColum implements Serializable { + private static final long serialVersionUID = 1663815585294731536L; + private String id; + private String name; + private String code; + private String describe; + private String parentId; + private Integer seq; + private String formLevel; + private String isDefault; +} diff --git a/src/main/java/com/keyware/htey/entity/user/AuditLog.java b/src/main/java/com/keyware/htey/entity/user/AuditLog.java new file mode 100644 index 0000000..b6a27f0 --- /dev/null +++ b/src/main/java/com/keyware/htey/entity/user/AuditLog.java @@ -0,0 +1,34 @@ +package com.keyware.htey.entity.user; + +import java.io.Serializable; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +@AllArgsConstructor +@TableName("K_USER_AUDIT_LOG") +public class AuditLog implements Serializable { + private static final long serialVersionUID = -1292417487409772488L; + private String id; + private String logName; + private String logNameType; + private String userName; + private String deptName; + private String ipAddress; + private String operTime; + private String comments; + private String userId; + private String projectSource; + private String status; + @TableField(exist = false) + private String fileTime; + @TableField(exist = false) + private String startTime; + @TableField(exist = false) + private String endTime; +} diff --git a/src/main/java/com/keyware/htey/entity/user/User.java b/src/main/java/com/keyware/htey/entity/user/User.java index 64f0538..c039fd2 100644 --- a/src/main/java/com/keyware/htey/entity/user/User.java +++ b/src/main/java/com/keyware/htey/entity/user/User.java @@ -1,15 +1,57 @@ package com.keyware.htey.entity.user; +import java.io.Serializable; + +import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableName; +import lombok.AllArgsConstructor; import lombok.Data; +import lombok.NoArgsConstructor; -import java.io.Serializable; @Data +@NoArgsConstructor +@AllArgsConstructor @TableName("K_USER") public class User implements Serializable { + private static final long serialVersionUID = -1292417487409772488L; private String id; private String userId; private String userName; private String password; private String departId; + private String userCreationTime; + private String userPwdModifTime; + private Long userStatus; + private Long userLock; + private Long userPwdError; + private String userPwdErrorDate; + private String exitTime; + private String passwordOld; + private String post; + private String email; + private String officeTelephone; + private String userNumber; + private String idCard; + private String mobilePhone; + private Long sex; + private String homePhone; + private Long logout; + private String initPwdTime; + private String sort; + private String isSys; + private String logoutTime; + private String projectSource; + private String uesrRankId; + @TableField(exist = false) + private String deptName; + @TableField(exist = false) + private String userNameForSerch; + @TableField(exist = false) + private String flag; + @TableField(exist = false) + private String secret; + @TableField(exist = false) + private String ids; + @TableField(exist = false) + private String secretName; } diff --git a/src/main/java/com/keyware/htey/entity/usersecret/Usersecret.java b/src/main/java/com/keyware/htey/entity/usersecret/Usersecret.java new file mode 100644 index 0000000..ee3e96d --- /dev/null +++ b/src/main/java/com/keyware/htey/entity/usersecret/Usersecret.java @@ -0,0 +1,18 @@ +package com.keyware.htey.entity.usersecret; + +import java.io.Serializable; + +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +@AllArgsConstructor +@TableName("USERSECRET") +public class Usersecret implements Serializable { + private static final long serialVersionUID = -1292417487409772488L; + private String id; + private String secret; +} diff --git a/src/main/java/com/keyware/htey/mybatis/itf/AuditLogMapper.java b/src/main/java/com/keyware/htey/mybatis/itf/AuditLogMapper.java new file mode 100644 index 0000000..fdd045c --- /dev/null +++ b/src/main/java/com/keyware/htey/mybatis/itf/AuditLogMapper.java @@ -0,0 +1,15 @@ +package com.keyware.htey.mybatis.itf; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.keyware.htey.entity.user.AuditLog; +import org.apache.ibatis.annotations.Mapper; + +/** + * @author yangmengchuan + * @date 2025/1/7 + * @description 用户与数据库交互 + */ +@Mapper +public interface AuditLogMapper extends BaseMapper { + +} diff --git a/src/main/java/com/keyware/htey/mybatis/itf/DepartmentMapper.java b/src/main/java/com/keyware/htey/mybatis/itf/DepartmentMapper.java new file mode 100644 index 0000000..d558aba --- /dev/null +++ b/src/main/java/com/keyware/htey/mybatis/itf/DepartmentMapper.java @@ -0,0 +1,20 @@ +package com.keyware.htey.mybatis.itf; + +import java.util.List; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.keyware.htey.entity.department.Department; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +/** + * @author yangmengchuan + * @date 2025/1/7 + * @description 用户与数据库交互 + */ +@Mapper +public interface DepartmentMapper extends BaseMapper { + List selectByDeparmentName(@Param("deptName") String var1, @Param("projectSource") String var2); + + Department selectByPrimaryKey(String var1); +} diff --git a/src/main/java/com/keyware/htey/mybatis/itf/OFourColumMapper.java b/src/main/java/com/keyware/htey/mybatis/itf/OFourColumMapper.java new file mode 100644 index 0000000..9435091 --- /dev/null +++ b/src/main/java/com/keyware/htey/mybatis/itf/OFourColumMapper.java @@ -0,0 +1,15 @@ +package com.keyware.htey.mybatis.itf; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.keyware.htey.entity.organizeassets.OFourColum; +import org.apache.ibatis.annotations.Mapper; + +/** + * @author yangmengchuan + * @date 2025/1/7 + * @description 用户与数据库交互 + */ +@Mapper +public interface OFourColumMapper extends BaseMapper { + +} 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 7651e28..31361b3 100644 --- a/src/main/java/com/keyware/htey/mybatis/itf/UserMapper.java +++ b/src/main/java/com/keyware/htey/mybatis/itf/UserMapper.java @@ -1,8 +1,11 @@ package com.keyware.htey.mybatis.itf; +import java.util.List; + import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.keyware.htey.entity.user.User; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; /** * @author yangmengchuan @@ -11,4 +14,24 @@ import org.apache.ibatis.annotations.Mapper; */ @Mapper public interface UserMapper extends BaseMapper { + + List selectByUserInfo17suo(@Param("user") User user); + + int updateByPrimaryKey(User user); + + int unlock(List list); + + int updateStatus(User var1); + + List selectByUserId(@Param("userId") String var1, @Param("projectSource") String var2); + + List selectByUserNumber(@Param("userNumber") String var1, @Param("projectSource") String var2); + + List selectAll(@Param("userId") String var1, @Param("projectSource") String var2); + + int insertSelective(User var1); + + User selectByPrimaryKey(String var1); + + int recovery(List var1); } diff --git a/src/main/java/com/keyware/htey/mybatis/itf/UsersecretMapper.java b/src/main/java/com/keyware/htey/mybatis/itf/UsersecretMapper.java new file mode 100644 index 0000000..50389f2 --- /dev/null +++ b/src/main/java/com/keyware/htey/mybatis/itf/UsersecretMapper.java @@ -0,0 +1,15 @@ +package com.keyware.htey.mybatis.itf; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.keyware.htey.entity.usersecret.Usersecret; +import org.apache.ibatis.annotations.Mapper; + +/** + * @author yangmengchuan + * @date 2025/1/7 + * @description 用户与数据库交互 + */ +@Mapper +public interface UsersecretMapper extends BaseMapper { + int insertSelective(Usersecret var1); +} diff --git a/src/main/java/com/keyware/htey/mybatis/itf/number/NumberBuilderMapper.java b/src/main/java/com/keyware/htey/mybatis/itf/number/NumberBuilderMapper.java new file mode 100644 index 0000000..18d6196 --- /dev/null +++ b/src/main/java/com/keyware/htey/mybatis/itf/number/NumberBuilderMapper.java @@ -0,0 +1,20 @@ +package com.keyware.htey.mybatis.itf.number; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.keyware.htey.entity.number.NumberBuilder; +import org.apache.ibatis.annotations.Mapper; + +/** + * @author daijj8 + * @version V1.0 + * @Package com.keyware.htey.mybatis.itf.number + * @date 2025/1/14 9:32 + */ +@Mapper +public interface NumberBuilderMapper extends BaseMapper { + NumberBuilder selectByPrimaryKey(String var1); + + int insertSelective(NumberBuilder var1); + + int updateByPrimaryKeySelective(NumberBuilder 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 new file mode 100644 index 0000000..f36867f --- /dev/null +++ b/src/main/java/com/keyware/htey/service/impl/AuditLogServiceImpl.java @@ -0,0 +1,41 @@ +package com.keyware.htey.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.keyware.htey.entity.user.AuditLog; +import com.keyware.htey.mybatis.itf.AuditLogMapper; +import com.keyware.htey.service.itf.AuditLogService; +import com.keyware.htey.utli.Constant; +import com.keyware.htey.utli.DateUtils; +import com.keyware.htey.utli.IdGenerator; +import com.keyware.htey.utli.IpUtil; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +@Service +@Slf4j +public class AuditLogServiceImpl extends ServiceImpl implements AuditLogService { + @Autowired + private AuditLogMapper auditLogMapper; + + public boolean insertLog(AuditLog auditLog) { + //todo 登录人信息 + //String userName = (String)session.getAttribute("userName"); + //String departName = (String)session.getAttribute("departName"); + //String userId = (String)session.getAttribute("userId"); + auditLog.setId(IdGenerator.uuid32()); + auditLog.setOperTime(DateUtils.getDateTime()); + auditLog.setIpAddress(IpUtil.getLocalIP()); + //auditLog.setUserName(userName); + //auditLog.setDeptName(departName); + //auditLog.setUserId(userId); + return this.save(auditLog); + + } + + @Override + public boolean addAuditLog(AuditLog auditLog) { + auditLog.setProjectSource(Constant.projectName); + return insertLog(auditLog); + } +} diff --git a/src/main/java/com/keyware/htey/service/impl/DepartmentServiceImpl.java b/src/main/java/com/keyware/htey/service/impl/DepartmentServiceImpl.java new file mode 100644 index 0000000..7be82f0 --- /dev/null +++ b/src/main/java/com/keyware/htey/service/impl/DepartmentServiceImpl.java @@ -0,0 +1,29 @@ +package com.keyware.htey.service.impl; + +import java.util.List; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.keyware.htey.entity.department.Department; +import com.keyware.htey.mybatis.itf.DepartmentMapper; +import com.keyware.htey.service.itf.DepartmentService; +import com.keyware.htey.utli.Constant; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +@Service +@Slf4j +public class DepartmentServiceImpl extends ServiceImpl implements DepartmentService { + @Autowired + private DepartmentMapper departmentMapper; + + @Override + public List selectByDeparmentName(String deptName) { + return this.departmentMapper.selectByDeparmentName(deptName, Constant.projectName); + } + + @Override + public Department selectByPrimaryKey(String id) { + return this.departmentMapper.selectByPrimaryKey(id); + } +} diff --git a/src/main/java/com/keyware/htey/service/impl/NumberBuilderServiceImpl.java b/src/main/java/com/keyware/htey/service/impl/NumberBuilderServiceImpl.java new file mode 100644 index 0000000..c1be230 --- /dev/null +++ b/src/main/java/com/keyware/htey/service/impl/NumberBuilderServiceImpl.java @@ -0,0 +1,69 @@ +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.number.NumberBuilderService; +import com.keyware.htey.utli.Constant; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +/** + * @author daijj8 + * @version V1.0 + * @Package com.keyware.htey.service.impl + * @date 2025/1/14 9:24 + */ +@Service +public class NumberBuilderServiceImpl implements NumberBuilderService { + @Autowired + private NumberBuilderMapper numberBuilderMapper; + + @Override + public String getUserNumber() { + Integer userNumber = this.getNumber("user_code"); + NumberBuilder selectByPrimaryKey = this.numberBuilderMapper.selectByPrimaryKey("userCodePre"); + if (userNumber == 1) { + return selectByPrimaryKey != null ? selectByPrimaryKey.getNumber() + "0001" : Constant.RULE_NUMBER + "0001"; + } else { + return selectByPrimaryKey != null ? selectByPrimaryKey.getNumber() + this.getStringNumber(userNumber) + : Constant.RULE_NUMBER + this.getStringNumber(userNumber); + } + } + + public Integer getNumber(String codeType) { + NumberBuilder numberBuilder = this.numberBuilderMapper.selectByPrimaryKey(codeType); + if (numberBuilder == null) { + return "seq_code".equals(codeType) ? 2 : 1; + } else { + return Integer.valueOf(numberBuilder.getNumber()) + 1; + } + } + + private String getStringNumber(Integer number) { + String strNumber; + for (strNumber = number.toString(); strNumber.length() < 4; strNumber = "0" + strNumber) { + } + return strNumber; + } + + public Integer updateNumber(String codeType) { + NumberBuilder numberBuilder = this.numberBuilderMapper.selectByPrimaryKey(codeType); + if (numberBuilder == null) { + NumberBuilder numberBuilder2 = new NumberBuilder(); + if ("seq_code".equals(codeType)) { + numberBuilder2.setNumber("2"); + } else { + numberBuilder2.setNumber("1"); + } + + numberBuilder2.setNumberId(codeType); + this.numberBuilderMapper.insertSelective(numberBuilder2); + return "seq_code".equals(codeType) ? 2 : 1; + } else { + Integer codeValue = Integer.valueOf(numberBuilder.getNumber()) + 1; + numberBuilder.setNumber(codeValue.toString()); + this.numberBuilderMapper.updateByPrimaryKeySelective(numberBuilder); + return Integer.valueOf(numberBuilder.getNumber()); + } + } +} diff --git a/src/main/java/com/keyware/htey/service/impl/OFourColumServiceImpl.java b/src/main/java/com/keyware/htey/service/impl/OFourColumServiceImpl.java new file mode 100644 index 0000000..454ef4a --- /dev/null +++ b/src/main/java/com/keyware/htey/service/impl/OFourColumServiceImpl.java @@ -0,0 +1,17 @@ +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.OFourColumService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +@Service("newOFourColumService") +@Slf4j +public class OFourColumServiceImpl extends ServiceImpl implements OFourColumService { + @Autowired + private OFourColumMapper oFourColumMapper; + +} 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 8482150..f1789df 100644 --- a/src/main/java/com/keyware/htey/service/impl/UserServiceImpl.java +++ b/src/main/java/com/keyware/htey/service/impl/UserServiceImpl.java @@ -1,15 +1,74 @@ package com.keyware.htey.service.impl; +import java.util.List; + import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.keyware.htey.entity.user.User; import com.keyware.htey.mybatis.itf.UserMapper; import com.keyware.htey.service.itf.UserService; +import com.keyware.htey.utli.Constant; +import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -@Service("userService") -public class UserServiceImpl extends ServiceImpl implements UserService{ +@Service +@Slf4j +public class UserServiceImpl extends ServiceImpl implements UserService { @Autowired private UserMapper userMapper; + private static String projectName = "kdtr"; + + @Override + public List selectByUserInfo17suo(User user) { + user.setProjectSource(projectName); + user.setUserStatus(1L); + return userMapper.selectByUserInfo17suo(user); + } + + @Override + public int updateByPrimaryKey(User user) { + return this.userMapper.updateByPrimaryKey(user); + } + + @Override + public int unlock(List record) { + return this.userMapper.unlock(record); + } + + @Override + public int updateStatus(User user) { + return this.userMapper.updateStatus(user); + } + + @Override + public List selectByUserNumber(String userNumber) { + return this.userMapper.selectByUserNumber(userNumber, Constant.projectName); + } + + @Override + public int insert(User record) { + record.setProjectSource(Constant.projectName); + return this.userMapper.insert(record); + } + + @Override + public List selectAll(String userId) { + return this.userMapper.selectAll(userId, Constant.projectName); + } + + @Override + public int insertSelective(User record) { + record.setProjectSource(Constant.projectName); + return this.userMapper.insertSelective(record); + } + + @Override + public User selectByPrimaryKey(String id) { + return this.userMapper.selectByPrimaryKey(id); + } + @Override + public int recovery(List record) { + return this.userMapper.recovery(record); + } } diff --git a/src/main/java/com/keyware/htey/service/impl/UsersecretServiceImpl.java b/src/main/java/com/keyware/htey/service/impl/UsersecretServiceImpl.java new file mode 100644 index 0000000..5a8ea9b --- /dev/null +++ b/src/main/java/com/keyware/htey/service/impl/UsersecretServiceImpl.java @@ -0,0 +1,21 @@ +package com.keyware.htey.service.impl; + +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.UsersecretService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +@Service +@Slf4j +public class UsersecretServiceImpl extends ServiceImpl implements UsersecretService { + @Autowired + private UsersecretMapper usersecretMapper; + + @Override + public int insertSelective(Usersecret userSecret) { + return this.usersecretMapper.insertSelective(userSecret); + } +} diff --git a/src/main/java/com/keyware/htey/service/itf/AuditLogService.java b/src/main/java/com/keyware/htey/service/itf/AuditLogService.java new file mode 100644 index 0000000..ed8764e --- /dev/null +++ b/src/main/java/com/keyware/htey/service/itf/AuditLogService.java @@ -0,0 +1,8 @@ +package com.keyware.htey.service.itf; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.keyware.htey.entity.user.AuditLog; + +public interface AuditLogService extends IService { + public boolean addAuditLog(AuditLog auditLog); +} diff --git a/src/main/java/com/keyware/htey/service/itf/DepartmentService.java b/src/main/java/com/keyware/htey/service/itf/DepartmentService.java new file mode 100644 index 0000000..5ecc0b4 --- /dev/null +++ b/src/main/java/com/keyware/htey/service/itf/DepartmentService.java @@ -0,0 +1,12 @@ +package com.keyware.htey.service.itf; + +import java.util.List; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.keyware.htey.entity.department.Department; + +public interface DepartmentService extends IService { + List selectByDeparmentName(String var1); + + Department selectByPrimaryKey(String var1); +} diff --git a/src/main/java/com/keyware/htey/service/itf/OFourColumService.java b/src/main/java/com/keyware/htey/service/itf/OFourColumService.java new file mode 100644 index 0000000..2516232 --- /dev/null +++ b/src/main/java/com/keyware/htey/service/itf/OFourColumService.java @@ -0,0 +1,8 @@ +package com.keyware.htey.service.itf; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.keyware.htey.entity.organizeassets.OFourColum; + +public interface OFourColumService extends IService { + +} 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 66a3333..67d82d2 100644 --- a/src/main/java/com/keyware/htey/service/itf/UserService.java +++ b/src/main/java/com/keyware/htey/service/itf/UserService.java @@ -1,7 +1,29 @@ package com.keyware.htey.service.itf; +import java.util.List; + import com.baomidou.mybatisplus.extension.service.IService; import com.keyware.htey.entity.user.User; public interface UserService extends IService { + + List selectByUserInfo17suo(User user); + + int updateByPrimaryKey(User user); + + int unlock(List list); + + int updateStatus(User var1); + + List selectByUserNumber(String var1); + + int insert(User var1); + + List selectAll(String var1); + + int insertSelective(User var1); + + User selectByPrimaryKey(String var1); + + int recovery(List var1); } diff --git a/src/main/java/com/keyware/htey/service/itf/UsersecretService.java b/src/main/java/com/keyware/htey/service/itf/UsersecretService.java new file mode 100644 index 0000000..e98fb58 --- /dev/null +++ b/src/main/java/com/keyware/htey/service/itf/UsersecretService.java @@ -0,0 +1,8 @@ +package com.keyware.htey.service.itf; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.keyware.htey.entity.usersecret.Usersecret; + +public interface UsersecretService extends IService { + int insertSelective(Usersecret var1); +} diff --git a/src/main/java/com/keyware/htey/service/itf/number/NumberBuilderService.java b/src/main/java/com/keyware/htey/service/itf/number/NumberBuilderService.java new file mode 100644 index 0000000..94c6d7b --- /dev/null +++ b/src/main/java/com/keyware/htey/service/itf/number/NumberBuilderService.java @@ -0,0 +1,13 @@ +package com.keyware.htey.service.itf.number; + +/** + * @author daijj8 + * @version V1.0 + * @Package com.keyware.htey.service.itf.number + * @date 2025/1/14 9:23 + */ +public interface NumberBuilderService { + String getUserNumber(); + + Integer updateNumber(String var1); +} diff --git a/src/main/java/com/keyware/htey/utli/AjaxMessage.java b/src/main/java/com/keyware/htey/utli/AjaxMessage.java new file mode 100644 index 0000000..0083260 --- /dev/null +++ b/src/main/java/com/keyware/htey/utli/AjaxMessage.java @@ -0,0 +1,17 @@ +package com.keyware.htey.utli; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class AjaxMessage { + private static final long serialVersionUID = 1680802699076731536L; + private String code; + private String message; + private String data; + private String token; + +} diff --git a/src/main/java/com/keyware/htey/utli/Constant.java b/src/main/java/com/keyware/htey/utli/Constant.java new file mode 100644 index 0000000..49a533e --- /dev/null +++ b/src/main/java/com/keyware/htey/utli/Constant.java @@ -0,0 +1,14 @@ +package com.keyware.htey.utli; + +/** + * @author daijj8 + * @version V1.0 + * @Package com.keyware.htey.utli + * @date 2025/1/13 14:54 + */ +public class Constant { + public static String projectName = "kdtr"; + public static String RULE_NUMBER = "kw"; + public static Integer userCount = 0; + public static String ERROE_MESSAGE = "系统错误,请联系管理员"; +} diff --git a/src/main/java/com/keyware/htey/utli/DateUtils.java b/src/main/java/com/keyware/htey/utli/DateUtils.java new file mode 100644 index 0000000..c4c8552 --- /dev/null +++ b/src/main/java/com/keyware/htey/utli/DateUtils.java @@ -0,0 +1,545 @@ +// +// Source code recreated from a .class file by IntelliJ IDEA +// (powered by FernFlower decompiler) +// + +package com.keyware.htey.utli; + +import java.text.DateFormat; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Calendar; +import java.util.Date; +import java.util.GregorianCalendar; +import java.util.Iterator; +import java.util.Locale; +import java.util.Map; +import java.util.Set; +import java.util.TreeMap; + +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang.time.DateFormatUtils; + +@Slf4j +public class DateUtils extends org.apache.commons.lang.time.DateUtils { + private static GregorianCalendar gc; + private static String[] parsePatterns; + public static String DEFAULT_DATE_FORMAT; + + public DateUtils() { + } + + public static String getDate() { + return getDate("yyyy-MM-dd"); + } + + public static String getDate(String pattern) { + return DateFormatUtils.format(new Date(), pattern); + } + + public static String formatDate(Date date, Object[] pattern) { + String formatDate = null; + if (pattern != null && pattern.length > 0) { + formatDate = DateFormatUtils.format(date, pattern[0].toString()); + } else { + formatDate = DateFormatUtils.format(date, "yyyy-MM-dd"); + } + + return formatDate; + } + + public static String formatDateTime(Date date) { + return formatDate(date, new Object[] {"yyyy-MM-dd HH:mm:ss"}); + } + + public static String getTime() { + return formatDate(new Date(), new Object[] {"HH:mm:ss"}); + } + + public static String getDateTime() { + return formatDate(new Date(), new Object[] {"yyyy-MM-dd HH:mm:ss"}); + } + + public static String getYear() { + return formatDate(new Date(), new Object[] {"yyyy"}); + } + + public static String getMonth() { + return formatDate(new Date(), new Object[] {"MM"}); + } + + public static String getDay() { + return formatDate(new Date(), new Object[] {"dd"}); + } + + public static String getWeek() { + return formatDate(new Date(), new Object[] {"E"}); + } + + public static Date parseDate(Object str) { + if (str == null) { + return null; + } else { + try { + return parseDate(str.toString(), parsePatterns); + } catch (Exception var2) { + log.error("日期转换失败", var2); + return null; + } + } + } + + public static long pastDays(Date date) { + long t = (new Date()).getTime() - date.getTime(); + return t / 86400000L; + } + + public static Date getDateStart(Date date) { + if (date == null) { + return null; + } else { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + + try { + date = sdf.parse(formatDate(date, new Object[] {"yyyy-MM-dd"}) + " 00:00:00"); + } catch (ParseException var3) { + log.error("获取日期失败", var3); + var3.printStackTrace(); + } + + return date; + } + } + + public static Date getDateEnd(Date date) { + if (date == null) { + return null; + } else { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + + try { + date = sdf.parse(formatDate(date, new Object[] {"yyyy-MM-dd"}) + " 23:59:59"); + } catch (ParseException var3) { + log.error("获取日期失败", var3); + var3.printStackTrace(); + } + + return date; + } + } + + public static Date getCurrentDate() { + Date date = new Date(System.currentTimeMillis()); + return date; + } + + public static int getCurrentTime(TimeFormatType timeFormatType) { + return getTime(getCurrentDate(), timeFormatType); + } + + public static int getTime(Date date, TimeFormatType timeFormatType) { + try { + Calendar c = Calendar.getInstance(); + c.setTime(date); + int type = timeFormatType.getValue(); + int i = c.get(type); + return type == 2 ? i + 1 : i; + } catch (Exception var5) { + log.error("获取日期失败", var5); + throw new RuntimeException("获取失败", var5); + } + } + + public static long getMillis(Date date) { + Calendar c = Calendar.getInstance(); + c.setTime(date); + return c.getTimeInMillis(); + } + + public static int operationDate(Date date, Date diffDate, DateOperationType dateOperationType) { + long add = getMillis(date) + getMillis(diffDate); + long diff = getMillis(date) - getMillis(diffDate); + return (int)((dateOperationType.getValue() ? add : diff) / 86400000L); + } + + public static Date operationDateOfMonth(Date date, int month, DateOperationType dateOperationType) { + Calendar c = Calendar.getInstance(); + c.setTime(date); + c.add(2, dateOperationType.getValue() ? month : month - month * 2); + return c.getTime(); + } + + public static Date operationDateOfDay(Date date, int day, DateOperationType dateOperationType) { + Calendar c = Calendar.getInstance(); + c.setTime(date); + long millis = c.getTimeInMillis(); + long millisOfday = (long)(day * 24 * 3600 * 1000); + long sumMillis = dateOperationType.getValue() ? millis + millisOfday : millis - millisOfday; + c.setTimeInMillis(sumMillis); + return c.getTime(); + } + + private static Object OpearationDate(Object object, String formatStr) { + if (object != null && null != formatStr && !"".equals(formatStr)) { + SimpleDateFormat format = new SimpleDateFormat(formatStr); + + try { + return object instanceof Date ? format.format(object) : format.parse(object.toString()); + } catch (Exception var4) { + log.error("操作失败", var4); + throw new RuntimeException("操作失败", var4); + } + } else { + throw new RuntimeException("参数不能为空"); + } + } + + public static Date getLastWorkDay(Date curDate, int n) { + Date endDate = curDate; + + for (int i = 0; i < n; ++i) { + endDate = new Date(endDate.getTime() - 86400000L); + int day_of_week = getDayOfWeek(endDate); + if (day_of_week == 1) { + endDate = new Date(endDate.getTime() - 172800000L); + } else if (day_of_week == 7) { + endDate = new Date(endDate.getTime() - 86400000L); + } + } + + return endDate; + } + + public static Integer getDayOfWeek(Date date) { + Calendar cal = new GregorianCalendar(); + cal.setTime(date); + return cal.get(7); + } + + private static void initCalendar(Date date) { + if (date == null) { + throw new IllegalArgumentException("argument date must be not null"); + } else { + gc.clear(); + gc.setTime(date); + } + } + + public static Date getAfterDate(Date date, int days) { + initCalendar(date); + gc.set(6, gc.get(6) + days); + return gc.getTime(); + } + + public static boolean before(String first, String second) { + SimpleDateFormat dfs = new SimpleDateFormat("yyyy-MM-dd"); + Date a = null; + Date b = null; + + try { + a = dfs.parse(first); + b = dfs.parse(second); + } catch (ParseException var6) { + log.error("操作失败", var6); + var6.printStackTrace(); + } + + return a.before(b); + } + + public static final String getDateStr(Date aDate) { + SimpleDateFormat df = null; + String returnValue = ""; + if (aDate != null) { + df = new SimpleDateFormat(parsePatterns[0]); + returnValue = df.format(aDate); + } + + return returnValue; + } + + public static final String getTimeStr(Date aDate) { + SimpleDateFormat df = null; + String returnValue = ""; + if (aDate != null) { + df = new SimpleDateFormat(parsePatterns[1]); + returnValue = df.format(aDate); + } + + return returnValue; + } + + public static Date convertStringToDate(String strDate) { + Date aDate = null; + + try { + String pattern = "\\d{4}[-|/]\\d{2}[-|/]\\d{2}[ ]\\d{2}[:]\\d{2}[:]\\d{2}"; + if (strDate.matches(pattern)) { + if (strDate.contains("/")) { + aDate = convertStringToDate("yyyy/MM/dd HH:mm:ss", strDate); + } else { + aDate = convertStringToDate(parsePatterns[1], strDate); + } + } else if (strDate.contains("/")) { + aDate = convertStringToDate("yyyy/MM/dd", strDate); + } else { + aDate = convertStringToDate(parsePatterns[0], strDate); + } + } catch (ParseException var3) { + log.error("操作失败", var3); + log.error("Could not convert '" + strDate + "' to a date, throwing exception"); + var3.printStackTrace(); + } + + return aDate; + } + + public static final Date convertStringToDate(String aMask, String strDate) throws ParseException { + SimpleDateFormat df = null; + Date date = null; + df = new SimpleDateFormat(aMask); + + try { + date = df.parse(strDate); + return date; + } catch (ParseException var5) { + log.error("日期转换失败", var5); + throw new ParseException(var5.getMessage(), var5.getErrorOffset()); + } + } + + public static final String getTimeStr(String format, Date aDate) { + SimpleDateFormat df = null; + String returnValue = ""; + if (aDate != null) { + df = new SimpleDateFormat(format); + returnValue = df.format(aDate); + } + + return returnValue; + } + + public static String beforNumDay(Date date, int day) { + Calendar c = Calendar.getInstance(); + c.setTime(date); + c.add(6, day); + return (new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")).format(c.getTime()); + } + + public static String strToDate(String strDate) { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + return sdf.format(new Date(Long.parseLong(strDate))); + } + + public static String formatTime(Date date, String formats) { + if (StringUtils.isEmpty(formats)) { + formats = "yyyy-MM-dd HH:mm:ss"; + } + + String time = ""; + DateFormat format = new SimpleDateFormat(formats); + if (date != null) { + time = format.format(date); + return time; + } else { + throw new RuntimeException("Empty date!"); + } + } + + public static long betweenDays(String startDate, String endDate) throws ParseException { + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); + Date enddate = simpleDateFormat.parse(endDate); + Date startdate = simpleDateFormat.parse(startDate); + Calendar cal = Calendar.getInstance(); + cal.setTime(enddate); + long endTime = cal.getTimeInMillis(); + cal.setTime(startdate); + long startTime = cal.getTimeInMillis(); + long between_days = (endTime - startTime) / 86400000L; + return between_days; + } + + public static long betweenSecond(String startDate, String endDate) throws ParseException { + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + Date enddate = simpleDateFormat.parse(endDate); + Date startdate = simpleDateFormat.parse(startDate); + Calendar cal = Calendar.getInstance(); + cal.setTime(enddate); + long endTime = cal.getTimeInMillis(); + cal.setTime(startdate); + long startTime = cal.getTimeInMillis(); + long between_second = (endTime - startTime) / 1000L; + return between_second; + } + + public static String getDateTimeInt() { + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMddHHmmss"); + String dateTime = simpleDateFormat.format(new Date()).trim(); + return dateTime; + } + + public static String[] getTimeInterval(Date date) { + String[] date1 = new String[2]; + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + Calendar cal = Calendar.getInstance(); + cal.setTime(date); + int dayWeek = cal.get(7); + if (1 == dayWeek) { + cal.add(5, -1); + } + + System.out.println("要计算日期为:" + sdf.format(cal.getTime())); + cal.setFirstDayOfWeek(2); + int day = cal.get(7); + cal.add(5, cal.getFirstDayOfWeek() - day); + String imptimeBegin = sdf.format(cal.getTime()); + System.out.println("所在周星期一的日期:" + imptimeBegin); + cal.add(5, 6); + String imptimeEnd = sdf.format(cal.getTime()); + System.out.println("所在周星期日的日期:" + imptimeEnd); + date1[0] = imptimeBegin; + date1[1] = imptimeEnd; + return date1; + } + + private static String[] showResult(String[] dateArray) { + Map dateMap = new TreeMap(); + int arrayLen = dateArray.length; + + for (int i = 0; i < arrayLen; ++i) { + String dateKey = dateArray[i]; + if (dateMap.containsKey(dateKey)) { + int value = (Integer)dateMap.get(dateKey) + 1; + dateMap.put(dateKey, value); + } else { + dateMap.put(dateKey, 1); + } + } + + Set keySet = dateMap.keySet(); + String[] sorttedArray = new String[keySet.size()]; + Iterator iter = keySet.iterator(); + + String key; + for (int index = 0; iter.hasNext(); sorttedArray[index++] = key) { + key = (String)iter.next(); + } + + int sorttedArrayLen = sorttedArray.length; + System.out.println("最小日期是:" + sorttedArray[0] + ", 天数为" + dateMap.get(sorttedArray[0])); + System.out.println("最大日期是:" + sorttedArray[sorttedArrayLen - 1] + ", 天数为" + dateMap.get( + sorttedArray[sorttedArrayLen - 1])); + return new String[] {sorttedArray[0], sorttedArray[sorttedArrayLen - 1]}; + } + + public static int countTwoDayWeek(Date startDate, Date endDate) { + String[] startWeek = getTimeInterval(startDate); + String[] endWeek = getTimeInterval(endDate); + SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); + Calendar cal = Calendar.getInstance(); + + try { + cal.setTime(dateFormat.parse(startWeek[0])); + long time1 = cal.getTimeInMillis(); + cal.setTime(dateFormat.parse(endWeek[1])); + long time2 = cal.getTimeInMillis(); + long between_days = (time2 - time1) / 86400000L; + Double days = Double.parseDouble(String.valueOf(between_days)); + if (days / 7.0 > 0.0 && days / 7.0 <= 1.0) { + return 1; + } else if (days / 7.0 > 1.0) { + int day = days.intValue(); + return day % 7 > 0 ? day / 7 + 1 : day / 7; + } else { + return days / 7.0 == 0.0 ? 0 : 0; + } + } catch (Exception var14) { + log.error("日期计算失败", var14); + var14.printStackTrace(); + return 0; + } + } + + public static long calculateTimeDifferenceByCalendar(String startDate, String endDate) { + if (startDate != null && endDate != null) { + DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm"); + + try { + Date d1 = df.parse(startDate); + Date d2 = df.parse(endDate); + long diff = d2.getTime() - d1.getTime(); + long min = diff / 60000L; + return min; + } catch (Exception var9) { + log.error("计算两个日期相差多少分钟时出错!", var9); + var9.printStackTrace(); + return 0L; + } + } else { + return 0L; + } + } + + static { + gc = new GregorianCalendar(Locale.CHINA); + DEFAULT_DATE_FORMAT = "yyyy-MM-dd"; + gc.setLenient(true); + gc.setFirstDayOfWeek(2); + parsePatterns = new String[] {"yyyy-MM-dd", "yyyy-MM-dd HH:mm:ss", "yyyy-MM-dd HH:mm", "yyyy/MM/dd", + "yyyy/MM/dd HH:mm:ss", "yyyy/MM/dd HH:mm"}; + } + + public static enum DateOperationType { + ADD(true), + DIFF(false); + + private final boolean value; + + private DateOperationType(boolean operation) { + this.value = operation; + } + + public boolean getValue() { + return this.value; + } + } + + public static enum TimeFormatType { + YEAR(1), + MONTH(2), + DAY(5), + HOUR(11), + MINUTE(12), + SECOND(13); + + private final int value; + + private TimeFormatType(int formatStr) { + this.value = formatStr; + } + + public int getValue() { + return this.value; + } + } + + public static enum DateFormatType { + DATE_FORMAT_STR("yyyy-MM-dd HH:mm:ss"), + SIMPLE_DATE_TIME_FORMAT_STR("yyyyMMddHHmmss"), + SIMPLE_DATE_FORMAT_STR("yyyy-MM-dd"), + SIMPLE_DATE_FORMAT_VIRGULE_STR("yyyy/MM/dd"), + HOUR_MINUTE_SECOND("HH:mm:ss"), + HOUR_MINUTE("HH:mm"); + + private final String value; + + private DateFormatType(String formatStr) { + this.value = formatStr; + } + + public String getValue() { + return this.value; + } + } +} diff --git a/src/main/java/com/keyware/htey/utli/EncryptUtil.java b/src/main/java/com/keyware/htey/utli/EncryptUtil.java new file mode 100644 index 0000000..52d1d9d --- /dev/null +++ b/src/main/java/com/keyware/htey/utli/EncryptUtil.java @@ -0,0 +1,68 @@ +package com.keyware.htey.utli; + +import java.security.MessageDigest; + +import lombok.extern.slf4j.Slf4j; + +/** + * @author daijj8 + * @version V1.0 + * @Package com.keyware.htey.utli + * @date 2025/1/13 16:46 + */ +@Slf4j +public class EncryptUtil { + + public EncryptUtil() { + } + + public static String md5AndSha(String inputText) { + return sha(md5(inputText)); + } + + public static String md5(String inputText) { + return encrypt(inputText, "md5"); + } + + public static String sha(String inputText) { + return encrypt(inputText, "sha-1"); + } + + private static String encrypt(String inputText, String algorithmName) { + if (inputText != null && !"".equals(inputText.trim())) { + if (algorithmName == null || "".equals(algorithmName.trim())) { + algorithmName = "md5"; + } + + String encryptText = null; + + try { + MessageDigest m = MessageDigest.getInstance(algorithmName); + m.update(inputText.getBytes("UTF8")); + byte[] s = m.digest(); + return hex(s); + } catch (Exception var6) { + log.error("操作失败", var6); + var6.printStackTrace(); + } + + return encryptText; + } else { + throw new IllegalArgumentException("请输入要加密的内容"); + } + } + + private static String hex(byte[] arr) { + StringBuffer sb = new StringBuffer(); + + for (byte b : arr) { + sb.append(Integer.toHexString(b & 255 | 256).substring(1, 3)); + } + + return sb.toString(); + } + + public static void main(String[] args) { + System.out.println(md5("123456")); + } +} diff --git a/src/main/java/com/keyware/htey/utli/ExcelUtils.java b/src/main/java/com/keyware/htey/utli/ExcelUtils.java new file mode 100644 index 0000000..3232b63 --- /dev/null +++ b/src/main/java/com/keyware/htey/utli/ExcelUtils.java @@ -0,0 +1,360 @@ +package com.keyware.htey.utli; + +import java.util.ArrayList; +import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +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.UserMapper; +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.number.NumberBuilderService; +import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.usermodel.CellType; +import org.apache.poi.ss.usermodel.DateUtil; +import org.apache.poi.ss.usermodel.Row; +import org.apache.poi.ss.usermodel.Sheet; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.util.StringUtils; + +/** + * @author daijj8 + * @version V1.0 + * @Package com.keyware.htey.utli + * @date 2025/1/14 8:51 + */ +public class ExcelUtils { + @Autowired + private UserMapper userMapper; + @Autowired + private UserService userService; + @Autowired + private DepartmentService departmentService; + @Autowired + private NumberBuilderService numberBuilderService; + @Autowired + private AuditLogService auditLogService; + + public static void checkFirstRowName(AjaxMessage ajaxMessage, Sheet sheet) { + Row row = sheet.getRow(0); + List columnName = new ArrayList(); + columnName.add("用户账号*"); + //if ("huayin".equals(customer)) { + // columnName.add("用户编号*"); + //} else { + columnName.add("员工编号*"); + //} + + columnName.add("姓名*"); + //if ("huayin".equals(customer)) { + // columnName.add("证件"); + //} else { + columnName.add("身份证号码"); + //} + + columnName.add("所属部门"); + columnName.add("电子邮件"); + columnName.add("性别"); + columnName.add("手机"); + columnName.add("办公电话"); + columnName.add("家庭电话"); + columnName.add("职务"); + if (null == row) { + ajaxMessage.setCode("0"); + ajaxMessage.setMessage("上传文档与批量导入平台用户的标准模板不一致,请下载excel模板进行编辑。"); + } else { + for (int i = 0; i < columnName.size(); ++i) { + Cell cell = row.getCell(i); + String cellValue = getCellValue(cell); + cellValue = cellValue.replaceAll(" ", ""); + if (!((String)columnName.get(i)).equals(cellValue)) { + ajaxMessage.setCode("0"); + ajaxMessage.setMessage("上传文档与批量导入平台用户的标准模板不一致,请下载excel模板进行编辑。"); + break; + } + } + } + } + + private static String getCellValue(org.apache.poi.ss.usermodel.Cell cell) { + String cellValue = ""; + if (cell == null) { + return cellValue; + } else { + try { + switch (cell.getCellType()) { + case NUMERIC: + if (DateUtil.isCellDateFormatted(cell)) { + cellValue = DateUtils.formatDateTime(cell.getDateCellValue()); + } else { + cell.setCellType(CellType.NUMERIC); + cellValue = String.valueOf(cell.getNumericCellValue()); + } + break; + case STRING: + cellValue = cell.getStringCellValue(); + break; + case FORMULA: + cell.setCellType(CellType.FORMULA); + cellValue = String.valueOf(cell.getCellFormula()); + break; + case BLANK: + cellValue = ""; + break; + case BOOLEAN: + cellValue = String.valueOf(cell.getBooleanCellValue()); + break; + case ERROR: + cellValue = "错误"; + break; + default: + cellValue = ""; + } + } catch (Exception e) { + e.printStackTrace(); + } + return cellValue; + } + } + + public String insertUser(AuditLog auditLog, Sheet sheet) { + int inserted = 0; + int skip = 0; + String userNames = ""; + int rowNum = sheet.getPhysicalNumberOfRows(); + List userList = new ArrayList(); + List userList3 = new ArrayList(); + List userList4 = new ArrayList(); + List userList5 = new ArrayList(); + + int i; + Row row; + String userId; + String userNumber; + for (i = 1; i < rowNum; ++i) { + row = sheet.getRow(i); + if (null == row) { + return "导入失败:请在中间空白行输入必填项"; + } + + userId = this.getCellValue(row.getCell(0)); + userNumber = this.getCellValue(row.getCell(1)); + userList.add(userId); + userList4.add(userNumber); + } + + int j; + for (i = 0; i < userList.size() - 1; ++i) { + for (j = userList.size() - 1; j > i; --j) { + if (((String)userList.get(j)).equals(userList.get(i))) { + userList3.add(userList.get(j)); + } + } + } + + for (i = 0; i < userList4.size() - 1; ++i) { + for (j = userList4.size() - 1; j > i; --j) { + if (((String)userList4.get(j)).equals(userList4.get(i))) { + userList5.add(userList4.get(j)); + } + } + } + + String userName; + String idCard; + String email; + String mobilePhone; + String officeTelephone; + String homePhone; + String regEx; + for (i = 1; i < rowNum; ++i) { + row = sheet.getRow(i); + userId = this.getCellValue(row.getCell(0)); + userNumber = this.getCellValue(row.getCell(1)); + userName = this.getCellValue(row.getCell(2)); + int var29; + if ("".equals(userId) && "".equals(userName) && "".equals(userNumber)) { + var29 = skip + 1; + return "导入失败:必填项不能为空"; + } + + if (!StringUtils.hasText(userId)) { + var29 = skip + 1; + return "导入失败:登录账号不能为空"; + } + + if ("".equals(userNumber)) { + var29 = skip + 1; + return "导入失败:员工编号不能为空"; + } + + if ("".equals(userName)) { + var29 = skip + 1; + return "导入失败:姓名不能为空"; + } + + idCard = this.getCellValue(row.getCell(3)); + email = this.getCellValue(row.getCell(5)); + mobilePhone = this.getCellValue(row.getCell(7)); + officeTelephone = this.getCellValue(row.getCell(8)); + homePhone = this.getCellValue(row.getCell(9)); + String post = this.getCellValue(row.getCell(10)); + if (userId.length() > 25 || userNumber.length() > 20 || userName.length() > 25 || email.length() > 100 + || officeTelephone.length() > 50 || homePhone.length() > 50 || post.length() > 50) { + var29 = skip + 1; + return "导入失败:输入信息长度入有误"; + } + + if (StringUtils.hasText(officeTelephone) && officeTelephone.length() < 2) { + var29 = skip + 1; + return "导入失败:办公电话输入长度有误"; + } + + if (StringUtils.hasText(homePhone) && homePhone.length() < 2) { + var29 = skip + 1; + return "导入失败:家庭电话输入长度有误"; + } + + Pattern pattern; + Matcher matcher; + boolean rs; + + if (StringUtils.hasText(userId)) { + regEx = "[0-9a-zA-Z\\_\\-\\(\\)]+"; + pattern = Pattern.compile(regEx); + matcher = pattern.matcher(userId); + rs = matcher.matches(); + if (!rs) { + var29 = skip + 1; + return "导入失败:账号" + userId + "输入有误"; + } + } + + User user = new User(); + user.setUserId(userId); + List selectByUserId = userMapper.selectByUserId(userId, Constant.projectName); + + if (selectByUserId != null && selectByUserId.size() > 0) { + var29 = skip + 1; + return "导入失败:登录账号" + userId + "不能重复添加"; + } + + if (userList3.contains(userId)) { + var29 = skip + 1; + return "导入失败:登录账号" + userId + "不能重复添加"; + } + + if (userList5.contains(userNumber)) { + var29 = skip + 1; + return "导入失败:员工编号" + userNumber + "不能重复添加"; + } + + if (StringUtils.hasText(userNumber)) { + user.setUserId((String)null); + user.setUserNumber(userNumber); + List users = userService.selectByUserNumber(userNumber); + if (users != null && users.size() > 0) { + var29 = skip + 1; + return "导入失败:用户编号" + userNumber + "不能重复添加"; + } + } + } + + for (i = 1; i < rowNum; ++i) { + row = sheet.getRow(i); + userId = this.getCellValue(row.getCell(0)); + userNumber = this.getCellValue(row.getCell(1)); + userName = this.getCellValue(row.getCell(2)); + idCard = this.getCellValue(row.getCell(3)); + email = this.getCellValue(row.getCell(4)); + mobilePhone = null; + officeTelephone = this.getCellValue(row.getCell(5)); + homePhone = this.getCellValue(row.getCell(6)); + Long sexLong = null; + regEx = this.getCellValue(row.getCell(7)); + officeTelephone = this.getCellValue(row.getCell(8)); + homePhone = this.getCellValue(row.getCell(9)); + String post = this.getCellValue(row.getCell(10)); + if (!"男".equals(homePhone) && !"女".equals(homePhone)) { + sexLong = null; + } + + if ("男".equals(homePhone)) { + sexLong = 0L; + } + + if ("女".equals(homePhone)) { + sexLong = 1L; + } + + User user = new User(); + user.setUserId(userId); + List selectByDeparmentName = this.departmentService.selectByDeparmentName(email); + if (selectByDeparmentName != null && selectByDeparmentName.size() > 0) { + mobilePhone = ((Department)selectByDeparmentName.get(0)).getId(); + } + + if (!StringUtils.hasText(userNumber)) { + userNumber = this.numberBuilderService.getUserNumber(); + this.numberBuilderService.updateNumber("user_code"); + } + + user.setId(IdGenerator.uuid32()); + user.setUserId(userId); + user.setUserName(userName); + user.setPassword(EncryptUtil.md5("11AAaa")); + user.setDepartId(mobilePhone); + user.setUserCreationTime(DateUtils.getDate()); + user.setUserPwdModifTime(DateUtils.getDate("yyyy-MM-dd HH:mm")); + user.setUserStatus(0L); + user.setUserLock(0L); + user.setUserPwdError(0L); + user.setUserPwdErrorDate(DateUtils.getDate()); + user.setPost(post); + user.setEmail(officeTelephone); + user.setOfficeTelephone(officeTelephone); + user.setUserNumber(userNumber); + user.setIdCard(idCard); + user.setMobilePhone(regEx); + user.setSex(sexLong); + user.setHomePhone(homePhone); + user.setLogout(0L); + userNames = userNames + userName + ","; + user.setSort(String.valueOf(Long.parseLong(DateUtils.getDateTimeInt()) + (long)i)); + user.setIsSys("0"); + userService.insert(user); + ++inserted; + } + + if (!"".equals(userNames) && null != userNames) { + //todo 登录人的用户名 userName + // String comments = sUserName + "新增了用户" + userNames.substring(0, userNames.length() - 1); + String comments = "新增了用户" + userNames.substring(0, userNames.length() - 1); + String logName = "批量添加人员"; + String logNameType = "用户列表"; + auditLog.setLogName(logName); + auditLog.setLogNameType(logNameType); + auditLog.setComments(comments); + auditLogService.addAuditLog(auditLog); + //todo 添加MESSAGE_TABLE表 + //String numCode = (String)request.getSession().getAttribute("customCode"); + //if (numCode != null && numCode.equals("tianjin712suo")) { + // User safeUser = userService.selectUserByUserId("safesecret"); + // /** + // * @Description:新增发送人ID及消息简短描述 + // * Modify Name:WangChenyu + // * Modify DateTime:2022年10月25日 + // */ + // String loginUserId = (String)request.getSession().getAttribute("user_id"); + // this.messageService.insertMessage("批量用户添加", "批量添加" + inserted + "个用户", "用户管理", null, + // loginUserId, safeUser.getId(), "", "0", "K"); + //} + } + + return "操作成功,添加" + inserted + "条数据," + skip + "条数据未添加成功"; + } +} diff --git a/src/main/java/com/keyware/htey/utli/IdComposeListUtil.java b/src/main/java/com/keyware/htey/utli/IdComposeListUtil.java new file mode 100644 index 0000000..9c8efb1 --- /dev/null +++ b/src/main/java/com/keyware/htey/utli/IdComposeListUtil.java @@ -0,0 +1,26 @@ +package com.keyware.htey.utli; + +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + +import com.keyware.htey.entity.user.User; + +/** + * @author daijj8 + * @version V1.0 + * @Package com.keyware.htey.utli + * @date 2025/1/13 17:15 + */ +public class IdComposeListUtil { + public static List listId(List userList) { + String userIds = stringId(userList); + return Arrays.asList(userIds.split(",")); + } + public static String stringId(List userList) { + return userList.stream() + .map(User::getId) + .map(String::valueOf) // 将ID转换为字符串 + .collect(Collectors.joining(", ")); // 使用逗号分隔 + } +} diff --git a/src/main/java/com/keyware/htey/utli/IdGenerator.java b/src/main/java/com/keyware/htey/utli/IdGenerator.java new file mode 100644 index 0000000..08e73f4 --- /dev/null +++ b/src/main/java/com/keyware/htey/utli/IdGenerator.java @@ -0,0 +1,63 @@ +package com.keyware.htey.utli; + +import java.security.SecureRandom; +import java.util.UUID; + +/** + * @author daijj8 + * @version V1.0 + * @Package com.keyware.htey.utli + * @date 2025/1/13 14:56 + */ +public class IdGenerator { + private static SecureRandom random = new SecureRandom(); + private static String[] BASE_CHARACTER = new String[] {"2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", + "E", "F", "G", "H", "J", "K", "L", "M", "N", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"}; + + public IdGenerator() { + } + + public static String uuid32() { + return UUID.randomUUID().toString().replaceAll("-", ""); + } + + public static String uuid36() { + return UUID.randomUUID().toString(); + } + + public static long randomLong() { + return Math.abs(random.nextLong()); + } + + public static String random12Str() { + StringBuilder sb = new StringBuilder(); + + for (int i = 0; i < 12; ++i) { + sb.append(BASE_CHARACTER[(int)(32.0 * Math.random())]); + } + + return sb.toString(); + } + + public static String random10Str() { + char[] ss = new char[10]; + + for (int i = 0; i < 10; ++i) { + int f = (int)(Math.random() * 3.0); + if (f == 0) { + ss[i] = (char)((int)(65.0 + Math.random() * 26.0)); + } else if (f == 1) { + ss[i] = (char)((int)(97.0 + Math.random() * 26.0)); + } else { + ss[i] = (char)((int)(48.0 + Math.random() * 10.0)); + } + } + + String is = new String(ss); + return is; + } + + public static void main(String[] args) { + System.out.println(uuid32() + "11"); + } +} diff --git a/src/main/java/com/keyware/htey/utli/IpUtil.java b/src/main/java/com/keyware/htey/utli/IpUtil.java new file mode 100644 index 0000000..41c4b49 --- /dev/null +++ b/src/main/java/com/keyware/htey/utli/IpUtil.java @@ -0,0 +1,25 @@ +package com.keyware.htey.utli; + +import java.net.InetAddress; + +import lombok.extern.slf4j.Slf4j; + +/** + * @author daijj8 + * @version V1.0 + * @Package com.keyware.htey.utli + * @date 2025/1/13 13:56 + */ +@Slf4j +public class IpUtil { + public static String getLocalIP() { + try { + InetAddress inetAddress = InetAddress.getLocalHost(); + return inetAddress.getHostAddress(); + } catch (Exception e) { + e.printStackTrace(); + return ""; + } + } + +} diff --git a/src/main/java/com/keyware/htey/utli/JsonUtils.java b/src/main/java/com/keyware/htey/utli/JsonUtils.java new file mode 100644 index 0000000..0d7796d --- /dev/null +++ b/src/main/java/com/keyware/htey/utli/JsonUtils.java @@ -0,0 +1,135 @@ +package com.keyware.htey.utli; + +import java.lang.reflect.Type; +import java.util.Collection; +import java.util.Enumeration; +import java.util.Iterator; +import java.util.List; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang.StringUtils; + +/** + * @author daijj8 + * @version V1.0 + * @Package com.keyware.htey.utli + * @date 2025/1/13 15:29 + */ +@Slf4j +public class JsonUtils { + + public static final String EMPTY = ""; + public static final String EMPTY_JSON = "{}"; + public static final String EMPTY_JSON_ARRAY = "[]"; + public static final String DEFAULT_DATE_PATTERN = "yyyy-MM-dd HH:mm:ss"; + public static final Double SINCE_VERSION_10 = 1.0; + public static final Double SINCE_VERSION_11 = 1.1; + public static final Double SINCE_VERSION_12 = 1.2; + + public JsonUtils() { + } + + public static String arrayListToJsonString(List menusParent) { + JSONArray jsonArray = new JSONArray(menusParent); + return jsonArray.toJSONString(); + } + + public static String objectToJsonString(Object obj) { + return JSON.toJSON(obj).toString(); + } + + public static Object jsonStringToObject(String jsonString, Class clazz) { + return JSONObject.parseObject(jsonString, clazz); + } + + public static List jsonStringToList(String jsonString, Class clazz) { + return JSON.parseArray(jsonString, clazz); + } + + public static String listToJson(List list) { + Gson gson = (new GsonBuilder()).setDateFormat("yyyy-MM-dd HH:mm:ss").create(); + return gson.toJson(list); + } + + public static String toJson(Object target) { + return toJson(target, (Type)null, false, (Double)null, (String)null, false); + } + + public static String toJson(Object target, Type targetType, boolean isSerializeNulls, Double version, + String datePattern, boolean excludesFieldsWithoutExpose) { + if (target == null) { + return "{}"; + } else { + GsonBuilder builder = new GsonBuilder(); + builder.disableHtmlEscaping(); + if (isSerializeNulls) { + builder.serializeNulls(); + } + + if (version != null) { + builder.setVersion(version); + } + + if (StringUtils.isEmpty(datePattern)) { + datePattern = "yyyy-MM-dd HH:mm:ss"; + } + + builder.setDateFormat(datePattern); + if (excludesFieldsWithoutExpose) { + builder.excludeFieldsWithoutExposeAnnotation(); + } + + String result = ""; + Gson gson = builder.create(); + + try { + if (targetType != null) { + result = gson.toJson(target, targetType); + } else { + result = gson.toJson(target); + } + } catch (Exception var10) { + log.error("操作失败", var10); + if (!(target instanceof Collection) && !(target instanceof Iterator) && !(target instanceof Enumeration) + && !target.getClass().isArray()) { + result = "{}"; + } else { + result = "[]"; + } + } + + return result; + } + } + + public static T fromJson(String json, Class clazz) { + return fromJson(json, clazz, (String)null); + } + + public static T fromJson(String json, Class clazz, String datePattern) { + if (StringUtils.isEmpty(json)) { + return null; + } else { + GsonBuilder builder = new GsonBuilder(); + if (StringUtils.isEmpty(datePattern)) { + datePattern = "yyyy-MM-dd HH:mm:ss"; + } + + builder.setDateFormat(datePattern); + Gson gson = builder.create(); + + try { + return gson.fromJson(json, clazz); + } catch (Exception var6) { + log.error("操作失败", var6); + return null; + } + } + } +} diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 859c747..dcdf10e 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -3,7 +3,7 @@ spring: name: HTEY datasource: url: jdbc:oscar://172.16.36.140:2003/OSRDB - username: tykd + username: HTEY password: 123456 driver-class-name: com.oscar.Driver # url: jdbc:oracle:thin:@172.16.36.140:1521:orcl @@ -39,4 +39,4 @@ springdoc: enabled: true # 是否启用 Swagger UI api-docs: path: /v3/api-docs # OpenAPI JSON 的访问路径 - enabled: true # 是否启用 OpenAPI JSON \ No newline at end of file + enabled: true # 是否启用 OpenAPI JSON diff --git a/src/main/resources/mapper/AuditLogMapper.xml b/src/main/resources/mapper/AuditLogMapper.xml new file mode 100644 index 0000000..59d1a6c --- /dev/null +++ b/src/main/resources/mapper/AuditLogMapper.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/mapper/DepartmentMapper.xml b/src/main/resources/mapper/DepartmentMapper.xml new file mode 100644 index 0000000..babc600 --- /dev/null +++ b/src/main/resources/mapper/DepartmentMapper.xml @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + 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 + + + + + + + diff --git a/src/main/resources/mapper/OFourColumMapper.xml b/src/main/resources/mapper/OFourColumMapper.xml new file mode 100644 index 0000000..44cbf9d --- /dev/null +++ b/src/main/resources/mapper/OFourColumMapper.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/src/main/resources/mapper/UserMapper.xml b/src/main/resources/mapper/UserMapper.xml new file mode 100644 index 0000000..ce19d05 --- /dev/null +++ b/src/main/resources/mapper/UserMapper.xml @@ -0,0 +1,381 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ID + , USER_ID, USER_NAME, PASSWORD, DEPART_ID, USER_CREATION_TIME, USER_PWD_MODIF_TIME, + USER_STATUS, USER_LOCK, USER_PWD_ERROR, USER_PWD_ERROR_DATE, EXIT_TIME, PASSWORD_OLD, + POST, EMAIL, OFFICE_TELEPHONE, USER_NUMBER, ID_CARD, MOBILE_PHONE, SEX, HOME_PHONE, + LOGOUT, INIT_PWD_TIME, SORT, IS_SYS, LOGOUT_TIME, PROJECT_SOURCE, UESR_RANK_ID,IMG_DATA + + + + + + 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=INTEGER}, + USER_LOCK= #{userLock,jdbcType=INTEGER}, + USER_PWD_ERROR = #{userPwdError,jdbcType=INTEGER}, + USER_PWD_ERROR_DATE = #{userPwdErrorDate,jdbcType=VARCHAR}, + EXIT_TIME = #{exitTime,jdbcType=VARCHAR}, + PASSWORD_OLD = #{passwordOld,jdbcType=VARCHAR}, + POST = #{post,jdbcType=VARCHAR}, + EMAIL = #{email,jdbcType=VARCHAR}, + OFFICE_TELEPHONE = #{officeTelephone,jdbcType=VARCHAR}, + USER_NUMBER = #{userNumber,jdbcType=VARCHAR}, + ID_CARD = #{idCard,jdbcType=VARCHAR}, + MOBILE_PHONE = #{mobilePhone,jdbcType=VARCHAR}, + SEX = #{sex,jdbcType=DECIMAL}, + HOME_PHONE = #{homePhone,jdbcType=VARCHAR}, + LOGOUT = #{logout,jdbcType=DECIMAL}, + INIT_PWD_TIME = #{initPwdTime,jdbcType=VARCHAR}, + SORT = #{sort,jdbcType=VARCHAR}, + + LOGOUT_TIME = #{logoutTime,jdbcType=VARCHAR}, + + + UESR_RANK_ID = #{uesrRankId,jdbcType=VARCHAR}, + + + where ID = #{id,jdbcType=VARCHAR} + + + update K_USER + set USER_LOCK= '0', + USER_PWD_ERROR = '0', + USER_PWD_ERROR_DATE = '' + where ID in + + #{item} + + + + update K_USER + set USER_STATUS= #{userStatus,jdbcType=INTEGER} + where ID = #{id,jdbcType=VARCHAR} + + + + + + + insert into K_USER + + + ID, + + + USER_ID, + + + USER_NAME, + + + PASSWORD, + + + DEPART_ID, + + + USER_CREATION_TIME, + + + USER_PWD_MODIF_TIME, + + + USER_STATUS, + + + USER_LOCK, + + + USER_PWD_ERROR, + + + USER_PWD_ERROR_DATE, + + + EXIT_TIME, + + + PASSWORD_OLD, + + + POST, + + + EMAIL, + + + OFFICE_TELEPHONE, + + + USER_NUMBER, + + + ID_CARD, + + + MOBILE_PHONE, + + + SEX, + + + HOME_PHONE, + + + LOGOUT, + + + INIT_PWD_TIME, + + + SORT, + + + IS_SYS, + + + LOGOUT_TIME, + + + PROJECT_SOURCE, + + + UESR_RANK_ID, + + + + + #{id,jdbcType=VARCHAR}, + + + #{userId,jdbcType=VARCHAR}, + + + #{userName,jdbcType=VARCHAR}, + + + #{password,jdbcType=VARCHAR}, + + + #{departId,jdbcType=VARCHAR}, + + + #{userCreationTime,jdbcType=VARCHAR}, + + + #{userPwdModifTime,jdbcType=VARCHAR}, + + + #{userStatus,jdbcType=DECIMAL}, + + + #{userLock,jdbcType=DECIMAL}, + + + #{userPwdError,jdbcType=DECIMAL}, + + + #{userPwdErrorDate,jdbcType=VARCHAR}, + + + #{exitTime,jdbcType=VARCHAR}, + + + #{passwordOld,jdbcType=VARCHAR}, + + + #{post,jdbcType=VARCHAR}, + + + #{email,jdbcType=VARCHAR}, + + + #{officeTelephone,jdbcType=VARCHAR}, + + + #{userNumber,jdbcType=VARCHAR}, + + + #{idCard,jdbcType=VARCHAR}, + + + #{mobilePhone,jdbcType=VARCHAR}, + + + #{sex,jdbcType=DECIMAL}, + + + #{homePhone,jdbcType=VARCHAR}, + + + #{logout,jdbcType=DECIMAL}, + + + #{initPwdTime,jdbcType=VARCHAR}, + + + #{sort,jdbcType=VARCHAR}, + + + #{isSys,jdbcType=VARCHAR}, + + + #{logoutTime,jdbcType=VARCHAR}, + + + #{projectSource,jdbcType=VARCHAR}, + + + #{uesrRankId,jdbcType=VARCHAR}, + + + + + + + update K_USER + set LOGOUT='0' ,LOGOUT_TIME = null + where ID in + + #{item} + + + diff --git a/src/main/resources/mapper/UsersecretMapper.xml b/src/main/resources/mapper/UsersecretMapper.xml new file mode 100644 index 0000000..0827ea2 --- /dev/null +++ b/src/main/resources/mapper/UsersecretMapper.xml @@ -0,0 +1,12 @@ + + + + + + + + + insert into USERSECRET (ID, SECRET) + values (#{id,jdbcType=VARCHAR}, #{secret,jdbcType=VARCHAR}) + + diff --git a/src/main/resources/mapper/number/NumberBuilderMapper.xml b/src/main/resources/mapper/number/NumberBuilderMapper.xml new file mode 100644 index 0000000..bcb97a5 --- /dev/null +++ b/src/main/resources/mapper/number/NumberBuilderMapper.xml @@ -0,0 +1,46 @@ + + + + + + + + + NUMBER_ID + , NUMBER_ + + + + insert into NUMBER_BUILDER + + + NUMBER_ID, + + + NUMBER_, + + + + + #{numberId,jdbcType=VARCHAR}, + + + #{number,jdbcType=VARCHAR}, + + + + + update NUMBER_BUILDER + + + NUMBER_ = #{number,jdbcType=VARCHAR}, + + + where NUMBER_ID = #{numberId,jdbcType=VARCHAR} + +