发布流程事件

segment2.0
linrf 2 years ago
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);
}
}

@ -1,7 +1,9 @@
package com.docus.server.controller;
import com.docus.server.common.event.FlowEvent;
import com.docus.server.common.service.IFileUploadService;
import com.docus.server.dto.segmentation.UploadBatchFileRequest;
import com.docus.server.service.IPublishEventService;
import com.docus.server.service.impl.CommonService;
import com.docus.server.service.impl.DownloadServiceImpl;
import com.docus.server.vo.scheduling.management.schcollectorversionfile.UploadFileVO;
@ -37,6 +39,8 @@ public class FileController {
private DownloadServiceImpl downloadService;
@Resource
private CommonService commonService;
@Resource
private IPublishEventService iPublishEventService;
@ApiOperation("文件下载")
@GetMapping("/download")
@ -51,10 +55,14 @@ public class FileController {
})
public void uploadFile(@RequestPart("files") MultipartFile[] files, @Validated UploadBatchFileRequest request) throws Exception {
List<UploadFileVO> segmentation = iFileUploadService.uploadFile(files, "segmentation");
//将基础信息存到库表里面,后面自动分段后,需要上传到归档系统
commonService.add(segmentation, request);
iPublishEventService.publishEvent(request.getPatientId(), FlowEvent.FlowTypeEnum.START_SEGMENT);
}
/**
*
*

@ -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…
Cancel
Save