Commit a834775076619c5c6ca13765942a41a311516c62

Authored by liquanyu
1 parent 9483e1a05b

工位统计

Showing 2 changed files with 3 additions and 48 deletions

platform-common/src/main/java/com/lyms/platform/common/dao/operator/MongoQuery.java View file @ a834775
... ... @@ -44,9 +44,9 @@
44 44 if (null != coniticon &&coniticon.getCriteria() !=null) {
45 45 query.addCriteria(coniticon.getCriteria());
46 46 }
47   -// if (CollectionUtils.isNotEmpty(sortList)) {
48   -// query.with(new Sort(sortList));
49   -// }
  47 + if (CollectionUtils.isNotEmpty(sortList)) {
  48 + query.with(new Sort(sortList));
  49 + }
50 50 if (end > 0) {
51 51 query.skip(start).limit(end);
52 52 }
platform-transfer/src/main/java/com/lyms/platform/contraller/TestController.java View file @ a834775
1   -package com.lyms.platform.contraller;
2   -
3   -import com.lyms.platform.pojo.Patients;
4   -import org.springframework.beans.factory.annotation.Autowired;
5   -import org.springframework.data.domain.Sort;
6   -import org.springframework.data.mongodb.core.MongoTemplate;
7   -import org.springframework.data.mongodb.core.aggregation.Aggregation;
8   -import org.springframework.data.mongodb.core.aggregation.AggregationResults;
9   -import org.springframework.data.mongodb.core.query.Criteria;
10   -import org.springframework.stereotype.Controller;
11   -import org.springframework.web.bind.annotation.RequestMapping;
12   -import org.springframework.web.bind.annotation.RequestMethod;
13   -import org.springframework.web.bind.annotation.ResponseBody;
14   -@Controller
15   -public class TestController {
16   - @Autowired
17   - private MongoTemplate mongoTemplate;
18   -
19   - @RequestMapping(value = "/testMongodb", method = RequestMethod.GET)
20   - @ResponseBody
21   - public Object testMongodb() {
22   - // TODO 店长是否实名认证
23   - Aggregation aggregation = Aggregation.newAggregation(
24   - // 关联member表
25   - Aggregation.lookup(
26   - "lyms_matdeliver", // 从表表名
27   - "parentId", // 如shop被查询主表的userId,相对于member表的外键
28   - "_id", // 如member从表的主键_id,相对于member表的主键
29   - "docs_member" // 联合查询出的别名,用于多条件查询表明前缀,相当于SQL中的临时表名
30   - ),
31   - Aggregation.match(
32   - Criteria.where("type").is(3) // 添加member表查询条件,如用户手机号,此处可举一反三
33   - ),
34   - // 分页:页码
35   - Aggregation.skip(1),
36   - // 分页:条数
37   - Aggregation.limit((long) 10),
38   - // 排序
39   - Aggregation.sort(Sort.Direction.DESC,"created")
40   - );
41   - // 执行查询,这里的shop必须是查询的主表名
42   - AggregationResults<Patients> results = mongoTemplate.aggregate(aggregation, "lyms_patient", Patients.class);
43   - return results.getMappedResults();
44   - }
45   -}