roo00 6 лет назад
Родитель
Сommit
33c1e99868
18 измененных файлов с 569 добавлено и 101 удалено
  1. 12 2
      o2server/x_cms_assemble_control/src/main/java/com/x/cms/assemble/control/factory/DocumentFactory.java
  2. 131 0
      o2server/x_cms_assemble_control/src/main/java/com/x/cms/assemble/control/jaxrs/appinfo/ActionEraseDocumentWithAppInfo.java
  3. 20 0
      o2server/x_cms_assemble_control/src/main/java/com/x/cms/assemble/control/jaxrs/appinfo/AppInfoAction.java
  4. 2 0
      o2server/x_cms_assemble_control/src/main/java/com/x/cms/assemble/control/jaxrs/appinfo/BaseAction.java
  5. 12 0
      o2server/x_cms_assemble_control/src/main/java/com/x/cms/assemble/control/jaxrs/appinfo/ExceptionIdEmpty.java
  6. 134 0
      o2server/x_cms_assemble_control/src/main/java/com/x/cms/assemble/control/jaxrs/categoryinfo/ActionEraseDocumentWithCategory.java
  7. 20 0
      o2server/x_cms_assemble_control/src/main/java/com/x/cms/assemble/control/jaxrs/categoryinfo/CategoryInfoAction.java
  8. 26 9
      o2server/x_cms_assemble_control/src/main/java/com/x/cms/assemble/control/service/AppInfoService.java
  9. 71 29
      o2server/x_cms_assemble_control/src/main/java/com/x/cms/assemble/control/service/CategoryInfoService.java
  10. 29 8
      o2server/x_cms_assemble_control/src/main/java/com/x/cms/assemble/control/service/DocumentInfoService.java
  11. 33 0
      o2server/x_cms_assemble_control/src/main/java/com/x/cms/assemble/control/service/DocumentInfoServiceAdv.java
  12. 1 1
      o2server/x_file_assemble_control/src/main/java/com/x/file/assemble/control/jaxrs/file/ActionUpload.java
  13. 11 9
      o2server/x_okr_assemble_control/src/main/java/com/x/okr/assemble/control/jaxrs/identity/ActionErrorInfoFilterListNextWithFilter.java
  14. 20 6
      o2server/x_okr_assemble_control/src/main/java/com/x/okr/assemble/control/jaxrs/login/ActionLogin.java
  15. 10 9
      o2server/x_okr_assemble_control/src/main/java/com/x/okr/assemble/control/jaxrs/okrcenterworkinfo/ActionListNextWithFilterAdmin.java
  16. 11 9
      o2server/x_okr_assemble_control/src/main/java/com/x/okr/assemble/control/jaxrs/okrtask/ActionListNextWithFilter.java
  17. 7 0
      o2server/x_okr_assemble_control/src/main/java/com/x/okr/assemble/control/service/OkrUserManagerService.java
  18. 19 19
      o2server/x_processplatform_service_processing/src/main/java/com/x/processplatform/service/processing/ScriptHelperFactory.java

+ 12 - 2
o2server/x_cms_assemble_control/src/main/java/com/x/cms/assemble/control/factory/DocumentFactory.java

@@ -65,14 +65,14 @@ public class DocumentFactory<T> extends AbstractFactory {
 	}
 	
 	//@MethodDescribe("根据ID列示指定分类所有Document信息列表")
-	public List<String> listByCategoryId( String categoryId ) throws Exception {
+	public List<String> listByCategoryId( String categoryId, Integer maxCount ) throws Exception {
 		EntityManager em = this.entityManagerContainer().get( Document.class );
 		CriteriaBuilder cb = em.getCriteriaBuilder();
 		CriteriaQuery<String> cq = cb.createQuery( String.class );
 		Root<Document> root = cq.from( Document.class );
 		Predicate p = cb.equal(root.get( Document_.categoryId ), categoryId );
 		cq.select(root.get( Document_.id)).where(p);
-		return em.createQuery( cq ).setMaxResults(10000).getResultList();
+		return em.createQuery( cq ).setMaxResults(maxCount).getResultList();
 	}
 	
 	//@MethodDescribe("根据ID列示指定分类所有Document信息数量")
@@ -86,6 +86,16 @@ public class DocumentFactory<T> extends AbstractFactory {
 		return em.createQuery(cq).getSingleResult();
 	}
 	
+	public Long countByAppId( String appId ) throws Exception {
+		EntityManager em = this.entityManagerContainer().get( Document.class );
+		CriteriaBuilder cb = em.getCriteriaBuilder();
+		CriteriaQuery<Long> cq = cb.createQuery(Long.class);
+		Root<Document> root = cq.from(Document.class);
+		Predicate p = cb.equal( root.get(Document_.appId), appId );
+		cq.select(cb.count(root)).where(p);
+		return em.createQuery(cq).getSingleResult();
+	}
+	
 	public List<Document> listInReviewDocumentList( Integer maxCount ) throws Exception {
 		EntityManager em = this.entityManagerContainer().get(Document.class);
 		CriteriaBuilder cb = em.getCriteriaBuilder();

+ 131 - 0
o2server/x_cms_assemble_control/src/main/java/com/x/cms/assemble/control/jaxrs/appinfo/ActionEraseDocumentWithAppInfo.java

@@ -0,0 +1,131 @@
+package com.x.cms.assemble.control.jaxrs.appinfo;
+
+import java.util.List;
+
+import javax.servlet.http.HttpServletRequest;
+
+import com.x.base.core.container.EntityManagerContainer;
+import com.x.base.core.container.factory.EntityManagerContainerFactory;
+import com.x.base.core.entity.annotation.CheckRemoveType;
+import com.x.base.core.project.cache.ApplicationCache;
+import com.x.base.core.project.config.StorageMapping;
+import com.x.base.core.project.http.ActionResult;
+import com.x.base.core.project.http.EffectivePerson;
+import com.x.base.core.project.jaxrs.WoId;
+import com.x.base.core.project.logger.Logger;
+import com.x.base.core.project.logger.LoggerFactory;
+import com.x.base.core.project.tools.ListTools;
+import com.x.cms.assemble.control.Business;
+import com.x.cms.assemble.control.DocumentDataHelper;
+import com.x.cms.assemble.control.ThisApplication;
+import com.x.cms.core.entity.AppInfo;
+import com.x.cms.core.entity.Document;
+import com.x.cms.core.entity.FileInfo;
+import com.x.query.core.entity.Item;
+
+public class ActionEraseDocumentWithAppInfo extends BaseAction {
+
+	private static  Logger logger = LoggerFactory.getLogger(ActionEraseDocumentWithAppInfo.class);
+
+	protected ActionResult<Wo> execute(HttpServletRequest request, String id, EffectivePerson effectivePerson) throws Exception {
+		ActionResult<Wo> result = new ActionResult<>();
+		AppInfo appInfo = null;
+		Boolean check = true;
+		
+		if ( id == null || id.isEmpty() ) {
+			check = false;
+			Exception exception = new ExceptionIdEmpty();
+			result.error(exception);
+		}
+		if( check ){
+			try {
+				appInfo = appInfoServiceAdv.get( id );
+				if( appInfo == null ){
+					check = false;
+					Exception exception = new ExceptionAppInfoNotExists( id );
+					result.error( exception );
+				}
+			} catch (Exception e) {
+				check = false;
+				Exception exception = new ExceptionAppInfoProcess( e, "根据指定ID查询应用栏目信息对象时发生异常。ID:" + id );
+				result.error( exception );
+				logger.error( e, effectivePerson, request, null);
+			}
+		}
+
+		if ( check ) {
+			//查询栏目下的文档数量
+			Long count = documentServiceAdv.countByAppId( id );
+			List<String> idsForDelete = null;
+			List<String> allFileInfoIds = null;	
+			Document document = null;
+			Integer queryMaxCount = 5000;
+			Integer whileCount = 0;
+			Integer currentWhileCount = 0;
+			FileInfo fileInfo = null;
+			StorageMapping mapping = null;
+			DocumentDataHelper documentDataHelper = null;
+			
+			if ( count > 0 ) {
+				logger.info(">>>>一共需要删除"+count+"个文档。");
+				result.setCount(count);
+				whileCount =  (int) (count/queryMaxCount + 1);
+				try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
+					Business business = new Business( emc );
+					
+					//循环清除分类下所有的文档信息
+					while( count > 0 && currentWhileCount<=whileCount ) {
+						logger.info(">>>>正在根据appId查询"+count+"个需要删除的文档ID列表。");
+						idsForDelete = documentServiceAdv.listIdsByAppId( id, null, queryMaxCount );
+						if( ListTools.isNotEmpty(  idsForDelete )) {
+							emc.beginTransaction( Document.class );
+							emc.beginTransaction( Item.class );
+							emc.beginTransaction( FileInfo.class );
+							
+							for( String docId : idsForDelete ) {
+								try {
+									document = emc.find( docId, Document.class );
+									//删除与该文档有关的所有数据Item信息
+									documentDataHelper = new DocumentDataHelper( emc, document );
+									documentDataHelper.remove();
+									
+									//删除文档的附件信息
+									allFileInfoIds = business.getFileInfoFactory().listAllByDocument( docId );
+									if( allFileInfoIds != null && !allFileInfoIds.isEmpty() ){
+										for( String fileInfoId : allFileInfoIds ){
+											fileInfo = emc.find( fileInfoId, FileInfo.class );
+											if( fileInfo != null ){
+												if( "ATTACHMENT".equals( fileInfo.getFileType() )){
+													mapping = ThisApplication.context().storageMappings().get( FileInfo.class, fileInfo.getStorage() );
+													fileInfo.deleteContent( mapping );
+												}
+											}
+											emc.remove( fileInfo, CheckRemoveType.all );
+										}
+									}
+									//删除文档信息
+									emc.remove( document, CheckRemoveType.all  );
+								}catch( Exception e ) {
+									e.printStackTrace();
+								}
+							}
+							emc.commit();
+							ApplicationCache.notify( Document.class );
+						}
+						count = documentServiceAdv.countByAppId( id );
+						logger.info(">>>>已经删除"+queryMaxCount+"个文档,还剩下"+count+"个文档需要删除。");
+					}
+				}
+			}
+		}
+		
+		Wo wo = new Wo();
+		wo.setId(id);
+		result.setData(wo);
+		return result;
+	}
+
+	public static class Wo extends WoId {
+
+	}
+}

+ 20 - 0
o2server/x_cms_assemble_control/src/main/java/com/x/cms/assemble/control/jaxrs/appinfo/AppInfoAction.java

@@ -79,6 +79,26 @@ public class AppInfoAction extends StandardJaxrsAction {
 		}
 		return ResponseFactory.getDefaultActionResultResponse(result);
 	}
+	
+	@JaxrsMethodDescribe(value = "根据栏目ID删除所有的信息文档.", action = ActionEraseDocumentWithAppInfo.class)
+	@DELETE
+	@Path("erase/app/{id}")
+	@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
+	@Consumes(MediaType.APPLICATION_JSON)
+	public Response eraseWithAppId(@Context HttpServletRequest request, 
+			@JaxrsParameterDescribe("栏目ID") @PathParam("id") String id) {
+		EffectivePerson effectivePerson = this.effectivePerson(request);
+		ActionResult<ActionEraseDocumentWithAppInfo.Wo> result = new ActionResult<>();
+		try {
+			result = new ActionEraseDocumentWithAppInfo().execute(request, id, effectivePerson );
+		} catch (Exception e) {
+			result = new ActionResult<>();
+			Exception exception = new ExceptionAppInfoProcess(e, "根据栏目ID删除所有的信息文档发生未知异常,ID:" + id);
+			result.error(exception);
+			logger.error(e, effectivePerson, request, null);
+		}
+		return ResponseFactory.getDefaultActionResultResponse(result);
+	}
 
 	@JaxrsMethodDescribe(value = "根据标识获取信息栏目信息对象.", action = ActionGet.class)
 	@GET

+ 2 - 0
o2server/x_cms_assemble_control/src/main/java/com/x/cms/assemble/control/jaxrs/appinfo/BaseAction.java

@@ -16,6 +16,7 @@ import com.x.base.core.project.tools.ListTools;
 import com.x.cms.assemble.control.service.AppDictServiceAdv;
 import com.x.cms.assemble.control.service.AppInfoServiceAdv;
 import com.x.cms.assemble.control.service.CategoryInfoServiceAdv;
+import com.x.cms.assemble.control.service.DocumentInfoServiceAdv;
 import com.x.cms.assemble.control.service.FormServiceAdv;
 import com.x.cms.assemble.control.service.PermissionOperateService;
 import com.x.cms.assemble.control.service.PermissionQueryService;
@@ -37,6 +38,7 @@ public class BaseAction extends StandardJaxrsAction {
     protected ScriptServiceAdv scriptServiceAdv = new ScriptServiceAdv();
 	protected AppDictServiceAdv appDictServiceAdv = new AppDictServiceAdv();
     protected CategoryInfoServiceAdv categoryInfoServiceAdv = new CategoryInfoServiceAdv();
+    protected DocumentInfoServiceAdv documentServiceAdv = new DocumentInfoServiceAdv();
 	protected UserManagerService userManagerService = new UserManagerService();
 	protected PermissionQueryService permissionQueryService = new PermissionQueryService();
 	protected PermissionOperateService permissionOperateService = new PermissionOperateService();

+ 12 - 0
o2server/x_cms_assemble_control/src/main/java/com/x/cms/assemble/control/jaxrs/appinfo/ExceptionIdEmpty.java

@@ -0,0 +1,12 @@
+package com.x.cms.assemble.control.jaxrs.appinfo;
+
+import com.x.base.core.project.exception.PromptException;
+
+class ExceptionIdEmpty extends PromptException {
+
+	private static final long serialVersionUID = 1859164370743532895L;
+
+	ExceptionIdEmpty() {
+		super("分类信息“ID”不能为空。" );
+	}
+}

+ 134 - 0
o2server/x_cms_assemble_control/src/main/java/com/x/cms/assemble/control/jaxrs/categoryinfo/ActionEraseDocumentWithCategory.java

@@ -0,0 +1,134 @@
+package com.x.cms.assemble.control.jaxrs.categoryinfo;
+
+import java.util.List;
+
+import javax.servlet.http.HttpServletRequest;
+
+import com.x.base.core.container.EntityManagerContainer;
+import com.x.base.core.container.factory.EntityManagerContainerFactory;
+import com.x.base.core.entity.annotation.CheckRemoveType;
+import com.x.base.core.project.cache.ApplicationCache;
+import com.x.base.core.project.config.StorageMapping;
+import com.x.base.core.project.http.ActionResult;
+import com.x.base.core.project.http.EffectivePerson;
+import com.x.base.core.project.jaxrs.WoId;
+import com.x.base.core.project.logger.Logger;
+import com.x.base.core.project.logger.LoggerFactory;
+import com.x.base.core.project.tools.ListTools;
+import com.x.cms.assemble.control.Business;
+import com.x.cms.assemble.control.DocumentDataHelper;
+import com.x.cms.assemble.control.ThisApplication;
+import com.x.cms.core.entity.CategoryInfo;
+import com.x.cms.core.entity.Document;
+import com.x.cms.core.entity.FileInfo;
+import com.x.query.core.entity.Item;
+
+public class ActionEraseDocumentWithCategory extends BaseAction {
+
+	private static  Logger logger = LoggerFactory.getLogger(ActionEraseDocumentWithCategory.class);
+
+	protected ActionResult<Wo> execute(HttpServletRequest request, String id, EffectivePerson effectivePerson) throws Exception {
+		ActionResult<Wo> result = new ActionResult<>();
+		CategoryInfo categoryInfo = null;
+		Boolean check = true;
+		
+		if ( id == null || id.isEmpty() ) {
+			check = false;
+			Exception exception = new ExceptionIdEmpty();
+			result.error(exception);
+		}
+		if ( check ) {
+			try {
+				categoryInfo = categoryInfoServiceAdv.get(id);
+			} catch ( Exception e ) {
+				check = false;
+				Exception exception = new ExceptionCategoryInfoProcess(e, "根据ID查询分类信息对象时发生异常。ID:" + id);
+				result.error(exception);
+				logger.error(e, effectivePerson, request, null);
+			}
+		}
+		if ( check ) {
+			if ( categoryInfo == null ) {
+				check = false;
+				Exception exception = new ExceptionCategoryInfoNotExists( id );
+				result.error(exception);
+			}
+		}
+		if ( check ) {
+			//查询分类下的文档数量
+			Long count = documentServiceAdv.countByCategoryId(id);
+			Document document = null;
+			List<String> idsForDelete = null;
+			List<String> allFileInfoIds = null;			
+			Integer queryMaxCount = 5000;
+			Integer whileCount = 0;
+			Integer currentWhileCount = 0;
+			FileInfo fileInfo = null;
+			StorageMapping mapping = null;
+			DocumentDataHelper documentDataHelper = null;
+			
+			if ( count > 0 ) {
+				logger.info(">>>>一共需要删除"+count+"个文档。");
+				result.setCount(count);
+				whileCount =  (int) (count/queryMaxCount + 1);
+				try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
+					Business business = new Business( emc );
+					
+					//循环清除分类下所有的文档信息
+					while( count > 0 && currentWhileCount<=whileCount ) {
+						logger.info(">>>>正在根据categoryId查询"+count+"个需要删除的文档ID列表。");
+						idsForDelete = documentServiceAdv.listIdsByCategoryId( id, queryMaxCount );
+						if( ListTools.isNotEmpty(  idsForDelete )) {
+							
+							emc.beginTransaction( Document.class );
+							emc.beginTransaction( Item.class );
+							emc.beginTransaction( FileInfo.class );
+							
+							for( String docId : idsForDelete ) {
+								try {
+									document = emc.find( docId, Document.class );
+									
+									//删除与该文档有关的所有数据Item信息
+									documentDataHelper = new DocumentDataHelper( emc, document );
+									documentDataHelper.remove();
+									
+									//删除文档的附件信息
+									allFileInfoIds = business.getFileInfoFactory().listAllByDocument( docId );
+									if( allFileInfoIds != null && !allFileInfoIds.isEmpty() ){
+										for( String fileInfoId : allFileInfoIds ){
+											fileInfo = emc.find( fileInfoId, FileInfo.class );
+											if( fileInfo != null ){
+												if( "ATTACHMENT".equals( fileInfo.getFileType() )){
+													mapping = ThisApplication.context().storageMappings().get( FileInfo.class, fileInfo.getStorage() );
+													fileInfo.deleteContent( mapping );
+												}
+											}
+											emc.remove( fileInfo, CheckRemoveType.all );
+										}
+									}
+									//删除文档信息
+									emc.remove( document, CheckRemoveType.all  );
+								}catch( Exception e ) {
+									e.printStackTrace();
+								}
+							}
+							emc.commit();
+							ApplicationCache.notify( Document.class );
+						}
+						count = documentServiceAdv.countByCategoryId( id );
+						logger.info(">>>>已经删除"+queryMaxCount+"个文档,还剩下"+count+"个文档需要删除。");
+					}
+				}
+			}
+		}
+		
+		Wo wo = new Wo();
+		wo.setId(id);
+		result.setData(wo);
+		return result;
+	}
+
+	public static class Wo extends WoId {
+
+	}
+}

+ 20 - 0
o2server/x_cms_assemble_control/src/main/java/com/x/cms/assemble/control/jaxrs/categoryinfo/CategoryInfoAction.java

@@ -118,6 +118,26 @@ public class CategoryInfoAction extends StandardJaxrsAction{
 		return ResponseFactory.getDefaultActionResultResponse(result);
 	}
 	
+	@JaxrsMethodDescribe(value = "根据分类ID删除所有的信息文档.", action = ActionEraseDocumentWithCategory.class)
+	@DELETE
+	@Path("erase/category/{id}")
+	@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
+	@Consumes(MediaType.APPLICATION_JSON)
+	public Response eraseWithCategory(@Context HttpServletRequest request, 
+			@JaxrsParameterDescribe("分类ID") @PathParam("id") String id) {
+		EffectivePerson effectivePerson = this.effectivePerson(request);
+		ActionResult<ActionEraseDocumentWithCategory.Wo> result = new ActionResult<>();
+		try {
+			result = new ActionEraseDocumentWithCategory().execute(request, id, effectivePerson );
+		} catch (Exception e) {
+			result = new ActionResult<>();
+			Exception exception = new ExceptionCategoryInfoProcess(e, "根据分类ID删除所有的信息文档发生未知异常,ID:" + id);
+			result.error(exception);
+			logger.error(e, effectivePerson, request, null);
+		}
+		return ResponseFactory.getDefaultActionResultResponse(result);
+	}
+	
 	@JaxrsMethodDescribe(value = "获取用户有查看访问文章信息的所有分类列表.", action = ActionListWhatICanView_Article.class)
 	@GET
 	@Path("list/view/app/{appId}")

+ 26 - 9
o2server/x_cms_assemble_control/src/main/java/com/x/cms/assemble/control/service/AppInfoService.java

@@ -167,6 +167,11 @@ public class AppInfoService {
 		List<String> document_ids = null;
 		CategoryInfo categoryInfo = null;
 		Document document = null;
+		Long docCount = 0L;
+		Integer totalWhileCount = 0;
+		Integer currenteWhileCount = 0;
+		Integer queryMaxCount = 1000;
+		
 		Business business = new Business(emc);
 		appInfo = emc.find( wrapIn.getId(), AppInfo.class );
 		emc.beginTransaction( AppInfo.class );
@@ -193,16 +198,28 @@ public class AppInfoService {
 						emc.check( categoryInfo, CheckPersistType.all );
 						
 						//对该目录下所有的文档的栏目名称和分类别名进行调整
-						document_ids = business.getDocumentFactory().listByCategoryId( categoryId );
-						if( document_ids != null && !document_ids.isEmpty() ){
-							for( String docId : document_ids ){
-								document = emc.find( docId, Document.class );
-								document.setAppName( categoryInfo.getAppName() );
-								document.setCategoryAlias( categoryInfo.getCategoryAlias() );
-								if( document.getHasIndexPic() == null ){
-									document.setHasIndexPic( false );
+						docCount = business.getDocumentFactory().countByCategoryId( categoryInfo.getId() );
+						if( docCount > 0 ) {
+							totalWhileCount = (int) (docCount/queryMaxCount) + 1;
+							if( totalWhileCount > 0 ) {
+								while( docCount > 0 && currenteWhileCount <= totalWhileCount ) {
+									document_ids = business.getDocumentFactory().listByCategoryId( categoryId, queryMaxCount );
+									if( document_ids != null && !document_ids.isEmpty() ){
+										for( String docId : document_ids ){
+											try {
+												document = emc.find( docId, Document.class );
+												document.setAppName( categoryInfo.getAppName() );
+												document.setCategoryAlias( categoryInfo.getCategoryAlias() );
+												if( document.getHasIndexPic() == null ){
+													document.setHasIndexPic( false );
+												}
+												emc.check( document, CheckPersistType.all );
+											}catch( Exception e ) {
+												e.printStackTrace();
+											}
+										}
+									}
 								}
-								emc.check( document, CheckPersistType.all );
 							}
 						}
 					}

+ 71 - 29
o2server/x_cms_assemble_control/src/main/java/com/x/cms/assemble/control/service/CategoryInfoService.java

@@ -130,6 +130,10 @@ public class CategoryInfoService {
 		String oldCategoryName = null;
 		List<String> document_ids = null;
 		Business business = new Business(emc);
+		Long docCount = 0L;
+		Integer totalWhileCount = 0;
+		Integer currenteWhileCount = 0;
+		Integer queryMaxCount = 1000;
 		
 		if( temp_categoryInfo.getId() == null ){
 			temp_categoryInfo.setId( CategoryInfo.createId() );
@@ -183,16 +187,33 @@ public class CategoryInfoService {
 			if( !oldCategoryName.equals( categoryInfo.getCategoryName() )){
 				emc.beginTransaction( Document.class );
 				//对该目录下所有的文档的栏目名称和分类别名进行调整
-				document_ids = business.getDocumentFactory().listByCategoryId( categoryInfo.getId() );
-				if( document_ids != null && !document_ids.isEmpty() ){
-					for( String docId : document_ids ){
-						document = emc.find( docId, Document.class );
-						document.setAppName( categoryInfo.getAppName() );
-						document.setCategoryAlias( categoryInfo.getCategoryAlias() );						
-						if( document.getHasIndexPic() == null ){
-							document.setHasIndexPic( false );
+				docCount = business.getDocumentFactory().countByCategoryId( categoryInfo.getId() );
+				if( docCount > 0 ) {
+					totalWhileCount = (int) (docCount/queryMaxCount) + 1;
+					if( totalWhileCount > 0 ) {
+						while( docCount > 0 && currenteWhileCount <= totalWhileCount ) {
+							//查询1000个文档进行操作
+							document_ids = business.getDocumentFactory().listByCategoryId( categoryInfo.getId(), queryMaxCount );
+							if( document_ids != null && !document_ids.isEmpty() ){
+								for( String docId : document_ids ){
+									try {
+										document = emc.find( docId, Document.class );
+										document.setAppName( categoryInfo.getAppName() );
+										document.setCategoryAlias( categoryInfo.getCategoryAlias() );						
+										if( document.getHasIndexPic() == null ){
+											document.setHasIndexPic( false );
+										}
+										emc.check( document, CheckPersistType.all );
+									}catch( Exception e ) {
+										e.printStackTrace();
+									}
+								}
+							}
+							//当前循环次数+1
+							currenteWhileCount ++;
+							//重新查询剩余的文档数量
+							docCount = business.getDocumentFactory().countByCategoryId( categoryInfo.getId() );
 						}
-						emc.check( document, CheckPersistType.all );
 					}
 				}
 			}
@@ -259,6 +280,10 @@ public class CategoryInfoService {
 		AppInfo appInfo = null;
 		ViewCategory viewCategory = null;
 		List<Item> dataItems = null;
+		Long docCount = 0L;
+		Integer totalWhileCount = 0;
+		Integer currenteWhileCount = 0;
+		Integer queryMaxCount = 1000;
 		
 		Business business = new Business( emc );
 		emc.beginTransaction( AppInfo.class );
@@ -268,8 +293,7 @@ public class CategoryInfoService {
 		emc.beginTransaction( Document.class );
 		emc.beginTransaction( Item.class );
 		
-		categoryInfo = emc.find( id, CategoryInfo.class );	
-		
+		categoryInfo = emc.find( id, CategoryInfo.class );			
 		categoryExt = emc.find( id, CategoryExt.class );	
 		
 		ids = business.getViewCategoryFactory().listByCategoryId(id);
@@ -291,26 +315,44 @@ public class CategoryInfoService {
 		}
 		
 		//还有文档以及文档权限需要删除
-		ids = business.getDocumentFactory().listByCategoryId( id );
-		if( ids != null && !ids.isEmpty()  ){
-			for( String del_id : ids ){
-				document = emc.find( del_id, Document.class );
-				if( document != null ){
-					//删除与该文档有关的所有数据信息
-					dataItems = business.itemFactory().listWithDocmentWithPath(del_id);
-					if ((!dataItems.isEmpty())) {
-						emc.beginTransaction( Item.class );
-						for ( Item o : dataItems ) {
-							emc.remove(o);
+		docCount = business.getDocumentFactory().countByCategoryId( id );
+		if( docCount > 0 ) {
+			totalWhileCount = (int) (docCount/queryMaxCount) + 1;
+			if( totalWhileCount > 0 ) {
+				while( docCount > 0 && currenteWhileCount <= totalWhileCount ) {
+					//查询1000个文档进行操作
+					ids = business.getDocumentFactory().listByCategoryId( id, queryMaxCount );
+					if( ids != null && !ids.isEmpty()  ){
+						for( String del_id : ids ){
+							document = emc.find( del_id, Document.class );
+							if( document != null ){
+								try {
+									//删除与该文档有关的所有数据信息
+									dataItems = business.itemFactory().listWithDocmentWithPath( del_id );
+									if ((!dataItems.isEmpty())) {
+										emc.beginTransaction( Item.class );
+										for ( Item o : dataItems ) {
+											emc.remove(o);
+										}
+									}
+								}catch( Exception e ) {
+									e.printStackTrace();
+								}
+								
+								//检查是否需要删除热点图片
+								try {
+									ThisApplication.queueDocumentDelete.send( document.getId() );
+								} catch ( Exception e1 ) {
+									e1.printStackTrace();
+								}
+								emc.remove( document );
+							}
 						}
 					}
-					//检查是否需要删除热点图片
-					try {
-						ThisApplication.queueDocumentDelete.send( document.getId() );
-					} catch ( Exception e1 ) {
-						e1.printStackTrace();
-					}
-					emc.remove( document );
+					//当前循环次数+1
+					currenteWhileCount ++;
+					//重新查询剩余的文档数量
+					docCount = business.getDocumentFactory().countByCategoryId( id );
 				}
 			}
 		}

+ 29 - 8
o2server/x_cms_assemble_control/src/main/java/com/x/cms/assemble/control/service/DocumentInfoService.java

@@ -17,13 +17,26 @@ import com.x.query.core.entity.Item;
 
 public class DocumentInfoService {
 
-//	public List<Document> list( EntityManagerContainer emc, List<String> ids ) throws Exception {
-//		if( ids == null || ids.isEmpty() ){
-//			return null;
-//		}
-//		Business business = new Business( emc );
-//		return business.getDocumentFactory().list( ids );
-//	}
+	@SuppressWarnings("unchecked")
+	public List<String> listByCategoryId( EntityManagerContainer emc, String categoryId, Integer maxCount ) throws Exception {
+		if( categoryId == null || categoryId.isEmpty() ){
+			return null;
+		}
+		Business business = new Business( emc );
+		return business.getDocumentFactory().listByCategoryId( categoryId, maxCount );
+	}
+	
+	@SuppressWarnings("unchecked")
+	public List<String> listByAppId( EntityManagerContainer emc, String appId, String documentType, Integer maxCount ) throws Exception {
+		if( appId == null || appId.isEmpty() ){
+			return null;
+		}
+		if( documentType == null || documentType.isEmpty() ){
+			documentType = "全部";
+		}
+		Business business = new Business( emc );
+		return business.getDocumentFactory().listByAppId( appId, documentType, maxCount );
+	}
 	
 	@SuppressWarnings("unchecked")
 	public List<String> listByCategoryId( EntityManagerContainer emc, String categoryId ) throws Exception {
@@ -31,7 +44,7 @@ public class DocumentInfoService {
 			return null;
 		}
 		Business business = new Business( emc );
-		return business.getDocumentFactory().listByCategoryId( categoryId );
+		return business.getDocumentFactory().listByCategoryId( categoryId, 10000 );
 	}
 
 	public Document get(EntityManagerContainer emc, String id) throws Exception {
@@ -49,6 +62,14 @@ public class DocumentInfoService {
 		Business business = new Business( emc );
 		return business.getDocumentFactory().countByCategoryId(categoryId);
 	}
+	
+	public Long countByAppId(EntityManagerContainer emc, String appId) throws Exception {
+		if( appId == null || appId.isEmpty() ){
+			return null;
+		}
+		Business business = new Business( emc );
+		return business.getDocumentFactory().countByAppId(appId);
+	}
 
 	public Document save( EntityManagerContainer emc, Document wrapIn ) throws Exception {
 		if( wrapIn == null ){

+ 33 - 0
o2server/x_cms_assemble_control/src/main/java/com/x/cms/assemble/control/service/DocumentInfoServiceAdv.java

@@ -58,6 +58,28 @@ public class DocumentInfoServiceAdv {
 			throw e;
 		}
 	}
+	
+	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, maxCount );
+		} catch ( Exception e ) {
+			throw e;
+		}
+	}
+	
+	public List<String> listIdsByAppId( String appId, String documentType, Integer maxCount ) throws Exception {
+		if( appId == null || appId.isEmpty() ){
+			throw new Exception("categoryId is null!");
+		}
+		try ( EntityManagerContainer emc = EntityManagerContainerFactory.instance().create() ) {
+			return documentInfoService.listByAppId( emc, appId, documentType, maxCount );
+		} catch ( Exception e ) {
+			throw e;
+		}
+	}
 
 	public Document get( String id ) throws Exception {
 		if( id == null || id.isEmpty() ){
@@ -125,6 +147,17 @@ public class DocumentInfoServiceAdv {
 			throw e;
 		}
 	}
+	
+	public Long countByAppId(String appId ) throws Exception {
+		if( appId == null || appId.isEmpty() ){
+			throw new Exception("appId is null!");
+		}
+		try ( EntityManagerContainer emc = EntityManagerContainerFactory.instance().create() ) {
+			return documentInfoService.countByAppId( emc, appId );
+		} catch ( Exception e ) {
+			throw e;
+		}
+	}
 
 	public List<Document> list(List<String> ids) throws Exception {
 		if( ListTools.isEmpty( ids ) ){

+ 1 - 1
o2server/x_file_assemble_control/src/main/java/com/x/file/assemble/control/jaxrs/file/ActionUpload.java

@@ -46,7 +46,7 @@ class ActionUpload extends BaseAction {
 			String fileName = new String(disposition.getFileName().getBytes(DefaultCharset.charset_iso_8859_1),
 					DefaultCharset.charset);
 			fileName = FilenameUtils.getName(fileName);
-			
+
 			if (StringUtils.isEmpty(FilenameUtils.getExtension(fileName))) {
 				throw new ExceptionEmptyExtension(fileName);
 			}

+ 11 - 9
o2server/x_okr_assemble_control/src/main/java/com/x/okr/assemble/control/jaxrs/identity/ActionErrorInfoFilterListNextWithFilter.java

@@ -53,18 +53,20 @@ public class ActionErrorInfoFilterListNextWithFilter extends BaseAction {
 			}
 		}
 		if (check) {
-			try {
-				if (!okrUserInfoService.getIsOkrManager(currentPerson.getDistinguishedName())) {
+			if( !"xadmin".equalsIgnoreCase( currentPerson.getName() )) {
+				try {
+					if (!okrUserInfoService.getIsOkrManager(currentPerson.getDistinguishedName())) {
+						check = false;
+						Exception exception = new ExceptionInsufficientPermissions(currentPerson.getDistinguishedName(),
+								ThisApplication.OKRMANAGER);
+						result.error(exception);
+					}
+				} catch (Exception e) {
 					check = false;
-					Exception exception = new ExceptionInsufficientPermissions(currentPerson.getDistinguishedName(),
-							ThisApplication.OKRMANAGER);
+					Exception exception = new ExceptionOkrSystemAdminCheck(e, currentPerson.getDistinguishedName());
 					result.error(exception);
+					logger.error(e, currentPerson, request, null);
 				}
-			} catch (Exception e) {
-				check = false;
-				Exception exception = new ExceptionOkrSystemAdminCheck(e, currentPerson.getDistinguishedName());
-				result.error(exception);
-				logger.error(e, currentPerson, request, null);
 			}
 		}
 

+ 20 - 6
o2server/x_okr_assemble_control/src/main/java/com/x/okr/assemble/control/jaxrs/login/ActionLogin.java

@@ -57,18 +57,32 @@ public class ActionLogin extends BaseAction {
 						okrUserCache = setUserLoginIdentity( request, effectivePerson, wrapIn.getLoginIdentity() );
 						result.setData(okrUserCache);
 					} catch (Exception e) {
-						Exception exception = new ExceptionGetOkrUserCache(e, effectivePerson.getDistinguishedName(),
-								wrapIn.getLoginIdentity());
+						Exception exception = new ExceptionGetOkrUserCache(e, effectivePerson.getDistinguishedName(), wrapIn.getLoginIdentity());
 						result.error(exception);
 						logger.error(e, effectivePerson, request, null);
 					}
 				} else {// 用户自己没有传入的身份,查询用户是否有该身份的代理配置(秘书)
 					try {
 						ids = okrConfigSecretaryService.listIdsByLeaderIdentity(effectivePerson.getDistinguishedName(), wrapIn.getLoginIdentity());
-						if (ListTools.isEmpty(ids)) {//用户没有指定身份的代理权限,无法登录系统
-							check = false;
-							Exception exception = new ExceptionUserHasNoProxyIdentity( effectivePerson.getDistinguishedName(), wrapIn.getLoginIdentity());
-							result.error(exception);
+						if (ListTools.isEmpty(ids)) {//用户没有指定身份的代理权限,无法登录系统							
+							//以用户自己的主要身份进行登录
+							identity = okrUserManagerService.getIdentityWithPerson( effectivePerson.getDistinguishedName() );
+							if( StringUtils.isNotEmpty( identity )) {
+								System.out.println( "用户使用身份:" + identity + " 登录系统......" );
+								try {
+									okrUserCache = setUserLoginIdentity( request, effectivePerson, identity );
+									result.setData(okrUserCache);
+								} catch (Exception e) {
+									check = false;
+									Exception exception = new ExceptionGetOkrUserCache(e, effectivePerson.getDistinguishedName(), wrapIn.getLoginIdentity());
+									result.error(exception);
+									logger.error(e, effectivePerson, request, null);
+								}
+							}else {
+								check = false;
+								Exception exception = new ExceptionUserHasNoProxyIdentity( effectivePerson.getDistinguishedName(), wrapIn.getLoginIdentity());
+								result.error(exception);
+							}							
 						} else {// 顺利查询到身份代理配置信息,向cache里新增用户相关信息
 							okrUserCache = setUserLoginIdentity(request, effectivePerson, wrapIn.getLoginIdentity());
 							result.setData(okrUserCache);

+ 10 - 9
o2server/x_okr_assemble_control/src/main/java/com/x/okr/assemble/control/jaxrs/okrcenterworkinfo/ActionListNextWithFilterAdmin.java

@@ -53,18 +53,19 @@ public class ActionListNextWithFilterAdmin extends BaseAction {
 		}
 
 		if (check) {
-			try {
-				if (!okrUserInfoService.getIsOkrManager(currentPerson.getDistinguishedName())) {
+			if( !"xadmin".equalsIgnoreCase( currentPerson.getName() )) {
+				try {
+					if (!okrUserInfoService.getIsOkrManager(currentPerson.getDistinguishedName())) {
+						check = false;
+						Exception exception = new ExceptionInsufficientPermissions(currentPerson.getDistinguishedName(), ThisApplication.OKRMANAGER);
+						result.error(exception);
+					}
+				} catch (Exception e) {
 					check = false;
-					Exception exception = new ExceptionInsufficientPermissions(currentPerson.getDistinguishedName(),
-							ThisApplication.OKRMANAGER);
+					Exception exception = new ExceptionOkrSystemAdminCheck(e, currentPerson.getDistinguishedName());
 					result.error(exception);
+					logger.error(e, currentPerson, request, null);
 				}
-			} catch (Exception e) {
-				check = false;
-				Exception exception = new ExceptionOkrSystemAdminCheck(e, currentPerson.getDistinguishedName());
-				result.error(exception);
-				logger.error(e, currentPerson, request, null);
 			}
 		}
 

+ 11 - 9
o2server/x_okr_assemble_control/src/main/java/com/x/okr/assemble/control/jaxrs/okrtask/ActionListNextWithFilter.java

@@ -54,19 +54,21 @@ public class ActionListNextWithFilter extends BaseAction {
 			logger.error(e, effectivePerson, request, null);
 		}
 
-		try {
-			if (!okrUserInfoService.getIsOkrManager(effectivePerson.getDistinguishedName())) {
+		if( !"xadmin".equalsIgnoreCase( effectivePerson.getName() )) {
+			try {
+				if (!okrUserInfoService.getIsOkrManager(effectivePerson.getDistinguishedName())) {
+					check = false;
+					Exception exception = new ExceptionInsufficientPermissions(effectivePerson.getDistinguishedName(), ThisApplication.OKRMANAGER);
+					result.error(exception);
+				}
+			} catch (Exception e) {
 				check = false;
-				Exception exception = new ExceptionInsufficientPermissions(effectivePerson.getDistinguishedName(),
-						ThisApplication.OKRMANAGER);
+				Exception exception = new ExceptionOkrSystemAdminCheck(e, effectivePerson.getDistinguishedName());
 				result.error(exception);
+				logger.error(e, effectivePerson, request, null);
 			}
-		} catch (Exception e) {
-			check = false;
-			Exception exception = new ExceptionOkrSystemAdminCheck(e, effectivePerson.getDistinguishedName());
-			result.error(exception);
-			logger.error(e, effectivePerson, request, null);
 		}
+		
 
 		if (check) {
 			if (wrapIn.getFilterLikeContent() != null && !wrapIn.getFilterLikeContent().isEmpty()) {

+ 7 - 0
o2server/x_okr_assemble_control/src/main/java/com/x/okr/assemble/control/service/OkrUserManagerService.java

@@ -6,6 +6,7 @@ import com.x.base.core.container.EntityManagerContainer;
 import com.x.base.core.container.factory.EntityManagerContainerFactory;
 import com.x.base.core.project.organization.Person;
 import com.x.base.core.project.organization.Unit;
+import com.x.base.core.project.tools.ListTools;
 import com.x.okr.assemble.control.Business;
 
 /**
@@ -173,6 +174,12 @@ public class OkrUserManagerService {
 		try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
 			business = new Business(emc);
 			identities = business.organization().identity().listWithPerson( personName );
+			System.out.println(">>>>>>>>>>>loginIdentity:" + loginIdentity );
+			if( ListTools.isNotEmpty( identities )) {
+				for( String identity : identities ) {
+					System.out.println(">>>>>>>>>>>identity:" + identity );
+				}
+			}			
 			if( identities.contains( loginIdentity )){
 				return true;
 			}

+ 19 - 19
o2server/x_processplatform_service_processing/src/main/java/com/x/processplatform/service/processing/ScriptHelperFactory.java

@@ -63,25 +63,25 @@ public class ScriptHelperFactory {
 	 * @return
 	 * @throws Exception
 	 */
-	public static ScriptHelper create(Business business, Work work, Data data, Activity activity,
-			BindingPair... bindingPairs) throws Exception {
-		WorkContext workContext = new WorkContext(business, work, activity);
-		Map<String, Object> map = new HashMap<>();
-		map.put(ScriptingEngine.BINDINGNAME_WORKCONTEXT, workContext);
-		map.put(ScriptingEngine.BINDINGNAME_DATA, data);
-		map.put(ScriptingEngine.BINDINGNAME_ORGANIZATION, new Organization(ThisApplication.context()));
-		map.put(ScriptingEngine.BINDINGNAME_WEBSERVICESCLIENT, new WebservicesClient());
-		map.put(ScriptingEngine.BINDINGNAME_DICTIONARY,
-				new ApplicationDictHelper(business.entityManagerContainer(), work.getApplication()));
-		map.put(ScriptingEngine.BINDINGNAME_APPLICATIONS, ThisApplication.context().applications());
-		for (BindingPair o : bindingPairs) {
-			map.put(o.getName(), o.getValue());
-		}
-		ScriptHelper sh = new ScriptHelper(business, map, initialScriptText);
-		return sh;
-	}
+//	public static ScriptHelper create(Business business, Work work, Data data, Activity activity,
+//			BindingPair... bindingPairs) throws Exception {
+//		WorkContext workContext = new WorkContext(business, work, activity);
+//		Map<String, Object> map = new HashMap<>();
+//		map.put(ScriptingEngine.BINDINGNAME_WORKCONTEXT, workContext);
+//		map.put(ScriptingEngine.BINDINGNAME_DATA, data);
+//		map.put(ScriptingEngine.BINDINGNAME_ORGANIZATION, new Organization(ThisApplication.context()));
+//		map.put(ScriptingEngine.BINDINGNAME_WEBSERVICESCLIENT, new WebservicesClient());
+//		map.put(ScriptingEngine.BINDINGNAME_DICTIONARY,
+//				new ApplicationDictHelper(business.entityManagerContainer(), work.getApplication()));
+//		map.put(ScriptingEngine.BINDINGNAME_APPLICATIONS, ThisApplication.context().applications());
+//		for (BindingPair o : bindingPairs) {
+//			map.put(o.getName(), o.getValue());
+//		}
+//		ScriptHelper sh = new ScriptHelper(business, map, initialScriptText);
+//		return sh;
+//	}
 
-	public static ScriptHelper create(Business business, Work work, Data data, Activity activity, Task task,
+	public static ScriptHelper createWithTask(Business business, Work work, Data data, Activity activity, Task task,
 			BindingPair... bindingPairs) throws Exception {
 		WorkContext workContext = new WorkContext(business, work, activity, task);
 		Map<String, Object> map = new HashMap<>();
@@ -99,7 +99,7 @@ public class ScriptHelperFactory {
 		return sh;
 	}
 
-	public static ScriptHelper create(Business business, Work work, Data data, Activity activity,
+	public static ScriptHelper createWithTaskCompleted(Business business, Work work, Data data, Activity activity,
 			TaskCompleted taskCompleted, BindingPair... bindingPairs) throws Exception {
 		WorkContext workContext = new WorkContext(business, work, activity, taskCompleted);
 		Map<String, Object> map = new HashMap<>();