|
|
|
@ -2,6 +2,7 @@ package org.jeecg.modules.api.controller;
|
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
|
@ -214,37 +215,33 @@ public class ApiController {
|
|
|
|
|
public Result restartTask(@RequestBody JSONObject jsonObject) throws InterruptedException {
|
|
|
|
|
System.out.println(jsonObject.toJSONString());
|
|
|
|
|
//获取已执行完的任务
|
|
|
|
|
//List<OcrIdentify> list = ocrIdentifyService.list(new LambdaQueryWrapper<OcrIdentify>());
|
|
|
|
|
List<OcrIdentifyDetail> list = ocrIdentifyDetailService.list();
|
|
|
|
|
int i1=0;
|
|
|
|
|
for (OcrIdentifyDetail ocrIdentifyDetail : list) {
|
|
|
|
|
String imgPath = ocrIdentifyDetail.getImageUrl();
|
|
|
|
|
JSONObject semanticResult = JSONObject.parseObject(ocrIdentifyDetail.getSemanticResult());
|
|
|
|
|
File file = new File(imgPath);
|
|
|
|
|
//当原图片存在时.
|
|
|
|
|
if (file.exists()) {
|
|
|
|
|
int i = imgPath.lastIndexOf("/");
|
|
|
|
|
String fileUrl = "/data/ocrImage/drawDashed" + imgPath.substring(0, i);
|
|
|
|
|
//判断新目录是否存在,不存在则新建
|
|
|
|
|
FileOUtils.folderCreate(fileUrl);
|
|
|
|
|
String outputImagePath = fileUrl + imgPath.substring(i + 1, imgPath.length());
|
|
|
|
|
List<List<Point>> resultToPoints = ImageUtils.semanticResultToPoints(semanticResult);
|
|
|
|
|
if (resultToPoints.size()>0) {
|
|
|
|
|
ImageUtils.drawDashedRectangleOnImages(file.getAbsolutePath(),resultToPoints,outputImagePath,"red");
|
|
|
|
|
ocrIdentifyDetail.setDrawDashedImageUrl(outputImagePath);
|
|
|
|
|
LambdaQueryWrapper<OcrIdentify> queryWrapper = new LambdaQueryWrapper<OcrIdentify>().in(OcrIdentify::getStatus, 0, 2).ne(OcrIdentify::getTaskSource, "模拟实验");
|
|
|
|
|
List<OcrIdentify> list = ocrIdentifyService.list(queryWrapper);
|
|
|
|
|
//List<OcrIdentifyDetail> list = ocrIdentifyDetailService.list(queryWrapper);
|
|
|
|
|
int i =0;
|
|
|
|
|
for (OcrIdentify ocrIdentify : list) {
|
|
|
|
|
String sourceImages = ocrIdentify.getIdentifyUrl();
|
|
|
|
|
//获取识别的图片
|
|
|
|
|
List<String> fileList = new ArrayList<>();
|
|
|
|
|
//获取相对路径
|
|
|
|
|
List<DictModel> ocr_relative_path = sysDictService.queryDictItemsByCode("ocr_relative_path");
|
|
|
|
|
String relativePath = null;
|
|
|
|
|
if (ocr_relative_path != null && ocr_relative_path.size() > 0) {
|
|
|
|
|
for (DictModel dictModel : ocr_relative_path) {
|
|
|
|
|
if (dictModel.getValue().equals("0")) {
|
|
|
|
|
relativePath = dictModel.getText();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
List<String> fileUrlList = FileOUtils.fileLists(relativePath, sourceImages);
|
|
|
|
|
for (String fileUrl : fileUrlList) {
|
|
|
|
|
//判断附件是否是 图片格式
|
|
|
|
|
if (fileUrl.lastIndexOf(".png") != -1 || fileUrl.lastIndexOf(".jpg") != -1 || fileUrl.lastIndexOf(".jpeg") != -1) {
|
|
|
|
|
fileList.add(fileUrl);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
i1++;
|
|
|
|
|
System.out.println(i1);
|
|
|
|
|
ocrIdentifyService.postSemantic(ocrIdentify,fileList);
|
|
|
|
|
}
|
|
|
|
|
ocrIdentifyDetailService.updateBatchById(list);
|
|
|
|
|
/*int i =0;
|
|
|
|
|
for (OcrIdentify ocrIdentify : list) {
|
|
|
|
|
if (ocrIdentify.getStatus().equals("1")) {
|
|
|
|
|
ocrIdentifyService.updateTaskResultInfo(ocrIdentify.getId());
|
|
|
|
|
}else{}
|
|
|
|
|
i++;
|
|
|
|
|
}*/
|
|
|
|
|
return Result.OK(list.size()+"个任务.");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|