فهرست منبع

代码修复、设备日志

G 6 روز پیش
والد
کامیت
2daae60ec3
19فایلهای تغییر یافته به همراه238 افزوده شده و 42 حذف شده
  1. BIN
      logs/2026-01/hdis-2026-01-21-1.log.gz
  2. 1 1
      tr-modules/tr-modules-phototherapy/src/main/java/cn/tr/module/phototherapy/common/controller/BusClinicController.java
  3. 14 2
      tr-modules/tr-modules-phototherapy/src/main/java/cn/tr/module/phototherapy/common/controller/BusDeviceHistoryController.java
  4. 1 1
      tr-modules/tr-modules-phototherapy/src/main/java/cn/tr/module/phototherapy/common/controller/BusTherapyRecordController.java
  5. 4 0
      tr-modules/tr-modules-phototherapy/src/main/java/cn/tr/module/phototherapy/common/dto/BusDeviceHistoryDTO.java
  6. 1 1
      tr-modules/tr-modules-phototherapy/src/main/java/cn/tr/module/phototherapy/common/dto/BusHospitalDTO.java
  7. 1 1
      tr-modules/tr-modules-phototherapy/src/main/java/cn/tr/module/phototherapy/common/dto/BusHospitalQueryDTO.java
  8. 41 0
      tr-modules/tr-modules-phototherapy/src/main/java/cn/tr/module/phototherapy/common/dto/DeviceRunningLogDTO.java
  9. 30 0
      tr-modules/tr-modules-phototherapy/src/main/java/cn/tr/module/phototherapy/common/dto/DeviceRunningLogQueryDTO.java
  10. 10 7
      tr-modules/tr-modules-phototherapy/src/main/java/cn/tr/module/phototherapy/common/dto/PatientTherapyDetailDTO.java
  11. 0 3
      tr-modules/tr-modules-phototherapy/src/main/java/cn/tr/module/phototherapy/common/dto/TherapyRecordDetailDTO.java
  12. 34 0
      tr-modules/tr-modules-phototherapy/src/main/java/cn/tr/module/phototherapy/common/enums/DeviceRunStateEnum.java
  13. 13 0
      tr-modules/tr-modules-phototherapy/src/main/java/cn/tr/module/phototherapy/common/repository/BusDeviceHistoryRepository.java
  14. 12 0
      tr-modules/tr-modules-phototherapy/src/main/java/cn/tr/module/phototherapy/common/service/IBusDeviceHistoryService.java
  15. 23 0
      tr-modules/tr-modules-phototherapy/src/main/java/cn/tr/module/phototherapy/common/service/impl/BusDeviceHistoryServiceImpl.java
  16. 11 6
      tr-modules/tr-modules-phototherapy/src/main/java/cn/tr/module/phototherapy/common/vo/PatientTherapyDetailVO.java
  17. 15 19
      tr-modules/tr-modules-phototherapy/src/main/resources/mapper/phototherapy/BusClinicRepository.xml
  18. 26 0
      tr-modules/tr-modules-phototherapy/src/main/resources/mapper/phototherapy/BusDeviceHistoryRepository.xml
  19. 1 1
      tr-modules/tr-modules-phototherapy/src/main/resources/mapper/phototherapy/BusTherapyRecordRepository.xml

BIN
logs/2026-01/hdis-2026-01-21-1.log.gz


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

@@ -73,7 +73,7 @@ public class BusClinicController extends BaseController{
         return CommonResult.success(busClinicService.removeBusClinicByIds(ids));
     }
 
-    @Operation(summary = "根据临床id获取患者治疗详情", description = "phototherapy:clinic:query")
+    @Operation(summary = "根据患者唯一编码获取患者治疗详情", description = "phototherapy:clinic:query")
     @GetMapping("/getPatientTherapyDetail/{patientUniqueId}")
     public CommonResult<PatientTherapyDetailVO> getPatientTherapyDetail(@PathVariable("patientUniqueId") String patientUniqueId){
         return CommonResult.success(busClinicService.getPatientTherapyDetailById(patientUniqueId));

+ 14 - 2
tr-modules/tr-modules-phototherapy/src/main/java/cn/tr/module/phototherapy/common/controller/BusDeviceHistoryController.java

@@ -4,6 +4,7 @@ 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.*;
 import lombok.AllArgsConstructor;
 import io.swagger.v3.oas.annotations.tags.Tag;
 import io.swagger.v3.oas.annotations.Operation;
@@ -12,9 +13,8 @@ import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RestController;
-import cn.tr.module.phototherapy.common.dto.BusDeviceHistoryDTO;
 import cn.tr.module.phototherapy.common.service.IBusDeviceHistoryService;
-import cn.tr.module.phototherapy.common.dto.BusDeviceHistoryQueryDTO;
+
 import java.util.*;
 import cn.tr.core.context.BaseController;
 import org.springframework.web.bind.annotation.*;
@@ -68,4 +68,16 @@ public class BusDeviceHistoryController extends BaseController{
     public CommonResult<Boolean> delete(@RequestBody Collection<Long> ids) {
         return CommonResult.success(busDeviceHistoryService.removeBusDeviceHistoryByIds(ids));
     }
+
+    @Operation(summary = "根据患者唯一编码获取设备运行日志列表", description = "权限: phototherapy:clinic:query")
+    @PostMapping("/getDeviceRunningLogList/page")
+    public TableDataInfo<DeviceRunningLogDTO> getDeviceRunningLogListPage(@RequestBody DeviceRunningLogQueryDTO query){
+        startPage();
+        return getDataTable(busDeviceHistoryService.getDeviceRunningLogList(
+                query.getPatientUniqueId(),
+                query.getStartDate(),
+                query.getEndDate(),
+                query.getTimeRangeType()
+        ));
+    }
 }

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

@@ -71,7 +71,7 @@ public class BusTherapyRecordController extends BaseController{
         return CommonResult.success(busTherapyRecordService.removeBusTherapyRecordByIds(ids));
     }
 
-    @Operation(summary = "根据临床id获取患者治疗记录列表", description = "权限: phototherapy:clinic:query")
+    @Operation(summary = "根据患者唯一编码获取患者治疗记录列表", description = "权限: phototherapy:clinic:query")
     @PostMapping("/getPatientTherapyRecordList/page")
     public TableDataInfo<TherapyRecordDetailDTO> getPatientTherapyRecordListPage(@RequestBody TherapyRecordDetailQueryDTO query){
         startPage();

+ 4 - 0
tr-modules/tr-modules-phototherapy/src/main/java/cn/tr/module/phototherapy/common/dto/BusDeviceHistoryDTO.java

@@ -37,6 +37,10 @@ public class BusDeviceHistoryDTO extends BaseDTO  {
     @NotBlank(message = "患者唯一标识不能为空", groups = {Update.class, Insert.class})
     private String patientUniqueId;
 
+    @Schema(description = "治疗记录表id")
+    @NotBlank(message = "治疗记录表id不能为空", groups = {Update.class, Insert.class})
+    private String therapyId;
+
     @Schema(description = "设备数据标识")
     private String classification;
 

+ 1 - 1
tr-modules/tr-modules-phototherapy/src/main/java/cn/tr/module/phototherapy/common/dto/BusHospitalDTO.java

@@ -35,5 +35,5 @@ public class BusHospitalDTO extends BaseDTO  {
 
     @Schema(description = "逻辑删除")
     @NotBlank(message = "逻辑删除不能为空", groups = {Update.class, Insert.class})
-    private Integer isDeleted;
+    private Integer isDelete;
 }

+ 1 - 1
tr-modules/tr-modules-phototherapy/src/main/java/cn/tr/module/phototherapy/common/dto/BusHospitalQueryDTO.java

@@ -31,5 +31,5 @@ public class BusHospitalQueryDTO  implements Serializable{
     private String logoPath;
 
     @Schema(description = "逻辑删除")
-    private Integer isDeleted;
+    private Integer isDelete;
 }

+ 41 - 0
tr-modules/tr-modules-phototherapy/src/main/java/cn/tr/module/phototherapy/common/dto/DeviceRunningLogDTO.java

@@ -0,0 +1,41 @@
+package cn.tr.module.phototherapy.common.dto;
+
+import cn.tr.module.phototherapy.common.enums.DeviceAlarmEnum;
+import cn.tr.module.phototherapy.common.enums.DeviceRunStateEnum;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+import java.util.Date;
+
+/**
+ * @ClassName DeviceRunningLogDTO
+ * @Description 设备运行日志传输对象
+ * @Date 2026/1/22 9:44
+ * @Version 1.0.0
+ */
+@Data
+@Schema(description = "设备运行日志查询")
+public class DeviceRunningLogDTO {
+
+    //device_history表
+    @Schema(description = "设备ID")
+    private String deviceId;
+
+    @Schema(description = "患者唯一编码")
+    private String patientUniqueId;
+
+    @Schema(description = "设备运行状态(0关机 1开机 2治疗中)")
+    private DeviceRunStateEnum runState;
+
+    @Schema(description = "设备报警类型")
+    private DeviceAlarmEnum alarmState;
+
+    @Schema(description = "设备上传数据时间")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm")
+    private Date uploadTime;
+
+
+
+
+}

+ 30 - 0
tr-modules/tr-modules-phototherapy/src/main/java/cn/tr/module/phototherapy/common/dto/DeviceRunningLogQueryDTO.java

@@ -0,0 +1,30 @@
+package cn.tr.module.phototherapy.common.dto;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+import java.util.Date;
+
+/**
+ * @ClassName DeviceRunningLogQueryDTO
+ * @Description 设备运行日志查询参数
+ * @Date 2026/1/22 10:24
+ * @Version 1.0.0
+ */
+@Data
+@Schema(description = "设备运行日志查询参数")
+public class DeviceRunningLogQueryDTO {
+
+
+    @Schema(description = "患者唯一标识")
+    private String patientUniqueId;
+
+    @Schema(description = "开始日期")
+    private Date startDate;
+
+    @Schema(description = "结束日期")
+    private Date endDate;
+
+    @Schema(description = "时间范围类型:0-自定义,1-今日数据,2-最近一周,3-最近两周,4-最近三周,5-最近一月,6-最近半年")
+    private Integer timeRangeType = 0;  // 默认为自定义
+}

+ 10 - 7
tr-modules/tr-modules-phototherapy/src/main/java/cn/tr/module/phototherapy/common/dto/PatientTherapyDetailDTO.java

@@ -50,9 +50,6 @@ public class PatientTherapyDetailDTO {
 
     @Schema(description = "治疗次数")
     private Integer therapyCount;
-    
-    @Schema(description = "治疗方案状态")
-    private TherapyPlanStatusEnum therapyPlanStatus;
 
     @Schema(description = "报警类型")
     private DeviceAlarmEnum deviceAlarm;
@@ -66,7 +63,13 @@ public class PatientTherapyDetailDTO {
 
     // 光疗方案(来自therapy_plan表)
     @Schema(description = "方案开始时间")
-    private Date startTime;
+    private Date phaseStartTime;
+
+    @Schema(description = "方案结束时间")
+    private Date phaseEndTime;
+
+    @Schema(description = "治疗方案状态")
+    private TherapyPlanStatusEnum therapyPlanStatus;
 
     @Schema(description = "治疗阶段")
     private String phaseType;
@@ -74,9 +77,6 @@ public class PatientTherapyDetailDTO {
     @Schema(description = "治疗频率")
     private Integer phaseFreq;
 
-    @Schema(description = "治疗方案")
-    private String therapyPlanDesc;
-
     @Schema(description = "阶段持续时间(分钟)")
     private Integer phaseDurationMin;
 
@@ -91,6 +91,9 @@ public class PatientTherapyDetailDTO {
     @Schema(description = "设备绑定时间")
     private Date bindStartTime;
 
+    @Schema(description = "是否当前绑定")
+    private IsCurrentBindEnum isCurrentBind;
+
 /*    @Schema(description = "设备解绑时间")
     private Date bindEndTime;*/
 }

+ 0 - 3
tr-modules/tr-modules-phototherapy/src/main/java/cn/tr/module/phototherapy/common/dto/TherapyRecordDetailDTO.java

@@ -31,9 +31,6 @@ public class TherapyRecordDetailDTO {
     @Schema(description = "阶段持续时间(分钟)")
     private String phaseDurationMin;
 
-/*    @Schema(description = "治疗方案")
-    private String therapyPlan;*/
-
     @Schema(description = "累计治疗时间(分钟)")
     private Integer therapyDuration;
 }

+ 34 - 0
tr-modules/tr-modules-phototherapy/src/main/java/cn/tr/module/phototherapy/common/enums/DeviceRunStateEnum.java

@@ -0,0 +1,34 @@
+package cn.tr.module.phototherapy.common.enums;
+
+import com.baomidou.mybatisplus.annotation.IEnum;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+/**
+ * @version 1.0.0
+ * @ClassName DeviceRunState.java
+ * @Description 设备运行状态枚举类  device_history
+ * @createTime 2026-1-22 09:45:00
+ */
+@AllArgsConstructor
+@JsonFormat(shape = JsonFormat.Shape.OBJECT)
+public enum DeviceRunStateEnum implements IEnum<Integer> {
+
+    //    以下为报警信息状态
+    ShutDown(0,"关机"),
+    StartUp(1,"开机"),
+    Treatment(2,"治疗中");
+
+
+
+
+    @Getter
+    @Schema(defaultValue = "运行状态编码")
+    private Integer value;
+    @Getter
+    @Schema(defaultValue = "运行状态内容")
+    private String text;
+
+}

+ 13 - 0
tr-modules/tr-modules-phototherapy/src/main/java/cn/tr/module/phototherapy/common/repository/BusDeviceHistoryRepository.java

@@ -1,10 +1,14 @@
 package cn.tr.module.phototherapy.common.repository;
 
+import cn.tr.module.phototherapy.common.dto.DeviceRunningLogDTO;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import org.apache.ibatis.annotations.Mapper;
 import cn.tr.module.phototherapy.common.po.BusDeviceHistoryPO;
 import org.springframework.stereotype.Repository;
 
+import java.util.Date;
+import java.util.List;
+
 /**
  * 设备历史Mapper接口
  *
@@ -14,4 +18,13 @@ import org.springframework.stereotype.Repository;
 @Repository
 @Mapper
 public interface BusDeviceHistoryRepository extends BaseMapper<BusDeviceHistoryPO> {
+    /**
+     * 查询设备运行日志
+     *
+     * @param patientUniqueId 患者唯一编码
+     * @param startDateTime   开始时间
+     * @param endDateTime     结束时间
+     * @return 设备运行日志
+     */
+    List<DeviceRunningLogDTO> selectDeviceRunningLog(String patientUniqueId, Date startDateTime, Date endDateTime);
 }

+ 12 - 0
tr-modules/tr-modules-phototherapy/src/main/java/cn/tr/module/phototherapy/common/service/IBusDeviceHistoryService.java

@@ -2,6 +2,8 @@ package cn.tr.module.phototherapy.common.service;
 
 import cn.tr.module.phototherapy.common.dto.BusDeviceHistoryDTO;
 import cn.tr.module.phototherapy.common.dto.BusDeviceHistoryQueryDTO;
+import cn.tr.module.phototherapy.common.dto.DeviceRunningLogDTO;
+
 import java.util.*;
 import java.util.Collection;
 
@@ -52,4 +54,14 @@ public interface IBusDeviceHistoryService{
      * @date   2026-01-13
      */
     boolean removeBusDeviceHistoryByIds(Collection<Long> ids);
+
+    /**
+     * 根据患者唯一编码获取设备运行日志列表
+     * @param patientUniqueId 患者唯一编码
+     * @param startDate 开始时间
+     * @param endDate 结束时间
+     * @author CodeGenerator
+     * @date 2026-01-13
+     */
+    List<DeviceRunningLogDTO> getDeviceRunningLogList(String patientUniqueId, Date startDate, Date endDate, Integer timeRangeType);
 }

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

@@ -1,5 +1,8 @@
 package cn.tr.module.phototherapy.common.service.impl;
 
+import cn.tr.module.phototherapy.common.dto.DeviceRunningLogDTO;
+import cn.tr.module.phototherapy.common.handle.TimeRangeHandler;
+import cn.tr.module.phototherapy.common.utils.QueryParamUtil;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.springframework.stereotype.Service;
 import cn.hutool.core.collection.CollectionUtil;
@@ -26,6 +29,8 @@ import cn.tr.core.exception.TRExcCode;
 @Service
 public class BusDeviceHistoryServiceImpl extends ServiceImpl<BusDeviceHistoryRepository, BusDeviceHistoryPO> implements IBusDeviceHistoryService {
 
+    @Resource
+    private BusDeviceHistoryRepository busDeviceHistoryRepository;
 
 
     /**
@@ -105,4 +110,22 @@ public class BusDeviceHistoryServiceImpl extends ServiceImpl<BusDeviceHistoryRep
         }
         return this.removeByIds(ids);
     };
+
+    @Override
+    public List<DeviceRunningLogDTO> getDeviceRunningLogList(String patientUniqueId, Date startDate, Date endDate,Integer timeRangeType) {
+        // 处理预设时间范围
+        Date[] dateRange = TimeRangeHandler.handleTimeRange(startDate, endDate, timeRangeType);
+        startDate = dateRange[0];
+        endDate = dateRange[1];
+
+        // 执行多表联查
+        Date startDateTime = QueryParamUtil.convertToStartOfDayFromDate(startDate);
+        Date endDateTime = QueryParamUtil.convertToEndOfDayFromDate(endDate);
+
+        // 从Repository获取原始数据
+        List<DeviceRunningLogDTO> results = busDeviceHistoryRepository.selectDeviceRunningLog(patientUniqueId, startDateTime, endDateTime);
+
+        // 转换为VO并按状态聚合
+        return results;
+    }
 }

+ 11 - 6
tr-modules/tr-modules-phototherapy/src/main/java/cn/tr/module/phototherapy/common/vo/PatientTherapyDetailVO.java

@@ -45,6 +45,9 @@ public class PatientTherapyDetailVO {
     @Schema(description = "所属分组")
     private GroupTypeEnum groupType;
 
+    @Schema(description = "是否当前绑定")
+    private IsCurrentBindEnum isCurrentBind;
+
 
     // 治疗信息(来自bus_therapy_record表统计)
     @Schema(description = "治疗次数")
@@ -53,9 +56,6 @@ public class PatientTherapyDetailVO {
     @Schema(description = "治疗状态")
     private TherapyStatusEnum therapyStatus;
 
-    @Schema(description = "治疗方案状态")
-    private TherapyPlanStatusEnum therapyPlanStatus;
-
     @Schema(description = "报警类型")
     private DeviceAlarmEnum deviceAlarm;
 
@@ -63,7 +63,10 @@ public class PatientTherapyDetailVO {
     // 光疗方案(来自therapy_plan表)
     @Schema(description = "开始时间")
     @JsonFormat(pattern = "yyyy-MM-dd")
-    private Date startTime;
+    private Date phaseStartTime;
+
+    @Schema(description = "治疗方案状态")
+    private TherapyPlanStatusEnum therapyPlanStatus;
 
     @Schema(description = "治疗阶段")
     private String phaseType;
@@ -71,8 +74,8 @@ public class PatientTherapyDetailVO {
     @Schema(description = "治疗频率")
     private Integer phaseFreq;
 
-    @Schema(description = "治疗方案")
-    private String therapyPlanDesc;
+    @Schema(description = "阶段持续时间(分钟)")
+    private Integer phaseDurationMin;
 
     @Schema(description = "方案医生")
     private String planDoctor;
@@ -85,4 +88,6 @@ public class PatientTherapyDetailVO {
     @Schema(description = "绑定开始时间")
     @JsonFormat(pattern = "yyyy-MM-dd")
     private Date bindStartTime;
+
+
 }

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

@@ -11,36 +11,32 @@
                c.patient_address,
                c.last_treatment_time,
                c.group_type,
+               c.is_current_bind                            as isCurrentBind,
                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,
-               CONCAT(
-                       tp.phase_freq,
-                       ':每次',
-                       COALESCE(CAST(tp.phase_duration_min AS TEXT), ''),
-                       'min'
-               )                                           as therapyPlanDesc,
-               tp.plan_doctor                              as planDoctor,
-               c.device_id                                 as deviceId,
-               c.bind_start_time                           as bindStartTime,
-               tp.plan_status                              as therapyPlanStatus,
+               tp.phase_start_time                         as phaseStartTime,
+               tp.phase_type                                as phaseType,
+                tp.phase_freq                               as phaseFreq,
+                tp.phase_duration_min                       as phaseDurationMin ,
+               tp.plan_doctor                               as planDoctor,
+               c.device_id                                  as deviceId,
+               c.bind_start_time                            as bindStartTime,
+               tp.plan_status                               as therapyPlanStatus,
                da.device_alarm                              as deviceAlarm
         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
+                 LEFT JOIN bus_therapy_record r ON c.patient_unique_id = r.patient_unique_id AND r.is_delete = 0
+                 LEFT JOIN bus_therapy_record r_today ON c.patient_unique_id = r_today.patient_unique_id
             AND r_today.is_delete = 0
             AND DATE (r_today.therapy_start_time) = DATE (NOW())
-            LEFT JOIN bus_device d ON c.patient_unique_id = d.patient_unique_id
-            LEFT JOIN bus_device_alarm da ON da.device_id = d.device_id
+            LEFT JOIN bus_device_alarm da ON da.device_id = c.device_id
         WHERE c.patient_unique_id = #{patientUniqueId}
           AND c.is_delete = 0
         GROUP BY
             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,
-            tp.create_time, tp.phase_type, tp.phase_freq,
-            tp.phase_duration_min, tp.plan_doctor, c.device_id, c.bind_start_time, tp.plan_status, da.device_alarm
+            c.patient_phone, c.patient_address, c.last_treatment_time, c.group_type,c.is_current_bind,
+            tp.phase_start_time, tp.phase_type, tp.phase_freq,
+            tp.phase_duration_min, tp.plan_doctor, c.device_id, c.bind_start_time,tp.plan_status,da.device_alarm
     </select>
     <select id="selectPatientLists" resultType="cn.tr.module.phototherapy.common.vo.PatientTherapyRecordVO"
             parameterType="cn.tr.module.phototherapy.common.dto.BusPatientListQueryDTO">

+ 26 - 0
tr-modules/tr-modules-phototherapy/src/main/resources/mapper/phototherapy/BusDeviceHistoryRepository.xml

@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="cn.tr.module.phototherapy.common.repository.BusDeviceHistoryRepository">
+
+
+    <select id="selectDeviceRunningLog" resultType="cn.tr.module.phototherapy.common.dto.DeviceRunningLogDTO">
+        SELECT
+            dh.device_id as deviceId,
+            dh.patient_unique_id as patientUniqueId,
+            dh.run_state as runState,
+            dh.alarm_state as alarmState,
+            dh.upload_time as uploadTime
+        FROM bus_device_history dh
+        WHERE dh.patient_unique_id = #{patientUniqueId}
+          AND dh.is_delete = 0
+        <if test="startDateTime != null">
+            AND dh.upload_time >= #{startDateTime}
+        </if>
+        <if test="endDateTime != null">
+            AND dh.upload_time &lt;= #{endDateTime}
+        </if>
+        ORDER BY dh.upload_time DESC
+    </select>
+</mapper>

+ 1 - 1
tr-modules/tr-modules-phototherapy/src/main/resources/mapper/phototherapy/BusTherapyRecordRepository.xml

@@ -20,7 +20,7 @@
         p.phase_freq,
         p.phase_duration_min
         FROM bus_therapy_record r
-        LEFT JOIN bus_clinic c ON r.clinic_id = c.id
+        LEFT JOIN bus_clinic c ON r.patient_unique_id = c.patient_unique_id
         LEFT JOIN bus_therapy_plan p ON c.therapy_plan_id = p.id
         WHERE c.patient_unique_id = #{patientUniqueId}
         AND r.is_delete = 0