|
|
@@ -11,8 +11,8 @@ import com.x.base.core.container.factory.EntityManagerContainerFactory;
|
|
|
import com.x.base.core.entity.annotation.CheckPersistType;
|
|
|
import com.x.base.core.entity.dataitem.DataItemConverter;
|
|
|
import com.x.base.core.entity.dataitem.ItemCategory;
|
|
|
+import com.x.base.core.project.exception.ExceptionWhen;
|
|
|
import com.x.base.core.project.gson.XGsonBuilder;
|
|
|
-import com.x.base.core.project.http.EffectivePerson;
|
|
|
import com.x.base.core.project.tools.ListTools;
|
|
|
import com.x.cms.assemble.control.Business;
|
|
|
import com.x.cms.assemble.control.DocumentDataHelper;
|
|
|
@@ -25,8 +25,7 @@ import com.x.cms.core.entity.content.Data;
|
|
|
import com.x.query.core.entity.Item;
|
|
|
|
|
|
/**
|
|
|
- * 对文档信息进行管理的服务类(高级)
|
|
|
- * 高级服务器可以利用Service完成事务控制
|
|
|
+ * 对文档信息进行管理的服务类
|
|
|
*
|
|
|
* @author O2LEE
|
|
|
*/
|
|
|
@@ -34,55 +33,67 @@ public class DocumentInfoServiceAdv {
|
|
|
private DocumentInfoService documentInfoService = new DocumentInfoService();
|
|
|
private PermissionOperateService permissionService = new PermissionOperateService();
|
|
|
|
|
|
- public List<Document> listByCategoryId( String categoryId ) throws Exception {
|
|
|
+ /**
|
|
|
+ * 根据指定的信息分类ID,获取分类下所有的信息文档对象
|
|
|
+ * @param categoryId 信息分类ID
|
|
|
+ * @param maxCount 查询最大条目数量
|
|
|
+ * @return
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ public List<Document> listByCategoryId( String categoryId, Integer maxCount ) throws Exception {
|
|
|
if( categoryId == null || categoryId.isEmpty() ){
|
|
|
throw new Exception("categoryId is null!");
|
|
|
}
|
|
|
List<String> ids = null;
|
|
|
try ( EntityManagerContainer emc = EntityManagerContainerFactory.instance().create() ) {
|
|
|
- ids = documentInfoService.listByCategoryId( emc, categoryId );
|
|
|
+ ids = documentInfoService.listByCategoryId( emc, categoryId, maxCount );
|
|
|
return emc.list( Document.class, ids );
|
|
|
-// return documentInfoService.list( emc, ids );
|
|
|
} catch ( Exception e ) {
|
|
|
throw e;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public List<String> listIdsByCategoryId( String categoryId ) throws Exception {
|
|
|
+ /**
|
|
|
+ * 根据指定的信息分类ID,获取分类下所有的文档ID列表
|
|
|
+ * @param categoryId 信息分类ID
|
|
|
+ * @param maxCount 查询最大条目数量
|
|
|
+ * @return
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ public List<String> listIdsByCategoryId( String categoryId, Integer maxCount ) throws Exception {
|
|
|
if( categoryId == null || categoryId.isEmpty() ){
|
|
|
throw new Exception("categoryId is null!");
|
|
|
}
|
|
|
try ( EntityManagerContainer emc = EntityManagerContainerFactory.instance().create() ) {
|
|
|
- return documentInfoService.listByCategoryId( emc, categoryId );
|
|
|
+ return documentInfoService.listByCategoryId( emc, categoryId, maxCount );
|
|
|
} catch ( Exception e ) {
|
|
|
throw e;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 根据ID获取指定信息文档对象
|
|
|
+ * @param id 信息文档ID
|
|
|
+ * @return
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
public Document get( String id ) throws Exception {
|
|
|
if( id == null || id.isEmpty() ){
|
|
|
throw new Exception("id is null!");
|
|
|
}
|
|
|
try ( EntityManagerContainer emc = EntityManagerContainerFactory.instance().create() ) {
|
|
|
- return documentInfoService.get( emc, id );
|
|
|
- } catch ( Exception e ) {
|
|
|
- throw e;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- public Document view( String id, EffectivePerson currentPerson ) throws Exception {
|
|
|
- if( id == null || id.isEmpty() ){
|
|
|
- throw new Exception("id is null!");
|
|
|
- }
|
|
|
- Document document = null;
|
|
|
- try ( EntityManagerContainer emc = EntityManagerContainerFactory.instance().create() ) {
|
|
|
- document = emc.find( id, Document.class );
|
|
|
- return document;
|
|
|
+ return emc.find( id, Document.class, ExceptionWhen.none );
|
|
|
} catch ( Exception e ) {
|
|
|
throw e;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 根据文档信息对象查询该文档信息的数据对象
|
|
|
+ * @param document 文档信息
|
|
|
+ * @return
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
public Data getDocumentData( Document document ) throws Exception {
|
|
|
if( document == null ){
|
|
|
throw new Exception("document is null!");
|
|
|
@@ -115,6 +126,12 @@ public class DocumentInfoServiceAdv {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 根据信息分类ID,获取分类下所有文档的数量
|
|
|
+ * @param categoryId 信息分类ID
|
|
|
+ * @return
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
public Long countByCategoryId(String categoryId ) throws Exception {
|
|
|
if( categoryId == null || categoryId.isEmpty() ){
|
|
|
throw new Exception("categoryId is null!");
|
|
|
@@ -126,18 +143,30 @@ public class DocumentInfoServiceAdv {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 根据ID列表列示指定ID的文档信息
|
|
|
+ * @param ids 信息文档ID列表
|
|
|
+ * @return
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
public List<Document> list(List<String> ids) throws Exception {
|
|
|
if( ListTools.isEmpty( ids ) ){
|
|
|
throw new Exception("ids is empty!");
|
|
|
}
|
|
|
try ( EntityManagerContainer emc = EntityManagerContainerFactory.instance().create() ) {
|
|
|
return emc.list( Document.class, ids );
|
|
|
-// return documentInfoService.list(emc, ids);
|
|
|
} catch ( Exception e ) {
|
|
|
throw e;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 保存文档信息
|
|
|
+ * @param document 文档信息对象
|
|
|
+ * @param jsonElement 文档数据对象
|
|
|
+ * @return
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
public Document save( Document document, JsonElement jsonElement ) throws Exception {
|
|
|
if( document == null ){
|
|
|
throw new Exception("document is null!");
|
|
|
@@ -145,8 +174,8 @@ public class DocumentInfoServiceAdv {
|
|
|
|
|
|
try ( EntityManagerContainer emc = EntityManagerContainerFactory.instance().create() ) {
|
|
|
document = documentInfoService.save( emc, document );
|
|
|
- //如果有数据信息,则保存数据信息
|
|
|
|
|
|
+ //如果有数据信息, 则保存数据信息
|
|
|
DocumentDataHelper documentDataHelper = new DocumentDataHelper( emc, document );
|
|
|
if( jsonElement != null ) {
|
|
|
documentDataHelper.update(jsonElement);
|
|
|
@@ -164,6 +193,12 @@ public class DocumentInfoServiceAdv {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 向文档数据表同步文档的最新数据信息
|
|
|
+ * @param document 文档信息对象(包含数据)
|
|
|
+ * @return
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
public Document refreshDocInfoData( Document document ) throws Exception {
|
|
|
if( document == null ){
|
|
|
throw new Exception("document is null!");
|
|
|
@@ -182,10 +217,27 @@ public class DocumentInfoServiceAdv {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 根据指定的条件获取符合条件的文档信息数量
|
|
|
+ * @param viewAbleCategoryIds 用于过滤的可见信息分类ID列表
|
|
|
+ * @param title 用于过滤的文档标题
|
|
|
+ * @param publisherList 用于过滤的发布者列表
|
|
|
+ * @param createDateList 用于过滤的信息创建日期列表
|
|
|
+ * @param publishDateList 用于过滤的信息发布日期列表
|
|
|
+ * @param statusList 用于过滤的信息文档状态列表
|
|
|
+ * @param documentType 用于过滤的信息类别
|
|
|
+ * @param creatorUnitNameList 用于过滤的创建者所属组织名称列表
|
|
|
+ * @param importBatchNames 用于过滤的导入数据批次名称列表
|
|
|
+ * @param personNames 用于过滤权限的人员姓名列表
|
|
|
+ * @param unitNames 用于过滤权限的人员所属组织名称列表
|
|
|
+ * @param groupNames 用于过滤权限的群组名称列表
|
|
|
+ * @param manager 查询者身份是否为管理员权限
|
|
|
+ * @return
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
public Long countWithCondition( List<String> viewAbleCategoryIds, String title, List<String> publisherList,
|
|
|
List<String> createDateList, List<String> publishDateList, List<String> statusList, String documentType,
|
|
|
- List<String> creatorUnitNameList,
|
|
|
- List<String> importBatchNames, List<String> personNames,
|
|
|
+ List<String> creatorUnitNameList, List<String> importBatchNames, List<String> personNames,
|
|
|
List<String> unitNames, List<String> groupNames, Boolean manager) throws Exception {
|
|
|
if( ListTools.isEmpty( viewAbleCategoryIds ) && !manager ){
|
|
|
return 0L;
|
|
|
@@ -198,6 +250,28 @@ public class DocumentInfoServiceAdv {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 根据指定的条件获取符合条件的下一页文档信息列表
|
|
|
+ * @param id 上一页最后一条信息ID,如果为第一页,则传入"(0)"
|
|
|
+ * @param count 一页查询的条目数量
|
|
|
+ * @param viewAbleCategoryIds 用于过滤的可见信息分类ID列表
|
|
|
+ * @param title 用于过滤的文档标题
|
|
|
+ * @param publisherList 用于过滤的发布者列表
|
|
|
+ * @param createDateList 用于过滤的信息创建日期列表
|
|
|
+ * @param publishDateList 用于过滤的信息发布日期列表
|
|
|
+ * @param statusList 用于过滤的信息文档状态列表
|
|
|
+ * @param documentType 用于过滤的信息类别
|
|
|
+ * @param creatorUnitNameList 用于过滤的创建者所属组织名称列表
|
|
|
+ * @param importBatchNames 用于过滤的导入数据批次名称列表
|
|
|
+ * @param personNames 用于过滤权限的人员姓名列表
|
|
|
+ * @param unitNames 用于过滤权限的人员所属组织名称列表
|
|
|
+ * @param groupNames 用于过滤权限的群组名称列表
|
|
|
+ * @param orderField 用于查询结果排序的属性名称
|
|
|
+ * @param order 查询结果的排序方式
|
|
|
+ * @param manager 查询者身份是否为管理员权限
|
|
|
+ * @return
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
public List<Document> listNextWithCondition(String id, Integer count, List<String> viewAbleCategoryIds, String title, List<String> publisherList,
|
|
|
List<String> createDateList, List<String> publishDateList, List<String> statusList, String documentType,
|
|
|
List<String> creatorUnitNameList, List<String> importBatchNames, List<String> personNames,
|
|
|
@@ -219,6 +293,14 @@ public class DocumentInfoServiceAdv {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 根据指定的信息分类ID列表以及文档类别,列示指定人员(根据creatorPerson匹配)草稿状态的文档信息列表
|
|
|
+ * @param name 指定人员名称
|
|
|
+ * @param categoryIdList 指定信息分类ID列表
|
|
|
+ * @param documentType 指定信息类别
|
|
|
+ * @return
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
public List<Document> listMyDraft( String name, List<String> categoryIdList, String documentType ) throws Exception {
|
|
|
if( name == null || name.isEmpty()){
|
|
|
throw new Exception("name is null!");
|
|
|
@@ -233,6 +315,13 @@ public class DocumentInfoServiceAdv {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 从文档中获取指定数据根路径为path0的数据
|
|
|
+ * @param document 文档信息对象
|
|
|
+ * @param path0 path0名称
|
|
|
+ * @return
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
public Item getDataWithDocIdWithPath(Document document, String path0 ) throws Exception {
|
|
|
if( path0 == null || path0.isEmpty()){
|
|
|
throw new Exception("path0 is null!");
|
|
|
@@ -248,17 +337,17 @@ public class DocumentInfoServiceAdv {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 普通用戶的查詢,帶權限查詢
|
|
|
- * @param title
|
|
|
- * @param appIdList
|
|
|
- * @param categoryIdList
|
|
|
- * @param publisherList
|
|
|
- * @param createDateList
|
|
|
- * @param publishDateList
|
|
|
- * @param statusList
|
|
|
- * @param personName
|
|
|
- * @param viewableCategoryIds
|
|
|
- * @param maxResultCount
|
|
|
+ * 普通用戶的查詢(帶權限查詢)
|
|
|
+ * @param title 用于过滤的文档标题
|
|
|
+ * @param appIdList 用于过滤的信息栏目ID列表
|
|
|
+ * @param categoryIdList 用于过滤的信息分类ID列表
|
|
|
+ * @param publisherList 用于过滤的发布者列表
|
|
|
+ * @param createDateList 用于过滤的信息创建日期列表
|
|
|
+ * @param publishDateList 用于过滤的信息发布日期列表
|
|
|
+ * @param statusList 用于过滤的信息文档状态列表
|
|
|
+ * @param personName 用于过滤权限的人员名称
|
|
|
+ * @param viewableCategoryIds 用于过滤的可见信息分类ID列表
|
|
|
+ * @param maxResultCount 查询最大文档数量
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
@@ -285,17 +374,17 @@ public class DocumentInfoServiceAdv {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 管理員的查詢,跨越權限
|
|
|
- * @param title
|
|
|
- * @param appIdList
|
|
|
- * @param appAliasList
|
|
|
- * @param categoryIdList
|
|
|
- * @param categoryAliasList
|
|
|
- * @param publisherList
|
|
|
- * @param createDateList
|
|
|
- * @param publishDateList
|
|
|
- * @param statusList
|
|
|
- * @param maxResultCount
|
|
|
+ * 管理員的查詢(跨越權限)
|
|
|
+ * @param title 用于过滤的文档标题
|
|
|
+ * @param appIdList 用于过滤的信息栏目ID列表
|
|
|
+ * @param appAliasList 用于过滤的信息栏目别外列表
|
|
|
+ * @param categoryIdList 用于过滤的信息分类ID列表
|
|
|
+ * @param categoryAliasList 用于过滤的信息分类别名列表
|
|
|
+ * @param publisherList 用于过滤的发布者列表
|
|
|
+ * @param createDateList 用于过滤的信息创建日期列表
|
|
|
+ * @param publishDateList 用于过滤的信息发布日期列表
|
|
|
+ * @param statusList 用于过滤的信息文档状态列表
|
|
|
+ * @param maxResultCount 查询最大文档数量
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
@@ -310,6 +399,11 @@ public class DocumentInfoServiceAdv {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 根据信息文档对象,向信息数据Item对象里补充distributeFactor、bundle和itemCategory信息
|
|
|
+ * @param o 信息数据对象
|
|
|
+ * @param document 信息对象
|
|
|
+ */
|
|
|
void fill(Item o, Document document) {
|
|
|
/** 将DateItem与Document放在同一个分区 */
|
|
|
o.setDistributeFactor(document.getDistributeFactor());
|
|
|
@@ -317,6 +411,12 @@ public class DocumentInfoServiceAdv {
|
|
|
o.setItemCategory(ItemCategory.cms);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 获取信息被阅读次数
|
|
|
+ * @param id 信息文档ID
|
|
|
+ * @return
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
public Long getViewCount( String id ) throws Exception {
|
|
|
if( id == null || id.isEmpty() ){
|
|
|
throw new Exception("id is null!");
|
|
|
@@ -332,7 +432,7 @@ public class DocumentInfoServiceAdv {
|
|
|
|
|
|
/**
|
|
|
* 根据组织好的document对象更新数据库中文档的权限信息
|
|
|
- * @param document
|
|
|
+ * @param document 信息文档对象
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
public void updateAllPermission(Document document) throws Exception {
|
|
|
@@ -363,9 +463,9 @@ public class DocumentInfoServiceAdv {
|
|
|
|
|
|
/**
|
|
|
* 根据读者作者列表更新文档所有的权限信息
|
|
|
- * @param docId
|
|
|
- * @param readerList
|
|
|
- * @param authorList
|
|
|
+ * @param docId 信息文档ID
|
|
|
+ * @param readerList 信息读者权限列表
|
|
|
+ * @param authorList 信息作者权限列表(允许修改信息的人员)
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
public void refreshDocumentPermission( String docId, List<PermissionInfo> readerList, List<PermissionInfo> authorList ) throws Exception {
|
|
|
@@ -377,8 +477,8 @@ public class DocumentInfoServiceAdv {
|
|
|
|
|
|
/**
|
|
|
* 根据组织好的权限信息列表更新指定文档的权限信息
|
|
|
- * @param docId
|
|
|
- * @param permissionList
|
|
|
+ * @param docId 信息文档ID
|
|
|
+ * @param permissionList 信息权限列表
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
public void refreshDocumentPermission(String docId, List<PermissionInfo> permissionList) throws Exception {
|
|
|
@@ -390,8 +490,8 @@ public class DocumentInfoServiceAdv {
|
|
|
|
|
|
/**
|
|
|
* 变更一个文档的分类信息
|
|
|
- * @param document
|
|
|
- * @param categoryInfo
|
|
|
+ * @param document 信息文档对象
|
|
|
+ * @param categoryInfo 新的信息分类对象
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
public Boolean changeCategory( Document document, CategoryInfo categoryInfo) throws Exception {
|
|
|
@@ -432,6 +532,13 @@ public class DocumentInfoServiceAdv {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 根据文档ID列表,批量修改数据
|
|
|
+ * @param docIds 文档ID
|
|
|
+ * @param dataChanges 数据修改信息
|
|
|
+ * @return
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
public Wo changeData(List<String> docIds, List<WiDataChange> dataChanges) throws Exception {
|
|
|
if( ListTools.isEmpty( docIds )){
|
|
|
throw new Exception("docIds is empty!");
|