Browse Source

add
自动发送数据

lifang 1 month ago
parent
commit
80c4f00859

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

@@ -107,7 +107,7 @@ public class BizReasearchQueueClinicServiceImpl extends ServiceImpl<BizReasearch
         insertBatch.parallelStream().forEach(queueClinicPO -> {
             rabbitTemplate.convertAndSend(
                     RabbitMQConstant.TOPIC_EXCHANGE_MP_NAME,
-                    RabbitMQConstant.ROUTING_KEY_MP_PUSH,
+                    RabbitMQConstant.QUEUE_REASEARCH_PUSH,
                     queueClinicPO.getId(),
                     message -> {
                         message.getMessageProperties().getHeaders().put("x-delay", 3);
@@ -235,10 +235,11 @@ public class BizReasearchQueueClinicServiceImpl extends ServiceImpl<BizReasearch
 
     //执行推送逻辑
     private void sendMessage(BizReasearchQueuePushVO source,long nextPushInterval){
-        String sql =String.format("last_push_interval = %d  and push_count = push_count + 1 and last_push_time = %s",nextPushInterval,DateUtil.now());
-        baseMapper.update(null,new LambdaUpdateWrapper<BizReasearchQueueClinicPO>()
-                .eq(BizReasearchQueueClinicPO::getId,source.getId())
-                .setSql(sql));
+        baseMapper.update(null, new LambdaUpdateWrapper<BizReasearchQueueClinicPO>()
+                .eq(BizReasearchQueueClinicPO::getId, source.getId())
+                .set(BizReasearchQueueClinicPO::getLastPushInterval, nextPushInterval)
+                .setSql("push_count = push_count + 1")
+                .set(BizReasearchQueueClinicPO::getLastPushTime, new Date()));
         try {
             BizMpPublishInfoDTO publishInfo = baseMapper.selectPushInfo(source.getId());
             wxTemplateSendHelper.sendMsg(publishInfo, MpPublishTaskTypeEnums.AFTER_QUESTION.getType());
@@ -257,8 +258,7 @@ public class BizReasearchQueueClinicServiceImpl extends ServiceImpl<BizReasearch
                 RabbitMQConstant.QUEUE_REASEARCH_PUSH,
                 id,
                 message -> {
-//                    message.getMessageProperties().getHeaders().put("x-delay", delayTime);
-                    message.getMessageProperties().getHeaders().put("x-delay", 3);
+                    message.getMessageProperties().getHeaders().put("x-delay", delayTime);
                     return message;
                 }
         );

+ 18 - 0
tr-plugins/tr-spring-boot-starter-plugin-mybatis/src/main/java/cn/tr/plugin/mybatis/config/handler/JsonbTypeHandler.java

@@ -15,6 +15,7 @@ import java.sql.CallableStatement;
 import java.sql.PreparedStatement;
 import java.sql.ResultSet;
 import java.sql.SQLException;
+import java.util.List;
 
 @MappedJdbcTypes(JdbcType.OTHER)
 @MappedTypes(Object.class)
@@ -62,6 +63,22 @@ public class JsonbTypeHandler extends BaseTypeHandler<Object> {
             return null;
         }
         try {
+            // 判断是否为数组格式
+            if (json.trim().startsWith("[") && json.trim().endsWith("]")) {
+                // 如果是数组,且 aClass 是 List 的子类,则解析为 List
+                if (aClass != null && List.class.isAssignableFrom(aClass)) {
+                    TypeFactory typeFactory = mapper.getTypeFactory();
+                    ParameterizedType parameterizedType = (ParameterizedType) aClass.getGenericSuperclass();
+                    if (parameterizedType != null) {
+                        Class<?> componentType = (Class<?>) parameterizedType.getActualTypeArguments()[0];
+                        return mapper.readValue(json, mapper.getTypeFactory().constructCollectionType(List.class, componentType));
+                    }
+                }
+                // 默认解析为 List<Object>
+                return mapper.readValue(json, mapper.getTypeFactory().constructCollectionType(List.class, Object.class));
+            }
+
+            // 非数组,按原逻辑处理
             if (aClass != null) {
                 return mapper.readValue(json, aClass);
             }
@@ -70,4 +87,5 @@ public class JsonbTypeHandler extends BaseTypeHandler<Object> {
             throw new SQLException("Error parsing JSONB string: " + json, e);
         }
     }
+
 }