拆分事件和ocr前缀
parent
b012279858
commit
a96cabe0af
@ -1,72 +1,26 @@
|
||||
package com.docus.server.common.event;
|
||||
|
||||
import com.docus.server.api.ocr.OcrApi;
|
||||
import com.docus.server.service.impl.PlatformServiceImpl;
|
||||
import com.docus.log.executor.TrackRetrySpringExecutor;
|
||||
import com.docus.log.handler.IJobHandler;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.context.event.EventListener;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
@Component
|
||||
@Slf4j
|
||||
public class FlowEventListener {
|
||||
@Resource
|
||||
private OcrApi ocrApi;
|
||||
@Resource
|
||||
private PlatformServiceImpl downloadService;
|
||||
|
||||
@EventListener
|
||||
@Async("threadPoolExecutor")
|
||||
public void flowListen(FlowEvent fileEvent) {
|
||||
|
||||
String patientId = fileEvent.getPatientId();
|
||||
public void flowListen(FlowEvent fileEvent) throws Exception {
|
||||
|
||||
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;
|
||||
}
|
||||
IJobHandler jobHandler = TrackRetrySpringExecutor.loadJobHandler(flowTypeEnum.name());
|
||||
|
||||
}
|
||||
jobHandler.execute(fileEvent.getPatientId());
|
||||
|
||||
/**
|
||||
* 开始上传归档系统
|
||||
*
|
||||
* @param patientId
|
||||
*/
|
||||
private void startUpload(String patientId) {
|
||||
downloadService.uploadPlatform(null, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 开始进行ocr识别
|
||||
*
|
||||
* @param patientId
|
||||
*/
|
||||
private void startOcr(String patientId) {
|
||||
System.out.println(patientId);
|
||||
List<String> text = ocrApi.getText("D:\\docus\\cut\\segmentation\\20230822\\c6b03e5767814895a2c155c32f174051\\麻醉.jpg");
|
||||
}
|
||||
|
||||
/**
|
||||
* 开始分段
|
||||
*
|
||||
* @param patientId
|
||||
*/
|
||||
private void startSegment(String patientId) {
|
||||
System.out.println(patientId);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,23 @@
|
||||
package com.docus.server.service.handler;
|
||||
|
||||
import com.docus.log.annotation.TrackRetryListener;
|
||||
import com.docus.server.api.ocr.OcrApi;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 开始OCR处理器
|
||||
*/
|
||||
@Component
|
||||
public class StartOcrHandler {
|
||||
@Resource
|
||||
private OcrApi ocrApi;
|
||||
|
||||
@TrackRetryListener("START_OCR")
|
||||
public void startOcr(String patientId) {
|
||||
System.out.println(patientId);
|
||||
List<String> text = ocrApi.getText("D:\\docus\\cut\\segmentation\\20230822\\c6b03e5767814895a2c155c32f174051\\麻醉.jpg");
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
package com.docus.server.service.handler;
|
||||
|
||||
import com.docus.log.annotation.TrackRetryListener;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 开始分段处理器
|
||||
*/
|
||||
@Component
|
||||
public class StartSegmentHandler {
|
||||
|
||||
@TrackRetryListener("START_SEGMENT")
|
||||
public void startSegment(String patientId) {
|
||||
System.out.println(patientId);
|
||||
}
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
package com.docus.server.service.handler;
|
||||
|
||||
import com.docus.log.annotation.TrackRetryListener;
|
||||
import com.docus.server.service.impl.PlatformServiceImpl;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* 开始上传归档系统处理器
|
||||
*/
|
||||
@Component
|
||||
public class StartUploadHandler {
|
||||
@Resource
|
||||
private PlatformServiceImpl downloadService;
|
||||
|
||||
@TrackRetryListener("START_UPLOAD")
|
||||
public void startUpload(String patientId) {
|
||||
downloadService.uploadPlatform(null, null);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue