package com.matrix.system.hiveErp.action;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.matrix.core.pojo.AjaxResult;
|
import com.matrix.core.tools.DateUtil;
|
import com.matrix.core.tools.excl.ExcelSheetPO;
|
import com.matrix.core.tools.excl.ExcelUtil;
|
import com.matrix.core.tools.excl.ExcelVersion;
|
import com.matrix.system.common.bean.reqVO.OperationLogReqVo;
|
import com.matrix.system.common.bean.respVO.OperationLogRespVo;
|
import com.matrix.system.common.service.OperationLogService;
|
import com.matrix.system.common.tools.ResponseHeadUtil;
|
import com.matrix.system.hive.action.util.QueryUtil;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.ui.ModelMap;
|
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;
|
|
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletResponse;
|
import java.io.IOException;
|
import java.io.OutputStream;
|
import java.net.URLEncoder;
|
import java.util.ArrayList;
|
import java.util.List;
|
|
@RestController
|
@RequestMapping(value = "admin/operation")
|
public class OperationLogController {
|
|
|
@Autowired
|
private OperationLogService operationLogService;
|
|
/**
|
* 查询单据操作记录
|
*
|
* @param operationLogReqVo
|
* @return
|
*/
|
@PostMapping(value = "/getOperation")
|
public
|
AjaxResult getOperation(@RequestBody OperationLogReqVo operationLogReqVo) {
|
QueryUtil.setQueryLimitCom(operationLogReqVo);
|
Page<OperationLogReqVo> page = new Page<>(operationLogReqVo.getPageNum(),operationLogReqVo.getPageSize());
|
|
Page<OperationLogRespVo> pageResult = operationLogService.selectPage(page,operationLogReqVo);
|
|
return AjaxResult.buildSuccessInstance(pageResult.getRecords(),pageResult.getTotal());
|
}
|
|
/**
|
* 导出操作记录
|
*/
|
@RequestMapping(value = "/exportExcel")
|
public void exportExcel(ModelMap model, HttpServletRequest request, HttpServletResponse response,OperationLogReqVo operationLogReqVo) throws Exception {
|
|
doExportExcel(response, operationLogReqVo);
|
}
|
|
|
private void doExportExcel(HttpServletResponse response, OperationLogReqVo operationLogReqVo) throws IOException {
|
|
|
|
List<ExcelSheetPO> res = new ArrayList<>();
|
ExcelSheetPO orderSheet = new ExcelSheetPO();
|
String title = "系统操作记录";
|
orderSheet.setSheetName(title);
|
orderSheet.setTitle(title);
|
String[] header = {"门店","操作用户", "操作时间", "操作功能","操作按钮", "单据号","操作会员","备注","IP地址"};
|
orderSheet.setHeaders(header);
|
|
QueryUtil.setQueryLimitCom(operationLogReqVo);
|
Page<OperationLogReqVo> page = new Page<>(operationLogReqVo.getPageNum(),operationLogReqVo.getPageSize());
|
|
Page<OperationLogRespVo> pageResult = operationLogService.selectPage(page,operationLogReqVo);
|
|
List<List<Object>> list = new ArrayList<>();
|
if (pageResult.getRecords().size() > 0) {
|
for (OperationLogRespVo item : pageResult.getRecords()) {
|
List<Object> temp = new ArrayList<>();
|
temp.add(item.getShopName());
|
temp.add(item.getOpeUser());
|
temp.add(DateUtil.dateToString(item.getCreateTime(), DateUtil.DATE_FORMAT_MM));
|
temp.add(item.getOpeFunctionLabel());
|
temp.add(item.getOpeButLabel());
|
temp.add(item.getBillNo());
|
temp.add(item.getVipName());
|
temp.add(item.getNote());
|
temp.add(item.getIp());
|
list.add(temp);
|
}
|
}
|
orderSheet.setDataList(list);
|
res.add(orderSheet);
|
response = ResponseHeadUtil.setExcelHead(response);
|
response.setHeader("Content-Disposition",
|
"attachment;filename=" + URLEncoder.encode(title + DateUtil.getTimeMark() + ".xlsx".trim(), "UTF-8"));
|
OutputStream os = response.getOutputStream();
|
ExcelUtil.createWorkbookAtOutStream(ExcelVersion.V2007, res, os, true);
|
}
|
|
}
|