|
@@ -7,6 +7,7 @@ import com.alibaba.fastjson.JSONObject;
|
|
import com.aliyun.oss.common.utils.BinaryUtil;
|
|
import com.aliyun.oss.common.utils.BinaryUtil;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.qmth.boot.api.exception.ApiException;
|
|
import com.qmth.boot.api.exception.ApiException;
|
|
|
|
+import com.qmth.distributed.print.business.annotation.ExcelDBFieldDesc;
|
|
import com.qmth.distributed.print.business.bean.dto.ExaminationExportDto;
|
|
import com.qmth.distributed.print.business.bean.dto.ExaminationExportDto;
|
|
import com.qmth.distributed.print.business.bean.dto.ExaminationImportDto;
|
|
import com.qmth.distributed.print.business.bean.dto.ExaminationImportDto;
|
|
import com.qmth.distributed.print.business.bean.dto.FieldsDto;
|
|
import com.qmth.distributed.print.business.bean.dto.FieldsDto;
|
|
@@ -411,6 +412,7 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
String cellValue = String.valueOf(ExcelUtil.convert(head.getCell(i)));
|
|
String cellValue = String.valueOf(ExcelUtil.convert(head.getCell(i)));
|
|
for (FieldsDto fieldsDto : fieldsDtoList) {
|
|
for (FieldsDto fieldsDto : fieldsDtoList) {
|
|
if (cellValue.equals(fieldsDto.getName())) {
|
|
if (cellValue.equals(fieldsDto.getName())) {
|
|
|
|
+ // 如果通用规则必填字段和excel表头匹配上了,则为该必选字段设置其在excel中的索引
|
|
fieldsDto.setIndex(i);
|
|
fieldsDto.setIndex(i);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -431,6 +433,7 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
List<FieldsDto> secondaryFieldList = new ArrayList<>(); // 备选字段
|
|
List<FieldsDto> secondaryFieldList = new ArrayList<>(); // 备选字段
|
|
|
|
|
|
ExaminationImportDto examinationImportDto = new ExaminationImportDto();
|
|
ExaminationImportDto examinationImportDto = new ExaminationImportDto();
|
|
|
|
+ Field[] examinationImportDtoFields = examinationImportDto.getClass().getDeclaredFields();
|
|
for (FieldsDto fieldsDto : fieldsDtoList) {
|
|
for (FieldsDto fieldsDto : fieldsDtoList) {
|
|
boolean match = false;
|
|
boolean match = false;
|
|
String name = fieldsDto.getName();
|
|
String name = fieldsDto.getName();
|
|
@@ -447,18 +450,22 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
throw ExceptionResultEnum.ERROR.exception("excel中第[" + (r + 1) + "]行,第[" + (index + 1) + "]列,字段[" + name + "]必填");
|
|
throw ExceptionResultEnum.ERROR.exception("excel中第[" + (r + 1) + "]行,第[" + (index + 1) + "]列,字段[" + name + "]必填");
|
|
}
|
|
}
|
|
|
|
|
|
- for (ExaminationDBFieldsEnum value : ExaminationDBFieldsEnum.values()) {
|
|
|
|
- String dbName = value.getDesc();
|
|
|
|
- String dbCode = value.getCode();
|
|
|
|
- int dbLength = value.getLength();
|
|
|
|
- if (dbName.equals(name)) {
|
|
|
|
|
|
+ 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) {
|
|
if (dbLength > 0) {
|
|
ConvertUtil.verifyLength(cellValue, dbLength, dbName);
|
|
ConvertUtil.verifyLength(cellValue, dbLength, dbName);
|
|
}
|
|
}
|
|
- // 使用反射 -> 根据db枚举类的code字段为对应的dbDto类中的对应属性赋值(因此要求枚举必须被dto类包含)
|
|
|
|
- Field field = examinationImportDto.getClass().getDeclaredField(dbCode);
|
|
|
|
- field.setAccessible(true);
|
|
|
|
- field.set(examinationImportDto, cellValue);
|
|
|
|
|
|
+ examinationImportDtoField.setAccessible(true);
|
|
|
|
+ examinationImportDtoField.set(examinationImportDto,cellValue);
|
|
match = true;
|
|
match = true;
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
@@ -492,6 +499,7 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
examinationImportDto.setPrintPlanName(printPlanName);
|
|
examinationImportDto.setPrintPlanName(printPlanName);
|
|
examinationImportDtoList.add(examinationImportDto);
|
|
examinationImportDtoList.add(examinationImportDto);
|
|
}
|
|
}
|
|
|
|
+
|
|
System.out.println(JSON.toJSONString(examinationImportDtoList));
|
|
System.out.println(JSON.toJSONString(examinationImportDtoList));
|
|
|
|
|
|
// 校验课程代码和试卷编号在印刷计划下是1对1的关系
|
|
// 校验课程代码和试卷编号在印刷计划下是1对1的关系
|