Jelajahi Sumber

修改添加无法自动添加医院id

zhouzeyu 5 hari lalu
induk
melakukan
75ab81095f
14 mengubah file dengan 59 tambahan dan 60 penghapusan
  1. 21 11
      tr-framework/src/main/java/cn/tr/core/config/CreateAndUpdateMetaObjectHandler.java
  2. 9 8
      tr-modules/tr-modules-phototherapy/src/main/java/cn/tr/module/phototherapy/common/controller/BusClinicController.java
  3. 2 2
      tr-modules/tr-modules-phototherapy/src/main/java/cn/tr/module/phototherapy/common/dto/BusClinicAddDTO.java
  4. 5 5
      tr-modules/tr-modules-phototherapy/src/main/java/cn/tr/module/phototherapy/common/po/BusClinicPO.java
  5. 2 5
      tr-modules/tr-modules-phototherapy/src/main/java/cn/tr/module/phototherapy/common/po/BusDeviceAlarmPO.java
  6. 2 5
      tr-modules/tr-modules-phototherapy/src/main/java/cn/tr/module/phototherapy/common/po/BusDeviceHistoryPO.java
  7. 2 4
      tr-modules/tr-modules-phototherapy/src/main/java/cn/tr/module/phototherapy/common/po/BusDevicePO.java
  8. 2 5
      tr-modules/tr-modules-phototherapy/src/main/java/cn/tr/module/phototherapy/common/po/BusHospitalConfigPO.java
  9. 2 2
      tr-modules/tr-modules-phototherapy/src/main/java/cn/tr/module/phototherapy/common/po/BusHospitalPO.java
  10. 2 1
      tr-modules/tr-modules-phototherapy/src/main/java/cn/tr/module/phototherapy/common/po/BusPatientPO.java
  11. 2 5
      tr-modules/tr-modules-phototherapy/src/main/java/cn/tr/module/phototherapy/common/po/BusTherapyPlanPO.java
  12. 2 5
      tr-modules/tr-modules-phototherapy/src/main/java/cn/tr/module/phototherapy/common/po/BusTherapyRecordPO.java
  13. 6 0
      tr-modules/tr-modules-phototherapy/src/main/java/cn/tr/module/phototherapy/common/service/IBusClinicService.java
  14. 0 2
      tr-modules/tr-modules-phototherapy/src/main/java/cn/tr/module/phototherapy/common/service/impl/BusTherapyPlanServiceImpl.java

+ 21 - 11
tr-framework/src/main/java/cn/tr/core/config/CreateAndUpdateMetaObjectHandler.java

@@ -29,34 +29,44 @@ public class CreateAndUpdateMetaObjectHandler implements MetaObjectHandler {
     @Override
     public void insertFill(MetaObject metaObject) {
         try {
-            LoginUser loginUser =null;
+            LoginUser loginUser = null;
             try {
-                loginUser= SecurityUtil.getLoginUser();
-            }catch (Exception __){
+                loginUser = SecurityUtil.getLoginUser();
+            } catch (Exception __) {
 
             }
             if (metaObject.hasGetter(MybatisConstant.CREATE_TIME) && metaObject.getValue(MybatisConstant.CREATE_TIME) == null) {
                 this.strictInsertFill(metaObject, MybatisConstant.CREATE_TIME, Date.class, new Date());
             }
             if (metaObject.hasGetter(MybatisConstant.IS_DELETE) && metaObject.getValue(MybatisConstant.IS_DELETE) == null) {
-                this.strictInsertFill(metaObject, MybatisConstant.IS_DELETE, Integer.class,0);
+                this.strictInsertFill(metaObject, MybatisConstant.IS_DELETE, Integer.class, 0);
             }
             if (metaObject.hasGetter(MybatisConstant.CREATE_BY) && metaObject.getValue(MybatisConstant.CREATE_BY) == null) {
 
                 this.strictInsertFill(metaObject, MybatisConstant.CREATE_BY, String.class, Objects.isNull(loginUser) ? "1" : loginUser.getId().toString());
             }
             if (metaObject.hasGetter(MybatisConstant.UPDATE_TIME) && metaObject.getValue(MybatisConstant.UPDATE_TIME) == null) {
-                this.strictUpdateFill(metaObject, MybatisConstant.UPDATE_TIME, Date.class, new Date());
+                this.strictInsertFill(metaObject, MybatisConstant.UPDATE_TIME, Date.class, new Date());
             }
             if (metaObject.hasGetter(MybatisConstant.UPDATE_BY) && metaObject.getValue(MybatisConstant.UPDATE_BY) == null) {
-                this.strictUpdateFill(metaObject, MybatisConstant.UPDATE_BY, String.class, Objects.isNull(loginUser) ? "1" : loginUser.getId().toString());
+                this.strictInsertFill(metaObject, MybatisConstant.UPDATE_BY, String.class, Objects.isNull(loginUser) ? "1" : loginUser.getId().toString());
             }
             if (metaObject.hasGetter(MybatisConstant.TENANT_ID) && metaObject.getValue(MybatisConstant.TENANT_ID) == null) {
-                ServletRequestAttributes request = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
-                String tenantId ="1";
-                if(request!=null){
-                    tenantId = String.valueOf(request.getAttribute("tenantId", SCOPE_REQUEST));
+
+                String tenantId = "1";
+                if (loginUser != null) {
+                    //优先从登录用户信息中获取
+                    tenantId = loginUser.getTenantId().toString();
+                } else {
+                    ServletRequestAttributes request = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
+                    if (request != null) {
+                        Object requestTenantId = request.getAttribute("tenantId", SCOPE_REQUEST);
+                        if (requestTenantId != null) {
+                            tenantId = String.valueOf(requestTenantId);
+                        }
+                    }
                 }
+
                 this.strictInsertFill(metaObject, MybatisConstant.TENANT_ID, String.class, tenantId);
             }
         } catch (Exception e) {
@@ -79,4 +89,4 @@ public class CreateAndUpdateMetaObjectHandler implements MetaObjectHandler {
         }
     }
 
-}
+}

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

@@ -50,12 +50,12 @@ public class BusClinicController extends BaseController{
         return CommonResult.success(busClinicService.selectBusClinicById(id));
     }
 
-    @Operation(summary = "添加临床表", description = "权限: phototherapy:clinic:add")
-    @PostMapping("/add")
-    @SaCheckPermission("phototherapy:clinic:add")
-    public CommonResult<Boolean> add(@RequestBody@Validated(Insert.class) BusClinicDTO source) {
-        return CommonResult.success(busClinicService.insertBusClinic(source));
-    }
+//    @Operation(summary = "添加临床表", description = "权限: phototherapy:clinic:add")
+//    @PostMapping("/add")
+//    @SaCheckPermission("phototherapy:clinic:add")
+//    public CommonResult<Boolean> add(@RequestBody@Validated(Insert.class) BusClinicDTO source) {
+//        return CommonResult.success(busClinicService.insertBusClinic(source));
+//    }
 
     @Operation(summary = "通过主键id编辑临床表", description = "权限: phototherapy:clinic:edit")
     @PostMapping("/edit")
@@ -77,9 +77,10 @@ public class BusClinicController extends BaseController{
         return CommonResult.success(busClinicService.getPatientTherapyDetailById(patientUniqueId));
     }
 
-    @Operation(summary = "新增患者")
+    @Operation(summary = "新增患者",description = "权限: phototherapy:clinic:add")
     @PostMapping("/addPatient")
-    public CommonResult<Boolean> addPatient(@RequestBody BusClinicAddDTO source) {
+    @SaCheckPermission("phototherapy:clinic:add")
+    public CommonResult<Boolean> addPatient(@Validated @RequestBody BusClinicAddDTO source) {
         return CommonResult.success(busClinicService.insertBusPatient(source));
     }
 }

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

@@ -14,6 +14,7 @@ import lombok.Data;
 import lombok.EqualsAndHashCode;
 import lombok.ToString;
 
+import java.io.Serializable;
 import java.util.Date;
 
 /**
@@ -24,9 +25,8 @@ import java.util.Date;
  **/
 @Data
 @Schema(description = "临床表传输对象")
-@EqualsAndHashCode(callSuper = true)
 @ToString
-public class BusClinicAddDTO extends BaseDTO  {
+public class BusClinicAddDTO implements Serializable {
     private static final long serialVersionUID = 1L;
 
     @Schema(description = "患者唯一标识")

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

@@ -1,6 +1,8 @@
 package cn.tr.module.phototherapy.common.po;
 
 import cn.tr.core.pojo.TenantPO;
+import cn.tr.module.common.entity.TenantGenericEntity;
+import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableLogic;
 import com.baomidou.mybatisplus.annotation.TableName;
@@ -10,6 +12,7 @@ import lombok.Data;
 import lombok.EqualsAndHashCode;
 import lombok.ToString;
 
+import java.io.Serializable;
 import java.time.LocalDateTime;
 import java.util.Date;
 
@@ -23,7 +26,8 @@ import java.util.Date;
 @TableName(value = "bus_clinic", autoResultMap = true)
 @EqualsAndHashCode(callSuper = true)
 @ToString
-public class BusClinicPO extends TenantPO {
+@Schema(description = "临床表")
+public class BusClinicPO extends TenantGenericEntity<String,String> {
 
     /** 主键 */
     @TableId
@@ -67,10 +71,6 @@ public class BusClinicPO extends TenantPO {
     @Schema(description = "设备id")
     private String deviceId;
 
-    /** 医院id */
-    @Schema(description = "医院id")
-    private String tenantId;
-
     /** 删除标志(0代表存在 1代表删除) */
     @TableLogic
     @Schema(description = "删除标志(0代表存在 1代表删除)")

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

@@ -1,6 +1,7 @@
 package cn.tr.module.phototherapy.common.po;
 
 import cn.tr.core.pojo.TenantPO;
+import cn.tr.module.common.entity.TenantGenericEntity;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
 import com.fasterxml.jackson.annotation.JsonFormat;
@@ -21,7 +22,7 @@ import java.time.LocalDateTime;
 @TableName(value = "bus_device_alarm", autoResultMap = true)
 @EqualsAndHashCode(callSuper = true)
 @ToString
-public class BusDeviceAlarmPO extends TenantPO {
+public class BusDeviceAlarmPO extends TenantGenericEntity<String,String> {
 
     /** 主键id */
     @TableId
@@ -53,10 +54,6 @@ public class BusDeviceAlarmPO extends TenantPO {
     @Schema(description = "设备运行状态")
     private Integer runState;
 
-    /** 医院id */
-    @Schema(description = "医院id")
-    private String tenantId;
-
     /** 报警时间 */
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
     @Schema(description = "报警时间")

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

@@ -1,6 +1,7 @@
 package cn.tr.module.phototherapy.common.po;
 
 import cn.tr.core.pojo.TenantPO;
+import cn.tr.module.common.entity.TenantGenericEntity;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableLogic;
 import com.baomidou.mybatisplus.annotation.TableName;
@@ -23,7 +24,7 @@ import java.util.Date;
 @TableName(value = "bus_device_history", autoResultMap = true)
 @EqualsAndHashCode(callSuper = true)
 @ToString
-public class BusDeviceHistoryPO extends TenantPO {
+public class BusDeviceHistoryPO extends TenantGenericEntity<Long,String> {
 
     /** 主键 */
     @TableId
@@ -90,8 +91,4 @@ public class BusDeviceHistoryPO extends TenantPO {
     @Schema(description = "删除标志(0代表存在 1代表删除)")
     private Integer isDelete;
 
-    /** 医院id */
-    @Schema(description = "医院id")
-    private String tenantId;
-
 }

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

@@ -1,6 +1,7 @@
 package cn.tr.module.phototherapy.common.po;
 
 import cn.tr.core.pojo.TenantPO;
+import cn.tr.module.common.entity.TenantGenericEntity;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
 import com.fasterxml.jackson.annotation.JsonFormat;
@@ -21,7 +22,7 @@ import java.time.LocalDateTime;
 @TableName(value = "bus_device", autoResultMap = true)
 @EqualsAndHashCode(callSuper = true)
 @ToString
-public class BusDevicePO extends TenantPO {
+public class BusDevicePO extends TenantGenericEntity<String,String> {
 
     /** 主键id */
     @TableId
@@ -44,9 +45,6 @@ public class BusDevicePO extends TenantPO {
     @Schema(description = "是否启用(0启用 1关闭)")
     private Integer enable;
 
-    /** 医院id */
-    @Schema(description = "医院id")
-    private String tenantId;
 
     /** 删除标志(0代表存在 1代表删除) */
     @Schema(description = "删除标志(0代表存在 1代表删除)")

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

@@ -1,6 +1,7 @@
 package cn.tr.module.phototherapy.common.po;
 
 import cn.tr.core.pojo.TenantPO;
+import cn.tr.module.common.entity.TenantGenericEntity;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
 import io.swagger.v3.oas.annotations.media.Schema;
@@ -19,17 +20,13 @@ import java.math.BigDecimal;
 @TableName(value = "bus_hospital_config", autoResultMap = true)
 @EqualsAndHashCode(callSuper = true)
 @ToString
-public class BusHospitalConfigPO extends TenantPO {
+public class BusHospitalConfigPO extends TenantGenericEntity<String,String> {
 
     /** 主键 */
     @TableId
     @Schema(description = "主键")
     private String id;
 
-    /** 医院id */
-    @Schema(description = "医院id")
-    private String tenantId;
-
     /** 依从性阈值(%) */
     @Schema(description = "依从性阈值(%)")
     private BigDecimal complianceThreshold;

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

@@ -1,6 +1,7 @@
 package cn.tr.module.phototherapy.common.po;
 
 import cn.tr.core.pojo.TenantPO;
+import cn.tr.module.common.entity.TenantGenericEntity;
 import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableLogic;
@@ -20,11 +21,10 @@ import lombok.ToString;
 @TableName(value = "bus_hospital", autoResultMap = true)
 @EqualsAndHashCode(callSuper = true)
 @ToString
-public class BusHospitalPO extends TenantPO {
+public class BusHospitalPO extends TenantGenericEntity<String,String> {
 
     /** 医院名称 */
     @Schema(description = "医院id")
-    @TableId(value = "tenant_id", type = IdType.INPUT)
     private String tenantId;
 
     /** 医院名称 */

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

@@ -1,6 +1,7 @@
 package cn.tr.module.phototherapy.common.po;
 
 import cn.tr.core.pojo.TenantPO;
+import cn.tr.module.common.entity.TenantGenericEntity;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
 import io.swagger.v3.oas.annotations.media.Schema;
@@ -18,7 +19,7 @@ import lombok.ToString;
 @TableName(value = "bus_patient", autoResultMap = true)
 @EqualsAndHashCode(callSuper = true)
 @ToString
-public class BusPatientPO extends TenantPO {
+public class BusPatientPO extends TenantGenericEntity<String,String> {
 
     /** 患者唯一编码 */
     @TableId

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

@@ -3,6 +3,7 @@ package cn.tr.module.phototherapy.common.po;
 import cn.tr.core.pojo.TenantPO;
 import cn.tr.core.validation.Insert;
 import cn.tr.core.validation.Update;
+import cn.tr.module.common.entity.TenantGenericEntity;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableLogic;
 import com.baomidou.mybatisplus.annotation.TableName;
@@ -25,7 +26,7 @@ import java.util.Date;
 @TableName(value = "bus_therapy_plan", autoResultMap = true)
 @EqualsAndHashCode(callSuper = true)
 @ToString
-public class BusTherapyPlanPO extends TenantPO {
+public class BusTherapyPlanPO extends TenantGenericEntity<String,String> {
 
     /** 方案主键 */
     @TableId
@@ -77,10 +78,6 @@ public class BusTherapyPlanPO extends TenantPO {
     @Schema(description = "患者唯一标识")
     private String patientUniqueId;
 
-    /** 医院id */
-    @Schema(description = "医院id")
-    private String tenantId;
-
     /** 逻辑删除(0存在 1删除) */
     @TableLogic
     @Schema(description = "逻辑删除(0存在 1删除)")

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

@@ -1,6 +1,7 @@
 package cn.tr.module.phototherapy.common.po;
 
 import cn.tr.core.pojo.TenantPO;
+import cn.tr.module.common.entity.TenantGenericEntity;
 import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableLogic;
@@ -24,7 +25,7 @@ import java.util.Date;
 @TableName(value = "bus_therapy_record", autoResultMap = true)
 @EqualsAndHashCode(callSuper = true)
 @ToString
-public class BusTherapyRecordPO extends TenantPO {
+public class BusTherapyRecordPO extends TenantGenericEntity<String,String> {
 
     /** 主键id */
     @TableId(type = IdType.ASSIGN_ID)
@@ -73,10 +74,6 @@ public class BusTherapyRecordPO extends TenantPO {
     @Schema(description = "依从性报警(0未显示  1显示)")
     private Integer complianceAlarm;
 
-    /** 医院id */
-    @Schema(description = "医院id")
-    private String tenantId;
-
     /** 删除标志(0存在  1删除) */
     @TableLogic
     @Schema(description = "删除标志(0存在  1删除)")

+ 6 - 0
tr-modules/tr-modules-phototherapy/src/main/java/cn/tr/module/phototherapy/common/service/IBusClinicService.java

@@ -62,5 +62,11 @@ public interface IBusClinicService{
      */
     PatientTherapyDetailVO getPatientTherapyDetailById(String patientUniqueId);
 
+    /**
+     * 新增患者
+     * @param   source 新增实体类
+     * @author CodeGenerator
+     * @date 2026-01-20
+     */
     Boolean insertBusPatient(BusClinicAddDTO source);
 }

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

@@ -120,7 +120,6 @@ public class BusTherapyPlanServiceImpl extends ServiceImpl<BusTherapyPlanReposit
         intensivePlan.setPatientUniqueId(source.getPatientUniqueId());
         intensivePlan.setPlanDoctor(source.getPlanDoctor());
         intensivePlan.setPhaseDay(intensivePhaseDayValue);
-        intensivePlan.setPlanName(source.getPatientName());
         intensivePlan.setPhaseType(source.getIntensivePhaseType());
         intensivePlan.setPhaseStartTime(source.getPhaseStartTime());
         intensivePlan.setPhaseFreq(source.getIntensivePhaseFreq());
@@ -135,7 +134,6 @@ public class BusTherapyPlanServiceImpl extends ServiceImpl<BusTherapyPlanReposit
         continuousPlan.setPatientUniqueId(source.getPatientUniqueId());
         continuousPlan.setPlanDoctor(source.getPlanDoctor());
         continuousPlan.setPhaseDay(continuousPhaseDayValue);
-        continuousPlan.setPlanName(source.getPatientName());
         continuousPlan.setPhaseType(source.getContinuousPhaseType());
 //        continuousPlan.setPhaseStartTime(source.getPhaseStartTime());
         continuousPlan.setPhaseFreq(source.getContinuousPhaseFreq());