Browse Source

feat: [操作日志] 导出

master
memorylkf 2 months ago
parent
commit
a8a3866fbb
3 changed files with 110 additions and 2 deletions
  1. +66
    -0
      hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/controller/SystemLogController.java
  2. +42
    -0
      hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/domain/SystemLog.java
  3. +2
    -2
      hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/impl/SystemLogServiceImpl.java

+ 66
- 0
hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/controller/SystemLogController.java View File

@ -2,8 +2,17 @@ package com.hxhq.business.controller;
import java.util.List;
import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.hxhq.business.form.systemlog.SystemLogSearchForm;
import com.hxhq.common.core.utils.DateUtils;
import com.hxhq.common.core.utils.ServletUtils;
import com.hxhq.common.core.utils.StringUtils;
import com.hxhq.common.core.utils.poi.ExcelUtil;
import com.hxhq.common.core.web.domain.AjaxResult;
import com.hxhq.common.security.annotation.RequiresPermissions;
import com.hxhq.system.api.domain.SysRole;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.hxhq.business.domain.SystemLog;
@ -11,6 +20,8 @@ import com.hxhq.business.service.ISystemLogService;
import com.hxhq.common.core.web.controller.BaseController;
import com.hxhq.common.core.web.page.TableDataInfo;
import javax.servlet.http.HttpServletResponse;
/**
* 系统日志Controller
@ -36,4 +47,59 @@ public class SystemLogController extends BaseController
List<SystemLog> list = systemLogService.queryList(form);
return getDataTable(list);
}
/**
* 查询系统日志列表
*/
@GetMapping("/czlxList")
@RequiresPermissions("business:systemLog:operate")
public AjaxResult czlxList()
{
QueryWrapper<SystemLog> queryWrapper = new QueryWrapper<>();
queryWrapper.select("distinct jcmc,jcmc_en");
List<SystemLog> list = systemLogService.list(queryWrapper);
return AjaxResult.success(list);
}
/**
* 查询系统日志列表
*/
@PostMapping("/export")
@RequiresPermissions("business:systemLog:operate:export")
public void export(HttpServletResponse response, SystemLogSearchForm form)
{
List<SystemLog> list = systemLogService.queryList(form);
for(SystemLog l : list){
l.setCzsj(DateUtils.parseDateToStr(l.getCreateTime()==null?"": DateUtils.YYYY_MM_DD_HH_MM_SS,l.getCreateTime()));
l.setCzlx(ServletUtils.getRequest().getHeader("lang").equals("zh_CN")?l.getJcmc():l.getJcmcEn());
String czxq = "";
if(ServletUtils.getRequest().getHeader("lang").equals("zh_CN")){
try{
JSONArray jsonArray = JSONArray.parseArray(l.getJcnr());
for(int i=0;i<jsonArray.size();i++){
JSONObject jsonObject = jsonArray.getJSONObject(i);
czxq+=jsonObject.getString("name")+":"+jsonObject.getString("value")+(i==jsonArray.size()-1?"":";");
}
czxq = (StringUtils.isNoneBlank(l.getName())?("【"+l.getName()+"】"):"")+czxq+(StringUtils.isNoneBlank(l.getRemark())?(";备注:"+l.getRemark()):"");
}catch (Exception e){
czxq = (StringUtils.isNoneBlank(l.getName())?("【"+l.getName()+"】"):"")+(StringUtils.isNoneBlank(l.getJcnr())?l.getJcnr():"")+(StringUtils.isNoneBlank(l.getRemark())?(";备注:"+l.getRemark()):"");
}
}else{
try{
JSONArray jsonArray = JSONArray.parseArray(l.getJcnrEn());
for(int i=0;i<jsonArray.size();i++){
JSONObject jsonObject = jsonArray.getJSONObject(i);
czxq+=jsonObject.getString("name")+":"+jsonObject.getString("value")+(i==jsonArray.size()-1?"":";");
}
czxq = (StringUtils.isNoneBlank(l.getNameEn())?("【"+l.getNameEn()+"】"):"")+czxq+(StringUtils.isNoneBlank(l.getRemark())?(";Comment:"+l.getRemark()):"");
}catch (Exception e){
czxq = (StringUtils.isNoneBlank(l.getNameEn())?("【"+l.getNameEn()+"】"):"")+(StringUtils.isNoneBlank(l.getJcnrEn())?l.getJcnrEn():"")+(StringUtils.isNoneBlank(l.getRemark())?(";Comment:"+l.getRemark()):"");
}
}
l.setCzxq(czxq);
}
ExcelUtil<SystemLog> util = new ExcelUtil<SystemLog>(SystemLog.class);
util.exportExcel(response, list, "操作日志");
}
}

+ 42
- 0
hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/domain/SystemLog.java View File

@ -1,6 +1,8 @@
package com.hxhq.business.domain;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.hxhq.common.core.annotation.Excel;
import com.hxhq.common.core.domain.MpBaseEntity;
@ -37,11 +39,28 @@ public class SystemLog extends MpBaseEntity
private Long qmrId;
/** 操作人名称 */
@Excel(name = "操作人",nameEn = "User",sort = 1)
private String qmrMc;
/** 操作人名称-英文 */
private String qmrMcEn;
/** 操作类型 */
@TableField(exist = false)
@Excel(name = "操作类型",nameEn = "Action",sort = 2)
private String czlx;
/** 操作详情 */
@TableField(exist = false)
@Excel(name = "操作详情",nameEn = "Detail",sort = 3)
private String czxq;
/** 操作时间 */
@TableField(exist = false)
@Excel(name = "操作时间",nameEn = "Datetime",sort = 4)
private String czsj;
public String getName() {
return name;
}
@ -128,4 +147,27 @@ public class SystemLog extends MpBaseEntity
return qmrMcEn;
}
public String getCzlx() {
return czlx;
}
public void setCzlx(String czlx) {
this.czlx = czlx;
}
public String getCzxq() {
return czxq;
}
public void setCzxq(String czxq) {
this.czxq = czxq;
}
public String getCzsj() {
return czsj;
}
public void setCzsj(String czsj) {
this.czsj = czsj;
}
}

+ 2
- 2
hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/impl/SystemLogServiceImpl.java View File

@ -40,8 +40,8 @@ public class SystemLogServiceImpl extends ServiceImpl
queryWrapper.like("qmr_mc",form.getQmrMc());
}
if(StringUtils.isNoneBlank(form.getJcmc())){
queryWrapper.and(q->q.like("jcmc",form.getJcmc())
.or().like("jcmc_en",form.getJcmc()));
queryWrapper.and(q->q.eq("jcmc",form.getJcmc())
.or().eq("jcmc_en",form.getJcmc()));
}
if(StringUtils.isNoneBlank(form.getJcnr())){
queryWrapper.and(q->q.like("jcnr",form.getJcnr())

Loading…
Cancel
Save