Browse Source

修改日志分页查询

zhongwei
段飞宇 2 years ago
parent
commit
22db8e5abf
  1. 3
      hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/controller/SysLogController.java
  2. 1
      hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/mapper/StatisticsMapper.java
  3. 8
      hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/mapper/StatisticsMapper.xml
  4. 1
      hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/mapper/SysLogMapper.java
  5. 10
      hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/service/impl/StatisticsServiceImpl.java

3
hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/controller/SysLogController.java

@ -97,6 +97,9 @@ public class SysLogController {
*/
@ApiOperation("根据Id获取日志数据")
@GetMapping("/get/{id}")
@ApiResponses({
@ApiResponse(code = 200,message = "OK",response = SysLog.class),
})
public R getById(@PathVariable Long id) {
SysLog sysLog = sysLogService.getById(id);
return R.data(sysLog);

1
hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/mapper/StatisticsMapper.java

@ -18,7 +18,6 @@ import org.springframework.stereotype.Repository;
* @author dfy
* @since 2023-04-08
*/
@Repository
public interface StatisticsMapper extends BaseMapper<Statistics> {

8
hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/mapper/StatisticsMapper.xml

@ -5,6 +5,14 @@
<select id="selectPages" resultType="com.hnac.hzims.middle.systemlog.vo.StatisticsResponseVo">
select module_name moduleName, sum(module_name_num) moduleNameNum
from hzims_statistics
<where>
<if test="statistics.createTime != null">
date_format(date_calculated,'%Y-%m-%d') &gt;= #{statistics.createTime}
</if>
<if test="statistics.endTime != null">
and date_format(date_calculated,'%Y-%m-%d') &lt;= #{statistics.endTime}
</if>
</where>
group by module_name;
</select>
</mapper>

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

@ -21,7 +21,6 @@ import java.util.List;
* @author dfy
* @since 2023-04-04
*/
@Repository
public interface SysLogMapper extends BaseMapper<SysLog> {
/**

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

@ -33,10 +33,6 @@ public class StatisticsServiceImpl extends ServiceImpl<StatisticsMapper, Statist
@Autowired
private SysLogService sysLogService;
@Autowired
private StatisticsService statisticsService;
/**
* 保存统计的数据
*/
@ -55,18 +51,18 @@ public class StatisticsServiceImpl extends ServiceImpl<StatisticsMapper, Statist
continue;
}
//查询数据
Statistics statistics = statisticsService.getStatisticsBydateCalculated(sysLogStatisticsVo);
Statistics statistics = this.getStatisticsBydateCalculated(sysLogStatisticsVo);
//如果为空保存数据,如果不为空更新数据
if (statistics == null) {
statistics = new Statistics();
statistics.setDateCalculated(sysLogStatisticsVo.getOperationTime());
statistics.setModuleNameNum(sysLogStatisticsVo.getModuleNameCount());
statistics.setModuleName(sysLogStatisticsVo.getModuleName());
statisticsService.save(statistics);
this.save(statistics);
} else {
statistics.setModuleName(sysLogStatisticsVo.getModuleName());
statistics.setModuleNameNum(sysLogStatisticsVo.getModuleNameCount());
statisticsService.updateById(statistics);
this.updateById(statistics);
}
}
}

Loading…
Cancel
Save