Bläddra i källkod

加入期末成绩模版下载

wangliang 1 år sedan
förälder
incheckning
4daf36266d

+ 9 - 1
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/TCScoreNormalServiceImpl.java

@@ -24,6 +24,8 @@ import java.io.IOException;
 import java.net.URLEncoder;
 import java.util.List;
 import java.util.Map;
+import java.util.Objects;
+import java.util.Random;
 
 /**
  * <p>
@@ -122,7 +124,13 @@ public class TCScoreNormalServiceImpl extends ServiceImpl<TCScoreNormalMapper, T
         XSSFRow rowExample = sheet.createRow(2);
         for (int i = 0; i < excelFieldList.size(); i++) {
             XSSFCell cell = rowExample.createCell(i);
-            cell.setCellValue(excelFieldList.get(i).getValue());
+            if (Objects.equals("score", excelFieldList.get(i).getCode())) {
+                cell.setCellValue(new Random().nextInt(100) + 1);
+            } else if (excelFieldList.get(i).getCode().startsWith("key")) {
+                cell.setCellValue(new Random().nextInt(10) + 1);
+            } else {
+                cell.setCellValue(excelFieldList.get(i).getValue());
+            }
             cell.setCellStyle(exampleStyle);
         }
 

+ 18 - 2
distributed-print/src/main/java/com/qmth/distributed/print/api/TCScoreEndExamController.java

@@ -1,7 +1,9 @@
 package com.qmth.distributed.print.api;
 
 import com.qmth.boot.api.constant.ApiConstant;
+import com.qmth.distributed.print.business.bean.excel.ExcelField;
 import com.qmth.distributed.print.business.bean.result.EditResult;
+import com.qmth.distributed.print.business.service.TCScoreNormalService;
 import com.qmth.teachcloud.common.annotation.OperationLogDetail;
 import com.qmth.teachcloud.common.contant.SystemConstant;
 import com.qmth.teachcloud.common.enums.log.CustomizedOperationTypeEnum;
@@ -10,9 +12,12 @@ import io.swagger.annotations.*;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
 
+import javax.annotation.Resource;
 import javax.validation.constraints.Max;
 import javax.validation.constraints.Min;
 import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
 
 /**
  * <p>
@@ -27,6 +32,9 @@ import java.io.IOException;
 @RequestMapping(ApiConstant.DEFAULT_URI_PREFIX + SystemConstant.PREFIX_URL_COURSE_DEGREE)
 public class TCScoreEndExamController {
 
+    @Resource
+    TCScoreNormalService tcScoreNormalService;
+
     @ApiOperation(value = "导入期末成绩-模板下载")
     @RequestMapping(value = "/score/end_exam/template_download", method = RequestMethod.POST)
     @OperationLogDetail(customizedOperationType = CustomizedOperationTypeEnum.EXPORT)
@@ -35,8 +43,16 @@ public class TCScoreEndExamController {
                                         @ApiParam(value = "科目编码", required = true) @RequestParam String courseCode,
                                         @ApiParam(value = "试卷编号", required = true) @RequestParam String paperNumber,
                                         @ApiParam(value = "试卷类型", required = true) @RequestParam String paperType) throws IOException {
-//        Long schoolId = Long.valueOf(ServletUtil.getRequestHeaderSchoolId().toString());
-//        examDetailService.downLoadExaminationTemplate(schoolId, ServletUtil.getResponse());
+        List<ExcelField> excelFieldList = new ArrayList<>();
+        excelFieldList.add(new ExcelField("examNumber", "学号", true));
+        excelFieldList.add(new ExcelField("name", "姓名", true));
+        excelFieldList.add(new ExcelField("score", "成绩", true));
+        excelFieldList.add(new ExcelField("key1", "1-1", true));
+        excelFieldList.add(new ExcelField("key2", "1-2", false));
+        tcScoreNormalService.downLoadExaminationTemplate("1、所有字段均为必填字段;\n" +
+                "2、期末成绩按总分,和小题分录入,题号按大题号-小题号方式录入,如下,1-1表示第一大题第一小题,2-1表示第二大题第一小题;\n" +
+                "3、请不要删除此行,也不要删除模板中的任何列;\n" +
+                "4、使用前请先删除样例数据。", "sheet1", "期末成绩导入模版", excelFieldList);
     }
 
     @ApiOperation(value = "导入期末成绩")

+ 0 - 3
distributed-print/src/main/java/com/qmth/distributed/print/api/TCScoreNormalController.java

@@ -39,9 +39,6 @@ public class TCScoreNormalController {
     @Resource
     TCScoreNormalService tcScoreNormalService;
 
-//    @Resource
-//    ExamDetailService examDetailService;
-
     @ApiOperation(value = "成绩管理列表")
     @RequestMapping(value = "/score/list", method = RequestMethod.POST)
     @OperationLogDetail(customizedOperationType = CustomizedOperationTypeEnum.SEARCH)