调整注册服务

This commit is contained in:
1378012178@qq.com 2025-04-22 17:11:05 +08:00
parent 5d5956f44d
commit af7b492bf8
6 changed files with 157 additions and 0 deletions

View File

@ -35,6 +35,12 @@
<artifactId>nursing-unit-api</artifactId> <artifactId>nursing-unit-api</artifactId>
<version>${nursingunit.version}</version> <version>${nursingunit.version}</version>
</dependency> </dependency>
<!-- COMMON 通用工具模块 -->
<dependency>
<groupId>com.nursingunit.boot</groupId>
<artifactId>nursing-unit-common</artifactId>
<version>${nursingunit.version}</version>
</dependency>
</dependencies> </dependencies>
</project> </project>

View File

@ -0,0 +1,35 @@
package com.nu.mq.directive.exceptionhandler;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.AmqpRejectAndDontRequeueException;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.listener.api.RabbitListenerErrorHandler;
import org.springframework.amqp.rabbit.support.ListenerExecutionFailedException;
import org.springframework.stereotype.Component;
@Slf4j
@Component("AdvisoryMQExceptionHandler")
public class AdvisoryMQExceptionHandler implements RabbitListenerErrorHandler {
@Override
public Object handleError(Message message, org.springframework.messaging.Message<?> message1, ListenerExecutionFailedException e) {
log.error("MQ消息处理失败 | 消息体: {} | 异常原因: {}", new String(message.getBody()), e.getCause().getMessage());
// 根据异常类型选择处理策略
if (isRetryable(e)) {
// 可重试异常抛出异常触发重试
throw e;
} else {
// 不可恢复异常拒绝消息且不重新入队
throw new AmqpRejectAndDontRequeueException("消息处理失败且禁止重试", e);
}
}
/**
* 判断异常是否可重试
*/
private boolean isRetryable(ListenerExecutionFailedException e) {
// 示例网络异常数据库临时锁超时可重试
return e.getCause() instanceof RuntimeException; // 根据实际业务调整
}
}

View File

@ -0,0 +1,28 @@
package com.nu.mq.NuBizAdvisoryInfo.listener;
import com.nu.dto.NuBizAdvisoryInfoDto;
import com.nu.modules.NuBizAdvisoryInfo.entity.NuBizAdvisoryInfo;
import com.nu.modules.NuBizAdvisoryInfo.service.INuBizAdvisoryInfoService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Slf4j
@Component
public class NuBizAdvisoryInfoListener {
@Autowired
private INuBizAdvisoryInfoService nuBizAdvisoryInfoService;
@RabbitListener(queues = "register.addData", errorHandler = "AdvisoryMQExceptionHandler")
public void handleMessage(NuBizAdvisoryInfoDto dto) {
try {
System.out.println(111);
NuBizAdvisoryInfo nuBizAdvisoryInfo = new NuBizAdvisoryInfo();
BeanUtils.copyProperties(dto,nuBizAdvisoryInfo);
nuBizAdvisoryInfoService.save(nuBizAdvisoryInfo);
} catch (Exception e) {
System.out.println("异常了:" + e.getMessage());
}
}
}

View File

@ -49,6 +49,7 @@ public class RabbitMQConfig {
public Queue nu002FwzlStatusQueue() { public Queue nu002FwzlStatusQueue() {
return new Queue("nu002.fwzl.status", true); return new Queue("nu002.fwzl.status", true);
} }
@Bean @Bean
public Binding binding1(Queue nu001FwzlAsyncQueue, DirectExchange fwzlExchange) { public Binding binding1(Queue nu001FwzlAsyncQueue, DirectExchange fwzlExchange) {
return BindingBuilder.bind(nu001FwzlAsyncQueue).to(fwzlExchange).with("nu001.fwzl.async"); return BindingBuilder.bind(nu001FwzlAsyncQueue).to(fwzlExchange).with("nu001.fwzl.async");
@ -65,4 +66,20 @@ public class RabbitMQConfig {
public Binding binding4(Queue nu002FwzlStatusQueue, DirectExchange fwzlExchange) { public Binding binding4(Queue nu002FwzlStatusQueue, DirectExchange fwzlExchange) {
return BindingBuilder.bind(nu002FwzlStatusQueue).to(fwzlExchange).with("nu002.fwzl.status"); return BindingBuilder.bind(nu002FwzlStatusQueue).to(fwzlExchange).with("nu002.fwzl.status");
} }
//注册
@Bean
public DirectExchange registerExchange() {
return new DirectExchange("hldy.register");
}
@Bean
public Queue registerAddQueue() {
return new Queue("register.addData", true);
}
@Bean
public Binding binding5(Queue registerAddQueue, DirectExchange registerExchange) {
return BindingBuilder.bind(registerAddQueue).to(registerExchange).with("register.addData");
}
} }

View File

@ -0,0 +1,68 @@
package com.nu.dto;
import lombok.Data;
import java.io.Serializable;
/**
* @Description: 咨询信息
* @Author: jeecg-boot
* @Date: 2025-04-07
* @Version: V1.0
*/
@Data
public class NuBizAdvisoryInfoDto implements Serializable {
private static final long serialVersionUID = 1L;
/**id*/
private String id;
/**微信id*/
private String openId;
/**微信名称*/
private String wechatName;
/**咨询人姓名*/
private String name;
/**性别*/
private String sex;
/**联系电话*/
private String tel;
/**咨询类型 1入住nu 2入驻机构 3我要加盟*/
private String advisoryType;
/**状态 1审核中 2审核完成 3驳回*/
private String status;
/**审核备注*/
private String content;
/**机构访问地址*/
private String serverUrl;
/**创建人*/
private String createBy;
/**创建日期*/
private java.util.Date createTime;
/**更新人*/
private String updateBy;
/**更新日期*/
private java.util.Date updateTime;
/**所属部门*/
private String sysOrgCode;
/**老人姓名*/
private String oldManName;
/**老人年龄*/
private String oldManAge;
/**医保类型*/
private String medicalInsuranceType;
/**老人性别*/
private String oldManSex;
/**报销类型*/
private String reimbType;
/**护理单元*/
private String nuId;
private String advisoryTypeName;
private String sexName;
private String sysOrgCodeName;
private String statusName;
private String oldManSexName;
private String medicalInsuranceTypeName;
private String reimbTypeName;
}

View File

@ -109,6 +109,9 @@ public class ConfigServiceDirectiveController extends JeecgController<ConfigServ
*/ */
@PostMapping("/async") @PostMapping("/async")
public Result<String> async(@RequestBody DirectiveMQDto dto) { public Result<String> async(@RequestBody DirectiveMQDto dto) {
//TODO 源数据的服务指令更新了 不处理 到日子后只能增量
//TODO 服务指令相关的字典服务类别类型等需要加个是否已被同步标识
//TODO 前台选择机构后刷新数据应该有个更新中的效果
List<DictModel> dicts = sysBaseAPI.getDictItems("mq_org_queue"); List<DictModel> dicts = sysBaseAPI.getDictItems("mq_org_queue");
String queue = dicts.stream().filter(d -> d.getValue().equals(dto.getOrgCode())).findFirst().map(DictModel::getText).orElse(null); String queue = dicts.stream().filter(d -> d.getValue().equals(dto.getOrgCode())).findFirst().map(DictModel::getText).orElse(null);
if (StringUtils.isNotBlank(queue)) { if (StringUtils.isNotBlank(queue)) {