diff --git a/talkonlineweb/src/main/java/com/lyms/talkonlineweb/controller/PatientController.java b/talkonlineweb/src/main/java/com/lyms/talkonlineweb/controller/PatientController.java index b788671..f89a00f 100644 --- a/talkonlineweb/src/main/java/com/lyms/talkonlineweb/controller/PatientController.java +++ b/talkonlineweb/src/main/java/com/lyms/talkonlineweb/controller/PatientController.java @@ -1,5 +1,6 @@ package com.lyms.talkonlineweb.controller; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.lyms.talkonlineweb.domain.*; @@ -8,22 +9,21 @@ import com.lyms.talkonlineweb.service.*; import com.lyms.talkonlineweb.util.Constant; import com.lyms.talkonlineweb.util.JwtUtils; import lombok.extern.log4j.Log4j2; +import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.validation.BindingResult; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; +import java.util.stream.Collectors; /** * 患者管理 */ @RestController @RequestMapping("pat") -@Log4j2 +@Slf4j public class PatientController { @Autowired @@ -53,11 +53,31 @@ public class PatientController { * @return */ @GetMapping("sltPatientLst") - public BaseResponse sltPatientLst(PatientInfo patientInfo, int current, int size){ + public BaseResponse sltPatientLst(PatientInfo patientInfo, int current, int size,@RequestParam(required = false) Integer qtype){ BaseResponse baseResponse=new BaseResponse(); Page page=new Page<>(current,size); - Page patientPagePage=patientInfoService.page(page, Wrappers.query(patientInfo)); + QueryWrapper queryWrapper = Wrappers.query(patientInfo); + if (Objects.nonNull(qtype) &&qtype==1){//从小程序购买 + queryWrapper.inSql("id","SELECT t.`pid` FROM lyms_tcard t WHERE t.`fid`=1"); + } + if (Objects.nonNull(qtype) && qtype==2){//从医院购买 + queryWrapper.inSql("id","SELECT t.`pid` FROM lyms_tcard t WHERE t.`fid`=2"); + } + Page patientPagePage=patientInfoService.page(page, queryWrapper); + List pLst=patientInfoService.list(queryWrapper); + int daiCnt=pLst.parallelStream().mapToInt(PatientInfo::getCcnt).sum();//待使用数量 + List pids=pLst.parallelStream().map(PatientInfo::getId).collect(Collectors.toList()); + + LymsTcard tcard=new LymsTcard(); + QueryWrapper tWrapper = Wrappers.query(tcard); + if(pids.size()==0){ + pids.add(-1); + } + tWrapper.in("pid",pids); + int sum=lymsTcardService.list(tWrapper).parallelStream().mapToInt(LymsTcard::getCnt).sum(); + + log.error("统计需要改动数据结构:daiCnt:{} sum:{}",daiCnt,sum); baseResponse.setObject(patientPagePage); return baseResponse; @@ -99,9 +119,6 @@ public class PatientController { f=lymsPcaseService.saveOrUpdate(pcase); String[] iArr=illness.split(","); - log.info(patient); - log.info(pcase); - Map param=new HashMap(); for (int i = 0; i < iArr.length; i++) { @@ -118,7 +135,7 @@ public class PatientController { ness.setId(iLst.get(0).getId()); } f=lymsIllnessService.saveOrUpdate(ness); - log.info(ness); + log.info(ness.toString()); } //需要添加医院购买卡记录