feat(event): 添加暂态事件波形查看与导出功能
- 新增 getTransientEventWave 接口用于查看暂态事件波形 - 新增 exportTransientEventWaves 接口用于批量导出暂态事件波形 - 添加 EventWaveExportParam 参数类支持波形导出 - 在 EventListMapper 中增加 selectTransientDetailsByIds 查询方法 - 更新事件列表查询参数支持毫秒级时间格式 - 移除事件描述模糊查询条件优化查询性能 - 添加波形导出相关的常量和工具类集成
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
package com.njcn.gather.system.cfg.controller;
|
||||
|
||||
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||
import com.njcn.common.pojo.constant.OperateType;
|
||||
import com.njcn.common.pojo.enums.common.LogEnum;
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.common.utils.LogUtil;
|
||||
import com.njcn.gather.system.cfg.pojo.param.SysConfigParam;
|
||||
import com.njcn.gather.system.cfg.pojo.po.SysConfig;
|
||||
import com.njcn.gather.system.cfg.service.ISysConfigService;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
import com.njcn.web.utils.HttpResultUtil;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* 系统配置接口。
|
||||
*/
|
||||
@Slf4j
|
||||
@Api(tags = "系统配置")
|
||||
@RestController
|
||||
@RequestMapping("/sysConfig")
|
||||
@RequiredArgsConstructor
|
||||
public class SysConfigController extends BaseController {
|
||||
|
||||
private final ISysConfigService sysConfigService;
|
||||
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
@GetMapping("/getConfig")
|
||||
@ApiOperation("获取系统配置")
|
||||
public HttpResult<SysConfig> getConfig() {
|
||||
String methodDescribe = getMethodDescribe("getConfig");
|
||||
LogUtil.njcnDebug(log, "{}", methodDescribe);
|
||||
SysConfig sysConfig = sysConfigService.getOneConfig();
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, sysConfig, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON, operateType = OperateType.UPDATE)
|
||||
@PostMapping("/update")
|
||||
@ApiOperation("修改系统配置")
|
||||
@ApiImplicitParam(name = "sysConfig", value = "系统配置", required = true)
|
||||
public HttpResult<Boolean> update(@RequestBody @Validated SysConfigParam.UpdateParam sysConfig) {
|
||||
String methodDescribe = getMethodDescribe("update");
|
||||
LogUtil.njcnDebug(log, "{}", methodDescribe);
|
||||
boolean result = sysConfigService.updateConfig(sysConfig);
|
||||
if (result) {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true, methodDescribe);
|
||||
}
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, false, methodDescribe);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.njcn.gather.system.cfg.mapper;
|
||||
|
||||
import com.github.yulichang.base.MPJBaseMapper;
|
||||
import com.njcn.gather.system.cfg.pojo.po.SysConfig;
|
||||
|
||||
/**
|
||||
* 系统配置 Mapper。
|
||||
*/
|
||||
public interface SysConfigMapper extends MPJBaseMapper<SysConfig> {
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
<?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.njcn.gather.system.cfg.mapper.SysConfigMapper">
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.njcn.gather.system.cfg.pojo.param;
|
||||
|
||||
import com.njcn.common.pojo.constant.PatternRegex;
|
||||
import com.njcn.gather.system.pojo.constant.SystemValidMessage;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.Pattern;
|
||||
|
||||
/**
|
||||
* 系统配置参数。
|
||||
*/
|
||||
@Data
|
||||
public class SysConfigParam {
|
||||
|
||||
@ApiModelProperty("波形文件存储根路径")
|
||||
private String waveStoragePath;
|
||||
|
||||
@Data
|
||||
public static class UpdateParam extends SysConfigParam {
|
||||
|
||||
@ApiModelProperty("id")
|
||||
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = SystemValidMessage.ID_FORMAT_ERROR)
|
||||
private String id;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.njcn.gather.system.cfg.pojo.po;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.njcn.db.mybatisplus.bo.BaseEntity;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 系统配置。
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName("sys_config")
|
||||
public class SysConfig extends BaseEntity implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -3293972902209033082L;
|
||||
|
||||
/**
|
||||
* 系统配置表Id。
|
||||
*/
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 波形文件存储根路径,默认 D:/。
|
||||
*/
|
||||
@TableField("wave_storage_path")
|
||||
private String waveStoragePath;
|
||||
|
||||
/**
|
||||
* 状态:0-删除 1-正常。
|
||||
*/
|
||||
private Integer state;
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.njcn.gather.system.cfg.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.njcn.gather.system.cfg.pojo.param.SysConfigParam;
|
||||
import com.njcn.gather.system.cfg.pojo.po.SysConfig;
|
||||
|
||||
/**
|
||||
* 系统配置服务。
|
||||
*/
|
||||
public interface ISysConfigService extends IService<SysConfig> {
|
||||
|
||||
/**
|
||||
* 更新系统配置。
|
||||
*
|
||||
* @param param 系统配置
|
||||
* @return 是否更新成功
|
||||
*/
|
||||
boolean updateConfig(SysConfigParam.UpdateParam param);
|
||||
|
||||
/**
|
||||
* 获取系统配置。
|
||||
*
|
||||
* @return 系统配置
|
||||
*/
|
||||
SysConfig getOneConfig();
|
||||
|
||||
/**
|
||||
* 获取波形文件存储根路径。
|
||||
*
|
||||
* @return 波形文件存储根路径,未配置时返回默认 D:/
|
||||
*/
|
||||
String getWaveStoragePath();
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
package com.njcn.gather.system.cfg.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.common.pojo.enums.common.DataStateEnum;
|
||||
import com.njcn.gather.system.cfg.mapper.SysConfigMapper;
|
||||
import com.njcn.gather.system.cfg.pojo.param.SysConfigParam;
|
||||
import com.njcn.gather.system.cfg.pojo.po.SysConfig;
|
||||
import com.njcn.gather.system.cfg.service.ISysConfigService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
/**
|
||||
* 系统配置服务实现。
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class SysConfigServiceImpl extends ServiceImpl<SysConfigMapper, SysConfig> implements ISysConfigService {
|
||||
|
||||
private static final String DEFAULT_CONFIG_ID = "00000000000000000000000000000001";
|
||||
private static final String DEFAULT_WAVE_STORAGE_PATH = "D:/";
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public boolean updateConfig(SysConfigParam.UpdateParam param) {
|
||||
SysConfig config = getOneConfig();
|
||||
if (config == null) {
|
||||
config = new SysConfig();
|
||||
config.setId(param != null && StringUtils.isNotBlank(param.getId()) ? param.getId().trim() : DEFAULT_CONFIG_ID);
|
||||
config.setState(DataStateEnum.ENABLE.getCode());
|
||||
config.setWaveStoragePath(DEFAULT_WAVE_STORAGE_PATH);
|
||||
}
|
||||
if (param != null && StringUtils.isNotBlank(param.getWaveStoragePath())) {
|
||||
config.setWaveStoragePath(param.getWaveStoragePath().trim());
|
||||
}
|
||||
return this.saveOrUpdate(config);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SysConfig getOneConfig() {
|
||||
QueryWrapper<SysConfig> queryWrapper = new QueryWrapper<SysConfig>();
|
||||
queryWrapper.eq("state", DataStateEnum.ENABLE.getCode());
|
||||
queryWrapper.last("LIMIT 1");
|
||||
return this.getOne(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getWaveStoragePath() {
|
||||
SysConfig config = getOneConfig();
|
||||
if (config == null || StringUtils.isBlank(config.getWaveStoragePath())) {
|
||||
return DEFAULT_WAVE_STORAGE_PATH;
|
||||
}
|
||||
return config.getWaveStoragePath().trim();
|
||||
}
|
||||
}
|
||||
@@ -19,6 +19,7 @@ import com.njcn.gather.system.dictionary.pojo.po.DictType;
|
||||
import com.njcn.gather.system.dictionary.pojo.vo.DictDataExcel;
|
||||
import com.njcn.gather.system.dictionary.service.IDictDataService;
|
||||
import com.njcn.gather.system.pojo.enums.SystemResponseEnum;
|
||||
import com.njcn.gather.system.util.ExportFileNameUtil;
|
||||
import com.njcn.web.factory.PageFactory;
|
||||
import com.njcn.web.pojo.dto.SimpleDTO;
|
||||
import com.njcn.web.pojo.dto.SimpleTreeDTO;
|
||||
@@ -179,7 +180,7 @@ public class DictDataServiceImpl extends ServiceImpl<DictDataMapper, DictData> i
|
||||
.eq("sys_dict_data.type_id", queryParam.getTypeId());
|
||||
List<DictData> dictDatas = this.list(queryWrapper);
|
||||
List<DictDataExcel> dictDataExcels = BeanUtil.copyToList(dictDatas, DictDataExcel.class);
|
||||
ExcelUtil.exportExcel("字典数据导出数据.xlsx", "字典数据", DictDataExcel.class, dictDataExcels);
|
||||
ExcelUtil.exportExcel(ExportFileNameUtil.appendToday("字典数据导出数据.xlsx"), "字典数据", DictDataExcel.class, dictDataExcels);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -19,6 +19,7 @@ import com.njcn.gather.system.dictionary.pojo.vo.DictTypeExcel;
|
||||
import com.njcn.gather.system.dictionary.service.IDictDataService;
|
||||
import com.njcn.gather.system.dictionary.service.IDictTypeService;
|
||||
import com.njcn.gather.system.pojo.enums.SystemResponseEnum;
|
||||
import com.njcn.gather.system.util.ExportFileNameUtil;
|
||||
import com.njcn.web.factory.PageFactory;
|
||||
import com.njcn.web.utils.ExcelUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -115,7 +116,7 @@ public class DictTypeServiceImpl extends ServiceImpl<DictTypeMapper, DictType> i
|
||||
dictTypeVOS.add(dictTypeExcel);
|
||||
});
|
||||
|
||||
ExcelUtil.exportExcel("字典类型导出数据.xlsx", "字典类型", DictTypeExcel.class, dictTypeVOS);
|
||||
ExcelUtil.exportExcel(ExportFileNameUtil.appendToday("字典类型导出数据.xlsx"), "字典类型", DictTypeExcel.class, dictTypeVOS);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -17,6 +17,7 @@ import com.njcn.gather.system.log.pojo.param.SysLogParam;
|
||||
import com.njcn.gather.system.log.pojo.po.SysLogAudit;
|
||||
import com.njcn.gather.system.log.service.ISysLogAuditService;
|
||||
import com.njcn.gather.system.log.util.CSVUtil;
|
||||
import com.njcn.gather.system.util.ExportFileNameUtil;
|
||||
import com.njcn.gather.user.user.pojo.po.SysUser;
|
||||
import com.njcn.gather.user.user.service.ISysUserService;
|
||||
import com.njcn.web.factory.PageFactory;
|
||||
@@ -149,7 +150,7 @@ public class SysLogAuditServiceImpl extends ServiceImpl<SysLogAuditMapper, SysLo
|
||||
XSSFWorkbook wb = new XSSFWorkbook();
|
||||
|
||||
try (ServletOutputStream outputStream = response.getOutputStream()) {
|
||||
fileName = URLEncoder.encode(fileName, CharsetUtil.UTF_8);
|
||||
fileName = URLEncoder.encode(ExportFileNameUtil.appendToday(fileName), CharsetUtil.UTF_8);
|
||||
response.reset();
|
||||
response.setHeader("Content-Disposition", "attachment; filename=\"" + fileName + "\"");
|
||||
response.setContentType("application/octet-stream;charset=UTF-8");
|
||||
|
||||
@@ -5,6 +5,7 @@ import cn.afterturn.easypoi.csv.CsvExportUtil;
|
||||
import cn.afterturn.easypoi.csv.entity.CsvExportParams;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
||||
import com.njcn.gather.system.util.ExportFileNameUtil;
|
||||
import com.njcn.web.utils.HttpServletUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@@ -73,7 +74,7 @@ public class CSVUtil {
|
||||
Throwable var1 = null;
|
||||
|
||||
try {
|
||||
fileName = URLEncoder.encode(fileName, "UTF-8");
|
||||
fileName = URLEncoder.encode(ExportFileNameUtil.appendToday(fileName), "UTF-8");
|
||||
response.reset();
|
||||
response.setHeader("Content-Disposition", "attachment; filename=\"" + fileName + "\"");
|
||||
response.setContentType("application/octet-stream;charset=UTF-8");
|
||||
@@ -108,7 +109,7 @@ public class CSVUtil {
|
||||
ServletOutputStream os = null;
|
||||
try {
|
||||
os = response.getOutputStream();
|
||||
fileName = URLEncoder.encode(fileName, "UTF-8");
|
||||
fileName = URLEncoder.encode(ExportFileNameUtil.appendToday(fileName), "UTF-8");
|
||||
response.reset();
|
||||
response.setHeader("Content-Disposition", "attachment; filename=\"" + fileName + "\"");
|
||||
response.setContentType("application/octet-stream;charset=UTF-8");
|
||||
|
||||
@@ -38,4 +38,9 @@ public interface DictConst {
|
||||
* 注册资源字典数据 ID:比对式
|
||||
*/
|
||||
String REG_RES_CONTRAST_ID = "7cd65363a6bf675ae408f28a281b77d4";
|
||||
|
||||
/**
|
||||
* 事件类型字典类型。
|
||||
*/
|
||||
String EVENT_TYPE_DICT = "事件类型";
|
||||
}
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.njcn.gather.system.util;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
|
||||
/**
|
||||
* 导出文件名处理工具。
|
||||
*/
|
||||
public final class ExportFileNameUtil {
|
||||
|
||||
private static final DateTimeFormatter DATE_FORMATTER = DateTimeFormatter.ofPattern("yyyyMMdd");
|
||||
|
||||
private ExportFileNameUtil() {
|
||||
}
|
||||
|
||||
public static String appendToday(String fileName) {
|
||||
return appendDate(fileName, LocalDate.now());
|
||||
}
|
||||
|
||||
public static String appendDate(String fileName, LocalDate date) {
|
||||
if (fileName == null || date == null) {
|
||||
return fileName;
|
||||
}
|
||||
String dateText = DATE_FORMATTER.format(date);
|
||||
int separatorIndex = Math.max(fileName.lastIndexOf('/'), fileName.lastIndexOf('\\'));
|
||||
int dotIndex = fileName.lastIndexOf('.');
|
||||
if (dotIndex > separatorIndex) {
|
||||
return fileName.substring(0, dotIndex) + "_" + dateText + fileName.substring(dotIndex);
|
||||
}
|
||||
return fileName + "_" + dateText;
|
||||
}
|
||||
}
|
||||
34
system/src/main/resources/sql/system/sys-config.sql
Normal file
34
system/src/main/resources/sql/system/sys-config.sql
Normal file
@@ -0,0 +1,34 @@
|
||||
-- 系统配置表。
|
||||
-- wave_storage_path 为波形文件存储根路径,默认值为 D:/。
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `sys_config` (
|
||||
`id` VARCHAR(64) NOT NULL COMMENT '系统配置表Id',
|
||||
`wave_storage_path` VARCHAR(255) NULL DEFAULT 'D:/' COMMENT '波形文件存储根路径',
|
||||
`state` TINYINT NULL DEFAULT 1 COMMENT '状态:0-删除,1-正常',
|
||||
`create_by` VARCHAR(64) NULL COMMENT '创建人',
|
||||
`create_time` DATETIME NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
`update_by` VARCHAR(64) NULL COMMENT '更新人',
|
||||
`update_time` DATETIME NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `idx_sys_config_state` (`state`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='系统配置表';
|
||||
|
||||
INSERT INTO `sys_config` (
|
||||
`id`,
|
||||
`wave_storage_path`,
|
||||
`state`,
|
||||
`create_time`,
|
||||
`update_time`
|
||||
)
|
||||
SELECT
|
||||
'00000000000000000000000000000001',
|
||||
'D:/',
|
||||
1,
|
||||
NOW(),
|
||||
NOW()
|
||||
WHERE NOT EXISTS (
|
||||
SELECT 1
|
||||
FROM `sys_config`
|
||||
WHERE `state` = 1
|
||||
LIMIT 1
|
||||
);
|
||||
Reference in New Issue
Block a user