Bläddra i källkod

add
研究队列手术问卷历史记录

lifang 2 månader sedan
förälder
incheckning
a33b69cfeb

+ 34 - 0
tr-modules/tr-module-smartFollowUp/src/main/java/cn/tr/module/smart/common/config/RabbitMQConfig.java

@@ -72,4 +72,38 @@ public class RabbitMQConfig {
                 .with(RabbitMQConstant.ROUTING_KEY_MP_PUSH)
                 .noargs();
     }
+
+
+    /***************************研究队列推送配置***************************/
+
+    /**
+     * 创建延迟消息交换机
+     * @return TopicExchange 交换机实例
+     */
+    @Bean
+    public CustomExchange reasearchExchange() {
+        Map<String, Object> args = new HashMap<>();
+        args.put("x-delayed-type", "topic");
+        return new CustomExchange(RabbitMQConstant.TOPIC_EXCHANGE_REASEARCH_NAME, "x-delayed-message", true, false, args);
+    }
+    /**
+     * 创建服务号推送队列
+     * @return Queue 队列实例
+     */
+    @Bean
+    public Queue reasearchQueue() {
+        // 设置队列不持久化,并且在没有消费者时自动删除
+        return new Queue(RabbitMQConstant.QUEUE_REASEARCH_PUSH, Boolean.FALSE, false, Boolean.TRUE);
+    }
+    /**
+     * 绑定服务号推送队列到主题交换机
+     * @return Queue 队列实例
+     */
+    @Bean
+    public Binding reasearchBinding() {
+        return BindingBuilder.bind(mpPushQueue())
+                .to(mpDelayExchange())
+                .with(RabbitMQConstant.ROUTING_KEY_REASEARCH_PUSH)
+                .noargs();
+    }
 }

+ 18 - 0
tr-modules/tr-module-smartFollowUp/src/main/java/cn/tr/module/smart/common/config/handler/JsonbLongListTypeHandler.java

@@ -0,0 +1,18 @@
+package cn.tr.module.smart.common.config.handler;
+
+import cn.tr.module.smart.common.entity.BizReasearchPushPointEntity;
+import cn.tr.plugin.mybatis.config.handler.JsonbTypeHandler;
+import org.apache.ibatis.type.JdbcType;
+import org.apache.ibatis.type.MappedJdbcTypes;
+import org.apache.ibatis.type.MappedTypes;
+
+import java.util.List;
+
+@MappedJdbcTypes(JdbcType.OTHER)
+@MappedTypes(List.class)
+public class JsonbLongListTypeHandler extends JsonbTypeHandler {
+
+    public JsonbLongListTypeHandler() {
+        super(Long.class);
+    }
+}

+ 41 - 0
tr-modules/tr-module-smartFollowUp/src/main/java/cn/tr/module/smart/common/controller/vo/BizReasearchQueuePushVO.java

@@ -0,0 +1,41 @@
+package cn.tr.module.smart.common.controller.vo;
+
+import cn.tr.module.smart.common.entity.BizReasearchPushPointEntity;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.ToString;
+
+import java.io.Serializable;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * 研究队列实体
+ *
+ * @author lf
+ * @date  2025/10/14 17:18
+ **/
+@Data
+@ToString
+public class BizReasearchQueuePushVO implements Serializable {
+
+    /** id */
+    @ApiModelProperty(value = "id", position = 1)
+    private String id;
+
+    private String clinicRoomId;
+
+    /** 队列状态 */
+    @ApiModelProperty(value = "队列状态", position = 4)
+    private String status;
+
+    /** 推送时间点格式化 */
+    @ApiModelProperty(value = "推送时间点格式化", position = 6)
+    private  List<Long> timePointsFormat;
+
+    /** 上次的推送时间间隔 */
+    private Integer lastPushInterval;
+
+    /** 手术结束时间 */
+    private Date clinicEndTime;
+}

+ 7 - 0
tr-modules/tr-module-smartFollowUp/src/main/java/cn/tr/module/smart/common/enums/RabbitMQConstant.java

@@ -15,4 +15,11 @@ public interface RabbitMQConstant {
     String ROUTING_KEY_MP_PUSH = "patient.mp.push";
 
     String QUEUE_MP_PUSH = "patient.mp.push";
+
+    //研究队列
+    String TOPIC_EXCHANGE_REASEARCH_NAME = "reasearch.exchange";
+
+    String ROUTING_KEY_REASEARCH_PUSH = "reasearch.queue.push";
+
+    String QUEUE_REASEARCH_PUSH = "reasearch.queue.push";
 }

+ 2 - 1
tr-modules/tr-module-smartFollowUp/src/main/java/cn/tr/module/smart/common/po/BizReasearchQueuePO.java

@@ -1,5 +1,6 @@
 package cn.tr.module.smart.common.po;
 
+import cn.tr.module.smart.common.config.handler.JsonbLongListTypeHandler;
 import cn.tr.module.smart.common.config.handler.JsonbReasearchPushPointListTypeHandler;
 import cn.tr.module.smart.common.entity.BizReasearchPushPointEntity;
 import cn.tr.plugin.mybatis.config.handler.JsonbTypeHandler;
@@ -48,7 +49,7 @@ public class BizReasearchQueuePO extends TenantPO {
 
     /** 推送时间点格式化 */
     @ApiModelProperty(value = "推送时间点格式化", position = 6)
-    @TableField(typeHandler = JsonbTypeHandler.class)
+    @TableField(typeHandler = JsonbLongListTypeHandler.class)
     private  List<Long> timePointsFormat;
 
     @ApiModelProperty(value = "将推送时间点转为字符串展示",position = 7)

+ 3 - 0
tr-modules/tr-module-smartFollowUp/src/main/java/cn/tr/module/smart/common/repository/BizReasearchQueueClinicRepository.java

@@ -1,6 +1,7 @@
 package cn.tr.module.smart.common.repository;
 
 import cn.tr.module.smart.common.controller.vo.BizReasearchQueueClinicVO;
+import cn.tr.module.smart.common.controller.vo.BizReasearchQueuePushVO;
 import cn.tr.module.smart.common.controller.vo.BizReasearchQueueQuestionAnswerVO;
 import cn.tr.module.smart.common.dto.BizReasearchQueueClinicQueryDTO;
 import cn.tr.module.smart.common.dto.BizReasearchQueueClinicQuestionAnswerRecordQueryDTO;
@@ -22,4 +23,6 @@ import java.util.List;
 @Mapper
 public interface BizReasearchQueueClinicRepository extends BaseMapper<BizReasearchQueueClinicPO> {
     List<BizReasearchQueueClinicVO> stdSelectBizReasearchQueueClinicList(@Param("query") BizReasearchQueueClinicQueryDTO query);
+
+    BizReasearchQueuePushVO stdSelectBizReasearchQueueClinicById(@Param("id") String id);
 }

+ 7 - 0
tr-modules/tr-module-smartFollowUp/src/main/java/cn/tr/module/smart/common/service/IBizReasearchQueueClinicService.java

@@ -5,6 +5,7 @@ import cn.tr.module.smart.common.controller.vo.BizReasearchQueueQuestionAnswerVO
 import cn.tr.module.smart.common.dto.BizReasearchQueueAddClinicDTO;
 import cn.tr.module.smart.common.dto.BizReasearchQueueClinicQueryDTO;
 import cn.tr.module.smart.common.dto.BizReasearchQueueClinicQuestionAnswerRecordQueryDTO;
+import cn.tr.module.smart.common.po.BizReasearchQueueClinicPO;
 
 import java.util.*;
 
@@ -41,4 +42,10 @@ public interface IBizReasearchQueueClinicService{
     Integer removeBizReasearchQueueClinicByIds(Collection<String> ids);
 
     List<BizReasearchQueueQuestionAnswerVO> stdSelectQuestionAnswerList(BizReasearchQueueClinicQuestionAnswerRecordQueryDTO query);
+
+    /**
+     * 向用户推送研究队列的消息
+     * @param id
+     */
+    void pushReasearchQueueQuestion(String id);
 }

+ 22 - 2
tr-modules/tr-module-smartFollowUp/src/main/java/cn/tr/module/smart/common/service/impl/BizReasearchQueueClinicServiceImpl.java

@@ -1,13 +1,19 @@
 package cn.tr.module.smart.common.service.impl;
 
+import cn.hutool.core.util.ObjectUtil;
+import cn.hutool.core.util.StrUtil;
+import cn.tr.core.annotation.TenantIgnore;
 import cn.tr.core.exception.TRExcCode;
 import cn.tr.module.smart.common.controller.vo.BizReasearchQueueClinicVO;
+import cn.tr.module.smart.common.controller.vo.BizReasearchQueuePushVO;
 import cn.tr.module.smart.common.controller.vo.BizReasearchQueueQuestionAnswerVO;
 import cn.tr.module.smart.common.dto.BizReasearchQueueAddClinicDTO;
 import cn.tr.module.smart.common.dto.BizReasearchQueueClinicQuestionAnswerRecordQueryDTO;
 import cn.tr.module.smart.common.mapper.BizQuestionAnswerMapper;
 import cn.tr.module.smart.common.po.BizQuestionAnswerPO;
+import cn.tr.module.smart.common.po.BizReasearchQueuePO;
 import cn.tr.module.smart.common.repository.BizQuestionAnswerRepository;
+import cn.tr.module.smart.common.repository.BizReasearchQueueRepository;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -32,7 +38,8 @@ import cn.tr.module.smart.common.service.IBizReasearchQueueClinicService;
 public class BizReasearchQueueClinicServiceImpl extends ServiceImpl<BizReasearchQueueClinicRepository,BizReasearchQueueClinicPO> implements IBizReasearchQueueClinicService {
     @Autowired
     private BizQuestionAnswerRepository questionAnswerRepository;
-
+    @Autowired
+    private BizReasearchQueueRepository reasearchQueueRepository;
 
     /**
      * 根据条件查询队列-临床手术关联表
@@ -103,5 +110,18 @@ public class BizReasearchQueueClinicServiceImpl extends ServiceImpl<BizReasearch
                 .orderByDesc(BizQuestionAnswerPO::getAnswerTime)));
     }
 
-    ;
+    @Override
+    @TenantIgnore
+    public void pushReasearchQueueQuestion(String id){
+        if(StrUtil.isBlank(id)){
+            return;
+        }
+        BizReasearchQueuePushVO reasearchQueuePushVO=this.baseMapper.stdSelectBizReasearchQueueClinicById(id);
+        if(ObjectUtil.isNull(reasearchQueuePushVO)){
+            return;
+        }
+        //先判断当前时间与手术结束时间的时间间隔是否满足研究队列的最小时间间隔要求
+
+
+    }
 }

+ 10 - 0
tr-modules/tr-module-smartFollowUp/src/main/resources/mapper/smart/BizReasearchQueueClinicMapper.xml

@@ -27,6 +27,14 @@
         <result property="answerTime" column="answer_time" />
     </resultMap>
 
+    <resultMap id="stdPushResult" type="cn.tr.module.smart.common.controller.vo.BizReasearchQueuePushVO">
+        <result property="id" column="id" />
+        <result property="clinicRoomId" column="clinic_room_id" />
+        <result property="status" column="status" />
+        <result property="timePointsFormat" column="time_points_format" typeHandler="cn.tr.module.smart.common.config.handler.JsonbLongListTypeHandler"/>
+        <result property="lastPushInterval" column="last_push_interval"/>
+        <result property="clinicEndTime" column="clinic_end_time"/>
+    </resultMap>
 
     <select id="stdSelectBizReasearchQueueClinicList" resultMap="stdResult">
         SELECT
@@ -51,4 +59,6 @@
         where brqc.queue_id = #{query.queueId}
         order by brqc.create_time desc
     </select>
+
+
 </mapper>