use of com.rebuild.core.configuration.ConfigBean in project rebuild by getrebuild.
the class DataReportManager method getReportsRaw.
/**
* 获取报表列表(含禁用)
*
* @param entity
* @return
*/
public ConfigBean[] getReportsRaw(Entity entity) {
final String cKey = "DataReportManager2-" + entity.getName();
ConfigBean[] cached = (ConfigBean[]) Application.getCommonsCache().getx(cKey);
if (cached != null) {
return cached;
}
Object[][] array = Application.createQueryNoFilter("select configId,name,isDisabled,templateFile,templateType from DataReportConfig where belongEntity = ?").setParameter(1, entity.getName()).array();
List<ConfigBean> alist = new ArrayList<>();
for (Object[] o : array) {
ConfigBean cb = new ConfigBean().set("id", o[0]).set("name", o[1]).set("disabled", o[2]).set("template", o[3]).set("type", ObjectUtils.toInt(o[4], TYPE_RECORD));
alist.add(cb);
}
cached = alist.toArray(new ConfigBean[0]);
Application.getCommonsCache().putx(cKey, cached);
return cached;
}
use of com.rebuild.core.configuration.ConfigBean in project rebuild by getrebuild.
the class ProjectTasks method build.
@Override
public JSON build() {
final int viewState = ObjectUtils.toInt(getExtraParams().get("state"), 0);
Object[][] tasks = Application.createQueryNoFilter("select taskId,projectId,projectPlanId,taskNumber,taskName,createdOn,deadline,endTime,status,priority" + " from ProjectTask where executor = ? and status = ? order by seq asc").setParameter(1, getUser()).setParameter(2, viewState).array();
JSONArray array = new JSONArray();
for (Object[] o : tasks) {
ID projectId = (ID) o[1];
ConfigBean cbProject = ProjectManager.instance.getProject(projectId, null);
// 已归档不显示
if (cbProject.getInteger("status") == ProjectManager.STATUS_ARCHIVED)
continue;
ConfigBean cbPlan = ProjectManager.instance.getPlanOfProject((ID) o[2], projectId);
String projectName = String.format("%s (%s)", cbProject.getString("projectName"), cbPlan.getString("planName"));
String taskNumber = String.format("%s-%s", cbProject.getString("projectCode"), o[3]);
array.add(JSONUtils.toJSONObject(new String[] { "id", "projectName", "planFlow", "taskNumber", "taskName", "createdOn", "deadline", "endTime", "status", "priority" }, new Object[] { o[0], projectName, cbPlan.getInteger("flowStatus"), taskNumber, o[4], I18nUtils.formatDate((Date) o[5]), I18nUtils.formatDate((Date) o[6]), I18nUtils.formatDate((Date) o[7]), o[8], o[9] }));
}
return array;
}
use of com.rebuild.core.configuration.ConfigBean in project rebuild by getrebuild.
the class ProjectTaskController method taskList.
@RequestMapping("tasks/list")
public JSON taskList(HttpServletRequest request) {
final ID user = getRequestUser(request);
final ID projectId = getIdParameterNotNull(request, "project");
final String planKey = getParameterNotNull(request, "plan");
String queryWhere = "(" + buildCustomPlanSql(planKey, projectId) + ")";
// 关键词搜索
String search = getParameter(request, "search");
if (StringUtils.isNotBlank(search)) {
queryWhere += " and taskName like '%" + StringEscapeUtils.escapeSql(search) + "%'";
}
// 高级查询
JSON advFilter = ServletUtils.getRequestJson(request);
if (advFilter != null) {
String filterSql = new AdvFilterParser((JSONObject) advFilter).toSqlWhere();
if (filterSql != null) {
queryWhere += " and (" + filterSql + ")";
}
}
int pageNo = getIntParameter(request, "pageNo", 1);
int pageSize = getIntParameter(request, "pageSize", 40);
int count = -1;
if (pageNo == 1) {
String countSql = "select count(taskId) from ProjectTask where " + queryWhere;
Object[] count2 = Application.createQueryNoFilter(countSql).unique();
count = ObjectUtils.toInt(count2[0]);
if (count == 0) {
return NO_TASKS;
}
}
queryWhere += " order by " + buildQuerySort(request);
ConfigBean project = ProjectManager.instance.getProject(projectId, user);
JSONArray alist = queryCardDatas(project, user, queryWhere, new int[] { pageSize, pageNo * pageSize - pageSize });
return JSONUtils.toJSONObject(new String[] { "count", "tasks" }, new Object[] { count, alist });
}
use of com.rebuild.core.configuration.ConfigBean in project rebuild by getrebuild.
the class ProjectTaskController method taskGet.
@GetMapping("tasks/get")
public JSON taskGet(@IdParam(name = "task") ID taskId, HttpServletRequest request) {
final ID user = getRequestUser(request);
ConfigBean project = ProjectManager.instance.getProjectByX(taskId, user);
String where = "taskId = '" + taskId + "'";
JSONArray a = queryCardDatas(project, getRequestUser(request), where, null);
return (JSON) a.get(0);
}
use of com.rebuild.core.configuration.ConfigBean in project rebuild by getrebuild.
the class ProjectTaskController method formatTask.
/**
* @param o
* @param user
* @param putTags
* @return
* @throws ConfigurationException 如果指定用户无权限
* @see #FMT_FIELDS11
*/
private JSONObject formatTask(Object[] o, ID user, boolean putTags) throws ConfigurationException {
final ConfigBean project = ProjectManager.instance.getProject((ID) o[0], user);
String taskNumber = String.format("%s-%s", project.getString("projectCode"), o[2]);
String createdOn = I18nUtils.formatDate((Date) o[5]);
String deadline = I18nUtils.formatDate((Date) o[6]);
String endTime = I18nUtils.formatDate((Date) o[11]);
Object[] executor = o[7] == null ? null : new Object[] { o[7], UserHelper.getName((ID) o[7]) };
JSONObject data = JSONUtils.toJSONObject(new String[] { "id", "taskNumber", "taskName", "createdOn", "deadline", "executor", "status", "seq", "priority", "endTime", "projectId", "projectStatus" }, new Object[] { o[3], taskNumber, o[4], createdOn, deadline, executor, o[8], o[9], o[10], endTime, o[0], project.getInteger("status") });
// 标签
if (putTags) {
data.put("tags", TaskTagController.getTaskTags((ID) o[3]));
}
if (user != null) {
// 项目信息
ConfigBean plan = ProjectManager.instance.getPlanOfProject((ID) o[1], (ID) o[0]);
data.put("planName", String.format("%s (%s)", project.getString("projectName"), plan.getString("planName")));
data.put("planFlow", plan.getInteger("flowStatus"));
// 权限
data.put("projectMember", project.get("members", Set.class).contains(user));
data.put("isManageable", ProjectHelper.isManageable((ID) o[3], user));
}
return data;
}
Aggregations