Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

修改多个在测试中发现的问题 #205

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions src/main/java/com/mossle/api/store/StoreDTO.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ public class StoreDTO {
private String key;
private DataSource dataSource;
private String displayName;
private String type;
private long size;

public String getModel() {
return model;
Expand Down Expand Up @@ -39,4 +41,36 @@ public String getDisplayName() {
public void setDisplayName(String displayName) {
this.displayName = displayName;
}

/**
* 获取文件MIME类型
* @return
*/
public String getType() {
return type;
}

/**
* 设置文件MIME类型
* @param type
*/
public void setType(String type) {
this.type = type;
}

/**
* 获取文件大小
* @return
*/
public long getSize() {
return size;
}

/**
* 设置文件大小
* @param size
*/
public void setSize(long size) {
this.size = size;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
import com.mossle.spi.process.ProcessTaskDefinition;

import org.apache.commons.lang3.StringUtils;

import org.hibernate.SQLQuery;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -464,10 +464,20 @@ public void completeTask(String humanTaskId, String userId, String action,
*/
public Page findPersonalTasks(String userId, String tenantId, int pageNo,
int pageSize) {
String hql = "from TaskInfo where assignee=? and tenantId=? and status='active' order by id desc";
Page page = taskInfoManager.pagedQuery(hql, pageNo, pageSize, userId,
tenantId);
List<TaskInfo> taskInfos = (List<TaskInfo>) page.getResult();
//修复某一账号多环节参与后,系统首页“待办任务”、”已办任务“出现多条重复数据问题
//String hql = "from TaskInfo where assignee=? and tenantId=? and status='active' order by id desc";
//Page page = taskInfoManager.pagedQuery(hql, pageNo, pageSize, userId,
// tenantId);
String sql="SELECT task.* FROM task_info task INNER JOIN"
+"(SELECT ID FROM task_info WHERE assignee=? and TENANT_ID=? AND `status`='complete' order by CREATE_TIME DESC LIMIT 0,1)"
+"b ON task.ID=b.ID";
SQLQuery query=taskInfoManager.getSession().createSQLQuery(sql);
query.setParameter(0, userId).setParameter(1, tenantId);
query.addEntity(TaskInfo.class);
List<TaskInfo> taskInfos = (List<TaskInfo>)query.list();;
Page page=new Page();
page.setPageNo(pageNo);
page.setPageSize(pageSize);
List<HumanTaskDTO> humanTaskDtos = this.convertHumanTaskDtos(taskInfos);
page.setResult(humanTaskDtos);

Expand All @@ -479,10 +489,19 @@ public Page findPersonalTasks(String userId, String tenantId, int pageNo,
*/
public Page findFinishedTasks(String userId, String tenantId, int pageNo,
int pageSize) {
String hql = "from TaskInfo where assignee=? and tenantId=? and status='complete' order by id desc";
Page page = taskInfoManager.pagedQuery(hql, pageNo, pageSize, userId,
tenantId);
List<TaskInfo> taskInfos = (List<TaskInfo>) page.getResult();
//修复某一账号多环节参与后,系统首页“待办任务”、”已办任务“出现多条重复数据问题
// String hql = "from TaskInfo where assignee=? and tenantId=? and status='complete' order by id desc";
// Page page = taskInfoManager.pagedQuery(hql, pageNo, pageSize, userId,
// tenantId);
// List<TaskInfo> taskInfos = (List<TaskInfo>) page.getResult();
String sql="SELECT task.* FROM task_info task INNER JOIN(SELECT BUSINESS_KEY, MAX(TASK_ID) taskID FROM task_info WHERE assignee=? and TENANT_ID=? AND `status`='complete' GROUP BY BUSINESS_KEY) b ON task.BUSINESS_KEY=b.BUSINESS_KEY AND task.TASK_ID=b.taskId ORDER BY CREATE_TIME DESC";
SQLQuery query=taskInfoManager.getSession().createSQLQuery(sql);
query.setParameter(0, userId).setParameter(1, tenantId);
query.addEntity(TaskInfo.class);
List<TaskInfo> taskInfos=(List<TaskInfo>)query.list();
Page page=new Page();
page.setPageNo(pageNo);
page.setPageSize(pageSize);
List<HumanTaskDTO> humanTaskDtos = this.convertHumanTaskDtos(taskInfos);
page.setResult(humanTaskDtos);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ public StoreDTO saveStore(String model, String key, DataSource dataSource,
storeInfo.setPath(storeDto.getKey());
storeInfo.setCreateTime(new Date());
storeInfo.setTenantId(tenantId);
storeInfo.setType(storeDto.getType());
storeInfo.setSize(storeDto.getSize());
storeInfoManager.save(storeInfo);

return storeDto;
Expand All @@ -50,6 +52,8 @@ public StoreDTO saveStore(String model, DataSource dataSource,
storeInfo.setPath(storeDto.getKey());
storeInfo.setCreateTime(new Date());
storeInfo.setTenantId(tenantId);
storeInfo.setType(storeDto.getType());
storeInfo.setSize(storeDto.getSize());
storeInfoManager.save(storeInfo);

return storeDto;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.mossle.spi.store;

import javax.activation.DataSource;
import javax.activation.FileDataSource;

import com.mossle.api.store.StoreDTO;

Expand Down Expand Up @@ -54,7 +55,10 @@ public StoreDTO convertStoreDto(StoreResult storeResult) {
storeDto.setKey(storeResult.getKey());
storeDto.setDataSource(storeResult.getDataSource());
storeDto.setDisplayName(storeResult.getKey());

//增加文件大小和文件类型处理
FileDataSource dataSource=(FileDataSource)storeResult.getDataSource();
storeDto.setSize(dataSource.getFile().length());
storeDto.setType(dataSource.getContentType());
return storeDto;
}

Expand Down