use of com.bc.pmpheep.back.vo.MaterialVO in project pmph by BCSquad.
the class MaterialServiceImpl method getMaterialVO.
@Override
public MaterialVO getMaterialVO(Long id) throws CheckedServiceException {
if (null == id) {
throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL, CheckedExceptionResult.NULL_PARAM, "教材主键为空");
}
// 教材主要信息
Material material = materialDao.getMaterialById(id);
// 教材主任
PmphUser director = pmphUserService.get(material.getDirector());
// 教材类型字符串
MaterialType materialType = materialTypeService.getMaterialTypeById(material.getMaterialType());
String mtype = "[]";
if (null != materialType) {
mtype = "[" + materialType.getPath().replace("-", ",") + "," + material.getMaterialType() + "]";
// 去掉 0
mtype = mtype.replace("[0,", "[").replace("[0", "[");
}
// 教材通知备注表
MaterialExtra materialExtra = materialExtraService.getMaterialExtraByMaterialId(id);
Gson gson = new Gson();
// 联系人
List<MaterialContact> materialContactList = materialContactService.listMaterialContactByMaterialId(id);
String materialContacts = gson.toJson(materialContactList);
// 扩展项
List<MaterialExtension> materialExtensionList = materialExtensionService.getMaterialExtensionByMaterialId(id);
String materialExtensions = gson.toJson(materialExtensionList);
// 项目编辑
List<MaterialProjectEditorVO> materialProjectEditorVOList = materialProjectEditorService.listMaterialProjectEditors(id);
String materialProjectEditorVOs = gson.toJson(materialProjectEditorVOList);
// 通知附件信息
List<MaterialNoticeAttachment> materialNoticeAttachmentList = new ArrayList<MaterialNoticeAttachment>(5);
if (null != materialExtra) {
materialNoticeAttachmentList = materialNoticeAttachmentService.getMaterialNoticeAttachmentsByMaterialExtraId(materialExtra.getId());
}
String materialNoticeAttachments = gson.toJson(materialNoticeAttachmentList);
// 通知备注附件信息
List<MaterialNoteAttachment> materialNoteAttachmentList = new ArrayList<MaterialNoteAttachment>(5);
if (null != materialExtra) {
materialNoteAttachmentList = materialNoteAttachmentService.getMaterialNoteAttachmentByMaterialExtraId(materialExtra.getId());
}
String materialNoteAttachments = gson.toJson(materialNoteAttachmentList);
return new MaterialVO(material, director == null ? null : director.getRealname(), mtype, materialExtra, materialContacts, materialExtensions, materialProjectEditorVOs, materialNoticeAttachments, materialNoteAttachments, StringUtil.tentToBinary(material.getPlanPermission()), StringUtil.tentToBinary(material.getProjectPermission()));
}
Aggregations