提交 8ebef04a 编写于 作者: L luojing

teamwork功能修改及优化

上级 ec12eaa5
......@@ -238,6 +238,11 @@ public class ProjectFactory extends AbstractFactory {
Root<Project> root = cq.from(Project.class);
Predicate p_permission = null;
System.out.println("personName="+personName);
System.out.println("identityNames="+identityNames);
System.out.println("unitNames="+unitNames);
System.out.println("groupNames="+groupNames);
if( StringUtils.isNotEmpty( personName )) {
//可以管理的栏目,肯定可以发布信息
p_permission = CriteriaBuilderTools.predicate_or( cb, p_permission, cb.isMember( personName, root.get( Project_.participantPersonList )) );
......
......@@ -51,6 +51,7 @@ public class ReviewFactory extends AbstractFactory {
Root<Review> root = cq.from( Review.class );
Predicate p = cb.equal( root.get( Review_.permissionObj ), person );
p = cb.and( p, cb.equal( root.get( Review_.project ), project ));
p = cb.and( p, cb.equal( root.get( Review_.deleted ), false ));
cq.select(root.get( Review_.taskId)).where(p);
return em.createQuery( cq ).getResultList();
}
......@@ -65,6 +66,7 @@ public class ReviewFactory extends AbstractFactory {
Root<Review> root = cq.from( Review.class );
Predicate p = cb.equal(root.get( Review_.project ), project );
p = cb.and( p, cb.equal(root.get( Review_.permissionObj ), person ));
p = cb.and( p, cb.equal( root.get( Review_.deleted ), false ));
cq.select( root.get( Review_.taskId) ).where(p);
return em.createQuery( cq ).setMaxResults(maxCount).getResultList();
}
......@@ -184,6 +186,7 @@ public class ReviewFactory extends AbstractFactory {
Root<Review> root = cq.from( Review.class );
Predicate p = cb.equal( root.get( Review_.permissionObj ), personName );
p = cb.and( p, root.get( Review_.taskId ).in( taskIds ));
p = cb.and( p, cb.equal( root.get( Review_.deleted ), false ));
cq.select(root.get( Review_.taskId)).where(p);
return em.createQuery( cq ).getResultList();
}
......@@ -201,6 +204,7 @@ public class ReviewFactory extends AbstractFactory {
Root<Review> root = cq.from( Review.class );
Predicate p = cb.equal( root.get( Review_.permissionObj ), person );
p = cb.and( p, cb.equal( root.get( Review_.parent ), taskId ));
p = cb.and( p, cb.equal( root.get( Review_.deleted ), false ));
return em.createQuery( cq.where(p) ).getResultList();
}
}
\ No newline at end of file
......@@ -29,14 +29,14 @@ public class ActionListWithTaskGroup extends BaseAction {
List<Wo> wos = null;
List<TaskList> taskLists = null;
Boolean check = true;
String cacheKey = ApplicationCache.concreteCacheKey( "list.my.taskgroup", taskGroupId, effectivePerson.getDistinguishedName() );
/*String cacheKey = ApplicationCache.concreteCacheKey( "list.my.taskgroup", taskGroupId, effectivePerson.getDistinguishedName() );
Element element = taskListCache.get( cacheKey );
if ((null != element) && (null != element.getObjectValue())) {
System.out.println("111");
wos = (List<Wo>) element.getObjectValue();
result.setData( wos );
} else {
} else {*/
if( Boolean.TRUE.equals( check ) ){
try {
taskLists = taskListQueryService.listWithTaskGroup( effectivePerson.getDistinguishedName(), taskGroupId );
......@@ -53,7 +53,7 @@ public class ActionListWithTaskGroup extends BaseAction {
}
}
}
taskListCache.put(new Element(cacheKey, wos));
//taskListCache.put(new Element(cacheKey, wos));
result.setData(wos);
}
} catch (Exception e) {
......@@ -63,7 +63,7 @@ public class ActionListWithTaskGroup extends BaseAction {
logger.error(e, effectivePerson, request, null);
}
}
}
//}
return result;
}
......
......@@ -51,6 +51,8 @@ public class ActionListPageWithFilter extends BaseAction {
if( wrapIn == null ) {
wrapIn = new Wi();
}
//添加过滤条件未删除状态才被查询
wrapIn.setDeleted("false");
queryFilter = wrapIn.getQueryFilter();
if( StringUtils.isNotEmpty( wrapIn.getGroup() )) {
//如果项目分组不为空,那么需要先根据项目分组来查询这个分组下的所有项目ID集合
......
......@@ -18,6 +18,7 @@ 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;
......@@ -52,7 +53,7 @@ public class ActionStatisticMyProjects extends BaseAction {
if( Boolean.TRUE.equals( check ) ){
try {
//查询我参与的所有项目
projectIds = projectQueryService.listAllViewableProjectIds( effectivePerson, 2000, new QueryFilter() );
projectIds = projectQueryService.listAllViewableProjectIds( effectivePerson, 2000, new QueryFilter() );
if( ListTools.isNotEmpty( projectIds )) {
projectList = projectQueryService.list( projectIds );
}
......
package com.x.teamwork.assemble.control.jaxrs.project;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import com.google.gson.JsonElement;
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.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.teamwork.assemble.control.service.BatchOperationPersistService;
import com.x.teamwork.assemble.control.service.BatchOperationProcessService;
import com.x.teamwork.core.entity.Dynamic;
import com.x.teamwork.core.entity.Project;
import com.x.teamwork.core.entity.ProjectDetail;
import com.x.teamwork.core.entity.ProjectGroup;
import com.x.teamwork.core.entity.ProjectTemplate;
import com.x.teamwork.core.entity.Task;
public class ActionTemplateSave extends BaseAction {
private static Logger logger = LoggerFactory.getLogger(ActionTemplateSave.class);
protected ActionResult<Wo> execute(HttpServletRequest request, EffectivePerson effectivePerson, JsonElement jsonElement ) throws Exception {
ActionResult<Wo> result = new ActionResult<>();
ProjectTemplate template = null;
ProjectTemplate old_template = null;
Wi wi = null;
Wo wo = new Wo();
Boolean check = true;
try {
wi = this.convertToWrapIn( jsonElement, Wi.class );
} catch (Exception e) {
check = false;
Exception exception = new ProjectPersistException(e, "系统在将JSON信息转换为对象时发生异常。JSON:" + jsonElement.toString());
result.error(exception);
logger.error(e, effectivePerson, request, null);
}
/*if( Boolean.TRUE.equals( check ) ){
old_template = projectQueryService.get( wi.getId() );
}
if( Boolean.TRUE.equals( check ) ){
ProjectDetail projectDetail = new ProjectDetail();
projectDetail.setDescription( wi.getDescription() );
try {
if( ListTools.isNotEmpty( wi.getGroups() )) {
wi.setGroupCount( wi.getGroups().size() );
}
template = projectPersistService.save( Wi.copier.copy(wi), projectDetail, effectivePerson );
//将项目添加到指定的项目组
projectGroupPersistService.releProjectToGroup( template.getId(), wi.getGroups() );
// 更新缓存
ApplicationCache.notify( Project.class );
ApplicationCache.notify( ProjectGroup.class );
ApplicationCache.notify( Task.class, ApplicationCache.concreteCacheKey( "ActionStatisticMyTasks", template.getId(), effectivePerson.getDistinguishedName() ) );
ApplicationCache.notify( Task.class, ApplicationCache.concreteCacheKey( "ActionStatisticMyTaskViews", template.getId(), effectivePerson.getDistinguishedName() ) );
wo.setId( template.getId() );
} catch (Exception e) {
check = false;
Exception exception = new ProjectPersistException(e, "项目信息保存时发生异常。");
result.error(exception);
logger.error(e, effectivePerson, request, null);
}
}
*/
if( Boolean.TRUE.equals( check ) ){
try {
new BatchOperationPersistService().addOperation(
BatchOperationProcessService.OPT_OBJ_PROJECT,
BatchOperationProcessService.OPT_TYPE_PERMISSION, template.getId(), template.getId(), "刷新文档权限:ID=" + template.getId() );
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
}
}
/*if( Boolean.TRUE.equals( check ) ){
try {
List<Dynamic> dynamics = dynamicPersistService.projectSaveDynamic(old_template, template, effectivePerson, jsonElement.toString() );
if( dynamics == null ) {
dynamics = new ArrayList<>();
}
if( wo != null ) {
wo.setDynamics(WoDynamic.copier.copy(dynamics));
}
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
}
}*/
result.setData( wo );
return result;
}
public static class Wi {
@FieldDescribe("数据库主键,自动生成,非必填.")
private String id;
@FieldDescribe("模板名称,必填")
private String title;
@FieldDescribe("排序号,非必填")
private Integer order;
@FieldDescribe("模板类型,非必填")
private String type;
@FieldDescribe("图标文件ID,非必填")
private String icon = null;
@FieldDescribe("说明信息(1M),非必填")
private String description;
@FieldDescribe("模板包含的默认永道,可多值,非必填.")
private List<String> taskList = null;
private String owner = null;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public Integer getOrder() {
return order;
}
public void setOrder(Integer order) {
this.order = order;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getIcon() {
return icon;
}
public void setIcon(String icon) {
this.icon = icon;
}
public String getOwner() {
return owner;
}
public void setOwner(String owner) {
this.owner = owner;
}
public List<String> getTaskList() {
return taskList;
}
public void setTaskList(List<String> taskList) {
this.taskList = taskList;
}
}
public static class Wo extends WoId {
@FieldDescribe("操作引起的动态内容")
List<WoDynamic> dynamics = new ArrayList<>();
public List<WoDynamic> getDynamics() {
return dynamics;
}
public void setDynamics(List<WoDynamic> dynamics) {
this.dynamics = dynamics;
}
}
public static class WoDynamic extends Dynamic{
private static final long serialVersionUID = -5076990764713538973L;
public static WrapCopier<Dynamic, WoDynamic> copier = WrapCopierFactory.wo( Dynamic.class, WoDynamic.class, null, JpaObject.FieldsInvisible);
private Long rank = 0L;
public Long getRank() {
return rank;
}
public void setRank(Long rank) {
this.rank = rank;
}
}
}
\ No newline at end of file
......@@ -8,6 +8,7 @@ import com.x.teamwork.assemble.control.service.ProjectGroupQueryService;
import com.x.teamwork.assemble.control.service.ProjectPersistService;
import com.x.teamwork.assemble.control.service.ProjectQueryService;
import com.x.teamwork.assemble.control.service.SystemConfigQueryService;
import com.x.teamwork.assemble.control.service.TaskPersistService;
import com.x.teamwork.core.entity.Project;
import net.sf.ehcache.Ehcache;
......
......@@ -13,6 +13,7 @@ import com.x.base.core.project.logger.LoggerFactory;
import com.x.base.core.project.tools.ListTools;
import com.x.teamwork.assemble.control.service.BatchOperationPersistService;
import com.x.teamwork.assemble.control.service.BatchOperationProcessService;
import com.x.teamwork.assemble.control.service.UserManagerService;
import com.x.teamwork.core.entity.*;
import org.apache.commons.lang3.StringUtils;
......@@ -26,6 +27,7 @@ import java.util.List;
public class ActionCopyTask extends BaseAction {
private static Logger logger = LoggerFactory.getLogger(ActionCopyTask.class);
private UserManagerService userManagerService = new UserManagerService();
/**
* 将指定的任务复制为新的工作任务
......@@ -48,6 +50,8 @@ public class ActionCopyTask extends BaseAction {
TaskExtField taskExtField = null;
List<Dynamic> dynamics = new ArrayList<>();
Boolean check = true;
List<String> groupIds = null;
List<String> listIds = null;
if ( StringUtils.isEmpty( sourceTaskId ) ) {
check = false;
......@@ -63,6 +67,8 @@ public class ActionCopyTask extends BaseAction {
Exception exception = new TaskNotExistsException(sourceTaskId);
result.error( exception );
}
groupIds = taskGroupQueryService.listGroupIdsByTask( sourceTask.getId() );
} catch (Exception e) {
check = false;
Exception exception = new TaskQueryException(e, "根据指定ID查询工作任务信息对象时发生异常。ID:" + sourceTaskId );
......@@ -96,6 +102,7 @@ public class ActionCopyTask extends BaseAction {
Task newTask = new Task();
TaskDetail newTaskDetail = new TaskDetail();
TaskExtField newTaskExtField = new TaskExtField();
if( Boolean.TRUE.equals( check ) ){
//COPY对象
sourceTask.copyTo( newTask );
......@@ -104,6 +111,10 @@ public class ActionCopyTask extends BaseAction {
//重新命名
newTask.setName( sourceTask.getName() + " - 副本");
//调整负责人为当前用户
newTask.setExecutor(effectivePerson.getDistinguishedName());
newTask.setExecutorIdentity(userManagerService.getIdentityWithPerson( newTask.getExecutor(), "min"));
//调整ID
newTask.setId( Task.createId() );
......@@ -113,6 +124,18 @@ public class ActionCopyTask extends BaseAction {
try {
newTask = taskPersistService.save( newTask, newTaskDetail, newTaskExtField, effectivePerson );
wo.setId( newTask.getId() );
if(ListTools.isNotEmpty( groupIds )){
if( !taskGroupQueryService.existsWithTaskAndGroup( groupIds.get(0), newTask.getId() )){
//添加任务和任务组的关联
taskGroupPersistService.addTaskToGroup( newTask.getId(),groupIds.get(0) );
taskGroupPersistService.refreshTaskCountInTaskGroupWithTaskId( effectivePerson.getDistinguishedName(), newTask.getId() );
listIds = taskListQueryService.listTaskListIdWithTaskId( sourceTask.getId(), groupIds.get(0));
}
}
if(ListTools.isNotEmpty( listIds )){
taskListPersistService.addTaskToTaskListWithOrderNumber( newTask.getId(), listIds.get(0), null, effectivePerson);
}
} catch (Exception e) {
check = false;
Exception exception = new TaskPersistException(e, "工作上级任务ID信息更新时发生异常。");
......
......@@ -61,7 +61,7 @@ public class ActionDelete extends BaseAction {
if( Boolean.TRUE.equals( check ) ){
try {
taskPersistService.delete(flag, effectivePerson );
//taskGroupPersistService.refreshTaskCountInTaskGroupWithTaskId( effectivePerson.getDistinguishedName(), flag );
taskGroupPersistService.refreshTaskCountInTaskGroupWithTaskId( effectivePerson.getDistinguishedName(), flag );
// 更新缓存
ApplicationCache.notify( Task.class );
......
......@@ -41,7 +41,7 @@ public class ActionGet extends BaseAction {
result.error( exception );
}
String cacheKey = ApplicationCache.concreteCacheKey( flag );
String cacheKey = ApplicationCache.concreteCacheKey( flag,effectivePerson );
Element element = taskCache.get( cacheKey );
if ((null != element) && (null != element.getObjectValue())) {
......@@ -133,7 +133,8 @@ public class ActionGet extends BaseAction {
if( Boolean.TRUE.equals( check ) ){
List<String> groupIds = null;
try {
groupIds = taskGroupQueryService.listGroupIdsByTask( task.getId() );
//groupIds = taskGroupQueryService.listGroupIdsByTask( task.getId() );
groupIds = taskGroupQueryService.listGroupIdsByPersonAndProject(effectivePerson,task.getProject());
if( ListTools.isNotEmpty( groupIds )){
wo.setTaskGroupId( groupIds.get(0) );
}
......@@ -153,6 +154,13 @@ public class ActionGet extends BaseAction {
listIds = taskListQueryService.listTaskListIdWithTaskId( task.getId(), wo.getTaskGroupId() );
if( ListTools.isNotEmpty( listIds )){
wo.setTaskListId( listIds.get(0) );
}else{
//返回当前项目的未分类taskListId
List<TaskList> taskList= null;
taskList = taskListQueryService.listWithTaskGroup( effectivePerson.getDistinguishedName(), wo.getTaskGroupId() );
if(taskList !=null){
wo.setTaskListId(taskList.get(0).getId());
}
}
} catch (Exception e) {
Exception exception = new TaskQueryException(e, "根据指定projectId查询项目扩展列配置信息对象时发生异常。projectId:" + task.getProject());
......@@ -161,50 +169,6 @@ public class ActionGet extends BaseAction {
}
}
}
// //查询任务所在的Group信息
// if( Boolean.TRUE.equals( check ) ){
// List<String> groupIds = null;
// List<TaskGroup> groupList = null;
// List<WoTaskGroup> woGroupList = new ArrayList<>();
// try {
// groupIds = taskGroupQueryService.listGroupIdsByTask( task.getId() );
// groupList = taskGroupQueryService.list( groupIds );
// if( ListTools.isNotEmpty( groupList )){
// woGroupList = WoTaskGroup.copier.copy( groupList );
// }
// wo.setTaskgroups( woGroupList );
// } catch (Exception e) {
// check = false;
// Exception exception = new TaskQueryException(e, "根据指定projectId查询项目扩展列配置信息对象时发生异常。projectId:" + task.getProject());
// result.error(exception);
// logger.error(e, effectivePerson, request, null);
// }
// }
//
// //查询任务所在的List信息
// if( Boolean.TRUE.equals( check ) ){
// if( ListTools.isNotEmpty(wo.getTaskgroups() )){
// List<String> listIds = null;
// List<TaskList> taskLists = null;
// List<WoTaskList> woTaskLists = new ArrayList<>();
// for( WoTaskGroup woGroup : wo.getTaskgroups() ){
// try {
// listIds = taskListQueryService.listTaskListIdWithTaskId( task.getId(), woGroup.getId() );
// taskLists = taskListQueryService.list( listIds );
// if( ListTools.isNotEmpty( taskLists )){
// woTaskLists = WoTaskList.copier.copy( taskLists );
// }
// woGroup.setTaskLists( woTaskLists );
// } catch (Exception e) {
// check = false;
// Exception exception = new TaskQueryException(e, "根据指定projectId查询项目扩展列配置信息对象时发生异常。projectId:" + task.getProject());
// result.error(exception);
// logger.error(e, effectivePerson, request, null);
// }
// }
// }
// }
}
taskCache.put(new Element( cacheKey, wo ));
result.setData(wo);
......
......@@ -54,6 +54,7 @@ public class ActionListNextWithFilter extends BaseAction {
}
if( Boolean.TRUE.equals( check ) ){
wrapIn.setDeleted("false");
queryFilter = wrapIn.getQueryFilter();
}
......
......@@ -48,7 +48,7 @@ public class ActionListPageWithFilter extends BaseAction {
result.error(exception);
logger.error(e, effectivePerson, request, null);
}
wrapIn.setDeleted("false");
if( Boolean.TRUE.equals( check ) ){
if( Boolean.TRUE.equals( check ) ){
queryFilter = wrapIn.getQueryFilter();
......
......@@ -82,7 +82,7 @@ public class ActionStatisticMyTasks extends BaseAction {
if( ListTools.isNotEmpty( taskList )) {
for( Task task : taskList ) {
taskTotal ++;
if( task.getCompleted() ) {
if( "completed".equalsIgnoreCase(task.getWorkStatus()) ) {
completedTotal++;
}
if( task.getOvertime() ) {
......
......@@ -64,6 +64,7 @@ public class ActionViewAllListNextWithFilter extends BaseAction {
if( Boolean.TRUE.equals( check ) ){
if( Boolean.TRUE.equals( check ) ){
wrapIn.setProject(projectId);
wrapIn.setDeleted("false");
queryFilter = wrapIn.getQueryFilter();
}
}
......
......@@ -65,6 +65,7 @@ public class ActionViewCompletedListNextWithFilter extends BaseAction {
if( Boolean.TRUE.equals( check ) ){
wrapIn.setProject(projectId);
wrapIn.setWorkStatus("completed");
wrapIn.setDeleted("false");
queryFilter = wrapIn.getQueryFilter();
}
}
......
......@@ -64,6 +64,7 @@ public class ActionViewMyExecutListNextWithFilter extends BaseAction {
if( Boolean.TRUE.equals( check ) ){
wrapIn.setProject(projectId);
wrapIn.setExecutor(effectivePerson.getDistinguishedName());
wrapIn.setDeleted("false");
queryFilter = wrapIn.getQueryFilter();
//queryFilter.addEqualsTerm( new EqualsTerm( "executor", effectivePerson.getDistinguishedName() ) );
}
......
......@@ -65,6 +65,7 @@ public class ActionViewOverTimeListNextWithFilter extends BaseAction {
if( Boolean.TRUE.equals( check ) ){
wrapIn.setProject(projectId);
wrapIn.setOvertime("true");
wrapIn.setDeleted("false");
queryFilter = wrapIn.getQueryFilter();
}
}
......
......@@ -66,6 +66,7 @@ public class ActionViewUncompletedListNextWithFilter extends BaseAction {
if( Boolean.TRUE.equals( check ) ){
wrapIn.setProject(projectId);
wrapIn.setWorkStatus("processing");
wrapIn.setDeleted("false");
queryFilter = wrapIn.getQueryFilter();
}
}
......
package com.x.teamwork.assemble.control.jaxrs.task;
import com.x.base.core.project.exception.PromptException;
class TaskGroupWithProjectNotExistsException extends PromptException {
private static final long serialVersionUID = 1859164370743532895L;
TaskGroupWithProjectNotExistsException( String id ) {
super("指定项目的工作任务组信息不存在。ID:" + id );
}
}
......@@ -12,6 +12,7 @@ import com.x.base.core.project.tools.ListTools;
import com.x.teamwork.core.entity.Project;
import com.x.teamwork.core.entity.ProjectDetail;
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.InTerm;
/**
......@@ -311,6 +312,7 @@ public class ProjectQueryService {
unitNames = userManagerService.listUnitNamesWithPerson( personName );
groupNames = userManagerService.listGroupNamesByPerson( personName );
identityNames = userManagerService.listIdentitiesWithPerson( personName );
queryFilter.addEqualsTerm( new EqualsTerm( "deleted", false ) );
return projectService.listAllViewableProjectIds( emc, maxCount, personName, identityNames, unitNames, groupNames, queryFilter );
} catch (Exception e) {
throw e;
......
......@@ -13,7 +13,11 @@ import com.x.teamwork.assemble.control.Business;
import com.x.teamwork.core.entity.Project;
import com.x.teamwork.core.entity.ProjectDetail;
import com.x.teamwork.core.entity.ProjectExtFieldRele;
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.TaskGroupRele;
import com.x.teamwork.core.entity.TaskListRele;
import com.x.teamwork.core.entity.tools.filter.QueryFilter;
class ProjectService {
......@@ -149,7 +153,7 @@ class ProjectService {
* @param id
* @throws Exception
*/
protected void delete(EntityManagerContainer emc, String id) throws Exception {
protected void delete(EntityManagerContainer emc, String id ) throws Exception {
Business business = new Business( emc );
Project project = emc.find( id, Project.class );
ProjectDetail projectDetail = emc.find( id, ProjectDetail.class );
......@@ -160,7 +164,10 @@ class ProjectService {
emc.beginTransaction( ProjectDetail.class );
emc.beginTransaction( ProjectExtFieldRele.class );
if( project != null ) {
emc.remove( project , CheckRemoveType.all );
//emc.remove( project , CheckRemoveType.all );
//改为软删除
project.setDeleted(true);
emc.check( project , CheckPersistType.all );
}
if( projectDetail != null ) {
emc.remove( projectDetail , CheckRemoveType.all );
......@@ -170,7 +177,8 @@ class ProjectService {
List<Task> tasks = business.taskFactory().list(ids);
if( ListTools.isNotEmpty(tasks)) {
for( Task task : tasks ) {
emc.remove( task , CheckRemoveType.all );
//emc.remove( task , CheckRemoveType.all );
this.remove( emc, task.getId() );
}
}
//还需要删除所有的ProjectExtFieldRele
......@@ -183,6 +191,85 @@ class ProjectService {
emc.commit();
}
}
/**
* 根据工作任务标识删除工作任务信息(物理删除)
* @param emc
* @param flag 主要是ID
* @throws Exception
*/
public void remove( EntityManagerContainer emc, String flag ) throws Exception {
emc.beginTransaction( Task.class );
emc.beginTransaction( Review.class );
emc.beginTransaction( TaskDetail.class );
emc.beginTransaction( TaskListRele.class );
emc.beginTransaction( TaskGroupRele.class );
removeTaskWithChildren( emc, flag);
emc.commit();
}
/**
* 根据工作任务标识删除工作任务信息( 物理删除 )
* @param emc
* @param id
* @throws Exception
*/
private void removeTaskWithChildren( EntityManagerContainer emc, String id ) throws Exception {
Business business = new Business( emc );
//还需要递归删除所有的下级Task
List<String> childrenIds = business.taskFactory().listByParent( id );
if( ListTools.isNotEmpty( childrenIds )) {
for( String _id : childrenIds ) {
removeTaskWithChildren( emc, _id );
}
}
//任务列表中的关联信息
List<TaskListRele> listReles = business.taskListFactory().listReleWithTask( id );
if( ListTools.isNotEmpty( listReles )) {
for( TaskListRele taskListRele : listReles ) {
emc.remove( taskListRele , CheckRemoveType.all );
}
}
//删除任务组关联信息
List<TaskGroupRele> groupReles = business.taskGroupReleFactory().listTaskReleWithTask( id );
if( ListTools.isNotEmpty( groupReles )) {
for( TaskGroupRele taskGroupRele : groupReles ) {
emc.remove( taskGroupRele , CheckRemoveType.all );
}
}
Task task = emc.find( id, Task.class );
TaskDetail taskDetail = emc.find( id, TaskDetail.class );
List<Review> reviewList = null;
List<List<String>> reviewIdBatchs = null;
List<String> reviewIds = business.reviewFactory().listReviewByTask( id, 9999 );
if( ListTools.isNotEmpty( reviewIds )) {
reviewIdBatchs = ListTools.batch( reviewIds, 1000 );
}
if( ListTools.isNotEmpty( reviewIdBatchs )) {
for( List<String> batch : reviewIdBatchs ) {
reviewList = emc.list( Review.class, batch );
if( ListTools.isNotEmpty( reviewList )) {
for( Review review : reviewList ) {
//emc.remove( review, CheckRemoveType.all );
//改为软删除
review.setDeleted(true);
emc.check( review, CheckPersistType.all );
}
}
}
}
if( task != null ) {
//emc.remove( task , CheckRemoveType.all );
//改为软删除
task.setDeleted(true);
emc.check( task, CheckPersistType.all );
}
if( taskDetail != null ) {
emc.remove( taskDetail , CheckRemoveType.all );
}
}
/**
* 根据条件查询项目ID列表,最大查询2000条
......
......@@ -62,7 +62,10 @@ public class ReviewService {
if( ListTools.isNotEmpty( reviewList )) {
emc.beginTransaction( Review.class );
for( Review review : reviewList ) {
emc.remove( review );
//emc.remove( review );
//改为软删除-lj
review.setDeleted(true);
emc.check( review , CheckPersistType.all );
}
emc.commit();
}
......
......@@ -78,6 +78,35 @@ public class TaskGroupQueryService {
}
return taskGroupList;
}
/**
* 根据用户列示所有的工作任务组信息ID列表
* @param person
* @param project
* @return
* @throws Exception
*/
public List<String> listGroupIdsByPersonAndProject( EffectivePerson effectivePerson, String project ) throws Exception {
if ( effectivePerson == null ) {
return new ArrayList<>();
}
if ( StringUtils.isEmpty( project ) ) {
return new ArrayList<>();
}
List<String> taskGroupListIds = null;
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
taskGroupListIds = taskGroupService.listGroupIdsByPersonAndProject(emc, effectivePerson.getDistinguishedName(), project );
//如果用户在该项目中没有工作任务组,则需要创建一个默认的工作任务组
if( ListTools.isEmpty( taskGroupListIds )) {
List<TaskGroup> taskGroupList = null;
taskGroupList = createDefaultTaskGroupForPerson( emc, effectivePerson, project );
taskGroupListIds.add(taskGroupList.get(0).getId());
}
} catch (Exception e) {
throw e;
}
return taskGroupListIds;
}
/**
* 为指定项目初始化一个工作任务组,并且将所有的工作任务加入到工作任务组中
......
......@@ -119,6 +119,7 @@ public class TaskListQueryService {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
TaskGroup taskGroup = emc.find( taskGroupId, TaskGroup.class );
System.out.println("taskGroupId="+taskGroupId);
List<TaskList> taskLists = taskListService.listWithTaskGroup( emc, taskGroupId );
if( ListTools.isEmpty( taskLists )) {
//没有任何工作任务列表,需要新建一组默认的工作任务列表
......@@ -129,20 +130,27 @@ public class TaskListQueryService {
if( taskGroup != null ) {
//查询用户所有的工作ID列表
List<String> taskIds_all_temp = reviewService.listTaskIdsWithPerson( emc, person, taskGroup.getProject() );
System.out.println("taskIds_all_temp="+taskIds_all_temp.size());
taskIds_all.addAll( taskIds_all_temp );
System.out.println("taskIds_all="+taskIds_all.size());
}
if( ListTools.isNotEmpty( taskIds_all )) {
//查询该用户所有的TaskList的ID列表
taskListIds = taskListService.listTaskListIdsWithGroup( emc, taskGroupId, person );
System.out.println("taskListIds="+taskListIds.size());
if( ListTools.isNotEmpty( taskListIds )) {
//看看这些TaskList所关联的所有的TaskId列表
taskIds_forTaskList = taskListService.listTaskIdsWithTaskListIds( emc, taskListIds );
System.out.println("根据taskListIds计算出的task="+taskIds_forTaskList.size());
taskIds_all.removeAll( taskIds_forTaskList );
if( ListTools.isNotEmpty( taskIds_all )) {
System.out.println("存在未分类的任务");
//存在未分类的任务
hasTaskWithNoList = true;
}
}else {
System.out.println("不存在taskListIds");
//存在未分类的任务
hasTaskWithNoList = true;
}
......
......@@ -110,11 +110,13 @@ public class TaskPersistService {
task.setCompleted( true );
task.setArchive( true );
}
String executor = null;
String executorIdentity = null;
String executorUnit = null;
//前端可能传身份,也可以直接传Person
//前端可能传身份,也可以直接传Person
if( StringUtils.isNotEmpty( task.getExecutorIdentity() ) ) {
executor = userManagerService.getPersonNameWithIdentity( task.getExecutorIdentity() );
if( StringUtils.isEmpty( executor )) {
......@@ -156,7 +158,7 @@ public class TaskPersistService {
task.setStartTime( new Date() );
}
if( task.getEndTime() == null ) {
task.setEndTime( new Date( ( task.getStartTime().getTime() + 30*60*1000) ) ); //30分钟之后
task.setEndTime( new Date( ( task.getStartTime().getTime() + 7*1440*60*1000) ) ); //30分钟之后
}
if( ListTools.isEmpty( task.getParticipantList() )) {
......@@ -472,7 +474,7 @@ public class TaskPersistService {
if( Task.name_FIELDNAME.equalsIgnoreCase( property )) {
task.setName( mainValue );
}else if( Task.workStatus_FIELDNAME.equalsIgnoreCase( property )) {
task.setWorkStatus( mainValue );
task.setWorkStatus( mainValue );
} else if( Task.priority_FIELDNAME.equalsIgnoreCase( property )) {
task.setPriority( mainValue );
} else if( Task.executor_FIELDNAME.equalsIgnoreCase( property )) {
......@@ -482,13 +484,14 @@ public class TaskPersistService {
personName = userManagerService.getPersonNameWithIdentity(mainValue);
personUnit = userManagerService.getUnitNameByIdentity(mainValue);
task.setExecutor( personName );
task.setExecutorIdentity(property);
task.setExecutorIdentity(mainValue);
task.setExecutorUnit(personUnit);
}else if( mainValue.endsWith( "@P" ) ) {
personName = mainValue;
personIdentity = userManagerService.getIdentityWithPerson(personName, "min");
personUnit = userManagerService.getUnitNameByIdentity(personIdentity);
task.setExecutor( personName );
task.setExecutorIdentity(property);
task.setExecutorIdentity(personIdentity);
task.setExecutorUnit(personUnit);
}
}else {
......@@ -501,13 +504,14 @@ public class TaskPersistService {
personName = userManagerService.getPersonNameWithIdentity(mainValue);
personUnit = userManagerService.getUnitNameByIdentity(mainValue);
task.setExecutor( personName );
task.setExecutorIdentity(property);
task.setExecutorIdentity(mainValue);
task.setExecutorUnit(personUnit);
}else if( mainValue.endsWith( "@P" ) ) {
personName = mainValue;
personIdentity = userManagerService.getIdentityWithPerson(personName, "min");
personUnit = userManagerService.getUnitNameByIdentity(personIdentity);
task.setExecutor( personName );
task.setExecutorIdentity(property);
task.setExecutorIdentity(personIdentity);
task.setExecutorUnit(personUnit);
}
}else {
......
......@@ -221,7 +221,7 @@ class TaskService {
* @param flag 主要是ID
* @throws Exception
*/
protected void remove( EntityManagerContainer emc, String flag ) throws Exception {
public void remove( EntityManagerContainer emc, String flag ) throws Exception {
emc.beginTransaction( Task.class );
emc.beginTransaction( Review.class );
emc.beginTransaction( TaskDetail.class );
......@@ -277,13 +277,19 @@ class TaskService {
reviewList = emc.list( Review.class, batch );
if( ListTools.isNotEmpty( reviewList )) {
for( Review review : reviewList ) {
emc.remove( review, CheckRemoveType.all );
//emc.remove( review, CheckRemoveType.all );
//改为软删除
review.setDeleted(true);
emc.check( review, CheckPersistType.all );
}
}
}
}
if( task != null ) {
emc.remove( task , CheckRemoveType.all );
//emc.remove( task , CheckRemoveType.all );
//改为软删除
task.setDeleted(true);
emc.check( task, CheckPersistType.all );
}
if( taskDetail != null ) {
emc.remove( taskDetail , CheckRemoveType.all );
......
......@@ -19,6 +19,7 @@ import com.x.teamwork.assemble.control.service.ProjectQueryService;
import com.x.teamwork.assemble.control.service.TaskQueryService;
import com.x.teamwork.core.entity.Review;
import com.x.teamwork.core.entity.Task;
import com.x.teamwork.core.entity.TaskStatuType;
/**
* 定时代理: 定期将所有的工作任务的截止时间核对一次,标识超时的工作任务
......@@ -54,7 +55,7 @@ public class Timertask_CheckAllTaskOverTime extends AbstractJob {
if( task != null ) {
logger.debug("Timertask_CheckAllTaskOverTime check task:" + task.getName());
if( task.getEndTime() != null ) {
if( task.getEndTime() != null && !TaskStatuType.completed.name().equalsIgnoreCase( task.getWorkStatus() )) {
if( task.getEndTime().before( now ) && !task.getOvertime()) {
//超时了,打上标识,并且发送提醒
emc.beginTransaction( Task.class );
......
......@@ -16,6 +16,10 @@ public final class PersistenceProperties extends AbstractPersistenceProperties {
public static final String table = "TEW_PROJECTDETAIL";
}
public static class ProjectTemplate {
public static final String table = "TEW_PROJECTTEMPLATE";
}
public static class TaskExtField {
public static final String table = "TEW_TASKEXTFIELD";
}
......
package com.x.teamwork.core.entity;
import java.util.List;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;
import org.apache.openjpa.persistence.PersistentCollection;
import org.apache.openjpa.persistence.jdbc.ContainerTable;
import org.apache.openjpa.persistence.jdbc.ElementColumn;
import org.apache.openjpa.persistence.jdbc.ElementIndex;
import org.apache.openjpa.persistence.jdbc.Index;
import org.apache.openjpa.persistence.jdbc.OrderColumn;
import com.x.base.core.entity.AbstractPersistenceProperties;
import com.x.base.core.entity.JpaObject;
import com.x.base.core.entity.SliceJpaObject;
import com.x.base.core.entity.annotation.CheckPersist;
import com.x.base.core.entity.annotation.ContainerEntity;
import com.x.base.core.project.annotation.FieldDescribe;
/**
* 项目模板信息
*
* @author O2LJ
*
*/
@ContainerEntity
@Entity
@Table(name = PersistenceProperties.ProjectTemplate.table, uniqueConstraints = {
@UniqueConstraint(name = PersistenceProperties.ProjectTemplate.table + JpaObject.IndexNameMiddle
+ JpaObject.DefaultUniqueConstraintSuffix, columnNames = { JpaObject.IDCOLUMN,
JpaObject.CREATETIMECOLUMN, JpaObject.UPDATETIMECOLUMN, JpaObject.SEQUENCECOLUMN }) })
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
public class ProjectTemplate extends SliceJpaObject {
private static final long serialVersionUID = 3856138316794473794L;
private static final String TABLE = PersistenceProperties.ProjectTemplate.table;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
@FieldDescribe("数据库主键,自动生成.")
@Id
@Column(length = length_id, name = ColumnNamePrefix + id_FIELDNAME)
private String id = createId();
public void onPersist() throws Exception {
}
/*
* =========================================================================
* ========= 以上为 JpaObject 默认字段
* =========================================================================
* =========
*/
/*
* =========================================================================
* ========= 以下为具体不同的业务及数据表字段要求
* =========================================================================
* =========
*/
public static final String title_FIELDNAME = "title";
@FieldDescribe("模板名称")
@Column( length = JpaObject.length_255B, name = ColumnNamePrefix + title_FIELDNAME)
@Index(name = TABLE + IndexNameMiddle + title_FIELDNAME)
private String title;
public static final String order_FIELDNAME = "order";
@FieldDescribe("排序号")
@Column( name = ColumnNamePrefix + order_FIELDNAME )
private Integer order;
public static final String type_FIELDNAME = "type";
@FieldDescribe("模板类型")
@Column( length = JpaObject.length_255B, name = ColumnNamePrefix + type_FIELDNAME)
@Index(name = TABLE + IndexNameMiddle + type_FIELDNAME)
@CheckPersist(allowEmpty = true )
private String type;
public static final String icon_FIELDNAME = "icon";
@FieldDescribe("图标文件ID")
@Column( length = JpaObject.length_id, name = ColumnNamePrefix + icon_FIELDNAME)
@CheckPersist(allowEmpty = true )
private String icon = null;
public static final String description_FIELDNAME = "description";
@FieldDescribe("模板类型")
@Column( length = JpaObject.length_255B, name = ColumnNamePrefix + description_FIELDNAME)
@Index(name = TABLE + IndexNameMiddle + description_FIELDNAME)
@CheckPersist(allowEmpty = true )
private String description;
public static final String owner_FIELDNAME = "owner";
@FieldDescribe("创建者")
@Column( length = AbstractPersistenceProperties.organization_name_length, name = ColumnNamePrefix + owner_FIELDNAME)
@Index( name = TABLE + IndexNameMiddle + owner_FIELDNAME )
@CheckPersist(allowEmpty = true)
private String owner;
public static final String taskList_FIELDNAME = "taskList";
@FieldDescribe("默认永道")
@PersistentCollection(fetch = FetchType.EAGER)
@OrderColumn(name = ORDERCOLUMNCOLUMN)
@ContainerTable(name = TABLE + ContainerTableNameMiddle + taskList_FIELDNAME, joinIndex = @Index(name = TABLE
+ IndexNameMiddle + taskList_FIELDNAME + JoinIndexNameSuffix))
@ElementColumn(length = JpaObject.length_255B, name = ColumnNamePrefix + taskList_FIELDNAME)
@ElementIndex(name = TABLE + IndexNameMiddle + taskList_FIELDNAME + ElementIndexNameSuffix)
@CheckPersist(allowEmpty = true)
private List<String> taskList;
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public Integer getOrder() {
return order;
}
public void setOrder(Integer order) {
this.order = order;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getIcon() {
return icon;
}
public void setIcon(String icon) {
this.icon = icon;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getOwner() {
return owner;
}
public void setOwner(String owner) {
this.owner = owner;
}
public List<String> getTaskList() {
return taskList;
}
public void setTaskList(List<String> taskList) {
this.taskList = taskList;
}
}
\ No newline at end of file
......@@ -86,7 +86,7 @@ public class TaskView extends SliceJpaObject {
public static final String executeCode_FIELDNAME = "executeCode";
@FieldDescribe("任务视图执行代号,系统视图使用,自定义视图不使用")
@Column( length = JpaObject.length_16B, name = ColumnNamePrefix + executeCode_FIELDNAME)
@Column( length = JpaObject.length_255B, name = ColumnNamePrefix + executeCode_FIELDNAME)
@Index(name = TABLE + IndexNameMiddle + executeCode_FIELDNAME)
private String executeCode;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册