本文介绍了如何使用RTC Java API根据修改的日期和时间获取工作项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用修改日期查询RTC。
我的查询是检查修改的日期与给定的日期和时间相同,但是我得到的响应是基于给定的日期,它忽略了时间。



回应:

理想情况下,两个记录都不应该在给定时间之前收到。



以下是我的代码:

  IQueryableAttributeFactory factory = QueryableAttributes.getFactory(IWorkItem.ITEM_TYPE); 

IQueryableAttribute recAttr1 = factory.findAttribute(projectArea,IItem.MODIFIED_PROPERTY,auditableClient,null);
IQueryableAttribute recAttr2 = factory.findAttribute(projectArea,IWorkItem.TYPE_PROPERTY,auditableClient,null);

日期date = new Date();
date.setDate(date.getDate() - 6);
DateFormat df = new SimpleDateFormat(MM / dd / yyyy HH:mm:ss);
String reportDate = df.format(date);
System.out.println(Date:+ reportDate);
Timestamp timeStamp = new Timestamp(date.getTime());

AttributeExpression recExpr1 = new AttributeExpression(recAttr1,AttributeOperation.EQUALS,timeStamp);

术语=新术语(Operator.AND);
term.add(recExpr1);

IQueryClient queryClient =(IQueryClient)teamRepository.getClientLibrary(IQueryClient.class);
IQueryResult< IResolvedResult< IWorkItem>> result = queryClient.getResolvedExpressionResults(projectArea,(Expression)term,IWorkItem.FULL_PROFILE);
System.out.println(这是总数:+ result.getResultSize(monitor).getTotal()+\\\
);

while(result.hasNext(null)){
IResolvedResult< IWorkItem> resolvedWorkItem = result.next(null);
IWorkItem workItem = resolvedWorkItem.getItem();
Date date1 = resolvedWorkItem.getItem()。modified();
System.out.println(Id:+ workItem.getId());
System.out.println(修改日期:+ date1.toString()+\\\
);
}

我可以根据日期还能准时得到结果吗? p>

我强烈地认为,RTC的后端逻辑完全忽略了时间,仅根据日期查询数据库。

解决方案

我有完全相同的问题。我想也许结果被缓存在某个地方,但不是这样。



我没有找到一种方式通过RTC查询来做到这一点,但应该是可能的在RTC查询返回后,在代码中过滤掉这些记录。保存您用于执行搜索的时间,然后通过执行以下操作来跳过任何记录:

  if(workItem.modified ).getTime()< lastModified)
continue;

我知道这不是理想,但至少有一种方法可以让所需的工作与。


I want to query RTC with modified date.My query is to check modified date is same as given date and time but the response that I am getting is based on given date and it is ignoring time.

Response:

Ideally, both the records should not be received in response as it is before given time.

Below is my code:

IQueryableAttributeFactory factory = QueryableAttributes.getFactory( IWorkItem.ITEM_TYPE );

IQueryableAttribute recAttr1 = factory.findAttribute(projectArea, IItem.MODIFIED_PROPERTY, auditableClient, null );
IQueryableAttribute recAttr2 = factory.findAttribute(projectArea, IWorkItem.TYPE_PROPERTY, auditableClient, null );

Date date = new Date();
date.setDate(date.getDate()-6);
DateFormat df = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
String reportDate = df.format(date);
System.out.println("Date: "+reportDate);
Timestamp timeStamp = new Timestamp(date.getTime());

AttributeExpression recExpr1 = new AttributeExpression(recAttr1, AttributeOperation.EQUALS, timeStamp );

Term term= new Term(Operator.AND);
term.add(recExpr1);

IQueryClient queryClient = (IQueryClient) teamRepository.getClientLibrary(IQueryClient.class);
IQueryResult<IResolvedResult<IWorkItem>> result = queryClient.getResolvedExpressionResults(projectArea, (Expression)term, IWorkItem.FULL_PROFILE);
System.out.println("This is total number: "+result.getResultSize(monitor).getTotal()+"\n");

while(result.hasNext(null)){
    IResolvedResult<IWorkItem> resolvedWorkItem = result.next(null);
    IWorkItem workItem = resolvedWorkItem.getItem();
    Date date1 = resolvedWorkItem.getItem().modified();
    System.out.println("Id: "+workItem.getId());
    System.out.println("Modified date :"+date1.toString()+"\n");
}

Can I get result not only based on date but also on time?

I strongly feel that the back-end logic of RTC is completely ignoring time and querying database only based on date.

解决方案

I have the exact same problem. I thought maybe the results were cached somewhere, but that wasn't it.

I haven't found a way to do this via RTC query, but it should be possible to filter out these records in your code after RTC query returned. Save the time you used to perform the search, then use that to skip any records by doing:

if (workItem.modified().getTime() < lastModified)
  continue;

I know this isn't ideal, but at least there's a way to get the desired set to work with.

这篇关于如何使用RTC Java API根据修改的日期和时间获取工作项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-12 19:48