Quellcode durchsuchen

优化sql语句

18339543638 vor 1 Jahr
Ursprung
Commit
f99137af09

+ 43 - 4
nb-service/web-service/src/main/java/com/nb/web/service/bus/service/LocalBusInfusionHistoryService.java

@@ -1,6 +1,7 @@
 package com.nb.web.service.bus.service;
 
 import cn.hutool.core.collection.CollectionUtil;
+import cn.hutool.core.util.ObjectUtil;
 import cn.hutool.core.util.StrUtil;
 import cn.hutool.json.JSONUtil;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@@ -26,6 +27,7 @@ import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.Assert;
 
+import javax.validation.constraints.NotNull;
 import java.util.*;
 import java.util.stream.Collectors;
 
@@ -161,7 +163,7 @@ public class LocalBusInfusionHistoryService extends BaseService<BusInfusionHisto
         if(CollectionUtil.size(undoConfigs)>50){
             throw new CustomException("一次性结束管理数量不能超过50个");
         }
-            undoConfigs.forEach(undoConfig -> this.undo(undoConfig,finishClinic));
+        undoConfigs.forEach(undoConfig -> this.undo(undoConfig,finishClinic));
 //        }else {
 //            //批量结束临床
 //            Map<String, List<ManualUndoConfig>> configsMap = undoConfigs.stream().collect(Collectors.groupingBy(ManualUndoConfig::getTenantId));
@@ -319,15 +321,52 @@ public class LocalBusInfusionHistoryService extends BaseService<BusInfusionHisto
     }
 
     public List<CombineEvalResult> queryStatsEval(CombineQuery query) {
-        return this.baseMapper.queryStatsEval(query);
+        List<CombineEvalResult> result = this.baseMapper.queryStatsEval(query);
+        fillEvalResultPatientInfo(result);
+        return result;
     }
 
     public List<CombineEvalResult> listStatsEval(CombineQuery query) {
-        return this.baseMapper.listStatsEval(query);
+        List<CombineEvalResult> result = this.baseMapper.listStatsEval(query);
+        fillEvalResultPatientInfo(result);
+        return result;
     }
 
     public IPage<CombineEvalResult> pageStatsEval(CombineQuery query, Page<CombineResult> page) {
-        return this.baseMapper.pageStatsEval(query,page);
+        IPage<CombineEvalResult> result = this.baseMapper.pageStatsEval(query, page);
+        fillEvalResultPatientInfo(result.getRecords());
+        return result;
+    }
+
+    private void fillEvalResultPatientInfo(List<CombineEvalResult> evals){
+        if(CollectionUtil.isEmpty(evals)){
+            return;
+        }
+        Set<String> clinicIds = evals.stream()
+                .filter(e -> StrUtil.isNotBlank(e.getClinicId()))
+                .map(CombineEvalResult::getClinicId)
+                .collect(Collectors.toSet());
+        if(CollectionUtil.isEmpty(clinicIds)){
+            return;
+        }
+        List<BusClinicEntity> clinics = clinicService.listByIds(clinicIds);
+        if(CollectionUtil.isEmpty(clinics)){
+            return;
+        }
+        Map<String, BusClinicEntity> clinicMap = clinics.stream()
+                .collect(Collectors.groupingBy(BusClinicEntity::getId, Collectors.collectingAndThen(Collectors.toList(), CollectionUtil::getFirst)));
+        for (CombineEvalResult eval : evals) {
+            String clinicId = eval.getClinicId();
+            BusClinicEntity clinic = clinicMap.get(clinicId);
+            if(ObjectUtil.isNull(clinic)){
+                continue;
+            }
+            eval.setPatientName(clinic.getPatientName());
+            eval.setPatientCode(clinic.getPatientCode());
+            eval.setPatientGender(clinic.getPatientGender());
+            eval.setPatientAge(clinic.getPatientAge());
+            eval.setSurgeryName(clinic.getSurgeryName());
+        }
     }
 
     public BusInfusionModifyEntity lastModify(String infusionId){

+ 2 - 0
nb-service/web-service/src/main/java/com/nb/web/service/bus/service/dto/CombineEvalResult.java

@@ -18,6 +18,8 @@ import java.util.Date;
 @Data
 public class CombineEvalResult extends CombineResult {
 
+    private String clinicId;
+
     @ApiModelProperty("评价时间")
     @ExcelProperty("评价时间")
     private Date evalTime;

+ 4 - 48
nb-service/web-service/src/main/resources/mapper/bus/BusInfusionHistoryMapper.xml

@@ -315,22 +315,8 @@
         i.id as infusion_id,
         i.last_upload_time as last_upload_time,
         i.start_time as infusion_start_time,
-        c.patient_code as patient_code,
-        c.ward as ward,
-        c.bed_no as bed_no,
-        c.surgery_name as surgery_name,
-        c.asa as asa,
-        c.patient_gender as patient_gender,
-        c.`patient_name` as patient_name,
-        c.`patient_age` as patient_age,
-        c.weight as weight,
-        c.`height` as height,
-        c.ana_doctor as ana_doctor,
-        c.ana_type as ana_type,
-        c.anal_type as anal_type,
-        c.surgery_doctor as surgery_doctor,
-        c.formula as formula,
-        c.entrust as entrust,
+        e.patient_code as patient_code,
+        c.id as clinic_id,
         e.evaluate_time as evaluate_time,
         e.statics as statics,
         e.activity as activity,
@@ -379,22 +365,7 @@
         i.id as infusion_id,
         i.last_upload_time as last_upload_time,
         i.start_time as infusion_start_time,
-        c.patient_code as patient_code,
-        c.ward as ward,
-        c.bed_no as bed_no,
-        c.surgery_name as surgery_name,
-        c.asa as asa,
-        c.patient_gender as patient_gender,
-        c.`patient_name` as patient_name,
-        c.`patient_age` as patient_age,
-        c.weight as weight,
-        c.`height` as height,
-        c.ana_doctor as ana_doctor,
-        c.ana_type as ana_type,
-        c.anal_type as anal_type,
-        c.surgery_doctor as surgery_doctor,
-        c.formula as formula,
-        c.entrust as entrust,
+        c.id as clinic_id,
         e.evaluate_time as evaluate_time,
         e.statics as statics,
         e.activity as activity,
@@ -443,22 +414,7 @@
         i.id as infusion_id,
         i.last_upload_time as last_upload_time,
         i.start_time as infusion_start_time,
-        c.patient_code as patient_code,
-        c.ward as ward,
-        c.bed_no as bed_no,
-        c.surgery_name as surgery_name,
-        c.asa as asa,
-        c.patient_gender as patient_gender,
-        c.`patient_name` as patient_name,
-        c.`patient_age` as patient_age,
-        c.weight as weight,
-        c.`height` as height,
-        c.ana_doctor as ana_doctor,
-        c.ana_type as ana_type,
-        c.anal_type as anal_type,
-        c.surgery_doctor as surgery_doctor,
-        c.formula as formula,
-        c.entrust as entrust,
+        c.id as clinic_id,
         e.evaluate_time as evaluate_time,
         e.statics as statics,
         e.activity as activity,