Commit 403429d67b7318145364afd45ac509936a57d75f

Authored by dongqin
1 parent ddbc873943

为同步儿童历史的追访数据接口添加hospitalId字段

Showing 3 changed files with 31 additions and 17 deletions

platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/BabyAfterVisitController.java View file @ 403429d
... ... @@ -40,9 +40,13 @@
40 40 */
41 41 @RequestMapping(method = RequestMethod.GET, value = "/init/statistics")
42 42 @ResponseBody
43   - private BaseResponse syncInitStatistics(@RequestParam(required = false) String babyId, @RequestParam(required = false) String startTime,@RequestParam(required = false) String endTime) {
  43 + private BaseResponse syncInitStatistics(@RequestParam(required = false) String babyId,
  44 + @RequestParam(required = false) String startTime,
  45 + @RequestParam(required = false) String endTime,
  46 + @RequestParam(required = false) String hospitalId
  47 + ) {
44 48 try {
45   - return babyAfterVisitService.syncInitStatistics(babyId, startTime, endTime);
  49 + return babyAfterVisitService.syncInitStatistics(babyId, startTime, endTime, hospitalId);
46 50 } catch (ExecutionException e) {
47 51 e.printStackTrace();
48 52 } catch (InterruptedException e) {
platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/BabyAfterVisitService.java View file @ 403429d
... ... @@ -64,7 +64,7 @@
64 64 * @param babyId
65 65 * @return
66 66 */
67   - BaseResponse syncInitStatistics(String babyId, String startTime, String endTime) throws ExecutionException, InterruptedException;
  67 + BaseResponse syncInitStatistics(String babyId, String startTime, String endTime, String hospitalId) throws ExecutionException, InterruptedException;
68 68  
69 69 /**
70 70 * 档案转正列表/儿保检查/眼保检查/听力筛查
platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/BabyAfterVisitServiceImpl.java View file @ 403429d
... ... @@ -152,7 +152,7 @@
152 152 * @return
153 153 */
154 154 @Override
155   - public BaseResponse syncInitStatistics(String babyId, String startTime, String endTime) throws ExecutionException, InterruptedException {
  155 + public BaseResponse syncInitStatistics(String babyId, String startTime, String endTime, String hospitalId) throws ExecutionException, InterruptedException {
156 156 BaseResponse response = new BaseResponse();
157 157 BabyAfterVisitRequest afterVisitQuery = new BabyAfterVisitRequest();
158 158 afterVisitQuery.setLimit(500);
159 159  
... ... @@ -162,12 +162,12 @@
162 162 Map<String, Integer> map = new HashMap<>(16);
163 163  
164 164 // 访视概况
165   - Integer statisticsModelsSize = getStatisticsModelsSize(babyId, afterVisitQuery, startDate, endDate);
  165 + Integer statisticsModelsSize = getStatisticsModelsSize(babyId, afterVisitQuery, startDate, endDate, hospitalId);
166 166 map.put("statisticsModelsSize", statisticsModelsSize);
167 167  
168 168 // 档案转正
169 169 List<BabyAfterVisitInfoModel> infoModels = new ArrayList<>();
170   - setSyncAfterVisitInfoList( null, infoModels, afterVisitQuery, TYPE_BUILD, startDate, endDate);
  170 + setSyncAfterVisitInfoList( null, infoModels, afterVisitQuery, TYPE_BUILD, startDate, endDate, hospitalId);
171 171 mongoTemplate.insert(infoModels, BabyAfterVisitInfoModel.class);
172 172 map.put("infoModels-build", infoModels.size());
173 173  
... ... @@ -205,7 +205,7 @@
205 205 }
206 206 }
207 207 }
208   - setSyncAfterVisitInfoList( ids, infoCheckModels, afterVisitQuery, TYPE_CHECK, startDate, endDate);
  208 + setSyncAfterVisitInfoList( ids, infoCheckModels, afterVisitQuery, TYPE_CHECK, startDate, endDate, hospitalId);
209 209 mongoTemplate.insert(infoCheckModels, BabyAfterVisitInfoModel.class);
210 210 map.put("infoModels-check-size", infoCheckModels.size());
211 211  
... ... @@ -243,7 +243,7 @@
243 243 }
244 244 }
245 245  
246   - setSyncAfterVisitInfoList(babyIds, infoEyeCheckModels, afterVisitQuery, TYPE_EYE_CHECK, startDate, endDate);
  246 + setSyncAfterVisitInfoList(babyIds, infoEyeCheckModels, afterVisitQuery, TYPE_EYE_CHECK, startDate, endDate, hospitalId);
247 247 mongoTemplate.insert(infoEyeCheckModels, BabyAfterVisitInfoModel.class);
248 248 map.put("infoModels-eyeCheck-size", infoEyeCheckModels.size());
249 249  
250 250  
... ... @@ -264,11 +264,15 @@
264 264 * @throws InterruptedException
265 265 * @throws ExecutionException
266 266 */
267   - private Integer getStatisticsModelsSize(String babyId, BabyAfterVisitRequest afterVisitQuery, Date startDate, Date endDate) throws InterruptedException, ExecutionException {
  267 + private Integer getStatisticsModelsSize(String babyId, BabyAfterVisitRequest afterVisitQuery, Date startDate, Date endDate, String hospitalId) throws InterruptedException, ExecutionException {
268 268 List<BabyAfterVisitStatisticsModel> statisticsModels = new LinkedList<>();
269 269 if (StringUtils.isNotEmpty(babyId)) {
270 270 // 单条数据,方便测试
271   - BabyModel babyModel = mongoTemplate.findOne(Query.query(Criteria.where("_id").is(babyId).and("created").gte(startDate).lte(endDate)), BabyModel.class);
  271 + Query query = Query.query(Criteria.where("_id").is(babyId).and("created").gte(startDate).lte(endDate));
  272 + if (StringUtils.isNotEmpty(hospitalId)) {
  273 + query.addCriteria(Criteria.where("hospitalId").is(hospitalId));
  274 + }
  275 + BabyModel babyModel = mongoTemplate.findOne(query, BabyModel.class);
272 276 if (babyModel != null) {
273 277 List<BabyModel> babyModelList = new ArrayList<>();
274 278 babyModelList.add(babyModel);
... ... @@ -279,7 +283,7 @@
279 283 } else {
280 284  
281 285 // 递归获取要同步的数据集
282   - setSyncList(statisticsModels, afterVisitQuery, startDate, endDate);
  286 + setSyncList(statisticsModels, afterVisitQuery, startDate, endDate, hospitalId);
283 287 }
284 288 // 批量保存
285 289 mongoTemplate.insert(statisticsModels, BabyAfterVisitStatisticsModel.class);
286 290  
... ... @@ -599,10 +603,13 @@
599 603 * @throws ExecutionException
600 604 * @throws InterruptedException
601 605 */
602   - private void setSyncAfterVisitInfoList(List<String> ids , List<BabyAfterVisitInfoModel> infoModels, BabyAfterVisitRequest afterVisitQuery, Integer type, Date startDate, Date endDate)
  606 + private void setSyncAfterVisitInfoList(List<String> ids , List<BabyAfterVisitInfoModel> infoModels, BabyAfterVisitRequest afterVisitQuery, Integer type, Date startDate, Date endDate, String hospitalId)
603 607 throws ExecutionException, InterruptedException {
604 608 Query query = new Query();
605 609 query.addCriteria(Criteria.where("created").gte(startDate).lte(endDate));
  610 + if (StringUtils.isNotEmpty(hospitalId)) {
  611 + query.addCriteria(Criteria.where("hospitalId").is(hospitalId));
  612 + }
606 613 long count = 0L;
607 614 if (Objects.equals(TYPE_BUILD, type)) {
608 615  
609 616  
610 617  
... ... @@ -664,13 +671,13 @@
664 671 for (int i = currentPage+ 1; i <= lastPage ; i++) {
665 672 afterVisitQuery.setPage(i);
666 673 if (TYPE_BUILD.equals(type)) {
667   - setSyncAfterVisitInfoList( null, infoModels, afterVisitQuery, type, startDate, endDate);
  674 + setSyncAfterVisitInfoList( null, infoModels, afterVisitQuery, type, startDate, endDate, hospitalId);
668 675 }
669 676 if (TYPE_CHECK.equals(type)) {
670   - setSyncAfterVisitInfoList( ids, infoModels, afterVisitQuery, type, startDate, endDate);
  677 + setSyncAfterVisitInfoList( ids, infoModels, afterVisitQuery, type, startDate, endDate, hospitalId);
671 678 }
672 679 if (TYPE_EYE_CHECK.equals(type)) {
673   - setSyncAfterVisitInfoList( ids, infoModels, afterVisitQuery, type, startDate, endDate);
  680 + setSyncAfterVisitInfoList( ids, infoModels, afterVisitQuery, type, startDate, endDate, hospitalId);
674 681 }
675 682  
676 683 }
677 684  
... ... @@ -682,10 +689,13 @@
682 689 * @param statisticsModels
683 690 * @param afterVisitQuery
684 691 */
685   - private void setSyncList(List<BabyAfterVisitStatisticsModel> statisticsModels, BabyAfterVisitRequest afterVisitQuery, Date startDate, Date endDate) throws ExecutionException, InterruptedException {
  692 + private void setSyncList(List<BabyAfterVisitStatisticsModel> statisticsModels, BabyAfterVisitRequest afterVisitQuery, Date startDate, Date endDate, String hospitalId) throws ExecutionException, InterruptedException {
686 693  
687 694 Query query = new Query();
688 695 query.addCriteria(Criteria.where("created").gte(startDate).lte(endDate));
  696 + if (StringUtils.isNotEmpty(hospitalId)) {
  697 + query.addCriteria(Criteria.where("hospitalId").is(hospitalId));
  698 + }
689 699 long count = mongoTemplate.count(query, BabyModel.class);
690 700 afterVisitQuery.mysqlBuild((int) count);
691 701 query.with(new Sort(new Sort.Order(Sort.Direction.DESC, "created")));
... ... @@ -727,7 +737,7 @@
727 737 }
728 738 for (int i = currentPage+ 1; i <= lastPage ; i++) {
729 739 afterVisitQuery.setPage(i);
730   - setSyncList(statisticsModels, afterVisitQuery, startDate, endDate);
  740 + setSyncList(statisticsModels, afterVisitQuery, startDate, endDate, hospitalId);
731 741 }
732 742 }
733 743