|
@@ -3,6 +3,7 @@ package cn.com.qmth.mps.service.impl;
|
|
|
import java.io.IOException;
|
|
|
import java.io.InputStream;
|
|
|
import java.util.ArrayList;
|
|
|
+import java.util.Arrays;
|
|
|
import java.util.Comparator;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
@@ -57,6 +58,9 @@ import cn.com.qmth.mps.vo.paper.StructDomain;
|
|
|
|
|
|
@Service
|
|
|
public class PaperServiceImpl extends ServiceImpl<PaperDao, PaperEntity> implements PaperService {
|
|
|
+ private static final String[] SUBJECT_EXCEL_HEADER = new String[] {"科目代码", "科目名称"};
|
|
|
+
|
|
|
+ private static final String[] SUBJECT_STRUCT_EXCEL_HEADER = new String[] {"科目代码", "科目名称", "大题名称", "大题号", "小题号", "小题满分","间隔分"};
|
|
|
|
|
|
@Autowired
|
|
|
private ExamService examService;
|
|
@@ -84,7 +88,11 @@ public class PaperServiceImpl extends ServiceImpl<PaperDao, PaperEntity> impleme
|
|
|
InputStream inputStream = null;
|
|
|
try {
|
|
|
inputStream = file.getInputStream();
|
|
|
- List<DataMap> lineList = ExcelReader.create(ExcelType.XLSX, inputStream, 0).getDataMapList();
|
|
|
+ ExcelReader reader=ExcelReader.create(ExcelType.XLSX, inputStream, 0);
|
|
|
+ List<DataMap> lineList = reader.getDataMapList();
|
|
|
+ if(!Arrays.equals(SUBJECT_EXCEL_HEADER,reader.getColumnNames())) {
|
|
|
+ throw new StatusException("Excel表头错误");
|
|
|
+ }
|
|
|
if (CollectionUtils.isEmpty(lineList)) {
|
|
|
throw new StatusException("Excel无内容");
|
|
|
}
|
|
@@ -319,7 +327,11 @@ public class PaperServiceImpl extends ServiceImpl<PaperDao, PaperEntity> impleme
|
|
|
InputStream inputStream = null;
|
|
|
try {
|
|
|
inputStream = file.getInputStream();
|
|
|
- List<DataMap> lineList = ExcelReader.create(ExcelType.XLSX, inputStream, 0).getDataMapList();
|
|
|
+ ExcelReader reader=ExcelReader.create(ExcelType.XLSX, inputStream, 0);
|
|
|
+ List<DataMap> lineList = reader.getDataMapList();
|
|
|
+ if(!Arrays.equals(SUBJECT_STRUCT_EXCEL_HEADER,reader.getColumnNames())) {
|
|
|
+ throw new StatusException("Excel表头错误");
|
|
|
+ }
|
|
|
if (CollectionUtils.isEmpty(lineList)) {
|
|
|
throw new StatusException("Excel无内容");
|
|
|
}
|