Search in sources :

Example 6 with MaterialContact

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

the class MigrationStageTen method materialNotice.

public void materialNotice() {
    List<Material> materials = materialService.getListMaterial("轮");
    List<CmsCategory> categorys = cmsCategoryService.getCmsCategoryListByCategoryName("公告");
    Long categoryId = categorys.get(0).getId();
    final String html = "<p><strong><span style=\"box-sizing: border-box; margin: 0px; padding: 0px;\">$f</span></strong>$d</p>";
    final String htmlS1 = "<p><strong><span style=\"box-sizing: border-box; margin: 0px; padding: 0px;\">$d</span></strong></p>";
    final String htmlS2 = "<p style=\"box-sizing: border-box; margin-top: 0px; margin-bottom: 10px; padding: 0px;\">$d</p>";
    for (Material material : materials) {
        CmsContent cmsContent = new CmsContent();
        cmsContent.setParentId(0L);
        cmsContent.setCategoryId(categoryId);
        cmsContent.setPath("0");
        cmsContent.setTitle(material.getMaterialName());
        cmsContent.setAuthorType((short) 0);
        cmsContent.setMaterialId(material.getId());
        /* 生成通知内容 */
        StringBuilder sb = new StringBuilder();
        String str = html.replace("$f", "截止日期:");
        str = str.replace("$d", sdf.format(material.getDeadline()));
        sb.append(str);
        /* 获取教材联系人 */
        List<MaterialContact> contacts = materialContactService.listMaterialContactByMaterialId(categoryId);
        if (CollectionUtil.isNotEmpty(contacts)) {
            str = htmlS1.replace("$f", "联系人:");
            sb.append(str);
            for (MaterialContact contact : contacts) {
                /* 裴中惠&nbsp;(电话:010-59787110&nbsp;,&nbsp;Email:pzh@pmph.com) */
                StringBuilder builder = new StringBuilder(contact.getContactUserName());
                builder.append("&nbsp;(电话:");
                builder.append(contact.getContactPhone());
                builder.append("&nbsp;,&nbsp;Email:");
                builder.append(contact.getContactEmail());
                builder.append(")");
                str = htmlS2.replace("$d", builder.toString());
                sb.append(str);
            }
        }
        str = html.replace("$f", "邮寄地址:");
        str = str.replace("$d", material.getMailAddress());
        sb.append(str);
        /* 获取通知内容和备注 */
        MaterialExtra extra = materialExtraService.getMaterialExtraByMaterialId(material.getId());
        str = htmlS1.replace("$d", "简&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;介:");
        sb.append(str);
        if (null != extra) {
        // str = htmlS2.replace("$d", extra.getNotice()) /* 存入MongoDB */
        }
        Content content = new Content(sb.toString());
        content = contentService.add(content);
        cmsContent.setMid(content.getId());
    }
}
Also used : CmsContent(com.bc.pmpheep.back.po.CmsContent) CmsContent(com.bc.pmpheep.back.po.CmsContent) Content(com.bc.pmpheep.general.po.Content) MaterialContact(com.bc.pmpheep.back.po.MaterialContact) Material(com.bc.pmpheep.back.po.Material) CmsCategory(com.bc.pmpheep.back.po.CmsCategory) MaterialExtra(com.bc.pmpheep.back.po.MaterialExtra)

Example 7 with MaterialContact

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

the class MaterialExtraServiceImpl method getMaterialExtraAndNoticeDetail.

/**
 * <pre>
 * 功能描述:根据教材ID查询教材通知详情及附件
 * 使用示范:
 *
 * @param materialId 教材ID
 * @return Map<String, Object> 集合
 * @throws CheckedServiceException
 * </pre>
 *
 * @throws UnsupportedEncodingException
 */
@Override
public Map<String, Object> getMaterialExtraAndNoticeDetail(Long materialId) throws CheckedServiceException {
    if (ObjectUtil.isNull(materialId)) {
        throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL_EXTRA, CheckedExceptionResult.NULL_PARAM, "教材主键为空");
    }
    Map<String, Object> resultMap = new HashMap<String, Object>();
    // 教材通知备注
    MaterialExtra materialExtra = null;
    // MongoDB中教材通知
    String contentText = null;
    // 联系人
    List<MaterialContact> materialContacts = null;
    // 教材通知附件
    List<MaterialNoticeAttachment> materialNoticeAttachments = null;
    // 教材备注附件
    List<MaterialNoteAttachment> materialNoteAttachments = null;
    // 教材
    Material material = materialService.getMaterialById(materialId);
    if (ObjectUtil.notNull(material)) {
        // 联系人
        materialContacts = materialContactService.listMaterialContactByMaterialId(materialId);
        materialExtra = this.getMaterialExtraByMaterialId(materialId);
        if (ObjectUtil.notNull(materialExtra)) {
            Long materialExtraId = materialExtra.getId();
            // 教材通知附件
            materialNoticeAttachments = materialNoticeAttachmentService.getMaterialNoticeAttachmentsByMaterialExtraId(materialExtraId);
            // 教材备注附件
            materialNoteAttachments = materialNoteAttachmentService.getMaterialNoteAttachmentByMaterialExtraId(materialExtraId);
        }
        // 判断内容是否已经发布或审核通过
        String fileNoticeDownLoadType = null;
        String fileNoteDownLoadType = null;
        if (Const.TRUE.booleanValue() == material.getIsPublished().booleanValue()) {
            fileNoticeDownLoadType = Const.MATERIAL_NOTICE_FILE_DOWNLOAD;
            fileNoteDownLoadType = Const.MATERIAL_NOTE_FILE_DOWNLOAD;
        } else {
            fileNoticeDownLoadType = Const.FILE_DOWNLOAD;
            fileNoteDownLoadType = Const.FILE_DOWNLOAD;
        }
        CmsContent cmsContent = cmsContentService.getCmsContentByMaterialId(materialId);
        if (ObjectUtil.notNull(cmsContent)) {
            Content content = contentService.get(cmsContent.getMid());
            if (ObjectUtil.notNull(content)) {
                contentText = content.getContent();
            }
        }
        if (CollectionUtil.isNotEmpty(materialNoticeAttachments)) {
            for (MaterialNoticeAttachment materialNoticeAttachment : materialNoticeAttachments) {
                String attachment = materialNoticeAttachment.getAttachment();
                // 拼接附件下载路径
                materialNoticeAttachment.setAttachment(fileNoticeDownLoadType + attachment);
            }
        }
        if (CollectionUtil.isNotEmpty(materialNoteAttachments)) {
            for (MaterialNoteAttachment materialNoteAttachment : materialNoteAttachments) {
                String attachment = materialNoteAttachment.getAttachment();
                // 拼接附件下载路径
                materialNoteAttachment.setAttachment(fileNoteDownLoadType + attachment);
            }
        }
    }
    // 教材
    resultMap.put("materialName", material);
    // 联系人
    resultMap.put("materialContacts", materialContacts);
    // 教材通知备注
    resultMap.put("materialExtra", materialExtra);
    // MongoDB中教材通知
    resultMap.put("content", contentText);
    // 教材通知附件
    resultMap.put("materialNoticeAttachments", materialNoticeAttachments);
    // 教材备注附件
    resultMap.put("materialNoteAttachments", materialNoteAttachments);
    return resultMap;
}
Also used : MaterialNoticeAttachment(com.bc.pmpheep.back.po.MaterialNoticeAttachment) CmsContent(com.bc.pmpheep.back.po.CmsContent) HashMap(java.util.HashMap) MaterialNoteAttachment(com.bc.pmpheep.back.po.MaterialNoteAttachment) MaterialContact(com.bc.pmpheep.back.po.MaterialContact) CheckedServiceException(com.bc.pmpheep.service.exception.CheckedServiceException) Material(com.bc.pmpheep.back.po.Material) CmsContent(com.bc.pmpheep.back.po.CmsContent) Content(com.bc.pmpheep.general.po.Content) MaterialExtra(com.bc.pmpheep.back.po.MaterialExtra)

Aggregations

MaterialContact (com.bc.pmpheep.back.po.MaterialContact)7 Material (com.bc.pmpheep.back.po.Material)5 MaterialExtra (com.bc.pmpheep.back.po.MaterialExtra)5 CmsContent (com.bc.pmpheep.back.po.CmsContent)4 MaterialNoteAttachment (com.bc.pmpheep.back.po.MaterialNoteAttachment)3 MaterialNoticeAttachment (com.bc.pmpheep.back.po.MaterialNoticeAttachment)3 Content (com.bc.pmpheep.general.po.Content)3 CheckedServiceException (com.bc.pmpheep.service.exception.CheckedServiceException)3 MaterialExtension (com.bc.pmpheep.back.po.MaterialExtension)2 PmphUser (com.bc.pmpheep.back.po.PmphUser)2 MaterialProjectEditorVO (com.bc.pmpheep.back.vo.MaterialProjectEditorVO)2 Gson (com.google.gson.Gson)2 HashMap (java.util.HashMap)2 CmsCategory (com.bc.pmpheep.back.po.CmsCategory)1 MaterialProjectEditor (com.bc.pmpheep.back.po.MaterialProjectEditor)1 MaterialType (com.bc.pmpheep.back.po.MaterialType)1 MaterialVO (com.bc.pmpheep.back.vo.MaterialVO)1 BaseTest (com.bc.pmpheep.test.BaseTest)1 TypeToken (com.google.gson.reflect.TypeToken)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1