Commit 558f9c95b21bbf21c09ee745e56b302498ea6818

Authored by changpengfei
1 parent ad2be16960
Exists in master

添加分类查询接口;来自小程序或医院;患者信息统计。

Showing 1 changed file with 28 additions and 11 deletions

talkonlineweb/src/main/java/com/lyms/talkonlineweb/controller/PatientController.java View file @ 558f9c9
1 1 package com.lyms.talkonlineweb.controller;
2 2  
  3 +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
3 4 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
4 5 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
5 6 import com.lyms.talkonlineweb.domain.*;
6 7  
7 8  
... ... @@ -8,22 +9,21 @@
8 9 import com.lyms.talkonlineweb.util.Constant;
9 10 import com.lyms.talkonlineweb.util.JwtUtils;
10 11 import lombok.extern.log4j.Log4j2;
  12 +import lombok.extern.slf4j.Slf4j;
11 13 import org.springframework.beans.factory.annotation.Autowired;
12 14 import org.springframework.validation.BindingResult;
13 15 import org.springframework.validation.annotation.Validated;
14 16 import org.springframework.web.bind.annotation.*;
15 17  
16   -import java.util.Date;
17   -import java.util.HashMap;
18   -import java.util.List;
19   -import java.util.Map;
  18 +import java.util.*;
  19 +import java.util.stream.Collectors;
20 20  
21 21 /**
22 22 * 患者管理
23 23 */
24 24 @RestController
25 25 @RequestMapping("pat")
26   -@Log4j2
  26 +@Slf4j
27 27 public class PatientController {
28 28  
29 29 @Autowired
30 30  
31 31  
... ... @@ -53,11 +53,31 @@
53 53 * @return
54 54 */
55 55 @GetMapping("sltPatientLst")
56   - public BaseResponse sltPatientLst(PatientInfo patientInfo, int current, int size){
  56 + public BaseResponse sltPatientLst(PatientInfo patientInfo, int current, int size,@RequestParam(required = false) Integer qtype){
57 57 BaseResponse baseResponse=new BaseResponse();
58 58 Page<PatientInfo> page=new Page<>(current,size);
59   - Page<PatientInfo> patientPagePage=patientInfoService.page(page, Wrappers.query(patientInfo));
  59 + QueryWrapper<PatientInfo> queryWrapper = Wrappers.query(patientInfo);
  60 + if (Objects.nonNull(qtype) &&qtype==1){//从小程序购买
  61 + queryWrapper.inSql("id","SELECT t.`pid` FROM lyms_tcard t WHERE t.`fid`=1");
  62 + }
  63 + if (Objects.nonNull(qtype) && qtype==2){//从医院购买
  64 + queryWrapper.inSql("id","SELECT t.`pid` FROM lyms_tcard t WHERE t.`fid`=2");
  65 + }
  66 + Page<PatientInfo> patientPagePage=patientInfoService.page(page, queryWrapper);
  67 + List<PatientInfo> pLst=patientInfoService.list(queryWrapper);
  68 + int daiCnt=pLst.parallelStream().mapToInt(PatientInfo::getCcnt).sum();//待使用数量
60 69  
  70 + List<Integer> pids=pLst.parallelStream().map(PatientInfo::getId).collect(Collectors.toList());
  71 +
  72 + LymsTcard tcard=new LymsTcard();
  73 + QueryWrapper<LymsTcard> tWrapper = Wrappers.query(tcard);
  74 + if(pids.size()==0){
  75 + pids.add(-1);
  76 + }
  77 + tWrapper.in("pid",pids);
  78 + int sum=lymsTcardService.list(tWrapper).parallelStream().mapToInt(LymsTcard::getCnt).sum();
  79 +
  80 + log.error("统计需要改动数据结构:daiCnt:{} sum:{}",daiCnt,sum);
61 81 baseResponse.setObject(patientPagePage);
62 82  
63 83 return baseResponse;
... ... @@ -99,9 +119,6 @@
99 119 f=lymsPcaseService.saveOrUpdate(pcase);
100 120 String[] iArr=illness.split(",");
101 121  
102   - log.info(patient);
103   - log.info(pcase);
104   -
105 122 Map param=new HashMap();
106 123  
107 124 for (int i = 0; i < iArr.length; i++) {
... ... @@ -118,7 +135,7 @@
118 135 ness.setId(iLst.get(0).getId());
119 136 }
120 137 f=lymsIllnessService.saveOrUpdate(ness);
121   - log.info(ness);
  138 + log.info(ness.toString());
122 139 }
123 140  
124 141 //需要添加医院购买卡记录