|
@@ -24,6 +24,8 @@ import java.io.OutputStream;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
+import static com.ym.mec.biz.dal.enums.QuestionnaireActiveTypeEnum.CLOUD_TEACHER_FEEDBACK;
|
|
|
+
|
|
|
@RequestMapping("questionnaireUserResult")
|
|
|
@Api(tags = "问题答案")
|
|
|
@RestController
|
|
@@ -45,57 +47,15 @@ public class QuestionnaireUserResultController extends BaseController {
|
|
|
@RequestMapping("/export")
|
|
|
@PreAuthorize("@pcs.hasPermissions('questionnaireUserResult/export')")
|
|
|
public void questionnaireUserResultExport(QuestionnaireActiveTypeEnum activeType, Integer cooperationId, HttpServletResponse response) throws Exception {
|
|
|
- List<QuestionnaireQuestion> questionList = questionnaireQuestionDao.queryQuestionList(cooperationId);
|
|
|
- questionList.removeAll(Collections.singleton(null));
|
|
|
- if(questionList != null && questionList.size() > 0){
|
|
|
- List<String> column = new ArrayList<>();
|
|
|
- column.add("活动编号");
|
|
|
- column.add("学员编号");
|
|
|
- column.add("学员姓名");
|
|
|
- column.add("手机号");
|
|
|
- List<String> collect = questionList.stream().map(e -> e.getContent()).collect(Collectors.toList());
|
|
|
- column.addAll(collect);
|
|
|
- String[] header = column.toArray(new String[column.size()]);
|
|
|
- Map<String,Object> resultMap = questionnaireUserResultService.questionnaireUserResultExport(activeType.getCode(),cooperationId,questionList);
|
|
|
- List<Map<String,Object>> jsonObjectList = (List<Map<String,Object>>)resultMap.get("jsonObjectList");
|
|
|
- if(jsonObjectList.size() == 0){
|
|
|
- throw new BizException("暂无可导出数据");
|
|
|
- }
|
|
|
- OutputStream outputStream = response.getOutputStream();
|
|
|
- HSSFWorkbook workbook = null;
|
|
|
- try {
|
|
|
- Set<String> body1 = (Set<String>)resultMap.get("body");
|
|
|
- String[] body = body1.toArray(new String[body1.size()]);
|
|
|
- workbook = POIUtil.exportExcel(header, body, jsonObjectList);
|
|
|
- response.setContentType("application/octet-stream");
|
|
|
- response.setHeader("Content-Disposition", "attachment;filename=replacement-" + DateUtil.getDate(new Date()) + ".xls");
|
|
|
- response.flushBuffer();
|
|
|
- outputStream = response.getOutputStream();
|
|
|
- workbook.write(outputStream);
|
|
|
- outputStream.flush();
|
|
|
- workbook.close();
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
- } finally {
|
|
|
- if (outputStream != null) {
|
|
|
- try {
|
|
|
- workbook.close();
|
|
|
- outputStream.close();
|
|
|
- } catch (IOException e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ List<QuestionnaireQuestion> questionList;
|
|
|
+ if(cooperationId != null){
|
|
|
+ questionList = questionnaireQuestionDao.queryQuestionList(cooperationId);
|
|
|
}else {
|
|
|
- throw new BizException("暂无可导出数据");
|
|
|
+ if(activeType != CLOUD_TEACHER_FEEDBACK){
|
|
|
+ throw new BizException("报表中心暂不支持 {} 导出",CLOUD_TEACHER_FEEDBACK.getDesc());
|
|
|
+ }
|
|
|
+ questionList = questionnaireQuestionDao.findByActiveType(activeType.getCode());
|
|
|
}
|
|
|
- }
|
|
|
-
|
|
|
- @ApiOperation(value = "导出")
|
|
|
- @RequestMapping("/export")
|
|
|
- @PreAuthorize("@pcs.hasPermissions('questionnaireUserResult/export1')")
|
|
|
- public void questionnaireUserResultExport1(QuestionnaireActiveTypeEnum activeType, Integer cooperationId, HttpServletResponse response) throws Exception {
|
|
|
- List<QuestionnaireQuestion> questionList = questionnaireQuestionDao.findByActiveType(activeType.getCode());
|
|
|
questionList.removeAll(Collections.singleton(null));
|
|
|
if(questionList != null && questionList.size() > 0){
|
|
|
List<String> column = new ArrayList<>();
|