Explorar el Código

方案状态修改

G hace 2 días
padre
commit
7f223594ba
Se han modificado 15 ficheros con 140 adiciones y 9 borrados
  1. BIN
      logs/2026-01/hdis-2026-01-23-1.log.gz
  2. 7 0
      tr-modules/tr-modules-phototherapy/src/main/java/cn/tr/module/phototherapy/common/controller/BusTherapyPlanController.java
  3. 22 0
      tr-modules/tr-modules-phototherapy/src/main/java/cn/tr/module/phototherapy/common/dto/BusTherapyPlanStatusDTO.java
  4. 3 1
      tr-modules/tr-modules-phototherapy/src/main/java/cn/tr/module/phototherapy/common/dto/DeviceRunningLogDTO.java
  5. 2 0
      tr-modules/tr-modules-phototherapy/src/main/java/cn/tr/module/phototherapy/common/dto/DeviceRunningLogQueryDTO.java
  6. 4 1
      tr-modules/tr-modules-phototherapy/src/main/java/cn/tr/module/phototherapy/common/dto/PatientTherapyDetailDTO.java
  7. 3 1
      tr-modules/tr-modules-phototherapy/src/main/java/cn/tr/module/phototherapy/common/dto/TherapyRecordDetailDTO.java
  8. 2 0
      tr-modules/tr-modules-phototherapy/src/main/java/cn/tr/module/phototherapy/common/dto/TherapyRecordDetailQueryDTO.java
  9. 3 5
      tr-modules/tr-modules-phototherapy/src/main/java/cn/tr/module/phototherapy/common/dto/UnbindDeviceDTO.java
  10. 7 0
      tr-modules/tr-modules-phototherapy/src/main/java/cn/tr/module/phototherapy/common/repository/BusClinicRepository.java
  11. 1 0
      tr-modules/tr-modules-phototherapy/src/main/java/cn/tr/module/phototherapy/common/repository/BusTherapyPlanRepository.java
  12. 10 0
      tr-modules/tr-modules-phototherapy/src/main/java/cn/tr/module/phototherapy/common/service/IBusTherapyPlanService.java
  13. 47 0
      tr-modules/tr-modules-phototherapy/src/main/java/cn/tr/module/phototherapy/common/service/impl/BusTherapyPlanServiceImpl.java
  14. 15 1
      tr-modules/tr-modules-phototherapy/src/main/resources/mapper/phototherapy/BusClinicRepository.xml
  15. 14 0
      tr-modules/tr-modules-phototherapy/src/main/resources/mapper/phototherapy/BusTherapyPlanRepository.xml

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


+ 7 - 0
tr-modules/tr-modules-phototherapy/src/main/java/cn/tr/module/phototherapy/common/controller/BusTherapyPlanController.java

@@ -82,4 +82,11 @@ public class BusTherapyPlanController extends BaseController{
         return CommonResult.success(busTherapyPlanService.queryByStatusAndName());
         return CommonResult.success(busTherapyPlanService.queryByStatusAndName());
     }
     }
 
 
+
+    @Operation(summary = "终止/启用治疗方案", description = "权限: phototherapy:common:edit")
+    @PostMapping("/updatePlanStatus")
+    @SaCheckPermission("phototherapy:common:edit")
+    public CommonResult<Boolean> updateTherapyPlanStatus(@RequestBody BusTherapyPlanStatusDTO source) {
+        return CommonResult.success(busTherapyPlanService.updateTherapyPlanStatus(source.getPatientUniqueId()));
+    }
 }
 }

+ 22 - 0
tr-modules/tr-modules-phototherapy/src/main/java/cn/tr/module/phototherapy/common/dto/BusTherapyPlanStatusDTO.java

@@ -0,0 +1,22 @@
+package cn.tr.module.phototherapy.common.dto;
+
+import io.swagger.v3.oas.annotations.Parameter;
+import io.swagger.v3.oas.annotations.media.Schema;
+import jakarta.validation.constraints.NotBlank;
+import lombok.Data;
+import lombok.ToString;
+
+/**
+ * @ClassName BusTherapyPlanStatusDTO
+ * @Description 患者治疗计划状态DTO
+ * @Date 2026/1/26 11:19
+ * @Version 1.0.0
+ */
+@Data
+@Schema(description = "BusTherapyPlanStatusDTO")
+@ToString
+public class BusTherapyPlanStatusDTO {
+    @NotBlank(message = "请求参数缺失:patientUniqueId")
+    @Parameter(description = "患者唯一编码", required = true)
+    private String patientUniqueId;
+}

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

@@ -6,6 +6,7 @@ import cn.tr.module.phototherapy.common.enums.DeviceRunStateEnum;
 import com.fasterxml.jackson.annotation.JsonFormat;
 import com.fasterxml.jackson.annotation.JsonFormat;
 import io.swagger.v3.oas.annotations.media.Schema;
 import io.swagger.v3.oas.annotations.media.Schema;
 import lombok.Data;
 import lombok.Data;
+import lombok.ToString;
 
 
 import java.util.Date;
 import java.util.Date;
 
 
@@ -17,7 +18,8 @@ import java.util.Date;
  */
  */
 @Data
 @Data
 @Schema(description = "设备运行日志查询")
 @Schema(description = "设备运行日志查询")
-public class DeviceRunningLogDTO extends BaseDTO {
+@ToString
+public class DeviceRunningLogDTO {
 
 
     //device_history表
     //device_history表
     @Schema(description = "设备ID")
     @Schema(description = "设备ID")

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

@@ -2,6 +2,7 @@ package cn.tr.module.phototherapy.common.dto;
 
 
 import io.swagger.v3.oas.annotations.media.Schema;
 import io.swagger.v3.oas.annotations.media.Schema;
 import lombok.Data;
 import lombok.Data;
+import lombok.ToString;
 
 
 import java.io.Serializable;
 import java.io.Serializable;
 import java.util.Date;
 import java.util.Date;
@@ -14,6 +15,7 @@ import java.util.Date;
  */
  */
 @Data
 @Data
 @Schema(description = "设备运行日志查询参数")
 @Schema(description = "设备运行日志查询参数")
+@ToString
 public class DeviceRunningLogQueryDTO implements Serializable {
 public class DeviceRunningLogQueryDTO implements Serializable {
 
 
 
 

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

@@ -5,6 +5,8 @@ import cn.tr.module.phototherapy.common.enums.*;
 import com.fasterxml.jackson.annotation.JsonFormat;
 import com.fasterxml.jackson.annotation.JsonFormat;
 import io.swagger.v3.oas.annotations.media.Schema;
 import io.swagger.v3.oas.annotations.media.Schema;
 import lombok.Data;
 import lombok.Data;
+import lombok.ToString;
+
 import java.time.LocalDateTime;
 import java.time.LocalDateTime;
 import java.util.Date;
 import java.util.Date;
 import java.util.List;
 import java.util.List;
@@ -18,7 +20,8 @@ import java.util.List;
  */
  */
 @Data
 @Data
 @Schema(description = "患者治疗详情DTO")
 @Schema(description = "患者治疗详情DTO")
-public class PatientTherapyDetailDTO extends BaseDTO {
+@ToString
+public class PatientTherapyDetailDTO {
 
 
     // 患者信息(来自bus_clinic表)
     // 患者信息(来自bus_clinic表)
     @Schema(description = "患者姓名")
     @Schema(description = "患者姓名")

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

@@ -4,6 +4,7 @@ import cn.tr.core.pojo.BaseDTO;
 import com.fasterxml.jackson.annotation.JsonFormat;
 import com.fasterxml.jackson.annotation.JsonFormat;
 import io.swagger.v3.oas.annotations.media.Schema;
 import io.swagger.v3.oas.annotations.media.Schema;
 import lombok.Data;
 import lombok.Data;
+import lombok.ToString;
 
 
 import java.time.LocalDate;
 import java.time.LocalDate;
 import java.time.LocalDateTime;
 import java.time.LocalDateTime;
@@ -17,7 +18,8 @@ import java.util.Date;
  */
  */
 @Data
 @Data
 @Schema(description = "治疗记录详情DTO")
 @Schema(description = "治疗记录详情DTO")
-public class TherapyRecordDetailDTO extends BaseDTO {
+@ToString
+public class TherapyRecordDetailDTO {
 
 
     @Schema(description = "治疗日期")
     @Schema(description = "治疗日期")
     @JsonFormat(pattern = "yyyy-MM-dd")
     @JsonFormat(pattern = "yyyy-MM-dd")

+ 2 - 0
tr-modules/tr-modules-phototherapy/src/main/java/cn/tr/module/phototherapy/common/dto/TherapyRecordDetailQueryDTO.java

@@ -4,6 +4,7 @@ import com.fasterxml.jackson.annotation.JsonFormat;
 import io.swagger.v3.oas.annotations.media.Schema;
 import io.swagger.v3.oas.annotations.media.Schema;
 import jakarta.validation.constraints.NotBlank;
 import jakarta.validation.constraints.NotBlank;
 import lombok.Data;
 import lombok.Data;
+import lombok.ToString;
 
 
 import java.io.Serializable;
 import java.io.Serializable;
 import java.util.Date;
 import java.util.Date;
@@ -16,6 +17,7 @@ import java.util.Date;
  */
  */
 @Data
 @Data
 @Schema(description = "治疗记录查询参数")
 @Schema(description = "治疗记录查询参数")
+@ToString
 public class TherapyRecordDetailQueryDTO implements Serializable {
 public class TherapyRecordDetailQueryDTO implements Serializable {
 
 
     @Schema(description = "患者唯一ID" , required = true)
     @Schema(description = "患者唯一ID" , required = true)

+ 3 - 5
tr-modules/tr-modules-phototherapy/src/main/java/cn/tr/module/phototherapy/common/dto/UnbindDeviceDTO.java

@@ -4,6 +4,7 @@ import cn.tr.core.pojo.BaseDTO;
 import io.swagger.v3.oas.annotations.media.Schema;
 import io.swagger.v3.oas.annotations.media.Schema;
 import jakarta.validation.constraints.NotBlank;
 import jakarta.validation.constraints.NotBlank;
 import lombok.Data;
 import lombok.Data;
+import lombok.ToString;
 
 
 import java.util.Date;
 import java.util.Date;
 
 
@@ -15,16 +16,13 @@ import java.util.Date;
  */
  */
 @Data
 @Data
 @Schema(description = "设备解绑传输对象")
 @Schema(description = "设备解绑传输对象")
-public class UnbindDeviceDTO extends BaseDTO {
+@ToString
+public class UnbindDeviceDTO  {
 
 
     @Schema(description = "患者唯一ID")
     @Schema(description = "患者唯一ID")
     @NotBlank(message = "患者唯一ID不能为空")
     @NotBlank(message = "患者唯一ID不能为空")
     private String patientUniqueId;
     private String patientUniqueId;
 
 
-    @Schema(description = "设备ID")
-    @NotBlank(message = "设备ID不能为空")
-    private String deviceId;
-
     @Schema(description = "是否当前绑定", hidden = true)
     @Schema(description = "是否当前绑定", hidden = true)
     private Integer isCurrentBind;
     private Integer isCurrentBind;
 
 

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

@@ -49,4 +49,11 @@ public interface BusClinicRepository extends BaseMapper<BusClinicPO> {
      * @return cn.tr.module.phototherapy.common.po.BusClinicPO
      * @return cn.tr.module.phototherapy.common.po.BusClinicPO
      **/
      **/
     BusClinicPO selectByPatientUniqueId(@Param("patientUniqueId") String patientUniqueId);
     BusClinicPO selectByPatientUniqueId(@Param("patientUniqueId") String patientUniqueId);
+
+    /**
+     * 根据patientUniqueId查询疗法计划id
+     * @param patientUniqueId
+     * @return java.lang.String
+     **/
+    String selectTherapyPlanIdByPatientId(String patientUniqueId);
 }
 }

+ 1 - 0
tr-modules/tr-modules-phototherapy/src/main/java/cn/tr/module/phototherapy/common/repository/BusTherapyPlanRepository.java

@@ -17,4 +17,5 @@ import java.util.List;
 @Mapper
 @Mapper
 public interface BusTherapyPlanRepository extends BaseMapper<BusTherapyPlanPO> {
 public interface BusTherapyPlanRepository extends BaseMapper<BusTherapyPlanPO> {
 
 
+    BusTherapyPlanPO selectStatusByPlanId(String therapyPlanId);
 }
 }

+ 10 - 0
tr-modules/tr-modules-phototherapy/src/main/java/cn/tr/module/phototherapy/common/service/IBusTherapyPlanService.java

@@ -75,4 +75,14 @@ public interface IBusTherapyPlanService{
      * @date   2026-01-13
      * @date   2026-01-13
      */
      */
     List<BusTherapyPlanDTO> queryByStatusAndName();
     List<BusTherapyPlanDTO> queryByStatusAndName();
+
+
+    /**
+     * 编辑治疗方案
+      * @param   patientUniqueId 患者唯一标识
+     * @author CodeGenerator
+     * @date   2026-01-13
+     */
+    Boolean updateTherapyPlanStatus(String patientUniqueId);
+
 }
 }

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

@@ -4,6 +4,7 @@ import cn.tr.module.phototherapy.common.dto.*;
 import cn.tr.module.phototherapy.common.enums.PhaseDayEnum;
 import cn.tr.module.phototherapy.common.enums.PhaseDayEnum;
 import cn.tr.module.phototherapy.common.enums.TherapyPlanNameEnum;
 import cn.tr.module.phototherapy.common.enums.TherapyPlanNameEnum;
 import cn.tr.module.phototherapy.common.enums.TherapyPlanStatusEnum;
 import cn.tr.module.phototherapy.common.enums.TherapyPlanStatusEnum;
+import cn.tr.module.phototherapy.common.repository.BusClinicRepository;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 import cn.tr.module.phototherapy.common.po.BusClinicPO;
 import cn.tr.module.phototherapy.common.po.BusClinicPO;
@@ -32,6 +33,11 @@ import cn.tr.core.exception.TRExcCode;
 @Service
 @Service
 public class BusTherapyPlanServiceImpl extends ServiceImpl<BusTherapyPlanRepository, BusTherapyPlanPO> implements IBusTherapyPlanService {
 public class BusTherapyPlanServiceImpl extends ServiceImpl<BusTherapyPlanRepository, BusTherapyPlanPO> implements IBusTherapyPlanService {
 
 
+    @Autowired
+    private BusClinicRepository busClinicRepository;
+
+    @Autowired
+    private BusTherapyPlanRepository therapyPlanRepository;
 
 
     /**
     /**
      * 根据条件查询设计方案
      * 根据条件查询设计方案
@@ -230,4 +236,45 @@ public class BusTherapyPlanServiceImpl extends ServiceImpl<BusTherapyPlanReposit
                 .isNull(BusTherapyPlanPO::getPhaseEndTime))
                 .isNull(BusTherapyPlanPO::getPhaseEndTime))
         );
         );
     }
     }
+
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public Boolean updateTherapyPlanStatus(String patientUniqueId) {
+
+        String therapyPlanId = busClinicRepository.selectTherapyPlanIdByPatientId(patientUniqueId);
+        if (therapyPlanId == null){
+            throw new ServiceException(TRExcCode.SYSTEM_ERROR_B0001, "患者无关联治疗方案");
+        }
+        // 2. 根据therapy_plan_id查询方案详情
+        BusTherapyPlanPO plan = therapyPlanRepository.selectStatusByPlanId(therapyPlanId);
+        if (plan == null){
+            throw new ServiceException(TRExcCode.SYSTEM_ERROR_B0001, "患者治疗方案不存在");
+        }
+
+        // 3. 判断当前状态,进行更改
+        int targetStatus;
+        TherapyPlanStatusEnum currentStatus = TherapyPlanStatusEnum.getByValue(plan.getPlanStatus());
+        if (currentStatus == null) {
+            throw new ServiceException(TRExcCode.SYSTEM_ERROR_B0001, "操作失败:方案状态异常");
+        }
+        if (TherapyPlanStatusEnum.TERMINATED.equals(currentStatus)) {
+            // 终止状态 → 切换为启用中
+             targetStatus = TherapyPlanStatusEnum.ENABLED.getValue();
+        } else if (TherapyPlanStatusEnum.ENABLED.equals(currentStatus) || TherapyPlanStatusEnum.WAITING.equals(currentStatus)) {
+            // 启用中/等待启用 → 切换为终止
+             targetStatus = TherapyPlanStatusEnum.TERMINATED.getValue();
+        } else {
+            throw new ServiceException(TRExcCode.SYSTEM_ERROR_B0001, "操作失败:当前状态无需更改");
+        }
+
+        // 4. 更新方案状态
+        plan.setPlanStatus(targetStatus);
+        int updateCount = therapyPlanRepository.updateById(plan);
+        if (updateCount == 0) {
+            throw new ServiceException(TRExcCode.SYSTEM_ERROR_B0001, "操作失败:更新方案状态失败");
+
+        }
+        return true;
+    }
 }
 }

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

@@ -12,7 +12,15 @@
                c.group_type,
                c.group_type,
                c.is_current_bind                            as isCurrentBind,
                c.is_current_bind                            as isCurrentBind,
                COUNT(DISTINCT DATE (r.therapy_start_time)) as therapy_count,
                COUNT(DISTINCT DATE (r.therapy_start_time)) as therapy_count,
-               COALESCE(MAX(r_today.therapy_status), 0)    as therapy_status,
+               COALESCE((
+                            SELECT r_today.therapy_status
+                            FROM bus_therapy_record r_today
+                            WHERE r_today.patient_unique_id = c.patient_unique_id
+                              AND r_today.is_delete = 0
+                              AND DATE(r_today.therapy_start_time) = DATE(NOW())
+                        ORDER BY r_today.create_time DESC
+                        LIMIT 1
+                   ), 2) as therapy_status,
                tp.phase_start_time                         as phaseStartTime,
                tp.phase_start_time                         as phaseStartTime,
                tp.phase_type                                as phaseType,
                tp.phase_type                                as phaseType,
                 tp.phase_freq                               as phaseFreq,
                 tp.phase_freq                               as phaseFreq,
@@ -113,5 +121,11 @@
         WHERE patient_unique_id = #{patientUniqueId}
         WHERE patient_unique_id = #{patientUniqueId}
             LIMIT 1
             LIMIT 1
     </select>
     </select>
+    <select id="selectTherapyPlanIdByPatientId" resultType="java.lang.String">
+        SELECT therapy_plan_id
+        FROM bus_clinic
+        WHERE patient_unique_id = #{patientUniqueId}
+          AND is_delete = 0
+    </select>
 
 
 </mapper>
 </mapper>

+ 14 - 0
tr-modules/tr-modules-phototherapy/src/main/resources/mapper/phototherapy/BusTherapyPlanRepository.xml

@@ -0,0 +1,14 @@
+<?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.BusTherapyPlanRepository">
+
+
+    <select id="selectStatusByPlanId" resultType="cn.tr.module.phototherapy.common.po.BusTherapyPlanPO">
+        select *
+        from bus_therapy_plan
+        where id = #{therapyPlanId}
+          AND is_delete = 0
+    </select>
+</mapper>