From a50f83c4b8680dfabf73b2b661d1cfe852c31636 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=AE=B5=E9=A3=9E=E5=AE=87?= <2684146481@qq.com> Date: Fri, 21 Apr 2023 15:36:46 +0800 Subject: [PATCH] =?UTF-8?q?=E6=97=A5=E5=BF=97=E6=A8=A1=E5=9D=97,=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../systemlog/controller/SysLogController.java | 26 ++++++++++++++ .../middle/systemlog/service/SysLogService.java | 1 + .../service/impl/StatisticsServiceImpl.java | 7 ++++ .../systemlog/service/impl/SysLogServiceImpl.java | 40 ++++++++++++++++++---- .../hzims/middle/systemlog/vo/StatisticsVo.java | 11 +++--- .../hnac/hzims/middle/systemlog/vo/SysLogVo.java | 28 +++++++++++++-- 6 files changed, 100 insertions(+), 13 deletions(-) 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 7763c73..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 @@ -115,5 +115,31 @@ public class SysLogController { 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/service/SysLogService.java b/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/service/SysLogService.java index a8ad76d..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 @@ -33,4 +33,5 @@ public interface SysLogService extends IService { * @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 b6aac7a..44bcf16 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 @@ -11,6 +11,7 @@ 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; @@ -99,6 +100,12 @@ public class StatisticsServiceImpl extends ServiceImpl selectPage(Page page1, StatisticsVo statistics) { QueryWrapper queryWrapper = new QueryWrapper<>(); + //开始时间 + queryWrapper.lambda().eq(StringUtils.isNotEmpty(statistics.getCreateTime()),Statistics::getDateCalculated, + statistics.getCreateTime()); + //结束时间 + queryWrapper.lambda().eq(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 d6896e1..3110c2c 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 @@ -15,6 +15,7 @@ import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; import java.time.LocalDate; +import java.time.LocalDateTime; import java.util.List; /** @@ -47,9 +48,24 @@ public class SysLogServiceImpl extends ServiceImpl impleme */ @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(); - LocalDate createTime = sysLog.getCreateTime(); - LocalDate endTime = sysLog.getEndTime(); + 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())) { @@ -58,16 +74,28 @@ public class SysLogServiceImpl extends ServiceImpl impleme 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(createTime)) { + queryWrapper.lambda().ge(SysLog::getOperationTime, createTime); } + //结束时间 if (ObjectUtils.isNotEmpty(endTime)){ queryWrapper.lambda().le(SysLog::getOperationTime,endTime); } - IPage statisticsPage = baseMapper.selectPage(page1, queryWrapper); - return statisticsPage; + //根据操作时间和功能模块查询 + 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 index 95d2493..e3db684 100644 --- 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 @@ -2,6 +2,7 @@ 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; @@ -25,14 +26,16 @@ public class StatisticsVo { /** * 开始时间 */ - @JsonFormat(pattern="yyyy-MM-dd ",timezone = "GMT+8",shape = JsonFormat.Shape.STRING) - private LocalDate createTime; + //@JsonFormat(pattern="yyyy-MM-dd",shape = JsonFormat.Shape.STRING) + //@DateTimeFormat(pattern = "yyyy-MM-dd") + private String createTime; /** * 结束时间 * */ - @JsonFormat(pattern="yyyy-MM-dd ",timezone = "GMT+8",shape = JsonFormat.Shape.STRING) - private LocalDate endTime; + //@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 index c711d4c..03b2f1d 100644 --- 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 @@ -1,8 +1,11 @@ package com.hnac.hzims.middle.systemlog.vo; +import com.baomidou.mybatisplus.annotation.TableField; +import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.time.LocalDate; +import java.time.LocalDateTime; /** * @Author WL @@ -14,20 +17,39 @@ import java.time.LocalDate; public class SysLogVo { + + @ApiModelProperty("功能模块") + private String moduleName; + + + /** - * key + * 功能模块,操作方法,方法描述 模糊查询 */ + @ApiModelProperty("功能模块,操作方法,方法描述 模糊查询") public String keyword; /** * 开始时间 */ - private LocalDate createTime; + @ApiModelProperty("开始时间") + private LocalDateTime createTime; /** * 结束时间 */ - private LocalDate endTime; + @ApiModelProperty("结束时间") + private LocalDateTime endTime; + + + @ApiModelProperty("操作时间") + private String dateCalculated; + + + @ApiModelProperty("请求地址") + private String path; + + }