Commit 6cec22f8 by 黄明步

新增oa用户识别记录

parent 77135644
...@@ -11,12 +11,16 @@ import com.alibaba.fastjson.JSON; ...@@ -11,12 +11,16 @@ import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.gxmailu.ocrCloudPlatform.dto.RecordDto; import com.gxmailu.ocrCloudPlatform.dto.RecordDto;
import com.gxmailu.ocrCloudPlatform.entity.AppAbilityRecordAll; import com.gxmailu.ocrCloudPlatform.entity.AppAbilityRecordAll;
import com.gxmailu.ocrCloudPlatform.entity.OaCallRecord;
import com.gxmailu.ocrCloudPlatform.excel.handler.ExcelFillCellMergeStrategy; import com.gxmailu.ocrCloudPlatform.excel.handler.ExcelFillCellMergeStrategy;
import com.gxmailu.ocrCloudPlatform.excel.model.CallRecordModel; import com.gxmailu.ocrCloudPlatform.excel.model.CallRecordModel;
import com.gxmailu.ocrCloudPlatform.excel.utils.ExcelStyleUtils; import com.gxmailu.ocrCloudPlatform.excel.utils.ExcelStyleUtils;
import com.gxmailu.ocrCloudPlatform.service.AppAbilityRecordAllService; import com.gxmailu.ocrCloudPlatform.service.AppAbilityRecordAllService;
import com.gxmailu.ocrCloudPlatform.service.OaCallRecordService;
import com.gxmailu.ocrCloudPlatform.vo.AppAbilityRecordVo; import com.gxmailu.ocrCloudPlatform.vo.AppAbilityRecordVo;
import com.gxmailu.ocrCloudPlatform.vo.Result; import com.gxmailu.ocrCloudPlatform.vo.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -37,6 +41,7 @@ import java.util.Map; ...@@ -37,6 +41,7 @@ import java.util.Map;
* @author zyz * @author zyz
* @since 2023-05-11 * @since 2023-05-11
*/ */
@Api(tags = "应用调用记录相关接口")
@Slf4j @Slf4j
@RestController @RestController
@RequestMapping("/appAbilityRecordAll") @RequestMapping("/appAbilityRecordAll")
...@@ -45,13 +50,16 @@ public class AppAbilityRecordAllController { ...@@ -45,13 +50,16 @@ public class AppAbilityRecordAllController {
@Autowired @Autowired
private AppAbilityRecordAllService recordAllService; private AppAbilityRecordAllService recordAllService;
@Autowired
private OaCallRecordService oaCallRecordService;
/** /**
* 导出应用调用记录 * 导出应用调用记录
* *
* @param yearMonthDay 年月日 * @param yearMonthDay 年月日
*/ */
@RequestMapping("/deriveCallRecord") @GetMapping("/deriveCallRecord")
@ResponseBody @ApiOperation(value = "导出调用记录")
public void deriveCallRecord(String yearMonthDay, String endYearMonthDay, HttpServletResponse response) { public void deriveCallRecord(String yearMonthDay, String endYearMonthDay, HttpServletResponse response) {
// 设置到新的对象上,用以下面的文件名称处理 // 设置到新的对象上,用以下面的文件名称处理
String newYearMonthDay = yearMonthDay; String newYearMonthDay = yearMonthDay;
...@@ -173,6 +181,7 @@ public class AppAbilityRecordAllController { ...@@ -173,6 +181,7 @@ public class AppAbilityRecordAllController {
} }
@PostMapping("/getListByPage") @PostMapping("/getListByPage")
@ApiOperation(value = "获取应用调用记录")
public Result getListByPage(@RequestBody RecordDto recordDto) { public Result getListByPage(@RequestBody RecordDto recordDto) {
Assert.notNull(recordDto, "参数不能为空"); Assert.notNull(recordDto, "参数不能为空");
try { try {
...@@ -191,33 +200,62 @@ public class AppAbilityRecordAllController { ...@@ -191,33 +200,62 @@ public class AppAbilityRecordAllController {
@GetMapping("/getCourtUseSum") @GetMapping("/getCourtUseSum")
@ApiOperation(value = "获取法院总使用量")
public Object getCourtUseSum() { public Object getCourtUseSum() {
return recordAllService.getCourtUseSum(); return recordAllService.getCourtUseSum();
} }
@GetMapping("/getCourtUseInYear") @GetMapping("/getCourtUseInYear")
@ApiOperation(value = "获取法院年度使用量")
public Object getCourtUseInYear(@RequestParam Integer year, @RequestParam String courtName) { public Object getCourtUseInYear(@RequestParam Integer year, @RequestParam String courtName) {
return recordAllService.getCourtUseInYear(year, courtName); return recordAllService.getCourtUseInYear(year, courtName);
} }
@GetMapping("/getCourtUseInMonth") @GetMapping("/getCourtUseInMonth")
@ApiOperation(value = "获取法院月使用量")
public Object getCourtUseInMonth(Integer year, Integer month, String courtName) { public Object getCourtUseInMonth(Integer year, Integer month, String courtName) {
return recordAllService.getCourtUseInMonth(year, month, courtName); return recordAllService.getCourtUseInMonth(year, month, courtName);
} }
@GetMapping("/getCourtUseInDay") @GetMapping("/getCourtUseInDay")
@ApiOperation(value = "获取法院日使用量")
public Object getCourtUseInDay(Integer year, Integer month, Integer day, String courtName) { public Object getCourtUseInDay(Integer year, Integer month, Integer day, String courtName) {
return recordAllService.getCourtUseInDay(year, month, day, courtName); return recordAllService.getCourtUseInDay(year, month, day, courtName);
} }
@GetMapping("getCorrelationData") @GetMapping("getCorrelationData")
@ApiOperation(value = "获取今日昨日对比折线图")
public Result getCorrelationDate(String day1, String day2) { public Result getCorrelationDate(String day1, String day2) {
return recordAllService.getCorrelationData(day1, day2); return recordAllService.getCorrelationData(day1, day2);
} }
@GetMapping("getBrokenLineData") @GetMapping("getBrokenLineData")
@ApiOperation(value = "获取指定日期折线图")
public Result getBrokenLineData(String date) { public Result getBrokenLineData(String date) {
return recordAllService.getBrokenLineData(date); return recordAllService.getBrokenLineData(date);
} }
@PostMapping("/saveOaOcrRecord")
@ApiOperation(value = "保存Oa门户用户的调用OCR记录")
public Result saveOaOcrRecord(@RequestBody OaCallRecord oaCallRecord) {
try {
List<AppAbilityRecordAll> recordList = recordAllService.getRecordByFileId(oaCallRecord.getFileIds());
int sum = recordList.stream().mapToInt(AppAbilityRecordAll::getFileCount).sum();
oaCallRecord.setPages(sum);
oaCallRecord.setCreateTime(DateUtil.date());
oaCallRecordService.save(oaCallRecord);
return Result.success("成功");
} catch (Exception e) {
log.error("saveOaOcrRecord执行失败", e);
}
return Result.error("保存OA用户调用记录失败");
}
@GetMapping("/getOaCallRecords")
@ApiOperation(value = "查询Oa门户用户的调用OCR记录")
public Result getOaCallRecordList(RecordDto dto) {
return Result.success("查询成功", oaCallRecordService.getOaCallRecordList(dto));
}
} }
...@@ -13,7 +13,6 @@ import org.springframework.web.bind.annotation.RequestParam; ...@@ -13,7 +13,6 @@ import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.*;
/** /**
* 统计相关 * 统计相关
...@@ -54,20 +53,4 @@ public class StatController { ...@@ -54,20 +53,4 @@ public class StatController {
public Result getServerMonitoring(@RequestParam(value = "time", required = false) Long time) { public Result getServerMonitoring(@RequestParam(value = "time", required = false) Long time) {
return statService.getServerMonitoring(time); return statService.getServerMonitoring(time);
} }
public static void main(String[] args) {
List<List<String>> listOfLists = new ArrayList<>();
listOfLists.add(Arrays.asList("b", "2", "3"));
listOfLists.add(Arrays.asList("a", "4", "5"));
listOfLists.add(Arrays.asList("d", "6", "7"));
listOfLists.add(Arrays.asList("c", "8", "9"));
System.out.println("原始二维列表:" + listOfLists);
// 对二维列表中的元素进行排序
Collections.sort(listOfLists, Comparator.comparing(list -> list.get(0)));
System.out.println("按第一个元素排序后的二维列表:" + listOfLists);
}
} }
...@@ -34,4 +34,14 @@ public class RecordDto implements Serializable { ...@@ -34,4 +34,14 @@ public class RecordDto implements Serializable {
*/ */
private Integer network; private Integer network;
/**
* 门户用户昵称
*/
private String nickName;
/**
* 部门名称
*/
private String deptName;
} }
/*
* Copyright 2019-2020 Zheng Jie
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.gxmailu.ocrCloudPlatform.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
/**
* 在线用户
*
* @author wilmiam
* @since 2021-07-09 18:13
*/
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@TableName("oa_call_record")
public class OaCallRecord implements Serializable {
@TableId(type = IdType.AUTO)
private Integer id;
/**
* 用户ID
*/
private Long userId;
/**
* 用户名
*/
private String userName;
/**
* 昵称
*/
private String nickName;
/**
* 部门ID
*/
private Long deptId;
/**
* 部门名称
*/
private String deptName;
/**
* 浏览器
*/
private String browser;
/**
* IP
*/
private String ip;
/**
* 地址
*/
private String address;
/**
* 登录时间
*/
private Date loginTime;
/**
* 文件id列表
*/
@TableField(exist = false)
@JsonIgnore
private List<String> fileIds;
/**
* 识别页数
*/
private Integer pages;
private Date createTime;
private Date updateTime;
}
package com.gxmailu.ocrCloudPlatform.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.gxmailu.ocrCloudPlatform.entity.OaCallRecord;
import org.apache.ibatis.annotations.Mapper;
/**
* <p>
* Oa门户用户ocr识别记录
* </p>
*
* @author Hmb
* @since 2024-04-19
*/
@Mapper
public interface OaCallRecordMapper extends BaseMapper<OaCallRecord> {
}
...@@ -4,7 +4,6 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; ...@@ -4,7 +4,6 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.gxmailu.ocrCloudPlatform.dto.RecordDto; import com.gxmailu.ocrCloudPlatform.dto.RecordDto;
import com.gxmailu.ocrCloudPlatform.entity.AppAbilityRecordAll; import com.gxmailu.ocrCloudPlatform.entity.AppAbilityRecordAll;
import com.gxmailu.ocrCloudPlatform.entity.DeriveCallRecord;
import com.gxmailu.ocrCloudPlatform.excel.model.CallRecordModel; import com.gxmailu.ocrCloudPlatform.excel.model.CallRecordModel;
import com.gxmailu.ocrCloudPlatform.vo.AppAbilityRecordVo; import com.gxmailu.ocrCloudPlatform.vo.AppAbilityRecordVo;
import com.gxmailu.ocrCloudPlatform.vo.Result; import com.gxmailu.ocrCloudPlatform.vo.Result;
...@@ -42,4 +41,5 @@ public interface AppAbilityRecordAllService extends IService<AppAbilityRecordAll ...@@ -42,4 +41,5 @@ public interface AppAbilityRecordAllService extends IService<AppAbilityRecordAll
Result getBrokenLineData(String date); Result getBrokenLineData(String date);
Page<AppAbilityRecordVo> getRecordListByPage(RecordDto recordDto) throws IOException; Page<AppAbilityRecordVo> getRecordListByPage(RecordDto recordDto) throws IOException;
List<AppAbilityRecordAll> getRecordByFileId(List<String> fileIds) throws Exception;
} }
package com.gxmailu.ocrCloudPlatform.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.gxmailu.ocrCloudPlatform.dto.RecordDto;
import com.gxmailu.ocrCloudPlatform.entity.OaCallRecord;
/**
* <p>
* OaOCR调用记录 服务类
* </p>
*
* @author Hmb
* @since 2024-04-12
*/
public interface OaCallRecordService extends IService<OaCallRecord> {
Page<OaCallRecord> getOaCallRecordList(RecordDto dto);
}
...@@ -182,6 +182,18 @@ public class AppAbilityRecordAllServiceImpl extends ServiceImpl<AppAbilityRecord ...@@ -182,6 +182,18 @@ public class AppAbilityRecordAllServiceImpl extends ServiceImpl<AppAbilityRecord
} }
@Override @Override
public List<AppAbilityRecordAll> getRecordByFileId(List<String> fileIds) throws Exception {
List<AppAbilityRecordAll> list = new ArrayList<>();
for (String fileId : fileIds) {
AppAbilityRecordAll record = elasticSearchService.getRecordByFileId(fileId);
if (record != null) {
list.add(record);
}
}
return list;
}
@Override
public Object getCourtUseSum() { public Object getCourtUseSum() {
List<Court> courtList = courtService.getCourtList(); List<Court> courtList = courtService.getCourtList();
return elasticSearchService.getCourtUseSum(courtList); return elasticSearchService.getCourtUseSum(courtList);
......
...@@ -544,4 +544,21 @@ public class ElasticSearchService { ...@@ -544,4 +544,21 @@ public class ElasticSearchService {
// 将 Map 中的值转回列表 // 将 Map 中的值转回列表
return new ArrayList<>(mergedMap.values()); return new ArrayList<>(mergedMap.values());
} }
public AppAbilityRecordAll getRecordByFileId(String fileId) throws Exception {
SearchResponse<AppAbilityRecordAll> response = client.search(s -> s
.index(APP_ABILITY_RECORD_INDEX)
.size(1)
.query(q -> q.bool(boolQuery -> {
if (StrUtil.isNotBlank(fileId)) {
boolQuery.must(builder -> builder.term(t -> t.field("fileId").value(fileId)));
}
return boolQuery;
})), AppAbilityRecordAll.class);
return CollUtil.isEmpty(response.hits().hits()) ? null : response.hits().hits().get(0).source();
}
} }
package com.gxmailu.ocrCloudPlatform.service.impl;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxmailu.ocrCloudPlatform.dto.RecordDto;
import com.gxmailu.ocrCloudPlatform.entity.OaCallRecord;
import com.gxmailu.ocrCloudPlatform.mapper.OaCallRecordMapper;
import com.gxmailu.ocrCloudPlatform.service.OaCallRecordService;
import org.springframework.stereotype.Service;
/**
* <p>
* OaOCR调用记录 服务实现类
* </p>
*
* @author zyz
* @since 2024-04-12
*/
@Service
public class OaCallRecordServiceImpl extends ServiceImpl<OaCallRecordMapper, OaCallRecord> implements OaCallRecordService {
@Override
public Page<OaCallRecord> getOaCallRecordList(RecordDto dto) {
LambdaQueryWrapper<OaCallRecord> wrapper = Wrappers.lambdaQuery(OaCallRecord.class);
if (StrUtil.isNotBlank(dto.getNickName())) {
wrapper.like(OaCallRecord::getNickName, dto.getNickName());
}
if (StrUtil.isNotBlank(dto.getDeptName())) {
wrapper.like(OaCallRecord::getDeptName, dto.getDeptName());
}
Page<OaCallRecord> page = new Page<>(dto.getPage(), dto.getLimit());
return baseMapper.selectPage(page, wrapper);
}
}
...@@ -34,6 +34,7 @@ import javax.annotation.Resource; ...@@ -34,6 +34,7 @@ import javax.annotation.Resource;
import java.io.IOException; import java.io.IOException;
import java.util.*; import java.util.*;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
...@@ -305,7 +306,7 @@ public class StatService { ...@@ -305,7 +306,7 @@ public class StatService {
.eq(ServerInfo::getNetwork, "0") .eq(ServerInfo::getNetwork, "0")
.select(ServerInfo::getIp, ServerInfo::getName)); .select(ServerInfo::getIp, ServerInfo::getName));
List<List<String>> metricList = new ArrayList<>(); List<List<String>> metricList = new CopyOnWriteArrayList<>();
List<CompletableFuture<Void>> futures = new ArrayList<>(); List<CompletableFuture<Void>> futures = new ArrayList<>();
...@@ -378,7 +379,11 @@ public class StatService { ...@@ -378,7 +379,11 @@ public class StatService {
} }
CompletableFuture.allOf(futures.toArray(new CompletableFuture[0])).join(); // 等待所有查询完成 CompletableFuture.allOf(futures.toArray(new CompletableFuture[0])).join(); // 等待所有查询完成
// 根据每个一维数组的第一个元素进行排序 // 根据每个一维数组的第一个元素进行排序
metricList.sort(Comparator.comparing(list -> list.get(0)));
metricList.sort(Comparator.comparing(
list -> list != null && !list.isEmpty() ? list.get(0) : null,
Comparator.nullsLast(Comparator.naturalOrder())
));
List<String> metricName = new ArrayList<>(Arrays.asList("metric", "硬盘", "CPU", "内存", "GPU", "近5分钟平均系统负载")); List<String> metricName = new ArrayList<>(Arrays.asList("metric", "硬盘", "CPU", "内存", "GPU", "近5分钟平均系统负载"));
// 添加到第一个元素 // 添加到第一个元素
...@@ -391,7 +396,7 @@ public class StatService { ...@@ -391,7 +396,7 @@ public class StatService {
log.error("查询服务器资源信息发生异常:" , e); log.error("查询服务器资源信息发生异常:" , e);
Object value = redisService.getValue(RedisConstant.SERVER_MONITORING); Object value = redisService.getValue(RedisConstant.SERVER_MONITORING);
List<Object> list = JSONUtil.toList(value.toString(), Object.class); List<Object> list = JSONUtil.toList(value.toString(), Object.class);
return Result.error("查询资源信息失败", list); return Result.success("成功", list);
} }
} }
} }
...@@ -48,7 +48,7 @@ public class PrometheusHttpUtil { ...@@ -48,7 +48,7 @@ public class PrometheusHttpUtil {
public static PromDataInfo getQueryDataInfo(String promQL, Long time) { public static PromDataInfo getQueryDataInfo(String promQL, Long time) {
time = null != time ? time : System.currentTimeMillis() / 1000; time = null != time ? time : System.currentTimeMillis() / 1000;
log.info("请求地址:{},请求PromQL:{},时间戳:{}", QUERY_URL, promQL, time); // log.info("请求地址:{},请求PromQL:{},时间戳:{}", QUERY_URL, promQL, time);
JSONObject param = new JSONObject(); JSONObject param = new JSONObject();
param.put(PromConstants.QUERY, promQL); param.put(PromConstants.QUERY, promQL);
param.put("time", time); param.put("time", time);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment