Search in sources :

Example 1 with MaterialVO

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()));
}
Also used : MaterialVO(com.bc.pmpheep.back.vo.MaterialVO) MaterialNoticeAttachment(com.bc.pmpheep.back.po.MaterialNoticeAttachment) PmphUser(com.bc.pmpheep.back.po.PmphUser) MaterialNoteAttachment(com.bc.pmpheep.back.po.MaterialNoteAttachment) MaterialContact(com.bc.pmpheep.back.po.MaterialContact) ArrayList(java.util.ArrayList) Gson(com.google.gson.Gson) MaterialExtension(com.bc.pmpheep.back.po.MaterialExtension) CheckedServiceException(com.bc.pmpheep.service.exception.CheckedServiceException) Material(com.bc.pmpheep.back.po.Material) MaterialProjectEditorVO(com.bc.pmpheep.back.vo.MaterialProjectEditorVO) MaterialType(com.bc.pmpheep.back.po.MaterialType) MaterialExtra(com.bc.pmpheep.back.po.MaterialExtra)

Aggregations

Material (com.bc.pmpheep.back.po.Material)1 MaterialContact (com.bc.pmpheep.back.po.MaterialContact)1 MaterialExtension (com.bc.pmpheep.back.po.MaterialExtension)1 MaterialExtra (com.bc.pmpheep.back.po.MaterialExtra)1 MaterialNoteAttachment (com.bc.pmpheep.back.po.MaterialNoteAttachment)1 MaterialNoticeAttachment (com.bc.pmpheep.back.po.MaterialNoticeAttachment)1 MaterialType (com.bc.pmpheep.back.po.MaterialType)1 PmphUser (com.bc.pmpheep.back.po.PmphUser)1 MaterialProjectEditorVO (com.bc.pmpheep.back.vo.MaterialProjectEditorVO)1 MaterialVO (com.bc.pmpheep.back.vo.MaterialVO)1 CheckedServiceException (com.bc.pmpheep.service.exception.CheckedServiceException)1 Gson (com.google.gson.Gson)1 ArrayList (java.util.ArrayList)1