|
@@ -20,6 +20,7 @@ import com.xjrsoft.module.student.entity.BaseStudentSchoolRoll;
|
|
|
import com.xjrsoft.module.veb.util.ImportExcelUtil;
|
|
import com.xjrsoft.module.veb.util.ImportExcelUtil;
|
|
|
import com.xjrsoft.module.xycxedu.dto.AddExamSubjectScoreEnterDto;
|
|
import com.xjrsoft.module.xycxedu.dto.AddExamSubjectScoreEnterDto;
|
|
|
import com.xjrsoft.module.xycxedu.dto.ExamSubjectScoreEnterDto;
|
|
import com.xjrsoft.module.xycxedu.dto.ExamSubjectScoreEnterDto;
|
|
|
|
|
+import com.xjrsoft.module.xycxedu.dto.ExamSubjectScoreEnterImportDto;
|
|
|
import com.xjrsoft.module.xycxedu.dto.ExamSubjectScoreEnterPageDto;
|
|
import com.xjrsoft.module.xycxedu.dto.ExamSubjectScoreEnterPageDto;
|
|
|
import com.xjrsoft.module.xycxedu.entity.ExamSubjectScore;
|
|
import com.xjrsoft.module.xycxedu.entity.ExamSubjectScore;
|
|
|
import com.xjrsoft.module.xycxedu.entity.ExamSubjectScoreEnter;
|
|
import com.xjrsoft.module.xycxedu.entity.ExamSubjectScoreEnter;
|
|
@@ -32,6 +33,7 @@ import com.xjrsoft.module.xycxedu.vo.ExamSubjectScoreEnterVo;
|
|
|
import lombok.AllArgsConstructor;
|
|
import lombok.AllArgsConstructor;
|
|
|
import org.apache.poi.ss.usermodel.Cell;
|
|
import org.apache.poi.ss.usermodel.Cell;
|
|
|
import org.apache.poi.ss.usermodel.CellStyle;
|
|
import org.apache.poi.ss.usermodel.CellStyle;
|
|
|
|
|
+import org.apache.poi.ss.usermodel.FillPatternType;
|
|
|
import org.apache.poi.ss.usermodel.Font;
|
|
import org.apache.poi.ss.usermodel.Font;
|
|
|
import org.apache.poi.ss.usermodel.HorizontalAlignment;
|
|
import org.apache.poi.ss.usermodel.HorizontalAlignment;
|
|
|
import org.apache.poi.ss.usermodel.IndexedColors;
|
|
import org.apache.poi.ss.usermodel.IndexedColors;
|
|
@@ -72,14 +74,14 @@ public class ExamSubjectScoreEnterServiceImpl extends MPJBaseServiceImpl<ExamSub
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public Boolean importData(Long id, MultipartFile file) throws IOException {
|
|
public Boolean importData(Long id, MultipartFile file) throws IOException {
|
|
|
ExamSubjectScoreEnter enter = this.getById(id);
|
|
ExamSubjectScoreEnter enter = this.getById(id);
|
|
|
- List<ExamSubjectScoreEnterImportVo> dataList = EasyExcel.read(file.getInputStream()).headRowNumber(2).head(ExamSubjectScoreEnterImportVo.class).sheet().doReadSync();
|
|
|
|
|
|
|
+ List<ExamSubjectScoreEnterImportDto> dataList = EasyExcel.read(file.getInputStream()).headRowNumber(2).head(ExamSubjectScoreEnterImportDto.class).sheet().doReadSync();
|
|
|
List<BaseCourseSubject> classList = courseSubjectService.list(
|
|
List<BaseCourseSubject> classList = courseSubjectService.list(
|
|
|
new QueryWrapper<BaseCourseSubject>().lambda()
|
|
new QueryWrapper<BaseCourseSubject>().lambda()
|
|
|
.eq(BaseCourseSubject::getDeleteMark, DeleteMark.NODELETE.getCode())
|
|
.eq(BaseCourseSubject::getDeleteMark, DeleteMark.NODELETE.getCode())
|
|
|
);
|
|
);
|
|
|
Map<Long, String> courseSubjectMaps = classList.stream().collect(Collectors.toMap(BaseCourseSubject::getId, BaseCourseSubject::getName));
|
|
Map<Long, String> courseSubjectMaps = classList.stream().collect(Collectors.toMap(BaseCourseSubject::getId, BaseCourseSubject::getName));
|
|
|
|
|
|
|
|
- List<String> credentialNumbers = dataList.stream().filter(x -> StrUtil.isNotEmpty(x.getCredentialNumber())).map(ExamSubjectScoreEnterImportVo::getCredentialNumber).collect(Collectors.toList());
|
|
|
|
|
|
|
+ List<String> credentialNumbers = dataList.stream().filter(x -> StrUtil.isNotEmpty(x.getCredentialNumber())).map(ExamSubjectScoreEnterImportDto::getCredentialNumber).collect(Collectors.toList());
|
|
|
if(credentialNumbers.isEmpty()){
|
|
if(credentialNumbers.isEmpty()){
|
|
|
return true;
|
|
return true;
|
|
|
}
|
|
}
|
|
@@ -99,7 +101,7 @@ public class ExamSubjectScoreEnterServiceImpl extends MPJBaseServiceImpl<ExamSub
|
|
|
Map<Long, ExamSubjectScore> listMap = scoreList.stream().collect(Collectors.toMap(ExamSubjectScore::getUserId, x -> x));
|
|
Map<Long, ExamSubjectScore> listMap = scoreList.stream().collect(Collectors.toMap(ExamSubjectScore::getUserId, x -> x));
|
|
|
|
|
|
|
|
List<ExamSubjectScore> updateList = new ArrayList<>();
|
|
List<ExamSubjectScore> updateList = new ArrayList<>();
|
|
|
- for (ExamSubjectScoreEnterImportVo importVo : dataList) {
|
|
|
|
|
|
|
+ for (ExamSubjectScoreEnterImportDto importVo : dataList) {
|
|
|
Long userId = userMaps.get(importVo.getCredentialNumber());
|
|
Long userId = userMaps.get(importVo.getCredentialNumber());
|
|
|
ExamSubjectScore examSubjectScores = listMap.get(userId);
|
|
ExamSubjectScore examSubjectScores = listMap.get(userId);
|
|
|
examSubjectScores.setCourseSubjectId(enter.getCourseSubjectId());
|
|
examSubjectScores.setCourseSubjectId(enter.getCourseSubjectId());
|
|
@@ -209,9 +211,6 @@ public class ExamSubjectScoreEnterServiceImpl extends MPJBaseServiceImpl<ExamSub
|
|
|
for (ArrayList<String> rowData : dataList) {
|
|
for (ArrayList<String> rowData : dataList) {
|
|
|
Row dataRow = sheet.createRow(dataRowNumber);
|
|
Row dataRow = sheet.createRow(dataRowNumber);
|
|
|
for (int i = 0; i < rowData.size(); i ++){
|
|
for (int i = 0; i < rowData.size(); i ++){
|
|
|
- if(dataRowNumber == 3){
|
|
|
|
|
- sheet.autoSizeColumn(i);
|
|
|
|
|
- }
|
|
|
|
|
String content = rowData.get(i);
|
|
String content = rowData.get(i);
|
|
|
Font font = workbook.createFont();
|
|
Font font = workbook.createFont();
|
|
|
font.setBold(false);// 设置为粗体
|
|
font.setBold(false);// 设置为粗体
|
|
@@ -304,6 +303,7 @@ public class ExamSubjectScoreEnterServiceImpl extends MPJBaseServiceImpl<ExamSub
|
|
|
cellStyle2.setVerticalAlignment(VerticalAlignment.CENTER);
|
|
cellStyle2.setVerticalAlignment(VerticalAlignment.CENTER);
|
|
|
cellStyle2.setAlignment(HorizontalAlignment.CENTER);
|
|
cellStyle2.setAlignment(HorizontalAlignment.CENTER);
|
|
|
cellStyle2.setFillForegroundColor(IndexedColors.YELLOW.getIndex());
|
|
cellStyle2.setFillForegroundColor(IndexedColors.YELLOW.getIndex());
|
|
|
|
|
+ cellStyle2.setFillPattern(FillPatternType.SOLID_FOREGROUND);//设置填充模式
|
|
|
|
|
|
|
|
Row row1 = sheet.createRow(rowNumber);
|
|
Row row1 = sheet.createRow(rowNumber);
|
|
|
List<ImportConfig> importConfigs = ImportExcelUtil.getAllFieldCN(clazz);
|
|
List<ImportConfig> importConfigs = ImportExcelUtil.getAllFieldCN(clazz);
|