1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
public String
getCTOStatistic() throws Exception
{ String
ctoTaskType = getParameterValue( "ctoTaskType" ).toString(); String
startDate = getParameterValue( "startDate" ).toString(); String
endDate = getParameterValue( "endDate" ).toString(); DBObject
initial = new BasicDBObject(); DBObject
index = new BasicDBObject(); BasicDBObject
cond = new BasicDBObject(); BasicDBObject
dateCondition = new BasicDBObject(); index.put( "count" , 0 ); index.put( "ctoPerson" , "" ); initial.put( "ctoPerson" ,
index); cond.put( "ctoStatus" , "Finished" ); if (StringUtils.isNotEmpty(ctoTaskType)){ cond.put( "taskId" ,
ctoTaskType); } if (StringUtils.isNotEmpty(startDate)){ dateCondition.append( "$gte" ,
DateUtil.toDate(startDate)); } if (StringUtils.isNotEmpty(endDate)){ dateCondition.append( "$lt" ,
DateUtil.toDate(endDate)); } cond.put( "jobCreateTime" ,dateCondition); String
reduce = "function
(doc, out) { " + "
out.ctoPerson.count = out.ctoPerson.count+=1; " + "
out.ctoPerson.ctoPerson = doc.ctoPerson;" + "}" ; BasicDBList
group = (BasicDBList) ctoJobService.group( new String[]
{ "ctoPerson" },
cond, initial, reduce, null ); this .jsonResult
= group.toString(); return SUCCESS; } |
Java实现MongoDB的日期(Date)分组功能
最新推荐文章于 2023-09-18 14:54:31 发布