feat(dataflow): 添加WebSocket端点+事件发布点
- WebSocketConfig: 新增 /ws/critical-value 和 /ws/dashboard 端点 - SurgeryAppServiceImpl: addSurgery 保存后发布 SurgeryCompletedEvent (Chain 8) - RadiologyImageAppServiceImpl: submitReport 发布后发布 ExamReportPublishedEvent (Chain 9) - NursingAppServiceImpl: createAssessment 完成后发布 AdmissionAssessmentCompletedEvent (Chain 10)
This commit is contained in:
@@ -10,8 +10,10 @@ import com.healthlink.his.check.service.IDicomPrintRecordService;
|
|||||||
import com.healthlink.his.check.service.IRadiologyImageReportService;
|
import com.healthlink.his.check.service.IRadiologyImageReportService;
|
||||||
import com.healthlink.his.check.service.IRadiologyImageService;
|
import com.healthlink.his.check.service.IRadiologyImageService;
|
||||||
import com.healthlink.his.web.check.appservice.IRadiologyImageAppService;
|
import com.healthlink.his.web.check.appservice.IRadiologyImageAppService;
|
||||||
|
import com.healthlink.his.web.dataflow.event.ExamReportPublishedEvent;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.context.ApplicationEventPublisher;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
@@ -26,6 +28,7 @@ public class RadiologyImageAppServiceImpl implements IRadiologyImageAppService {
|
|||||||
private final IRadiologyImageService imageService;
|
private final IRadiologyImageService imageService;
|
||||||
private final IRadiologyImageReportService reportService;
|
private final IRadiologyImageReportService reportService;
|
||||||
private final IDicomPrintRecordService printService;
|
private final IDicomPrintRecordService printService;
|
||||||
|
private final ApplicationEventPublisher eventPublisher;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
@@ -84,6 +87,12 @@ public class RadiologyImageAppServiceImpl implements IRadiologyImageAppService {
|
|||||||
r.setStatus("REPORTED");
|
r.setStatus("REPORTED");
|
||||||
r.setReportTime(new Date());
|
r.setReportTime(new Date());
|
||||||
reportService.updateById(r);
|
reportService.updateById(r);
|
||||||
|
|
||||||
|
// Chain 9: 检查报告发布后发布事件
|
||||||
|
eventPublisher.publishEvent(new ExamReportPublishedEvent(this,
|
||||||
|
r.getEncounterId(), r.getPatientId(),
|
||||||
|
r.getId(), r.getExamName(), r.getImpression()));
|
||||||
|
|
||||||
return R.ok();
|
return R.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -42,7 +42,9 @@ import com.healthlink.his.workflow.domain.ServiceRequest;
|
|||||||
import com.healthlink.his.workflow.domain.ActivityDefinition;
|
import com.healthlink.his.workflow.domain.ActivityDefinition;
|
||||||
import com.healthlink.his.workflow.service.IActivityDefinitionService;
|
import com.healthlink.his.workflow.service.IActivityDefinitionService;
|
||||||
import com.healthlink.his.workflow.service.IServiceRequestService;
|
import com.healthlink.his.workflow.service.IServiceRequestService;
|
||||||
|
import com.healthlink.his.web.dataflow.event.SurgeryCompletedEvent;
|
||||||
import org.springframework.beans.BeanUtils;
|
import org.springframework.beans.BeanUtils;
|
||||||
|
import org.springframework.context.ApplicationEventPublisher;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
@@ -99,6 +101,9 @@ public class SurgeryAppServiceImpl implements ISurgeryAppService {
|
|||||||
@Resource
|
@Resource
|
||||||
private RedisCache redisCache;
|
private RedisCache redisCache;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private ApplicationEventPublisher eventPublisher;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param surgeryDto 查询条件
|
* @param surgeryDto 查询条件
|
||||||
@@ -433,6 +438,11 @@ public class SurgeryAppServiceImpl implements ISurgeryAppService {
|
|||||||
// 清除相关缓存
|
// 清除相关缓存
|
||||||
clearSurgeryAppCache(surgery);
|
clearSurgeryAppCache(surgery);
|
||||||
|
|
||||||
|
// Chain 8: 手术保存后发布事件
|
||||||
|
eventPublisher.publishEvent(new SurgeryCompletedEvent(this,
|
||||||
|
surgeryDto.getEncounterId(), surgeryDto.getPatientId(),
|
||||||
|
surgeryId, surgeryDto.getSurgeryName()));
|
||||||
|
|
||||||
return R.ok(surgeryId, "手术申请提交成功!");
|
return R.ok(surgeryId, "手术申请提交成功!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -94,4 +94,56 @@ public class WebSocketConfig {
|
|||||||
log.error("WebSocket error: {}", session.getId(), error);
|
log.error("WebSocket error: {}", session.getId(), error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ServerEndpoint("/ws/critical-value")
|
||||||
|
@Slf4j
|
||||||
|
public static class CriticalValueEndpoint {
|
||||||
|
private static final java.util.Set<String> connectedSessions = java.util.concurrent.ConcurrentHashMap.newKeySet();
|
||||||
|
|
||||||
|
@OnOpen
|
||||||
|
public void onOpen(Session session) {
|
||||||
|
connectedSessions.add(session.getId());
|
||||||
|
log.info("CriticalValue WebSocket connected: {}, total={}", session.getId(), connectedSessions.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
@OnClose
|
||||||
|
public void onClose(Session session) {
|
||||||
|
connectedSessions.remove(session.getId());
|
||||||
|
log.info("CriticalValue WebSocket disconnected: {}, total={}", session.getId(), connectedSessions.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
@OnError
|
||||||
|
public void onError(Session session, Throwable error) {
|
||||||
|
log.error("CriticalValue WebSocket error: {}", session.getId(), error);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void broadcast(String message) {
|
||||||
|
for (String sessionId : connectedSessions) {
|
||||||
|
// broadcast to all connected sessions
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@ServerEndpoint("/ws/dashboard")
|
||||||
|
@Slf4j
|
||||||
|
public static class DashboardEndpoint {
|
||||||
|
private static final java.util.Set<String> connectedSessions = java.util.concurrent.ConcurrentHashMap.newKeySet();
|
||||||
|
|
||||||
|
@OnOpen
|
||||||
|
public void onOpen(Session session) {
|
||||||
|
connectedSessions.add(session.getId());
|
||||||
|
log.info("Dashboard WebSocket connected: {}, total={}", session.getId(), connectedSessions.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
@OnClose
|
||||||
|
public void onClose(Session session) {
|
||||||
|
connectedSessions.remove(session.getId());
|
||||||
|
log.info("Dashboard WebSocket disconnected: {}, total={}", session.getId(), connectedSessions.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
@OnError
|
||||||
|
public void onError(Session session, Throwable error) {
|
||||||
|
log.error("Dashboard WebSocket error: {}", session.getId(), error);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,8 +2,10 @@ package com.healthlink.his.web.nursing.appservice.impl;
|
|||||||
import com.healthlink.his.nursing.domain.*;
|
import com.healthlink.his.nursing.domain.*;
|
||||||
import com.healthlink.his.nursing.service.*;
|
import com.healthlink.his.nursing.service.*;
|
||||||
import com.healthlink.his.web.nursing.appservice.INursingAppService;
|
import com.healthlink.his.web.nursing.appservice.INursingAppService;
|
||||||
|
import com.healthlink.his.web.dataflow.event.AdmissionAssessmentCompletedEvent;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.context.ApplicationEventPublisher;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@Service
|
@Service
|
||||||
@@ -11,12 +13,19 @@ public class NursingAppServiceImpl implements INursingAppService {
|
|||||||
@Autowired private INursingAssessmentService assessmentService;
|
@Autowired private INursingAssessmentService assessmentService;
|
||||||
@Autowired private INursingCarePlanService carePlanService;
|
@Autowired private INursingCarePlanService carePlanService;
|
||||||
@Autowired private INursingHandoffService handoffService;
|
@Autowired private INursingHandoffService handoffService;
|
||||||
|
@Autowired private ApplicationEventPublisher eventPublisher;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NursingAssessment createAssessment(NursingAssessment a) {
|
public NursingAssessment createAssessment(NursingAssessment a) {
|
||||||
a.setRiskLevel(calculateRiskLevel(a));
|
a.setRiskLevel(calculateRiskLevel(a));
|
||||||
a.setDeleteFlag("0");
|
a.setDeleteFlag("0");
|
||||||
assessmentService.save(a);
|
assessmentService.save(a);
|
||||||
|
|
||||||
|
// Chain 10: 入院评估完成后发布事件
|
||||||
|
eventPublisher.publishEvent(new AdmissionAssessmentCompletedEvent(this,
|
||||||
|
a.getEncounterId(), a.getPatientId(),
|
||||||
|
a.getId(), a.getRiskLevel()));
|
||||||
|
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user