Browse Source

日志修改

zhongwei
段飞宇 2 years ago
parent
commit
eba1130362
  1. 2
      hzims-biz-common/src/main/java/com/hnac/hzims/common/logs/annotation/OperationAnnotation.java
  2. 16
      hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/mapper/SysLogMapper.xml
  3. 8
      hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/service/StatisticsService.java
  4. 28
      hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/service/impl/StatisticsServiceImpl.java
  5. 14
      hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/service/impl/SysLogServiceImpl.java
  6. 4
      hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/vo/SysLogVo.java

2
hzims-biz-common/src/main/java/com/hnac/hzims/common/logs/annotation/OperationAnnotation.java

@ -20,7 +20,7 @@ public @interface OperationAnnotation {
/**
* 功能模块
*/
String moduleName() default "";
String moduleName() default "功能模块";
/**

16
hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/mapper/SysLogMapper.xml

@ -2,16 +2,22 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.hnac.hzims.middle.systemlog.mapper.SysLogMapper">
<!-- <select id="countStatistics" resultType="com.hnac.hzims.middle.systemlog.vo.SysLogStatisticsVo">-->
<!-- select date_format(operation_time, '%Y-%m-%d') operationTime,-->
<!-- module_name,-->
<!-- count(module_name) moduleNameCount-->
<!-- from hzims_sys_log-->
<!-- where to_days(operation_time) = to_days(now())-->
<!-- group by operationTime,module_name;-->
<!-- </select>-->
<select id="countStatistics" resultType="com.hnac.hzims.middle.systemlog.vo.SysLogStatisticsVo">
select date_format(operation_time, '%Y-%m-%d') operationTime,
title,
count(title) titleCount,
module_name,
count(module_name) moduleNameCount,
path,
count(path) pathCount
group_concat(distinct title) title,
group_concat(distinct path) path
from hzims_sys_log
where to_days(operation_time) = to_days(now())
group by operationTime,title,module_name,path;
group by module_name;
</select>
</mapper>

8
hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/service/StatisticsService.java

@ -5,9 +5,7 @@ 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;
import com.hnac.hzims.middle.systemlog.vo.SysLogStatisticsVo;
/**
* <p>
@ -26,10 +24,10 @@ public interface StatisticsService extends IService<Statistics> {
/**
* 根据时间查询数据
* @param operationTime
* @param sysLogStatistics
* @return
*/
Statistics getStatisticsBydateCalculated(String operationTime);
Statistics getStatisticsBydateCalculated(SysLogStatisticsVo sysLogStatistics);
/**

28
hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/service/impl/StatisticsServiceImpl.java

@ -15,7 +15,6 @@ import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.time.YearMonth;
import java.util.List;
/**
@ -51,8 +50,11 @@ public class StatisticsServiceImpl extends ServiceImpl<StatisticsMapper, Statist
return;
}
for (SysLogStatisticsVo sysLogStatisticsVo : sysLogStatisticsVoList) {
if (StringUtils.isBlank(sysLogStatisticsVo.getModuleName())){
continue;
}
//查询数据
Statistics statistics = statisticsService.getStatisticsBydateCalculated(sysLogStatisticsVo.getOperationTime());
Statistics statistics = statisticsService.getStatisticsBydateCalculated(sysLogStatisticsVo);
//如果为空保存数据,如果不为空更新数据
if (statistics == null) {
statistics = new Statistics();
@ -61,16 +63,16 @@ public class StatisticsServiceImpl extends ServiceImpl<StatisticsMapper, Statist
statistics.setTitle(sysLogStatisticsVo.getTitle());
statistics.setModuleName(sysLogStatisticsVo.getModuleName());
statistics.setPath(sysLogStatisticsVo.getPath());
statistics.setTitleNum(sysLogStatisticsVo.getTitleCount());
statistics.setPathNum(sysLogStatisticsVo.getPathCount());
// statistics.setTitleNum(sysLogStatisticsVo.getTitleCount());
// statistics.setPathNum(sysLogStatisticsVo.getPathCount());
statisticsService.save(statistics);
} else {
statistics.setTitle(sysLogStatisticsVo.getTitle());
statistics.setModuleName(sysLogStatisticsVo.getModuleName());
statistics.setPath(sysLogStatisticsVo.getPath());
statistics.setModuleNameNum(sysLogStatisticsVo.getModuleNameCount());
statistics.setTitleNum(sysLogStatisticsVo.getTitleCount());
statistics.setPathNum(sysLogStatisticsVo.getPathCount());
//statistics.setTitleNum(sysLogStatisticsVo.getTitleCount());
//statistics.setPathNum(sysLogStatisticsVo.getPathCount());
statisticsService.updateById(statistics);
}
}
@ -79,13 +81,14 @@ public class StatisticsServiceImpl extends ServiceImpl<StatisticsMapper, Statist
/**
* 根据时间查询数据
*
* @param operationTime
* @param sysLogStatistics
* @return
*/
@Override
public Statistics getStatisticsBydateCalculated(String operationTime) {
public Statistics getStatisticsBydateCalculated(SysLogStatisticsVo sysLogStatistics) {
QueryWrapper<Statistics> statisticsQueryWrapper = new QueryWrapper<>();
statisticsQueryWrapper.eq("date_calculated", operationTime);
statisticsQueryWrapper.eq("date_calculated", sysLogStatistics.getOperationTime());
statisticsQueryWrapper.eq("module_name", sysLogStatistics.getModuleName());
return baseMapper.selectOne(statisticsQueryWrapper);
}
@ -101,11 +104,10 @@ public class StatisticsServiceImpl extends ServiceImpl<StatisticsMapper, Statist
public IPage<Statistics> selectPage(Page<Statistics> page1, StatisticsVo statistics) {
QueryWrapper<Statistics> queryWrapper = new QueryWrapper<>();
//开始时间
queryWrapper.lambda().ge(StringUtils.isNotEmpty(statistics.getCreateTime()),Statistics::getDateCalculated,
statistics.getCreateTime());
queryWrapper.lambda().ge(StringUtils.isNotEmpty(statistics.getCreateTime()), Statistics::getDateCalculated, statistics.getCreateTime());
//结束时间
queryWrapper.lambda().le(StringUtils.isNotEmpty(statistics.getEndTime()),Statistics::getDateCalculated,
statistics.getEndTime());
queryWrapper.lambda().le(StringUtils.isNotEmpty(statistics.getEndTime()), Statistics::getDateCalculated, statistics.getEndTime());
queryWrapper.lambda().orderByDesc(Statistics::getDateCalculated);
IPage<Statistics> statisticsPage = baseMapper.selectPage(page1, queryWrapper);
return statisticsPage;
}

14
hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/service/impl/SysLogServiceImpl.java

@ -66,6 +66,7 @@ public class SysLogServiceImpl extends ServiceImpl<SysLogMapper, SysLog> impleme
String dateCalculated = sysLog.getDateCalculated();
String moduleName = sysLog.getModuleName();
String path = sysLog.getPath();
String title = sysLog.getTitle();
QueryWrapper<SysLog> queryWrapper = new QueryWrapper<>();
if (StringUtils.isNotEmpty(sysLog.getKeyword())) {
@ -79,6 +80,16 @@ public class SysLogServiceImpl extends ServiceImpl<SysLogMapper, SysLog> impleme
queryWrapper.lambda().eq(SysLog::getPath, path);
}
//功能模块
if (StringUtils.isNotEmpty(moduleName)){
queryWrapper.lambda().eq(SysLog::getModuleName,moduleName);
}
//操作方法
if (StringUtils.isNotEmpty(title)){
queryWrapper.lambda().eq(SysLog::getTitle,title);
}
//开始时间
if (ObjectUtils.isNotEmpty(createTime)) {
@ -96,6 +107,9 @@ public class SysLogServiceImpl extends ServiceImpl<SysLogMapper, SysLog> impleme
queryWrapper.eq("date_format(operation_time,'%Y-%m')",dateCalculated);
}
queryWrapper.lambda().orderByDesc(SysLog::getOperationTime);
return queryWrapper;
}

4
hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/vo/SysLogVo.java

@ -53,4 +53,8 @@ public class SysLogVo {
private String path;
@ApiModelProperty("请求地址")
private String title;
}

Loading…
Cancel
Save