mirror of
https://gitee.com/wkeyuan/DWSurvey.git
synced 2024-12-02 12:08:44 +08:00
Optimization and export
This commit is contained in:
parent
a2fe50f6ba
commit
27870689f0
@ -143,6 +143,22 @@ public class SurveyAnswerManagerImpl extends
|
||||
String quId = question.getId();
|
||||
// 查询每一题的答案,如果是主观题,则判断是否答对
|
||||
QuType quType = question.getQuType();
|
||||
|
||||
//重置导出
|
||||
question.setAnAnswer(new AnAnswer());
|
||||
question.setAnCheckboxs(new ArrayList<AnCheckbox>());
|
||||
question.setAnDFillblanks(new ArrayList<AnDFillblank>());
|
||||
question.setAnEnumqus(new ArrayList<AnEnumqu>());
|
||||
question.setAnFillblank(new AnFillblank());
|
||||
question.setAnRadio(new AnRadio());
|
||||
question.setAnYesno(new AnYesno());
|
||||
question.setAnScores(new ArrayList<AnScore>());
|
||||
question.setAnChenRadios(new ArrayList<AnChenRadio>());
|
||||
question.setAnChenCheckboxs(new ArrayList<AnChenCheckbox>());
|
||||
question.setAnChenFbks(new ArrayList<AnChenFbk>());
|
||||
question.setAnCompChenRadios(new ArrayList<AnCompChenRadio>());
|
||||
question.setAnChenScores(new ArrayList<AnChenScore>());
|
||||
|
||||
if (quType == QuType.YESNO) {// 是非题答案
|
||||
AnYesno anYesno = anYesnoManager.findAnswer(surveyAnswerId, quId);
|
||||
if (anYesno != null) {
|
||||
@ -281,36 +297,24 @@ public class SurveyAnswerManagerImpl extends
|
||||
String fileName = surveyId + "_exportSurvey.xls";
|
||||
|
||||
XLSExportUtil exportUtil = new XLSExportUtil(fileName, savePath);
|
||||
|
||||
List<PropertyFilter> filters = new ArrayList<PropertyFilter>();
|
||||
filters.add(new PropertyFilter("EQS_surveyId", surveyId));
|
||||
Criterion cri1 = Restrictions.eq("surveyId",surveyId);
|
||||
Page<SurveyAnswer> page = new Page<SurveyAnswer>();
|
||||
page.setPageSize(100);
|
||||
page.setPageSize(5000);
|
||||
try {
|
||||
|
||||
page = findPage(page, filters);
|
||||
page = findPage(page,cri1);
|
||||
int totalPage = page.getTotalPage();
|
||||
List<SurveyAnswer> answers = page.getResult();
|
||||
|
||||
// 得到题列表
|
||||
List<Question> questions = questionManager.findDetails(surveyId,
|
||||
"2");
|
||||
List<Question> questions = questionManager.findDetails(surveyId,"2");
|
||||
exportXLSTitle(exportUtil, questions);
|
||||
|
||||
for (int i = 1; i <= totalPage; i++) {
|
||||
for (int j = 0; j < answers.size(); j++) {
|
||||
int answerListSize = answers.size();
|
||||
for (int j = 0; j < answerListSize; j++) {
|
||||
SurveyAnswer surveyAnswer = answers.get(j);
|
||||
String surveyAnswerId = surveyAnswer.getId();
|
||||
exportUtil.createRow((j + 1) + ((i - 1) * 100));
|
||||
exportUtil.createRow(j+1);
|
||||
exportXLSRow(exportUtil, surveyAnswerId, questions, surveyAnswer);
|
||||
System.out.println(j+1+"/"+answerListSize);
|
||||
}
|
||||
page.setPageNo(i);
|
||||
page = findPage(page, filters);
|
||||
answers = page.getResult();
|
||||
}
|
||||
|
||||
exportUtil.exportXLS();
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@ -319,13 +323,9 @@ public class SurveyAnswerManagerImpl extends
|
||||
|
||||
private void exportXLSRow(XLSExportUtil exportUtil,String surveyAnswerId, List<Question> questions,SurveyAnswer surveyAnswer) {
|
||||
int cellIndex = 0;
|
||||
|
||||
for (Question question : questions) {
|
||||
// 遍历每一题
|
||||
getquestionAnswer(surveyAnswerId, question);
|
||||
// exportUtil.setCell(index, value);
|
||||
QuType quType = question.getQuType();
|
||||
|
||||
String quName = question.getQuName();
|
||||
String titleName = quType.getCnName();
|
||||
if (quType == QuType.YESNO) {// 是非题
|
||||
@ -350,6 +350,7 @@ public class SurveyAnswerManagerImpl extends
|
||||
}
|
||||
}
|
||||
answerOptionName=HtmlUtil.removeTagFromText(answerOptionName);
|
||||
answerOptionName = answerOptionName.replace(" "," ");
|
||||
exportUtil.setCell(cellIndex++, answerOptionName);
|
||||
} else if (quType == QuType.CHECKBOX) {// 多选题
|
||||
List<AnCheckbox> anCheckboxs=question.getAnCheckboxs();
|
||||
@ -366,17 +367,15 @@ public class SurveyAnswerManagerImpl extends
|
||||
}
|
||||
}
|
||||
answerOptionName=HtmlUtil.removeTagFromText(answerOptionName);
|
||||
answerOptionName = answerOptionName.replace(" "," ");
|
||||
exportUtil.setCell(cellIndex++, answerOptionName);
|
||||
}
|
||||
} else if (quType == QuType.FILLBLANK) {// 填空题
|
||||
AnFillblank anFillblank=question.getAnFillblank();
|
||||
|
||||
exportUtil.setCell(cellIndex++, anFillblank.getAnswer());
|
||||
} else if (quType == QuType.ANSWER) {// 多行填空题
|
||||
AnAnswer anAnswer=question.getAnAnswer();
|
||||
|
||||
exportUtil.setCell(cellIndex++, anAnswer.getAnswer());
|
||||
// exportUtil.setCell(cellIndex++, titleName);
|
||||
} else if (quType == QuType.COMPRADIO) {// 复合单选题
|
||||
AnRadio anRadio=question.getAnRadio();
|
||||
String quItemId = anRadio.getQuItemId();
|
||||
@ -393,6 +392,7 @@ public class SurveyAnswerManagerImpl extends
|
||||
}
|
||||
answerOptionName=HtmlUtil.removeTagFromText(answerOptionName);
|
||||
answerOtherText=HtmlUtil.removeTagFromText(answerOtherText);
|
||||
answerOptionName = answerOptionName.replace(" "," ");
|
||||
exportUtil.setCell(cellIndex++, answerOptionName);
|
||||
exportUtil.setCell(cellIndex++, answerOtherText);
|
||||
} else if (quType == QuType.COMPCHECKBOX) {// 复合多选题
|
||||
@ -411,15 +411,14 @@ public class SurveyAnswerManagerImpl extends
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
answerOptionName=HtmlUtil.removeTagFromText(answerOptionName);
|
||||
answerOptionName = answerOptionName.replace(" "," ");
|
||||
exportUtil.setCell(cellIndex++, answerOptionName);
|
||||
if(1==quCheckbox.getIsNote()){
|
||||
answerOtherText=HtmlUtil.removeTagFromText(answerOtherText);
|
||||
exportUtil.setCell(cellIndex++, answerOtherText);
|
||||
}
|
||||
}
|
||||
|
||||
} else if (quType == QuType.ENUMQU) {// 枚举题
|
||||
List<AnEnumqu> anEnumqus=question.getAnEnumqus();
|
||||
int enumNum = question.getParamInt01();
|
||||
@ -445,6 +444,7 @@ public class SurveyAnswerManagerImpl extends
|
||||
break;
|
||||
}
|
||||
}
|
||||
answerOptionName = answerOptionName.replace(" "," ");
|
||||
exportUtil.setCell(cellIndex++, answerOptionName);
|
||||
}
|
||||
} else if (quType == QuType.SCORE) {// 评分题
|
||||
@ -484,11 +484,11 @@ public class SurveyAnswerManagerImpl extends
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
answerColOptionName=HtmlUtil.removeTagFromText(answerColOptionName);
|
||||
answerColOptionName = answerColOptionName.replace(" "," ");
|
||||
exportUtil.setCell(cellIndex++, answerColOptionName);
|
||||
}
|
||||
} else if (quType == QuType.CHENCHECKBOX) {// 矩阵多选题
|
||||
} else if (quType == QuType.CHENCHECKBOX) {
|
||||
List<QuChenRow> quChenRows = question.getRows();
|
||||
List<QuChenColumn> quChenColumns = question.getColumns();
|
||||
List<AnChenCheckbox> anChenCheckboxs = question.getAnChenCheckboxs();
|
||||
@ -506,10 +506,11 @@ public class SurveyAnswerManagerImpl extends
|
||||
}
|
||||
}
|
||||
answerOptionName=HtmlUtil.removeTagFromText(answerOptionName);
|
||||
answerOptionName = answerOptionName.replace(" "," ");
|
||||
exportUtil.setCell(cellIndex++, answerOptionName);
|
||||
}
|
||||
}
|
||||
} else if (quType == QuType.COMPCHENRADIO) {// 复合矩阵单选题
|
||||
} else if (quType == QuType.COMPCHENRADIO) {
|
||||
List<QuChenRow> quChenRows = question.getRows();
|
||||
List<QuChenColumn> quChenColumns = question.getColumns();
|
||||
List<QuChenOption> quChenOptions = question.getOptions();
|
||||
@ -539,6 +540,7 @@ public class SurveyAnswerManagerImpl extends
|
||||
}
|
||||
}
|
||||
answerOptionName=HtmlUtil.removeTagFromText(answerOptionName);
|
||||
answerOptionName = answerOptionName.replace(" "," ");
|
||||
exportUtil.setCell(cellIndex++, answerOptionName);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user