xiaof 4 лет назад
Родитель
Сommit
257d8ab699

+ 9 - 2
stmms-ms-admin/src/main/java/cn/com/qmth/stmms/ms/admin/api/StudentApi.java

@@ -78,15 +78,22 @@ public class StudentApi {
      * @param student
      */
     @RequestMapping(value = "{domain}", method = RequestMethod.PUT)
-    public void update(@PathVariable Student domain, @RequestBody Student student) {
+    public Student update(@PathVariable Student domain, @RequestBody Student student) {
         Long isExist = paperRepo.countByWorkIdAndExamNumber(domain.getWorkId(), domain.getExamNumber());
         if (isExist > 0) {
             throw new RuntimeException("该考生已上传,无法修改");
         }
+        Student temp = studentRepo.findByWorkIdAndExamNumber(domain.getWorkId(), student.getExamNumber());
+        if(temp != null && domain.getId() != temp.getId()){
+            throw new RuntimeException("该考号已存在");
+        }
         domain.setName(student.getName());
+        domain.setExamNumber(student.getExamNumber());
         domain.setExamRoom(student.getExamRoom());
         domain.setAreaCode(student.getAreaCode());
-        studentRepo.save(domain);
+        domain.setAreaName(student.getAreaName());
+        domain.setSchool(student.getSchool());
+        return studentRepo.save(domain);
     }
 
     /**

+ 1 - 0
stmms-ms-admin/src/main/java/cn/com/qmth/stmms/ms/admin/exporter/UserExporter.java

@@ -71,6 +71,7 @@ public class UserExporter {
                 studentDTO.setAreaCode(String.valueOf(i[3]));
                 studentDTO.setExamRoom(String.valueOf(i[4]));
                 studentDTO.setSourceName(String.valueOf(i[5]));
+                studentDTO.setSchool(String.valueOf(i[6]));
                 list.add(studentDTO);
             });
             String fileName = null;

+ 2 - 2
stmms-ms-admin/src/main/java/cn/com/qmth/stmms/ms/admin/importer/StudentImporter.java

@@ -28,7 +28,7 @@ public class StudentImporter {
     @RequestMapping(method = RequestMethod.POST)
     public List<ExcelError> batchAll(@RequestParam Long workId,
                                      @RequestParam(required = false, defaultValue = "false") boolean isAbsent, @RequestParam MultipartFile file)
-            throws IOException {
+            throws Exception {
         return dataUploadService.uploadStudents(workId, isAbsent, file.getInputStream());
     }
 
@@ -80,7 +80,7 @@ public class StudentImporter {
     @RequestMapping(value = "/relateStudent", method = RequestMethod.POST)
     public List<ExcelError> batchAll(@RequestParam Long workId,
                                      @RequestParam MultipartFile file)
-            throws IOException {
+            throws Exception {
         return dataUploadService.uploadStudentRelate(workId, file.getInputStream());
     }
 }

+ 47 - 2
stmms-ms-admin/src/main/java/cn/com/qmth/stmms/ms/admin/service/DataUploadService.java

@@ -19,6 +19,7 @@ import cn.com.qmth.stmms.ms.core.repository.*;
 import cn.com.qmth.stmms.ms.core.vo.Subject;
 import com.alibaba.fastjson.JSONObject;
 import org.apache.commons.codec.digest.DigestUtils;
+import org.mockito.internal.exceptions.ExceptionIncludingMockitoWarnings;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -229,7 +230,14 @@ public class DataUploadService {
     }
 
     @Transactional
-    public List<ExcelError> uploadStudents(Long workId, final boolean isAbsent, InputStream inputStream) {
+    public List<ExcelError> uploadStudents(Long workId, final boolean isAbsent, InputStream inputStream) throws Exception {
+        //有采集数据,不能导入
+        List<Paper> papers = paperRepo.findByWorkId(workId);
+        if (papers != null && papers.size() > 0) {
+            throw new Exception("已有采集数据,不能导入考生数据");
+        }
+        examQuestionRepo.deleteByWorkId(workId);
+
         ExcelReader excelReader = new ExcelReader(StudentDTO.class);
         List<ExcelError> excelErrors = excelReader.reader(inputStream, new ExcelReaderHandle() {
 
@@ -312,6 +320,10 @@ public class DataUploadService {
                 }
             }
         });
+        String errors = errorsString(excelErrors);
+        if(errors.length() > 0) {
+            throw new Exception(errors);
+        }
         return excelErrors;
     }
 
@@ -439,6 +451,10 @@ public class DataUploadService {
         if (Objects.nonNull(excelErrors) && excelErrors.size() > 0) {
             TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
         }
+        String errors = errorsString(excelErrors);
+        if(errors.length() > 0) {
+            throw new Exception(errors);
+        }
         return excelErrors;
     }
 
@@ -510,7 +526,13 @@ public class DataUploadService {
     }
 
     @Transactional
-    public List<ExcelError> uploadStudentRelate(Long workId, InputStream inputStream) {
+    public List<ExcelError> uploadStudentRelate(Long workId, InputStream inputStream) throws Exception {
+        //已进入分档,不能导入
+        List<MarkSubject> list = markSubjectRepo.findAllByWorkIdAndStageNot(workId, MarkStage.INIT.ordinal());
+        if (list != null && list.size() > 0) {
+            throw new Exception("已有进入分档阶段,不能导入关联考生数据");
+        }
+
         ExcelReader excelReader = new ExcelReader(StudentRelateDTO.class);
         List<ExcelError> excelErrors = excelReader.reader(inputStream, obj -> {
             try {
@@ -551,6 +573,10 @@ public class DataUploadService {
                 return excelError;
             }
         });
+        String errors = errorsString(excelErrors);
+        if(errors.length() > 0) {
+            throw new Exception(errors);
+        }
         return excelErrors;
     }
 
@@ -605,4 +631,23 @@ public class DataUploadService {
         }
         return true;
     }
+
+    /**
+     * 拼接导入异常信息
+     * @param excelErrors
+     * @return
+     */
+    private String errorsString(List<ExcelError> excelErrors) {
+        StringJoiner sj = new StringJoiner(";");
+        if(!excelErrors.isEmpty() && excelErrors.size() > 0){
+            int forint = excelErrors.size() < 10 ? excelErrors.size() : 9 ;
+            for (int i = 0; i < forint; i++) {
+                ExcelError excelError = excelErrors.get(i);
+                StringBuffer sb = new StringBuffer();
+                sb.append("第").append(excelError.getRow()).append("行,").append(excelError.getExcelErrorType());
+                sj.add(sb.toString());
+            }
+        }
+        return sj.toString();
+    }
 }

+ 1 - 1
stmms-ms-commons/src/main/java/cn/com/qmth/stmms/ms/commons/utils/excel/ExcelReader.java

@@ -45,7 +45,7 @@ public class ExcelReader extends ExcelUtils {
 				if(!Objects.equals(columnSetting.getHeader(), obj)){
 					ExcelError error = new ExcelError();
 					error.setRow(1);
-					error.setExcelErrorType("表格格式有误");
+					error.setExcelErrorType("表头格式有误,请检查");
 					excelErrors.add(error);
 					return excelErrors;
 				}

+ 2 - 2
stmms-ms-core/src/main/java/cn/com/qmth/stmms/ms/core/domain/ParamSetting.java

@@ -52,10 +52,10 @@ public class ParamSetting implements Serializable {
         paramSetting.setDeviation(3);
         paramSetting.setAutoCallback(0);
         paramSetting.setMajority(1);
-        paramSetting.setLevelShowAllPaper(1);
+        paramSetting.setLevelShowAllPaper(0);
         paramSetting.setRoundUp(1);
         paramSetting.setChangeStage(0);
-        paramSetting.setScoreShowAllPaper(1);
+        paramSetting.setScoreShowAllPaper(0);
         return paramSetting;
     }
 

+ 2 - 0
stmms-ms-core/src/main/java/cn/com/qmth/stmms/ms/core/repository/MarkSubjectRepo.java

@@ -25,4 +25,6 @@ public interface MarkSubjectRepo extends JpaRepository<MarkSubject,String> {
     List<MarkSubject> findAllByWorkIdAndEnableTrue(Long workId);
 
     List<MarkSubject> findByWorkIdAndTestNotIn(Long workId, List<Integer> ints);
+
+    List<MarkSubject> findAllByWorkIdAndStageNot(Long workId, int ordinal);
 }

+ 1 - 1
stmms-ms-core/src/main/java/cn/com/qmth/stmms/ms/core/repository/StudentRepo.java

@@ -24,7 +24,7 @@ public interface StudentRepo extends JpaRepository<Student, Long>, JpaSpecificat
 
     List<Student> findByWorkIdAndTest(Long workId, String test);
 
-    @Query(value = "select s.exam_number, s.name, s.area_name , s.area_code, s.exam_room, s.source_name from paper p join student s on p.work_id = s.work_id and p.exam_number = s.exam_number and p.area_code = s.area_code where p.work_id = ? and p.subject = ? and p.is_missing = true", nativeQuery = true)
+    @Query(value = "select s.exam_number, s.name, s.area_name , s.area_code, s.exam_room, s.source_name, s.school from paper p join student s on p.work_id = s.work_id and p.exam_number = s.exam_number and p.area_code = s.area_code where p.work_id = ? and p.subject = ? and p.is_missing = true", nativeQuery = true)
     List<Object[]> listMissingBySubject(Long workId, String subject);
 
     void deleteByWorkIdAndTest(Long workId, String test);

+ 2 - 0
stmms-ms-marking/src/main/java/cn/com/qmth/stmms/ms/marking/api/MarkTaskApi.java

@@ -321,6 +321,8 @@ public class MarkTaskApi {
             if (Objects.nonNull(areaCode)) {
                 predicates.add(builder.equal(root.get("paper").get("areaCode"), areaCode));
             }
+            //过滤标准卷
+            predicates.add(builder.equal(root.get("paper").get("isSample"), false));
             return builder.and(predicates.toArray(new Predicate[predicates.size()]));
         };
 

+ 3 - 3
stmms-ms-marking/src/main/java/cn/com/qmth/stmms/ms/marking/api/PaperApi.java

@@ -171,9 +171,9 @@ public class PaperApi {
             if (isManual != null) {
                 predicates.add(builder.equal(root.get("isManual"), isManual));
             }
-//            if (Objects.nonNull(missing)) {
-//                predicates.add(builder.equal(root.get("isMissing"), missing));
-//            }
+            if (missing != missing) {
+                predicates.add(builder.equal(root.get("isMissing"), missing));
+            }
             //考生姓名
             if (Objects.nonNull(studentName)) {
                 predicates.add(builder.equal(root.get("studentName"), studentName));