|
|
|
@ -40,10 +40,7 @@ import javax.annotation.Resource;
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
|
import java.io.Serializable;
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Arrays;
|
|
|
|
|
import java.util.Collection;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 业务层实现
|
|
|
|
@ -320,20 +317,38 @@ public class OcrPictureServiceImpl extends BaseServiceImpl<OcrPictureMybatisDao,
|
|
|
|
|
}
|
|
|
|
|
//TODO 接口请求判断重复情况
|
|
|
|
|
logService.addLog(103, "AI获取图片相似度接口", sysUser, "sendParams");
|
|
|
|
|
JSONObject jsonObjectSimi = ImageClassUtil.getSimilarity(StringUtils.isBlank(ocrPicture.getLocalpictrueurl()) ? ocrPicture.getImgurl() : ocrPicture.getLocalpictrueurl(),
|
|
|
|
|
StringUtils.isBlank(ocrPictureNext.getLocalpictrueurl()) ? ocrPictureNext.getImgurl() : ocrPictureNext.getLocalpictrueurl(),
|
|
|
|
|
similarityPath);
|
|
|
|
|
System.out.println("responseDataXs--code = [" + jsonObjectSimi.get("code") + "]");
|
|
|
|
|
System.out.println("responseDataXs--similarity = [" + jsonObjectSimi.get("similarity") + "]");
|
|
|
|
|
String resultValue = "";
|
|
|
|
|
//返回内容为零,表示成功,否则表示失败
|
|
|
|
|
if (null != jsonObjectSimi && jsonObjectSimi.getString("code").equals("0")) {
|
|
|
|
|
resultValue = jsonObjectSimi.getString("similarity");
|
|
|
|
|
ocrPictureNext.setResult(resultValue);
|
|
|
|
|
} else {
|
|
|
|
|
resultValue = "0";
|
|
|
|
|
ocrPictureNext.setResult(resultValue);
|
|
|
|
|
if(StringUtils.isBlank(ocrPicture.getImgHash())){
|
|
|
|
|
Map<String,String> map = this.getOcrPictureClassifyAndHash(ocrPicture.getLocalpictrueurl());
|
|
|
|
|
if(map!=null){
|
|
|
|
|
ocrPicture.setImgHash(map.get("hash"));
|
|
|
|
|
ocrPicture.setClassificationid(map.get("classId"));
|
|
|
|
|
}
|
|
|
|
|
this.updateById(ocrPicture);
|
|
|
|
|
}
|
|
|
|
|
if(StringUtils.isBlank(ocrPictureNext.getImgHash())){
|
|
|
|
|
Map<String,String> map = this.getOcrPictureClassifyAndHash(ocrPictureNext.getLocalpictrueurl());
|
|
|
|
|
if(map!=null){
|
|
|
|
|
ocrPictureNext.setImgHash(map.get("hash"));
|
|
|
|
|
ocrPictureNext.setClassificationid(map.get("classId"));
|
|
|
|
|
}
|
|
|
|
|
this.updateById(ocrPictureNext);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String img=StringUtils.isBlank(ocrPicture.getImgHash())?StringUtils.isBlank(ocrPicture.getLocalpictrueurl()) ? ocrPicture.getImgurl() : ocrPicture.getLocalpictrueurl():ocrPicture.getImgHash();
|
|
|
|
|
String imgNext=StringUtils.isBlank(ocrPictureNext.getImgHash())?StringUtils.isBlank(ocrPictureNext.getLocalpictrueurl()) ? ocrPictureNext.getImgurl() : ocrPictureNext.getLocalpictrueurl():ocrPictureNext.getImgHash();
|
|
|
|
|
// JSONObject jsonObjectSimi = ImageClassUtil.getSimilarity(img,imgNext,similarityPath);
|
|
|
|
|
// System.out.println("responseDataXs--code = [" + jsonObjectSimi.get("code") + "]");
|
|
|
|
|
// System.out.println("responseDataXs--similarity = [" + jsonObjectSimi.get("similarity") + "]");
|
|
|
|
|
String resultValue = HashCompareUtil.cmpHash(img, imgNext);
|
|
|
|
|
//返回内容为零,表示成功,否则表示失败
|
|
|
|
|
// if (null != jsonObjectSimi && jsonObjectSimi.getString("code").equals("0")) {
|
|
|
|
|
// resultValue = jsonObjectSimi.getString("similarity");
|
|
|
|
|
// ocrPictureNext.setResult(resultValue);
|
|
|
|
|
// } else {
|
|
|
|
|
// resultValue = "0";
|
|
|
|
|
// ocrPictureNext.setResult(resultValue);
|
|
|
|
|
// }
|
|
|
|
|
ocrPictureNext.setResult(resultValue);
|
|
|
|
|
BigDecimal b1 = new BigDecimal(resultValue);
|
|
|
|
|
BigDecimal b2 = new BigDecimal("100");
|
|
|
|
|
int val = b1.compareTo(b2);
|
|
|
|
@ -351,32 +366,32 @@ public class OcrPictureServiceImpl extends BaseServiceImpl<OcrPictureMybatisDao,
|
|
|
|
|
ocrPicture.setListCom(compareList);
|
|
|
|
|
//非历史图片主键集合
|
|
|
|
|
ocrPicture.setPicturecompareList(picturecompareList);
|
|
|
|
|
//查询项目对象
|
|
|
|
|
if (null == ocrPicture.getCategoryid()) {
|
|
|
|
|
//TODO 没有对应项目,返回提示信息
|
|
|
|
|
if (null != error && error.length() > 1) {
|
|
|
|
|
error.append("," + ocrPicture.getImgname());
|
|
|
|
|
} else {
|
|
|
|
|
error.append(ocrPicture.getImgname());
|
|
|
|
|
}
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
Category category = categoryService.getById(ocrPicture.getCategoryid());
|
|
|
|
|
if (null == category) {
|
|
|
|
|
if (null != errorProject && errorProject.length() > 1) {
|
|
|
|
|
errorProject.append("," + ocrPicture.getImgname());
|
|
|
|
|
} else {
|
|
|
|
|
errorProject.append(ocrPicture.getImgname());
|
|
|
|
|
}
|
|
|
|
|
continue;
|
|
|
|
|
} else if (StringUtils.isBlank(category.getProcessdefinitionid())) {
|
|
|
|
|
if (null != errorFlow && errorFlow.length() > 1) {
|
|
|
|
|
errorFlow.append("," + category.getCategoryname());
|
|
|
|
|
} else {
|
|
|
|
|
errorFlow.append(category.getCategoryname());
|
|
|
|
|
}
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
// //查询项目对象
|
|
|
|
|
// if (null == ocrPicture.getCategoryid()) {
|
|
|
|
|
// //TODO 没有对应项目,返回提示信息
|
|
|
|
|
// if (null != error && error.length() > 1) {
|
|
|
|
|
// error.append("," + ocrPicture.getImgname());
|
|
|
|
|
// } else {
|
|
|
|
|
// error.append(ocrPicture.getImgname());
|
|
|
|
|
// }
|
|
|
|
|
// continue;
|
|
|
|
|
// }
|
|
|
|
|
// Category category = categoryService.getById(ocrPicture.getCategoryid());
|
|
|
|
|
// if (null == category) {
|
|
|
|
|
// if (null != errorProject && errorProject.length() > 1) {
|
|
|
|
|
// errorProject.append("," + ocrPicture.getImgname());
|
|
|
|
|
// } else {
|
|
|
|
|
// errorProject.append(ocrPicture.getImgname());
|
|
|
|
|
// }
|
|
|
|
|
// continue;
|
|
|
|
|
// } else if (StringUtils.isBlank(category.getProcessdefinitionid())) {
|
|
|
|
|
// if (null != errorFlow && errorFlow.length() > 1) {
|
|
|
|
|
// errorFlow.append("," + category.getCategoryname());
|
|
|
|
|
// } else {
|
|
|
|
|
// errorFlow.append(category.getCategoryname());
|
|
|
|
|
// }
|
|
|
|
|
// continue;
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
//创建工单,如果创建成功,增加标志,用于过滤条件使用
|
|
|
|
|
OcrTaskchildPicture ocrTaskchildPicture = this.updateTaskChild(ocrPicture, ocrPackagetask.getId(), buessinessno);
|
|
|
|
@ -417,6 +432,20 @@ public class OcrPictureServiceImpl extends BaseServiceImpl<OcrPictureMybatisDao,
|
|
|
|
|
return ResultVoUtil.error("失败。");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Map<String, String> getOcrPictureClassifyAndHash(String img) {
|
|
|
|
|
JSONObject jsonObjectSimi = ImageClassUtil.getClassify(img,"","http://127.0.0.1:8000/api/classify/");
|
|
|
|
|
//返回内容为零,表示成功,否则表示失败
|
|
|
|
|
if (null != jsonObjectSimi && jsonObjectSimi.getString("code").equals("0")) {
|
|
|
|
|
Map<String,String> map=new HashMap();
|
|
|
|
|
map.put("classId",jsonObjectSimi.getString("classId"));
|
|
|
|
|
map.put("hash",jsonObjectSimi.getString("hash"));
|
|
|
|
|
return map;
|
|
|
|
|
}else{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public OcrTaskchildPicture updateTaskChild(OcrPicture ocrPicture, Long packageid, String buessinessno) {
|
|
|
|
|
OcrTaskchildPicture ocrTaskchildPicture = ocrTaskchildPictureService.getOne(new LambdaQueryWrapper<OcrTaskchildPicture>().eq(OcrTaskchildPicture::getPictureid, ocrPicture.getId()));
|
|
|
|
|
ocrTaskchildPicture.setBuessinessno(buessinessno);
|
|
|
|
|