|
|
|
@ -58,8 +58,8 @@ public class ApiController {
|
|
|
|
|
@RequestMapping("/identify")
|
|
|
|
|
@Transactional
|
|
|
|
|
@ResponseBody
|
|
|
|
|
public Result<?> pushSemantic(@RequestBody JSONObject requestBody){
|
|
|
|
|
if (requestBody==null) {
|
|
|
|
|
public Result<?> pushSemantic(@RequestBody JSONObject requestBody) {
|
|
|
|
|
if (requestBody == null) {
|
|
|
|
|
return Result.error("请输入请求参数");
|
|
|
|
|
}
|
|
|
|
|
//1.获取请求参数
|
|
|
|
@ -72,37 +72,37 @@ public class ApiController {
|
|
|
|
|
List<JSONObject> sourceJsonList = sourceJson.toJavaList(JSONObject.class);//校验数据源
|
|
|
|
|
//=============================================================
|
|
|
|
|
//2.参数判断
|
|
|
|
|
AssertUtils.notNull(requestId,"[requestId]-不可为空");
|
|
|
|
|
AssertUtils.notTrue(!"door".equals(scenes),String.format("暂不支持该场景类型[%s]",scenes));
|
|
|
|
|
AssertUtils.notNull(ruleId,"[ruleId]-不可为空");
|
|
|
|
|
AssertUtils.notNull(requestId, "[requestId]-不可为空");
|
|
|
|
|
AssertUtils.notTrue(!"door".equals(scenes), String.format("暂不支持该场景类型[%s]", scenes));
|
|
|
|
|
AssertUtils.notNull(ruleId, "[ruleId]-不可为空");
|
|
|
|
|
OcrRuleCheckVo ruleCheck = ocrRuleCheckService.findById(ruleId);
|
|
|
|
|
AssertUtils.notNull(ruleCheck,"[ruleId]-不存在");
|
|
|
|
|
AssertUtils.notNull(priority,"[priority]-不可为空");
|
|
|
|
|
AssertUtils.notNull(sourceJson,"[sourceJson]-不可为空");
|
|
|
|
|
AssertUtils.notNull(ruleCheck, "[ruleId]-不存在");
|
|
|
|
|
AssertUtils.notNull(priority, "[priority]-不可为空");
|
|
|
|
|
AssertUtils.notNull(sourceJson, "[sourceJson]-不可为空");
|
|
|
|
|
|
|
|
|
|
//获取识别的图片
|
|
|
|
|
List<String> fileList=new ArrayList<>();
|
|
|
|
|
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) {
|
|
|
|
|
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();
|
|
|
|
|
relativePath = dictModel.getText();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
List<String> fileUrlList= FileOUtils.fileLists(relativePath,sourceImages);
|
|
|
|
|
List<String> fileUrlList = FileOUtils.fileLists(relativePath, sourceImages);
|
|
|
|
|
for (String fileUrl : fileUrlList) {
|
|
|
|
|
//判断附件是否是 图片格式
|
|
|
|
|
if (fileUrl.lastIndexOf(".png")!=-1 || fileUrl.lastIndexOf(".jpg")!=-1|| fileUrl.lastIndexOf(".jpeg")!=-1) {
|
|
|
|
|
if (fileUrl.lastIndexOf(".png") != -1 || fileUrl.lastIndexOf(".jpg") != -1 || fileUrl.lastIndexOf(".jpeg") != -1) {
|
|
|
|
|
fileList.add(fileUrl);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
AssertUtils.hasSize(fileList,"图片目录下未获取到可使用的图片格式文件");
|
|
|
|
|
OcrIdentify ocrIdentify=new OcrIdentify();
|
|
|
|
|
AssertUtils.hasSize(fileList, "图片目录下未获取到可使用的图片格式文件");
|
|
|
|
|
OcrIdentify ocrIdentify = new OcrIdentify();
|
|
|
|
|
//2.创建识别任务
|
|
|
|
|
if(true){
|
|
|
|
|
if (true) {
|
|
|
|
|
ocrIdentify.setTaskName(requestId);
|
|
|
|
|
ocrIdentify.setRequestId(requestId);
|
|
|
|
|
ocrIdentify.setStatus("0");//任务进行中
|
|
|
|
@ -120,7 +120,7 @@ public class ApiController {
|
|
|
|
|
ocrIdentifyService.save(ocrIdentify);
|
|
|
|
|
}
|
|
|
|
|
//3.请求python ocr识别,异步执行
|
|
|
|
|
ocrIdentifyService.postSemantic(ocrIdentify,fileList);
|
|
|
|
|
ocrIdentifyService.postSemantic(ocrIdentify, fileList);
|
|
|
|
|
return Result.OK("请求成功");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -155,9 +155,9 @@ public class ApiController {
|
|
|
|
|
@PostMapping(value = "/imgNotify")
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
|
public JSONObject imgNotify() {
|
|
|
|
|
String ss="{\t\"requestId\":\"10001\",\t\"result\":{\t\t\"ocrResult\":[\t\t\t{\t\t\t\t\"tag\":\"hospitalName\",\t\t\t\t\"inputText\":\"仁和医院\",\t\t\t\t\"ocrText\":\"仁和医院\",\t\t\t\t\"ocrPrecisionRate\":0.8,\t\t\t\t\"sourceImage\":{\t\t\t\t\t\"fileName\":\"test1.png\",\t\t\t\t\t\"path\":\"/usr/local/ocr/test1.png\"\t\t\t\t},\t\t\t\t\"failureReason\":\"\"\t\t\t}\t\t],\t\t\"ruleValidation\":false,\t\t\"retrieveReviewCompliance\":\"80\",\t\t\"imageTagRetrievePercentage\":\"66.6\",\t\t\"failureReason\":\"医生名称不匹配\"\t}}";
|
|
|
|
|
JSONObject requestBody=JSONObject.parseObject(ss);
|
|
|
|
|
JSONObject semanticResponseJson = RestUtil.post("http://111.202.228.113:8071/callback", requestBody);
|
|
|
|
|
String ss = "{\t\"requestId\":\"10001\",\t\"result\":{\t\t\"ocrResult\":[\t\t\t{\t\t\t\t\"tag\":\"hospitalName\",\t\t\t\t\"inputText\":\"仁和医院\",\t\t\t\t\"ocrText\":\"仁和医院\",\t\t\t\t\"ocrPrecisionRate\":0.8,\t\t\t\t\"sourceImage\":{\t\t\t\t\t\"fileName\":\"test1.png\",\t\t\t\t\t\"path\":\"/usr/local/ocr/test1.png\"\t\t\t\t},\t\t\t\t\"failureReason\":\"\"\t\t\t}\t\t],\t\t\"ruleValidation\":false,\t\t\"retrieveReviewCompliance\":\"80\",\t\t\"imageTagRetrievePercentage\":\"66.6\",\t\t\"failureReason\":\"医生名称不匹配\"\t}}";
|
|
|
|
|
JSONObject requestBody = JSONObject.parseObject(ss);
|
|
|
|
|
JSONObject semanticResponseJson = RestUtil.postTest("http://111.202.228.113:8071/callback", requestBody, new JSONObject());
|
|
|
|
|
return semanticResponseJson;
|
|
|
|
|
/*String requestId = jsonObject.getString("requestId");
|
|
|
|
|
String fileName = jsonObject.getString("fileName");
|
|
|
|
@ -170,8 +170,8 @@ public class ApiController {
|
|
|
|
|
@PostMapping(value = "/imgNotify1")
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
|
public JSONObject imgNotify1() {
|
|
|
|
|
String ss="{\t\"requestId\":\"10001\",\t\"result\":{\t\t\"ocrResult\":[\t\t\t{\t\t\t\t\"tag\":\"hospitalName\",\t\t\t\t\"inputText\":\"仁和医院\",\t\t\t\t\"ocrText\":\"仁和医院\",\t\t\t\t\"ocrPrecisionRate\":0.8,\t\t\t\t\"sourceImage\":{\t\t\t\t\t\"fileName\":\"test1.png\",\t\t\t\t\t\"path\":\"/usr/local/ocr/test1.png\"\t\t\t\t},\t\t\t\t\"failureReason\":\"\"\t\t\t}\t\t],\t\t\"ruleValidation\":false,\t\t\"retrieveReviewCompliance\":\"80\",\t\t\"imageTagRetrievePercentage\":\"66.6\",\t\t\"failureReason\":\"医生名称不匹配\"\t}}";
|
|
|
|
|
JSONObject requestBody=JSONObject.parseObject(ss);
|
|
|
|
|
String ss = "{\t\"requestId\":\"10001\",\t\"result\":{\t\t\"ocrResult\":[\t\t\t{\t\t\t\t\"tag\":\"hospitalName\",\t\t\t\t\"inputText\":\"仁和医院\",\t\t\t\t\"ocrText\":\"仁和医院\",\t\t\t\t\"ocrPrecisionRate\":0.8,\t\t\t\t\"sourceImage\":{\t\t\t\t\t\"fileName\":\"test1.png\",\t\t\t\t\t\"path\":\"/usr/local/ocr/test1.png\"\t\t\t\t},\t\t\t\t\"failureReason\":\"\"\t\t\t}\t\t],\t\t\"ruleValidation\":false,\t\t\"retrieveReviewCompliance\":\"80\",\t\t\"imageTagRetrievePercentage\":\"66.6\",\t\t\"failureReason\":\"医生名称不匹配\"\t}}";
|
|
|
|
|
JSONObject requestBody = JSONObject.parseObject(ss);
|
|
|
|
|
JSONObject semanticResponseJson = RestUtil.post("https://192.168.5.179:8080/api/task/image/ocr/callback", requestBody);
|
|
|
|
|
return semanticResponseJson;
|
|
|
|
|
/*String requestId = jsonObject.getString("requestId");
|
|
|
|
|