master
周文涛 2 years ago
parent 72503772da
commit 47a1ed8eac

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

Loading…
Cancel
Save