调查问卷导入问题
This commit is contained in:
@ -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("导入失败,请检查调查问卷内容是否正确");
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
redisCache.setCacheObject(id, true);
|
||||
answerIds.add(id);
|
||||
}
|
||||
dwAnswerMapper.insertDwAnswerBatch(answers);
|
||||
return rows;
|
||||
if (answers.size() > 0){
|
||||
int result = dwAnswerMapper.insertDwAnswerBatch(answers);
|
||||
if (result > 0){
|
||||
for(String id : answerIds){
|
||||
redisCache.setCacheObject(id, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
return answers.size();
|
||||
}catch (Exception ex){
|
||||
ex.printStackTrace();
|
||||
return -1;
|
||||
|
Reference in New Issue
Block a user