1、统计服务根据日期统计apiLog实现
This commit is contained in:
parent
771c524ae6
commit
02881dd139
|
|
@ -7,8 +7,13 @@ import com.xjs.business.log.domain.TaskLog;
|
||||||
import com.xjs.business.log.domain.WebmagicLog;
|
import com.xjs.business.log.domain.WebmagicLog;
|
||||||
import com.xjs.business.log.factory.RemoteLogFactory;
|
import com.xjs.business.log.factory.RemoteLogFactory;
|
||||||
import org.springframework.cloud.openfeign.FeignClient;
|
import org.springframework.cloud.openfeign.FeignClient;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* rpc远程调用日志服务接口
|
* rpc远程调用日志服务接口
|
||||||
|
|
@ -23,6 +28,9 @@ public interface RemoteLogFeign {
|
||||||
@PostMapping("/apilog/forPRC")
|
@PostMapping("/apilog/forPRC")
|
||||||
R<Object> saveApiLog(@RequestBody ApiLog apiLog);
|
R<Object> saveApiLog(@RequestBody ApiLog apiLog);
|
||||||
|
|
||||||
|
@GetMapping("/apilog/byDateForRPC")
|
||||||
|
R<Map<String, List>> statisticsByDate(@RequestParam("startDate") String startDate, @RequestParam("endDate") String endDate);
|
||||||
|
|
||||||
|
|
||||||
@PostMapping("reptileLog/saveForPRC")
|
@PostMapping("reptileLog/saveForPRC")
|
||||||
R<Object> saveReptileLog(@RequestBody WebmagicLog webmagicLog);
|
R<Object> saveReptileLog(@RequestBody WebmagicLog webmagicLog);
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,9 @@ import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.cloud.openfeign.FallbackFactory;
|
import org.springframework.cloud.openfeign.FallbackFactory;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 日志远程调用rpc服务降级处理
|
* 日志远程调用rpc服务降级处理
|
||||||
* @author xiejs
|
* @author xiejs
|
||||||
|
|
@ -28,6 +31,12 @@ public class RemoteLogFactory implements FallbackFactory<RemoteLogFeign> {
|
||||||
return R.fail("日志模块api日志服务添加调用失败" + cause.getMessage());
|
return R.fail("日志模块api日志服务添加调用失败" + cause.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public R<Map<String, List>> statisticsByDate(String startDate, String endDate) {
|
||||||
|
log.error("日志模块api日志服务根据时间查询调用失败");
|
||||||
|
return R.fail("日志模块api日志服务根据时间查询调用失败" + cause.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public R<Object> saveReptileLog(WebmagicLog webmagicLog) {
|
public R<Object> saveReptileLog(WebmagicLog webmagicLog) {
|
||||||
log.error("日志模块爬虫日志服务添加调用失败");
|
log.error("日志模块爬虫日志服务添加调用失败");
|
||||||
|
|
|
||||||
|
|
@ -16,3 +16,12 @@ export function getStatisticsTodayApi() {
|
||||||
method: 'get',
|
method: 'get',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 根据时间查询API记录统计
|
||||||
|
export function statisticsByDate(param) {
|
||||||
|
return request({
|
||||||
|
url: '/statistics/apistatistics/byDate',
|
||||||
|
method: 'get',
|
||||||
|
params:param
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,10 +4,36 @@
|
||||||
element-loading-spinner="el-icon-loading"
|
element-loading-spinner="el-icon-loading"
|
||||||
element-loading-background="rgba(0, 0, 0, 0.8)">
|
element-loading-background="rgba(0, 0, 0, 0.8)">
|
||||||
|
|
||||||
<div ref="historyChart" style="height: 400px;width: 100%;margin-top: 25px">
|
<el-form :model="historyApiLogParams" ref="historyApiLogParams"
|
||||||
|
:inline="true"
|
||||||
|
label-width="70px"
|
||||||
|
style="margin-left: 150px">
|
||||||
|
<el-form-item label="">
|
||||||
|
<el-date-picker
|
||||||
|
v-model="daterangeCreateTime"
|
||||||
|
size="small"
|
||||||
|
style="width: 320px"
|
||||||
|
value-format="yyyy-MM-dd"
|
||||||
|
format="yyyy 年 MM 月 dd 日"
|
||||||
|
type="daterange"
|
||||||
|
range-separator="-"
|
||||||
|
start-placeholder="开始日期"
|
||||||
|
end-placeholder="结束日期"
|
||||||
|
:picker-options="pickerOptions"
|
||||||
|
@change="dateQuery"
|
||||||
|
></el-date-picker>
|
||||||
|
</el-form-item>
|
||||||
|
|
||||||
|
<el-form-item>
|
||||||
|
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
|
||||||
|
|
||||||
|
<div ref="historyChart" style="height: 372px;width: 100%;margin-top: 25px">
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div ref="todayChart" style="height: 400px;width: 100%">
|
<div ref="todayChart" style="height: 372px;width: 100%">
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
@ -18,7 +44,11 @@
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
import {getStatisticsHistoryApi, getStatisticsTodayApi} from "@/api/business/statistics/apistatistics";
|
import {
|
||||||
|
getStatisticsHistoryApi,
|
||||||
|
getStatisticsTodayApi,
|
||||||
|
statisticsByDate
|
||||||
|
} from "@/api/business/statistics/apistatistics";
|
||||||
|
|
||||||
|
|
||||||
import * as echarts from 'echarts/core';
|
import * as echarts from 'echarts/core';
|
||||||
|
|
@ -29,11 +59,13 @@ import {CanvasRenderer} from 'echarts/renderers';
|
||||||
import {TitleComponent} from 'echarts/components';
|
import {TitleComponent} from 'echarts/components';
|
||||||
import {BarChart} from 'echarts/charts';
|
import {BarChart} from 'echarts/charts';
|
||||||
import { TooltipComponent } from 'echarts/components';
|
import { TooltipComponent } from 'echarts/components';
|
||||||
|
import {pickerOptions} from "@/layout/mixin/PickerOptions";
|
||||||
echarts.use([GridComponent, LineChart, CanvasRenderer, UniversalTransition, TitleComponent, BarChart,TooltipComponent]);
|
echarts.use([GridComponent, LineChart, CanvasRenderer, UniversalTransition, TitleComponent, BarChart,TooltipComponent]);
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "ApiStatistics",
|
name: "ApiStatistics",
|
||||||
|
|
||||||
|
mixins: [pickerOptions],
|
||||||
|
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
|
@ -42,6 +74,13 @@ export default {
|
||||||
|
|
||||||
//遮罩层
|
//遮罩层
|
||||||
loading: false,
|
loading: false,
|
||||||
|
|
||||||
|
historyApiLogParams: {
|
||||||
|
startDate: null,
|
||||||
|
endDate: null,
|
||||||
|
},
|
||||||
|
//检查查询范围
|
||||||
|
daterangeCreateTime: [],
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
@ -73,7 +112,6 @@ export default {
|
||||||
},
|
},
|
||||||
yAxis: {
|
yAxis: {
|
||||||
splitNumber: 10,
|
splitNumber: 10,
|
||||||
max: 2000,
|
|
||||||
},
|
},
|
||||||
series: [{
|
series: [{
|
||||||
name: '次数',
|
name: '次数',
|
||||||
|
|
@ -102,7 +140,6 @@ export default {
|
||||||
},
|
},
|
||||||
yAxis: {
|
yAxis: {
|
||||||
splitNumber: 10,
|
splitNumber: 10,
|
||||||
max: 60,
|
|
||||||
},
|
},
|
||||||
series: [{
|
series: [{
|
||||||
name: '次数',
|
name: '次数',
|
||||||
|
|
@ -133,6 +170,40 @@ export default {
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/** 重置按钮操作 */
|
||||||
|
resetQuery() {
|
||||||
|
this.daterangeCreateTime = [];
|
||||||
|
this.historyApiLogParams.startDate = null
|
||||||
|
this.historyApiLogParams.endDate = null
|
||||||
|
this.handleQuery();
|
||||||
|
},
|
||||||
|
/** 搜索按钮操作 */
|
||||||
|
handleQuery() {
|
||||||
|
this.getStatisticsTodayApi();
|
||||||
|
},
|
||||||
|
|
||||||
|
dateQuery() {
|
||||||
|
//清空时间参数
|
||||||
|
this.historyApiLogParams.startDate=null
|
||||||
|
this.historyApiLogParams.endDate=null
|
||||||
|
|
||||||
|
this.statisticsByDate();
|
||||||
|
},
|
||||||
|
|
||||||
|
statisticsByDate() {
|
||||||
|
this.loading = true
|
||||||
|
if (null != this.daterangeCreateTime && '' !== this.daterangeCreateTime) {
|
||||||
|
this.historyApiLogParams.startDate = this.daterangeCreateTime[0];
|
||||||
|
this.historyApiLogParams.endDate = this.daterangeCreateTime[1];
|
||||||
|
}
|
||||||
|
statisticsByDate(this.historyApiLogParams).then(res =>{
|
||||||
|
this.loading = false
|
||||||
|
this.todayApiData=res.data
|
||||||
|
this.initToday()
|
||||||
|
}).catch(err =>{
|
||||||
|
this.loading = false
|
||||||
|
})
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -174,7 +174,7 @@ export default {
|
||||||
|
|
||||||
//获取历史天气
|
//获取历史天气
|
||||||
getHistoryWeather() {
|
getHistoryWeather() {
|
||||||
if (null != this.daterangeCreateTime && '' != this.daterangeCreateTime) {
|
if (null != this.daterangeCreateTime && '' !== this.daterangeCreateTime) {
|
||||||
this.historyWeatherParams.startDate = this.daterangeCreateTime[0];
|
this.historyWeatherParams.startDate = this.daterangeCreateTime[0];
|
||||||
this.historyWeatherParams.endDate = this.daterangeCreateTime[1];
|
this.historyWeatherParams.endDate = this.daterangeCreateTime[1];
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@ import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 日志Controller
|
* 日志Controller
|
||||||
|
|
@ -34,6 +35,17 @@ public class ApiLogController extends BaseController {
|
||||||
private IApiLogService apiLogService;
|
private IApiLogService apiLogService;
|
||||||
|
|
||||||
|
|
||||||
|
@GetMapping("getApiName")
|
||||||
|
@ApiOperation("获取所有Api名称")
|
||||||
|
@RequiresPermissions("log:apilog:list")
|
||||||
|
public AjaxResult getApiName() {
|
||||||
|
List<String> apiNameList = apiLogService.getApiName();
|
||||||
|
return AjaxResult.success(apiNameList);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//----------------------------远程调用--------------------------------
|
||||||
|
|
||||||
@PostMapping("forPRC")
|
@PostMapping("forPRC")
|
||||||
@ApiOperation("供AOP切面RPC远程调用")
|
@ApiOperation("供AOP切面RPC远程调用")
|
||||||
public R<Object> saveApiLog(@RequestBody ApiLog apiLog) {
|
public R<Object> saveApiLog(@RequestBody ApiLog apiLog) {
|
||||||
|
|
@ -42,13 +54,11 @@ public class ApiLogController extends BaseController {
|
||||||
return save ? R.ok() : R.fail();
|
return save ? R.ok() : R.fail();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("byDateForRPC")
|
||||||
@GetMapping("getApiName")
|
@ApiOperation("根据时间查询API记录")
|
||||||
@ApiOperation("获取所有Api名称")
|
public R<Map<String, List>> statisticsByDate(@RequestParam String startDate, @RequestParam String endDate) {
|
||||||
@RequiresPermissions("log:apilog:list")
|
Map<String, List> map = apiLogService.statisticsByDate(startDate,endDate);
|
||||||
public AjaxResult getApiName() {
|
return R.ok(map);
|
||||||
List<String> apiNameList = apiLogService.getApiName();
|
|
||||||
return AjaxResult.success(apiNameList);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,8 @@ package com.xjs.apilog.mapper;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import com.xjs.apilog.domain.ApiLog;
|
import com.xjs.apilog.domain.ApiLog;
|
||||||
|
import com.xjs.apilog.vo.ApiLogVo;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
@ -13,6 +15,15 @@ import java.util.List;
|
||||||
*/
|
*/
|
||||||
public interface ApiLogMapper extends BaseMapper<ApiLog> {
|
public interface ApiLogMapper extends BaseMapper<ApiLog> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
*根据时间查询API记录统计
|
||||||
|
* @param startDate 开始时间
|
||||||
|
* @param endDate 结束时间
|
||||||
|
* @return list
|
||||||
|
*/
|
||||||
|
List<ApiLogVo> statisticsByDate(@Param("startDate") String startDate, @Param("endDate") String endDate);
|
||||||
|
|
||||||
|
|
||||||
//------------------------代码自动生成-----------------------------------
|
//------------------------代码自动生成-----------------------------------
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -46,4 +57,6 @@ public interface ApiLogMapper extends BaseMapper<ApiLog> {
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public int deleteApiLogByIds(Long[] ids);
|
public int deleteApiLogByIds(Long[] ids);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
import com.xjs.apilog.domain.ApiLog;
|
import com.xjs.apilog.domain.ApiLog;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 日志Service接口
|
* 日志Service接口
|
||||||
|
|
@ -52,4 +53,12 @@ public interface IApiLogService extends IService<ApiLog> {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
List<String> getApiName();
|
List<String> getApiName();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据时间查询API记录统计
|
||||||
|
* @param startDate 开始时间
|
||||||
|
* @param endDate 结束时间
|
||||||
|
* @return map
|
||||||
|
*/
|
||||||
|
Map<String, List> statisticsByDate(String startDate, String endDate);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,12 +6,16 @@ import com.ruoyi.common.core.domain.R;
|
||||||
import com.xjs.apilog.domain.ApiLog;
|
import com.xjs.apilog.domain.ApiLog;
|
||||||
import com.xjs.apilog.mapper.ApiLogMapper;
|
import com.xjs.apilog.mapper.ApiLogMapper;
|
||||||
import com.xjs.apilog.service.IApiLogService;
|
import com.xjs.apilog.service.IApiLogService;
|
||||||
|
import com.xjs.apilog.vo.ApiLogVo;
|
||||||
import com.xjs.business.warning.RemoteWarningCRUDFeign;
|
import com.xjs.business.warning.RemoteWarningCRUDFeign;
|
||||||
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 javax.annotation.Resource;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 日志Service业务层处理
|
* 日志Service业务层处理
|
||||||
|
|
@ -21,7 +25,7 @@ import java.util.List;
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
public class ApiLogServiceImpl extends ServiceImpl<ApiLogMapper,ApiLog> implements IApiLogService {
|
public class ApiLogServiceImpl extends ServiceImpl<ApiLogMapper,ApiLog> implements IApiLogService {
|
||||||
@Autowired
|
@Resource
|
||||||
private ApiLogMapper apiLogMapper;
|
private ApiLogMapper apiLogMapper;
|
||||||
@Autowired
|
@Autowired
|
||||||
private RemoteWarningCRUDFeign remoteWarningCRUDFeign;
|
private RemoteWarningCRUDFeign remoteWarningCRUDFeign;
|
||||||
|
|
@ -80,4 +84,19 @@ public class ApiLogServiceImpl extends ServiceImpl<ApiLogMapper,ApiLog> implemen
|
||||||
}
|
}
|
||||||
return new ArrayList<String>();
|
return new ArrayList<String>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<String, List> statisticsByDate(String startDate, String endDate) {
|
||||||
|
List<ApiLogVo> recordList =apiLogMapper.statisticsByDate(startDate, endDate);
|
||||||
|
Map<String, List> map = new HashMap<>();
|
||||||
|
List<String> apiNames = new ArrayList<>();
|
||||||
|
List<Long> count = new ArrayList<>();
|
||||||
|
recordList.forEach(record ->{
|
||||||
|
apiNames.add(record.getApiName());
|
||||||
|
count.add(record.getCount());
|
||||||
|
});
|
||||||
|
map.put("apiNames", apiNames);
|
||||||
|
map.put("count", count);
|
||||||
|
return map;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,23 @@
|
||||||
|
package com.xjs.apilog.vo;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* api日志vo
|
||||||
|
* @author xiejs
|
||||||
|
* @since 2022-04-06
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class ApiLogVo {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* api名称
|
||||||
|
*/
|
||||||
|
private String apiName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数量
|
||||||
|
*/
|
||||||
|
private Long count;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -36,6 +36,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
<include refid="selectApiLogVo"/>
|
<include refid="selectApiLogVo"/>
|
||||||
where id = #{id}
|
where id = #{id}
|
||||||
</select>
|
</select>
|
||||||
|
<select id="statisticsByDate" resultType="com.xjs.apilog.vo.ApiLogVo">
|
||||||
|
select api_name ,count(api_name) count FROM
|
||||||
|
(select api_name from api_log where
|
||||||
|
create_time BETWEEN #{startDate} and #{endDate}) t
|
||||||
|
GROUP BY api_name
|
||||||
|
</select>
|
||||||
|
|
||||||
<delete id="deleteApiLogById" parameterType="Long">
|
<delete id="deleteApiLogById" parameterType="Long">
|
||||||
delete from api_log where id = #{id}
|
delete from api_log where id = #{id}
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ import io.swagger.annotations.ApiOperation;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
@ -42,4 +43,12 @@ public class ApiStatisticsController {
|
||||||
return R.ok(map);
|
return R.ok(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("byDate")
|
||||||
|
@ApiOperation("根据时间查询API记录统计")
|
||||||
|
@RequiresPermissions("statistics:apistatistics:list")
|
||||||
|
public R<Map<String, List>> statisticsByDate(@RequestParam String startDate,@RequestParam String endDate) {
|
||||||
|
Map<String, List> map = apiStatisticsService.statisticsByDate(startDate,endDate);
|
||||||
|
return R.ok(map);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,4 +24,11 @@ public interface ApiStatisticsService {
|
||||||
*/
|
*/
|
||||||
Map<String, List> statisticsTodayApi();
|
Map<String, List> statisticsTodayApi();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据时间查询API记录统计
|
||||||
|
* @param startDate 开始时间
|
||||||
|
* @param endDate 结束时间
|
||||||
|
* @return map
|
||||||
|
*/
|
||||||
|
Map<String, List> statisticsByDate(String startDate, String endDate);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
package com.xjs.service.impl;
|
package com.xjs.service.impl;
|
||||||
|
|
||||||
|
import com.ruoyi.common.core.constant.HttpStatus;
|
||||||
import com.ruoyi.common.core.domain.R;
|
import com.ruoyi.common.core.domain.R;
|
||||||
|
import com.xjs.business.log.RemoteLogFeign;
|
||||||
import com.xjs.business.warning.RemoteWarningCRUDFeign;
|
import com.xjs.business.warning.RemoteWarningCRUDFeign;
|
||||||
import com.xjs.business.warning.domain.ApiRecord;
|
import com.xjs.business.warning.domain.ApiRecord;
|
||||||
import com.xjs.service.ApiStatisticsService;
|
import com.xjs.service.ApiStatisticsService;
|
||||||
|
|
@ -14,6 +16,7 @@ import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* api统计服务接口实现
|
* api统计服务接口实现
|
||||||
|
*
|
||||||
* @author xiejs
|
* @author xiejs
|
||||||
* @since 2022-01-25
|
* @since 2022-01-25
|
||||||
*/
|
*/
|
||||||
|
|
@ -23,6 +26,8 @@ public class ApiStatisticsServiceImpl implements ApiStatisticsService {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private RemoteWarningCRUDFeign remoteWarningCRUDFeign;
|
private RemoteWarningCRUDFeign remoteWarningCRUDFeign;
|
||||||
|
@Autowired
|
||||||
|
private RemoteLogFeign remoteLogFeign;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, List> statisticsHistoryApi() {
|
public Map<String, List> statisticsHistoryApi() {
|
||||||
|
|
@ -30,7 +35,7 @@ public class ApiStatisticsServiceImpl implements ApiStatisticsService {
|
||||||
Map<String, List> map = new HashMap<>();
|
Map<String, List> map = new HashMap<>();
|
||||||
List<String> apiNames = new ArrayList<>();
|
List<String> apiNames = new ArrayList<>();
|
||||||
List<Long> count = new ArrayList<>();
|
List<Long> count = new ArrayList<>();
|
||||||
recordList.forEach(record ->{
|
recordList.forEach(record -> {
|
||||||
apiNames.add(record.getApiName());
|
apiNames.add(record.getApiName());
|
||||||
count.add(record.getTotalCount());
|
count.add(record.getTotalCount());
|
||||||
});
|
});
|
||||||
|
|
@ -45,7 +50,7 @@ public class ApiStatisticsServiceImpl implements ApiStatisticsService {
|
||||||
Map<String, List> map = new HashMap<>();
|
Map<String, List> map = new HashMap<>();
|
||||||
List<String> apiNames = new ArrayList<>();
|
List<String> apiNames = new ArrayList<>();
|
||||||
List<Long> count = new ArrayList<>();
|
List<Long> count = new ArrayList<>();
|
||||||
recordList.forEach(record ->{
|
recordList.forEach(record -> {
|
||||||
apiNames.add(record.getApiName());
|
apiNames.add(record.getApiName());
|
||||||
count.add(record.getDayCount());
|
count.add(record.getDayCount());
|
||||||
});
|
});
|
||||||
|
|
@ -54,13 +59,28 @@ public class ApiStatisticsServiceImpl implements ApiStatisticsService {
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<String, List> statisticsByDate(String startDate, String endDate) {
|
||||||
|
R<Map<String, List>> r = remoteLogFeign.statisticsByDate(startDate, endDate);
|
||||||
|
if (r.getCode() == HttpStatus.SUCCESS) {
|
||||||
|
return r.getData();
|
||||||
|
}else {
|
||||||
|
return new HashMap<>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取R中的data
|
* 获取R中的data
|
||||||
|
*
|
||||||
* @return List
|
* @return List
|
||||||
*/
|
*/
|
||||||
private List<ApiRecord> getData() {
|
private List<ApiRecord> getData() {
|
||||||
R<List<ApiRecord>> listR = remoteWarningCRUDFeign.selectApiRecordListForRPC();
|
R<List<ApiRecord>> listR = remoteWarningCRUDFeign.selectApiRecordListForRPC();
|
||||||
return listR.getData();
|
if (listR.getCode() == HttpStatus.SUCCESS) {
|
||||||
|
return listR.getData();
|
||||||
|
} else {
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue