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) {
/* 裴中惠 (电话:010-59787110 , Email:pzh@pmph.com) */
StringBuilder builder = new StringBuilder(contact.getContactUserName());
builder.append(" (电话:");
builder.append(contact.getContactPhone());
builder.append(" , 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", "简 介:");
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());
}
}
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;
}
Aggregations