Prechádzať zdrojové kódy

修改临床根据条件查询接口

zhouzeyu 1 týždeň pred
rodič
commit
fcec23c4ea

+ 3 - 1
tr-modules/tr-modules-phototherapy/src/main/java/cn/tr/module/phototherapy/common/controller/BusClinicController.java

@@ -4,7 +4,9 @@ import cn.dev33.satoken.annotation.SaCheckPermission;
 import cn.tr.core.validation.Insert;
 import cn.tr.core.validation.Update;
 import cn.tr.core.pojo.CommonResult;
+import cn.tr.module.phototherapy.common.dto.BusPatientListQueryDTO;
 import cn.tr.module.phototherapy.common.dto.PatientTherapyDetailDTO;
+import cn.tr.module.phototherapy.common.vo.PatientTherapyRecordVO;
 import lombok.AllArgsConstructor;
 import io.swagger.v3.oas.annotations.tags.Tag;
 import io.swagger.v3.oas.annotations.Operation;
@@ -37,7 +39,7 @@ public class BusClinicController extends BaseController{
 
     @Operation(summary = "根据条件查询临床表", description = "权限: 无")
     @PostMapping("/query/page")
-    public TableDataInfo<BusClinicDTO> selectList(@RequestBody BusClinicQueryDTO query) {
+    public TableDataInfo<PatientTherapyRecordVO> selectList(@RequestBody BusPatientListQueryDTO query) {
         startPage();
         return getDataTable(busClinicService.selectBusClinicList(query));
     }

+ 50 - 0
tr-modules/tr-modules-phototherapy/src/main/java/cn/tr/module/phototherapy/common/dto/BusPatientListQueryDTO.java

@@ -0,0 +1,50 @@
+package cn.tr.module.phototherapy.common.dto;
+
+import cn.tr.module.phototherapy.common.enums.*;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+import lombok.ToString;
+
+import java.io.Serializable;
+import java.sql.Timestamp;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * 临床表查询参数
+ *
+ * @author CodeGenerator
+ * @date 2026-01-12
+ **/
+@Data
+@Schema(description = "临床表查询参数")
+@ToString
+public class BusPatientListQueryDTO implements Serializable{
+    private static final long serialVersionUID = 1L;
+
+    @Schema(description = "患者姓名")
+    private String patientName;
+
+    @Schema(description = "年龄区间(列表第一个值为最小年龄,第二个为最大年龄)")
+    private List<Integer> patientAge;
+
+    @Schema(description = "患者性别(0女 1男 2未知)")
+    private PatientGenderEnum patientGender;
+
+    @Schema(description = "所属分组(0治疗组 1对照组)")
+    private GroupTypeEnum groupType;
+
+    @Schema(description = "方案状态(0启用 1等待启用 2终止)")
+    private TherapyPlanStatusEnum planStatus;
+
+    @Schema(description = "设备报警")
+    private DeviceAlarmEnum deviceAlarm;
+
+    @Schema(description = "是否绑定")
+    private IsCurrentBindEnum isCurrentBind;
+
+    @Schema(description = "患者上次治疗时间")
+    private List<Timestamp> lastTreatmentTime;
+
+}

+ 11 - 0
tr-modules/tr-modules-phototherapy/src/main/java/cn/tr/module/phototherapy/common/repository/BusClinicRepository.java

@@ -1,12 +1,16 @@
 package cn.tr.module.phototherapy.common.repository;
 
+import cn.tr.module.phototherapy.common.dto.BusPatientListQueryDTO;
 import cn.tr.module.phototherapy.common.vo.PatientTherapyDetailVO;
+import cn.tr.module.phototherapy.common.vo.PatientTherapyRecordVO;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import org.apache.ibatis.annotations.Mapper;
 import cn.tr.module.phototherapy.common.po.BusClinicPO;
 import org.apache.ibatis.annotations.Param;
 import org.springframework.stereotype.Repository;
 
+import java.util.List;
+
 /**
  * 临床表Mapper接口
  *
@@ -22,4 +26,11 @@ public interface BusClinicRepository extends BaseMapper<BusClinicPO> {
      * @return cn.tr.module.phototherapy.common.vo.PatientTherapyDetailVO
      **/
     PatientTherapyDetailVO selectPatientTherapyDetailById(@Param("patientUniqueId") String patientUniqueId);
+
+    /**
+     * 根据条件查询患者列表
+     * @param query
+     * @return java.util.List<cn.tr.module.phototherapy.common.vo.PatientTherapyRecordVO>
+     **/
+    List<PatientTherapyRecordVO> selectPatientLists(@Param("query") BusPatientListQueryDTO query);
 }

+ 3 - 1
tr-modules/tr-modules-phototherapy/src/main/java/cn/tr/module/phototherapy/common/service/IBusClinicService.java

@@ -2,7 +2,9 @@ package cn.tr.module.phototherapy.common.service;
 
 import cn.tr.module.phototherapy.common.dto.BusClinicDTO;
 import cn.tr.module.phototherapy.common.dto.BusClinicQueryDTO;
+import cn.tr.module.phototherapy.common.dto.BusPatientListQueryDTO;
 import cn.tr.module.phototherapy.common.dto.PatientTherapyDetailDTO;
+import cn.tr.module.phototherapy.common.vo.PatientTherapyRecordVO;
 
 import java.util.*;
 import java.util.Collection;
@@ -21,7 +23,7 @@ public interface IBusClinicService{
      * @author   CodeGenerator
      * @date     2026-01-12
      */
-    List<BusClinicDTO> selectBusClinicList(BusClinicQueryDTO query);
+    List<PatientTherapyRecordVO> selectBusClinicList(BusPatientListQueryDTO query);
 
     /**
      * 根据id查询临床表

+ 4 - 17
tr-modules/tr-modules-phototherapy/src/main/java/cn/tr/module/phototherapy/common/service/impl/BusClinicServiceImpl.java

@@ -1,7 +1,9 @@
 package cn.tr.module.phototherapy.common.service.impl;
 
+import cn.tr.module.phototherapy.common.dto.BusPatientListQueryDTO;
 import cn.tr.module.phototherapy.common.dto.PatientTherapyDetailDTO;
 import cn.tr.module.phototherapy.common.vo.PatientTherapyDetailVO;
+import cn.tr.module.phototherapy.common.vo.PatientTherapyRecordVO;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import jakarta.annotation.Resource;
 import org.springframework.stereotype.Service;
@@ -40,23 +42,8 @@ public class BusClinicServiceImpl extends ServiceImpl<BusClinicRepository, BusCl
      * @date 2026-01-12
      */
     @Override
-    public List<BusClinicDTO> selectBusClinicList(BusClinicQueryDTO query) {
-        return BusClinicMapper.INSTANCE.convertDtoList(
-                this.list(new LambdaQueryWrapper<BusClinicPO>()
-                        .eq(ObjectUtil.isNotNull(query.getId()), BusClinicPO::getId, query.getId())
-                        .eq(ObjectUtil.isNotNull(query.getPatientUniqueId()), BusClinicPO::getPatientUniqueId, query.getPatientUniqueId())
-                        .eq(ObjectUtil.isNotNull(query.getUserId()), BusClinicPO::getUserId, query.getUserId())
-                        .eq(ObjectUtil.isNotNull(query.getLastTreatmentTime()), BusClinicPO::getLastTreatmentTime, query.getLastTreatmentTime())
-                        .eq(ObjectUtil.isNotNull(query.getTherapyPlanId()), BusClinicPO::getTherapyPlanId, query.getTherapyPlanId())
-                        .like(ObjectUtil.isNotNull(query.getPatientName()), BusClinicPO::getPatientName, query.getPatientName())
-                        .eq(ObjectUtil.isNotNull(query.getPatientAge()), BusClinicPO::getPatientAge, query.getPatientAge())
-                        .eq(ObjectUtil.isNotNull(query.getPatientGender()), BusClinicPO::getPatientGender, query.getPatientGender())
-                        .like(ObjectUtil.isNotNull(query.getPatientPhone()), BusClinicPO::getPatientPhone, query.getPatientPhone())
-                        .like(ObjectUtil.isNotNull(query.getPatientAddress()), BusClinicPO::getPatientAddress, query.getPatientAddress())
-                        .eq(ObjectUtil.isNotNull(query.getDeviceId()), BusClinicPO::getDeviceId, query.getDeviceId())
-                        .eq(ObjectUtil.isNotNull(query.getTenantId()), BusClinicPO::getTenantId, query.getTenantId())
-                )
-        );
+    public List<PatientTherapyRecordVO> selectBusClinicList(BusPatientListQueryDTO query) {
+        return busClinicRepository.selectPatientLists(query);
     }
 
     ;

+ 1 - 0
tr-modules/tr-modules-phototherapy/src/main/java/cn/tr/module/phototherapy/common/service/impl/BusTherapyRecordServiceImpl.java

@@ -37,6 +37,7 @@ public class BusTherapyRecordServiceImpl extends ServiceImpl<BusTherapyRecordRep
     private BusTherapyRecordRepository therapyRecordRepository;
 
 
+
     /**
     * 根据条件查询治疗记录
     * @param    query 查询参数

+ 17 - 9
tr-modules/tr-modules-phototherapy/src/main/java/cn/tr/module/phototherapy/common/vo/PatientTherapyRecordVO.java

@@ -1,5 +1,9 @@
 package cn.tr.module.phototherapy.common.vo;
 
+import cn.tr.module.phototherapy.common.enums.DeviceAlarmEnum;
+import cn.tr.module.phototherapy.common.enums.GroupTypeEnum;
+import cn.tr.module.phototherapy.common.enums.IsCurrentBindEnum;
+import cn.tr.module.phototherapy.common.enums.TherapyPlanStatusEnum;
 import com.fasterxml.jackson.annotation.JsonFormat;
 import io.swagger.v3.oas.annotations.media.Schema;
 import lombok.Data;
@@ -38,25 +42,29 @@ public class PatientTherapyRecordVO {
     @Schema(description = "患者上次治疗时间")
     private Date lastTreatmentTime;
 
-    /** 阶段类型 */
-    @Schema(description = "阶段类型")
-    private String phaseType;
-
-    /** 阶段目标次数 */
-    @Schema(description = "阶段目标次数")
-    private Integer phaseTargetTimes;
-
     /** 阶段频率(如每日1次/隔日1次/每周3次) */
     @Schema(description = "阶段频率(如每日1次/隔日1次/每周3次)")
     private String phaseFreq;
 
+    /** 阶段建议时长 */
+    @Schema(description = "阶段建议时长")
+    private Integer phaseDurationMin;
+
+    @Schema(description = "设备报警")
+    private DeviceAlarmEnum deviceAlarm;
 
     @Schema(description = "治疗方案")
     private String therapyPlanDesc;
 
+    @Schema(description = "是否绑定")
+    private IsCurrentBindEnum isCurrentBind;
+
     /** 方案状态(0启用 1等待启用 2终止) */
     @Schema(description = "方案状态(0启用 1等待启用 2终止)")
-    private Integer planStatus;
+    private TherapyPlanStatusEnum planStatus;
+
+    @Schema(description = "所属分组(0治疗组 1对照组)")
+    private GroupTypeEnum groupType;
 
     @Schema(description = "设备id")
     private String deviceId;

+ 5 - 0
tr-modules/tr-modules-phototherapy/src/main/java/cn/tr/module/phototherapy/common/vo/TherapyRecordDetailVO.java

@@ -1,5 +1,6 @@
 package cn.tr.module.phototherapy.common.vo;
 
+import com.fasterxml.jackson.annotation.JsonFormat;
 import io.swagger.v3.oas.annotations.media.Schema;
 import lombok.Data;
 
@@ -32,4 +33,8 @@ public class TherapyRecordDetailVO {
 
     @Schema(description = "阶段持续时间(分钟)")
     private Integer phaseDurationMin;
+
+    @Schema(description = "患者上次治疗时间")
+    private Date lastTreatmentTime;
+
 }

+ 83 - 19
tr-modules/tr-modules-phototherapy/src/main/resources/mapper/phototherapy/BusClinicRepository.xml

@@ -3,30 +3,29 @@
 <mapper namespace="cn.tr.module.phototherapy.common.repository.BusClinicRepository">
 
     <select id="selectPatientTherapyDetailById" resultType="cn.tr.module.phototherapy.common.vo.PatientTherapyDetailVO">
-        SELECT
-            c.patient_name,
-            c.patient_age,
-            c.patient_gender,
-            c.patient_unique_id,
-            c.patient_phone,
-            c.patient_address,
-            c.last_treatment_time,
-            c.group_type,
-            COUNT(DISTINCT DATE(r.therapy_start_time)) as therapy_count,
-            COALESCE(MAX(r_today.therapy_status), 0) as therapy_status,
-            tp.create_time as startTime,
-            tp.phase_type,
-            tp.phase_freq,
-            tp.phase_duration_min,
-            tp.plan_doctor,
-            c.device_id,
-            c.bind_start_time
+        SELECT c.patient_name,
+               c.patient_age,
+               c.patient_gender,
+               c.patient_unique_id,
+               c.patient_phone,
+               c.patient_address,
+               c.last_treatment_time,
+               c.group_type,
+               COUNT(DISTINCT DATE (r.therapy_start_time)) as therapy_count,
+               COALESCE(MAX(r_today.therapy_status), 0)    as therapy_status,
+               tp.create_time                              as startTime,
+               tp.phase_type,
+               tp.phase_freq,
+               tp.phase_duration_min,
+               tp.plan_doctor,
+               c.device_id,
+               c.bind_start_time
         FROM bus_clinic c
                  LEFT JOIN bus_therapy_plan tp ON c.therapy_plan_id = tp.id
                  LEFT JOIN bus_therapy_record r ON c.id = r.clinic_id AND r.is_delete = 0
                  LEFT JOIN bus_therapy_record r_today ON c.id = r_today.clinic_id
             AND r_today.is_delete = 0
-            AND DATE(r_today.therapy_start_time) = DATE(NOW())
+            AND DATE (r_today.therapy_start_time) = DATE (NOW())
         WHERE c.patient_unique_id = #{patientUniqueId}
           AND c.is_delete = 0
         GROUP BY
@@ -35,4 +34,69 @@
             tp.create_time, tp.phase_type, tp.phase_freq,
             tp.phase_duration_min, tp.plan_doctor, c.device_id, c.bind_start_time
     </select>
+    <select id="selectPatientLists" resultType="cn.tr.module.phototherapy.common.vo.PatientTherapyRecordVO"
+            parameterType="cn.tr.module.phototherapy.common.dto.BusPatientListQueryDTO">
+        select bc.patient_unique_id,
+               bc.patient_name,
+               bc.patient_age,
+               bc.patient_gender,
+               bc.patient_phone,
+               bc.last_treatment_time,
+               bc.bind_start_time,
+               bc.group_type,
+               bc.is_current_bind,
+               bc.last_treatment_time,
+               bc.is_current_bind,
+               btp.phase_type,
+               btp.phase_target_times,
+               CONCAT(
+               COALESCE(btp.phase_freq, ''),
+               ':每次',
+               COALESCE(CAST(btp.phase_duration_min AS TEXT), ''),
+               'min'
+                ) as therapyPlanDesc,
+               btp.plan_status,
+               bd.device_id,
+               bda.device_alarm
+        from bus_clinic bc
+                 LEFT JOIN bus_therapy_plan btp ON bc.patient_unique_id = btp.patient_unique_id
+                 LEFT JOIN bus_device bd ON bc.patient_unique_id = bd.patient_unique_id
+                 LEFT JOIN bus_device_alarm bda on bda.device_id = bd.device_id
+        <where>
+            <if test="query.patientName != null">
+                and patient_name = #{query.patientName}
+            </if>
+            <if test="query.patientGender != null">
+                and patient_gender = #{query.patientGender}
+            </if>
+            <if test="query.planStatus != null">
+                and plan_status = #{query.planStatus}
+            </if>
+            <if test="query.isCurrentBind != null">
+                and is_current_bind = #{query.isCurrentBind}
+            </if>
+            <if test="query.groupType != null">
+                and group_type = #{query.groupType}
+            </if>
+            <if test="query.deviceAlarm != null">
+                and device_alarm = #{query.deviceAlarm}
+            </if>
+            <if test="query.lastTreatmentTime != null and query.lastTreatmentTime.size() >0">
+                and last_treatment_time &gt;= #{query.lastTreatmentTime[0]}
+            </if>
+            <if test="query.lastTreatmentTime != null and query.lastTreatmentTime.size() >1">
+                and last_treatment_time &lt;= #{query.lastTreatmentTime[1]}
+            </if>
+            <if test="query.patientAge != null and query.patientAge.size() > 0">
+                <if test="query.patientAge[0] != null">
+                    and bc.patient_age &gt;= #{query.patientAge[0]}
+                </if>
+                <if test="query.patientAge.size() > 1 and query.patientAge[1] != null">
+                    and bc.patient_age &lt;= #{query.patientAge[1]}
+                </if>
+            </if>
+        </where>
+
+
+    </select>
 </mapper>

+ 1 - 0
tr-test/src/main/resources/application.yml

@@ -77,6 +77,7 @@ mybatis-plus:
   configuration:
     log-impl: org.apache.ibatis.logging.nologging.NoLoggingImpl
 #    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
+    default-enum-type-handler: com.baomidou.mybatisplus.core.handlers.MybatisEnumTypeHandler
   global-config:
     db-config:
       logic-delete-value: 1