xiaofei 1 жил өмнө
parent
commit
4922ba1e12

+ 14 - 13
distributed-print-business/src/main/java/com/qmth/distributed/print/business/mapper/ExamDetailMapper.java

@@ -10,6 +10,7 @@ import com.qmth.distributed.print.business.bean.result.SummarizedDataResult;
 import com.qmth.distributed.print.business.entity.ExamDetail;
 import com.qmth.distributed.print.business.entity.ExamDetailCourse;
 import com.qmth.teachcloud.common.bean.dto.DataPermissionRule;
+import io.swagger.models.auth.In;
 import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
@@ -94,19 +95,19 @@ public interface ExamDetailMapper extends BaseMapper<ExamDetail> {
     @SuppressWarnings("MybatisXMapperMethodInspection")
     List<Map> listStudentByExamDetailCourseId(@Param("schoolId") Long schoolId, @Param("examDetailCourseId") Long examDetailCourseId, @Param("ticketNumber") String ticketNumber, @Param("type") String type);
 
-    String selectPaperCount(@Param("schoolId") Long schoolId,
-                             @Param("semesterId") Long semesterId,
-                             @Param("examId") Long examId,
-                             @Param("printPlanId") Long printPlanId,
-                             @Param("status") String status,
-                             @Param("courseCode") String courseCode,
-                             @Param("paperNumber") String paperNumber,
-                             @Param("examPlace") String examPlace,
-                             @Param("examRoom") String examRoom,
-                             @Param("examStartTime") Long examStartTime,
-                             @Param("examEndTime") Long examEndTime,
-                             @Param("printHouseId") Long printHouseId,
-                             @Param("dpr") DataPermissionRule dpr);
+    Integer selectPaperCount(@Param("schoolId") Long schoolId,
+                        @Param("semesterId") Long semesterId,
+                        @Param("examId") Long examId,
+                        @Param("printPlanId") Long printPlanId,
+                        @Param("status") String status,
+                        @Param("courseCode") String courseCode,
+                        @Param("paperNumber") String paperNumber,
+                        @Param("examPlace") String examPlace,
+                        @Param("examRoom") String examRoom,
+                        @Param("examStartTime") Long examStartTime,
+                        @Param("examEndTime") Long examEndTime,
+                        @Param("printHouseId") Long printHouseId,
+                        @Param("dpr") DataPermissionRule dpr);
 
     List<ExamDetailCourse> listSyncPaperNumberByPrintPlanId(@Param("printPlanId") Long printPlanId);
 

+ 2 - 7
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/ExamDetailServiceImpl.java

@@ -183,13 +183,8 @@ public class ExamDetailServiceImpl extends ServiceImpl<ExamDetailMapper, ExamDet
         if (printTaskTotalDto != null) {
             // 试卷总计
             int paperCount = 0;
-            String paperNumberStrs = this.baseMapper.selectPaperCount(schoolId, semesterId, examId, printPlanId, status, courseCode, paperNumber, examPlace, examRoom, examStartTime, examEndTime, printHouseId, dpr);
-            if (StringUtils.isNotBlank(paperNumberStrs)) {
-                String[] paperNumbers = paperNumberStrs.split(",");
-                Set<String> paperNumberSet = new HashSet<>(Arrays.asList(paperNumbers));
-                paperCount = paperNumberSet.size();
-            }
-            printTaskTotalDto.setPaperCount(paperCount);
+            Integer paperNumberCount = this.baseMapper.selectPaperCount(schoolId, semesterId, examId, printPlanId, status, courseCode, paperNumber, examPlace, examRoom, examStartTime, examEndTime, printHouseId, dpr);
+            printTaskTotalDto.setPaperCount(paperNumberCount);
         }
         return printTaskTotalDto;
     }

+ 2 - 2
distributed-print-business/src/main/resources/mapper/ExamDetailMapper.xml

@@ -495,9 +495,9 @@
             and c.ticket_number >= #{ticketNumber}
         </if>
     </select>
-    <select id="selectPaperCount" resultType="java.lang.String">
+    <select id="selectPaperCount" resultType="java.lang.Integer">
         SELECT
-            group_concat(distinct c.paper_number, c.paper_type)
+            count(distinct c.paper_number, c.paper_type)
         FROM
             exam_print_plan a
             JOIN

+ 3 - 2
distributed-print/src/main/java/com/qmth/distributed/print/api/SysController.java

@@ -47,6 +47,7 @@ import javax.annotation.Resource;
 import javax.servlet.http.HttpServletResponse;
 import javax.validation.Valid;
 import java.io.File;
+import java.io.IOException;
 import java.io.InputStream;
 import java.net.URL;
 import java.security.NoSuchAlgorithmException;
@@ -852,13 +853,13 @@ public class SysController {
      */
     @ApiOperation(value = "下载导入模板")
     @RequestMapping(value = "/download_import_template", method = RequestMethod.POST)
-    public void downloadImportTemplate(@RequestParam(value = "type") String type, HttpServletResponse response) {
+    public void downloadImportTemplate(@RequestParam(value = "type") String type, HttpServletResponse response) throws IOException {
         List<String> templateEnums = Stream.of(ImportTemplateEnum.values()).map(m -> m.name()).collect(Collectors.toList());
         if (!templateEnums.contains(type)) {
             throw ExceptionResultEnum.ERROR.exception("不支持的模板类型");
         }
         ImportTemplateEnum importTemplateEnum = ImportTemplateEnum.valueOf(type);
-        InputStream inputStream = this.getClass().getResourceAsStream(File.separator + "temps" + File.separator + importTemplateEnum.getTemplateName());
+        InputStream inputStream = FileUtil.getStream("temps/" + importTemplateEnum.getTemplateName());
         // 导出
         FileUtil.outputFile(response, inputStream, importTemplateEnum.getFileName());
     }

+ 10 - 0
teachcloud-common/src/main/java/com/qmth/teachcloud/common/util/FileUtil.java

@@ -600,4 +600,14 @@ public class FileUtil {
             log.error(SystemConstant.LOG_ERROR, e);
         }
     }
+
+    public static InputStream getStream(String path) {
+        try {
+            ClassLoader classLoader = FileUtil.class.getClassLoader();
+            URL url = classLoader.getResource(path);
+            return url.openStream();
+        } catch (Exception e) {
+            throw new RuntimeException(e);
+        }
+    }
 }