Search in sources :

Example 1 with Survey

use of com.bc.pmpheep.back.po.Survey 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 Survey

use of com.bc.pmpheep.back.po.Survey 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 Survey

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

the class SurveyTargetServiceImpl method batchSaveSurveyTargetByList.

@Override
public Integer batchSaveSurveyTargetByList(Message message, SurveyTargetVO surveyTargetVO, String sessionId) throws Exception {
    PmphUser pmphUser = SessionUtil.getPmphUserBySessionId(sessionId);
    if (ObjectUtil.isNull(pmphUser)) {
        throw new CheckedServiceException(CheckedExceptionBusiness.QUESTIONNAIRE_SURVEY, CheckedExceptionResult.NULL_PARAM, "用户为空");
    }
    if (ObjectUtil.isNull(surveyTargetVO.getSurveyId())) {
        throw new CheckedServiceException(CheckedExceptionBusiness.QUESTIONNAIRE_SURVEY, CheckedExceptionResult.NULL_PARAM, "问卷表Id为空");
    }
    if (CollectionUtil.isEmpty(surveyTargetVO.getOrgIds())) {
        throw new CheckedServiceException(CheckedExceptionBusiness.QUESTIONNAIRE_SURVEY, CheckedExceptionResult.NULL_PARAM, "学校Id为空");
    }
    if (StringUtil.isEmpty(surveyTargetVO.getStartTime())) {
        throw new CheckedServiceException(CheckedExceptionBusiness.QUESTIONNAIRE_SURVEY, CheckedExceptionResult.NULL_PARAM, "问卷开始时间为空");
    }
    if (StringUtil.isEmpty(surveyTargetVO.getEndTime())) {
        throw new CheckedServiceException(CheckedExceptionBusiness.QUESTIONNAIRE_SURVEY, CheckedExceptionResult.NULL_PARAM, "问卷结束时间为空");
    }
    Timestamp statTime = DateUtil.str2Timestam(surveyTargetVO.getStartTime());
    Timestamp endTime = DateUtil.str2Timestam(surveyTargetVO.getEndTime());
    if (statTime.getTime() > DateUtil.getCurrentTimeByYMD().getTime()) {
        throw new CheckedServiceException(CheckedExceptionBusiness.QUESTIONNAIRE_SURVEY, CheckedExceptionResult.NULL_PARAM, "问卷开始时间不能大于今天");
    }
    if (endTime.getTime() < DateUtil.getCurrentTimeByYMD().getTime()) {
        throw new CheckedServiceException(CheckedExceptionBusiness.QUESTIONNAIRE_SURVEY, CheckedExceptionResult.NULL_PARAM, "问卷结束时间不能小于今天");
    }
    if (statTime.getTime() > endTime.getTime()) {
        throw new CheckedServiceException(CheckedExceptionBusiness.QUESTIONNAIRE_SURVEY, CheckedExceptionResult.ILLEGAL_PARAM, "开始日期不能大于结束日期");
    }
    List<Long> orgIds = this.listOrgIdBySurveyId(surveyTargetVO.getSurveyId());
    Integer count = 0;
    // 当前用户
    Long userId = pmphUser.getId();
    List<Long> listOrgId = new ArrayList<Long>();
    if (CollectionUtil.isEmpty(orgIds)) {
        // 第一次发布
        listOrgId.addAll(surveyTargetVO.getOrgIds());
        surveyService.updateSurvey(new Survey(surveyTargetVO.getSurveyId(), Const.SURVEY_STATUS_1, DateUtil.str2Timestam(surveyTargetVO.getStartTime()), DateUtil.str2Timestam(surveyTargetVO.getEndTime())));
    } else {
        // 第二次发布
        for (Long id : surveyTargetVO.getOrgIds()) {
            if (!orgIds.contains(id)) {
                listOrgId.add(id);
            }
        }
    }
    List<SurveyTarget> list = new ArrayList<SurveyTarget>(listOrgId.size());
    for (Long orgId : listOrgId) {
        list.add(new SurveyTarget(userId, surveyTargetVO.getSurveyId(), orgId));
    }
    if (CollectionUtil.isNotEmpty(list)) {
        // 保存发起问卷中间表
        count = surveyTargetDao.batchSaveSurveyTargetByList(list);
    }
    if (count > 0) {
        // MongoDB 消息插入
        message = messageService.add(message);
        if (StringUtil.isEmpty(message.getId())) {
            throw new CheckedServiceException(CheckedExceptionBusiness.MESSAGE, CheckedExceptionResult.OBJECT_NOT_FOUND, "储存失败!");
        }
        // 发送消息
        List<WriterUser> writerUserList = // 作家用户
        writerUserService.getWriterUserListByOrgIds(listOrgId);
        // 系统消息
        List<UserMessage> userMessageList = new ArrayList<UserMessage>(writerUserList.size());
        for (WriterUser writerUser : writerUserList) {
            userMessageList.add(new UserMessage(message.getId(), surveyTargetVO.getTitle(), Const.MSG_TYPE_1, userId, Const.SENDER_TYPE_1, writerUser.getId(), Const.RECEIVER_TYPE_2, 0L));
        }
        // 获取学校管理员集合
        List<OrgUser> orgUserList = orgUserService.getOrgUserListByOrgIds(listOrgId);
        // 收件人邮箱
        List<String> orgUserEmail = new ArrayList<String>(orgUserList.size());
        for (OrgUser orgUser : orgUserList) {
            userMessageList.add(new UserMessage(message.getId(), surveyTargetVO.getTitle(), Const.MSG_TYPE_1, userId, Const.SENDER_TYPE_1, orgUser.getId(), Const.RECEIVER_TYPE_3, 0L));
            if (!"-".equals(orgUser.getEmail()) && !"null".equals(orgUser.getEmail())) {
            // orgUserEmail.add(orgUser.getEmail());// 获取学校管理员邮箱地址
            }
        }
        // Integer size = orgUserEmail.size();
        String[] emails = new String[] { "515944204@qq.com", "2310870657@qq.com", "501331000@qq.com" };
        // String[] toEmail = (String[]) orgUserEmail.toArray(new String[size]);
        if (ArrayUtil.isEmpty(emails)) {
            throw new CheckedServiceException(CheckedExceptionBusiness.QUESTIONNAIRE_SURVEY, CheckedExceptionResult.NULL_PARAM, "收件人邮箱为空");
        }
        // 发送邮件
        JavaMailSenderUtil javaMailSenderUtil = new JavaMailSenderUtil();
        String serverUrl = getLogin2frontUrl().substring(0, getLogin2frontUrl().lastIndexOf("/"));
        // 给学校管理员发送邮件
        javaMailSenderUtil.sendMail(surveyTargetVO.getTitle(), // message.getContent(),
        "<p style='margin: 5px 0px; color: rgb(0, 0, 0); font-family: sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-align: left;'><span style='font-family: 黑体, SimHei;'>您好:</span></p><p style='margin: 5px 0px; color: rgb(0, 0, 0); font-family: sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-align: left;'><span style='font-family: 黑体, SimHei;'>&nbsp; &nbsp; 现有一份《" + surveyTargetVO.getTitle() + "》需要您登陆下面地址,填写您宝贵意见。</span></p><p style='margin: 5px 0px; color: rgb(0, 0, 0); font-family: sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-align: left;'><span style='font-family: 黑体, SimHei;'>&nbsp;&nbsp;&nbsp;&nbsp;登陆地址:<a href='" + serverUrl + "/survey/writeSurvey.action?surveyId=" + surveyTargetVO.getSurveyId() + "'>人卫E教平台</a><br/></span></p><p style='margin: 5px 0px; color: rgb(0, 0, 0); font-family: sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;'><br/></p>", emails);
        // 发送消息
        if (CollectionUtil.isNotEmpty(userMessageList)) {
            // 插入消息发送对象数据
            userMessageService.addUserMessageBatch(userMessageList);
            // websocket发送的id集合
            List<String> websocketUserIds = new ArrayList<String>();
            for (UserMessage userMessage : userMessageList) {
                websocketUserIds.add(userMessage.getReceiverType() + "_" + userMessage.getReceiverId());
            }
            // webscokt发送消息
            if (CollectionUtil.isNotEmpty(websocketUserIds)) {
                WebScocketMessage webScocketMessage = new WebScocketMessage(message.getId(), Const.MSG_TYPE_1, userId, pmphUser.getRealname(), Const.SENDER_TYPE_1, Const.SEND_MSG_TYPE_0, RouteUtil.DEFAULT_USER_AVATAR, surveyTargetVO.getTitle(), message.getContent(), DateUtil.getCurrentTime());
                myWebSocketHandler.sendWebSocketMessageToUser(websocketUserIds, webScocketMessage);
            }
        }
    }
    return count;
}
Also used : SurveyTarget(com.bc.pmpheep.back.po.SurveyTarget) PmphUser(com.bc.pmpheep.back.po.PmphUser) OrgUser(com.bc.pmpheep.back.po.OrgUser) ArrayList(java.util.ArrayList) CheckedServiceException(com.bc.pmpheep.service.exception.CheckedServiceException) UserMessage(com.bc.pmpheep.back.po.UserMessage) WebScocketMessage(com.bc.pmpheep.websocket.WebScocketMessage) Timestamp(java.sql.Timestamp) Survey(com.bc.pmpheep.back.po.Survey) JavaMailSenderUtil(com.bc.pmpheep.back.util.mail.JavaMailSenderUtil) WriterUser(com.bc.pmpheep.back.po.WriterUser)

Example 4 with Survey

use of com.bc.pmpheep.back.po.Survey 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)

Example 5 with Survey

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

the class SurveyServiceTest method listSurvey.

@SuppressWarnings({ "unused", "rawtypes", "unchecked" })
@Test
@Rollback(Const.ISROLLBACK)
public void listSurvey() {
    Survey survey = this.addSurveys();
    PageParameter pageParameter = new PageParameter<>();
    PageResult pageResult = new PageResult<>();
    SurveyVO surveyVO = new SurveyVO();
    pageParameter.setParameter(surveyVO);
    pageParameter.setPageSize(10);
    pageResult = surveyService.listSurvey(pageParameter);
    Assert.assertNotNull("分页数据失败", pageResult);
}
Also used : Survey(com.bc.pmpheep.back.po.Survey) SurveyVO(com.bc.pmpheep.back.vo.SurveyVO) PageParameter(com.bc.pmpheep.back.plugin.PageParameter) PageResult(com.bc.pmpheep.back.plugin.PageResult) Test(org.junit.Test) BaseTest(com.bc.pmpheep.test.BaseTest) Rollback(org.springframework.test.annotation.Rollback)

Aggregations

Survey (com.bc.pmpheep.back.po.Survey)5 SurveyTemplate (com.bc.pmpheep.back.po.SurveyTemplate)3 SurveyTemplateQuestion (com.bc.pmpheep.back.po.SurveyTemplateQuestion)3 CheckedServiceException (com.bc.pmpheep.service.exception.CheckedServiceException)3 ArrayList (java.util.ArrayList)3 PmphUser (com.bc.pmpheep.back.po.PmphUser)2 JsonUtil (com.bc.pmpheep.back.util.JsonUtil)2 SurveyQuestionListVO (com.bc.pmpheep.back.vo.SurveyQuestionListVO)2 PageParameter (com.bc.pmpheep.back.plugin.PageParameter)1 PageResult (com.bc.pmpheep.back.plugin.PageResult)1 OrgUser (com.bc.pmpheep.back.po.OrgUser)1 SurveyQuestion (com.bc.pmpheep.back.po.SurveyQuestion)1 SurveyQuestionOption (com.bc.pmpheep.back.po.SurveyQuestionOption)1 SurveyTarget (com.bc.pmpheep.back.po.SurveyTarget)1 SurveyType (com.bc.pmpheep.back.po.SurveyType)1 UserMessage (com.bc.pmpheep.back.po.UserMessage)1 WriterUser (com.bc.pmpheep.back.po.WriterUser)1 JavaMailSenderUtil (com.bc.pmpheep.back.util.mail.JavaMailSenderUtil)1 SurveyVO (com.bc.pmpheep.back.vo.SurveyVO)1 BaseTest (com.bc.pmpheep.test.BaseTest)1