diff --git a/hzims-biz-common/src/main/java/com/hnac/hzims/common/logs/aop/SysLogAspect.java b/hzims-biz-common/src/main/java/com/hnac/hzims/common/logs/aop/SysLogAspect.java index 75e217c..c2935fe 100644 --- a/hzims-biz-common/src/main/java/com/hnac/hzims/common/logs/aop/SysLogAspect.java +++ b/hzims-biz-common/src/main/java/com/hnac/hzims/common/logs/aop/SysLogAspect.java @@ -56,6 +56,7 @@ public class SysLogAspect { //private StopWatch stopWatch = new StopWatch(); + private static final ThreadLocal TIME_THREADLOCAL = new NamedThreadLocal<>("Cost Time"); diff --git a/hzims-biz-common/src/main/java/com/hnac/hzims/common/logs/to/SysLogTo.java b/hzims-biz-common/src/main/java/com/hnac/hzims/common/logs/to/SysLogTo.java index 4b311ba..3816057 100644 --- a/hzims-biz-common/src/main/java/com/hnac/hzims/common/logs/to/SysLogTo.java +++ b/hzims-biz-common/src/main/java/com/hnac/hzims/common/logs/to/SysLogTo.java @@ -1,5 +1,6 @@ package com.hnac.hzims.common.logs.to; +import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.time.LocalDateTime; @@ -21,97 +22,115 @@ public class SysLogTo { /** * 租户ID */ + @ApiModelProperty("租户ID") private String tenantId; /** * 服务器ip */ + @ApiModelProperty("服务器ip") protected String serverIp; /** * 服务器地址 */ + @ApiModelProperty("服务器地址") protected String serverHost; /** * 服务名称 */ + @ApiModelProperty("服务名称") protected String serverName; /** * 环境 */ + @ApiModelProperty("环境") protected String env; /** * 操作人 id */ + @ApiModelProperty("操作人id") private Long operationUserId; /** * 操作人 */ + @ApiModelProperty("操作人") private String operationUserName; /** * 请求路径 (操作地址) */ + @ApiModelProperty(" 请求路径 (操作地址)") private String path; /** * 用户代理 */ + @ApiModelProperty("用户代理") protected String userAgent; /** * 操作方式 */ + @ApiModelProperty("操作方式") protected String method; /** * 方法类 */ + @ApiModelProperty("方法类") protected String methodClass; /** * 方法名 */ + @ApiModelProperty("方法名") protected String methodName; /** * 方法执行时间 消耗时间 毫秒 */ + @ApiModelProperty("法执行时间 消耗时间 毫秒") private String costTime; /** * 方法入参 */ + @ApiModelProperty("方法入参") private String parameter; /** * 操作方法 */ + @ApiModelProperty("操作方法") private String title; /** * 方法描述 */ + @ApiModelProperty("方法描述") private String action; /** * 系统类型 */ + @ApiModelProperty("系统类型") private String operatorType; /** * 操作人类别 */ + @ApiModelProperty("操作人类别") private String businessType; @@ -120,32 +139,38 @@ public class SysLogTo { * * @param jsonResult */ + @ApiModelProperty("返回结果") public String jsonResult; /** * 请求的Ip */ + @ApiModelProperty("请求的Ip") private String localIp; /** * 错误消息 */ + @ApiModelProperty("错误消息") private String errorMsg; /** * 操作时间 */ + @ApiModelProperty("操作时间") private LocalDateTime operationTime; /** * 操作状态(0 正常 1 异常) */ + @ApiModelProperty("操作状态") private Integer status; /** * 功能模块 */ + @ApiModelProperty("功能模块") private String moduleName; } diff --git a/hzims-service/hzims-middle/pom.xml b/hzims-service/hzims-middle/pom.xml index 606c141..38e1819 100644 --- a/hzims-service/hzims-middle/pom.xml +++ b/hzims-service/hzims-middle/pom.xml @@ -17,6 +17,7 @@ UTF-8 UTF-8 2.6.13 + 1.9.6 @@ -59,6 +60,13 @@ + + + com.github.xiaoymin + swagger-bootstrap-ui + ${swagger-bootstrap-ui.version} + + diff --git a/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/config/Swagger2Config.java b/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/config/Swagger2Config.java new file mode 100644 index 0000000..b7c5e2a --- /dev/null +++ b/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/config/Swagger2Config.java @@ -0,0 +1,59 @@ +package com.hnac.hzims.middle.systemlog.config; + +import com.google.common.base.Predicates; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; +import springfox.documentation.builders.ApiInfoBuilder; +import springfox.documentation.builders.PathSelectors; +import springfox.documentation.service.ApiInfo; +import springfox.documentation.service.Contact; +import springfox.documentation.spi.DocumentationType; +import springfox.documentation.spring.web.plugins.Docket; +import springfox.documentation.swagger2.annotations.EnableSwagger2; + +/** + * @Author WL + * @Version v1.0 + * @Serial 1.0 + * @Date 2023/4/13 13:40 + */ +@Configuration +@EnableSwagger2 +public class Swagger2Config implements WebMvcConfigurer { + + + @Override + public void addResourceHandlers(ResourceHandlerRegistry registry) { + registry.addResourceHandler("/**") + .addResourceLocations("classpath:/static/"); + registry.addResourceHandler("doc.html") + .addResourceLocations("classpath:/META-INF/resources/"); + registry.addResourceHandler("/webjars/**") + .addResourceLocations("classpath:/META-INF/resources/webjars/"); + } + + + + @Bean + public Docket webApiConfig(){ + return new Docket(DocumentationType.SWAGGER_2) + .groupName("日志模块") + .apiInfo(webApiInfo()) + .select() + //只显示api路径下的页面 + .paths(Predicates.and(PathSelectors.regex("/systemlog/.*"))) + .build(); + + } + + private ApiInfo webApiInfo() { + return new ApiInfoBuilder() + .title("网站-API文档") + .description("本文档描述了网站微服务接口定义") + .version("1.0") + .contact(new Contact("WL", "http://localhost:8501/", "55317332@qq.com")) + .build(); + } +} diff --git a/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/controller/StatisticsController.java b/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/controller/StatisticsController.java index 7e5a59b..51e8e00 100644 --- a/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/controller/StatisticsController.java +++ b/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/controller/StatisticsController.java @@ -1,9 +1,24 @@ package com.hnac.hzims.middle.systemlog.controller; -import org.springframework.web.bind.annotation.RequestMapping; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.hnac.hzims.common.logs.annotation.OperationAnnotation; +import com.hnac.hzims.common.logs.enums.BusinessType; +import com.hnac.hzims.common.logs.enums.OperatorType; +import com.hnac.hzims.middle.systemlog.entity.Statistics; +import com.hnac.hzims.middle.systemlog.entity.SysLog; +import com.hnac.hzims.middle.systemlog.service.StatisticsService; +import com.hnac.hzims.middle.systemlog.vo.StatisticsVo; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiResponse; +import io.swagger.annotations.ApiResponses; +import org.springblade.core.tool.api.R; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; -import org.springframework.web.bind.annotation.RestController; +import java.util.List; /** *

@@ -13,9 +28,61 @@ import org.springframework.web.bind.annotation.RestController; * @author dfy * @since 2023-04-08 */ +@Api(tags = "操作日志统计数据") @RestController @RequestMapping("/systemlog/statistics") public class StatisticsController { + + @Autowired + private StatisticsService statisticsService; + + + /** + * 查询 + * + * @param statistics + * @return + */ + @ApiOperation("操作日志统计数据分页查询") + @OperationAnnotation(moduleName = "操作日志", + operatorType = OperatorType.MANAGE, + businessType = BusinessType.INSERT + , title = "操作日志统计数据", action = "操作日志统计数据分页查询") + @ApiResponses({ + @ApiResponse(code = 200,message = "OK",response = Statistics.class), + }) + @GetMapping("/selectPage/{page}/{size}") + public R selectPage( + @PathVariable Long page, + @PathVariable Long size, + StatisticsVo statistics) { + Page page1 = new Page(page, size); + IPage pageSize = statisticsService.selectPage(page1, statistics); + return R.data(pageSize); + } + + + /** + * 根据Id查询日志 + * + * @param id + * @return + */ + @ApiResponses({ + @ApiResponse(code = 200,message = "OK",response = Statistics.class), + }) + @ApiOperation("根据Id查询日志") + @OperationAnnotation(moduleName = "操作日志", + operatorType = OperatorType.MANAGE, + businessType = BusinessType.INSERT + , title = "操作日志统计数据", action = "根据Id查询日志") + @GetMapping("/get/{id}") + public R list(@PathVariable Long id) { + Statistics statistics = statisticsService.getById(id); + return R.data(statistics); + } + + } diff --git a/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/controller/SysLogController.java b/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/controller/SysLogController.java index b40b640..bbd34e9 100644 --- a/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/controller/SysLogController.java +++ b/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/controller/SysLogController.java @@ -2,17 +2,26 @@ package com.hnac.hzims.middle.systemlog.controller; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.hnac.hzims.common.logs.annotation.OperationAnnotation; +import com.hnac.hzims.common.logs.enums.BusinessType; +import com.hnac.hzims.common.logs.enums.OperatorType; import com.hnac.hzims.common.logs.to.SysLogTo; +import com.hnac.hzims.middle.systemlog.entity.Statistics; import com.hnac.hzims.middle.systemlog.entity.SysLog; import com.hnac.hzims.middle.systemlog.service.SysLogService; +import com.hnac.hzims.middle.systemlog.vo.StatisticsVo; +import com.hnac.hzims.middle.systemlog.vo.SysLogVo; import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiResponse; +import io.swagger.annotations.ApiResponses; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.springblade.core.tool.api.R; import org.springframework.beans.BeanUtils; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import java.util.List; import java.util.stream.Collectors; @@ -39,6 +48,11 @@ public class SysLogController { * 保存操作日志 * @param sysLogToList */ + @OperationAnnotation(moduleName = "操作日志", + operatorType = OperatorType.MANAGE, + businessType = BusinessType.INSERT + ,title = "系统日志",action = "保存操作日志") + @ApiOperation("保存操作日志") @PostMapping("/batchSave") public void saveBatch(@RequestBody List sysLogToList) { //数据转换 @@ -56,5 +70,76 @@ public class SysLogController { log.info("操作日志新增失败 ~~~"); throw new IllegalArgumentException("操作日志新增失败"); } + + + /** + * 日志分页查询 + * @param page + * @param size + * @return + */ + @OperationAnnotation(moduleName = "操作日志", + operatorType = OperatorType.MANAGE, + businessType = BusinessType.INSERT + ,title = "系统日志",action = "日志分页查询") + @ApiOperation("日志分页查询") + @GetMapping("/selectPage/{page}/{size}") + @ApiResponses({ + @ApiResponse(code = 200,message = "OK",response = SysLog.class), + }) + public R selectPage( + @PathVariable Long page, + @PathVariable Long size, + SysLogVo sysLog) { + Page page1 = new Page(page, size); + IPage pageSize = sysLogService.selectPage(page1, sysLog); + return R.data(pageSize); + } + + + /** + * 根据Id获取日志数据 + * @return + */ + @ApiResponses({ + @ApiResponse(code = 200,message = "OK",response = SysLog.class), + }) + @OperationAnnotation(moduleName = "操作日志", + operatorType = OperatorType.MANAGE, + businessType = BusinessType.INSERT + ,title = "系统日志",action = "根据Id获取日志数据") + @ApiOperation("根据Id获取日志数据") + @GetMapping("/get/{id}") + public R getById(@PathVariable Long id) { + SysLog sysLog = sysLogService.getById(id); + return R.data(sysLog); + } + + + + + + // /** + // * 根据Id获取日志数据 + // * @return + // */ + // @ApiResponses({ + // @ApiResponse(code = 200,message = "OK",response = SysLog.class), + // }) + // @OperationAnnotation(moduleName = "操作日志", + // operatorType = OperatorType.MANAGE, + // businessType = BusinessType.INSERT + // ,title = "系统日志",action = "根据操作模块查询信息") + // @ApiOperation("根据操作模块查询信息") + // @GetMapping("/selectPageByModuleName/{page}/{size}") + // public R selectPageByModuleName( + // @PathVariable Long page, + // @PathVariable Long size, + // SysLogVo sysLogVo) { + // Page objectPage = new Page<>(page,size); + // IPage sysLog = sysLogService.selectPageByModuleName(objectPage,sysLogVo); + // return R.data(sysLog); + // } + } diff --git a/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/entity/Statistics.java b/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/entity/Statistics.java index 9d8f338..241de00 100644 --- a/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/entity/Statistics.java +++ b/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/entity/Statistics.java @@ -6,6 +6,8 @@ import com.baomidou.mybatisplus.annotation.TableField; import java.io.Serializable; import java.time.YearMonth; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.experimental.Accessors; @@ -22,6 +24,7 @@ import lombok.experimental.Accessors; @EqualsAndHashCode(callSuper = false) @Accessors(chain = true) @TableName("hzims_statistics") +@ApiModel("操作日志统计对象") public class Statistics implements Serializable { private static final long serialVersionUID=1L; @@ -29,12 +32,14 @@ public class Statistics implements Serializable { /** * 编号 */ + @ApiModelProperty("编号") @TableField("id") private Long id; /** * 统计日期 */ + @ApiModelProperty("统计日期") @TableField("date_calculated") private String dateCalculated; @@ -42,6 +47,7 @@ public class Statistics implements Serializable { /** * 操作模块 */ + @ApiModelProperty("操作模块") @TableField("title") private String title; @@ -49,6 +55,7 @@ public class Statistics implements Serializable { /** * 操作模块统计 */ + @ApiModelProperty("操作模块统计") @TableField("title_num") private Integer titleNum; @@ -56,6 +63,7 @@ public class Statistics implements Serializable { /** * 功能模块统计 */ + @ApiModelProperty("功能模块统计") @TableField("module_name") private String moduleName; @@ -63,6 +71,7 @@ public class Statistics implements Serializable { /** * 功能模块统计 */ + @ApiModelProperty("功能模块统计") @TableField("module_name_num") private Integer moduleNameNum; @@ -70,24 +79,28 @@ public class Statistics implements Serializable { /** * 请求路径统计 */ + @ApiModelProperty("请求路径统计") @TableField("path") private String path; /** * 请求路径统计 */ + @ApiModelProperty("请求路径统计") @TableField("path_num") private Integer pathNum; /** * 创建时间 */ + @ApiModelProperty("创建时间") @TableField("create_time") private LocalDateTime createTime; /** * 更新时间 */ + @ApiModelProperty("更新时间") @TableField("update_time") private LocalDateTime updateTime; diff --git a/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/entity/SysLog.java b/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/entity/SysLog.java index 210acca..5bb4897 100644 --- a/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/entity/SysLog.java +++ b/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/entity/SysLog.java @@ -1,17 +1,24 @@ package com.hnac.hzims.middle.systemlog.entity; import com.baomidou.mybatisplus.annotation.TableName; + import java.time.LocalDateTime; import java.sql.Blob; + import com.baomidou.mybatisplus.annotation.TableField; + import java.io.Serializable; + +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.experimental.Accessors; /** *

- * + * *

* * @author dfy @@ -21,9 +28,10 @@ import lombok.experimental.Accessors; @EqualsAndHashCode(callSuper = false) @Accessors(chain = true) @TableName("hzims_sys_log") +@ApiModel("系统日志统计对象") public class SysLog implements Serializable { - private static final long serialVersionUID=1L; + private static final long serialVersionUID = 1L; /** * 操作日志编号 @@ -35,165 +43,194 @@ public class SysLog implements Serializable { /** * 功能模块 */ + @ApiModelProperty("功能模块") @TableField("module_name") private String moduleName; /** * 租户ID */ + @ApiModelProperty("租户ID") @TableField("tenant_id") private String tenantId; /** * 服务器ip */ + @ApiModelProperty("服务器ip") @TableField("server_ip") private String serverIp; /** * 服务器地址 */ + @ApiModelProperty("服务器地址") @TableField("server_host") private String serverHost; /** * 服务名称 */ + @ApiModelProperty("服务名称") @TableField("server_name") private String serverName; /** * 环境 */ + @ApiModelProperty("环境") @TableField("env") private String env; /** * 操作人Id */ + @ApiModelProperty("操作人Id") @TableField("operation_user_id") private Long operationUserId; /** * 操作人名称 */ + @ApiModelProperty("操作人名称") @TableField("operation_user_name") private String operationUserName; /** * 请求路径 (操作地址) */ + @ApiModelProperty(" 请求路径 (操作地址)") @TableField("path") private String path; /** * 用户代理 */ + @ApiModelProperty("用户代理") @TableField("user_agent") private String userAgent; /** * 操作方式 */ + @ApiModelProperty("操作方式") @TableField("method") private String method; /** * 方法类 */ + @ApiModelProperty("方法类") @TableField("method_class") private String methodClass; /** * 方法名 */ + @ApiModelProperty("方法名") @TableField("method_name") private String methodName; /** * 方法执行时间 消耗时间 毫秒 */ + @ApiModelProperty("方法执行时间 消耗时间 毫秒") @TableField("cost_time") private String costTime; /** * 方法入参 */ + @ApiModelProperty("方法入参") @TableField("parameter") private String parameter; /** * 操作方法 */ + @ApiModelProperty("操作方法") @TableField("title") private String title; /** * 方法描述 */ + @ApiModelProperty("方法描述") @TableField("action") private String action; /** * 系统类型 */ + @ApiModelProperty("系统类型") @TableField("operator_type") private String operatorType; /** * 操作人类别 */ + @ApiModelProperty("操作人类别") @TableField("business_type") private String businessType; /** * 返回结果 */ + @ApiModelProperty("返回结果") @TableField("json_result") private String jsonResult; /** * 请求的Ip */ + @ApiModelProperty("请求的Ip") @TableField("local_ip") private String localIp; /** * 错误消息 */ + @ApiModelProperty("错误消息") @TableField("error_msg") private String errorMsg; /** * 操作时间 */ + @ApiModelProperty("操作时间") @TableField("operation_time") + @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",shape = JsonFormat.Shape.STRING) private LocalDateTime operationTime; /** * 操作状态(0 正常 1 异常) */ + @ApiModelProperty("操作状态") @TableField("status") private Integer status; /** * 创建时间 */ + @ApiModelProperty("创建时间") @TableField("create_time") + @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",shape = JsonFormat.Shape.STRING) private LocalDateTime createTime; /** * 更新时间 */ + @ApiModelProperty("更新时间") @TableField("update_time") + @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",shape = JsonFormat.Shape.STRING) private LocalDateTime updateTime; /** * 逻辑删除 (0 可用 1 删除) */ + @ApiModelProperty("逻辑删除") @TableField("is_deleted") private Integer isDeleted; - } diff --git a/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/service/StatisticsService.java b/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/service/StatisticsService.java index 32abe97..39a9e5f 100644 --- a/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/service/StatisticsService.java +++ b/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/service/StatisticsService.java @@ -1,9 +1,13 @@ package com.hnac.hzims.middle.systemlog.service; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.hnac.hzims.middle.systemlog.entity.Statistics; import com.baomidou.mybatisplus.extension.service.IService; +import com.hnac.hzims.middle.systemlog.vo.StatisticsVo; import java.time.YearMonth; +import java.util.List; /** *

@@ -26,4 +30,14 @@ public interface StatisticsService extends IService { * @return */ Statistics getStatisticsBydateCalculated(String operationTime); + + + /** + * 分页查询 + * @param page1 + * @param statistics + * @return + */ + IPage selectPage(Page page1, StatisticsVo statistics); + } diff --git a/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/service/SysLogService.java b/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/service/SysLogService.java index 224eceb..4abc935 100644 --- a/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/service/SysLogService.java +++ b/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/service/SysLogService.java @@ -1,8 +1,11 @@ package com.hnac.hzims.middle.systemlog.service; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.hnac.hzims.middle.systemlog.entity.SysLog; import com.baomidou.mybatisplus.extension.service.IService; import com.hnac.hzims.middle.systemlog.vo.SysLogStatisticsVo; +import com.hnac.hzims.middle.systemlog.vo.SysLogVo; import java.util.List; @@ -21,4 +24,14 @@ public interface SysLogService extends IService { * @return */ List countStatistics(); + + + /** + * 分页查询 + * @param page1 + * @param sysLog + * @return + */ + IPage selectPage(Page page1, SysLogVo sysLog); + } diff --git a/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/service/impl/StatisticsServiceImpl.java b/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/service/impl/StatisticsServiceImpl.java index 78c135e..26f1d5a 100644 --- a/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/service/impl/StatisticsServiceImpl.java +++ b/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/service/impl/StatisticsServiceImpl.java @@ -1,13 +1,17 @@ package com.hnac.hzims.middle.systemlog.service.impl; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.hnac.hzims.middle.systemlog.entity.Statistics; import com.hnac.hzims.middle.systemlog.mapper.StatisticsMapper; import com.hnac.hzims.middle.systemlog.service.StatisticsService; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.hnac.hzims.middle.systemlog.service.SysLogService; +import com.hnac.hzims.middle.systemlog.vo.StatisticsVo; import com.hnac.hzims.middle.systemlog.vo.SysLogStatisticsVo; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -84,4 +88,25 @@ public class StatisticsServiceImpl extends ServiceImpl selectPage(Page page1, StatisticsVo statistics) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + //开始时间 + queryWrapper.lambda().ge(StringUtils.isNotEmpty(statistics.getCreateTime()),Statistics::getDateCalculated, + statistics.getCreateTime()); + //结束时间 + queryWrapper.lambda().le(StringUtils.isNotEmpty(statistics.getEndTime()),Statistics::getDateCalculated, + statistics.getEndTime()); + IPage statisticsPage = baseMapper.selectPage(page1, queryWrapper); + return statisticsPage; + } } diff --git a/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/service/impl/SysLogServiceImpl.java b/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/service/impl/SysLogServiceImpl.java index e1b242b..6f49c9d 100644 --- a/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/service/impl/SysLogServiceImpl.java +++ b/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/service/impl/SysLogServiceImpl.java @@ -1,12 +1,21 @@ package com.hnac.hzims.middle.systemlog.service.impl; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.hnac.hzims.middle.systemlog.entity.Statistics; import com.hnac.hzims.middle.systemlog.entity.SysLog; import com.hnac.hzims.middle.systemlog.mapper.SysLogMapper; import com.hnac.hzims.middle.systemlog.service.SysLogService; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.hnac.hzims.middle.systemlog.vo.SysLogStatisticsVo; +import com.hnac.hzims.middle.systemlog.vo.SysLogVo; +import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; +import java.time.LocalDate; +import java.time.LocalDateTime; import java.util.List; /** @@ -29,4 +38,65 @@ public class SysLogServiceImpl extends ServiceImpl impleme public List countStatistics() { return baseMapper.countStatistics(); } + + /** + * 分页查询 + * + * @param page1 + * @param sysLog + * @return + */ + @Override + public IPage selectPage(Page page1, SysLogVo sysLog) { + QueryWrapper queryWrapper = getSysLogQueryWrapper(sysLog); + IPage statisticsPage = baseMapper.selectPage(page1, queryWrapper); + return statisticsPage; + } + + + /** + * 日志查询接口 + * @param sysLog + * @return + */ + private static QueryWrapper getSysLogQueryWrapper(SysLogVo sysLog) { + String keyword = sysLog.getKeyword(); + LocalDateTime createTime = sysLog.getCreateTime(); + LocalDateTime endTime = sysLog.getEndTime(); + String dateCalculated = sysLog.getDateCalculated(); + String moduleName = sysLog.getModuleName(); + String path = sysLog.getPath(); + + QueryWrapper queryWrapper = new QueryWrapper<>(); + if (StringUtils.isNotEmpty(sysLog.getKeyword())) { + queryWrapper.lambda().like(SysLog::getModuleName, keyword); + queryWrapper.lambda().or().like(SysLog::getTitle, keyword); + queryWrapper.lambda().or().like(SysLog::getAction, keyword); + } + + //请求地址 + if (StringUtils.isNotEmpty(path)) { + queryWrapper.lambda().eq(SysLog::getPath, path); + } + + + //开始时间 + if (ObjectUtils.isNotEmpty(createTime)) { + queryWrapper.lambda().ge(SysLog::getOperationTime, createTime); + } + + //结束时间 + if (ObjectUtils.isNotEmpty(endTime)){ + queryWrapper.lambda().le(SysLog::getOperationTime,endTime); + } + + //根据操作时间和功能模块查询 + if (StringUtils.isNotEmpty(dateCalculated) && StringUtils.isNotEmpty(moduleName)){ + queryWrapper.lambda().eq(SysLog::getModuleName,moduleName); + queryWrapper.eq("date_format(operation_time,'%Y-%m')",dateCalculated); + } + + return queryWrapper; + } + } diff --git a/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/vo/StatisticsVo.java b/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/vo/StatisticsVo.java new file mode 100644 index 0000000..6b82c1d --- /dev/null +++ b/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/vo/StatisticsVo.java @@ -0,0 +1,41 @@ +package com.hnac.hzims.middle.systemlog.vo; + +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; +import org.springframework.format.annotation.DateTimeFormat; + +import java.time.LocalDate; +import java.time.LocalDateTime; + +/** + * @Author WL + * @Version v1.0 + * @Serial 1.0 + * @Date 2023/4/21 9:21 + */ +@Data +public class StatisticsVo { + + + /** + * key + */ + public String keyword; + + + /** + * 开始时间 + */ + //@JsonFormat(pattern="yyyy-MM-dd",shape = JsonFormat.Shape.STRING) + @DateTimeFormat(pattern = "yyyy-MM-dd") + private String createTime; + + /** + * 结束时间 + * + */ + //@JsonFormat(pattern="yyyy-MM-dd",shape = JsonFormat.Shape.STRING) + @DateTimeFormat(pattern = "yyyy-MM-dd") + private String endTime; + +} diff --git a/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/vo/SysLogVo.java b/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/vo/SysLogVo.java new file mode 100644 index 0000000..e4b6a4f --- /dev/null +++ b/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/vo/SysLogVo.java @@ -0,0 +1,56 @@ +package com.hnac.hzims.middle.systemlog.vo; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import org.springframework.format.annotation.DateTimeFormat; + +import java.time.LocalDate; +import java.time.LocalDateTime; + +/** + * @Author WL + * @Version v1.0 + * @Serial 1.0 + * @Date 2023/4/21 9:53 + */ +@Data +public class SysLogVo { + + + @ApiModelProperty("功能模块") + private String moduleName; + + + /** + * 功能模块,操作方法,方法描述 模糊查询 + */ + @ApiModelProperty("功能模块,操作方法,方法描述 模糊查询") + public String keyword; + + + /** + * 开始时间 + */ + @ApiModelProperty(value = "开始时间") + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private LocalDateTime createTime; + + /** + * 结束时间 + */ + @ApiModelProperty(value = "结束时间") + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private LocalDateTime endTime; + + + @ApiModelProperty("操作时间") + private String dateCalculated; + + + @ApiModelProperty("请求地址") + private String path; + + +} diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/mapper/ImsDutyGroupPMapper.xml b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/mapper/ImsDutyGroupPMapper.xml index 0a02bd9..ca66a40 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/mapper/ImsDutyGroupPMapper.xml +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/mapper/ImsDutyGroupPMapper.xml @@ -45,7 +45,7 @@ select from hz_ims_duty_group_p - where ID = #{groupId,jdbcType=BIGINT} + where GROUP_ID = #{groupId,jdbcType=BIGINT}