Commit 361c1687ea98441d5219241e27facd02fb1eb731
1 parent
83a1db66df
Exists in
master
and in
6 other branches
辅助建档分页
Showing 2 changed files with 19 additions and 4 deletions
platform-biz-patient-service/src/main/java/com/lyms/platform/biz/service/PersonService.java
View file @
361c168
... | ... | @@ -7,6 +7,7 @@ |
7 | 7 | import com.lyms.platform.query.PersonModelQuery; |
8 | 8 | import org.apache.commons.lang.StringUtils; |
9 | 9 | import org.springframework.beans.factory.annotation.Autowired; |
10 | +import org.springframework.data.domain.Sort; | |
10 | 11 | import org.springframework.stereotype.Service; |
11 | 12 | |
12 | 13 | import java.util.List; |
13 | 14 | |
... | ... | @@ -34,8 +35,19 @@ |
34 | 35 | personModelQuery.mysqlBuild(personDao.queryCount(query)); |
35 | 36 | query.start(personModelQuery.getOffset()).end(personModelQuery.getLimit()); |
36 | 37 | } |
38 | + return personDao.queryPersons(query); | |
39 | + } | |
37 | 40 | |
38 | - return personDao.queryPersons(personModelQuery.convertToQuery()); | |
41 | + | |
42 | + public List<PersonModel> queryPersons(PersonModelQuery personModelQuery,Sort.Direction direction,String field) { | |
43 | + | |
44 | + MongoQuery query = personModelQuery.convertToQuery(); | |
45 | + if (StringUtils.isNotEmpty(personModelQuery.getNeed())) { | |
46 | + personModelQuery.mysqlBuild(personDao.queryCount(query)); | |
47 | + query.start(personModelQuery.getOffset()).end(personModelQuery.getLimit()); | |
48 | + } | |
49 | + | |
50 | + return personDao.queryPersons(query.addOrder(direction, field)); | |
39 | 51 | } |
40 | 52 | } |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/TestController.java
View file @
361c168
... | ... | @@ -1907,22 +1907,25 @@ |
1907 | 1907 | @Override |
1908 | 1908 | public void run() { |
1909 | 1909 | int limt = 1000; |
1910 | - int page = 0; | |
1910 | + int page = 1; | |
1911 | 1911 | PersonModelQuery personModelQuery = new PersonModelQuery(); |
1912 | 1912 | personModelQuery.setYn(YnEnums.YES.getId()); |
1913 | 1913 | personModelQuery.setTypes(new Integer[]{1, 3}); //孕妇或者产妇基本信息 |
1914 | 1914 | personModelQuery.setNeed("true"); |
1915 | + personModelQuery.setLimit(limt); | |
1915 | 1916 | if (StringUtils.isNotEmpty(id)) |
1916 | 1917 | { |
1917 | 1918 | personModelQuery.setId(id); |
1918 | 1919 | } |
1919 | 1920 | while (true) |
1920 | 1921 | { |
1922 | + System.out.println("page======"+page); | |
1921 | 1923 | personModelQuery.setPage(page); |
1922 | - personModelQuery.setLimit(limt); | |
1923 | - List<PersonModel> personModels = personService.queryPersons(personModelQuery); | |
1924 | + | |
1925 | + List<PersonModel> personModels = personService.queryPersons(personModelQuery,Sort.Direction.DESC, "created"); | |
1924 | 1926 | if (CollectionUtils.isNotEmpty(personModels)) |
1925 | 1927 | { |
1928 | + System.out.println("sss"); | |
1926 | 1929 | int batchSize = 200; |
1927 | 1930 | int end = 0; |
1928 | 1931 | for (int i = 0; i < personModels.size(); i += batchSize) { |