1、拦截器增加请求地址、参数的日志输出

2、wps在线编辑增加文件下载(只做到文件保存到文件这一步骤,还需要存库、前端实现下载、预览功能)
This commit is contained in:
1378012178@qq.com 2025-01-06 08:53:22 +08:00
parent 36057f3126
commit 703000d3e3
14 changed files with 1781 additions and 1082 deletions

View File

@ -1,6 +1,7 @@
package org.jeecg.common.exception;
import cn.hutool.core.util.ObjectUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.authz.AuthorizationException;
import org.apache.shiro.authz.UnauthorizedException;
import org.jeecg.common.api.vo.Result;
@ -15,19 +16,18 @@ import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import org.springframework.web.multipart.MaxUploadSizeExceededException;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.NoHandlerFoundException;
import lombok.extern.slf4j.Slf4j;
import javax.servlet.http.HttpServletRequest;
import java.sql.SQLException;
import java.sql.SQLNonTransientException;
import java.sql.SQLSyntaxErrorException;
import java.util.Iterator;
/**
* 异常处理器
*
* @Author scott
* @Date 2019
*/
@RestControllerAdvice
@Slf4j
@ -37,8 +37,9 @@ public class JeecgBootExceptionHandler {
* 处理自定义异常
*/
@ExceptionHandler(JeecgBootException.class)
public Result<?> handleJeecgBootException(JeecgBootException e){
log.error(e.getMessage(), e);
public Result<?> handleJeecgBootException(JeecgBootException e, HttpServletRequest request) {
log.error("Intercepted exception for request: URL={}, Method={}, Parameters={}",
request.getRequestURI(), request.getMethod(), request.getParameterMap(), e);
return Result.error(e.getMessage());
}
@ -46,65 +47,52 @@ public class JeecgBootExceptionHandler {
* 处理自定义微服务异常
*/
@ExceptionHandler(JeecgCloudException.class)
public Result<?> handleJeecgCloudException(JeecgCloudException e){
log.error(e.getMessage(), e);
public Result<?> handleJeecgCloudException(JeecgCloudException e, HttpServletRequest request) {
log.error("Intercepted exception for request: URL={}, Method={}, Parameters={}",
request.getRequestURI(), request.getMethod(), request.getParameterMap(), e);
return Result.error(e.getMessage());
}
/**
* 处理自定义异常
* 处理自定义401异常
*/
@ExceptionHandler(JeecgBoot401Exception.class)
@ResponseStatus(HttpStatus.UNAUTHORIZED)
public Result<?> handleJeecgBoot401Exception(JeecgBoot401Exception e){
log.error(e.getMessage(), e);
return new Result(401,e.getMessage());
public Result<?> handleJeecgBoot401Exception(JeecgBoot401Exception e, HttpServletRequest request) {
log.error("Intercepted exception for request: URL={}, Method={}, Parameters={}",
request.getRequestURI(), request.getMethod(), request.getParameterMap(), e);
return new Result<>(401, e.getMessage());
}
@ExceptionHandler(NoHandlerFoundException.class)
public Result<?> handlerNoFoundException(Exception e) {
log.error(e.getMessage(), e);
public Result<?> handlerNoFoundException(Exception e, HttpServletRequest request) {
log.error("Intercepted exception for request: URL={}, Method={}, Parameters={}",
request.getRequestURI(), request.getMethod(), request.getParameterMap(), e);
return Result.error(404, "路径不存在,请检查路径是否正确");
}
@ExceptionHandler(DuplicateKeyException.class)
public Result<?> handleDuplicateKeyException(DuplicateKeyException e){
log.error(e.getMessage(), e);
public Result<?> handleDuplicateKeyException(DuplicateKeyException e, HttpServletRequest request) {
log.error("Intercepted exception for request: URL={}, Method={}, Parameters={}",
request.getRequestURI(), request.getMethod(), request.getParameterMap(), e);
return Result.error("数据库中已存在该记录");
}
@ExceptionHandler({UnauthorizedException.class, AuthorizationException.class})
public Result<?> handleAuthorizationException(AuthorizationException e){
log.error(e.getMessage(), e);
public Result<?> handleAuthorizationException(AuthorizationException e, HttpServletRequest request) {
log.error("Intercepted exception for request: URL={}, Method={}, Parameters={}",
request.getRequestURI(), request.getMethod(), request.getParameterMap(), e);
return Result.noauth("没有权限,请联系管理员授权");
}
@ExceptionHandler(Exception.class)
public Result<?> handleException(Exception e){
log.error(e.getMessage(), e);
//update-begin---author:zyf ---date:20220411 for处理Sentinel限流自定义异常
Throwable throwable = e.getCause();
SentinelErrorInfoEnum errorInfoEnum = SentinelErrorInfoEnum.getErrorByException(throwable);
if (ObjectUtil.isNotEmpty(errorInfoEnum)) {
return Result.error(errorInfoEnum.getError());
}
//update-end---author:zyf ---date:20220411 for处理Sentinel限流自定义异常
// return Result.error("操作失败"+e.getMessage());
return Result.error("操作失败");
}
/**
* @Author 政辉
* @param e
* @return
*/
@ExceptionHandler(HttpRequestMethodNotSupportedException.class)
public Result<?> httpRequestMethodNotSupportedException(HttpRequestMethodNotSupportedException e){
public Result<?> httpRequestMethodNotSupportedException(HttpRequestMethodNotSupportedException e, HttpServletRequest request) {
StringBuffer sb = new StringBuffer();
sb.append("不支持");
sb.append(e.getMethod());
sb.append("请求方法,");
sb.append("支持以下");
String[] methods = e.getSupportedMethods();
if (methods != null) {
for (String str : methods) {
@ -112,44 +100,73 @@ public class JeecgBootExceptionHandler {
sb.append("");
}
}
log.error("Intercepted unsupported HTTP method request: URL={}, Method={}, Parameters={}",
request.getRequestURI(), e.getMethod(), request.getParameterMap());
log.error(sb.toString(), e);
//return Result.error("没有权限,请联系管理员授权");
return Result.error(405, sb.toString());
}
/**
* spring默认上传大小100MB 超出大小捕获异常MaxUploadSizeExceededException
*/
@ExceptionHandler(MaxUploadSizeExceededException.class)
public Result<?> handleMaxUploadSizeExceededException(MaxUploadSizeExceededException e) {
log.error(e.getMessage(), e);
public Result<?> handleMaxUploadSizeExceededException(MaxUploadSizeExceededException e, HttpServletRequest request) {
if (request instanceof MultipartHttpServletRequest) {
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
Iterator<String> fileNames = multipartRequest.getFileNames();
while (fileNames.hasNext()) {
String fileName = fileNames.next();
MultipartFile file = multipartRequest.getFile(fileName);
log.error("File upload exceeded max size: File name={}, Size={} bytes, Content type={}",
file.getOriginalFilename(), file.getSize(), file.getContentType());
}
}
return Result.error("文件大小超出10MB限制, 请压缩或降低文件质量!");
}
@ExceptionHandler(DataIntegrityViolationException.class)
public Result<?> handleDataIntegrityViolationException(DataIntegrityViolationException e) {
log.error(e.getMessage(), e);
public Result<?> handleDataIntegrityViolationException(DataIntegrityViolationException e, HttpServletRequest request) {
log.error("Intercepted exception for request: URL={}, Method={}, Parameters={}",
request.getRequestURI(), request.getMethod(), request.getParameterMap(), e);
//issues/3624数据库执行异常handleDataIntegrityViolationException提示有误 #3624
return Result.error("执行数据库异常,违反了完整性例如:违反惟一约束、违反非空限制、字段内容超出长度等");
}
@ExceptionHandler(PoolException.class)
public Result<?> handlePoolException(PoolException e) {
log.error(e.getMessage(), e);
public Result<?> handlePoolException(PoolException e, HttpServletRequest request) {
log.error("Intercepted exception for request: URL={}, Method={}, Parameters={}",
request.getRequestURI(), request.getMethod(), request.getParameterMap(), e);
return Result.error("Redis 连接异常!");
}
@ExceptionHandler({SQLSyntaxErrorException.class, SQLNonTransientException.class, SQLException.class})
public Result<?> handleSQLSyntaxErrorException(SQLException e) {
log.error(e.getMessage(), e);
public Result<?> handleSQLSyntaxErrorException(SQLException e, HttpServletRequest request) {
log.error("Intercepted exception for request: URL={}, Method={}, Parameters={}",
request.getRequestURI(), request.getMethod(), request.getParameterMap(), e);
return Result.error("SQL语法错误");
}
@ExceptionHandler({BadSqlGrammarException.class, InvalidDataAccessResourceUsageException.class, NonTransientDataAccessException.class, DataAccessException.class})
public Result<?> handleBadSqlGrammarException(DataAccessException e) {
log.error(e.getMessage(), e);
public Result<?> handleBadSqlGrammarException(DataAccessException e, HttpServletRequest request) {
log.error("Intercepted exception for request: URL={}, Method={}, Parameters={}",
request.getRequestURI(), request.getMethod(), request.getParameterMap(), e);
return Result.error("SQL语法错误");
}
@ExceptionHandler(Exception.class)
public Result<?> handleException(Exception e, HttpServletRequest request) {
log.error("Intercepted an exception for request: URL={}, Method={}, Parameters={}",
request.getRequestURI(), request.getMethod(), request.getParameterMap(), e);
// 处理Sentinel限流自定义异常
Throwable throwable = e.getCause();
SentinelErrorInfoEnum errorInfoEnum = SentinelErrorInfoEnum.getErrorByException(throwable);
if (ObjectUtil.isNotEmpty(errorInfoEnum)) {
return Result.error(errorInfoEnum.getError());
}
return Result.error("操作失败");
}
}

View File

@ -0,0 +1,153 @@
package org.jeecg.common.exception;
import cn.hutool.core.util.ObjectUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.authz.AuthorizationException;
import org.apache.shiro.authz.UnauthorizedException;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.enums.SentinelErrorInfoEnum;
import org.springframework.dao.*;
import org.springframework.data.redis.connection.PoolException;
import org.springframework.http.HttpStatus;
import org.springframework.jdbc.BadSqlGrammarException;
import org.springframework.web.HttpRequestMethodNotSupportedException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import org.springframework.web.multipart.MaxUploadSizeExceededException;
import org.springframework.web.servlet.NoHandlerFoundException;
import java.sql.SQLException;
import java.sql.SQLNonTransientException;
import java.sql.SQLSyntaxErrorException;
/**
* 异常处理器
*
* @Author scott
* @Date 2019
*/
@RestControllerAdvice
@Slf4j
public class JeecgBootExceptionHandlerbk {
/**
* 处理自定义异常
*/
@ExceptionHandler(JeecgBootException.class)
public Result<?> handleJeecgBootException(JeecgBootException e){
log.error(e.getMessage(), e);
return Result.error(e.getMessage());
}
/**
* 处理自定义微服务异常
*/
@ExceptionHandler(JeecgCloudException.class)
public Result<?> handleJeecgCloudException(JeecgCloudException e){
log.error(e.getMessage(), e);
return Result.error(e.getMessage());
}
/**
* 处理自定义异常
*/
@ExceptionHandler(JeecgBoot401Exception.class)
@ResponseStatus(HttpStatus.UNAUTHORIZED)
public Result<?> handleJeecgBoot401Exception(JeecgBoot401Exception e){
log.error(e.getMessage(), e);
return new Result(401,e.getMessage());
}
@ExceptionHandler(NoHandlerFoundException.class)
public Result<?> handlerNoFoundException(Exception e) {
log.error(e.getMessage(), e);
return Result.error(404, "路径不存在,请检查路径是否正确");
}
@ExceptionHandler(DuplicateKeyException.class)
public Result<?> handleDuplicateKeyException(DuplicateKeyException e){
log.error(e.getMessage(), e);
return Result.error("数据库中已存在该记录");
}
@ExceptionHandler({UnauthorizedException.class, AuthorizationException.class})
public Result<?> handleAuthorizationException(AuthorizationException e){
log.error(e.getMessage(), e);
return Result.noauth("没有权限,请联系管理员授权");
}
@ExceptionHandler(Exception.class)
public Result<?> handleException(Exception e){
log.error(e.getMessage(), e);
//update-begin---author:zyf ---date:20220411 for处理Sentinel限流自定义异常
Throwable throwable = e.getCause();
SentinelErrorInfoEnum errorInfoEnum = SentinelErrorInfoEnum.getErrorByException(throwable);
if (ObjectUtil.isNotEmpty(errorInfoEnum)) {
return Result.error(errorInfoEnum.getError());
}
//update-end---author:zyf ---date:20220411 for处理Sentinel限流自定义异常
// return Result.error("操作失败"+e.getMessage());
return Result.error("操作失败");
}
/**
* @Author 政辉
* @param e
* @return
*/
@ExceptionHandler(HttpRequestMethodNotSupportedException.class)
public Result<?> httpRequestMethodNotSupportedException(HttpRequestMethodNotSupportedException e){
StringBuffer sb = new StringBuffer();
sb.append("不支持");
sb.append(e.getMethod());
sb.append("请求方法,");
sb.append("支持以下");
String [] methods = e.getSupportedMethods();
if(methods!=null){
for(String str:methods){
sb.append(str);
sb.append("");
}
}
log.error(sb.toString(), e);
//return Result.error("没有权限,请联系管理员授权");
return Result.error(405,sb.toString());
}
/**
* spring默认上传大小100MB 超出大小捕获异常MaxUploadSizeExceededException
*/
@ExceptionHandler(MaxUploadSizeExceededException.class)
public Result<?> handleMaxUploadSizeExceededException(MaxUploadSizeExceededException e) {
log.error(e.getMessage(), e);
return Result.error("文件大小超出10MB限制, 请压缩或降低文件质量! ");
}
@ExceptionHandler(DataIntegrityViolationException.class)
public Result<?> handleDataIntegrityViolationException(DataIntegrityViolationException e) {
log.error(e.getMessage(), e);
//issues/3624数据库执行异常handleDataIntegrityViolationException提示有误 #3624
return Result.error("执行数据库异常,违反了完整性例如:违反惟一约束、违反非空限制、字段内容超出长度等");
}
@ExceptionHandler(PoolException.class)
public Result<?> handlePoolException(PoolException e) {
log.error(e.getMessage(), e);
return Result.error("Redis 连接异常!");
}
@ExceptionHandler({ SQLSyntaxErrorException.class, SQLNonTransientException.class, SQLException.class })
public Result<?> handleSQLSyntaxErrorException(SQLException e) {
log.error(e.getMessage(), e);
return Result.error("SQL语法错误");
}
@ExceptionHandler({ BadSqlGrammarException.class, InvalidDataAccessResourceUsageException.class, NonTransientDataAccessException.class, DataAccessException.class })
public Result<?> handleBadSqlGrammarException(DataAccessException e) {
log.error(e.getMessage(), e);
return Result.error("SQL语法错误");
}
}

View File

@ -0,0 +1,50 @@
package org.jeecg.common.exception;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Iterator;
@Component
@Slf4j
public class LoggingInterceptor implements HandlerInterceptor {
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
// 记录普通请求信息
log.info("Request intercepted: URL={}, Method={}, Parameters={}",
request.getRequestURI(), request.getMethod(), request.getParameterMap());
// 如果是多部分请求文件上传记录文件元数据
if (request instanceof MultipartHttpServletRequest) {
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
Iterator<String> fileNames = multipartRequest.getFileNames();
while (fileNames.hasNext()) {
String fileName = fileNames.next();
MultipartFile file = multipartRequest.getFile(fileName);
log.info("Intercepted file upload: URL={}, File name={}, Size={} bytes, Content type={}",
request.getRequestURI(), file.getOriginalFilename(), file.getSize(), file.getContentType());
}
}
return true; // 继续处理链
}
// 可选实现postHandle和afterCompletion方法...
@Override
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
// 可以在这里添加处理后的行为
}
@Override
public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
// 可以在这里添加请求完成后的行为
}
}

View File

@ -0,0 +1,19 @@
package org.jeecg.common.exception;
import org.jeecg.common.exception.LoggingInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Configuration
public class WebConfig implements WebMvcConfigurer {
@Autowired
private LoggingInterceptor loggingInterceptor;
@Override
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(loggingInterceptor).addPathPatterns("/**");
}
}

View File

@ -9,6 +9,7 @@ import com.xkcoding.http.HttpUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.compress.utils.Lists;
import org.apache.commons.lang.StringUtils;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
@ -21,6 +22,7 @@ import org.jeecg.common.util.DateUtils;
import org.jeecg.modules.kc.config.entity.KcExportConfigTpkwcqkjzglx;
import org.jeecg.modules.kc.config.service.IKcExportConfigTpkwcqkjzglxService;
import org.jeecg.modules.kc.grab.imports.entity.Xxhbbks;
import org.jeecg.modules.kc.grab.imports.entity.Xxhbtkxx;
import org.jeecg.modules.kc.grab.imports.service.IXxhbbksService;
import org.jeecg.modules.kc.kcSysConfig.entity.KcSysConfig;
import org.jeecg.modules.kc.kcSysConfig.service.IKcSysConfigService;
@ -32,6 +34,8 @@ import org.jeecg.modules.kc.zyDbtx.service.IZyDbtxService;
import org.jeecg.modules.kc.zyInfo.entity.CyInfoSys;
import org.jeecg.modules.kc.zyInfo.entity.ZyInfo;
import org.jeecg.modules.kc.zyInfo.entity.ZyInfoSys;
import org.jeecg.modules.kc.zyInfo.pojo.ExportEntity1;
import org.jeecg.modules.kc.zyInfo.pojo.ExportEntity2;
import org.jeecg.modules.kc.zyInfo.service.IZyInfoService;
import org.jeecg.modules.kc.zyInfoStudent.entity.ZyInfoStudent;
import org.jeecg.modules.kc.zyInfoStudent.service.IZyInfoStudentService;
@ -39,6 +43,7 @@ import org.jeecg.modules.system.service.impl.SysBaseApiImpl;
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
import org.jeecgframework.poi.excel.entity.ExportParams;
import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.ResponseEntity;
@ -198,8 +203,6 @@ public class ZyInfoController extends JeecgController<ZyInfo, IZyInfoService> {
}
@ApiOperation(value = "引用作业列表", notes = "引用作业列表")
@GetMapping(value = "/listOther")
public Result<IPage<ZyInfo>> listOther(ZyInfo zyInfo,
@ -605,7 +608,6 @@ public class ZyInfoController extends JeecgController<ZyInfo, IZyInfoService> {
}
@ApiOperation(value = "教学大纲-分页列表查询", notes = "教学大纲-分页列表查询")
@GetMapping(value = "/sysList")
public Result<IPage<ZyInfoSys>> sysList(ZyInfoSys zyInfoSys,
@ -738,7 +740,6 @@ public class ZyInfoController extends JeecgController<ZyInfo, IZyInfoService> {
}
@ApiOperation(value = "作业发布-通过id查询", notes = "作业发布-通过id查询")
@GetMapping(value = "/queryZyinfoByStuId")
public Result<ZyInfo> queryZyinfoByStuId(@RequestParam(name = "id", required = true) String id) {
@ -748,7 +749,6 @@ public class ZyInfoController extends JeecgController<ZyInfo, IZyInfoService> {
}
@AutoLog(value = "作业发布-添加")
@ApiOperation(value = "作业发布-添加", notes = "作业发布-添加")
@PostMapping(value = "/batchAdd")
@ -886,7 +886,6 @@ public class ZyInfoController extends JeecgController<ZyInfo, IZyInfoService> {
}
/**
* 编辑
*
@ -949,8 +948,6 @@ public class ZyInfoController extends JeecgController<ZyInfo, IZyInfoService> {
}
@ApiOperation(value = "统计作业测试使用情况", notes = "统计作业测试使用情况")
@GetMapping(value = "/sysStaticNo")
public Result<Map<String, Object>> sysStaticNo(ZyInfoSys zyInfoSys,
@ -986,8 +983,120 @@ public class ZyInfoController extends JeecgController<ZyInfo, IZyInfoService> {
return Result.OK(pageList);
}
@ApiOperation(value = "统计作业测试使用情况", notes = "刷新排行数据")
@GetMapping(value = "/getPHData")
public Result<List<ZyInfoSys>> getPHData(ZyInfoSys zyInfoSys,
@RequestParam(name = "tag", required = false) String tag,
HttpServletRequest req) {
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
//-------------获取当前登陆人是否是管理员角色如果不是都按照教务秘书处理---------------------------
List<String> roleList = sysBaseApi.getRolesByUsername(sysUser.getUsername());
String adminRole = "1";//0 admin 1教务秘书
for (String role : roleList) {
if (org.apache.commons.lang.StringUtils.equals("admin", role)) {
adminRole = "0";
break;
}
}
QueryWrapper<ZyInfoSys> queryWrapper = new QueryWrapper<ZyInfoSys>();
if (org.apache.commons.lang.StringUtils.equals("1", adminRole)) {
QueryWrapper<KcExportConfigTpkwcqkjzglx> queryWrapperCon = new QueryWrapper<KcExportConfigTpkwcqkjzglx>();
queryWrapperCon.eq("gh", sysUser.getUsername());
queryWrapperCon.orderByDesc("create_time");
queryWrapperCon.last("limit 1");
KcExportConfigTpkwcqkjzglx kcExportConfigTpkwcqkjzglx = kcExportConfigTpkwcqkjzglxService.getOne(queryWrapperCon);
zyInfoSys.setKkdw(kcExportConfigTpkwcqkjzglx.getDwmc());
}
if (com.baomidou.mybatisplus.core.toolkit.StringUtils.isEmpty(zyInfoSys.getXqxn())) {
KcSysConfig kcSysConfig = kcSysConfigService.getById("1");
zyInfoSys.setXqxn(kcSysConfig.getFlag1());
}
List<ZyInfoSys> list = zyInfoService.getPHData(zyInfoSys, tag);
return Result.OK(list);
}
@ApiOperation(value = "统计作业测试使用情况", notes = "导出排行数据")
@GetMapping(value = "/exportPHData")
public ModelAndView exportPHData(ZyInfoSys zyInfoSys, @RequestParam(name = "tag", required = false) String tag) {
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
//-------------获取当前登陆人是否是管理员角色如果不是都按照教务秘书处理---------------------------
List<String> roleList = sysBaseApi.getRolesByUsername(sysUser.getUsername());
String adminRole = "1";//0 admin 1教务秘书
for (String role : roleList) {
if (org.apache.commons.lang.StringUtils.equals("admin", role)) {
adminRole = "0";
break;
}
}
QueryWrapper<ZyInfoSys> queryWrapper = new QueryWrapper<ZyInfoSys>();
if (org.apache.commons.lang.StringUtils.equals("1", adminRole)) {
QueryWrapper<KcExportConfigTpkwcqkjzglx> queryWrapperCon = new QueryWrapper<KcExportConfigTpkwcqkjzglx>();
queryWrapperCon.eq("gh", sysUser.getUsername());
queryWrapperCon.orderByDesc("create_time");
queryWrapperCon.last("limit 1");
KcExportConfigTpkwcqkjzglx kcExportConfigTpkwcqkjzglx = kcExportConfigTpkwcqkjzglxService.getOne(queryWrapperCon);
zyInfoSys.setKkdw(kcExportConfigTpkwcqkjzglx.getDwmc());
}
if (com.baomidou.mybatisplus.core.toolkit.StringUtils.isEmpty(zyInfoSys.getXqxn())) {
KcSysConfig kcSysConfig = kcSysConfigService.getById("1");
zyInfoSys.setXqxn(kcSysConfig.getFlag1());
}
List<ZyInfoSys> list = zyInfoService.getPHData(zyInfoSys, tag);
List exportList = Lists.newArrayList();
String title = "";
ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
if("kctop10".equals(tag)){
title = "本学年课程使用排行";
mv.addObject(NormalExcelConstants.CLASS, ExportEntity2.class);
//处理数据转换
exportList = list.stream()
.map(zyInfo -> {
ExportEntity2 entity = new ExportEntity2();
// 使用 Spring BeanUtils 复制属性
BeanUtils.copyProperties(zyInfo, entity);
String rn = entity.getRownum();
entity.setRownum(rn.substring(0,rn.indexOf(".")));
return entity;
})
.collect(Collectors.toList());
}else{
mv.addObject(NormalExcelConstants.CLASS, ExportEntity1.class);
if ("xntop10".equals(tag)) {
title = "本学年作业使用排行";
}
if ("jrtop10".equals(tag)) {
title = "本学年测验使用排行";
}
if ("jstop10".equals(tag)) {
title = "本学年教师使用排行";
}
//处理数据转换
exportList = list.stream()
.map(zyInfo -> {
ExportEntity1 entity = new ExportEntity1();
// 使用 Spring BeanUtils 复制属性
BeanUtils.copyProperties(zyInfo, entity);
String rn = entity.getRownum();
entity.setRownum(rn.substring(0,rn.indexOf(".")));
return entity;
})
.collect(Collectors.toList());
}
//此处设置的filename无效 ,前端会重更新设置一下
mv.addObject(NormalExcelConstants.FILE_NAME, title);
//update-begin--Author:liusq Date:20210126 for图片导出报错ImageBasePath未设置--------------------
ExportParams exportParams = new ExportParams(title + "报表", "导出人:" + sysUser.getRealname(), title);
exportParams.setImageBasePath(upLoadPath);
//update-end--Author:liusq Date:20210126 for图片导出报错ImageBasePath未设置----------------------
mv.addObject(NormalExcelConstants.PARAMS, exportParams);
mv.addObject(NormalExcelConstants.DATA_LIST, exportList);
return mv;
}
@ApiOperation(value = "统计作业使用情况", notes = "统计作业使用情况")
@GetMapping(value = "/sysStaticZyList")
@ -1108,7 +1217,6 @@ public class ZyInfoController extends JeecgController<ZyInfo, IZyInfoService> {
}
@ApiOperation(value = "作业发布-分页列表查询", notes = "作业发布-分页列表查询")
@GetMapping(value = "/listKhcl")
public Result<IPage<ZyInfo>> listKhcl(ZyInfo zyInfo,

View File

@ -26,6 +26,7 @@ public class ZyInfoSys implements Serializable {
private String xqxn;
@Excel(name = "学院", width = 15)
private String kkdw;
private String dwh;//学院号
@Excel(name = "课程名称", width = 15)
private String kcmc;
@Excel(name = "课程性质", width = 15)

View File

@ -36,10 +36,26 @@ public interface ZyInfoMapper extends BaseMapper<ZyInfo> {
List<ZyInfoSys> getZyStaticNo(@Param("zyInfoSys") ZyInfoSys zyInfoSys);
List<ZyInfoSys> getXyZyList(@Param("zyInfoSys") ZyInfoSys zyInfoSys);
List<ZyInfoSys> getZyTopList(@Param("zyInfoSys") ZyInfoSys zyInfoSys);
List<ZyInfoSys> getZyList(@Param("zyInfoSys") ZyInfoSys zyInfoSys);
List<ZyInfoSys> getCyTopList(@Param("zyInfoSys") ZyInfoSys zyInfoSys);
List<ZyInfoSys> getCyList(@Param("zyInfoSys") ZyInfoSys zyInfoSys);
List<ZyInfoSys> getXYCyList(@Param("zyInfoSys") ZyInfoSys zyInfoSys);
List<ZyInfoSys> getKcTopList(@Param("zyInfoSys") ZyInfoSys zyInfoSys);
List<ZyInfoSys> getXnKcList(@Param("zyInfoSys") ZyInfoSys zyInfoSys);
List<ZyInfoSys> getJsTopList(@Param("zyInfoSys") ZyInfoSys zyInfoSys);
List<ZyInfoSys> getXnJsList(@Param("zyInfoSys") ZyInfoSys zyInfoSys);
IPage<ZyInfoSys> sysStaticZyList(Page<ZyInfoSys> page,@Param("zyInfoSys") ZyInfoSys zyInfoSys);
IPage<CyInfoSys> sysStaticCyList(Page<CyInfoSys> page, @Param("zyInfoSys") CyInfoSys cyInfoSys);

View File

@ -244,6 +244,26 @@
select count(distinct ww.id) as count,'10' as type from wjx_wjxx ww join kc_kechengbiao kk on kk.jgh = ww.create_by AND kk.rwbh = ww.rwbh AND kk.xqxn = ww.xqxn where (ww.update_time = DATE_FORMAT(NOW(),'%Y-%m-%d') or ww.create_time = DATE_FORMAT(NOW(),'%Y-%m-%d') ) and ww.qpublish in (2)
union all
select count(distinct zi.id) as count,'11' as type from zy_info zi join kc_kechengbiao kk on kk.jgh = zi.create_by AND kk.rwbh = zi.rwbh AND kk.xqxn = zi.xnxq where zi.zy_status in ('1','2') and zi.xnxq = #{zyInfoSys.xqxn} and zi.sfcc in ('1','2') and kk.flag = 0
union all
select count(*) as count,'12' as type from zy_info where file_path is not null and xnxq = #{zyInfoSys.xqxn}
union all
select count(*) as count,'13' as type from zy_info where file_path is not null and xnxq = #{zyInfoSys.xqxn} and xshpkg = '1'
union all
select count(*) as count,'14' as type from zy_info where file_path is not null and xnxq = #{zyInfoSys.xqxn} and sfcc = '1'
union all
SELECT COUNT(*) as count,'16' as type FROM wjx_djxx WHERE create_time BETWEEN (SELECT bxqkssj FROM kc_sys_config WHERE flag1=#{zyInfoSys.xqxn} LIMIT 1) AND (SELECT bxqjssj FROM kc_sys_config WHERE flag1=#{zyInfoSys.xqxn} LIMIT 1);
</select>
<select id="getXyZyList" resultType="org.jeecg.modules.kc.zyInfo.entity.ZyInfoSys">
select (@rownum:=@rownum + 1) AS rownum,t.* from (
select count(*) as count,b.dwmc as kkdw from zy_info a,xxhbuser b where a.create_by = b.gh and xnxq = #{zyInfoSys.xqxn} and zy_status in (1,2) GROUP BY b.dwmc
) t , (SELECT @rownum:=0) AS r ORDER BY count-0 desc
</select>
<select id="getZyList" resultType="org.jeecg.modules.kc.zyInfo.entity.ZyInfoSys">
select (@rownum:=@rownum + 1) AS rownum,t.* from (
select a.create_by,count(*) as count,b.xm as skjs,b.dwmc as kkdw from zy_info a,xxhbuser b where a.create_by = b.gh and xnxq = #{zyInfoSys.xqxn} and zy_status in (1,2) GROUP BY a.create_by ,b.xm,b.dwmc
) t , (SELECT @rownum:=0) AS r ORDER BY count-0 desc
</select>
<select id="getZyTopList" resultType="org.jeecg.modules.kc.zyInfo.entity.ZyInfoSys">
@ -252,13 +272,169 @@
) t , (SELECT @rownum:=0) AS r ORDER BY count-0 desc limit 10
</select>
<select id="getCyList" resultType="org.jeecg.modules.kc.zyInfo.entity.ZyInfoSys">
select (@rownum:=@rownum + 1) AS rownum,t.* from (
select a.create_by,count(*) as count,b.xm as skjs,b.dwmc as kkdw from wjx_wjxx a,xxhbuser b where a.create_by = b.gh and xqxn = #{zyInfoSys.xqxn} and qpublish in (1,2) GROUP BY a.create_by ,b.xm,b.dwmc
) t , (SELECT @rownum:=0) AS r ORDER BY count-0 desc
</select>
<select id="getCyTopList" resultType="org.jeecg.modules.kc.zyInfo.entity.ZyInfoSys">
select (@rownum:=@rownum + 1) AS rownum,t.* from (
select a.create_by,count(*) as count,b.xm as skjs,b.dwmc as kkdw from wjx_wjxx a,xxhbuser b where a.create_by = b.gh and xqxn = #{zyInfoSys.xqxn} and qpublish in (1,2) GROUP BY a.create_by ,b.xm,b.dwmc
) t , (SELECT @rownum:=0) AS r ORDER BY count-0 desc limit 10
</select>
<select id="getXYCyList" resultType="org.jeecg.modules.kc.zyInfo.entity.ZyInfoSys">
select (@rownum:=@rownum + 1) AS rownum,t.* from (
select count(*) as count,b.dwmc as kkdw from wjx_wjxx a,xxhbuser b where a.create_by = b.gh and xqxn = #{zyInfoSys.xqxn} and qpublish in (1,2) GROUP BY b.dwmc
) t , (SELECT @rownum:=0) AS r ORDER BY count-0 desc
</select>
<select id="getKcTopList" resultType="org.jeecg.modules.kc.zyInfo.entity.ZyInfoSys">
SELECT
( @rownum := @rownum + 1 ) AS rownum,
t.*
FROM
(
SELECT
b.kcmc,
count(*) AS count,
b.kkdw
FROM
zy_info a,
kc_kechengbiao b
WHERE
a.rwbh = b.rwbh
AND a.xnxq = #{zyInfoSys.xqxn} GROUP BY b.kcmc,b.kkdw
union all
SELECT
b.kcmc,
count(*) AS count,
b.kkdw
FROM
wjx_wjxx a,
kc_kechengbiao b
WHERE
a.rwbh = b.rwbh
AND a.xqxn = #{zyInfoSys.xqxn} GROUP BY b.kcmc,b.kkdw
) t,
( SELECT @rownum := 0 ) AS r
ORDER BY
count - 0 DESC
LIMIT 10
</select>
<select id="getXnKcList" resultType="org.jeecg.modules.kc.zyInfo.entity.ZyInfoSys">
SELECT
( @rownum := @rownum + 1 ) AS rownum,
t.*
FROM
(
SELECT
b.kcmc,
count(*) AS count,
b.kkdw
FROM
zy_info a,
kc_kechengbiao b
WHERE
a.rwbh = b.rwbh
AND a.xnxq = #{zyInfoSys.xqxn} GROUP BY b.kcmc,b.kkdw
union all
SELECT
b.kcmc,
count(*) AS count,
b.kkdw
FROM
wjx_wjxx a,
kc_kechengbiao b
WHERE
a.rwbh = b.rwbh
AND a.xqxn = #{zyInfoSys.xqxn} GROUP BY b.kcmc,b.kkdw
) t,
( SELECT @rownum := 0 ) AS r
ORDER BY
count - 0 DESC
</select>
<select id="getJsTopList" resultType="org.jeecg.modules.kc.zyInfo.entity.ZyInfoSys">
SELECT
( @rownum := @rownum + 1 ) AS rownum,
t.*
FROM
(
SELECT
a.create_by,
count(*) AS count,
b.xm AS skjs,
b.dwmc AS kkdw
FROM
zy_info a,
xxhbuser b
WHERE
a.create_by = b.gh
AND xnxq = #{zyInfoSys.xqxn} and zy_status in (1,2) GROUP BY a.create_by ,b.xm,b.dwmc
union all
SELECT
a.create_by,
count(*) AS count,
b.xm AS skjs,
b.dwmc AS kkdw
FROM
wjx_wjxx a,
xxhbuser b
WHERE
a.create_by = b.gh
AND xqxn = #{zyInfoSys.xqxn} and qpublish in (1,2) GROUP BY a.create_by ,b.xm,b.dwmc
) t,
( SELECT @rownum := 0 ) AS r
ORDER BY
count - 0 DESC
LIMIT 10
</select>
<select id="getXnJsList" resultType="org.jeecg.modules.kc.zyInfo.entity.ZyInfoSys">
SELECT
( @rownum := @rownum + 1 ) AS rownum,
t.*
FROM
(
SELECT
a.create_by,
count(*) AS count,
b.xm AS skjs,
b.dwmc AS kkdw
FROM
zy_info a,
xxhbuser b
WHERE
a.create_by = b.gh
AND xnxq = #{zyInfoSys.xqxn} and zy_status in (1,2) GROUP BY a.create_by ,b.xm,b.dwmc
union all
SELECT
a.create_by,
count(*) AS count,
b.xm AS skjs,
b.dwmc AS kkdw
FROM
wjx_wjxx a,
xxhbuser b
WHERE
a.create_by = b.gh
AND xqxn = #{zyInfoSys.xqxn} and qpublish in (1,2) GROUP BY a.create_by ,b.xm,b.dwmc
) t,
( SELECT @rownum := 0 ) AS r
ORDER BY
count - 0 DESC
</select>
<select id="sysStaticZyList" resultType="org.jeecg.modules.kc.zyInfo.entity.ZyInfoSys">
select a.*,b.skjs,b.jgh,b.kcmc,b.kcbh,b.xkrs,b.kkdw,b.kcxz,b.zc,a.xnxq as xqxn,

View File

@ -0,0 +1,28 @@
package org.jeecg.modules.kc.zyInfo.pojo;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.jeecgframework.poi.excel.annotation.Excel;
import java.io.Serializable;
/**
* @Description: 导出用
* @Author: zmy
*/
@Data
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = false)
public class ExportEntity1 implements Serializable {
private static final long serialVersionUID = 1L;
@Excel(name = "序号", width = 10)
private String rownum;
@Excel(name = "姓名", width = 15)
private String skjs;
@Excel(name = "次数", width = 15)
private String count;
@Excel(name = "学院", width = 40)
private String kkdw;
}

View File

@ -0,0 +1,28 @@
package org.jeecg.modules.kc.zyInfo.pojo;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.jeecgframework.poi.excel.annotation.Excel;
import java.io.Serializable;
/**
* @Description: 导出用
* @Author: zmy
*/
@Data
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = false)
public class ExportEntity2 implements Serializable {
private static final long serialVersionUID = 1L;
@Excel(name = "序号", width = 10)
private String rownum;
@Excel(name = "课程", width = 40)
private String kcmc;
@Excel(name = "次数", width = 15)
private String count;
@Excel(name = "学院", width = 40)
private String kkdw;
}

View File

@ -37,6 +37,8 @@ public interface IZyInfoService extends IService<ZyInfo> {
Map<String,Object> sysStaticNo(ZyInfoSys zyInfoSys);
List<ZyInfoSys> getPHData(ZyInfoSys zyInfoSys,String tag);
IPage<ZyInfoSys> sysStaticZyList(Page<ZyInfoSys> page, ZyInfoSys zyInfoSys);
IPage<CyInfoSys> sysStaticCyList(Page<CyInfoSys> page, CyInfoSys cyInfoSys);

View File

@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.google.common.collect.Lists;
import com.xkcoding.http.HttpUtil;
import org.apache.commons.lang.StringUtils;
import org.apache.shiro.SecurityUtils;
@ -180,6 +181,12 @@ public class ZyInfoServiceImpl extends ServiceImpl<ZyInfoMapper, ZyInfo> impleme
String jr_cy_syzcs = "0";
String jr_cy_ywczcs = "0";
String xn_zy_cccs = "0"; //查重次数
String xn_kc_zyzxsrc = "0";//使用课程作业总学生人次
String xn_kc_zyhp = "0";//使用课程作业互评总学生人次
String xn_kc_zycc = "0";//使用课程作业查重总学生人次
String xn_kc_zywczxsrc = "0";//完成课程作业总学生人次
String xn_kc_ktcy = "0";//使用课堂测验总学生人次
String xn_kc_wccy = "0";//完成课堂测验总学生人次
List<ZyInfoSys> list = baseMapper.getZyStaticNo(zyInfoSys);
for (ZyInfoSys par : list) {
@ -205,13 +212,36 @@ public class ZyInfoServiceImpl extends ServiceImpl<ZyInfoMapper, ZyInfo> impleme
jr_cy_ywczcs = par.getCount();
} else if (StringUtils.equals("11", par.getType())) {
xn_zy_cccs = par.getCount();
} else if (StringUtils.equals("12", par.getType())) {
xn_kc_zyzxsrc = par.getCount();
} else if (StringUtils.equals("13", par.getType())) {
xn_kc_zyhp = par.getCount();
} else if (StringUtils.equals("14", par.getType())) {
xn_kc_zycc = par.getCount();
} else if (StringUtils.equals("15", par.getType())) {
xn_kc_zywczxsrc = par.getCount();
} else if (StringUtils.equals("16", par.getType())) {
xn_kc_ktcy = par.getCount();
} else if (StringUtils.equals("17", par.getType())) {
xn_kc_wccy = par.getCount();
}
}
//本学年作业使用排行TOP10
List<ZyInfoSys> list1 = baseMapper.getZyTopList(zyInfoSys);
//本学年测验使用排行TOP10
List<ZyInfoSys> list2 = baseMapper.getCyTopList(zyInfoSys);
//本学年课程使用排行TOP10
List<ZyInfoSys> list3 = baseMapper.getKcTopList(zyInfoSys);
//本学年教师使用排行TOP10
List<ZyInfoSys> list4 = baseMapper.getJsTopList(zyInfoSys);
list.add(zyInfoSys);
//本学年各个学院作业数
List<ZyInfoSys> list5 = baseMapper.getXyZyList(zyInfoSys);
//本学年各个学院测验数
List<ZyInfoSys> list6 = baseMapper.getXYCyList(zyInfoSys);
map.put("xn_zy_syzcs", xn_zy_syzcs);//本学年作业使用总次数
map.put("xn_zy_hpzcs", xn_zy_hpzcs);//本学年作业互评总次数
map.put("xn_zy_ywczcs", xn_zy_ywczcs);//本学年作业已完成总次数
@ -223,12 +253,39 @@ public class ZyInfoServiceImpl extends ServiceImpl<ZyInfoMapper, ZyInfo> impleme
map.put("jr_zy_ywczcs", jr_zy_ywczcs);//今日作业已完成总次数
map.put("jr_cy_syzcs", jr_cy_syzcs);//今日测验使用总次数
map.put("jr_cy_ywczcs", jr_cy_ywczcs);//今日测验已完成总次数
map.put("xn_kc_zyzxsrc",xn_kc_zyzxsrc );//使用课程作业总学生人次
map.put("xn_kc_zyhp",xn_kc_zyhp );//使用课程作业互评总学生人次
map.put("xn_kc_zycc",xn_kc_zycc );//使用课程作业查重总学生人次
map.put("xn_kc_zywczxsrc",xn_kc_zywczxsrc );//完成课程作业总学生人次
map.put("xn_kc_ktcy",xn_kc_ktcy );//使用课堂测验总学生人次
map.put("xn_kc_wccy",xn_kc_wccy );//完成课堂测验总学生人次
map.put("xntop10", list1);//本学年作业使用排行TOP10
map.put("jrtop10", list2);//本学年测验使用排行TOP10
map.put("kctop10", list3);//本学年课程使用排行TOP10
map.put("jstop10", list4);//本学年教师使用排行TOP10
map.put("xnxyzycs", list5);//本学年各个学院作业数
map.put("xnxycycs", list6);//本学年各个学院测验数
return map;
}
@Override
public List<ZyInfoSys> getPHData(ZyInfoSys zyInfoSys,String tag) {
List<ZyInfoSys> list = Lists.newArrayList();
if("xntop10".equals(tag)){
list = baseMapper.getZyList(zyInfoSys);
}
if("jrtop10".equals(tag)){
list = baseMapper.getCyList(zyInfoSys);
}
if("kctop10".equals(tag)){
list = baseMapper.getXnKcList(zyInfoSys);
}
if("jstop10".equals(tag)){
list = baseMapper.getXnJsList(zyInfoSys);
}
return list;
}
@Override
public IPage<ZyInfoSys> sysStaticZyList(Page<ZyInfoSys> page, ZyInfoSys zyInfoSys) {
return baseMapper.sysStaticZyList(page, zyInfoSys);

View File

@ -18,16 +18,26 @@ import org.jeecg.modules.kc.kcCasusers.service.IKcCasusersService;
import org.jeecg.modules.kc.zyInfoStudent.entity.ZyInfoStudent;
import org.jeecg.modules.kc.zyInfoStudent.service.IZyInfoStudentService;
import org.jeecg.modules.kc.zyZyxx.entity.ZyZyxx;
import org.jeecg.modules.system.controller.CommonController;
import org.jeecg.modules.system.entity.SysUser;
import org.jeecg.modules.system.service.ISysUserService;
import org.jeecg.modules.wps.entity.WpsEnti;
import org.jeecg.modules.wps.entity.WpsUploadEnti;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;
import java.util.*;
/**
@ -46,6 +56,9 @@ public class WpsController extends JeecgController<KcCasusers, IKcCasusersServic
@Autowired
private ISysUserService sysUserService;
@Autowired
private CommonController commonController;
/**
* 文档预览
*
@ -82,11 +95,14 @@ public class WpsController extends JeecgController<KcCasusers, IKcCasusersServic
*/
@RequestMapping(value = "/files/{fileId}/download", method = {RequestMethod.GET})
public Map<String, Object> download(@PathVariable("fileId") String fileId) {
log.info("~~~~~~~~~~~~>>>>>>>>>>>");
log.info("download--fileId=" + fileId);
log.info("~~~~~~~~~~~~<<<<<<<<<<<");
ZyInfoStudent zyInfoStudent = zyInfoStudentService.getById(fileId);
Map<String, Object> mapRet = new HashMap<>();
Map<String, Object> mapRet2 = new HashMap<>();
// https://kczxcs.nenu.edu.cn/jeecg-boot/sys/common/static/temp/QA%E4%BD%9C%E4%B8%9A%E7%B3%BB%E7%BB%9F%E5%B8%B8%E8%A7%81%E9%97%AE%E9%A2%98_1733101749150.docx
mapRet2.put("url", "https://kczxcs.nenu.edu.cn/jeecg-boot/sys/common/static/" + zyInfoStudent.getFilePath());
Map<String, String> headers = new HashMap<>();
mapRet.put("code", 0);
mapRet.put("data", mapRet2);
return mapRet;
@ -197,7 +213,7 @@ public class WpsController extends JeecgController<KcCasusers, IKcCasusersServic
Map<String, Object> mapRet = new HashMap<>();
mapRet.put("code", 0);
Map<String, Object> mapRet2 = new HashMap<>();
mapRet2.put("url", "https://kczxcs.nenu.edu.cn/jeecg-boot/sys/common/static/" + zyInfoStudent.getFilePath());
mapRet2.put("url", "https://kczxcs.nenu.edu.cn/jeecg-boot/v3/3rd/static/" + zyInfoStudent.getFilePath());
mapRet2.put("method", "POST");
mapRet.put("data", mapRet2);
mapRet.put("message", "");
@ -226,5 +242,18 @@ public class WpsController extends JeecgController<KcCasusers, IKcCasusersServic
return mapRet;
}
@PostMapping("/static/temp/{fileName}")
public ResponseEntity<String> downloadFile(@PathVariable String fileName
, @RequestParam(value = "file", required = false) MultipartFile file) {
log.info(">>>>>>>>>");
log.info("fileName=" + fileName);
String newFileName = fileName.substring(0, fileName.indexOf("_")) + "_" + System.currentTimeMillis() + fileName.substring(fileName.indexOf("."));
log.info("fileName222处理后=", newFileName);
String savePath = commonController.uploadLocal(file, newFileName, "temp");
log.info("savePath=" + savePath);
log.info("<<<<<<<<<");
//TODO 存数据库 不能旧的不删除然后每次都新存 前端关闭弹窗时调用保存方法来触发这个接口
return null;
}
}

View File

@ -21,6 +21,7 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.util.AntPathMatcher;
import org.springframework.util.FileCopyUtils;
import org.springframework.web.bind.annotation.*;
@ -34,6 +35,11 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.stream.Collectors;
@ -68,8 +74,8 @@ public class CommonController {
SftpConfig sftpConfig;
/**
* @Author 政辉
* @return
* @Author 政辉
*/
@GetMapping("/403")
public Result<?> noauth() {
@ -78,6 +84,7 @@ public class CommonController {
/**
* 文件上传统一方法
*
* @param request
* @param response
* @return
@ -109,8 +116,10 @@ public class CommonController {
}
return result;
}
/**
* 文件上传统一方法
*
* @param bizPath
* @param file
* @return
@ -159,6 +168,7 @@ public class CommonController {
/**
* 本地文件上传
*
* @param mf 文件
* @param bizPath 自定义路径
* @return
@ -169,11 +179,12 @@ public class CommonController {
/**
* 本地文件上传
*
* @param mf 文件
* @param bizPath 自定义路径
* @return
*/
private String uploadLocal(MultipartFile mf,String _fileName,String bizPath){
public String uploadLocal(MultipartFile mf, String _fileName, String bizPath) {
try {
String ctxPath = uploadpath;
String fileName = _fileName;
@ -329,6 +340,7 @@ public class CommonController {
return Result.OK("upload ok");
}
@PostMapping(value = "/sectionUpload/end")
public Result<?> sectionUploadEnd(@RequestBody SectionUploadData sectionUploadData) {
log.info("合并文件!");
@ -426,6 +438,7 @@ public class CommonController {
/**
* file转MultipartFile
*
* @param file File对象
* @return MultipartFile 对象
*/
@ -608,9 +621,9 @@ public class CommonController {
// }
/**
* @功能pdf预览Iframe
* @param modelAndView
* @return
* @功能pdf预览Iframe
*/
@RequestMapping("/pdf/pdfPreviewIframe")
public ModelAndView pdfPreviewIframe(ModelAndView modelAndView) {
@ -621,6 +634,7 @@ public class CommonController {
/**
* 把指定URL后的字符串全部截断当成参数
* 这么做是为了防止URL中包含中文或者特殊字符/匹配不了的问题
*
* @param request
* @return
*/
@ -632,6 +646,7 @@ public class CommonController {
/**
* 获取文件真实路径
*
* @param path
* @return
*/