调查问卷导入问题
This commit is contained in:
@ -182,6 +182,8 @@ public class DwQuestionController extends BaseController
|
|||||||
int successNum = dwQuestionService.importData(file, dwInfo);
|
int successNum = dwQuestionService.importData(file, dwInfo);
|
||||||
if (successNum > 0) {
|
if (successNum > 0) {
|
||||||
return AjaxResult.success();
|
return AjaxResult.success();
|
||||||
|
}else if (successNum == 0){
|
||||||
|
return AjaxResult.success("导入数据为0");
|
||||||
}else {
|
}else {
|
||||||
return AjaxResult.error("导入失败,请检查调查问卷内容是否正确");
|
return AjaxResult.error("导入失败,请检查调查问卷内容是否正确");
|
||||||
}
|
}
|
||||||
|
@ -123,15 +123,16 @@ public class DwQuestionServiceImpl implements IDwQuestionService
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
List<DwAnswer> answers = new ArrayList<DwAnswer>();
|
List<DwAnswer> answers = new ArrayList<DwAnswer>();
|
||||||
|
List<String> answerIds = new ArrayList<>();
|
||||||
for (int i = 1; i <= rows; i++) {
|
for (int i = 1; i <= rows; i++) {
|
||||||
//第一个调查问卷问题
|
//第一个调查问卷问题
|
||||||
Row row = sheet.getRow(i);
|
Row row = sheet.getRow(i);
|
||||||
Cell idCell = row.getCell(0);
|
Cell idCell = row.getCell(0);
|
||||||
idCell.setCellType(CellType.STRING);
|
idCell.setCellType(CellType.STRING);
|
||||||
String id = idCell.getStringCellValue();
|
String id = idCell.getStringCellValue();
|
||||||
// if (redisCache.hasKey(id)){
|
if (redisCache.hasKey(id)){
|
||||||
// continue;
|
continue;
|
||||||
// }
|
}
|
||||||
if (dwInfo.getId().intValue() == 1) {
|
if (dwInfo.getId().intValue() == 1) {
|
||||||
Cell cell15 = row.getCell(15);
|
Cell cell15 = row.getCell(15);
|
||||||
DwAnswer answer110 = new DwAnswer();
|
DwAnswer answer110 = new DwAnswer();
|
||||||
@ -2023,10 +2024,17 @@ public class DwQuestionServiceImpl implements IDwQuestionService
|
|||||||
}else {
|
}else {
|
||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
redisCache.setCacheObject(id, true);
|
answerIds.add(id);
|
||||||
}
|
}
|
||||||
dwAnswerMapper.insertDwAnswerBatch(answers);
|
if (answers.size() > 0){
|
||||||
return rows;
|
int result = dwAnswerMapper.insertDwAnswerBatch(answers);
|
||||||
|
if (result > 0){
|
||||||
|
for(String id : answerIds){
|
||||||
|
redisCache.setCacheObject(id, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return answers.size();
|
||||||
}catch (Exception ex){
|
}catch (Exception ex){
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
return -1;
|
return -1;
|
||||||
|
Reference in New Issue
Block a user