Browse Source

teamwork统计相关服务_预留

luojing 5 years ago
parent
commit
f6d5a5a21b

+ 184 - 0
o2server/x_teamwork_assemble_control/src/main/java/com/x/teamwork/assemble/control/factory/StatisticFactory.java

@@ -0,0 +1,184 @@
+package com.x.teamwork.assemble.control.factory;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.persistence.EntityManager;
+import javax.persistence.criteria.CriteriaBuilder;
+import javax.persistence.criteria.CriteriaQuery;
+import javax.persistence.criteria.Predicate;
+import javax.persistence.criteria.Root;
+
+import org.apache.commons.lang3.StringUtils;
+
+import com.x.base.core.project.exception.ExceptionWhen;
+import com.x.teamwork.assemble.control.AbstractFactory;
+import com.x.teamwork.assemble.control.Business;
+import com.x.teamwork.core.entity.Task;
+import com.x.teamwork.core.entity.TaskDetail;
+import com.x.teamwork.core.entity.Task_;
+
+
+public class StatisticFactory extends AbstractFactory {
+
+	public StatisticFactory( Business business ) throws Exception {
+		super(business);
+	}
+
+	/**
+	 * 获取指定Id的Task实体信息对象
+	 * @param id
+	 * @return
+	 * @throws Exception
+	 */
+	public Task get( String id ) throws Exception {
+		return this.entityManagerContainer().find( id, Task.class, ExceptionWhen.none );
+	}
+	
+	/**
+	 * 获取指定Id的TaskDetail实体信息对象
+	 * @param id
+	 * @return
+	 * @throws Exception
+	 */
+	public TaskDetail getDetail( String id ) throws Exception {
+		return this.entityManagerContainer().find( id, TaskDetail.class, ExceptionWhen.none );
+	}
+	
+	/**
+	 * 列示指定Id的Task实体信息列表
+	 * @param ids
+	 * @return
+	 * @throws Exception
+	 */
+	public List<Task> list( List<String> ids ) throws Exception {
+		if( ids == null || ids.size() == 0 ){
+			return new ArrayList<Task>();
+		}
+		EntityManager em = this.entityManagerContainer().get(Task.class);
+		CriteriaBuilder cb = em.getCriteriaBuilder();
+		CriteriaQuery<Task> cq = cb.createQuery(Task.class);
+		Root<Task> root = cq.from(Task.class);
+		Predicate p = root.get(Task_.id).in(ids);
+		cq.orderBy( cb.asc( root.get( Task_.createTime ) ) );
+		return em.createQuery(cq.where(p)).getResultList();
+	}
+	
+	/**
+	 * 根据类别列示Task实体ID信息列表
+	 * @param application
+	 * @return
+	 * @throws Exception
+	 */
+	public List<String> listByProject( String projectId ) throws Exception {
+		if( StringUtils.isEmpty( projectId ) ){
+			throw new Exception("projectId can not be empty!");
+		}
+		EntityManager em = this.entityManagerContainer().get(Task.class);
+		CriteriaBuilder cb = em.getCriteriaBuilder();
+		CriteriaQuery<String> cq = cb.createQuery(String.class);
+		Root<Task> root = cq.from(Task.class);
+		Predicate p = cb.equal( root.get(Task_.project), projectId );
+		cq.select( root.get(Task_.id ) );
+		return em.createQuery(cq.where(p)).getResultList();
+	}
+	
+	/**
+	 * 根据类别列示Task实体ID信息列表
+	 * @param projectId
+	 * @return
+	 * @throws Exception
+	 */
+	public List<Task> listAllTasksByProject( String projectId ) throws Exception {
+		if( StringUtils.isEmpty( projectId ) ){
+			throw new Exception("projectId can not be empty!");
+		}
+		EntityManager em = this.entityManagerContainer().get(Task.class);
+		CriteriaBuilder cb = em.getCriteriaBuilder();
+		CriteriaQuery<Task> cq = cb.createQuery(Task.class);
+		Root<Task> root = cq.from(Task.class);
+		Predicate p = cb.equal( root.get(Task_.project), projectId );
+		return em.createQuery(cq.where(p)).getResultList(); 
+	}
+	
+	/**
+	 * 查询未review的工作任务信息
+	 * @param maxCount
+	 * @return
+	 * @throws Exception
+	 */
+	public List<Task> listUnReviewTask(int maxCount) throws Exception {
+		if( maxCount == 0  ){
+			maxCount = 100;
+		}
+		EntityManager em = this.entityManagerContainer().get(Task.class);
+		CriteriaBuilder cb = em.getCriteriaBuilder();
+		CriteriaQuery<Task> cq = cb.createQuery(Task.class);
+		Root<Task> root = cq.from(Task.class);
+		Predicate p = cb.or( cb.isNull(root.get(Task_.reviewed )), cb.isFalse( root.get(Task_.reviewed )));
+		cq.orderBy( cb.asc( root.get( Task_.updateTime ) ) );
+		return em.createQuery(cq.where(p)).getResultList();
+	}
+
+	
+	/**
+	 * 根据类别列示Task实体信息列表
+	 * @param application
+	 * @return
+	 * @throws Exception
+	 */
+	public List<String> listByParent( String pid) throws Exception {
+		if( StringUtils.isEmpty( pid ) ){
+			throw new Exception("projectId can not be empty!");
+		}
+		EntityManager em = this.entityManagerContainer().get(Task.class);
+		CriteriaBuilder cb = em.getCriteriaBuilder();
+		CriteriaQuery<String> cq = cb.createQuery(String.class);
+		Root<Task> root = cq.from(Task.class);
+		Predicate p = cb.equal( root.get(Task_.parent), pid );
+		cq.select( root.get(Task_.id ) );
+		return em.createQuery(cq.where(p)).getResultList();
+	}
+	
+	/**
+	 * 根据条件查询符合条件的项目信息数量
+	 * @param projectId
+	 * @return
+	 * @throws Exception
+	 */
+	public Long countWithProject( String projectId ) throws Exception {
+		EntityManager em = this.entityManagerContainer().get( Task.class );
+		CriteriaBuilder cb = em.getCriteriaBuilder();
+		CriteriaQuery<Long> cq = cb.createQuery(Long.class);
+		Root<Task> root = cq.from(Task.class);
+		Predicate p = cb.equal( root.get( Task_.project), projectId );
+		cq.select(cb.count(root)).where(p);
+		return em.createQuery(cq).getSingleResult();
+	}
+
+	public List<Task> allUnCompletedSubTasks(String taskId) throws Exception {
+		if( StringUtils.isEmpty( taskId )  ){
+			return null;
+		}
+		EntityManager em = this.entityManagerContainer().get(Task.class);
+		CriteriaBuilder cb = em.getCriteriaBuilder();
+		CriteriaQuery<Task> cq = cb.createQuery(Task.class);
+		Root<Task> root = cq.from(Task.class);
+		Predicate p = cb.equal(  root.get( Task_.parent ), taskId );
+		p = cb.and( p, cb.isFalse( root.get(Task_.completed )));
+		return em.createQuery(cq.where(p)).getResultList();
+	}
+
+	public List<String> listAllTaskIdsWithProject(String project) throws Exception {
+		if( StringUtils.isEmpty( project )  ){
+			return null;
+		}
+		EntityManager em = this.entityManagerContainer().get(Task.class);
+		CriteriaBuilder cb = em.getCriteriaBuilder();
+		CriteriaQuery<String> cq = cb.createQuery(String.class);
+		Root<Task> root = cq.from(Task.class);
+		Predicate p = cb.equal(  root.get( Task_.project ), project );
+		cq.select( root.get(Task_.id ) );
+		return em.createQuery(cq.where(p)).getResultList();
+	}
+}

+ 272 - 0
o2server/x_teamwork_assemble_control/src/main/java/com/x/teamwork/assemble/control/jaxrs/statistics/ActionStatisticMyProjects.java

@@ -0,0 +1,272 @@
+package com.x.teamwork.assemble.control.jaxrs.statistics;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.servlet.http.HttpServletRequest;
+
+import com.x.base.core.project.annotation.FieldDescribe;
+import com.x.base.core.project.bean.WrapCopier;
+import com.x.base.core.project.bean.WrapCopierFactory;
+import com.x.base.core.project.cache.ApplicationCache;
+import com.x.base.core.project.http.ActionResult;
+import com.x.base.core.project.http.EffectivePerson;
+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.base.core.project.tools.SortTools;
+import com.x.teamwork.core.entity.Project;
+import com.x.teamwork.core.entity.ProjectGroup;
+import com.x.teamwork.core.entity.tools.filter.QueryFilter;
+import com.x.teamwork.core.entity.tools.filter.term.EqualsTerm;
+
+import net.sf.ehcache.Element;
+
+public class ActionStatisticMyProjects extends BaseAction {
+
+	private static Logger logger = LoggerFactory.getLogger(ActionStatisticMyProjects.class);
+
+	protected ActionResult<Wo> execute(HttpServletRequest request, EffectivePerson effectivePerson ) throws Exception {
+		ActionResult<Wo> result = new ActionResult<>();
+		Wo wo = null;
+		List<String> projectIds = null;
+		List<Project> projectList = null;
+		List<ProjectGroup>  projectGroupList = null;
+		List<WoGroup> woGroupList = null;
+		Boolean check = true;
+		
+		Integer allCount = 0;
+		Integer starCount = 0;
+		Integer myCount = 0;
+		Integer unGroupCount = 0;
+		Integer completedCount = 0;
+		Integer archiveCount = 0;
+		Integer deleteCount = 0;
+
+
+			if( Boolean.TRUE.equals( check ) ){
+				try {
+					//查询我参与的所有项目
+					projectIds = projectQueryService.listAllProjectIds( effectivePerson, 2000,  new QueryFilter() );
+					if( ListTools.isNotEmpty( projectIds )) {
+						projectList = projectQueryService.list( projectIds );
+					}
+				} catch (Exception e) {
+					check = false;
+					Exception exception = new ProjectQueryException( e, "查询用户参与的所有项目信息列表时发生异常。" );
+					result.error(exception);
+					logger.error(e, effectivePerson, request, null);
+				}
+			}
+			
+			if( Boolean.TRUE.equals( check ) ){
+				try {
+					//查询我所有的项目组列表
+					projectGroupList = projectGroupQueryService.listGroupByPerson( effectivePerson.getDistinguishedName() );
+				} catch (Exception e) {
+					check = false;
+					Exception exception = new ProjectQueryException( e, "查询用户所有项目组信息列表时发生异常。" );
+					result.error(exception);
+					logger.error(e, effectivePerson, request, null);
+				}
+			}
+			
+			if( Boolean.TRUE.equals( check ) ){
+				if( ListTools.isNotEmpty( projectGroupList )) {
+					woGroupList = WoGroup.copier.copy( projectGroupList );
+					SortTools.asc( woGroupList, "createTime");
+				}
+			}			
+			
+			if( Boolean.TRUE.equals( check ) ){
+				if( ListTools.isNotEmpty( projectList )) {
+					for(  Project project : projectList ) {
+						if(project.getDeleted() != null && project.getDeleted() ){
+							deleteCount++;
+						}else{
+							allCount++;						
+							if( project.getStarPersonList() != null  && project.getStarPersonList().contains( effectivePerson.getDistinguishedName() ) ) {
+								starCount++;
+							}
+							if( project.getCreatorPerson().equalsIgnoreCase(effectivePerson.getDistinguishedName()  )) {
+								myCount++;
+							}
+							if( project.getGroupCount() == null || project.getGroupCount() == 0 ) {
+								unGroupCount++;
+							}
+							if( project.getCompleted() != null && project.getCompleted() ) {
+								completedCount++;
+							}
+							if( project.getArchive() != null && project.getArchive() ) {
+								archiveCount++;
+							}
+							woGroupList = checkGroup( project, woGroupList );
+						}
+						
+					}
+				}
+			}
+			
+			if( Boolean.TRUE.equals( check ) ){
+				try {
+					wo = new Wo();
+					wo.setAllCount( allCount );
+					wo.setMyCount(myCount);
+					wo.setStarCount(starCount);
+					wo.setUnGroupCount(unGroupCount);
+					wo.setCompletedCount(completedCount);
+					wo.setArchiveCount(archiveCount);
+					wo.setDeleteCount(deleteCount);					
+					if( ListTools.isNotEmpty( woGroupList )) {
+						SortTools.asc( woGroupList, "createTime");
+					}	
+					wo.setGroups( woGroupList );
+					result.setData(wo);
+				} catch (Exception e) {
+					Exception exception = new ProjectQueryException(e, "将查询出来的应用项目信息对象转换为可输出的数据信息时发生异常。");
+					result.error(exception);
+					logger.error(e, effectivePerson, request, null);
+				}
+			}
+		return result;
+	}
+
+	private List<WoGroup> checkGroup( Project project, List<WoGroup> woGroupList) throws Exception {
+		if( ListTools.isEmpty( woGroupList )) {
+			return null;
+		}
+		for( WoGroup woGroup : woGroupList ) {
+			if( projectGroupQueryService.existsWithProjectAndGroup( woGroup.getId(), project.getId() ) ) {
+				woGroup.addProjectCount(1);
+				break;
+			}
+		}
+		return woGroupList;
+	}
+
+	public static class Wo{
+
+		@FieldDescribe("所有项目数量")
+		private Integer allCount = 0;
+		
+		@FieldDescribe("所有项目数量")
+		private Integer starCount = 0;
+		
+		@FieldDescribe("所有项目数量")
+		private Integer myCount = 0;
+		
+		@FieldDescribe("所有项目数量")
+		private Integer unGroupCount = 0;
+		
+		@FieldDescribe("所有项目数量")
+		private Integer completedCount = 0;
+		
+		@FieldDescribe("所有项目数量")
+		private Integer archiveCount = 0;
+		
+		@FieldDescribe("所有项目数量")
+		private Integer deleteCount = 0;
+		
+		@FieldDescribe("所有分组信息")
+		private List<WoGroup> groups = null;
+		
+		public List<WoGroup> getGroups() {
+			return groups;
+		}
+
+		public void setGroups(List<WoGroup> groups) {
+			this.groups = groups;
+		}
+
+		public Integer getAllCount() {
+			return allCount;
+		}
+
+		public void setAllCount(Integer allCount) {
+			this.allCount = allCount;
+		}
+
+		public Integer getStarCount() {
+			return starCount;
+		}
+
+		public void setStarCount(Integer starCount) {
+			this.starCount = starCount;
+		}
+
+		public Integer getMyCount() {
+			return myCount;
+		}
+
+		public void setMyCount(Integer myCount) {
+			this.myCount = myCount;
+		}
+
+		public Integer getUnGroupCount() {
+			return unGroupCount;
+		}
+
+		public void setUnGroupCount(Integer unGroupCount) {
+			this.unGroupCount = unGroupCount;
+		}
+
+		public Integer getCompletedCount() {
+			return completedCount;
+		}
+
+		public void setCompletedCount(Integer completedCount) {
+			this.completedCount = completedCount;
+		}
+
+		public Integer getArchiveCount() {
+			return archiveCount;
+		}
+
+		public void setArchiveCount(Integer archiveCount) {
+			this.archiveCount = archiveCount;
+		}
+
+		public Integer getDeleteCount() {
+			return deleteCount;
+		}
+
+		public void setDeleteCount(Integer deleteCount) {
+			this.deleteCount = deleteCount;
+		}
+	}
+	
+	public static class WoGroup extends ProjectGroup{
+		
+		@FieldDescribe("分组项目数量")
+		private Integer projectCount = 0;
+		
+		public Integer getProjectCount() {
+			return projectCount;
+		}
+
+		public void setProjectCount(Integer projectCount) {
+			this.projectCount = projectCount;
+		}
+
+		public void addProjectCount( Integer count ) {
+			if( this.projectCount == null ) {
+				this.projectCount =0;
+			}
+			this.projectCount += count;
+		}
+		
+		private static final long serialVersionUID = -5076990764713538973L;
+
+		public static List<String> Excludes = new ArrayList<String>();
+		
+		static {
+			Excludes.add("creatorPerson");
+			Excludes.add("owner");
+			Excludes.add("updateTime");
+			Excludes.add("distributeFactor");
+			Excludes.add("sequence");
+		}
+		
+		static WrapCopier<ProjectGroup, WoGroup> copier = WrapCopierFactory.wo( ProjectGroup.class, WoGroup.class, null, Excludes);
+	}
+}

+ 132 - 0
o2server/x_teamwork_assemble_control/src/main/java/com/x/teamwork/assemble/control/jaxrs/statistics/ActionStatisticTaskWithFilter.java

@@ -0,0 +1,132 @@
+package com.x.teamwork.assemble.control.jaxrs.statistics;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.apache.commons.lang3.StringUtils;
+
+import com.google.gson.JsonElement;
+import com.x.base.core.container.EntityManagerContainer;
+import com.x.base.core.container.factory.EntityManagerContainerFactory;
+import com.x.base.core.entity.JpaObject;
+import com.x.base.core.project.annotation.FieldDescribe;
+import com.x.base.core.project.bean.WrapCopier;
+import com.x.base.core.project.bean.WrapCopierFactory;
+import com.x.base.core.project.cache.ApplicationCache;
+import com.x.base.core.project.http.ActionResult;
+import com.x.base.core.project.http.EffectivePerson;
+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.teamwork.assemble.control.Business;
+import com.x.teamwork.core.entity.Task;
+import com.x.teamwork.core.entity.tools.filter.QueryFilter;
+import com.x.teamwork.core.entity.tools.filter.term.InTerm;
+
+import net.sf.ehcache.Element;
+
+public class ActionStatisticTaskWithFilter extends BaseAction {
+
+	private static Logger logger = LoggerFactory.getLogger(ActionStatisticTaskWithFilter.class);
+
+	protected ActionResult<List<Wo>> execute( HttpServletRequest request, EffectivePerson effectivePerson, JsonElement jsonElement ) throws Exception {
+		ActionResult<List<Wo>> result = new ActionResult<>();
+		ResultObject resultObject = null;
+		List<Wo> wos = new ArrayList<>();
+		Wi wrapIn = null;		
+		Boolean check = true;
+		QueryFilter  queryFilter = null;
+		String flag = null;
+		Integer count = 2000;
+		
+		
+		
+		try {
+			wrapIn = this.convertToWrapIn(jsonElement, Wi.class);
+		} catch (Exception e) {
+			check = false;
+			Exception exception = new StatisticQueryException(e, "系统在将JSON信息转换为对象时发生异常。JSON:" + jsonElement.toString());
+			result.error(exception);
+			logger.error(e, effectivePerson, request, null);
+		}
+
+		if( Boolean.TRUE.equals( check ) ){
+			wrapIn.setDeleted("false");
+			queryFilter = wrapIn.getQueryFilter();
+		}
+		
+		if( Boolean.TRUE.equals( check ) ){
+			
+				try {
+					Long total = statisticQueryService.countWithFilter( effectivePerson, queryFilter );
+					List<Task>  taskList = statisticQueryService.listWithFilter( effectivePerson, count, flag, wrapIn.getOrderField(), wrapIn.getOrderType(), queryFilter );
+					wos = Wo.copier.copy(taskList);
+					resultObject = new ResultObject( total, wos );
+					
+					result.setCount( resultObject.getTotal() );
+					result.setData( resultObject.getWos() );
+				} catch (Exception e) {
+					check = false;
+					logger.warn("系统查询项目信息列表时发生异常!");
+					result.error(e);
+					logger.error(e, effectivePerson, request, null);
+				}
+			}		
+		return result;
+	}
+	
+	public static class Wi extends WrapInQueryTask{
+	}
+	
+	public static class Wo extends Task {
+		
+		private Long rank;
+
+		public Long getRank() {
+			return rank;
+		}
+
+		public void setRank(Long rank) {
+			this.rank = rank;
+		}
+
+		private static final long serialVersionUID = -5076990764713538973L;
+
+		public static List<String> Excludes = new ArrayList<String>();
+
+		static WrapCopier<Task, Wo> copier = WrapCopierFactory.wo( Task.class, Wo.class, null, ListTools.toList(JpaObject.FieldsInvisible));
+
+	}
+	
+	public static class ResultObject {
+
+		private Long total;
+		
+		private List<Wo> wos;
+
+		public ResultObject() {}
+		
+		public ResultObject(Long count, List<Wo> data) {
+			this.total = count;
+			this.wos = data;
+		}
+
+		public Long getTotal() {
+			return total;
+		}
+
+		public void setTotal(Long total) {
+			this.total = total;
+		}
+
+		public List<Wo> getWos() {
+			return wos;
+		}
+
+		public void setWos(List<Wo> wos) {
+			this.wos = wos;
+		}
+	}
+}

+ 28 - 0
o2server/x_teamwork_assemble_control/src/main/java/com/x/teamwork/assemble/control/jaxrs/statistics/BaseAction.java

@@ -0,0 +1,28 @@
+package com.x.teamwork.assemble.control.jaxrs.statistics;
+
+import com.x.base.core.project.cache.ApplicationCache;
+import com.x.base.core.project.jaxrs.StandardJaxrsAction;
+import com.x.teamwork.assemble.control.service.ProjectGroupPersistService;
+import com.x.teamwork.assemble.control.service.ProjectGroupQueryService;
+import com.x.teamwork.assemble.control.service.ProjectQueryService;
+import com.x.teamwork.assemble.control.service.StatisticQueryService;
+import com.x.teamwork.assemble.control.service.SystemConfigQueryService;
+import com.x.teamwork.core.entity.Project;
+
+import net.sf.ehcache.Ehcache;
+
+public class BaseAction extends StandardJaxrsAction {
+
+	protected Ehcache projectCache = ApplicationCache.instance().getCache( Project.class );
+	
+	protected 	ProjectQueryService projectQueryService = new ProjectQueryService();
+	
+	protected ProjectGroupQueryService projectGroupQueryService = new ProjectGroupQueryService();
+	
+	protected ProjectGroupPersistService projectGroupPersistService = new ProjectGroupPersistService();	
+	
+	protected 	SystemConfigQueryService systemConfigQueryService = new SystemConfigQueryService();
+	
+	protected 	StatisticQueryService statisticQueryService = new StatisticQueryService();
+	
+}

+ 16 - 0
o2server/x_teamwork_assemble_control/src/main/java/com/x/teamwork/assemble/control/jaxrs/statistics/ProjectQueryException.java

@@ -0,0 +1,16 @@
+package com.x.teamwork.assemble.control.jaxrs.statistics;
+
+import com.x.base.core.project.exception.PromptException;
+
+class ProjectQueryException extends PromptException {
+
+	private static final long serialVersionUID = 1859164370743532895L;
+
+	ProjectQueryException( Throwable e ) {
+		super("系统在查询项目信息时发生异常。" , e );
+	}
+	
+	ProjectQueryException( Throwable e, String message ) {
+		super("系统在查询项目信息时发生异常。Message:" + message, e );
+	}
+}

+ 16 - 0
o2server/x_teamwork_assemble_control/src/main/java/com/x/teamwork/assemble/control/jaxrs/statistics/StatisticQueryException.java

@@ -0,0 +1,16 @@
+package com.x.teamwork.assemble.control.jaxrs.statistics;
+
+import com.x.base.core.project.exception.PromptException;
+
+class StatisticQueryException extends PromptException {
+
+	private static final long serialVersionUID = 1859164370743532895L;
+
+	StatisticQueryException( Throwable e ) {
+		super("统计查询工作任务信息时发生异常。" , e );
+	}
+	
+	StatisticQueryException( Throwable e, String message ) {
+		super("统计查询工作任务信息时发生异常。Message:" + message, e );
+	}
+}

+ 73 - 0
o2server/x_teamwork_assemble_control/src/main/java/com/x/teamwork/assemble/control/jaxrs/statistics/StatisticsAction.java

@@ -0,0 +1,73 @@
+package com.x.teamwork.assemble.control.jaxrs.statistics;
+
+import java.util.List;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.container.AsyncResponse;
+import javax.ws.rs.container.Suspended;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
+
+import com.google.gson.JsonElement;
+import com.x.base.core.project.annotation.JaxrsDescribe;
+import com.x.base.core.project.annotation.JaxrsMethodDescribe;
+import com.x.base.core.project.annotation.JaxrsParameterDescribe;
+import com.x.base.core.project.http.ActionResult;
+import com.x.base.core.project.http.EffectivePerson;
+import com.x.base.core.project.http.HttpMediaType;
+import com.x.base.core.project.jaxrs.ResponseFactory;
+import com.x.base.core.project.jaxrs.StandardJaxrsAction;
+import com.x.base.core.project.logger.Logger;
+import com.x.base.core.project.logger.LoggerFactory;
+
+
+@Path("statistics")
+@JaxrsDescribe("统计管理")
+public class StatisticsAction extends StandardJaxrsAction {
+
+	private Logger logger = LoggerFactory.getLogger(StatisticsAction.class);
+
+	@JaxrsMethodDescribe(value = "查询我的项目统计信息.", action = ActionStatisticMyProjects.class)
+	@GET
+	@Path("statitic/my")
+	@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
+	@Consumes(MediaType.APPLICATION_JSON)
+	public void statiticMyProject(@Suspended final AsyncResponse asyncResponse, 
+			@Context HttpServletRequest request ) {
+		ActionResult<ActionStatisticMyProjects.Wo> result = new ActionResult<>();
+		EffectivePerson effectivePerson = this.effectivePerson(request);
+		try {
+			result = new ActionStatisticMyProjects().execute( request, effectivePerson );
+		} catch (Exception e) {
+			logger.error(e, effectivePerson, request, null);
+			result.error(e);
+		}
+		asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
+	}
+	
+	@JaxrsMethodDescribe(value = "列示工作任务信息,下一页.", action = ActionStatisticTaskWithFilter.class)
+	@PUT
+	@Path("statitic/{id}/next/{count}")
+	@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
+	@Consumes(MediaType.APPLICATION_JSON)
+	public void listNextWithFilter(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
+			@JaxrsParameterDescribe("查询过滤条件") JsonElement jsonElement ) {
+		ActionResult<List<ActionStatisticTaskWithFilter.Wo>> result = new ActionResult<>();
+		EffectivePerson effectivePerson = this.effectivePerson(request);
+		try {
+			result = new ActionStatisticTaskWithFilter().execute(request, effectivePerson,jsonElement); 
+		} catch (Exception e) {
+			logger.error(e, effectivePerson, request, null);
+			result.error(e);
+		}
+		asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
+	}
+
+}

+ 139 - 0
o2server/x_teamwork_assemble_control/src/main/java/com/x/teamwork/assemble/control/jaxrs/statistics/WrapInQueryTask.java

@@ -0,0 +1,139 @@
+package com.x.teamwork.assemble.control.jaxrs.statistics;
+
+import org.apache.commons.lang3.StringUtils;
+
+import com.x.base.core.project.annotation.FieldDescribe;
+import com.x.teamwork.core.entity.tools.filter.QueryFilter;
+import com.x.teamwork.core.entity.tools.filter.term.EqualsTerm;
+import com.x.teamwork.core.entity.tools.filter.term.IsFalseTerm;
+import com.x.teamwork.core.entity.tools.filter.term.LikeTerm;
+
+public class WrapInQueryTask {
+	
+	@FieldDescribe("用于排列的属性,非必填,默认为createTime.")
+	private String orderField = "createTime";
+
+	@FieldDescribe("排序方式:DESC | ASC,非必填,默认为DESC.")
+	private String orderType = "DESC";
+	
+	@FieldDescribe("用于搜索的项目ID,单值,非必填.")
+	private String project = null;
+	
+	@FieldDescribe("用于搜索的上级工作任务ID,单值,非必填.")
+	private String parentId = null;	
+	
+	@FieldDescribe("用于搜索的工作状态:草稿- draft  | 执行中- processing | 已完成- completed | 已归档- archived,单值,非必填")
+	private String workStatus = null;
+		
+	
+	@FieldDescribe("是否已经删除,true|false,非必填")
+	private String deleted = null;		
+	
+	@FieldDescribe("执行者或者负责人,单值,非必填")
+	private String executor = null;		
+
+	private Long rank = 0L;
+
+	public Long getRank() {
+		return rank;
+	}
+
+	public void setRank(Long rank) {
+		this.rank = rank;
+	}
+	
+	public String getOrderField() {
+		return orderField;
+	}
+
+	public void setOrderField(String orderField) {
+		this.orderField = orderField;
+	}
+
+	public String getOrderType() {
+		return orderType;
+	}
+
+	public void setOrderType(String orderType) {
+		this.orderType = orderType;
+	}
+
+	public String getProject() {
+		return project;
+	}
+
+	public void setProject(String project) {
+		this.project = project;
+	}
+
+	public String getParentId() {
+		return parentId;
+	}
+
+	public void setParentId(String parentId) {
+		this.parentId = parentId;
+	}
+
+	public String getWorkStatus() {
+		return workStatus;
+	}
+
+	public void setWorkStatus(String workStatus) {
+		this.workStatus = workStatus;
+	}
+	
+	public String getDeleted() {
+		return deleted;
+	}
+
+	public void setDeleted(String deleted) {
+		this.deleted = deleted;
+	}
+
+	public String getExecutor() {
+		return executor;
+	}
+
+	public void setExecutor(String executor) {
+		this.executor = executor;
+	}
+	
+	/**
+	 * 根据传入的查询参数,组织一个完整的QueryFilter对象
+	 * @return
+	 */
+	public QueryFilter getQueryFilter() {
+		QueryFilter queryFilter = new QueryFilter();
+		//组织查询条件对象
+		if( StringUtils.isNotEmpty( this.getProject() )) {
+			queryFilter.addEqualsTerm( new EqualsTerm( "project", this.getProject() ) );
+		}
+		if( StringUtils.isNotEmpty( this.getParentId() )) {
+			queryFilter.addEqualsTerm( new EqualsTerm( "parent", this.getParentId() ) );
+		}
+		if( StringUtils.isNotEmpty( this.getWorkStatus() )) {
+			queryFilter.addEqualsTerm( new EqualsTerm( "workStatus", this.getWorkStatus() ) );
+		}else {
+			//默认查询所有的未归档的工作任务
+			queryFilter.addIsFalseTerm( new IsFalseTerm("archive"));
+		}
+		if( StringUtils.isNotEmpty( this.getExecutor())) {
+			queryFilter.addEqualsTerm( new EqualsTerm( "executor", this.getExecutor() ) );
+		}
+		/*if( StringUtils.isNotEmpty( this.getCompleted() )) {
+			if( "true".equalsIgnoreCase( this.getCompleted() )) {
+				queryFilter.addEqualsTerm( new EqualsTerm( "completed", true ) );
+			}else {
+				queryFilter.addEqualsTerm( new EqualsTerm( "completed", false ) );
+			}
+		}*/
+		if( StringUtils.isNotEmpty( this.getDeleted() )) {
+			if( "true".equalsIgnoreCase( this.getDeleted() )) {
+				queryFilter.addEqualsTerm( new EqualsTerm( "deleted", true ) );
+			}else {
+				queryFilter.addEqualsTerm( new EqualsTerm( "deleted", false ) );
+			}
+		}
+		return queryFilter;
+	}
+}

+ 615 - 0
o2server/x_teamwork_assemble_control/src/main/java/com/x/teamwork/assemble/control/service/StatisticQueryService.java

@@ -0,0 +1,615 @@
+package com.x.teamwork.assemble.control.service;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.commons.lang3.StringUtils;
+
+import com.x.base.core.container.EntityManagerContainer;
+import com.x.base.core.container.factory.EntityManagerContainerFactory;
+import com.x.base.core.project.http.EffectivePerson;
+import com.x.base.core.project.tools.ListTools;
+import com.x.teamwork.assemble.control.Business;
+import com.x.teamwork.assemble.control.jaxrs.task.BaseAction.TaskListChange;
+import com.x.teamwork.core.entity.Review;
+import com.x.teamwork.core.entity.Task;
+import com.x.teamwork.core.entity.TaskDetail;
+import com.x.teamwork.core.entity.TaskExtField;
+import com.x.teamwork.core.entity.TaskGroup;
+import com.x.teamwork.core.entity.TaskList;
+import com.x.teamwork.core.entity.TaskListRele;
+import com.x.teamwork.core.entity.tools.filter.QueryFilter;
+
+/**
+ * 对工作任务信息查询的服务
+ * 
+ * @author O2LEE
+ */
+public class StatisticQueryService {
+
+	private TaskService taskService = new TaskService();
+	private TaskListService taskListService = new TaskListService();
+	private TaskGroupService taskGroupService = new TaskGroupService();
+	private ReviewService reviewService = new ReviewService();
+	private UserManagerService userManagerService = new UserManagerService();
+	
+	/**
+	 * 根据工作任务的标识查询工作任务信息
+	 * @param id
+	 * @return
+	 * @throws Exception
+	 */
+	public Task get( String id ) throws Exception {
+		if ( StringUtils.isEmpty( id )) {
+			return null;
+		}
+		try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
+			return emc.find(id, Task.class );
+		} catch (Exception e) {
+			throw e;
+		}
+	}
+	
+	public TaskDetail getDetail(String id) throws Exception {
+		if ( StringUtils.isEmpty( id )) {
+			return null;
+		}
+		try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
+			return emc.find(id, TaskDetail.class );
+		} catch (Exception e) {
+			throw e;
+		}
+	}
+	
+	/**
+	 * 根据任务ID查询扩展属性信息
+	 * @param id
+	 * @return
+	 * @throws Exception
+	 */
+	public TaskExtField getExtField(String id) throws Exception {
+		if ( StringUtils.isEmpty( id )) {
+			return null;
+		}
+		try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
+			return emc.find(id, TaskExtField.class );
+		} catch (Exception e) {
+			throw e;
+		}
+	}
+	
+	/**
+	 * 根据ID列表查询工作任务信息列表
+	 * @param ids
+	 * @return
+	 * @throws Exception
+	 */
+	public List<Task> list(List<String> ids) throws Exception {
+		if (ListTools.isEmpty( ids )) {
+			return null;
+		}
+		try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
+			return emc.list( Task.class,  ids );
+		} catch (Exception e) {
+			throw e;
+		}
+	}
+	
+	public Long countWithFilter( EffectivePerson effectivePerson, QueryFilter queryFilter ) throws Exception {
+		String personName = effectivePerson.getDistinguishedName();
+		try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
+			return taskService.countWithFilter(emc, personName, queryFilter);
+		} catch (Exception e) {
+			throw e;
+		}
+	}
+
+	public Long countWithTaskListId(String taskListId) throws Exception {
+		if ( StringUtils.isEmpty( taskListId )) {
+			return null;
+		}
+		try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
+			return taskService.countWithTaskListId( emc, taskListId );
+		} catch (Exception e) {
+			throw e;
+		}
+	}
+	
+	/**
+	 * 根据TaskListID查询任务列表,如果taskListId,则查询所有未分类的工作列表
+	 * @param projectId
+	 * @param taskListId
+	 * @param personName
+	 * @return
+	 * @throws Exception
+	 */
+	public List<Task> listTaskWithTaskListId( String projectId, String taskListId, String personName ) throws Exception {
+		if ( StringUtils.isEmpty( taskListId )) {
+			return null;
+		}
+		
+		Task task = null;
+		TaskList taskList = null;
+		List<String> taskIds = null;
+		List<String> taskListIds = null;
+		List<String> taskIds_forTaskList = null;
+		List<TaskGroup> taskGroupList = null;
+		List<TaskListRele> taskListReles = null;
+		List<Task> resultList = new ArrayList<>();
+		
+		try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
+			taskList = emc.find( taskListId, TaskList.class );
+			if( taskList != null ) {
+				//查询该TaskList下所有的任务列表
+				taskIds = taskListService.listTaskIdsWithTaskListId( emc, taskListId );
+				//查询这些任务在指定工作任务列表里的关联,按关联的排序号查询任务信息列表
+				taskListReles = taskListService.listReleWithTaskAndListId(emc, taskIds, taskListId );				
+				if( ListTools.isNotEmpty( taskListReles )) {
+					for( TaskListRele rele : taskListReles ) {
+						task = emc.find( rele.getTaskId(), Task.class );
+						task.setOrder( rele.getOrder() );
+						resultList.add( task );
+					}
+				}
+				return resultList;
+			}else {
+				//查询所有未归类的任务列表
+				List<String> taskIds_all = new ArrayList<>();
+				//查询在指定项目里所有可见的工作任务列表
+				List<String> taskIds_all_tmp = reviewService.listTaskIdsWithPerson(emc, personName, projectId );
+				if( taskIds_all_tmp == null ) {
+					taskIds_all_tmp = new ArrayList<>();
+				}
+				for( String str : taskIds_all_tmp ) {
+					taskIds_all.add( str );
+				}
+				//查询默认的TaskGroup
+				taskGroupList = taskGroupService.listGroupByPersonAndProject( emc, personName, projectId);
+				if( ListTools.isNotEmpty( taskGroupList )) {
+					//查询该用户所有的TaskList的ID列表
+					taskListIds = taskListService.listTaskListIdsWithGroup( emc, taskGroupList.get(0).getId(), personName );
+					if( ListTools.isNotEmpty( taskListIds )) {
+						//看看这些TaskList所关联的所有的TaskId列表
+						taskIds_forTaskList = taskListService.listTaskIdsWithTaskListIds( emc, taskListIds );
+						if( taskIds_forTaskList == null ) {
+							taskIds_forTaskList = new ArrayList<>();
+						}
+						taskIds_all.removeAll( taskIds_forTaskList );
+					}
+				}
+				return new Business(emc).taskFactory().list(taskIds_all );
+			}
+		} catch (Exception e) {
+			throw e;
+		}
+	}
+	
+	/**
+	 * 根据TaskListID查询任务列表,如果taskListId,则查询所有未分类的工作列表
+	 * @param projectId
+	 * @param taskListId
+	 * @param personName
+	 * @return
+	 * @throws Exception
+	 */
+	public List<Task> listMyTaskWithTaskListId( String projectId, String taskListId, String personName ) throws Exception {
+		if ( StringUtils.isEmpty( taskListId )) {
+			return null;
+		}
+		
+		Task task = null;
+		TaskList taskList = null;
+		List<String> taskIds = null;
+		List<String> taskListIds = null;
+		List<String> taskIds_forTaskList = null;
+		List<TaskGroup> taskGroupList = null;
+		List<TaskListRele> taskListReles = null;
+		List<Task> resultList = new ArrayList<>();
+		
+		try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
+			taskList = emc.find( taskListId, TaskList.class );
+			if( taskList != null ) {				
+				//查询该TaskList下所有的任务列表
+				taskIds = taskListService.listTaskIdsWithTaskListId( emc, taskListId );
+				//查询这些任务在指定工作任务列表里的关联,按关联的排序号查询任务信息列表
+				taskListReles = taskListService.listReleWithTaskAndListId(emc, taskIds, taskListId );				
+				if( ListTools.isNotEmpty( taskListReles )) {
+					for( TaskListRele rele : taskListReles ) {
+						task = emc.find( rele.getTaskId(), Task.class );
+						//只查询自己负责的任务
+						if( personName.equalsIgnoreCase( task.getExecutor() ) ||
+								( task.getParticipantList() !=null && task.getParticipantList().contains( personName ))
+						) {
+							task.setOrder( rele.getOrder() );
+							resultList.add( task );
+						}
+					}
+				}
+			}else {
+				//查询所有未归类的任务列表
+				List<String> taskIds_all = new ArrayList<>();
+				//查询在指定项目里所有可见的工作任务列表
+				List<String> taskIds_all_tmp = reviewService.listTaskIdsWithPerson(emc, personName, projectId );
+				if( taskIds_all_tmp == null ) {
+					taskIds_all_tmp = new ArrayList<>();
+				}
+				System.out.println("w:taskIds_all_tmp="+taskIds_all_tmp.size());
+				
+				for( String str : taskIds_all_tmp ) {
+					taskIds_all.add( str );
+				}
+				System.out.println("w:taskIds_all="+taskIds_all.size());
+				//查询默认的TaskGroup
+				taskGroupList = taskGroupService.listGroupByPersonAndProject( emc, personName, projectId);
+				if( ListTools.isNotEmpty( taskGroupList )) {
+					//查询该用户所有的TaskList的ID列表
+					taskListIds = taskListService.listTaskListIdsWithGroup( emc, taskGroupList.get(0).getId(), personName );
+					if( ListTools.isNotEmpty( taskListIds )) {
+						//看看这些TaskList所关联的所有的TaskId列表
+						taskIds_forTaskList = taskListService.listTaskIdsWithTaskListIds( emc, taskListIds );
+						if( taskIds_forTaskList == null ) {
+							taskIds_forTaskList = new ArrayList<>();
+						}
+						System.out.println("默认泳道:taskIds_forTaskList="+taskIds_forTaskList.size());
+						taskIds_all.removeAll( taskIds_forTaskList );
+					}
+				}
+				List<Task> taskListTmp = new Business(emc).taskFactory().list(taskIds_all );
+				if( ListTools.isNotEmpty( taskListTmp )) {
+					for( Task _task : taskListTmp ) {
+						//只查询自己负责的任务
+						if( personName.equalsIgnoreCase( _task.getExecutor() )||
+								( _task.getParticipantList() !=null && _task.getParticipantList().contains( personName )))
+						{
+							resultList.add( _task );
+						}
+					}
+				}
+			}
+		} catch (Exception e) {
+			throw e;
+		}
+		return resultList;
+	}
+	
+	/**
+	 * 在人员的可见范围之类,根据指定的工作任务ID,查询子任务列表
+	 * @param taskId
+	 * @param effectivePerson
+	 * @return
+	 * @throws Exception 
+	 */
+	public List<Task> listTaskWithParentId(String taskId, EffectivePerson effectivePerson) throws Exception {
+		if ( StringUtils.isEmpty( taskId )) {
+			return null;
+		}
+		if ( effectivePerson == null ) {
+			return null;
+		}
+		List<Task> taskList = null;
+		try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
+			//查询用户在该项目里可见的所有项目列表
+			List<Review> reviewList = reviewService.listTaskWithPersonAndParentId( emc, effectivePerson.getDistinguishedName(), taskId );
+			if( ListTools.isNotEmpty( reviewList )) {
+				taskList = taskService.convertToTask(reviewList);
+			}
+		} catch (Exception e) {
+			throw e;
+		}
+		return taskList;
+	}
+	
+	/**
+	 *  根据过滤条件查询符合要求的工作任务信息列表
+	 * @param effectivePerson
+	 * @param pageSize
+	 * @param pageNum
+	 * @param orderField
+	 * @param orderType
+	 * @param queryFilter
+	 * @return
+	 * @throws Exception
+	 */
+	public List<Task> listWithFilter( EffectivePerson effectivePerson, Integer pageSize, Integer pageNum, String orderField, String orderType, QueryFilter queryFilter ) throws Exception {
+		List<Task> taskList = null;
+		List<Task> result = new ArrayList<>();
+		Integer maxCount = 20;
+		Integer startNumber = 0;		
+		
+		if( pageNum == 0 ) { pageNum = 1; }
+		if( pageSize == 0 ) { pageSize = 20; }
+		maxCount = pageSize * pageNum;
+		startNumber = pageSize * ( pageNum -1 );
+		
+		if( StringUtils.isEmpty( orderField ) ) { 
+			orderField = "createTime";
+		}
+		if( StringUtils.isEmpty( orderType ) ) { 
+			orderType = "desc";
+		}
+		
+		try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
+			taskList = taskService.listWithFilter( emc, maxCount, orderField, orderType, effectivePerson.getDistinguishedName(), queryFilter );
+			if( ListTools.isNotEmpty( taskList )) {
+				for( int i = 0; i<taskList.size(); i++ ) {
+					if( i >= startNumber ) {
+						result.add( taskList.get( i ));
+					}
+				}
+			}
+		} catch (Exception e) {
+			throw e;
+		}
+		return result;
+	}
+
+	
+	/**
+	 * 根据条件查询符合条件的工作任务信息ID,根据上一条的sequnce查询指定数量的信息
+	 * @param effectivePerson
+	 * @param pageSize
+	 * @param lastId
+	 * @param orderField
+	 * @param orderType
+	 * @param queryFilter
+	 * @return
+	 * @throws Exception
+	 */
+	public List<Task> listWithFilter( EffectivePerson effectivePerson, Integer pageSize, String lastId, String orderField, String orderType, QueryFilter queryFilter ) throws Exception {
+		List<Task> taskList = null;
+		List<Task> resultList = new ArrayList<>();
+		Integer maxCount = 2000;
+		Task lastTask = null;
+		
+		if( pageSize == 0 ) { pageSize = 20; }
+		
+		if( StringUtils.isEmpty( orderField ) ) { 
+			orderField = "createTime";
+		}
+		if( StringUtils.isEmpty( orderType ) ) { 
+			orderType = "desc";
+		}
+		try ( EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
+			if( StringUtils.isNotEmpty(lastId) && !"(0)".equals( lastId ) && !"null".equals( lastId )) {
+				lastTask = emc.find( lastId, Task.class );
+			}
+			taskList = taskService.listWithFilter( emc, maxCount, orderField, orderType, effectivePerson.getDistinguishedName(), queryFilter );
+		} catch (Exception e) {
+			throw e;
+		}
+		if( ListTools.isNotEmpty( taskList )) {
+			int count = 0;
+			if( lastTask != null ) {
+				boolean add = false;
+				//获取自lastTask之后的一页内容
+				for( Task task : taskList ) {
+					if( add ) {
+						count ++;
+						if( count <= pageSize ) {
+							resultList.add( task );
+						}
+					}
+					if( task.getId().equals( lastTask.getId() )) {
+						add = true;
+					}
+				}
+			}else {
+				//只获取第一页内容
+				for( Task task : taskList ) {
+					count ++;
+					if( count <= pageSize ) {
+						resultList.add(task);
+					}
+				}
+			}
+		}		
+		return resultList;
+	}
+	
+	/**
+	 * 判断用户是否为指定工作任务的管理员
+	 * @param taskId
+	 * @param distinguishedName
+	 * @return
+	 * @throws Exception 
+	 */
+	public Boolean isTaskManager(String taskId, String distinguishedName) throws Exception {
+		try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
+			Task task = emc.find( taskId, Task.class );
+			if( ListTools.isNotEmpty( task.getManageablePersonList() )){
+				if( distinguishedName.equalsIgnoreCase( task.getCreatorPerson() )) {
+					return true;
+				}
+				if( distinguishedName.equalsIgnoreCase( task.getExecutor() )) {
+					return true;
+				}
+				if( task.getManageablePersonList().contains( distinguishedName )) {
+					return true;
+				}
+			}
+		} catch (Exception e) {
+			throw e;
+		}
+		return false;
+	}
+
+	/**
+	 * 判断用户是工作任务参与者
+	 * @param taskId
+	 * @param distinguishedName
+	 * @return
+	 * @throws Exception 
+	 */
+	public Boolean isTaskParticipant( String taskId, String personName ) throws Exception {		
+		List<String> unitNames = null;
+		List<String> groupNames = null;
+		List<String> identityNames = null;
+		
+		try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
+			unitNames = userManagerService.listUnitNamesWithPerson( personName );
+			groupNames = userManagerService.listGroupNamesByPerson(personName);
+			identityNames = userManagerService.listIdentitiesWithPerson(personName);
+			
+			Task task = emc.find( taskId, Task.class );
+
+			if( task.getParticipantList().contains( personName )) {
+				return true;
+			}
+			
+			identityNames.retainAll( task.getParticipantList() );
+			if( ListTools.isNotEmpty( identityNames )) {
+				return true;
+			}
+			unitNames.retainAll( task.getParticipantList() );
+			if( ListTools.isNotEmpty( unitNames )) {
+				return true;
+			}
+			groupNames.retainAll( task.getParticipantList() );
+			if( ListTools.isNotEmpty( groupNames )) {
+				return true;
+			}
+		} catch (Exception e) {
+			throw e;
+		}
+		return false;
+	}
+
+	/**
+	 * 根据任务的状态信息变化查询展现的列表变化
+	 * 任务原来所在的列表是绑定状态的,才会根据状态来变化列表,否则就不变
+	 * @param id
+	 * @param sourceStatus
+	 * @param targetStatus
+	 * @return
+	 */
+	public TaskListChange getTaskListChange( String id, String sourceStatus, String targetStatus ) {
+		TaskListChange change = null;
+		String sourceListId = null;
+		String targetListId = null;
+		//根据任务ID、sourceStatus查询原来所在列表ID
+		
+		//根据任务ID、targetStatus查询目标列表ID
+		
+		//组织一个ViewChange
+		if( StringUtils.isNotEmpty( sourceListId ) || StringUtils.isNotEmpty( targetListId ) ) {
+			change = new TaskListChange();
+			change.setSource(sourceListId);
+			change.setTarget(targetListId);
+			return change;
+		}
+		return null;		
+	}
+
+	public List<Task> listUnReviewIds( int maxCount ) throws Exception {
+		if ( maxCount == 0 ) {
+			maxCount = 100;
+		}
+		try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
+			return taskService.listUnReviewTaskIds( emc, 100 );
+		} catch (Exception e) {
+			throw e;
+		}
+	}
+
+	/**
+	 * 查询指定任务的所有未完成的子任务信息列表
+	 * @param taskId
+	 * @return
+	 * @throws Exception 
+	 */
+	public List<Task> allUnCompletedSubTasks(String taskId) throws Exception {
+		if( StringUtils.isEmpty( taskId ) ) { 
+			return null;
+		}
+		try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
+			return taskService.allUnCompletedSubTasks( emc, taskId );
+		} catch (Exception e) {
+			throw e;
+		}
+	}
+
+	public Integer countWithTaskGroupId( String taskGroupId, EffectivePerson effectivePerson ) throws Exception {
+		if( StringUtils.isEmpty( taskGroupId ) ) { 
+			return 0;
+		}
+		try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
+			TaskGroup taskGroup = emc.find( taskGroupId, TaskGroup.class );
+			if( taskGroup != null ) {
+				List<String> taskIds = taskService.listTaskIdsWithPermissionInProject(emc, 999, taskGroup.getProject(), effectivePerson.getDistinguishedName() );
+				if( ListTools.isNotEmpty( taskIds )) {
+					return taskIds.size();
+				}
+			}
+		} catch (Exception e) {
+			throw e;
+		}
+		return 0;
+	}
+
+	public List<Task> listTaskWithProjectAndPerson(String project, EffectivePerson effectivePerson) throws Exception {
+		if( StringUtils.isEmpty( project ) ) { 
+			return null;
+		}
+		if( effectivePerson == null ) { 
+			return null;
+		}
+		Business business = null;
+		List<String> taskIds = null;
+		try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
+			business = new Business( emc );
+			taskIds = business.reviewFactory().listTaskIdsWithPersonAndProject( effectivePerson.getDistinguishedName(), project);
+			if( ListTools.isNotEmpty( taskIds )) {
+				return emc.list( Task.class, taskIds );
+			}
+		} catch (Exception e) {
+			throw e;
+		}
+		return null;
+	}
+	
+	public List<String> listAllTaskIdsWithProject( String project ) throws Exception {
+		if( StringUtils.isEmpty( project ) ) { 
+			return null;
+		}
+		try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
+			return taskService.listAllTaskIdsWithProject( emc, project );			
+		} catch (Exception e) {
+			throw e;
+		}
+	}
+
+	public String getValueFromTaskExtField( TaskExtField taskExtField, String extFieldName) {
+		if( StringUtils.isEmpty( extFieldName )) {
+			return "";
+		}
+		if( taskExtField == null ) {
+			return "";
+		}
+		if( StringUtils.equals( extFieldName, "memoString_1" ) ) {
+			return taskExtField.getMemoString_1();
+		}else if( StringUtils.equals( extFieldName, "memoString_2" ) ) {
+			return taskExtField.getMemoString_2();
+		}else if( StringUtils.equals( extFieldName, "memoString_3" ) ) {
+			return taskExtField.getMemoString_3();
+		}else if( StringUtils.equals( extFieldName, "memoString_4" ) ) {
+			return taskExtField.getMemoString_4();
+		}else if( StringUtils.equals( extFieldName, "memoString_5" ) ) {
+			return taskExtField.getMemoString_5();
+		}else if( StringUtils.equals( extFieldName, "memoString_6" ) ) {
+			return taskExtField.getMemoString_6();
+		}else if( StringUtils.equals( extFieldName, "memoString_7" ) ) {
+			return taskExtField.getMemoString_7();
+		}else if( StringUtils.equals( extFieldName, "memoString_8" ) ) {
+			return taskExtField.getMemoString_8();
+		}else if( StringUtils.equals( extFieldName, "memoString_1_lob" ) ) {
+			return taskExtField.getMemoString_1_lob();
+		}else if( StringUtils.equals( extFieldName, "memoString_2_lob" ) ) {
+			return taskExtField.getMemoString_2_lob();
+		}else if( StringUtils.equals( extFieldName, "memoString_3_lob" ) ) {
+			return taskExtField.getMemoString_3_lob();
+		}else if( StringUtils.equals( extFieldName, "memoString_4_lob" ) ) {
+			return taskExtField.getMemoString_4_lob();
+		}
+		return "";
+	}	
+}