|
@@ -609,7 +609,6 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
|
}
|
|
|
}
|
|
|
List<ExaminationImportDto> examinationImportDtoList = new ArrayList<>();
|
|
|
-
|
|
|
for (int r = 1; r < totalRows; r++) {
|
|
|
Row row = sheet.getRow(r);
|
|
|
|
|
@@ -624,43 +623,45 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
|
int index = fieldsDto.getIndex();
|
|
|
String level = fieldsDto.getLevel();
|
|
|
|
|
|
- Cell cell = row.getCell(index);
|
|
|
- if (cell == null) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception("excel中第[" + (r + 1) + "]行,第[" + (index + 1) + "]列,字段[" + name + "]必填");
|
|
|
- }
|
|
|
- String cellValue = String.valueOf(ExcelUtil.convert(cell));
|
|
|
- if (cellValue == null || cellValue.length() < 1 || cellValue.equals("null")) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception("excel中第[" + (r + 1) + "]行,第[" + (index + 1) + "]列,字段[" + name + "]必填");
|
|
|
- }
|
|
|
-
|
|
|
- for (Field examinationImportDtoField : examinationImportDtoFields) {
|
|
|
- ExcelDBFieldDesc excelDBFieldDesc = examinationImportDtoField.getAnnotation(ExcelDBFieldDesc.class);
|
|
|
- if (excelDBFieldDesc == null) {
|
|
|
- // 如果没有注解,说明该数据库必须字段不是从excel中获得的,直接跳过
|
|
|
- continue;
|
|
|
+ if (Objects.nonNull(row)) {
|
|
|
+ Cell cell = row.getCell(index);
|
|
|
+ if (cell == null) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("excel中第[" + (r + 1) + "]行,第[" + (index + 1) + "]列,字段[" + name + "]必填");
|
|
|
+ }
|
|
|
+ String cellValue = String.valueOf(ExcelUtil.convert(cell));
|
|
|
+ if (cellValue == null || cellValue.length() < 1 || cellValue.equals("null")) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("excel中第[" + (r + 1) + "]行,第[" + (index + 1) + "]列,字段[" + name + "]必填");
|
|
|
}
|
|
|
|
|
|
- // 如果数据库字段中文名和必填字段中文名称对应,则通过反射为数据库必选字段赋值
|
|
|
- String dbName = excelDBFieldDesc.name();
|
|
|
- int dbLength = excelDBFieldDesc.length();
|
|
|
- if (dbName.equals(name)) {
|
|
|
- if (dbLength > 0) {
|
|
|
- ConvertUtil.verifyLength(cellValue, dbLength, dbName);
|
|
|
+ for (Field examinationImportDtoField : examinationImportDtoFields) {
|
|
|
+ ExcelDBFieldDesc excelDBFieldDesc = examinationImportDtoField.getAnnotation(ExcelDBFieldDesc.class);
|
|
|
+ if (excelDBFieldDesc == null) {
|
|
|
+ // 如果没有注解,说明该数据库必须字段不是从excel中获得的,直接跳过
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 如果数据库字段中文名和必填字段中文名称对应,则通过反射为数据库必选字段赋值
|
|
|
+ String dbName = excelDBFieldDesc.name();
|
|
|
+ int dbLength = excelDBFieldDesc.length();
|
|
|
+ if (dbName.equals(name)) {
|
|
|
+ if (dbLength > 0) {
|
|
|
+ ConvertUtil.verifyLength(cellValue, dbLength, dbName);
|
|
|
+ }
|
|
|
+ examinationImportDtoField.setAccessible(true);
|
|
|
+ examinationImportDtoField.set(examinationImportDto, cellValue);
|
|
|
+ match = true;
|
|
|
+ break;
|
|
|
}
|
|
|
- examinationImportDtoField.setAccessible(true);
|
|
|
- examinationImportDtoField.set(examinationImportDto, cellValue);
|
|
|
- match = true;
|
|
|
- break;
|
|
|
}
|
|
|
- }
|
|
|
- if (!match || "secondary".equals(level)) {
|
|
|
- // 必选+扩展字段不能匹配到数据库中的字段存放 或者 该字段为扩展字段,则添加到扩展字段中
|
|
|
- FieldsDto secondaryField = new FieldsDto();
|
|
|
- secondaryField.setCode(code);
|
|
|
- secondaryField.setName(name);
|
|
|
- secondaryField.setEnable(true);
|
|
|
- secondaryField.setValue(cellValue);
|
|
|
- secondaryFieldList.add(secondaryField);
|
|
|
+ if (!match || "secondary".equals(level)) {
|
|
|
+ // 必选+扩展字段不能匹配到数据库中的字段存放 或者 该字段为扩展字段,则添加到扩展字段中
|
|
|
+ FieldsDto secondaryField = new FieldsDto();
|
|
|
+ secondaryField.setCode(code);
|
|
|
+ secondaryField.setName(name);
|
|
|
+ secondaryField.setEnable(true);
|
|
|
+ secondaryField.setValue(cellValue);
|
|
|
+ secondaryFieldList.add(secondaryField);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
// 校验试卷编号
|
|
@@ -699,7 +700,7 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
|
examDetailService.deleteExaminationData(printPlanId);
|
|
|
|
|
|
// 卷袋号生成规则
|
|
|
- SerialNumberParams serialNumberParams = new SerialNumberParams("packageCode-", "p", 6);
|
|
|
+ SerialNumberParams serialNumberParams = new SerialNumberParams("packageCode-", "1", 6);
|
|
|
String key = serialNumberParams.getModel() + serialNumberParams.getPrefix();
|
|
|
RedisAtomicLong counter = new RedisAtomicLong(key, Objects.requireNonNull(redisTemplate.getConnectionFactory()));
|
|
|
Long value = counter.get();
|