|
|
|
@ -1,17 +1,24 @@
|
|
|
|
|
package com.docus.server.service.impl;
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.io.FileUtil;
|
|
|
|
|
import com.docus.core.util.Func;
|
|
|
|
|
import com.docus.core.util.json.JSON;
|
|
|
|
|
import com.docus.server.api.ocr.OcrApi;
|
|
|
|
|
import com.docus.server.dto.segmentation.UploadBatchFileRequest;
|
|
|
|
|
import com.docus.server.dto.segmentation.ocrbasic.AddOcrBasicDTO;
|
|
|
|
|
import com.docus.server.dto.segmentation.ocrbasictest.AddOcrBasicTestDTO;
|
|
|
|
|
import com.docus.server.dto.segmentation.ocrfileinfo.AddOcrFileInfoDTO;
|
|
|
|
|
import com.docus.server.dto.segmentation.ocrfileinfotest.AddOcrFileInfoTestDTO;
|
|
|
|
|
import com.docus.server.dto.segmentation.ocrfileinfotest.DeleteOcrFileInfoTestDTO;
|
|
|
|
|
import com.docus.server.entity.segmentation.OcrFileInfoTest;
|
|
|
|
|
import com.docus.server.enums.OcrStatusEnum;
|
|
|
|
|
import com.docus.server.service.IOcrBasicService;
|
|
|
|
|
import com.docus.server.service.IOcrBasicTestService;
|
|
|
|
|
import com.docus.server.service.IOcrFileInfoService;
|
|
|
|
|
import com.docus.server.service.IOcrFileInfoTestService;
|
|
|
|
|
import com.docus.server.service.handler.StartOcrTestHandler;
|
|
|
|
|
import com.docus.server.vo.scheduling.management.schcollectorversionfile.UploadFileVO;
|
|
|
|
|
import com.google.common.collect.Lists;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
|
@ -31,6 +38,10 @@ public class CommonService {
|
|
|
|
|
private IOcrBasicTestService iOcrBasicTestService;
|
|
|
|
|
@Resource
|
|
|
|
|
private IOcrFileInfoTestService iOcrFileInfoTestService;
|
|
|
|
|
@Resource
|
|
|
|
|
private OcrApi ocrApi;
|
|
|
|
|
@Resource
|
|
|
|
|
private StartOcrTestHandler startOcrTestHandler;
|
|
|
|
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
|
public Object add(List<UploadFileVO> segmentation, UploadBatchFileRequest request) {
|
|
|
|
@ -109,4 +120,60 @@ public class CommonService {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
|
public AddOcrFileInfoTestDTO add(UploadFileVO uploadFileVO, UploadBatchFileRequest request) {
|
|
|
|
|
|
|
|
|
|
AddOcrFileInfoTestDTO addOcrFileInfoDTO = new AddOcrFileInfoTestDTO();
|
|
|
|
|
|
|
|
|
|
// addOcrFileInfoDTO.setPatientId(request.getPatientId());
|
|
|
|
|
addOcrFileInfoDTO.setFileTitle(uploadFileVO.getFileTitle());
|
|
|
|
|
addOcrFileInfoDTO.setPicName(uploadFileVO.getFileName());
|
|
|
|
|
addOcrFileInfoDTO.setFileType(2);
|
|
|
|
|
addOcrFileInfoDTO.setSerialNumber(UUID.randomUUID().toString().replace("-", ""));
|
|
|
|
|
addOcrFileInfoDTO.setPicUrl(uploadFileVO.getSaveFilePath() + uploadFileVO.getFilePath());
|
|
|
|
|
addOcrFileInfoDTO.setPicCompressUrl(uploadFileVO.getSaveCompressFilePath() + uploadFileVO.getFilePath());
|
|
|
|
|
addOcrFileInfoDTO.setPicCutUrl(uploadFileVO.getSaveCutFilePath() + uploadFileVO.getFilePath());
|
|
|
|
|
addOcrFileInfoDTO.setFileSize(uploadFileVO.getFileSize());
|
|
|
|
|
addOcrFileInfoDTO.setHeight(uploadFileVO.getHeight());
|
|
|
|
|
addOcrFileInfoDTO.setWidth(uploadFileVO.getWidth());
|
|
|
|
|
addOcrFileInfoDTO.setX(uploadFileVO.getX());
|
|
|
|
|
addOcrFileInfoDTO.setY(uploadFileVO.getY());
|
|
|
|
|
addOcrFileInfoDTO.setJsonStr(JSON.toJSON(uploadFileVO.getParams()));
|
|
|
|
|
addOcrFileInfoDTO.setOcrStatus(OcrStatusEnum.NO_START);
|
|
|
|
|
|
|
|
|
|
Long id = iOcrFileInfoTestService.saveOrUpdate(addOcrFileInfoDTO);
|
|
|
|
|
addOcrFileInfoDTO.setPatientId(String.valueOf(id));
|
|
|
|
|
addOcrFileInfoDTO.setId(id);
|
|
|
|
|
|
|
|
|
|
return addOcrFileInfoDTO;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public OcrFileInfoTest getOcr(UploadFileVO uploadFileVO, UploadBatchFileRequest request) {
|
|
|
|
|
|
|
|
|
|
//上一份
|
|
|
|
|
String patientId = request.getPatientId();
|
|
|
|
|
if (Func.isNotBlank(patientId)) {
|
|
|
|
|
OcrFileInfoTest ocrFileInfoTest = iOcrFileInfoTestService.findOneBy(patientId);
|
|
|
|
|
|
|
|
|
|
if (null != ocrFileInfoTest) {
|
|
|
|
|
iOcrFileInfoTestService.delete(DeleteOcrFileInfoTestDTO.builder().ids(Lists.newArrayList(ocrFileInfoTest.getId())).build());
|
|
|
|
|
|
|
|
|
|
FileUtil.del(ocrFileInfoTest.getPicUrl());
|
|
|
|
|
FileUtil.del(ocrFileInfoTest.getPicCompressUrl());
|
|
|
|
|
FileUtil.del(ocrFileInfoTest.getPicCutUrl());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//当前
|
|
|
|
|
AddOcrFileInfoTestDTO addOcrFileInfoTestDTO = this.add(uploadFileVO, request);
|
|
|
|
|
|
|
|
|
|
List<OcrFileInfoTest> ocrFileInfoTests = startOcrTestHandler.startOcr(addOcrFileInfoTestDTO.getPatientId());
|
|
|
|
|
|
|
|
|
|
if (Func.isNotEmpty(ocrFileInfoTests)) {
|
|
|
|
|
return ocrFileInfoTests.get(0);
|
|
|
|
|
} else {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|