feat: There is no way the, 操作日志导出1年内

This commit is contained in:
super_liu
2022-06-16 17:31:08 +08:00
parent a2546f2815
commit 11de5d4c55
10 changed files with 164 additions and 8 deletions
@@ -142,6 +142,9 @@ public class WebMvcConfig implements WebMvcConfigurer {
addInterceptor.excludePathPatterns("/api/sarStandardsInfo/sar-standards-info/convertDocAll_GNW");
addInterceptor.excludePathPatterns("/api/sarStandardsInfo/sar-standards-info/convertDocAll_QB");
// 操作日志导出
addInterceptor.excludePathPatterns("/api/sysLog/sys-log/exportSysLogExcelVOExcelData");
//// //测试接口使用
// addInterceptor.excludePathPatterns("/api/**");
@@ -1387,7 +1387,7 @@ public class SearchCenterServiceImpl implements SearchCenterService {
if("废止".equals(textStatus) || "被代替".equals(textStatus) || "作废".equals(textStatus) ){
textStatusColor = "redClass";
}else if("参考".equals(textStatus)){
textStatusColor = "yellowClass";
textStatusColor = "greenClass";
}
}
//解析高亮字段
@@ -1523,7 +1523,7 @@ public class SearchCenterServiceImpl implements SearchCenterService {
// .addSort(new ScoreSortBuilder().order(SortOrder.DESC))
.addSort("standTypeOrder",SortOrder.ASC)
.addSort("standSortOrder",SortOrder.ASC)
.addSort("numberTitle.keyword",SortOrder.ASC)
// .addSort("numberTitle.keyword",SortOrder.ASC)
.addSort("yearOrder",SortOrder.DESC)
.addSort("sortTitle.keyword",SortOrder.ASC)
.setFrom((searchInfoEO.getPage()-1)*searchInfoEO.getPageSize())
@@ -1545,7 +1545,7 @@ public class SearchCenterServiceImpl implements SearchCenterService {
// textStatusColor = "redClass";
// break;
// }else if("参考".equals(textStatus)){
// textStatusColor = "yellowClass";
// textStatusColor = "greenClass";
// break;
// }
// }
@@ -1558,7 +1558,7 @@ public class SearchCenterServiceImpl implements SearchCenterService {
if("废止".equals(textStatus) || "被代替".equals(textStatus) || "作废".equals(textStatus) ){
textStatusColor = "redClass";
}else if("参考".equals(textStatus)){
textStatusColor = "yellowClass";
textStatusColor = "greenClass";
}
}
@@ -1897,7 +1897,7 @@ public class SearchCenterServiceImpl implements SearchCenterService {
if("废止".equals(textStatus) || "被代替".equals(textStatus) || "作废".equals(textStatus) ){
textStatusColor = "redClass";
}else if("参考".equals(textStatus)){
textStatusColor = "yellowClass";
textStatusColor = "greenClass";
}
}
@@ -3,12 +3,20 @@ package com.adc.da.slrs.sysLog.controller;
import com.adc.da.http.ResponseMessage;
import com.adc.da.http.Result;
import com.adc.da.slrs.sarMenu.entity.SarMenu;
import com.adc.da.slrs.sysLog.entity.SysLogExcel;
import com.adc.da.slrs.sysLog.service.ISysLogService;
import com.adc.da.slrs.sysLog.vo.SysLogReqDTO;
import com.adc.da.slrs.sysLog.vo.SysLogReqExportDTO;
import com.adc.da.util.UUIDUtils;
import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.ExcelWriter;
import com.alibaba.excel.write.style.column.LongestMatchColumnWidthStyleStrategy;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.util.IOUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
@@ -17,6 +25,9 @@ import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.RestController;
import com.adc.da.base.web.BaseController;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.net.URLEncoder;
import java.util.List;
/**
@@ -35,6 +46,35 @@ public class SysLogController extends BaseController<SysLog> {
@Autowired
private ISysLogService sysLogService;
@ApiOperation(value = "|SysCorpEO|导出excel")
@GetMapping(value = "/exportSysLogExcelVOExcelData")
public void exportSysLogExcelVOExcelData(String exportJson, HttpServletResponse response,
HttpServletRequest request) throws Exception {
try {
SysLogReqExportDTO sysLogExcelVO = JSONObject.parseObject(exportJson,SysLogReqExportDTO.class);
response.setContentType("application/vnd.ms-excel");
response.setCharacterEncoding("utf-8");
if(StringUtils.isBlank(sysLogExcelVO.getExportName()) || "null".equals(sysLogExcelVO.getExportName())){
sysLogExcelVO.setExportName("操作日志");
}
String fileName = URLEncoder.encode(sysLogExcelVO.getExportName(), "UTF-8").replaceAll("\\+", "%20");
response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".xlsx");
List<SysLogExcel> data=sysLogService.getSysLogExcelVOExcelData(sysLogExcelVO);
// 这里需要设置不关闭流
EasyExcel.write(response.getOutputStream(), SysLogExcel.class)
.registerWriteHandler(new LongestMatchColumnWidthStyleStrategy())
.autoCloseStream(Boolean.FALSE).sheet("sheet1")
.doWrite(data);
} catch (Exception e) {
System.out.println(e);
// 重置response
response.reset();
response.setContentType("application/json");
response.setCharacterEncoding("utf-8");
response.getWriter().println(JSON.toJSONString(Result.error()));
}
}
@ApiOperation("获取操作日志")
@GetMapping("/getAllLog")
@@ -1,12 +1,13 @@
package com.adc.da.slrs.sysLog.dao;
import com.adc.da.slrs.sysLog.entity.SysLog;
import com.adc.da.slrs.sysLog.entity.SysLogExcel;
import com.adc.da.slrs.sysLog.vo.SysLogReqDTO;
import com.adc.da.slrs.sysLog.vo.SysLogReqExportDTO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Param;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
@@ -20,5 +21,7 @@ import java.util.List;
*/
public interface SysLogDao extends BaseMapper<SysLog> {
List<SysLogExcel> getSysLogExcelVOExcelData(@Param("sysLogReqDTO") SysLogReqExportDTO sysLogReqDTO);
IPage<SysLog> queryAllLog(Page page,@Param("sysLogReqDTO") SysLogReqDTO sysLogReqDTO);
}
@@ -0,0 +1,42 @@
package com.adc.da.slrs.sysLog.entity;
import com.adc.da.base.entity.BaseEntity;
import com.alibaba.excel.annotation.ExcelProperty;
import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
/**
* <p>
*
* </p>
*
* @author yzh
* @since 2022-02-15
*/
@Data
public class SysLogExcel{
@ExcelProperty("操作人")
private String account;
@ExcelProperty("所属部门")
private String dept;
@ExcelProperty("操作时间")
private String operTime;
@ExcelProperty("操作类型")
private String oper;
@ExcelProperty("操作内容")
private String special;
}
@@ -1,11 +1,14 @@
package com.adc.da.slrs.sysLog.service;
import com.adc.da.slrs.sysLog.entity.SysLog;
import com.adc.da.slrs.sysLog.entity.SysLogExcel;
import com.adc.da.slrs.sysLog.vo.SysLogReqDTO;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.adc.da.slrs.sysLog.vo.SysLogReqExportDTO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import java.util.List;
/**
* <p>
* 服务类
@@ -17,4 +20,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
public interface ISysLogService extends IService<SysLog> {
IPage<SysLog> getAllLog(SysLogReqDTO sysLogReqDTO);
List<SysLogExcel> getSysLogExcelVOExcelData(SysLogReqExportDTO sysLogReqDTO);
}
@@ -2,13 +2,17 @@ package com.adc.da.slrs.sysLog.service.impl;
import com.adc.da.slrs.sysLog.entity.SysLog;
import com.adc.da.slrs.sysLog.dao.SysLogDao;
import com.adc.da.slrs.sysLog.entity.SysLogExcel;
import com.adc.da.slrs.sysLog.service.ISysLogService;
import com.adc.da.slrs.sysLog.vo.SysLogReqDTO;
import com.adc.da.slrs.sysLog.vo.SysLogReqExportDTO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* <p>
* 服务实现类
@@ -20,6 +24,11 @@ import org.springframework.stereotype.Service;
@Service
public class SysLogServiceImpl extends ServiceImpl<SysLogDao, SysLog> implements ISysLogService {
@Override
public List<SysLogExcel> getSysLogExcelVOExcelData(SysLogReqExportDTO sysLogReqDTO) {
return this.baseMapper.getSysLogExcelVOExcelData(sysLogReqDTO);
}
@Override
public IPage<SysLog> getAllLog(SysLogReqDTO sysLogReqDTO) {
Page<SysLog> page = new Page<>(sysLogReqDTO.getPage(), sysLogReqDTO.getPageSize());
@@ -15,4 +15,10 @@ public class SysLogReqDTO extends BasePage {
private String oper;
private String content;
private String exportType;
private String userId;
private String exportName;
}
@@ -0,0 +1,24 @@
package com.adc.da.slrs.sysLog.vo;
import com.adc.da.base.page.BasePage;
import lombok.Data;
@Data
public class SysLogReqExportDTO {
private String account;
private String sTime;
private String eTime;
private String oper;
private String content;
private String exportType;
private String userId;
private String exportName;
}
@@ -2,6 +2,29 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.adc.da.slrs.sysLog.dao.SysLogDao">
<select id="getSysLogExcelVOExcelData" parameterType="com.adc.da.slrs.sysLog.vo.SysLogReqExportDTO" resultType="com.adc.da.slrs.sysLog.entity.SysLogExcel">
select CONCAT('(',ts_user.account,')',ts_user.UNAME) as account,ts_user.UNAME as accountName,ts_institution.name dept,sys_log.oper_time,sys_log.oper,sys_log.special from sys_log
left join ts_user on sys_log.user_id = ts_user.usid
left join ts_institution on ts_user.institution_id = ts_institution.id
WHERE 1=1 and sys_log.oper_time >= DATE_SUB(CURDATE(),INTERVAL 1 YEAR)
<if test="sysLogReqDTO.account != null and sysLogReqDTO.account != ''">
and ts_user.account = #{sysLogReqDTO.account}
</if>
<if test="sysLogReqDTO.sTime != null and sysLogReqDTO.sTime != ''">
and sys_log.oper_time >= #{sysLogReqDTO.sTime}
</if>
<if test="sysLogReqDTO.eTime != null and sysLogReqDTO.eTime != ''">
and sys_log.oper_time &lt;= #{sysLogReqDTO.eTime}
</if>
<if test="sysLogReqDTO.oper != null and sysLogReqDTO.oper != ''">
and sys_log.oper = #{sysLogReqDTO.oper}
</if>
<if test="sysLogReqDTO.content != null and sysLogReqDTO.content != ''">
and sys_log.special like concat(concat('%',#{sysLogReqDTO.content}),'%')
</if>
order by sys_log.oper_time desc
</select>
<select id="queryAllLog" parameterType="com.adc.da.slrs.sysLog.vo.SysLogReqDTO" resultType="com.adc.da.slrs.sysLog.entity.SysLog">
select ts_user.account,ts_user.UNAME as accountName,ts_institution.name dept,sys_log.oper_time,sys_log.oper,sys_log.special from sys_log
left join ts_user on sys_log.user_id = ts_user.usid