Browse Source

扫描汇总-答题卡扫描、签到表扫描

xiatian 1 year ago
parent
commit
7a6154c483

+ 48 - 11
distributed-print/src/main/java/com/qmth/distributed/print/api/mark/ScanController.java

@@ -1,20 +1,31 @@
 package com.qmth.distributed.print.api.mark;
 
 
+import java.util.concurrent.TimeUnit;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
+
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import com.qmth.boot.api.annotation.Aac;
 import com.qmth.boot.api.constant.ApiConstant;
+import com.qmth.boot.core.enums.Platform;
+import com.qmth.distributed.print.config.SysProperty;
+import com.qmth.teachcloud.common.bean.auth.ExpireTimeBean;
 import com.qmth.teachcloud.common.contant.SystemConstant;
-import com.qmth.teachcloud.common.entity.BasicSemester;
+import com.qmth.teachcloud.common.entity.TBSession;
 import com.qmth.teachcloud.common.service.BasicSemesterService;
-import com.qmth.teachcloud.common.util.Result;
-import com.qmth.teachcloud.common.util.ResultUtil;
-import io.swagger.annotations.*;
-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 com.qmth.teachcloud.common.util.AuthUtil;
+import com.qmth.teachcloud.common.util.RedisUtil;
+import com.qmth.teachcloud.common.util.ServletUtil;
+import com.qmth.teachcloud.mark.bean.sys.ActiveTimeVo;
+import com.qmth.teachcloud.mark.bean.sys.ApiStatusVo;
 
-import javax.annotation.Resource;
-import java.util.Map;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
 
 /**
  * <p>
@@ -31,5 +42,31 @@ public class ScanController {
 
     @Resource
     BasicSemesterService basicSemesterService;
-
+    @Resource
+    private SysProperty sysProperty;
+    @Resource
+    private RedisUtil redisUtil;
+    
+    @Aac(auth = false)
+    @ApiOperation(value = "服务端状态")
+    @RequestMapping("server/status")
+    public ApiStatusVo status(HttpServletRequest request) {
+        ApiStatusVo vo = new ApiStatusVo();
+        vo.setFileUriPrefix(sysProperty.getFileUriPrefix());
+        vo.setVersion(sysProperty.getVersion());
+        vo.setTime(System.currentTimeMillis());
+        return vo;
+    }
+    
+    @ApiOperation(value = "心跳接口")
+    @PostMapping("server/heartbeat")
+    public ActiveTimeVo heartbeat() {
+        Platform platform = ServletUtil.getRequestPlatform();
+        ExpireTimeBean expireTime = AuthUtil.getExpireTime(platform);
+        TBSession ts=(TBSession)ServletUtil.getRequestSession();
+        redisUtil.expire(ts.getId(), expireTime.getExpireSeconds(),TimeUnit.SECONDS);
+        ActiveTimeVo vo = new ActiveTimeVo();
+        vo.setActiveTime(System.currentTimeMillis());
+        return vo;
+    }
 }

+ 38 - 0
distributed-print/src/main/java/com/qmth/distributed/print/api/mark/ScanExamController.java

@@ -0,0 +1,38 @@
+package com.qmth.distributed.print.api.mark;
+
+import javax.annotation.Resource;
+
+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 com.qmth.boot.api.constant.ApiConstant;
+import com.qmth.distributed.print.business.service.BasicExamService;
+import com.qmth.teachcloud.common.contant.SystemConstant;
+import com.qmth.teachcloud.common.entity.BasicExam;
+import com.qmth.teachcloud.common.util.RedisUtil;
+import com.qmth.teachcloud.mark.bean.scanexaminfo.ScanExamInfoVo;
+import com.qmth.teachcloud.mark.service.MarkStudentService;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+
+@Api(tags = "扫描汇总接口")
+@RestController
+@RequestMapping(ApiConstant.DEFAULT_URI_PREFIX + SystemConstant.PREFIX_URL_SCAN+"/exam")
+public class ScanExamController {
+    @Resource
+    private MarkStudentService markStudentService;
+    @Resource
+    private BasicExamService basicExamService;
+    @Resource
+    private RedisUtil redisUtil;
+    
+    @ApiOperation(value = "扫描汇总-答题卡扫描、签到表扫描")
+    @RequestMapping(value = "card/info", method = RequestMethod.POST)
+    public ScanExamInfoVo cardInfo(@RequestParam Long examId) {
+    	BasicExam exam=basicExamService.getById(examId);
+        return markStudentService.getScanExamInfo(exam);
+    }
+}

+ 15 - 2
distributed-print/src/main/java/com/qmth/distributed/print/api/ScanSystemController.java → distributed-print/src/main/java/com/qmth/distributed/print/api/scan/ScanSystemController.java

@@ -1,4 +1,5 @@
-package com.qmth.distributed.print.api;
+package com.qmth.distributed.print.api.scan;
+
 
 import java.util.concurrent.TimeUnit;
 
@@ -16,6 +17,7 @@ import com.qmth.distributed.print.config.SysProperty;
 import com.qmth.teachcloud.common.bean.auth.ExpireTimeBean;
 import com.qmth.teachcloud.common.contant.SystemConstant;
 import com.qmth.teachcloud.common.entity.TBSession;
+import com.qmth.teachcloud.common.service.BasicSemesterService;
 import com.qmth.teachcloud.common.util.AuthUtil;
 import com.qmth.teachcloud.common.util.RedisUtil;
 import com.qmth.teachcloud.common.util.ServletUtil;
@@ -25,10 +27,21 @@ import com.qmth.teachcloud.mark.bean.sys.ApiStatusVo;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 
-@Api(tags = "系统接口(扫描)")
+/**
+ * <p>
+ * 扫描系统相关 前端控制器
+ * </p>
+ *
+ * @author xf
+ * @since 2023-09-22
+ */
+@Api(tags = "扫描-登录、登出、服务器时间")
 @RestController
 @RequestMapping(ApiConstant.DEFAULT_URI_PREFIX + SystemConstant.PREFIX_URL_SCAN)
 public class ScanSystemController {
+
+    @Resource
+    BasicSemesterService basicSemesterService;
     @Resource
     private SysProperty sysProperty;
     @Resource

+ 28 - 0
teachcloud-mark/src/main/java/com/qmth/teachcloud/mark/bean/scanexaminfo/AnswerScan.java

@@ -0,0 +1,28 @@
+package com.qmth.teachcloud.mark.bean.scanexaminfo;
+
+
+public class AnswerScan {
+
+	private int courseCount;
+	private int totalCount;
+	private int scannedCount;
+	public int getTotalCount() {
+		return totalCount;
+	}
+	public void setTotalCount(int totalCount) {
+		this.totalCount = totalCount;
+	}
+	public int getScannedCount() {
+		return scannedCount;
+	}
+	public void setScannedCount(int scannedCount) {
+		this.scannedCount = scannedCount;
+	}
+	public int getCourseCount() {
+		return courseCount;
+	}
+	public void setCourseCount(int courseCount) {
+		this.courseCount = courseCount;
+	}
+	
+}

+ 13 - 0
teachcloud-mark/src/main/java/com/qmth/teachcloud/mark/bean/scanexaminfo/PackageScan.java

@@ -0,0 +1,13 @@
+package com.qmth.teachcloud.mark.bean.scanexaminfo;
+
+
+public class PackageScan {
+	private int scannedCount;
+	public int getScannedCount() {
+		return scannedCount;
+	}
+	public void setScannedCount(int scannedCount) {
+		this.scannedCount = scannedCount;
+	}
+	
+}

+ 56 - 0
teachcloud-mark/src/main/java/com/qmth/teachcloud/mark/bean/scanexaminfo/ScanExamInfoVo.java

@@ -0,0 +1,56 @@
+package com.qmth.teachcloud.mark.bean.scanexaminfo;
+
+public class ScanExamInfoVo {
+
+    private Long id;
+
+
+    private String name;
+
+
+    private AnswerScan answerScan;
+
+    private PackageScan packageScan;
+    
+    
+
+	public ScanExamInfoVo() {
+        answerScan = new AnswerScan();
+        packageScan = new PackageScan();
+	}
+
+	public Long getId() {
+		return id;
+	}
+
+	public void setId(Long id) {
+		this.id = id;
+	}
+
+	public String getName() {
+		return name;
+	}
+
+	public void setName(String name) {
+		this.name = name;
+	}
+
+	public AnswerScan getAnswerScan() {
+		return answerScan;
+	}
+
+	public void setAnswerScan(AnswerScan answerScan) {
+		this.answerScan = answerScan;
+	}
+
+	public PackageScan getPackageScan() {
+		return packageScan;
+	}
+
+	public void setPackageScan(PackageScan packageScan) {
+		this.packageScan = packageScan;
+	}
+
+
+
+}

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

@@ -27,4 +27,6 @@ public interface MarkPaperService extends IService<MarkPaper> {
     Boolean finishPaper(Long examId, List<String> paperNumbers, MarkPaperStatus status);
 
     List<MarkPaper> listQualityMarkPaperByStatus(MarkPaperStatus formal, int uploadCount);
+
+	int getCountByExam(Long id);
 }

+ 7 - 3
teachcloud-mark/src/main/java/com/qmth/teachcloud/mark/service/MarkStudentService.java

@@ -1,10 +1,12 @@
 package com.qmth.teachcloud.mark.service;
 
-import com.qmth.teachcloud.mark.entity.MarkStudent;
+import java.util.List;
+
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.qmth.teachcloud.common.entity.BasicExam;
 import com.qmth.teachcloud.common.enums.mark.SubjectiveStatus;
-
-import java.util.List;
+import com.qmth.teachcloud.mark.bean.scanexaminfo.ScanExamInfoVo;
+import com.qmth.teachcloud.mark.entity.MarkStudent;
 
 /**
  * <p>
@@ -19,4 +21,6 @@ public interface MarkStudentService extends IService<MarkStudent> {
     List<String> listClassByExamIdAndCourseCode(Long examId, String paperNumber);
 
     void updateSubjectiveStatusAndScore(Long studentId, SubjectiveStatus status, int score, String scoreList);
+
+	ScanExamInfoVo getScanExamInfo(BasicExam exam);
 }

+ 3 - 1
teachcloud-mark/src/main/java/com/qmth/teachcloud/mark/service/ScanPackageService.java

@@ -1,7 +1,7 @@
 package com.qmth.teachcloud.mark.service;
 
-import com.qmth.teachcloud.mark.entity.ScanPackage;
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.qmth.teachcloud.mark.entity.ScanPackage;
 
 /**
  * <p>
@@ -13,4 +13,6 @@ import com.baomidou.mybatisplus.extension.service.IService;
  */
 public interface ScanPackageService extends IService<ScanPackage> {
 
+	int getCount(Long examId);
+
 }

+ 7 - 0
teachcloud-mark/src/main/java/com/qmth/teachcloud/mark/service/impl/MarkPaperServiceImpl.java

@@ -82,4 +82,11 @@ public class MarkPaperServiceImpl extends ServiceImpl<MarkPaperMapper, MarkPaper
         return this.baseMapper.listQualityMarkPaperByStatus(status.name(), uploadCount);
     }
 
+	@Override
+	public int getCountByExam(Long examId) {
+		QueryWrapper<MarkPaper> queryWrapper = new QueryWrapper<>();
+        queryWrapper.lambda().eq(MarkPaper::getExamId, examId);
+		return baseMapper.selectCount(queryWrapper);
+	}
+
 }

+ 43 - 9
teachcloud-mark/src/main/java/com/qmth/teachcloud/mark/service/impl/MarkStudentServiceImpl.java

@@ -1,19 +1,27 @@
 package com.qmth.teachcloud.mark.service.impl;
 
+import java.util.ArrayList;
+import java.util.List;
+import java.util.stream.Collectors;
+
+import org.apache.commons.collections4.CollectionUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.qmth.teachcloud.mark.entity.MarkStudent;
+import com.qmth.teachcloud.common.entity.BasicExam;
+import com.qmth.teachcloud.common.enums.ScanStatus;
 import com.qmth.teachcloud.common.enums.mark.SubjectiveStatus;
+import com.qmth.teachcloud.mark.bean.scanexaminfo.ScanExamInfoVo;
+import com.qmth.teachcloud.mark.entity.MarkStudent;
 import com.qmth.teachcloud.mark.mapper.MarkStudentMapper;
+import com.qmth.teachcloud.mark.service.MarkPaperService;
 import com.qmth.teachcloud.mark.service.MarkStudentService;
-import org.apache.commons.collections4.CollectionUtils;
-import org.apache.commons.lang3.StringUtils;
-import org.springframework.stereotype.Service;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.stream.Collectors;
+import com.qmth.teachcloud.mark.service.ScanPackageService;
 
 /**
  * <p>
@@ -25,7 +33,11 @@ import java.util.stream.Collectors;
  */
 @Service
 public class MarkStudentServiceImpl extends ServiceImpl<MarkStudentMapper, MarkStudent> implements MarkStudentService {
-
+	@Autowired
+	private MarkPaperService markPaperService;
+	@Autowired
+	private ScanPackageService scanPackageService;
+	
     @Override
     public List<String> listClassByExamIdAndCourseCode(Long examId, String paperNumber) {
         QueryWrapper<MarkStudent> queryWrapper = new QueryWrapper<>();
@@ -49,4 +61,26 @@ public class MarkStudentServiceImpl extends ServiceImpl<MarkStudentMapper, MarkS
                 .eq(MarkStudent::getId, studentId);
         this.update(updateWrapper);
     }
+
+	@Override
+	public ScanExamInfoVo getScanExamInfo(BasicExam exam) {
+		ScanExamInfoVo vo=new ScanExamInfoVo();
+		vo.setId(exam.getId());
+		vo.setName(exam.getName());
+		vo.getAnswerScan().setCourseCount(markPaperService.getCountByExam(exam.getId()));
+		vo.getAnswerScan().setTotalCount(getCount(exam.getId(), null));
+		vo.getAnswerScan().setScannedCount(getCount(exam.getId(), ScanStatus.SCANNED));
+		vo.getPackageScan().setScannedCount(scanPackageService.getCount(exam.getId()));
+		return vo;
+	}
+	
+	private int getCount(Long examId,ScanStatus status) {
+		QueryWrapper<MarkStudent> wrapper = new QueryWrapper<>();
+        LambdaQueryWrapper<MarkStudent> lw = wrapper.lambda();
+        lw.eq(MarkStudent::getExamId, examId);
+        if(status!=null) {
+        	lw.eq(MarkStudent::getScanStatus, status);
+        }
+        return baseMapper.selectCount(wrapper);
+	}
 }

+ 14 - 3
teachcloud-mark/src/main/java/com/qmth/teachcloud/mark/service/impl/ScanPackageServiceImpl.java

@@ -1,14 +1,17 @@
 package com.qmth.teachcloud.mark.service.impl;
 
+import org.springframework.stereotype.Service;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.qmth.teachcloud.mark.entity.ScanPackage;
 import com.qmth.teachcloud.mark.mapper.ScanPackageMapper;
 import com.qmth.teachcloud.mark.service.ScanPackageService;
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import org.springframework.stereotype.Service;
 
 /**
  * <p>
- *  服务实现类
+ * 服务实现类
  * </p>
  *
  * @author xf
@@ -17,4 +20,12 @@ import org.springframework.stereotype.Service;
 @Service
 public class ScanPackageServiceImpl extends ServiceImpl<ScanPackageMapper, ScanPackage> implements ScanPackageService {
 
+	@Override
+	public int getCount(Long examId) {
+		QueryWrapper<ScanPackage> wrapper = new QueryWrapper<>();
+		LambdaQueryWrapper<ScanPackage> lw = wrapper.lambda();
+		lw.eq(ScanPackage::getExamId, examId);
+		return baseMapper.selectCount(wrapper);
+	}
+
 }