调查问卷导入问题

This commit is contained in:
2025-08-22 16:32:20 +08:00
parent b026e32ad3
commit 90dad7fa18
2 changed files with 16 additions and 6 deletions

View File

@ -182,6 +182,8 @@ public class DwQuestionController extends BaseController
int successNum = dwQuestionService.importData(file, dwInfo);
if (successNum > 0) {
return AjaxResult.success();
}else if (successNum == 0){
return AjaxResult.success("导入数据为0");
}else {
return AjaxResult.error("导入失败,请检查调查问卷内容是否正确");
}

View File

@ -123,15 +123,16 @@ public class DwQuestionServiceImpl implements IDwQuestionService
return -1;
}
List<DwAnswer> answers = new ArrayList<DwAnswer>();
List<String> answerIds = new ArrayList<>();
for (int i = 1; i <= rows; i++) {
//第一个调查问卷问题
Row row = sheet.getRow(i);
Cell idCell = row.getCell(0);
idCell.setCellType(CellType.STRING);
String id = idCell.getStringCellValue();
// if (redisCache.hasKey(id)){
// continue;
// }
if (redisCache.hasKey(id)){
continue;
}
if (dwInfo.getId().intValue() == 1) {
Cell cell15 = row.getCell(15);
DwAnswer answer110 = new DwAnswer();
@ -2023,10 +2024,17 @@ public class DwQuestionServiceImpl implements IDwQuestionService
}else {
return -2;
}
answerIds.add(id);
}
if (answers.size() > 0){
int result = dwAnswerMapper.insertDwAnswerBatch(answers);
if (result > 0){
for(String id : answerIds){
redisCache.setCacheObject(id, true);
}
dwAnswerMapper.insertDwAnswerBatch(answers);
return rows;
}
}
return answers.size();
}catch (Exception ex){
ex.printStackTrace();
return -1;