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. 30
      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 "功能模块";
/** /**

30
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"> <!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"> <mapper namespace="com.hnac.hzims.middle.systemlog.mapper.SysLogMapper">
<select id="countStatistics" resultType="com.hnac.hzims.middle.systemlog.vo.SysLogStatisticsVo"> <!-- <select id="countStatistics" resultType="com.hnac.hzims.middle.systemlog.vo.SysLogStatisticsVo">-->
select date_format(operation_time, '%Y-%m-%d') operationTime, <!-- select date_format(operation_time, '%Y-%m-%d') operationTime,-->
title, <!-- module_name,-->
count(title) titleCount, <!-- count(module_name) moduleNameCount-->
module_name, <!-- from hzims_sys_log-->
count(module_name) moduleNameCount, <!-- where to_days(operation_time) = to_days(now())-->
path, <!-- group by operationTime,module_name;-->
count(path) pathCount <!-- </select>-->
from hzims_sys_log <select id="countStatistics" resultType="com.hnac.hzims.middle.systemlog.vo.SysLogStatisticsVo">
where to_days(operation_time) = to_days(now()) select date_format(operation_time, '%Y-%m-%d') operationTime,
group by operationTime,title,module_name,path; module_name,
</select> count(module_name) moduleNameCount,
group_concat(distinct title) title,
group_concat(distinct path) path
from hzims_sys_log
where to_days(operation_time) = to_days(now())
group by module_name;
</select>
</mapper> </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.hnac.hzims.middle.systemlog.entity.Statistics;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.hnac.hzims.middle.systemlog.vo.StatisticsVo; import com.hnac.hzims.middle.systemlog.vo.StatisticsVo;
import com.hnac.hzims.middle.systemlog.vo.SysLogStatisticsVo;
import java.time.YearMonth;
import java.util.List;
/** /**
* <p> * <p>
@ -26,10 +24,10 @@ public interface StatisticsService extends IService<Statistics> {
/** /**
* 根据时间查询数据 * 根据时间查询数据
* @param operationTime * @param sysLogStatistics
* @return * @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.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.time.YearMonth;
import java.util.List; import java.util.List;
/** /**
@ -51,8 +50,11 @@ public class StatisticsServiceImpl extends ServiceImpl<StatisticsMapper, Statist
return; return;
} }
for (SysLogStatisticsVo sysLogStatisticsVo : sysLogStatisticsVoList) { for (SysLogStatisticsVo sysLogStatisticsVo : sysLogStatisticsVoList) {
if (StringUtils.isBlank(sysLogStatisticsVo.getModuleName())){
continue;
}
//查询数据 //查询数据
Statistics statistics = statisticsService.getStatisticsBydateCalculated(sysLogStatisticsVo.getOperationTime()); Statistics statistics = statisticsService.getStatisticsBydateCalculated(sysLogStatisticsVo);
//如果为空保存数据,如果不为空更新数据 //如果为空保存数据,如果不为空更新数据
if (statistics == null) { if (statistics == null) {
statistics = new Statistics(); statistics = new Statistics();
@ -61,16 +63,16 @@ public class StatisticsServiceImpl extends ServiceImpl<StatisticsMapper, Statist
statistics.setTitle(sysLogStatisticsVo.getTitle()); statistics.setTitle(sysLogStatisticsVo.getTitle());
statistics.setModuleName(sysLogStatisticsVo.getModuleName()); statistics.setModuleName(sysLogStatisticsVo.getModuleName());
statistics.setPath(sysLogStatisticsVo.getPath()); statistics.setPath(sysLogStatisticsVo.getPath());
statistics.setTitleNum(sysLogStatisticsVo.getTitleCount()); // statistics.setTitleNum(sysLogStatisticsVo.getTitleCount());
statistics.setPathNum(sysLogStatisticsVo.getPathCount()); // statistics.setPathNum(sysLogStatisticsVo.getPathCount());
statisticsService.save(statistics); statisticsService.save(statistics);
} else { } else {
statistics.setTitle(sysLogStatisticsVo.getTitle()); statistics.setTitle(sysLogStatisticsVo.getTitle());
statistics.setModuleName(sysLogStatisticsVo.getModuleName()); statistics.setModuleName(sysLogStatisticsVo.getModuleName());
statistics.setPath(sysLogStatisticsVo.getPath()); statistics.setPath(sysLogStatisticsVo.getPath());
statistics.setModuleNameNum(sysLogStatisticsVo.getModuleNameCount()); statistics.setModuleNameNum(sysLogStatisticsVo.getModuleNameCount());
statistics.setTitleNum(sysLogStatisticsVo.getTitleCount()); //statistics.setTitleNum(sysLogStatisticsVo.getTitleCount());
statistics.setPathNum(sysLogStatisticsVo.getPathCount()); //statistics.setPathNum(sysLogStatisticsVo.getPathCount());
statisticsService.updateById(statistics); statisticsService.updateById(statistics);
} }
} }
@ -79,13 +81,14 @@ public class StatisticsServiceImpl extends ServiceImpl<StatisticsMapper, Statist
/** /**
* 根据时间查询数据 * 根据时间查询数据
* *
* @param operationTime * @param sysLogStatistics
* @return * @return
*/ */
@Override @Override
public Statistics getStatisticsBydateCalculated(String operationTime) { public Statistics getStatisticsBydateCalculated(SysLogStatisticsVo sysLogStatistics) {
QueryWrapper<Statistics> statisticsQueryWrapper = new QueryWrapper<>(); 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); return baseMapper.selectOne(statisticsQueryWrapper);
} }
@ -101,11 +104,10 @@ public class StatisticsServiceImpl extends ServiceImpl<StatisticsMapper, Statist
public IPage<Statistics> selectPage(Page<Statistics> page1, StatisticsVo statistics) { public IPage<Statistics> selectPage(Page<Statistics> page1, StatisticsVo statistics) {
QueryWrapper<Statistics> queryWrapper = new QueryWrapper<>(); QueryWrapper<Statistics> queryWrapper = new QueryWrapper<>();
//开始时间 //开始时间
queryWrapper.lambda().ge(StringUtils.isNotEmpty(statistics.getCreateTime()),Statistics::getDateCalculated, queryWrapper.lambda().ge(StringUtils.isNotEmpty(statistics.getCreateTime()), Statistics::getDateCalculated, statistics.getCreateTime());
statistics.getCreateTime());
//结束时间 //结束时间
queryWrapper.lambda().le(StringUtils.isNotEmpty(statistics.getEndTime()),Statistics::getDateCalculated, queryWrapper.lambda().le(StringUtils.isNotEmpty(statistics.getEndTime()), Statistics::getDateCalculated, statistics.getEndTime());
statistics.getEndTime()); queryWrapper.lambda().orderByDesc(Statistics::getDateCalculated);
IPage<Statistics> statisticsPage = baseMapper.selectPage(page1, queryWrapper); IPage<Statistics> statisticsPage = baseMapper.selectPage(page1, queryWrapper);
return statisticsPage; 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 dateCalculated = sysLog.getDateCalculated();
String moduleName = sysLog.getModuleName(); String moduleName = sysLog.getModuleName();
String path = sysLog.getPath(); String path = sysLog.getPath();
String title = sysLog.getTitle();
QueryWrapper<SysLog> queryWrapper = new QueryWrapper<>(); QueryWrapper<SysLog> queryWrapper = new QueryWrapper<>();
if (StringUtils.isNotEmpty(sysLog.getKeyword())) { if (StringUtils.isNotEmpty(sysLog.getKeyword())) {
@ -79,6 +80,16 @@ public class SysLogServiceImpl extends ServiceImpl<SysLogMapper, SysLog> impleme
queryWrapper.lambda().eq(SysLog::getPath, path); 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)) { 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.eq("date_format(operation_time,'%Y-%m')",dateCalculated);
} }
queryWrapper.lambda().orderByDesc(SysLog::getOperationTime);
return queryWrapper; 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; private String path;
@ApiModelProperty("请求地址")
private String title;
} }

Loading…
Cancel
Save