发布流程事件
parent
a6ee50800f
commit
d5a7d6da61
@ -1,68 +0,0 @@
|
||||
package com.docus.server.common;
|
||||
|
||||
public class MsgConstants {
|
||||
|
||||
/**
|
||||
* 客户端与采集调度器心跳
|
||||
*/
|
||||
public static final String HEARTBEAT_REQUEST = "0";
|
||||
|
||||
/**
|
||||
* 客户端上线注册
|
||||
*/
|
||||
public static final String ONLINE_REGISTER = "1";
|
||||
|
||||
/**
|
||||
* 客户端下线移除
|
||||
*/
|
||||
public static final String OFFLINE_REMOVE = "2";
|
||||
|
||||
/**
|
||||
* 客户端异常注册
|
||||
*/
|
||||
public static final String EXCEPTION_REMOVE = "3";
|
||||
|
||||
/**
|
||||
* 终端重启命令
|
||||
*/
|
||||
public static final String TERMINATOR_RESTART = "4";
|
||||
|
||||
/**
|
||||
* 采集器重启命令
|
||||
*/
|
||||
public static final String COLLECTOR_RESTART = "5";
|
||||
|
||||
/**
|
||||
* 虚拟机重启命令
|
||||
*/
|
||||
public static final String VIRTUAL_RESTART = "6";
|
||||
|
||||
/**
|
||||
* 更新采集器文件命令
|
||||
*/
|
||||
public static final String UPDATE_COLLECTOR_FILE = "7";
|
||||
|
||||
/**
|
||||
* 更新采集器配置命令
|
||||
*/
|
||||
public static final String UPDATE_COLLECTOR_CONFIG = "8";
|
||||
|
||||
/**
|
||||
* 采集调度器下发任务命令
|
||||
*/
|
||||
public static final String SCH_DISTRIBUTE_TASKS = "9";
|
||||
/**
|
||||
* 接收采集器上报的任务
|
||||
*/
|
||||
public static final String REV_COLLECTOR_TASK = "10";
|
||||
|
||||
/**
|
||||
* 是否有可用类型的采集器命令
|
||||
*/
|
||||
public static final String HAS_VALID_COLLECTOR = "11";
|
||||
|
||||
/**
|
||||
* 获取终端采集器数据量命令
|
||||
*/
|
||||
public static final String HAS_COLLECTOR_COUNT = "12";
|
||||
}
|
@ -0,0 +1,54 @@
|
||||
package com.docus.server.common.event;
|
||||
|
||||
import com.docus.infrastructure.core.db.enums.IIntegerEnum;
|
||||
import lombok.Getter;
|
||||
import org.springframework.context.ApplicationEvent;
|
||||
|
||||
/**
|
||||
* 流程事件
|
||||
*/
|
||||
@Getter
|
||||
public class FlowEvent extends ApplicationEvent {
|
||||
/**
|
||||
* 业务系统病案主键
|
||||
*/
|
||||
private final String patientId;
|
||||
/**
|
||||
* 自动分段流程类型
|
||||
*/
|
||||
private final FlowTypeEnum flowTypeEnum;
|
||||
|
||||
public FlowEvent(Object source, String patientId, FlowTypeEnum flowTypeEnum) {
|
||||
super(source);
|
||||
this.patientId = patientId;
|
||||
this.flowTypeEnum = flowTypeEnum;
|
||||
}
|
||||
|
||||
|
||||
public enum FlowTypeEnum implements IIntegerEnum {
|
||||
//
|
||||
START_SEGMENT(1, "开始分段事件"),
|
||||
START_OCR(2, "开始OCR事件"),
|
||||
START_UPLOAD(3, "开始上传归档系统事件");
|
||||
|
||||
|
||||
private Integer value;
|
||||
private String display;
|
||||
|
||||
FlowTypeEnum(Integer value, String display) {
|
||||
this.value = value;
|
||||
this.display = display;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getValue() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplay() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,62 @@
|
||||
package com.docus.server.common.event;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.context.event.EventListener;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
@Slf4j
|
||||
public class FlowEventListener {
|
||||
|
||||
@EventListener
|
||||
@Async("threadPoolExecutor")
|
||||
public void flowListen(FlowEvent fileEvent) {
|
||||
|
||||
String patientId = fileEvent.getPatientId();
|
||||
|
||||
FlowEvent.FlowTypeEnum flowTypeEnum = fileEvent.getFlowTypeEnum();
|
||||
|
||||
switch (flowTypeEnum) {
|
||||
case START_SEGMENT:
|
||||
startSegment(patientId);
|
||||
break;
|
||||
case START_OCR:
|
||||
startOcr(patientId);
|
||||
break;
|
||||
case START_UPLOAD:
|
||||
startUpload(patientId);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 开始上传归档系统
|
||||
*
|
||||
* @param patientId
|
||||
*/
|
||||
private void startUpload(String patientId) {
|
||||
System.out.println(patientId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 开始进行ocr识别
|
||||
*
|
||||
* @param patientId
|
||||
*/
|
||||
private void startOcr(String patientId) {
|
||||
System.out.println(patientId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 开始分段
|
||||
*
|
||||
* @param patientId
|
||||
*/
|
||||
private void startSegment(String patientId) {
|
||||
System.out.println(patientId);
|
||||
}
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
package com.docus.server.service;
|
||||
|
||||
import com.docus.server.common.event.FlowEvent;
|
||||
|
||||
public interface IPublishEventService {
|
||||
void publishEvent(String patientId, FlowEvent.FlowTypeEnum flowTypeEnum);
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
package com.docus.server.service.impl;
|
||||
|
||||
import com.docus.server.common.event.FlowEvent;
|
||||
import com.docus.server.service.IPublishEventService;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
@Service
|
||||
public class PublishEventService implements IPublishEventService {
|
||||
|
||||
@Resource
|
||||
private ApplicationContext applicationContext;
|
||||
|
||||
/**
|
||||
* 发布事件
|
||||
*/
|
||||
@Override
|
||||
public void publishEvent(String patientId, FlowEvent.FlowTypeEnum flowTypeEnum) {
|
||||
applicationContext.publishEvent(new FlowEvent(this, patientId, flowTypeEnum));
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue