浏览代码

3.3.0 fix

xiaofei 1 年之前
父节点
当前提交
a44f1eefab

+ 13 - 0
distributed-print/install/mysql/init/teachcloud_db.sql

@@ -1933,6 +1933,19 @@ CREATE TABLE IF NOT EXISTS `scan_file_property` (
         PRIMARY KEY (`path`) USING BTREE
         ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
 
+-- ----------------------------
+-- Table structure for scan_log
+-- ----------------------------
+CREATE TABLE  IF NOT EXISTS `scan_log` (
+      `school_code` VARCHAR(20) NOT NULL COMMENT '学校代码',
+      `device_code` VARCHAR(50) NOT NULL COMMENT '设备号',
+      `file_name` VARCHAR(45) NOT NULL COMMENT '文件名',
+      `md5` VARCHAR(45) NOT NULL COMMENT '扫描端日志',
+      `path` VARCHAR(45) NULL COMMENT '文件存储路径',
+      `upload_time` BIGINT(20) NULL COMMENT '上传时间',
+    PRIMARY KEY (`school_code`, `device_code`, `file_name`) USING BTREE
+    ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
+
 -- ----------------------------
 -- Table structure for scan_omr_task
 -- ----------------------------

+ 64 - 0
distributed-print/src/main/java/com/qmth/distributed/print/api/mark/ScanLogController.java

@@ -0,0 +1,64 @@
+package com.qmth.distributed.print.api.mark;
+
+
+import com.qmth.boot.api.annotation.Aac;
+import com.qmth.boot.api.constant.ApiConstant;
+import com.qmth.teachcloud.common.contant.SystemConstant;
+import com.qmth.teachcloud.common.util.Result;
+import com.qmth.teachcloud.common.util.ResultUtil;
+import com.qmth.teachcloud.mark.service.ScanLogService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.multipart.MultipartFile;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletResponse;
+import javax.validation.constraints.Max;
+import javax.validation.constraints.Min;
+
+/**
+ * <p>
+ * 扫描日志 前端控制器
+ * </p>
+ *
+ * @author xf
+ * @since 2023-12-08
+ */
+@Api(tags = "扫描日志上传知学知考接口")
+@RestController
+@RequestMapping(ApiConstant.DEFAULT_URI_PREFIX + SystemConstant.PREFIX_URL_SCAN + "/log")
+public class ScanLogController {
+
+    @Resource
+    private ScanLogService scanLogService;
+
+    /**
+     * 班级阅卷进度列表查询
+     */
+    @ApiOperation(value = "日志文件上传")
+    @RequestMapping(value = "/upload", method = RequestMethod.POST)
+    @Aac(auth = false)
+    public Result upload(@ApiParam(value = "学校代码", required = true) @RequestParam String schoolCode,
+                         @ApiParam(value = "设备编号", required = true) @RequestParam String deviceCode,
+                         @ApiParam(value = "文件", required = true) @RequestParam MultipartFile file,
+                         @ApiParam(value = "md5", required = true) @RequestParam String md5) {
+        return ResultUtil.ok(scanLogService.uploadLogFile(schoolCode, deviceCode, file, md5));
+    }
+
+    /**
+     * 评阅题目列表
+     */
+    @ApiOperation(value = "日志文件查询")
+    @RequestMapping(value = "/list", method = RequestMethod.POST)
+    @Aac(auth = false)
+    public Result listGroupQuestions(@ApiParam(value = "学校代码", required = true) @RequestParam String schoolCode,
+                                     @RequestParam @Min(SystemConstant.PAGE_NUMBER_MIN) Integer pageNumber,
+                                     @RequestParam @Min(SystemConstant.PAGE_SIZE_MIN) @Max(SystemConstant.PAGE_SIZE_MAX) Integer pageSize) {
+        return ResultUtil.ok(scanLogService.listScanLog(schoolCode, pageNumber, pageSize));
+    }
+}

文件差异内容过多而无法显示
+ 1 - 1
distributed-print/src/test/java/com/qmth/distributed/print/ConvertUtilTest.java


+ 5 - 1
teachcloud-common/src/main/java/com/qmth/teachcloud/common/enums/UploadFileEnum.java

@@ -51,7 +51,11 @@ public enum UploadFileEnum {
     /**
      * 签到表文件(path:{uploadType}/{examId}/{coursePaperId}/{packageCode}-{packageNo}.jpg)
      */
-    PACKAGE("package", "private", "%s/%d/%s/%s-%s.%s");
+    PACKAGE("package", "private", "%s/%d/%s/%s-%s.%s"),
+    /**
+     * 扫描端日志文件(path:{uploadType}/{schoolCode}/{deviceCode}/{fileName})
+     */
+    LOG("log", "public", "%s/%s/%s/%s");
 
     private String title;
     private String fssType;

+ 129 - 0
teachcloud-mark/src/main/java/com/qmth/teachcloud/mark/entity/ScanLog.java

@@ -0,0 +1,129 @@
+package com.qmth.teachcloud.mark.entity;
+
+import com.baomidou.mybatisplus.annotation.FieldStrategy;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
+import com.github.jeffreyning.mybatisplus.anno.MppMultiId;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+
+import java.io.Serializable;
+
+/**
+ * <p>
+ *
+ * </p>
+ *
+ * @author xf
+ * @since 2023-12-08
+ */
+@TableName("scan_log")
+@ApiModel(value = "ScanLog对象", description = "")
+public class ScanLog implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @JsonSerialize(using = ToStringSerializer.class)
+    @ApiModelProperty(value = "学校代码")
+    @MppMultiId(value = "school_code")
+    private String schoolCode;
+    @ApiModelProperty(value = "设备号")
+    @MppMultiId(value = "device_code")
+    private String deviceCode;
+
+    @ApiModelProperty(value = "文件名")
+    @MppMultiId(value = "file_name")
+    private String fileName;
+
+    @ApiModelProperty(value = "扫描端日志")
+    private String md5;
+
+    @ApiModelProperty(value = "地址")
+    @TableField(value = "path", updateStrategy = FieldStrategy.IGNORED)
+    private String path;
+
+    @ApiModelProperty(value = "上传时间")
+    private Long uploadTime;
+
+    @TableField(exist = false)
+    private String pathUrl;
+
+    public ScanLog() {
+    }
+
+    public ScanLog(String schoolCode, String deviceCode, String fileName) {
+        this.schoolCode = schoolCode;
+        this.deviceCode = deviceCode;
+        this.fileName = fileName;
+    }
+
+    public String getSchoolCode() {
+        return schoolCode;
+    }
+
+    public void setSchoolCode(String schoolCode) {
+        this.schoolCode = schoolCode;
+    }
+
+    public String getDeviceCode() {
+        return deviceCode;
+    }
+
+    public void setDeviceCode(String deviceCode) {
+        this.deviceCode = deviceCode;
+    }
+
+    public String getFileName() {
+        return fileName;
+    }
+
+    public void setFileName(String fileName) {
+        this.fileName = fileName;
+    }
+
+    public String getMd5() {
+        return md5;
+    }
+
+    public void setMd5(String md5) {
+        this.md5 = md5;
+    }
+
+    public String getPath() {
+        return path;
+    }
+
+    public void setPath(String path) {
+        this.path = path;
+    }
+
+    public Long getUploadTime() {
+        return uploadTime;
+    }
+
+    public void setUploadTime(Long uploadTime) {
+        this.uploadTime = uploadTime;
+    }
+
+    public String getPathUrl() {
+        return pathUrl;
+    }
+
+    public void setPathUrl(String pathUrl) {
+        this.pathUrl = pathUrl;
+    }
+
+    @Override
+    public String toString() {
+        return "ScanLog{" +
+                "schoolCode=" + schoolCode +
+                ", deviceCode=" + deviceCode +
+                ", fileName=" + fileName +
+                ", md5=" + md5 +
+                ", path=" + path +
+                ", uploadTime=" + uploadTime +
+                "}";
+    }
+}

+ 17 - 0
teachcloud-mark/src/main/java/com/qmth/teachcloud/mark/mapper/ScanLogMapper.java

@@ -0,0 +1,17 @@
+package com.qmth.teachcloud.mark.mapper;
+
+import com.github.jeffreyning.mybatisplus.base.MppBaseMapper;
+import com.qmth.teachcloud.mark.entity.ScanLog;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * <p>
+ *  Mapper 接口
+ * </p>
+ *
+ * @author xf
+ * @since 2023-12-08
+ */
+public interface ScanLogMapper extends MppBaseMapper<ScanLog> {
+
+}

+ 2 - 0
teachcloud-mark/src/main/java/com/qmth/teachcloud/mark/service/MarkFileService.java

@@ -21,5 +21,7 @@ public interface MarkFileService {
 
 	String uploadPackage(InputStream in, String md5, Long examId, String coursePaperId, String packageCode,
 			Integer packageNo);
+	String getScanLogUri(String schoolCode, String deviceCode, String fileName);
 
+	String uploadScanLog(InputStream in, String md5, String schoolCode, String deviceCode, String fileName);
 }

+ 24 - 0
teachcloud-mark/src/main/java/com/qmth/teachcloud/mark/service/ScanLogService.java

@@ -0,0 +1,24 @@
+package com.qmth.teachcloud.mark.service;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.qmth.teachcloud.mark.entity.ScanLog;
+import com.baomidou.mybatisplus.extension.service.IService;
+import org.springframework.web.multipart.MultipartFile;
+
+import javax.validation.constraints.Max;
+import javax.validation.constraints.Min;
+
+/**
+ * <p>
+ * 服务类
+ * </p>
+ *
+ * @author xf
+ * @since 2023-12-08
+ */
+public interface ScanLogService extends IService<ScanLog> {
+
+    boolean uploadLogFile(String schoolCode, String deviceCode, MultipartFile file, String md5);
+
+    IPage<ScanLog> listScanLog(String schoolCode, Integer pageNumber, Integer pageSize);
+}

+ 25 - 1
teachcloud-mark/src/main/java/com/qmth/teachcloud/mark/service/impl/MarkFileServiceImpl.java

@@ -95,7 +95,7 @@ public class MarkFileServiceImpl implements MarkFileService {
                                 Integer packageNo) {
         String path = getPackageUri(examId, coursePaperId, packageCode, packageNo);
         try {
-            return fileStoreUtils.uploadFile(in, md5, UploadFileEnum.SHEET, path);
+            return fileStoreUtils.uploadFile(in, md5, UploadFileEnum.PACKAGE, path);
         } catch (RuntimeException e) {
             throw e;
         } catch (Exception e) {
@@ -114,4 +114,28 @@ public class MarkFileServiceImpl implements MarkFileService {
     public String getPackageUri(Long examId, String coursePaperId, String packageCode, Integer packageNo) {
         return UploadFileEnum.PACKAGE.getPath(UploadFileEnum.PACKAGE.getTitle(), examId, coursePaperId, packageCode, packageNo, FormatType.JPG.name().toLowerCase());
     }
+
+    @Override
+    public String getScanLogUri(String schoolCode, String deviceCode, String fileName) {
+        return UploadFileEnum.LOG.getPath(UploadFileEnum.LOG.getTitle(), schoolCode, deviceCode, fileName);
+    }
+
+    @Override
+    public String uploadScanLog(InputStream in, String md5, String schoolCode, String deviceCode, String fileName) {
+        String path = getScanLogUri(schoolCode, deviceCode, fileName);
+        try {
+            return fileStoreUtils.uploadFile(in, md5, UploadFileEnum.LOG, path);
+        } catch (RuntimeException e) {
+            throw e;
+        } catch (Exception e) {
+            throw new StatusException("文件上传出错:" + path, e);
+        } finally {
+            if (in != null) {
+                try {
+                    in.close();
+                } catch (IOException e) {
+                }
+            }
+        }
+    }
 }

+ 69 - 0
teachcloud-mark/src/main/java/com/qmth/teachcloud/mark/service/impl/ScanLogServiceImpl.java

@@ -0,0 +1,69 @@
+package com.qmth.teachcloud.mark.service.impl;
+
+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.github.jeffreyning.mybatisplus.service.MppServiceImpl;
+import com.qmth.teachcloud.common.service.FileUploadService;
+import com.qmth.teachcloud.common.util.FileUtil;
+import com.qmth.teachcloud.mark.entity.ScanLog;
+import com.qmth.teachcloud.mark.mapper.ScanLogMapper;
+import com.qmth.teachcloud.mark.service.MarkFileService;
+import com.qmth.teachcloud.mark.service.ScanLogService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+import org.springframework.web.multipart.MultipartFile;
+
+import javax.annotation.Resource;
+import java.io.IOException;
+
+/**
+ * <p>
+ * 服务实现类
+ * </p>
+ *
+ * @author xf
+ * @since 2023-12-08
+ */
+@Service
+public class ScanLogServiceImpl extends MppServiceImpl<ScanLogMapper, ScanLog> implements ScanLogService {
+
+    @Resource
+    private MarkFileService markFileService;
+    @Resource
+    private FileUploadService fileUploadService;
+
+    @Override
+    public boolean uploadLogFile(String schoolCode, String deviceCode, MultipartFile file, String md5) {
+        try {
+            String fileName = file.getOriginalFilename();
+            ScanLog scanLog = this.selectByMultiId(new ScanLog(schoolCode, deviceCode, fileName));
+            if (scanLog == null) {
+                scanLog = new ScanLog();
+                scanLog.setSchoolCode(schoolCode);
+                scanLog.setDeviceCode(deviceCode);
+                scanLog.setFileName(fileName);
+            }
+            scanLog.setMd5(FileUtil.md5File(file.getInputStream()));
+            String path = markFileService.uploadScanLog(file.getInputStream(), md5, schoolCode, deviceCode, fileName);
+            scanLog.setPath(path);
+            scanLog.setUploadTime(System.currentTimeMillis());
+            return this.saveOrUpdateByMultiId(scanLog);
+        } catch (IOException e) {
+            return false;
+        }
+    }
+
+    @Override
+    public IPage<ScanLog> listScanLog(String schoolCode, Integer pageNumber, Integer pageSize) {
+        Page<ScanLog> page = new Page<>(pageNumber, pageSize);
+        QueryWrapper<ScanLog> queryWrapper = new QueryWrapper<>();
+        queryWrapper.lambda().eq(ScanLog::getSchoolCode, schoolCode).orderByDesc(ScanLog::getUploadTime);
+        Page<ScanLog> scanLogPage = this.page(page, queryWrapper);
+        for (ScanLog record : scanLogPage.getRecords()) {
+            record.setPathUrl(fileUploadService.filePreview(record.getPath()));
+            record.setPath(null);
+        }
+        return scanLogPage;
+    }
+}

+ 1 - 1
teachcloud-mark/src/main/java/com/qmth/teachcloud/mark/utils/FileStoreUtils.java

@@ -293,7 +293,7 @@ public class FileStoreUtils {
                 this.localUpload(fileName, inputStream, md5, uploadFileEnum.getFssType());
                 type = SystemConstant.LOCAL;
             }
-            return JSON.toJSONString(new FilePathVo(fileName, uploadFileEnum, type));
+            return JSON.toJSONString(new FilePathVo(fileName, uploadFileEnum, type, md5));
         } catch (Exception e) {
             throw ExceptionResultEnum.ERROR.exception("文件上传失败:" + e.getMessage());
         }

+ 15 - 0
teachcloud-mark/src/main/resources/mapper/ScanLogMapper.xml

@@ -0,0 +1,15 @@
+<?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.qmth.teachcloud.mark.mapper.ScanLogMapper">
+
+    <!-- 通用查询映射结果 -->
+    <resultMap id="BaseResultMap" type="com.qmth.teachcloud.mark.entity.ScanLog">
+        <id column="school_code" property="schoolCode" />
+        <id column="device_code" property="deviceCode" />
+        <id column="file_name" property="fileName" />
+        <result column="md5" property="md5" />
+        <result column="path" property="path" />
+        <result column="upload_time" property="uploadTime" />
+    </resultMap>
+
+</mapper>

部分文件因为文件数量过多而无法显示