feat():日志接口
This commit is contained in:
@@ -0,0 +1,39 @@
|
|||||||
|
package com.fizz.business.controller;
|
||||||
|
|
||||||
|
import com.fizz.business.domain.LogData;
|
||||||
|
import com.fizz.business.form.LogDataForm;
|
||||||
|
import com.fizz.business.service.LogDataService;
|
||||||
|
import com.github.pagehelper.PageInfo;
|
||||||
|
import com.ruoyi.common.annotation.Anonymous;
|
||||||
|
import com.ruoyi.common.core.domain.R;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
@RequestMapping("/logdata" )
|
||||||
|
@Api("南钢日志接口")
|
||||||
|
@Anonymous
|
||||||
|
public class LogDataController {
|
||||||
|
|
||||||
|
private final LogDataService logDataService;
|
||||||
|
|
||||||
|
@ApiOperation("历史记录")
|
||||||
|
@PostMapping ("/list" )
|
||||||
|
public R<PageInfo<LogData>> getLogDataPage(@RequestBody LogDataForm logDataForm) {
|
||||||
|
return R.ok(logDataService.pageList(logDataForm));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "报警确认", description = "报警确认")
|
||||||
|
@PatchMapping("/confirm/{seqid}" )
|
||||||
|
//@PreAuthorize("@pms.hasPermission('business_log_data_edit')" )
|
||||||
|
public R<?> alarmAck(@PathVariable Integer seqid) {
|
||||||
|
logDataService.alarmAck(seqid);
|
||||||
|
return R.ok();
|
||||||
|
}
|
||||||
|
}
|
||||||
66
business/src/main/java/com/fizz/business/domain/LogData.java
Normal file
66
business/src/main/java/com/fizz/business/domain/LogData.java
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
package com.fizz.business.domain;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@TableName("log_data")
|
||||||
|
@Schema(description = "")
|
||||||
|
public class LogData {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* seqid
|
||||||
|
*/
|
||||||
|
@TableId(type = IdType.ASSIGN_ID)
|
||||||
|
@Schema(description ="seqid")
|
||||||
|
private Integer seqid;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* timestamp
|
||||||
|
*/
|
||||||
|
@Schema(description ="timestamp")
|
||||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss")
|
||||||
|
private Date timestamp;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* module
|
||||||
|
*/
|
||||||
|
@Schema(description ="module")
|
||||||
|
private String module;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* logtype
|
||||||
|
*/
|
||||||
|
@Schema(description ="logtype")
|
||||||
|
private String logtype;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* logtext
|
||||||
|
*/
|
||||||
|
@Schema(description ="logtext")
|
||||||
|
private String logtext;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* status
|
||||||
|
*/
|
||||||
|
@Schema(description ="status")
|
||||||
|
private Integer status;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* confirmTime
|
||||||
|
*/
|
||||||
|
@Schema(description ="confirmTime")
|
||||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss")
|
||||||
|
private Date confirmTime;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
package com.fizz.business.form;
|
||||||
|
|
||||||
|
import cn.hutool.core.date.DatePattern;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class LogDataForm implements Serializable {
|
||||||
|
private static final long serialVersionUID = 1126261593345506267L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 开始时间
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(value = "开始时间")
|
||||||
|
@DateTimeFormat(pattern = DatePattern.NORM_DATETIME_PATTERN)
|
||||||
|
private LocalDateTime startTime;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "结束时间")
|
||||||
|
@DateTimeFormat(pattern = DatePattern.NORM_DATETIME_PATTERN)
|
||||||
|
private LocalDateTime endTime;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "报警类型")
|
||||||
|
private String logtype;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 报警模块
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(value = "报警模块")
|
||||||
|
private String module;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 警报内容
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(value = "警报内容")
|
||||||
|
private String logtext;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 报警状态
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(value = "报警状态")
|
||||||
|
private Integer status;
|
||||||
|
|
||||||
|
private int pageNum;
|
||||||
|
|
||||||
|
private int pageSize;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
package com.fizz.business.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.fizz.business.domain.LogData;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public interface LogDataMapper extends BaseMapper<LogData> {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
package com.fizz.business.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.PageDTO;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.fizz.business.domain.LogData;
|
||||||
|
import com.fizz.business.form.LogDataForm;
|
||||||
|
import com.github.pagehelper.PageInfo;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface LogDataService extends IService<LogData> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页查询
|
||||||
|
*/
|
||||||
|
PageInfo<LogData> pageList(LogDataForm logDataForm);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 报警确认
|
||||||
|
* @param seqid
|
||||||
|
*/
|
||||||
|
void alarmAck(Integer seqid);
|
||||||
|
}
|
||||||
@@ -0,0 +1,76 @@
|
|||||||
|
package com.fizz.business.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.ArrayUtil;
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
|
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.PageDTO;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.fizz.business.domain.LogData;
|
||||||
|
import com.fizz.business.domain.RollHistory;
|
||||||
|
import com.fizz.business.form.LogDataForm;
|
||||||
|
import com.fizz.business.mapper.LogDataMapper;
|
||||||
|
import com.fizz.business.service.LogDataService;
|
||||||
|
import com.github.pagehelper.PageHelper;
|
||||||
|
import com.github.pagehelper.PageInfo;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.LocalTime;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class LogDataServiceImpl extends ServiceImpl<LogDataMapper, LogData> implements LogDataService {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PageInfo<LogData> pageList(LogDataForm logDataForm) {
|
||||||
|
|
||||||
|
// 调用分页查询方法,获取EventRecords的分页结果
|
||||||
|
PageHelper.startPage(logDataForm.getPageNum(), logDataForm.getPageSize());
|
||||||
|
|
||||||
|
LambdaQueryChainWrapper<LogData> lambdaQuery = lambdaQuery();
|
||||||
|
|
||||||
|
|
||||||
|
if(ObjectUtil.isNotEmpty(logDataForm.getStartTime())){
|
||||||
|
LocalDateTime start = LocalDateTime.of(logDataForm.getStartTime().toLocalDate(), LocalTime.MIN);
|
||||||
|
lambdaQuery.ge(LogData::getTimestamp, start);
|
||||||
|
}
|
||||||
|
if(ObjectUtil.isNotEmpty(logDataForm.getEndTime())){
|
||||||
|
LocalDateTime end = LocalDateTime.of(logDataForm.getStartTime().toLocalDate(), LocalTime.MAX);
|
||||||
|
lambdaQuery.ge(LogData::getTimestamp, end);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (StringUtils.isNotBlank(logDataForm.getLogtype())) {
|
||||||
|
lambdaQuery.eq(LogData::getLogtype, logDataForm.getLogtype());
|
||||||
|
}
|
||||||
|
if (StringUtils.isNotBlank(logDataForm.getModule())) {
|
||||||
|
lambdaQuery.eq(LogData::getModule, logDataForm.getModule());
|
||||||
|
}
|
||||||
|
if (StringUtils.isNotBlank(logDataForm.getLogtext())) {
|
||||||
|
lambdaQuery.like(LogData::getLogtext, logDataForm.getLogtext());
|
||||||
|
}
|
||||||
|
if (ObjectUtil.isNotNull(logDataForm.getStatus())) {
|
||||||
|
lambdaQuery.eq(LogData::getStatus, logDataForm.getStatus());
|
||||||
|
}
|
||||||
|
lambdaQuery.orderByDesc(LogData::getTimestamp);
|
||||||
|
|
||||||
|
|
||||||
|
List<LogData> list = lambdaQuery.list();
|
||||||
|
PageInfo<LogData> pageInfo = new PageInfo<>(list);
|
||||||
|
|
||||||
|
return pageInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void alarmAck(Integer seqid) {
|
||||||
|
lambdaUpdate()
|
||||||
|
.set(LogData::getConfirmTime, new Date())
|
||||||
|
.eq(LogData::getSeqid, seqid)
|
||||||
|
.update();
|
||||||
|
}
|
||||||
|
}
|
||||||
6
business/src/main/resources/mapper/LogDataMapper.xml
Normal file
6
business/src/main/resources/mapper/LogDataMapper.xml
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
|
||||||
|
<mapper namespace="com.fizz.business.mapper.LogDataMapper">
|
||||||
|
</mapper>
|
||||||
Reference in New Issue
Block a user