提交 9673ac90 编写于 作者: L luojing

teamwork后台服务

上级 291f2c15
......@@ -12,6 +12,7 @@ import com.x.teamwork.assemble.control.factory.BatchOperationFactory;
import com.x.teamwork.assemble.control.factory.ChatFactory;
import com.x.teamwork.assemble.control.factory.DynamicFactory;
import com.x.teamwork.assemble.control.factory.PriorityFactory;
import com.x.teamwork.assemble.control.factory.ProjectConfigFactory;
import com.x.teamwork.assemble.control.factory.ProjectExtFieldReleFactory;
import com.x.teamwork.assemble.control.factory.ProjectFactory;
import com.x.teamwork.assemble.control.factory.ProjectGroupFactory;
......@@ -58,6 +59,7 @@ public class Business {
private TaskTagFactory taskTagFactory;
private AttachmentFactory attachmentFactory;
private PriorityFactory priorityFactory;
private ProjectConfigFactory projectConfigFactory;
public Organization organization() throws Exception {
if (null == this.organization) {
......@@ -198,6 +200,18 @@ public class Business {
return projectGroupFactory;
}
/**
* 获取优先级数据库访问类
* @return
* @throws Exception
*/
public ProjectConfigFactory projectConfigFactory() throws Exception {
if (null == this.projectConfigFactory) {
this.projectConfigFactory = new ProjectConfigFactory( this );
}
return projectConfigFactory;
}
/**
* 获取优先级数据库访问类
* @return
......
......@@ -12,6 +12,7 @@ import javax.persistence.criteria.Root;
import org.apache.commons.lang3.StringUtils;
import com.x.base.core.project.exception.ExceptionWhen;
import com.x.base.core.project.tools.ListTools;
import com.x.teamwork.assemble.control.AbstractFactory;
import com.x.teamwork.assemble.control.Business;
import com.x.teamwork.core.entity.Priority;
......@@ -36,6 +37,21 @@ public class PriorityFactory extends AbstractFactory {
return this.entityManagerContainer().find( id, Priority.class, ExceptionWhen.none );
}
/**
* 获取指定name的优先级实体信息对象
* @param name
* @return
* @throws Exception
*/
public List<Priority> getByName( String name ) throws Exception {
EntityManager em = this.entityManagerContainer().get(Priority.class);
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<Priority> cq = cb.createQuery(Priority.class);
Root<Priority> root = cq.from(Priority.class);
Predicate p = cb.equal( root.get(Priority_.priority), name );
return em.createQuery(cq.where(p)).getResultList();
}
/**
* 列示指定Id的ProjectGroup实体信息列表
* @param ids
......
......@@ -5,8 +5,11 @@ import com.x.base.core.project.jaxrs.StandardJaxrsAction;
import com.x.teamwork.assemble.control.service.DynamicPersistService;
import com.x.teamwork.assemble.control.service.PriorityPersistService;
import com.x.teamwork.assemble.control.service.PriorityQueryService;
import com.x.teamwork.assemble.control.service.ProjectConfigPersistService;
import com.x.teamwork.assemble.control.service.ProjectConfigQueryService;
import com.x.teamwork.assemble.control.service.SystemConfigQueryService;
import com.x.teamwork.core.entity.Priority;
import com.x.teamwork.core.entity.ProjectConfig;
import net.sf.ehcache.Ehcache;
......@@ -22,4 +25,10 @@ public class BaseAction extends StandardJaxrsAction {
protected SystemConfigQueryService systemConfigQueryService = new SystemConfigQueryService();
protected Ehcache projectConfigCache = ApplicationCache.instance().getCache( ProjectConfig.class );
protected ProjectConfigPersistService projectConfigPersistService = new ProjectConfigPersistService();
protected ProjectConfigQueryService projectConfigQueryService = new ProjectConfigQueryService();
}
......@@ -8,6 +8,7 @@ import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
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;
......@@ -27,6 +28,7 @@ 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;
import com.x.teamwork.assemble.control.jaxrs.project.ActionListNextWithFilter;
@Path("global")
@JaxrsDescribe("全局信息管理")
......@@ -126,4 +128,100 @@ public class GlobalAction extends StandardJaxrsAction {
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
@JaxrsMethodDescribe(value = "根据ID查询项目配置信息.", action = ActionProjectConfigGet.class)
@GET
@Path("projectConfig/{id}")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void projectConfigGet(@Suspended final AsyncResponse asyncResponse,
@Context HttpServletRequest request,
@JaxrsParameterDescribe("项目配置ID") @PathParam("id") String id ) {
ActionResult<ActionProjectConfigGet.Wo> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionProjectConfigGet().execute( request, effectivePerson, id );
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
@JaxrsMethodDescribe(value = "创建或者更新一个项目配置信息.", action = ActionProjectConfigSave.class)
@POST
@Path("projectConfig")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void projectConfigSave(@Suspended final AsyncResponse asyncResponse,
@Context HttpServletRequest request,
@JaxrsParameterDescribe("需要保存的优先级信息") JsonElement jsonElement ) {
ActionResult<ActionProjectConfigSave.Wo> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionProjectConfigSave().execute(request, effectivePerson, jsonElement);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
@JaxrsMethodDescribe(value = "根据标识删除项目配置信息.", action = ActionProjectConfigDelete.class)
@DELETE
@Path("projectConfig/{id}")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void projectConfigDelete(@Suspended final AsyncResponse asyncResponse,
@Context HttpServletRequest request,
@JaxrsParameterDescribe("标识") @PathParam("id") String id ) {
ActionResult<ActionProjectConfigDelete.Wo> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionProjectConfigDelete().execute(request, effectivePerson, id);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
@JaxrsMethodDescribe(value = "列示项目配置信息,下一页.", action = ActionListProjectConfigNextWithFilter.class)
@PUT
@Path("listProjectConfig/{id}/next/{count}")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void listProjectConfigNextWithFilter(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
@JaxrsParameterDescribe("最后一条信息数据的ID") @PathParam( "id" ) String id,
@JaxrsParameterDescribe("每页显示的条目数量") @PathParam( "count" ) Integer count,
@JaxrsParameterDescribe("查询过滤条件") JsonElement jsonElement ) {
ActionResult<List<ActionListProjectConfigNextWithFilter.Wo>> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionListProjectConfigNextWithFilter().execute(request, effectivePerson, id, count, jsonElement);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
@JaxrsMethodDescribe(value = "根据ID查询项目配置信息.", action = ActionProjectConfigGetByProject.class)
@GET
@Path("projectConfig/project/{id}")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void projectConfigGetByProject(@Suspended final AsyncResponse asyncResponse,
@Context HttpServletRequest request,
@JaxrsParameterDescribe("项目ID") @PathParam("id") String id ) {
ActionResult<ActionProjectConfigGetByProject.Wo> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionProjectConfigGetByProject().execute( request, effectivePerson, id );
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
}
\ No newline at end of file
......@@ -7,6 +7,6 @@ class PriorityFlagForQueryEmptyException extends PromptException {
private static final long serialVersionUID = 1859164370743532895L;
PriorityFlagForQueryEmptyException() {
super("查询的优先级信息ID为空,无法继续查询数据。" );
super("查询的优先级信息ID为空,无法继续查询数据。" );
}
}
......@@ -237,6 +237,11 @@ public class ActionUpdateSingleProperty extends BaseAction {
}
private Dynamic changeTaskProperty( String personName, String projectId, String taskId, String dynamicTitle, String dynamicOptType, String property, String oldValue, String mainValue, String secondaryValue, String dataType, Boolean nullable ) throws Exception {
taskPersistService.changeTaskProperty( taskId, property, mainValue, secondaryValue );
if(Task.priority_FIELDNAME.equalsIgnoreCase( property )){
mainValue = mainValue.split("\\|\\|")[0];
}
String dynamicDescription = personName + "将工作任务的[" + dynamicTitle + "]变更为:[" + mainValue + "]。";
if( StringUtils.isEmpty( mainValue ) && nullable ) {
Exception exception = new TaskPersistException( "工作任务属性["+ dynamicTitle +"]不允许为空,请检查您的输入。");
......@@ -261,7 +266,7 @@ public class ActionUpdateSingleProperty extends BaseAction {
}
}
}
taskPersistService.changeTaskProperty( taskId, property, mainValue, secondaryValue );
//taskPersistService.changeTaskProperty( taskId, property, mainValue, secondaryValue );
Dynamic dynamic_info = new Dynamic();
dynamic_info.setTitle( dynamicTitle );
......
......@@ -35,7 +35,7 @@ public class PriorityQueryService {
}
/**
* 根据项目组的标识查询项目组信息
* 根据优先级的标识查询优先级信息
* @param id
* @return
* @throws Exception
......@@ -51,6 +51,23 @@ public class PriorityQueryService {
}
}
/**
* 根据优先级的名称查询优先级信息
* @param name
* @return
* @throws Exception
*/
public List<Priority> getByName( String name ) throws Exception {
if ( StringUtils.isEmpty( name )) {
return null;
}
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
return priorityService.getByName(emc, name );
} catch (Exception e) {
throw e;
}
}
/**
* 根据用户列示优先级信息列表
* @param person
......
......@@ -37,6 +37,18 @@ class PriorityService {
Business business = new Business( emc );
return business.priorityFactory().get( id );
}
/**
* 根据优先级名称查询优先级的信息
* @param emc
* @param name
* @return
* @throws Exception
*/
protected List<Priority> getByName( EntityManagerContainer emc, String name ) throws Exception {
Business business = new Business( emc );
return business.priorityFactory().getByName( name );
}
/**
* 根据优先级ID删除优先级信息
......
......@@ -483,14 +483,16 @@ public class TaskPersistService {
}else if( Task.workStatus_FIELDNAME.equalsIgnoreCase( property )) {
task.setWorkStatus( mainValue );
} else if( Task.priority_FIELDNAME.equalsIgnoreCase( property )) {
PriorityQueryService priorityQueryService = new PriorityQueryService();
/*PriorityQueryService priorityQueryService = new PriorityQueryService();
if( StringUtils.isNotEmpty( mainValue )) {
Priority priority = priorityQueryService.get(mainValue);
if(priority != null){
String priorityName = mainValue.split("||")[0];
List<Priority> prioritys = priorityQueryService.getByName(priorityName);
if(ListTools.isNotEmpty(prioritys)){
Priority priority = prioritys.get(0);
task.setPriority(priority.getPriority()+"||"+priority.getPriorityColor() );
}
}
//task.setPriority( mainValue );
}*/
task.setPriority( mainValue );
} else if( Task.executor_FIELDNAME.equalsIgnoreCase( property )) {
if( StringUtils.isNotEmpty( mainValue )) {
String personName = null, personIdentity = null, personUnit = null;
......
......@@ -44,6 +44,10 @@ public final class PersistenceProperties extends AbstractPersistenceProperties {
public static final String table = "TEW_PIORITY";
}
public static class ProjectConfig {
public static final String table = "TEW_PROJECTCONFIG";
}
public static class Config {
public static final String table = "TEW_CONFIG";
}
......
......@@ -70,14 +70,14 @@ public class Priority extends SliceJpaObject {
*/
public static final String priority_FIELDNAME = "priority";
@FieldDescribe("优先级名称.")
@Column(length = length_id, name = ColumnNamePrefix + priority_FIELDNAME)
@Column(length = JpaObject.length_255B, name = ColumnNamePrefix + priority_FIELDNAME)
@Index(name = TABLE + IndexNameMiddle + priority_FIELDNAME)
@CheckPersist(allowEmpty = false)
private String priority;
public static final String color_FIELDNAME = "priorityColor";
@FieldDescribe("优先级颜色")
@Column( length = JpaObject.length_16B, name = ColumnNamePrefix + color_FIELDNAME)
@Column( length = JpaObject.length_255B, name = ColumnNamePrefix + color_FIELDNAME)
@CheckPersist( allowEmpty = false )
private String priorityColor;
......
package com.x.teamwork.core.entity;
import javax.persistence.Column;
import javax.persistence.Entity;
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.jdbc.Index;
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;
import com.x.base.core.project.tools.DateTools;
/**
* 优先级信息
*
* @author O2LJ
*
*/
@ContainerEntity
@Entity
@Table(name = PersistenceProperties.ProjectConfig.table, uniqueConstraints = {
@UniqueConstraint(name = PersistenceProperties.ProjectConfig.table + JpaObject.IndexNameMiddle
+ JpaObject.DefaultUniqueConstraintSuffix, columnNames = { JpaObject.IDCOLUMN,
JpaObject.CREATETIMECOLUMN, JpaObject.UPDATETIMECOLUMN, JpaObject.SEQUENCECOLUMN }) })
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
public class ProjectConfig extends SliceJpaObject {
private static final long serialVersionUID = 3856138316794473794L;
private static final String TABLE = PersistenceProperties.ProjectConfig.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 {
/** 生成默认排序号 */
if (null == this.order) {
this.order = DateTools.timeOrderNumber();
}
}
/*
* =========================================================================
* ========= 以上为 JpaObject 默认字段
* =========================================================================
* =========
*/
/*
* =========================================================================
* ========= 以下为具体不同的业务及数据表字段要求
* =========================================================================
* =========
*/
public static final String project_FIELDNAME = "project";
@FieldDescribe("项目信息ID.")
@Column(length = length_id, name = ColumnNamePrefix + project_FIELDNAME)
@Index(name = TABLE + IndexNameMiddle + project_FIELDNAME)
@CheckPersist(allowEmpty = false)
private String project;
public static final String taskCreate_FIELDNAME = "taskCreate";
@FieldDescribe("新建任务")
@Column( length = JpaObject.length_16B, name = ColumnNamePrefix + taskCreate_FIELDNAME)
@Index(name = TABLE + IndexNameMiddle + taskCreate_FIELDNAME)
@CheckPersist( allowEmpty = true )
private Boolean taskCreate;
public static final String taskCopy_FIELDNAME = "taskCopy";
@FieldDescribe("复制任务")
@Column( length = JpaObject.length_16B, name = ColumnNamePrefix + taskCopy_FIELDNAME)
@Index(name = TABLE + IndexNameMiddle + taskCopy_FIELDNAME)
@CheckPersist( allowEmpty = true )
private Boolean taskCopy;
public static final String taskRemove_FIELDNAME = "taskRemove";
@FieldDescribe("删除任务")
@Column( length = JpaObject.length_16B, name = ColumnNamePrefix + taskRemove_FIELDNAME)
@Index(name = TABLE + IndexNameMiddle + taskRemove_FIELDNAME)
@CheckPersist( allowEmpty = true )
private Boolean taskRemove;
public static final String laneCreate_FIELDNAME = "laneCreate";
@FieldDescribe("新建泳道")
@Column( length = JpaObject.length_16B, name = ColumnNamePrefix + laneCreate_FIELDNAME)
@Index(name = TABLE + IndexNameMiddle + laneCreate_FIELDNAME)
@CheckPersist( allowEmpty = true )
private Boolean laneCreate;
public static final String laneEdit_FIELDNAME = "laneEdit";
@FieldDescribe("编辑泳道")
@Column( length = JpaObject.length_16B, name = ColumnNamePrefix + laneEdit_FIELDNAME)
@Index(name = TABLE + IndexNameMiddle + laneEdit_FIELDNAME)
@CheckPersist( allowEmpty = true )
private Boolean laneEdit;
public static final String laneRemove_FIELDNAME = "laneRemove";
@FieldDescribe("删除泳道")
@Column( length = JpaObject.length_16B, name = ColumnNamePrefix + laneRemove_FIELDNAME)
@Index(name = TABLE + IndexNameMiddle + laneRemove_FIELDNAME)
@CheckPersist( allowEmpty = true )
private Boolean laneRemove;
public static final String attachmentUpload_FIELDNAME = "attachmentUpload";
@FieldDescribe("上传附件")
@Column( length = JpaObject.length_16B, name = ColumnNamePrefix + attachmentUpload_FIELDNAME)
@Index(name = TABLE + IndexNameMiddle + attachmentUpload_FIELDNAME)
@CheckPersist( allowEmpty = true )
private Boolean attachmentUpload;
public static final String comment_FIELDNAME = "comment";
@FieldDescribe("允许评论")
@Column( length = JpaObject.length_16B, name = ColumnNamePrefix + comment_FIELDNAME)
@Index(name = TABLE + IndexNameMiddle + comment_FIELDNAME)
@CheckPersist( allowEmpty = true )
private Boolean comment;
public static final String order_FIELDNAME = "order";
@FieldDescribe("排序号")
@Column( name = ColumnNamePrefix + order_FIELDNAME )
private Integer order;
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 description_FIELDNAME = "description";
@FieldDescribe("描述.")
@Column(length = length_id, name = ColumnNamePrefix + description_FIELDNAME)
@Index(name = TABLE + IndexNameMiddle + description_FIELDNAME)
@CheckPersist(allowEmpty = true)
private String description;
public String getProject() {
return project;
}
public void setProject(String project) {
this.project = project;
}
public Boolean getTaskCreate() {
return taskCreate;
}
public void setTaskCreate(Boolean taskCreate) {
this.taskCreate = taskCreate;
}
public Boolean getTaskCopy() {
return taskCopy;
}
public void setTaskCopy(Boolean taskCopy) {
this.taskCopy = taskCopy;
}
public Boolean getTaskRemove() {
return taskRemove;
}
public void setTaskRemove(Boolean taskRemove) {
this.taskRemove = taskRemove;
}
public Boolean getLaneCreate() {
return laneCreate;
}
public void setLaneCreate(Boolean laneCreate) {
this.laneCreate = laneCreate;
}
public Boolean getLaneEdit() {
return laneEdit;
}
public void setLaneEdit(Boolean laneEdit) {
this.laneEdit = laneEdit;
}
public Boolean getLaneRemove() {
return laneRemove;
}
public void setLaneRemove(Boolean laneRemove) {
this.laneRemove = laneRemove;
}
public Boolean getAttachmentUpload() {
return attachmentUpload;
}
public void setAttachmentUpload(Boolean attachmentUpload) {
this.attachmentUpload = attachmentUpload;
}
public Boolean getComment() {
return comment;
}
public void setComment(Boolean comment) {
this.comment = comment;
}
public Integer getOrder() {
return order;
}
public void setOrder(Integer order) {
this.order = order;
}
public String getOwner() {
return owner;
}
public void setOwner(String owner) {
this.owner = owner;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
}
\ No newline at end of file
......@@ -125,10 +125,10 @@ public class Task extends SliceJpaObject {
public static final String priority_FIELDNAME = "priority";
@FieldDescribe("工作等级:普通 | 紧急 | 特急")
@Column( length = JpaObject.length_16B, name = ColumnNamePrefix + priority_FIELDNAME)
@Column( length = JpaObject.length_255B, name = ColumnNamePrefix + priority_FIELDNAME)
@Index(name = TABLE + IndexNameMiddle + priority_FIELDNAME)
@CheckPersist( allowEmpty = true )
private String priority = "普通";
private String priority;
public static final String workStatus_FIELDNAME = "workStatus";
@FieldDescribe("工作状态:执行中- processing | 已完成- completed | 已归档- archived")
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册