Pārlūkot izejas kodu

修改用户管理bug和实现患者编辑功能 自动计算强化期和持续期

zhouzeyu 5 dienas atpakaļ
vecāks
revīzija
03f6e29f43
27 mainītis faili ar 715 papildinājumiem un 114 dzēšanām
  1. 7 3
      tr-modules/tr-module-system/src/main/java/cn/tr/module/sys/user/controller/SysUserController.java
  2. 1 2
      tr-modules/tr-module-system/src/main/java/cn/tr/module/sys/user/dto/SysUserEditDTO.java
  3. 4 2
      tr-modules/tr-module-system/src/main/java/cn/tr/module/sys/user/po/SysDeptPO.java
  4. 2 0
      tr-modules/tr-module-system/src/main/java/cn/tr/module/sys/user/po/SysPostPO.java
  5. 3 0
      tr-modules/tr-module-system/src/main/java/cn/tr/module/sys/user/po/SysUserPostPO.java
  6. 4 0
      tr-modules/tr-module-system/src/main/java/cn/tr/module/sys/user/service/ISysUserService.java
  7. 5 5
      tr-modules/tr-module-system/src/main/java/cn/tr/module/sys/user/service/impl/SysDeptServiceImpl.java
  8. 87 0
      tr-modules/tr-module-system/src/main/java/cn/tr/module/sys/user/service/impl/SysUserServiceImpl.java
  9. 14 6
      tr-modules/tr-modules-phototherapy/src/main/java/cn/tr/module/phototherapy/common/controller/BusClinicController.java
  10. 10 4
      tr-modules/tr-modules-phototherapy/src/main/java/cn/tr/module/phototherapy/common/controller/BusTherapyPlanController.java
  11. 5 2
      tr-modules/tr-modules-phototherapy/src/main/java/cn/tr/module/phototherapy/common/dto/BusClinicAddDTO.java
  12. 3 2
      tr-modules/tr-modules-phototherapy/src/main/java/cn/tr/module/phototherapy/common/dto/BusClinicDTO.java
  13. 81 0
      tr-modules/tr-modules-phototherapy/src/main/java/cn/tr/module/phototherapy/common/dto/BusClinicEditDTO.java
  14. 32 0
      tr-modules/tr-modules-phototherapy/src/main/java/cn/tr/module/phototherapy/common/dto/BusPlanStatusAndNameQueryDTO.java
  15. 1 1
      tr-modules/tr-modules-phototherapy/src/main/java/cn/tr/module/phototherapy/common/dto/BusTherapyPlanAddDTO.java
  16. 2 5
      tr-modules/tr-modules-phototherapy/src/main/java/cn/tr/module/phototherapy/common/dto/BusTherapyPlanDTO.java
  17. 62 0
      tr-modules/tr-modules-phototherapy/src/main/java/cn/tr/module/phototherapy/common/dto/BusTherapyPlanEditDTO.java
  18. 0 3
      tr-modules/tr-modules-phototherapy/src/main/java/cn/tr/module/phototherapy/common/dto/BusTherapyPlanQueryDTO.java
  19. 3 0
      tr-modules/tr-modules-phototherapy/src/main/java/cn/tr/module/phototherapy/common/po/BusClinicPO.java
  20. 2 2
      tr-modules/tr-modules-phototherapy/src/main/java/cn/tr/module/phototherapy/common/po/BusTherapyPlanPO.java
  21. 138 0
      tr-modules/tr-modules-phototherapy/src/main/java/cn/tr/module/phototherapy/common/quartz/TheraPhaseAutoUpdateTask.java
  22. 2 0
      tr-modules/tr-modules-phototherapy/src/main/java/cn/tr/module/phototherapy/common/repository/BusTherapyPlanRepository.java
  23. 45 16
      tr-modules/tr-modules-phototherapy/src/main/java/cn/tr/module/phototherapy/common/service/IBusClinicService.java
  24. 17 4
      tr-modules/tr-modules-phototherapy/src/main/java/cn/tr/module/phototherapy/common/service/IBusTherapyPlanService.java
  25. 46 2
      tr-modules/tr-modules-phototherapy/src/main/java/cn/tr/module/phototherapy/common/service/impl/BusClinicServiceImpl.java
  26. 138 54
      tr-modules/tr-modules-phototherapy/src/main/java/cn/tr/module/phototherapy/common/service/impl/BusTherapyPlanServiceImpl.java
  27. 1 1
      tr-modules/tr-modules-phototherapy/src/main/java/cn/tr/module/phototherapy/web/auth/WebAuthGranter.java

+ 7 - 3
tr-modules/tr-module-system/src/main/java/cn/tr/module/sys/user/controller/SysUserController.java

@@ -1,7 +1,9 @@
 package cn.tr.module.sys.user.controller;
 
 import cn.dev33.satoken.annotation.SaCheckPermission;
+import cn.tr.core.context.BaseController;
 import cn.tr.core.pojo.CommonResult;
+import cn.tr.core.pojo.TableDataInfo;
 import cn.tr.module.common.annotation.Log;
 import cn.tr.module.common.utils.ExcelUtil;
 import cn.tr.module.sys.exception.CustomException;
@@ -22,6 +24,7 @@ import jakarta.annotation.Resource;
 
 import java.util.List;
 
+
 /**
  * <p>
  * 用户表 前端控制器
@@ -33,7 +36,7 @@ import java.util.List;
 @Tag(name = "用户管理")
 @RestController
 @RequestMapping("/sys/user")
-public class SysUserController {
+public class SysUserController extends BaseController {
 
     @Resource
     private ISysUserService sysUserService;
@@ -44,8 +47,9 @@ public class SysUserController {
     @Operation(summary = "用户管理分页查询")
     @GetMapping("/page")
     @SaCheckPermission("system:sysUser:page")
-    public CommonResult page(Page reqPage, SysUserQueryDTO req) {
-        return CommonResult.success(sysUserService.page(reqPage, req));
+    public TableDataInfo<SysUserPO> page(SysUserQueryDTO req) {
+        startPage();
+        return getDataTable(sysUserService.selectSysUserList( req));
     }
 
     /**

+ 1 - 2
tr-modules/tr-module-system/src/main/java/cn/tr/module/sys/user/dto/SysUserEditDTO.java

@@ -90,7 +90,7 @@ public class SysUserEditDTO implements Serializable {
      * 性别 1男;2女;3未知
      */
     @NotNull(message = "性别不能为空")
-    private SexEnum sex;
+    private Integer sex;
 
     /**
      * 部门ID
@@ -100,7 +100,6 @@ public class SysUserEditDTO implements Serializable {
     /**
      * 排序
      */
-    @NotNull(message = "排序不能为空")
     private Integer sort;
 
     /**

+ 4 - 2
tr-modules/tr-module-system/src/main/java/cn/tr/module/sys/user/po/SysDeptPO.java

@@ -2,8 +2,10 @@ package cn.tr.module.sys.user.po;
 
 import cn.tr.module.common.entity.TenantGenericEntity;
 import cn.tr.module.common.menus.StatusEnum;
+import cn.tr.module.common.mybatisplus.handler.IntegerStringTypeHandler;
 import com.baomidou.mybatisplus.annotation.FieldFill;
 import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableName;
 import com.fasterxml.jackson.annotation.JsonFormat;
 import com.fasterxml.jackson.databind.annotation.JsonSerialize;
 import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
@@ -21,7 +23,7 @@ import java.util.List;
  * @since 2021-06-10
  */
 @Data
-//@TableName("sys_dept")
+@TableName("sys_dept")
 public class SysDeptPO extends TenantGenericEntity<Long,String> {
 
     private static final long serialVersionUID = 1L;
@@ -95,7 +97,7 @@ public class SysDeptPO extends TenantGenericEntity<Long,String> {
     /**
      * 状态 0正常;1停用
      */
-    private StatusEnum status;
+    private String status;
 
     /**
      * 创建人

+ 2 - 0
tr-modules/tr-module-system/src/main/java/cn/tr/module/sys/user/po/SysPostPO.java

@@ -8,6 +8,7 @@ import com.alibaba.excel.annotation.write.style.*;
 import com.alibaba.excel.enums.poi.HorizontalAlignmentEnum;
 import com.baomidou.mybatisplus.annotation.FieldFill;
 import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableName;
 import com.fasterxml.jackson.annotation.JsonFormat;
 import com.fasterxml.jackson.databind.annotation.JsonSerialize;
 import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
@@ -33,6 +34,7 @@ import java.util.Date;
 @ContentStyle(horizontalAlignment = HorizontalAlignmentEnum.CENTER)
 @ContentFontStyle(fontHeightInPoints = 10)
 @ExcelIgnoreUnannotated
+@TableName(value = "sys_post",autoResultMap = true)
 public class SysPostPO implements Serializable {
 
     private static final long serialVersionUID = 1L;

+ 3 - 0
tr-modules/tr-module-system/src/main/java/cn/tr/module/sys/user/po/SysUserPostPO.java

@@ -1,5 +1,7 @@
 package cn.tr.module.sys.user.po;
 
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableName;
 import com.fasterxml.jackson.databind.annotation.JsonSerialize;
 import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
 import lombok.Data;
@@ -15,6 +17,7 @@ import java.io.Serializable;
  * @since 2021-06-10
  */
 @Data
+@TableName(value = "sys_user_post",autoResultMap = true)
 public class SysUserPostPO implements Serializable {
 
     private static final long serialVersionUID = 1L;

+ 4 - 0
tr-modules/tr-module-system/src/main/java/cn/tr/module/sys/user/service/ISysUserService.java

@@ -5,6 +5,8 @@ import cn.tr.module.sys.user.po.SysUserPO;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.IService;
+
+import java.util.Collection;
 import java.util.List;
 
 /**
@@ -73,4 +75,6 @@ public interface ISysUserService extends IService<SysUserPO> {
     SysUserDTO selectSysUserById(String userId);
 
     List<SysUserPO> listDoctorOptions();
+
+    List<SysUserPO> selectSysUserList(SysUserQueryDTO req);
 }

+ 5 - 5
tr-modules/tr-module-system/src/main/java/cn/tr/module/sys/user/service/impl/SysDeptServiceImpl.java

@@ -87,10 +87,10 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDeptPO> im
         if (!this.checkUniqueDeptName(req.getDeptName(), req.getId())) {
             throw new CustomException("部门名称已存在");
         }
-        if (req.getStatus().equals(StatusEnum.NO.getValue()) &&
-                this.list(Wrappers.lambdaQuery(SysDeptPO.class)
-                        .eq(SysDeptPO::getStatus, StatusEnum.YES)
-                        .apply("find_in_set({0}, ancestors)", req.getId())).size() > 0) {
+        if (req.getStatus().equals(String.valueOf(StatusEnum.NO.getValue())) &&
+                !this.list(Wrappers.lambdaQuery(SysDeptPO.class)
+                        .eq(SysDeptPO::getStatus, String.valueOf(StatusEnum.YES.getValue()))
+                        .apply("find_in_set({0}, ancestors)", req.getId())).isEmpty()) {
             throw new CustomException("该部门存在未停用的下级部门");
         }
         SysDeptPO entity = BeanUtil.copyProperties(req, SysDeptPO.class);
@@ -113,7 +113,7 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDeptPO> im
         List<SysDeptPO> parentList = Arrays.asList(entity.getAncestors().split(",")).stream().map(item -> {
             SysDeptPO sysDeptTemp = new SysDeptPO();
             sysDeptTemp.setId(Long.parseLong(item));
-            sysDeptTemp.setStatus(StatusEnum.YES);
+            sysDeptTemp.setStatus(String.valueOf(StatusEnum.YES.getValue()));
             return sysDeptTemp;
         }).collect(Collectors.toList());
         this.updateBatchById(parentList);

+ 87 - 0
tr-modules/tr-module-system/src/main/java/cn/tr/module/sys/user/service/impl/SysUserServiceImpl.java

@@ -4,6 +4,7 @@ import cn.dev33.satoken.exception.NotPermissionException;
 import cn.dev33.satoken.session.SaSession;
 import cn.dev33.satoken.stp.StpLogic;
 import cn.hutool.core.bean.BeanUtil;
+import cn.hutool.core.collection.CollectionUtil;
 import cn.hutool.core.util.StrUtil;
 import cn.tr.core.pojo.LoginUser;
 import cn.tr.core.pojo.SysRoleInfo;
@@ -31,6 +32,7 @@ import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.CollectionUtils;
 import jakarta.annotation.Resource;
 import java.util.List;
+import java.util.Map;
 import java.util.Objects;
 import java.util.Set;
 import java.util.concurrent.CompletableFuture;
@@ -94,6 +96,91 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserRepository, SysUserPO
         return page;
     }
 
+    @Override
+    public List<SysUserPO> selectSysUserList(SysUserQueryDTO req) {
+        List<SysDeptPO> sysDeptList = Lists.newArrayList();
+        if (StrUtil.isNotBlank(req.getDeptId()) && sysDeptService != null) {
+            Long deptId = null;
+            try {
+                deptId = StrUtil.isNotBlank(req.getDeptId()) ? Long.parseLong(req.getDeptId()) : null;
+            } catch (NumberFormatException e) {
+                // 处理非法部门ID,避免查询报错
+                throw new CustomException("部门ID非法");
+            }
+            if (deptId != null) {
+                sysDeptList = sysDeptService.list(Wrappers.lambdaQuery(SysDeptPO.class)
+                        .apply("find_in_set({0}, ancestors)", deptId));
+            }
+        }
+
+        // 转换部门ID为Long类型的列表
+        List<Long> sysDeptIdList = sysDeptList.stream()
+                .map(SysDeptPO::getId) // sys_dept.id是Long
+                .collect(Collectors.toList());
+
+        LambdaQueryWrapper<SysUserPO> queryWrapper = Wrappers.lambdaQuery();
+        queryWrapper.like(StrUtil.isNotBlank(req.getAccount()), SysUserPO::getAccount, req.getAccount());
+        queryWrapper.like(StrUtil.isNotBlank(req.getNickname()), SysUserPO::getNickname, req.getNickname());
+        queryWrapper.like(StrUtil.isNotBlank(req.getRealname()), SysUserPO::getRealname, req.getRealname());
+        queryWrapper.like(StrUtil.isNotBlank(req.getEnglishName()), SysUserPO::getEnglishName, req.getEnglishName());
+        queryWrapper.like(StrUtil.isNotBlank(req.getEmail()), SysUserPO::getEmail, req.getEmail());
+        queryWrapper.like(StrUtil.isNotBlank(req.getPhone()), SysUserPO::getPhone, req.getPhone());
+        queryWrapper.like(StrUtil.isNotBlank(req.getStaffNumber()), SysUserPO::getStaffNumber, req.getStaffNumber());
+        queryWrapper.eq(SysUserPO::getStatus, String.valueOf(StatusEnum.YES.getValue()));
+        queryWrapper.and(StrUtil.isNotBlank(req.getDeptId()), wrapper ->
+                wrapper.eq(SysUserPO::getDeptId, req.getDeptId())
+                        .or(!CollectionUtils.isEmpty(sysDeptIdList), wrapper2 ->
+                                wrapper2.in(SysUserPO::getDeptId,
+                                        sysDeptIdList.stream().map(String::valueOf).collect(Collectors.toList())
+                                )
+                        )
+        );
+
+        queryWrapper.orderByAsc(SysUserPO::getCreateTime);
+
+        List<SysUserPO> sysUserList = this.list(queryWrapper);
+
+
+        // 优化:批量查询部门(修复部门ID类型转换)
+        if (sysDeptService != null && CollectionUtil.isNotEmpty(sysUserList)) {
+            // 收集所有用户的部门ID(String转Long,过滤非法值)
+            List<Long> deptIds = sysUserList.stream()
+                    .map(SysUserPO::getDeptId)
+                    .filter(StrUtil::isNotBlank)
+                    .map(deptIdStr -> {
+                        try {
+                            return Long.parseLong(deptIdStr);
+                        } catch (NumberFormatException e) {
+                            throw new CustomException("部门ID非法");
+                        }
+                    })
+                    .filter(Objects::nonNull)
+                    .distinct()
+                    .collect(Collectors.toList());
+
+            if (CollectionUtil.isNotEmpty(deptIds)) {
+                // 批量查询部门(用Long类型的ID查询,匹配sys_dept.id的int8类型)
+                Map<Long, String> deptIdToNameMap = sysDeptService.listByIds(deptIds).stream()
+                        .collect(Collectors.toMap(
+                                SysDeptPO::getId,
+                                SysDeptPO::getDeptName,
+                                (v1, v2) -> v1
+                        ));
+
+                // 批量设置部门名称
+                sysUserList.forEach(item -> {
+                    try {
+                        Long deptId = Long.parseLong(item.getDeptId());
+                        item.setDeptName(deptIdToNameMap.get(deptId));
+                    } catch (NumberFormatException e) {
+                        item.setDeptName(null); // 非法ID则置空
+                    }
+                });
+            }
+        }
+        return sysUserList;
+    }
+
     @Override
     public List<SysUserPO> list(SysUserQueryDTO req) {
         LambdaQueryWrapper<SysUserPO> queryWrapper = Wrappers.lambdaQuery();

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

@@ -57,6 +57,19 @@ public class BusClinicController extends BaseController{
 //        return CommonResult.success(busClinicService.insertBusClinic(source));
 //    }
 
+    @Operation(summary = "新增患者",description = "权限: phototherapy:clinic:add")
+    @PostMapping("/addPatient")
+    @SaCheckPermission("phototherapy:clinic:add")
+    public CommonResult<Boolean> addPatient(@Validated @RequestBody BusClinicAddDTO source) {
+        return CommonResult.success(busClinicService.insertBusPatient(source));
+    }
+
+    @Operation(summary = "根据患者唯一编码编辑患者")
+    @PostMapping("/editPatient")
+    public CommonResult<Boolean> editPatient(@Validated @RequestBody BusClinicEditDTO source) {
+        return CommonResult.success(busClinicService.updateBusPatientByUniqueId(source));
+    }
+
     @Operation(summary = "通过主键id编辑临床表", description = "权限: phototherapy:clinic:edit")
     @PostMapping("/edit")
     @SaCheckPermission("phototherapy:clinic:edit")
@@ -77,10 +90,5 @@ public class BusClinicController extends BaseController{
         return CommonResult.success(busClinicService.getPatientTherapyDetailById(patientUniqueId));
     }
 
-    @Operation(summary = "新增患者",description = "权限: phototherapy:clinic:add")
-    @PostMapping("/addPatient")
-    @SaCheckPermission("phototherapy:clinic:add")
-    public CommonResult<Boolean> addPatient(@Validated @RequestBody BusClinicAddDTO source) {
-        return CommonResult.success(busClinicService.insertBusPatient(source));
-    }
+
 }

+ 10 - 4
tr-modules/tr-modules-phototherapy/src/main/java/cn/tr/module/phototherapy/common/controller/BusTherapyPlanController.java

@@ -4,8 +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.BusClinicAddDTO;
-import cn.tr.module.phototherapy.common.dto.BusTherapyPlanAddDTO;
+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;
@@ -14,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.BusTherapyPlanDTO;
 import cn.tr.module.phototherapy.common.service.IBusTherapyPlanService;
-import cn.tr.module.phototherapy.common.dto.BusTherapyPlanQueryDTO;
+
 import java.util.*;
 import cn.tr.core.context.BaseController;
 import org.springframework.web.bind.annotation.*;
@@ -70,10 +68,18 @@ public class BusTherapyPlanController extends BaseController{
         return CommonResult.success(busTherapyPlanService.updateBusTherapyPlanById(source));
     }
 
+
     @Operation(summary = "删除设计方案", description = "权限: phototherapy:common:remove")
     @PostMapping("/removeByIds")
     @SaCheckPermission("phototherapy:common:remove")
     public CommonResult<Boolean> delete(@RequestBody Collection<String> ids) {
         return CommonResult.success(busTherapyPlanService.removeBusTherapyPlanByIds(ids));
     }
+
+    @Operation(summary = "根据状态和阶段名字治疗方案")
+    @PostMapping("/queryByStatusAndName")
+    public CommonResult<List<BusTherapyPlanDTO>> queryByStatusAndName() {
+        return CommonResult.success(busTherapyPlanService.queryByStatusAndName());
+    }
+
 }

+ 5 - 2
tr-modules/tr-modules-phototherapy/src/main/java/cn/tr/module/phototherapy/common/dto/BusClinicAddDTO.java

@@ -24,7 +24,7 @@ import java.util.Date;
  * @date 2026-01-12
  **/
 @Data
-@Schema(description = "临床表传输对象")
+@Schema(description = "临床表添加传输对象")
 @ToString
 public class BusClinicAddDTO implements Serializable {
     private static final long serialVersionUID = 1L;
@@ -48,7 +48,10 @@ public class BusClinicAddDTO implements Serializable {
     @Schema(description = "患者地址")
     private String patientAddress;
 
-    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @Schema(description = "患者生日")
+    private Date patientBirthday;
+
+    @JsonFormat(pattern = "yyyy-MM-dd")
     @Schema(description = "阶段开始时间")
     private Date phaseStartTime;
 

+ 3 - 2
tr-modules/tr-modules-phototherapy/src/main/java/cn/tr/module/phototherapy/common/dto/BusClinicDTO.java

@@ -35,11 +35,9 @@ public class BusClinicDTO extends BaseDTO  {
     private String patientUniqueId;
 
     @Schema(description = "患者上次治疗时间")
-    @NotNull(message = "患者上次治疗时间不能为空", groups = {Update.class, Insert.class})
     private Date lastTreatmentTime;
 
     @Schema(description = "关联治疗方案表(当前阶段)")
-    @NotBlank(message = "关联治疗方案表(当前阶段)不能为空", groups = {Update.class, Insert.class})
     private String therapyPlanId;
 
     @Schema(description = "患者姓名")
@@ -57,6 +55,9 @@ public class BusClinicDTO extends BaseDTO  {
     @Schema(description = "患者地址")
     private String patientAddress;
 
+    @Schema(description = "患者生日")
+    private Date patientBirthday;
+
     @Schema(description = "设备id")
     @NotBlank(message = "设备id不能为空", groups = {Update.class, Insert.class})
     private String deviceId;

+ 81 - 0
tr-modules/tr-modules-phototherapy/src/main/java/cn/tr/module/phototherapy/common/dto/BusClinicEditDTO.java

@@ -0,0 +1,81 @@
+package cn.tr.module.phototherapy.common.dto;
+
+import cn.tr.core.validation.Insert;
+import cn.tr.core.validation.Update;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.v3.oas.annotations.media.Schema;
+import jakarta.validation.constraints.NotBlank;
+import lombok.Data;
+import lombok.ToString;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * 临床表修改传输对象
+ *
+ * @author CodeGenerator
+ * @date 2026-01-12
+ **/
+@Data
+@Schema(description = "临床表修改传输对象")
+@ToString
+public class BusClinicEditDTO implements Serializable {
+    private static final long serialVersionUID = 1L;
+
+    @Schema(description = "患者唯一标识")
+    private String patientUniqueId;
+
+    @Schema(description = "患者姓名")
+    private String patientName;
+
+    @Schema(description = "患者年龄")
+    private Integer patientAge;
+
+    @Schema(description = "患者性别文本(0女 1男 2未知)")
+    private String patientGenderText;
+
+    @Schema(description = "患者联系电话")
+    private String patientPhone;
+
+    @Schema(description = "患者地址")
+    private String patientAddress;
+
+    @Schema(description = "患者生日")
+    private Date patientBirthday;
+
+    @Schema(description = "强化期阶段")
+    private String intensivePhaseType;
+
+    @Schema(description = "强化期阶段频率")
+    private Integer intensivePhaseFreq;
+
+    @Schema(description = "强化期阶段建议时长")
+    private Integer intensivePhaseDurationMin;
+
+    @Schema(description = "次续期阶段")
+    private String continuousPhaseType;
+
+    @Schema(description = "次续期阶段频率")
+    private Integer continuousPhaseFreq;
+
+    @Schema(description = "次续期阶段建议时长")
+    private Integer continuousPhaseDurationMin;
+
+    @Schema(description = "强化期阶段日文本(每日/隔日)")
+    private String intensivePhaseDayText;
+
+    @Schema(description = "次续期阶段日文本(每日/隔日)")
+    private String continuousPhaseDayText;
+
+    @Schema(description = "所属分组(0治疗组 1对照组)")
+    private String groupTypeText;
+
+    @Schema(description = "负责医生")
+    private String planDoctor;
+
+    @Schema(description = "治疗方案id")
+    private String therapyPlanId;
+
+
+}

+ 32 - 0
tr-modules/tr-modules-phototherapy/src/main/java/cn/tr/module/phototherapy/common/dto/BusPlanStatusAndNameQueryDTO.java

@@ -0,0 +1,32 @@
+package cn.tr.module.phototherapy.common.dto;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+import lombok.ToString;
+
+import java.io.Serializable;
+
+/**
+ * 治疗方案表查询参数
+ *
+ * @author CodeGenerator
+ * @date 2026-01-13
+ **/
+@Data
+@Schema(description = "阶段方案和阶段类型查询参数")
+@ToString
+public class BusPlanStatusAndNameQueryDTO implements Serializable{
+    private static final long serialVersionUID = 1L;
+
+    @Schema(description = "阶段类型")
+    private String phaseType;
+
+    @Schema(description = "方案状态(0启用 1等待启用 2终止)")
+    private Integer planStatus;
+
+    @Schema(description = "逻辑删除(0存在 1删除)")
+    private Integer isDelete;
+
+
+
+}

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

@@ -47,7 +47,7 @@ public class BusTherapyPlanAddDTO extends BaseDTO  {
     @Schema(description = "方案状态(0启用 1等待启用 2终止)")
     private Integer planStatus;
 
-    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(pattern = "yyyy-MM-dd ")
     @Schema(description = "阶段开始时间")
     private Date phaseStartTime;
 

+ 2 - 5
tr-modules/tr-modules-phototherapy/src/main/java/cn/tr/module/phototherapy/common/dto/BusTherapyPlanDTO.java

@@ -51,11 +51,11 @@ public class BusTherapyPlanDTO extends BaseDTO  {
     @Schema(description = "方案状态(0启用 1等待启用 2终止)")
     private Integer planStatus;
 
-    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(pattern = "yyyy-MM-dd")
     @Schema(description = "阶段开始时间")
     private Date phaseStartTime;
 
-    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(pattern = "yyyy-MM-dd")
     @Schema(description = "阶段结束时间")
     private Date phaseEndTime;
 
@@ -65,9 +65,6 @@ public class BusTherapyPlanDTO extends BaseDTO  {
     @Schema(description = "患者唯一标识")
     private String patientUniqueId;
 
-    @Schema(description = "医院id")
-    private String tenantId;
-
     @Schema(description = "逻辑删除(0存在 1删除)")
     @NotNull(message = "逻辑删除不能为空", groups = {Update.class, Insert.class})
     private Integer isDelete;

+ 62 - 0
tr-modules/tr-modules-phototherapy/src/main/java/cn/tr/module/phototherapy/common/dto/BusTherapyPlanEditDTO.java

@@ -0,0 +1,62 @@
+package cn.tr.module.phototherapy.common.dto;
+
+import cn.tr.core.pojo.BaseDTO;
+import cn.tr.core.validation.Insert;
+import cn.tr.core.validation.Update;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.v3.oas.annotations.media.Schema;
+import jakarta.validation.constraints.NotBlank;
+import jakarta.validation.constraints.NotNull;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.ToString;
+
+import java.util.Date;
+
+/**
+ * 治疗方案表修改传输对象
+ *
+ * @author CodeGenerator
+ * @date 2026-01-13
+ **/
+@Data
+@Schema(description = "设计方案修改传输对象")
+@EqualsAndHashCode(callSuper = true)
+@ToString
+public class BusTherapyPlanEditDTO extends BaseDTO  {
+    private static final long serialVersionUID = 1L;
+
+    @Schema(description = "方案医生")
+    private String planDoctor;
+
+    @Schema(description = "强化期阶段")
+    private String intensivePhaseType;
+
+    @Schema(description = "强化期阶段频率")
+    private Integer intensivePhaseFreq;
+
+    @Schema(description = "强化期阶段建议时长")
+    private Integer intensivePhaseDurationMin;
+
+    @Schema(description = "次续期阶段")
+    private String continuousPhaseType;
+
+    @Schema(description = "次续期阶段频率")
+    private Integer continuousPhaseFreq;
+
+    @Schema(description = "次续期阶段建议时长")
+    private Integer continuousPhaseDurationMin;
+
+    @Schema(description = "强化期阶段日文本(每日/隔日)")
+    private String intensivePhaseDayText;
+
+    @Schema(description = "次续期阶段日文本(每日/隔日)")
+    private String continuousPhaseDayText;
+
+    @Schema(description = "患者唯一标识")
+    private String patientUniqueId;
+
+    @Schema(description = "逻辑删除(0存在 1删除)")
+    private Integer isDelete;
+
+}

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

@@ -42,9 +42,6 @@ public class BusTherapyPlanQueryDTO  implements Serializable{
     @Schema(description = "方案状态(0启用 1等待启用 2终止)")
     private Integer planStatus;
 
-    @Schema(description = "医院id")
-    private String tenantId;
-
     @Schema(description = "逻辑删除(0存在 1删除)")
     private Integer isDelete;
 

+ 3 - 0
tr-modules/tr-modules-phototherapy/src/main/java/cn/tr/module/phototherapy/common/po/BusClinicPO.java

@@ -67,6 +67,9 @@ public class BusClinicPO extends TenantGenericEntity<String,String> {
     @Schema(description = "患者地址")
     private String patientAddress;
 
+    @Schema(description = "患者生日")
+    private Date patientBirthday;
+
     /** 设备id */
     @Schema(description = "设备id")
     private String deviceId;

+ 2 - 2
tr-modules/tr-modules-phototherapy/src/main/java/cn/tr/module/phototherapy/common/po/BusTherapyPlanPO.java

@@ -67,12 +67,12 @@ public class BusTherapyPlanPO extends TenantGenericEntity<String,String> {
 
     /** 阶段开始时间 */
     @Schema(description = "阶段开始时间")
-    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(pattern = "yyyy-MM-dd")
     private Date phaseStartTime;
 
     /** 阶段结束时间 */
     @Schema(description = "阶段结束时间")
-    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(pattern = "yyyy-MM-dd")
     private Date phaseEndTime;
 
     @Schema(description = "患者唯一标识")

+ 138 - 0
tr-modules/tr-modules-phototherapy/src/main/java/cn/tr/module/phototherapy/common/quartz/TheraPhaseAutoUpdateTask.java

@@ -0,0 +1,138 @@
+package cn.tr.module.phototherapy.common.quartz;
+
+import cn.hutool.core.date.DateTime;
+import cn.hutool.core.date.DateUtil;
+import cn.tr.module.phototherapy.common.dto.BusTherapyPlanDTO;
+import cn.tr.module.phototherapy.common.enums.TherapyPlanNameEnum;
+import cn.tr.module.phototherapy.common.enums.TherapyPlanStatusEnum;
+import cn.tr.module.phototherapy.common.po.BusClinicPO;
+import cn.tr.module.phototherapy.common.po.BusTherapyPlanPO;
+import cn.tr.module.phototherapy.common.repository.BusClinicRepository;
+import cn.tr.module.phototherapy.common.repository.BusTherapyPlanRepository;
+import cn.tr.module.phototherapy.common.service.impl.BusClinicServiceImpl;
+import cn.tr.module.phototherapy.common.service.impl.BusTherapyPlanServiceImpl;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import jakarta.annotation.Resource;
+import lombok.extern.slf4j.Slf4j;
+import org.checkerframework.checker.units.qual.A;
+import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.stereotype.Component;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.Date;
+import java.util.List;
+
+/**
+ * @author zzy
+ * @version 1.0
+ * @description: 根据时间节点自动计算强化期和维持期
+ * @date 2026/1/23 14:12
+ */
+@Component
+@Slf4j
+public class TheraPhaseAutoUpdateTask {
+
+    @Resource
+    private BusTherapyPlanServiceImpl busTherapyPlanServiceImpl;
+    @Resource
+    private BusTherapyPlanRepository busTherapyPlanRepository;
+    @Resource
+    private BusClinicServiceImpl busClinicServiceImpl;
+
+    /**
+     * 每日1点执行一次
+     */
+//    @Scheduled(cron = "0 */1 * * * ?")
+    @Scheduled(cron = "0 0 1 * * ?")
+    @Transactional(rollbackFor = Exception.class)
+    public void autoUpdateTheraPhase() {
+        log.info("开始执行任务治疗阶段自动更新任务");
+        //1.处理强化期方案
+        processIntensivePhaseEnd();
+        //2.处理维持期方案
+        processContinuousPhaseEnd();
+
+        log.info("=== 治疗阶段自动更新任务执行完成 ===");
+    }
+
+    /**
+     * 处理强化期方案
+     */
+    private void processIntensivePhaseEnd() {
+        //查询出来需要修改的强化期方案
+        List<BusTherapyPlanDTO> intensivePlans = busTherapyPlanServiceImpl.queryByStatusAndName();
+        //执行循环修改
+        for (BusTherapyPlanDTO intensivePlan : intensivePlans) {
+            //获取到强化期方案开始时间
+            Date phaseStartTime = intensivePlan.getPhaseStartTime();
+            //计算出预计时间
+            DateTime expectedEndTime = DateUtil.offsetDay(phaseStartTime, 10);
+            Date now = new Date();
+            //判断时间是否结束
+            if (now.after(expectedEndTime) || now.equals(expectedEndTime)){
+                BusTherapyPlanDTO updateIntensive = new BusTherapyPlanDTO();
+                updateIntensive.setId(intensivePlan.getId());
+                updateIntensive.setPhaseEndTime(now);
+                updateIntensive.setPlanStatus(TherapyPlanStatusEnum.TERMINATED.getValue());
+                busTherapyPlanServiceImpl.updateBusTherapyPlanById(updateIntensive);
+                log.info("更新方案{}的方案状态为结束", intensivePlan.getId());
+                enableCorrespondingContinuousPlan(intensivePlan.getPatientUniqueId(), now);
+
+            }
+        }
+
+    }
+    private void enableCorrespondingContinuousPlan(String patientUniqueId, Date startDate) {
+        LambdaQueryWrapper<BusTherapyPlanPO> queryWrapper = new LambdaQueryWrapper<>();
+        queryWrapper.eq(BusTherapyPlanPO::getPatientUniqueId, patientUniqueId)
+                .eq(BusTherapyPlanPO::getPhaseType, TherapyPlanNameEnum.MAINTENANCE.getText())
+                .eq(BusTherapyPlanPO::getPlanStatus, TherapyPlanStatusEnum.WAITING.getValue());
+
+        BusTherapyPlanPO continuousPlan = busTherapyPlanRepository.selectOne(queryWrapper);
+        if (continuousPlan != null) {
+            BusTherapyPlanPO updateContinuous = new BusTherapyPlanPO();
+            updateContinuous.setId(continuousPlan.getId());
+            updateContinuous.setPhaseStartTime(startDate);
+            updateContinuous.setPlanStatus(TherapyPlanStatusEnum.ENABLED.getValue());
+            busTherapyPlanRepository.updateById(updateContinuous);
+            //修改临床表中的治疗方案id
+            //通过治疗方案id查询到患者的唯一标识
+            BusClinicPO updateClinic = new BusClinicPO();
+            updateClinic.setPatientUniqueId(patientUniqueId);
+            updateClinic.setTherapyPlanId(continuousPlan.getId());
+            busClinicServiceImpl.updateBusClinicByPatientUniqueId(updateClinic);
+            log.info("维持期方案[{}]已启用,开始时间设为:{}", continuousPlan.getId(), startDate);
+        } else {
+            log.warn("未找到患者[{}]对应的维持期方案", patientUniqueId);
+        }
+    }
+
+    /**
+     * 处理维持期方案
+     */
+    private void processContinuousPhaseEnd() {
+        LambdaQueryWrapper<BusTherapyPlanPO> queryWrapper = new LambdaQueryWrapper<>();
+        queryWrapper.eq(BusTherapyPlanPO::getPhaseType, TherapyPlanNameEnum.MAINTENANCE.getText())
+                .eq(BusTherapyPlanPO::getPlanStatus, 0)
+                .isNull(BusTherapyPlanPO::getPhaseEndTime);
+
+        List<BusTherapyPlanPO> continuousPlans = busTherapyPlanRepository.selectList(queryWrapper);
+
+        for (BusTherapyPlanPO plan : continuousPlans) {
+            Date startTime = plan.getPhaseStartTime();
+            Date expectedEndTime = DateUtil.offsetDay(startTime, 20);
+            Date now = new Date();
+
+            if (now.after(expectedEndTime) || now.equals(expectedEndTime)) {
+                BusTherapyPlanPO updateContinuous = new BusTherapyPlanPO();
+                updateContinuous.setId(plan.getId());
+                updateContinuous.setPhaseEndTime(now);
+                updateContinuous.setPlanStatus(TherapyPlanStatusEnum.TERMINATED.getValue());
+                busTherapyPlanRepository.updateById(updateContinuous);
+                log.info("维持期方案[{}]已结束,更新结束时间为:{}", plan.getId(), now);
+            }
+        }
+    }
+
+
+}

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

@@ -5,6 +5,8 @@ import org.apache.ibatis.annotations.Mapper;
 import cn.tr.module.phototherapy.common.po.BusTherapyPlanPO;
 import org.springframework.stereotype.Repository;
 
+import java.util.List;
+
 /**
  * 治疗方案表Mapper接口
  *

+ 45 - 16
tr-modules/tr-modules-phototherapy/src/main/java/cn/tr/module/phototherapy/common/service/IBusClinicService.java

@@ -1,6 +1,7 @@
 package cn.tr.module.phototherapy.common.service;
 
 import cn.tr.module.phototherapy.common.dto.*;
+import cn.tr.module.phototherapy.common.po.BusClinicPO;
 import cn.tr.module.phototherapy.common.vo.PatientTherapyDetailVO;
 import cn.tr.module.phototherapy.common.vo.PatientTherapyRecordVO;
 
@@ -13,35 +14,39 @@ import java.util.Collection;
  * @author CodeGenerator
  * @date 2026-01-12
  **/
-public interface IBusClinicService{
+public interface IBusClinicService {
 
     /**
      * 根据条件查询临床表
-     * @param    query 查询参数
-     * @author   CodeGenerator
-     * @date     2026-01-12
+     *
+     * @param query 查询参数
+     * @author CodeGenerator
+     * @date 2026-01-12
      */
     List<PatientTherapyRecordVO> selectBusClinicList(BusPatientListQueryDTO query);
 
     /**
      * 根据id查询临床表
-     * @param    id 主键id
-     * @author   CodeGenerator
-     * @date     2026-01-12
+     *
+     * @param id 主键id
+     * @author CodeGenerator
+     * @date 2026-01-12
      */
     BusClinicDTO selectBusClinicById(String id);
 
     /**
      * 编辑临床表
-     * @param   source 编辑实体类
-     * @author  CodeGenerator
-     * @date    2026-01-12
+     *
+     * @param source 编辑实体类
+     * @author CodeGenerator
+     * @date 2026-01-12
      */
     boolean updateBusClinicById(BusClinicDTO source);
 
     /**
      * 新增临床表
-     * @param   source 新增实体类
+     *
+     * @param source 新增实体类
      * @author CodeGenerator
      * @date 2026-01-12
      */
@@ -49,24 +54,48 @@ public interface IBusClinicService{
 
     /**
      * 删除临床表详情
-     * @param  ids 删除主键集合
+     *
+     * @param ids 删除主键集合
      * @author CodeGenerator
-     * @date   2026-01-12
+     * @date 2026-01-12
      */
     boolean removeBusClinicByIds(Collection<String> ids);
 
     /**
      * 根据临床id获取患者治疗详情
-      * @param  patientUniqueId 患者唯一标识
-     * @date    2026-01-20
+     *
+     * @param patientUniqueId 患者唯一标识
+     * @date 2026-01-20
      */
     PatientTherapyDetailVO getPatientTherapyDetailById(String patientUniqueId);
 
     /**
      * 新增患者
-     * @param   source 新增实体类
+     *
+     * @param source 新增实体类
      * @author CodeGenerator
      * @date 2026-01-20
      */
     Boolean insertBusPatient(BusClinicAddDTO source);
+
+    /**
+     * 根据患者唯一编码编辑患者
+     *
+     * @param source 编辑实体类
+     * @author CodeGenerator
+     * @date 2026-01-20
+     */
+    Boolean updateBusPatientByUniqueId(BusClinicEditDTO source);
+
+    /**
+     * 根据患者唯一编码修改治疗方案id
+     *
+     * @param updateClinic
+     * @author CodeGenerator
+     * @date 2026-01-20
+     */
+    void updateBusClinicByPatientUniqueId(BusClinicPO updateClinic);
+
+
+//    Boolean updateBusClinicByPatientUniqueId(BusClinicPO source);
 }

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

@@ -1,9 +1,7 @@
 package cn.tr.module.phototherapy.common.service;
 
-import cn.tr.module.phototherapy.common.dto.BusClinicAddDTO;
-import cn.tr.module.phototherapy.common.dto.BusTherapyPlanAddDTO;
-import cn.tr.module.phototherapy.common.dto.BusTherapyPlanDTO;
-import cn.tr.module.phototherapy.common.dto.BusTherapyPlanQueryDTO;
+import cn.tr.module.phototherapy.common.dto.*;
+
 import java.util.*;
 import java.util.Collection;
 
@@ -62,4 +60,19 @@ public interface IBusTherapyPlanService{
      * @date   2026-01-13
      */
     List<BusTherapyPlanDTO> addBatchBusTherapyPlanBatch(BusClinicAddDTO source);
+
+
+    /**
+     * 批量修改治疗方案
+     * @author  zzy
+     * @date   2026-01-13
+     */
+    boolean editBatchBusTherapyPlanBatch(BusClinicEditDTO source);
+
+    /**
+     * 根据状态和阶段名字查询治疗方案
+     * @author  zzy
+     * @date   2026-01-13
+     */
+    List<BusTherapyPlanDTO> queryByStatusAndName();
 }

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

@@ -3,12 +3,14 @@ package cn.tr.module.phototherapy.common.service.impl;
 import cn.tr.module.phototherapy.common.dto.*;
 import cn.tr.module.phototherapy.common.enums.GroupTypeEnum;
 import cn.tr.module.phototherapy.common.enums.PatientGenderEnum;
+import cn.tr.module.phototherapy.common.enums.PhaseDayEnum;
 import cn.tr.module.phototherapy.common.mapper.BusTherapyRecordMapper;
 import cn.tr.module.phototherapy.common.po.BusTherapyPlanPO;
 import cn.tr.module.phototherapy.common.repository.BusDeviceRepository;
 import cn.tr.module.phototherapy.common.repository.BusTherapyPlanRepository;
 import cn.tr.module.phototherapy.common.vo.PatientTherapyDetailVO;
 import cn.tr.module.phototherapy.common.vo.PatientTherapyRecordVO;
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import jakarta.annotation.Resource;
 import org.springframework.stereotype.Service;
@@ -40,8 +42,6 @@ public class BusClinicServiceImpl extends ServiceImpl<BusClinicRepository, BusCl
     private BusTherapyPlanServiceImpl busTherapyPlanServiceImpl;
     @Resource
     private BusTherapyPlanRepository busTherapyPlanRepository;
-    @Resource
-    private BusDeviceRepository busDeviceRepository;
 
 
 
@@ -171,6 +171,7 @@ public class BusClinicServiceImpl extends ServiceImpl<BusClinicRepository, BusCl
         clinicDTO.setTherapyPlanId(intensivePlanId);
         clinicDTO.setPatientName(source.getPatientName());
         clinicDTO.setPatientAge(source.getPatientAge());
+        clinicDTO.setPatientBirthday(source.getPatientBirthday());
         clinicDTO.setPatientGender(patientGenderValue);
         clinicDTO.setPatientPhone(source.getPatientPhone());
         clinicDTO.setPatientAddress(source.getPatientAddress());
@@ -183,4 +184,47 @@ public class BusClinicServiceImpl extends ServiceImpl<BusClinicRepository, BusCl
         }
         return true;
     }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public Boolean updateBusPatientByUniqueId(BusClinicEditDTO source) {
+        //根据唯一编码查询患者信息
+        BusClinicPO patient = this.getOne(new LambdaQueryWrapper<BusClinicPO>()
+                .eq(BusClinicPO::getPatientUniqueId, source.getPatientUniqueId()));
+        if (ObjectUtil.isNull(patient)){
+            throw new ServiceException(TRExcCode.SYSTEM_ERROR_B0001, "患者不存在");
+        }
+
+        PatientGenderEnum patientGenderEnum = PatientGenderEnum.getByText(source.getPatientGenderText());
+        Integer patientGenderValue = patientGenderEnum.getValue();
+
+        GroupTypeEnum groupTypeEnum = GroupTypeEnum.getByText(source.getGroupTypeText());
+        Integer groupTypeValue = groupTypeEnum.getValue();
+        //根据患者唯一编码修改患者信息
+        String patientUniqueId = patient.getPatientUniqueId();
+        this.update(new LambdaUpdateWrapper<BusClinicPO>()
+                .eq(BusClinicPO::getPatientUniqueId, patientUniqueId)
+                .set(BusClinicPO::getPatientName, source.getPatientName())
+                .set(BusClinicPO::getPatientGender, patientGenderValue)
+                .set(BusClinicPO::getPatientPhone, source.getPatientPhone())
+                .set(BusClinicPO::getPatientAddress, source.getPatientAddress())
+                .set(BusClinicPO::getPatientBirthday, source.getPatientBirthday())
+                .set(BusClinicPO::getGroupType, groupTypeValue));
+
+        //2.批量修改治疗信息
+        boolean result = busTherapyPlanServiceImpl.editBatchBusTherapyPlanBatch(source);
+        if (!result){
+            throw new ServiceException(TRExcCode.SYSTEM_ERROR_B0001, "修改患者失败");
+        }
+        return true;
+    }
+
+
+
+    @Override
+    public void updateBusClinicByPatientUniqueId(BusClinicPO source) {
+        this.update(new LambdaUpdateWrapper<BusClinicPO>()
+                .eq(BusClinicPO::getPatientUniqueId,source.getPatientUniqueId())
+                .set(BusClinicPO::getTherapyPlanId, source.getTherapyPlanId()));
+    }
 }

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

@@ -1,7 +1,6 @@
 package cn.tr.module.phototherapy.common.service.impl;
 
-import cn.tr.module.phototherapy.common.dto.BusClinicAddDTO;
-import cn.tr.module.phototherapy.common.dto.BusTherapyPlanAddDTO;
+import cn.tr.module.phototherapy.common.dto.*;
 import cn.tr.module.phototherapy.common.enums.PhaseDayEnum;
 import cn.tr.module.phototherapy.common.enums.TherapyPlanNameEnum;
 import cn.tr.module.phototherapy.common.enums.TherapyPlanStatusEnum;
@@ -16,9 +15,9 @@ import cn.tr.core.exception.ServiceException;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import cn.tr.module.phototherapy.common.repository.BusTherapyPlanRepository;
 import cn.tr.module.phototherapy.common.po.BusTherapyPlanPO;
-import cn.tr.module.phototherapy.common.dto.BusTherapyPlanDTO;
-import cn.tr.module.phototherapy.common.dto.BusTherapyPlanQueryDTO;
+
 import java.util.*;
+
 import cn.tr.module.phototherapy.common.service.IBusTherapyPlanService;
 import cn.tr.module.phototherapy.common.mapper.BusTherapyPlanMapper;
 import jakarta.annotation.Resource;
@@ -34,80 +33,93 @@ import cn.tr.core.exception.TRExcCode;
 public class BusTherapyPlanServiceImpl extends ServiceImpl<BusTherapyPlanRepository, BusTherapyPlanPO> implements IBusTherapyPlanService {
 
 
-
     /**
-    * 根据条件查询设计方案
-    * @param    query 查询参数
-    * @author   CodeGenerator
-    * @date     2026-01-13
-    */
+     * 根据条件查询设计方案
+     *
+     * @param query 查询参数
+     * @author CodeGenerator
+     * @date 2026-01-13
+     */
     @Override
-    public List<BusTherapyPlanDTO> selectBusTherapyPlanList(BusTherapyPlanQueryDTO query){
+    public List<BusTherapyPlanDTO> selectBusTherapyPlanList(BusTherapyPlanQueryDTO query) {
         return BusTherapyPlanMapper.INSTANCE.convertDtoList(
                 this.list(new LambdaQueryWrapper<BusTherapyPlanPO>()
-                    .eq(ObjectUtil.isNotNull(query.getId()), BusTherapyPlanPO::getId, query.getId())
-                    .eq(ObjectUtil.isNotNull(query.getPlanDoctor()), BusTherapyPlanPO::getPlanDoctor, query.getPlanDoctor())
-                    .like(ObjectUtil.isNotNull(query.getPlanName()), BusTherapyPlanPO::getPlanName, query.getPlanName())
-                    .eq(ObjectUtil.isNotNull(query.getPhaseType()), BusTherapyPlanPO::getPhaseType, query.getPhaseType())
-                    .eq(ObjectUtil.isNotNull(query.getPhaseTargetTimes()), BusTherapyPlanPO::getPhaseTargetTimes, query.getPhaseTargetTimes())
-                    .eq(ObjectUtil.isNotNull(query.getPhaseFreq()), BusTherapyPlanPO::getPhaseFreq, query.getPhaseFreq())
-                    .eq(ObjectUtil.isNotNull(query.getPhaseDurationMin()), BusTherapyPlanPO::getPhaseDurationMin, query.getPhaseDurationMin())
-                    .eq(ObjectUtil.isNotNull(query.getPlanStatus()), BusTherapyPlanPO::getPlanStatus, query.getPlanStatus())
-                    .eq(ObjectUtil.isNotNull(query.getIsDelete()), BusTherapyPlanPO::getIsDelete, query.getIsDelete())
-                    .eq(ObjectUtil.isNotNull(query.getTenantId()), BusTherapyPlanPO::getTenantId, query.getTenantId())
+                        .eq(ObjectUtil.isNotNull(query.getId()), BusTherapyPlanPO::getId, query.getId())
+                        .eq(ObjectUtil.isNotNull(query.getPlanDoctor()), BusTherapyPlanPO::getPlanDoctor, query.getPlanDoctor())
+                        .like(ObjectUtil.isNotNull(query.getPlanName()), BusTherapyPlanPO::getPlanName, query.getPlanName())
+                        .eq(ObjectUtil.isNotNull(query.getPhaseType()), BusTherapyPlanPO::getPhaseType, query.getPhaseType())
+                        .eq(ObjectUtil.isNotNull(query.getPhaseTargetTimes()), BusTherapyPlanPO::getPhaseTargetTimes, query.getPhaseTargetTimes())
+                        .eq(ObjectUtil.isNotNull(query.getPhaseFreq()), BusTherapyPlanPO::getPhaseFreq, query.getPhaseFreq())
+                        .eq(ObjectUtil.isNotNull(query.getPhaseDurationMin()), BusTherapyPlanPO::getPhaseDurationMin, query.getPhaseDurationMin())
+                        .eq(ObjectUtil.isNotNull(query.getPlanStatus()), BusTherapyPlanPO::getPlanStatus, query.getPlanStatus())
+                        .eq(ObjectUtil.isNotNull(query.getIsDelete()), BusTherapyPlanPO::getIsDelete, query.getIsDelete())
                 )
         );
-    };
+    }
+
+    ;
 
     /**
-    * 根据id查询设计方案
-    * @param    id 主键id
-    * @author   CodeGenerator
-    * @date     2026-01-13
-    */
+     * 根据id查询设计方案
+     *
+     * @param id 主键id
+     * @author CodeGenerator
+     * @date 2026-01-13
+     */
     @Override
-    public BusTherapyPlanDTO selectBusTherapyPlanById(String id){
+    public BusTherapyPlanDTO selectBusTherapyPlanById(String id) {
         return BusTherapyPlanMapper.INSTANCE.convertDto(this.getById(id));
-    };
+    }
+
+    ;
 
     /**
-    * 编辑设计方案
-    * @param   source 编辑实体类
-    * @author  CodeGenerator
-    * @date    2026-01-13
-    */
+     * 编辑设计方案
+     *
+     * @param source 编辑实体类
+     * @author CodeGenerator
+     * @date 2026-01-13
+     */
     @Transactional(rollbackFor = Exception.class)
     @Override
-    public boolean updateBusTherapyPlanById(BusTherapyPlanDTO source){
-            return this.updateById(BusTherapyPlanMapper.INSTANCE.convertPO(source));
-    };
+    public boolean updateBusTherapyPlanById(BusTherapyPlanDTO source) {
+        return this.updateById(BusTherapyPlanMapper.INSTANCE.convertPO(source));
+    }
+
+    ;
 
     /**
-    * 新增设计方案
-    * @param   source 新增实体类
-    * @author CodeGenerator
-    * @date 2026-01-13
-    */
+     * 新增设计方案
+     *
+     * @param source 新增实体类
+     * @author CodeGenerator
+     * @date 2026-01-13
+     */
     @Override
     @Transactional(rollbackFor = Exception.class)
-    public boolean insertBusTherapyPlan(BusTherapyPlanDTO source){
+    public boolean insertBusTherapyPlan(BusTherapyPlanDTO source) {
         return this.save(BusTherapyPlanMapper.INSTANCE.convertPO(source));
-    };
+    }
+
+    ;
 
     /**
-    * 删除设计方案详情
-    * @param  ids 删除主键集合
-    * @author CodeGenerator
-    * @date   2026-01-13
-    */
+     * 删除设计方案详情
+     *
+     * @param ids 删除主键集合
+     * @author CodeGenerator
+     * @date 2026-01-13
+     */
     @Override
     @Transactional(rollbackFor = Exception.class)
-    public boolean removeBusTherapyPlanByIds(Collection<String> ids){
-        if(CollectionUtil.isEmpty(ids)){
-            throw new ServiceException(TRExcCode.SYSTEM_ERROR_B0001,"请选择要删除的数据");
+    public boolean removeBusTherapyPlanByIds(Collection<String> ids) {
+        if (CollectionUtil.isEmpty(ids)) {
+            throw new ServiceException(TRExcCode.SYSTEM_ERROR_B0001, "请选择要删除的数据");
         }
         return this.removeByIds(ids);
-    };
+    }
+
+    ;
 
     @Override
     public List<BusTherapyPlanDTO> addBatchBusTherapyPlanBatch(BusClinicAddDTO source) {
@@ -127,7 +139,8 @@ public class BusTherapyPlanServiceImpl extends ServiceImpl<BusTherapyPlanReposit
         intensivePlan.setPlanStatus(TherapyPlanStatusEnum.ENABLED.getValue());
         planList.add(intensivePlan);
 
-        Integer continuousPhaseDayValue = phaseDayEnum.getValue();
+        PhaseDayEnum continuousphaseDayEnum = PhaseDayEnum.getByText(source.getContinuousPhaseDayText());
+        Integer continuousPhaseDayValue = continuousphaseDayEnum.getValue();
 
         //生成持续期
         BusTherapyPlanDTO continuousPlan = new BusTherapyPlanDTO();
@@ -146,4 +159,75 @@ public class BusTherapyPlanServiceImpl extends ServiceImpl<BusTherapyPlanReposit
         this.saveBatch(planPOList);
         return BusTherapyPlanMapper.INSTANCE.convertDtoList(planPOList);
     }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public boolean editBatchBusTherapyPlanBatch(BusClinicEditDTO source) {
+        String patientUniqueId = source.getPatientUniqueId();
+        if (ObjectUtil.isEmpty(patientUniqueId)) {
+            throw new ServiceException(TRExcCode.SYSTEM_ERROR_B0001, "患者唯一标识不能为空");
+        }
+        //查询该患者的所有方法
+        List<BusTherapyPlanPO> planPOList = this.list(new LambdaQueryWrapper<BusTherapyPlanPO>()
+                .eq(BusTherapyPlanPO::getPatientUniqueId, patientUniqueId)
+                .eq(BusTherapyPlanPO::getIsDelete, 0));
+
+        if (CollectionUtil.isEmpty(planPOList)) {
+            throw new ServiceException(TRExcCode.SYSTEM_ERROR_B0001, "该患者没有治疗方案");
+        }
+
+        // 2. 转换阶段日文本为枚举值(每日→0,隔日→1)
+        PhaseDayEnum intensivePhaseDayEnum = PhaseDayEnum.getByText(source.getIntensivePhaseDayText());
+        Integer intensivePhaseDayValue = intensivePhaseDayEnum.getValue();
+        PhaseDayEnum continuousPhaseDayEnum = PhaseDayEnum.getByText(source.getContinuousPhaseDayText());
+        Integer continuousPhaseDayValue = continuousPhaseDayEnum.getValue();
+
+        //便利方案,按阶段类型分别更新
+        List<BusTherapyPlanPO> updateList = new ArrayList<>();
+        for (BusTherapyPlanPO plan : planPOList) {
+            if (TherapyPlanNameEnum.INTENSIVE.getText().equals(plan.getPhaseType())) {
+                if (source.getIntensivePhaseDayText() != null) {
+                    plan.setPhaseDay(intensivePhaseDayValue);
+                }
+                if (source.getIntensivePhaseFreq() != null) {
+                    plan.setPhaseFreq(source.getIntensivePhaseFreq());
+                }
+                if (source.getIntensivePhaseDurationMin() != null) {
+                    plan.setPhaseDurationMin(source.getIntensivePhaseDurationMin());
+                }
+                if (source.getPlanDoctor() != null) {
+                    plan.setPlanDoctor(source.getPlanDoctor());
+                }
+
+            } else if (TherapyPlanNameEnum.MAINTENANCE.getText().equals(plan.getPhaseType())) {
+                if (source.getContinuousPhaseDayText() != null) {
+                    plan.setPhaseDay(continuousPhaseDayValue);
+                }
+                if (source.getContinuousPhaseFreq() != null) {
+                    plan.setPhaseFreq(source.getContinuousPhaseFreq());
+                }
+                if (source.getContinuousPhaseDurationMin() != null) {
+                    plan.setPhaseDurationMin(source.getContinuousPhaseDurationMin());
+                }
+                if (source.getPlanDoctor() != null) {
+                    plan.setPlanDoctor(source.getPlanDoctor());
+                }
+            }
+            updateList.add(plan);
+        }
+        if (CollectionUtil.isNotEmpty(updateList)) {
+            this.updateBatchById(updateList);
+        }
+        return true;
+    }
+
+    @Override
+    public List<BusTherapyPlanDTO> queryByStatusAndName() {
+        return BusTherapyPlanMapper.INSTANCE.convertDtoList(this.list(new LambdaQueryWrapper<BusTherapyPlanPO>()
+                .eq(BusTherapyPlanPO::getPlanStatus, TherapyPlanStatusEnum.ENABLED.getValue())
+                .eq(BusTherapyPlanPO::getPhaseType, TherapyPlanNameEnum.INTENSIVE.getText())
+                .eq(BusTherapyPlanPO::getIsDelete, 0)
+                .isNull(BusTherapyPlanPO::getPhaseEndTime))
+        );
+    }
 }

+ 1 - 1
tr-modules/tr-modules-phototherapy/src/main/java/cn/tr/module/phototherapy/web/auth/WebAuthGranter.java

@@ -95,7 +95,7 @@ public class WebAuthGranter implements IAuthGranter {
             log.info("登录用户:{}已被删除", source.getUsername());
             throw new CustomException("对不起,您的账号已被删除");
         }
-        if (sysUser.getStatus().equals(StatusEnum.NO.getValue())) {
+        if (sysUser.getStatus().equals(String.valueOf(StatusEnum .NO.getValue()))) {
             log.info("登录用户:{}已被停用", source.getUsername());
             throw new CustomException("对不起,您的账号已被停用");
         }