Search in sources :

Example 1 with SurveyTemplateQuestion

use of com.bc.pmpheep.back.po.SurveyTemplateQuestion in project pmph by BCSquad.

the class MigrationPlus method survey.

protected void survey() {
    SurveyType surveyType = new SurveyType("学生", 1);
    surveyTypeService.addSurveyType(surveyType);
    SurveyType surveyType2 = new SurveyType("教师", 2);
    surveyTypeService.addSurveyType(surveyType2);
    SurveyType surveyType3 = new SurveyType("医生", 3);
    surveyTypeService.addSurveyType(surveyType3);
    // 查询武震的new_pk
    String sql = "select * from sys_user where userid = '1496375695709123-789241'";
    List<Map<String, Object>> maps = JdbcHelper.getJdbcTemplate().queryForList(sql);
    Map<String, Object> map = maps.get(0);
    Long id = (Long) map.get("new_pk");
    SurveyTemplate surveyTemplate = new SurveyTemplate("人卫e教平台满意度问卷模板", 999, id, "该问卷只针对教师", surveyType2.getId(), false);
    surveyTemplateService.addSurveyTemplate(surveyTemplate);
    Survey survey = new Survey("人卫e教平台满意度问卷模板", "希望您能抽出几分钟时间,将您的感受和建议告诉我们,我们非常重视每位教师的宝贵意见,期待您的参与!", "该问卷只针对教师", surveyTemplate.getId(), surveyType2.getId(), id, null, null, 999, (short) 0);
    surveyService.addSurvey(survey);
    SurveyQuestion surveyQuestion = new SurveyQuestion(0L, "您是否使用过人卫e教平台网站?", (short) 1, 1, null, true);
    surveyQuestionService.addSurveyQuestion(surveyQuestion);
    SurveyQuestionOption surveyQuestionOption = new SurveyQuestionOption(surveyQuestion.getId(), "是", false, null);
    surveyQuestionOptionService.addSurveyQuestionOption(surveyQuestionOption);
    SurveyQuestionOption surveyQuestionOption2 = new SurveyQuestionOption(surveyQuestion.getId(), "否", false, null);
    surveyQuestionOptionService.addSurveyQuestionOption(surveyQuestionOption2);
    SurveyQuestion surveyQuestion2 = new SurveyQuestion(0L, "您使用人卫e教平台网站的目的是?", (short) 2, 2, null, true);
    surveyQuestionService.addSurveyQuestion(surveyQuestion2);
    SurveyQuestionOption surveyQuestionOption3 = new SurveyQuestionOption(surveyQuestion2.getId(), "工作需要", false, null);
    surveyQuestionOptionService.addSurveyQuestionOption(surveyQuestionOption3);
    SurveyQuestionOption surveyQuestionOption4 = new SurveyQuestionOption(surveyQuestion2.getId(), "获取生活信息,扩展视野受", false, null);
    surveyQuestionOptionService.addSurveyQuestionOption(surveyQuestionOption4);
    SurveyQuestionOption surveyQuestionOption5 = new SurveyQuestionOption(surveyQuestion2.getId(), "关注名人动态", false, null);
    surveyQuestionOptionService.addSurveyQuestionOption(surveyQuestionOption5);
    SurveyQuestionOption surveyQuestionOption6 = new SurveyQuestionOption(surveyQuestion2.getId(), "寻找知趣相投的群体", false, null);
    surveyQuestionOptionService.addSurveyQuestionOption(surveyQuestionOption6);
    SurveyQuestionOption surveyQuestionOption7 = new SurveyQuestionOption(surveyQuestion2.getId(), "展现自己多彩的生活", false, null);
    surveyQuestionOptionService.addSurveyQuestionOption(surveyQuestionOption7);
    SurveyQuestionOption surveyQuestionOption8 = new SurveyQuestionOption(surveyQuestion2.getId(), "其他", false, null);
    surveyQuestionOptionService.addSurveyQuestionOption(surveyQuestionOption8);
    SurveyQuestion surveyQuestion3 = new SurveyQuestion(0L, "您在人卫e教平台网站上主要做什么?", (short) 2, 3, null, true);
    surveyQuestionService.addSurveyQuestion(surveyQuestion3);
    SurveyQuestionOption surveyQuestionOption9 = new SurveyQuestionOption(surveyQuestion3.getId(), "教材申报", false, null);
    surveyQuestionOptionService.addSurveyQuestionOption(surveyQuestionOption9);
    SurveyQuestionOption surveyQuestionOption10 = new SurveyQuestionOption(surveyQuestion3.getId(), "查看图书", false, null);
    surveyQuestionOptionService.addSurveyQuestionOption(surveyQuestionOption10);
    SurveyQuestionOption surveyQuestionOption11 = new SurveyQuestionOption(surveyQuestion3.getId(), "图书纠错", false, null);
    surveyQuestionOptionService.addSurveyQuestionOption(surveyQuestionOption11);
    SurveyQuestionOption surveyQuestionOption12 = new SurveyQuestionOption(surveyQuestion3.getId(), "选题申报", false, null);
    surveyQuestionOptionService.addSurveyQuestionOption(surveyQuestionOption12);
    SurveyQuestionOption surveyQuestionOption13 = new SurveyQuestionOption(surveyQuestion3.getId(), "评论图书", false, null);
    surveyQuestionOptionService.addSurveyQuestionOption(surveyQuestionOption13);
    SurveyQuestionOption surveyQuestionOption14 = new SurveyQuestionOption(surveyQuestion3.getId(), "其他", false, null);
    surveyQuestionOptionService.addSurveyQuestionOption(surveyQuestionOption14);
    SurveyQuestion surveyQuestion4 = new SurveyQuestion(0L, "您使用人卫e教平台网站的频率是?", (short) 1, 4, null, true);
    surveyQuestionService.addSurveyQuestion(surveyQuestion4);
    SurveyQuestionOption surveyQuestionOption15 = new SurveyQuestionOption(surveyQuestion4.getId(), "几乎每天都会使用", false, null);
    surveyQuestionOptionService.addSurveyQuestionOption(surveyQuestionOption15);
    SurveyQuestionOption surveyQuestionOption16 = new SurveyQuestionOption(surveyQuestion4.getId(), "每个星期都会使用", false, null);
    surveyQuestionOptionService.addSurveyQuestionOption(surveyQuestionOption16);
    SurveyQuestionOption surveyQuestionOption17 = new SurveyQuestionOption(surveyQuestion4.getId(), "每个月都会使用", false, null);
    surveyQuestionOptionService.addSurveyQuestionOption(surveyQuestionOption17);
    SurveyQuestionOption surveyQuestionOption18 = new SurveyQuestionOption(surveyQuestion4.getId(), "很少使用", false, null);
    surveyQuestionOptionService.addSurveyQuestionOption(surveyQuestionOption18);
    SurveyQuestion surveyQuestion5 = new SurveyQuestion(0L, "到目前为止,您使用人卫e教平台网站有多久了?", (short) 1, 5, null, true);
    surveyQuestionService.addSurveyQuestion(surveyQuestion5);
    SurveyQuestionOption surveyQuestionOption19 = new SurveyQuestionOption(surveyQuestion5.getId(), "不到1个月", false, null);
    surveyQuestionOptionService.addSurveyQuestionOption(surveyQuestionOption19);
    SurveyQuestionOption surveyQuestionOption20 = new SurveyQuestionOption(surveyQuestion5.getId(), "1-3个月(含3个月)", false, null);
    surveyQuestionOptionService.addSurveyQuestionOption(surveyQuestionOption20);
    SurveyQuestionOption surveyQuestionOption21 = new SurveyQuestionOption(surveyQuestion5.getId(), "3-6个月(含6个月)", false, null);
    surveyQuestionOptionService.addSurveyQuestionOption(surveyQuestionOption21);
    SurveyQuestionOption surveyQuestionOption22 = new SurveyQuestionOption(surveyQuestion5.getId(), "6-12个月(含12个月)", false, null);
    surveyQuestionOptionService.addSurveyQuestionOption(surveyQuestionOption22);
    SurveyQuestionOption surveyQuestionOption23 = new SurveyQuestionOption(surveyQuestion5.getId(), "1-2年(含2年)", false, null);
    surveyQuestionOptionService.addSurveyQuestionOption(surveyQuestionOption23);
    SurveyQuestionOption surveyQuestionOption24 = new SurveyQuestionOption(surveyQuestion5.getId(), "2年以上", false, null);
    surveyQuestionOptionService.addSurveyQuestionOption(surveyQuestionOption24);
    SurveyQuestion surveyQuestion6 = new SurveyQuestion(0L, "您的性别是", (short) 1, 6, null, true);
    surveyQuestionService.addSurveyQuestion(surveyQuestion6);
    SurveyQuestionOption surveyQuestionOption25 = new SurveyQuestionOption(surveyQuestion6.getId(), "男", false, null);
    surveyQuestionOptionService.addSurveyQuestionOption(surveyQuestionOption25);
    SurveyQuestionOption surveyQuestionOption26 = new SurveyQuestionOption(surveyQuestion6.getId(), "女", false, null);
    surveyQuestionOptionService.addSurveyQuestionOption(surveyQuestionOption26);
    SurveyQuestion surveyQuestion7 = new SurveyQuestion(0L, "您的学历是", (short) 1, 7, null, true);
    surveyQuestionService.addSurveyQuestion(surveyQuestion7);
    SurveyQuestionOption surveyQuestionOption27 = new SurveyQuestionOption(surveyQuestion7.getId(), "本科", false, null);
    surveyQuestionOptionService.addSurveyQuestionOption(surveyQuestionOption27);
    SurveyQuestionOption surveyQuestionOption28 = new SurveyQuestionOption(surveyQuestion7.getId(), "硕士及以上", false, null);
    surveyQuestionOptionService.addSurveyQuestionOption(surveyQuestionOption28);
    SurveyQuestion surveyQuestion8 = new SurveyQuestion(0L, "您对人卫e教平台网站的发展还有哪些期待", (short) 5, 8, null, true);
    surveyQuestionService.addSurveyQuestion(surveyQuestion8);
    SurveyQuestionOption surveyQuestionOption29 = new SurveyQuestionOption(surveyQuestion8.getId(), "期待", false, null);
    surveyQuestionOptionService.addSurveyQuestionOption(surveyQuestionOption29);
    SurveyQuestion surveyQuestion9 = new SurveyQuestion(0L, "您对人卫e教平台网站的发展还有哪些建议", (short) 5, 9, null, true);
    surveyQuestionService.addSurveyQuestion(surveyQuestion9);
    SurveyQuestionOption surveyQuestionOption30 = new SurveyQuestionOption(surveyQuestion9.getId(), "建议", false, null);
    surveyQuestionOptionService.addSurveyQuestionOption(surveyQuestionOption30);
    SurveyQuestion surveyQuestion10 = new SurveyQuestion(0L, "您对人卫e教平台网站的态度是", (short) 4, 10, null, true);
    surveyQuestionService.addSurveyQuestion(surveyQuestion10);
    SurveyQuestionOption surveyQuestionOption31 = new SurveyQuestionOption(surveyQuestion10.getId(), "态度", false, null);
    surveyQuestionOptionService.addSurveyQuestionOption(surveyQuestionOption31);
    SurveyTemplateQuestion surveyTemplateQuestion = new SurveyTemplateQuestion(surveyTemplate.getId(), surveyQuestion.getId());
    surveyTemplateQuestionService.addSurveyTemplateQuestion(surveyTemplateQuestion);
    SurveyTemplateQuestion surveyTemplateQuestion2 = new SurveyTemplateQuestion(surveyTemplate.getId(), surveyQuestion2.getId());
    surveyTemplateQuestionService.addSurveyTemplateQuestion(surveyTemplateQuestion2);
    SurveyTemplateQuestion surveyTemplateQuestion3 = new SurveyTemplateQuestion(surveyTemplate.getId(), surveyQuestion3.getId());
    surveyTemplateQuestionService.addSurveyTemplateQuestion(surveyTemplateQuestion3);
    SurveyTemplateQuestion surveyTemplateQuestion4 = new SurveyTemplateQuestion(surveyTemplate.getId(), surveyQuestion4.getId());
    surveyTemplateQuestionService.addSurveyTemplateQuestion(surveyTemplateQuestion4);
    SurveyTemplateQuestion surveyTemplateQuestion5 = new SurveyTemplateQuestion(surveyTemplate.getId(), surveyQuestion5.getId());
    surveyTemplateQuestionService.addSurveyTemplateQuestion(surveyTemplateQuestion5);
    SurveyTemplateQuestion surveyTemplateQuestion6 = new SurveyTemplateQuestion(surveyTemplate.getId(), surveyQuestion6.getId());
    surveyTemplateQuestionService.addSurveyTemplateQuestion(surveyTemplateQuestion6);
    SurveyTemplateQuestion surveyTemplateQuestion7 = new SurveyTemplateQuestion(surveyTemplate.getId(), surveyQuestion7.getId());
    surveyTemplateQuestionService.addSurveyTemplateQuestion(surveyTemplateQuestion7);
    SurveyTemplateQuestion surveyTemplateQuestion8 = new SurveyTemplateQuestion(surveyTemplate.getId(), surveyQuestion8.getId());
    surveyTemplateQuestionService.addSurveyTemplateQuestion(surveyTemplateQuestion8);
    SurveyTemplateQuestion surveyTemplateQuestion9 = new SurveyTemplateQuestion(surveyTemplate.getId(), surveyQuestion9.getId());
    surveyTemplateQuestionService.addSurveyTemplateQuestion(surveyTemplateQuestion9);
    SurveyTemplateQuestion surveyTemplateQuestion10 = new SurveyTemplateQuestion(surveyTemplate.getId(), surveyQuestion10.getId());
    surveyTemplateQuestionService.addSurveyTemplateQuestion(surveyTemplateQuestion10);
}
Also used : SurveyQuestionOption(com.bc.pmpheep.back.po.SurveyQuestionOption) SurveyType(com.bc.pmpheep.back.po.SurveyType) Survey(com.bc.pmpheep.back.po.Survey) SurveyTemplate(com.bc.pmpheep.back.po.SurveyTemplate) SurveyTemplateQuestion(com.bc.pmpheep.back.po.SurveyTemplateQuestion) Map(java.util.Map) SurveyQuestion(com.bc.pmpheep.back.po.SurveyQuestion)

Example 2 with SurveyTemplateQuestion

use of com.bc.pmpheep.back.po.SurveyTemplateQuestion in project pmph by BCSquad.

the class SurveyServiceImpl method updateSurveyAndTemplate.

@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public Integer updateSurveyAndTemplate(String questionAnswerJosn, SurveyVO surveyVO) throws CheckedServiceException {
    if (StringUtil.isEmpty(questionAnswerJosn)) {
        throw new CheckedServiceException(CheckedExceptionBusiness.QUESTIONNAIRE_SURVEY, CheckedExceptionResult.NULL_PARAM, "问题为空");
    }
    if (ObjectUtil.isNull(surveyVO)) {
        throw new CheckedServiceException(CheckedExceptionBusiness.QUESTIONNAIRE_SURVEY, CheckedExceptionResult.NULL_PARAM, "对象为空");
    }
    if (ObjectUtil.isNull(surveyVO.getId())) {
        throw new CheckedServiceException(CheckedExceptionBusiness.QUESTIONNAIRE_SURVEY, CheckedExceptionResult.NULL_PARAM, "问卷ID为空");
    }
    if (ObjectUtil.isNull(surveyVO.getTemplateId())) {
        throw new CheckedServiceException(CheckedExceptionBusiness.QUESTIONNAIRE_SURVEY, CheckedExceptionResult.NULL_PARAM, "模版ID为空");
    }
    // json字符串转List对象集合
    List<SurveyQuestionListVO> SurveyQuestionListVO = new JsonUtil().getArrayListObjectFromStr(SurveyQuestionListVO.class, questionAnswerJosn);
    if (CollectionUtil.isEmpty(SurveyQuestionListVO)) {
        throw new CheckedServiceException(CheckedExceptionBusiness.QUESTIONNAIRE_SURVEY, CheckedExceptionResult.NULL_PARAM, "参数为空");
    }
    // 问卷ID
    Long surveyId = surveyVO.getId();
    // 问卷名称
    String title = surveyVO.getTemplateName();
    // 问卷概述
    String intro = surveyVO.getIntro();
    // 问卷调查对象
    Long typeId = surveyVO.getTypeId();
    // 模版ID
    Long templateId = surveyVO.getTemplateId();
    Integer count = 0;
    // 更新问卷表
    count = this.updateSurvey(new Survey(surveyId, title, intro, typeId));
    surveyTemplateService.updateSurveyTemplate(new SurveyTemplate(templateId, title, intro, // 更新模版表
    typeId));
    // 查询模版下的所有问题
    List<SurveyTemplateQuestion> lists = surveyTemplateQuestionService.getSurveyTemplateQuestionByTemplateId(templateId);
    List<Long> questionIdList = new ArrayList<Long>(lists.size());
    for (SurveyTemplateQuestion surveyTemplateQuestion : lists) {
        questionIdList.add(surveyTemplateQuestion.getQuestionId());
    }
    // 删除模版问题中间表下模版对应的所有问题
    surveyTemplateQuestionService.deleteSurveyTemplateQuestionByTemplateId(templateId);
    // 删除问题表
    surveyQuestionService.batchDeleteSurveyQuestionByQuestionIds(questionIdList);
    // 删除问题选项表
    surveyQuestionOptionService.batchDeleteSurveyQuestionOptionByQuestionIds(questionIdList);
    // 重新添加问题
    List<Long> newIds = this.addQuestionAndOption(SurveyQuestionListVO);
    // 模版问题中间表
    List<SurveyTemplateQuestion> surveyTemplateQuestions = new ArrayList<SurveyTemplateQuestion>(newIds.size());
    for (Long questionId : newIds) {
        surveyTemplateQuestions.add(new SurveyTemplateQuestion(templateId, questionId));
    }
    // 重新添加模版问题中间表
    count = surveyTemplateQuestionService.batchInsertSurveyTemplateQuestion(surveyTemplateQuestions);
    return count;
}
Also used : SurveyTemplate(com.bc.pmpheep.back.po.SurveyTemplate) SurveyQuestionListVO(com.bc.pmpheep.back.vo.SurveyQuestionListVO) ArrayList(java.util.ArrayList) CheckedServiceException(com.bc.pmpheep.service.exception.CheckedServiceException) JsonUtil(com.bc.pmpheep.back.util.JsonUtil) Survey(com.bc.pmpheep.back.po.Survey) SurveyTemplateQuestion(com.bc.pmpheep.back.po.SurveyTemplateQuestion)

Example 3 with SurveyTemplateQuestion

use of com.bc.pmpheep.back.po.SurveyTemplateQuestion in project pmph by BCSquad.

the class SurveyTemplateServiceImpl method addSurveyTemplateVO.

@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public SurveyTemplate addSurveyTemplateVO(String questionAnswerJosn, SurveyTemplateVO surveyTemplateVO, String sessionId) throws CheckedServiceException {
    PmphUser pmphUser = SessionUtil.getPmphUserBySessionId(sessionId);
    if (ObjectUtil.isNull(pmphUser)) {
        throw new CheckedServiceException(CheckedExceptionBusiness.MESSAGE, CheckedExceptionResult.NULL_PARAM, "用户为空");
    }
    if (ObjectUtil.isNull(surveyTemplateVO)) {
        throw new CheckedServiceException(CheckedExceptionBusiness.QUESTIONNAIRE_SURVEY, CheckedExceptionResult.NULL_PARAM, "参数为空");
    }
    if (StringUtil.isEmpty(questionAnswerJosn)) {
        throw new CheckedServiceException(CheckedExceptionBusiness.QUESTIONNAIRE_SURVEY, CheckedExceptionResult.NULL_PARAM, "问题及问题选项为空");
    }
    // json字符串转List对象集合
    List<SurveyQuestionListVO> surveyQuestionListVO;
    try {
        surveyQuestionListVO = new JsonUtil().getArrayListObjectFromStr(SurveyQuestionListVO.class, questionAnswerJosn);
    } catch (Exception e) {
        throw new CheckedServiceException(CheckedExceptionBusiness.QUESTIONNAIRE_SURVEY, CheckedExceptionResult.VO_CONVERSION_FAILED, "json字符串转List对象失败");
    }
    if (CollectionUtil.isEmpty(surveyQuestionListVO)) {
        throw new CheckedServiceException(CheckedExceptionBusiness.QUESTIONNAIRE_SURVEY, CheckedExceptionResult.NULL_PARAM, "参数为空");
    }
    // 问卷名称
    String templateName = surveyTemplateVO.getTemplateName();
    if (templateName.length() > 50) {
        throw new CheckedServiceException(CheckedExceptionBusiness.QUESTIONNAIRE_SURVEY, CheckedExceptionResult.NULL_PARAM, "问卷标题不能超过50个字符");
    }
    // 问卷概述
    String intro = surveyTemplateVO.getIntro();
    if (templateName.length() > 200) {
        throw new CheckedServiceException(CheckedExceptionBusiness.QUESTIONNAIRE_SURVEY, CheckedExceptionResult.NULL_PARAM, "问卷概述不能超过200个字符");
    }
    if (templateName.length() > 200) {
        throw new CheckedServiceException(CheckedExceptionBusiness.QUESTIONNAIRE_SURVEY, CheckedExceptionResult.NULL_PARAM, "问卷概述不能超过200个字符");
    }
    // 问卷调查类型
    Long typeId = surveyTemplateVO.getTypeId();
    // 问卷创建人
    Long userId = pmphUser.getId();
    SurveyTemplate surveyTemplate = // 添加模版表
    addSurveyTemplate(new SurveyTemplate(templateName, intro, typeId, userId));
    // 获取模版id
    Long templateId = surveyTemplate.getId();
    if (ObjectUtil.isNull(templateId)) {
        throw new CheckedServiceException(CheckedExceptionBusiness.QUESTIONNAIRE_SURVEY, CheckedExceptionResult.NULL_PARAM, "新增模版失败");
    }
    Survey survey = // 添加问卷表
    surveyService.addSurvey(new Survey(templateName, intro, templateId, typeId, userId));
    if (ObjectUtil.isNull(survey.getId())) {
        throw new CheckedServiceException(CheckedExceptionBusiness.QUESTIONNAIRE_SURVEY, CheckedExceptionResult.NULL_PARAM, "新增问卷失败");
    }
    // 添加问题及问题选项
    List<Long> newIds = addQuestionAndOption(surveyQuestionListVO);
    // 模版问题中间表
    List<SurveyTemplateQuestion> surveyTemplateQuestions = new ArrayList<SurveyTemplateQuestion>(newIds.size());
    for (Long questionId : newIds) {
        surveyTemplateQuestions.add(new SurveyTemplateQuestion(templateId, questionId));
    }
    // 添加模版问题中间表
    surveyTemplateQuestionDao.batchInsertSurveyTemplateQuestion(surveyTemplateQuestions);
    System.out.println(surveyTemplate.toString());
    return surveyTemplate;
}
Also used : SurveyTemplate(com.bc.pmpheep.back.po.SurveyTemplate) SurveyQuestionListVO(com.bc.pmpheep.back.vo.SurveyQuestionListVO) PmphUser(com.bc.pmpheep.back.po.PmphUser) ArrayList(java.util.ArrayList) CheckedServiceException(com.bc.pmpheep.service.exception.CheckedServiceException) JsonUtil(com.bc.pmpheep.back.util.JsonUtil) CheckedServiceException(com.bc.pmpheep.service.exception.CheckedServiceException) Survey(com.bc.pmpheep.back.po.Survey) SurveyTemplateQuestion(com.bc.pmpheep.back.po.SurveyTemplateQuestion)

Aggregations

Survey (com.bc.pmpheep.back.po.Survey)3 SurveyTemplate (com.bc.pmpheep.back.po.SurveyTemplate)3 SurveyTemplateQuestion (com.bc.pmpheep.back.po.SurveyTemplateQuestion)3 JsonUtil (com.bc.pmpheep.back.util.JsonUtil)2 SurveyQuestionListVO (com.bc.pmpheep.back.vo.SurveyQuestionListVO)2 CheckedServiceException (com.bc.pmpheep.service.exception.CheckedServiceException)2 ArrayList (java.util.ArrayList)2 PmphUser (com.bc.pmpheep.back.po.PmphUser)1 SurveyQuestion (com.bc.pmpheep.back.po.SurveyQuestion)1 SurveyQuestionOption (com.bc.pmpheep.back.po.SurveyQuestionOption)1 SurveyType (com.bc.pmpheep.back.po.SurveyType)1 Map (java.util.Map)1