|
|
@ -2,7 +2,6 @@ package cn.jyjz.xiaoyao.ocr.service.impl;
|
|
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.date.DateTime;
|
|
|
|
import cn.hutool.core.date.DateTime;
|
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
|
import cn.jyjz.flowable.domain.vo.FlowInstanceVo;
|
|
|
|
|
|
|
|
import cn.jyjz.flowable.service.IFlowInstanceService;
|
|
|
|
import cn.jyjz.flowable.service.IFlowInstanceService;
|
|
|
|
import cn.jyjz.xiaoyao.abase.service.SeqManageService;
|
|
|
|
import cn.jyjz.xiaoyao.abase.service.SeqManageService;
|
|
|
|
import cn.jyjz.xiaoyao.admin.service.LogService;
|
|
|
|
import cn.jyjz.xiaoyao.admin.service.LogService;
|
|
|
@ -18,39 +17,34 @@ import cn.jyjz.xiaoyao.ocr.util.DataDictionaryUtil;
|
|
|
|
import cn.jyjz.xiaoyao.ocr.util.ImageClassUtil;
|
|
|
|
import cn.jyjz.xiaoyao.ocr.util.ImageClassUtil;
|
|
|
|
import cn.jyjz.xiaoyao.ocr.util.SearchEnum;
|
|
|
|
import cn.jyjz.xiaoyao.ocr.util.SearchEnum;
|
|
|
|
import cn.jyjz.xiaoyao.ocr.util.SearchParaFormatting;
|
|
|
|
import cn.jyjz.xiaoyao.ocr.util.SearchParaFormatting;
|
|
|
|
import cn.jyjz.xiaoyao.ocr.util.httputil.HttpClient;
|
|
|
|
|
|
|
|
import cn.jyjz.xiaoyao.ocr.util.httputil.HttpHeader;
|
|
|
|
|
|
|
|
import cn.jyjz.xiaoyao.ocr.util.httputil.HttpParamers;
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
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 org.apache.commons.lang.ArrayUtils;
|
|
|
|
|
|
|
|
import org.apache.commons.lang.time.DateFormatUtils;
|
|
|
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
import org.apache.poi.hpsf.Decimal;
|
|
|
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
|
import org.springframework.security.core.parameters.P;
|
|
|
|
import org.springframework.mock.web.MockHttpServletRequest;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import cn.jyjz.xiaoyao.common.mybatisplus.base.BaseServiceImpl;
|
|
|
|
import cn.jyjz.xiaoyao.common.mybatisplus.base.BaseServiceImpl;
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
import org.springframework.web.context.request.RequestContextHolder;
|
|
|
|
|
|
|
|
import org.springframework.web.context.request.ServletRequestAttributes;
|
|
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
import java.io.Serializable;
|
|
|
|
import java.io.Serializable;
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
import java.text.DecimalFormat;
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.Arrays;
|
|
|
|
import java.util.Arrays;
|
|
|
|
import java.util.Collection;
|
|
|
|
import java.util.Collection;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 业务层实现
|
|
|
|
* 业务层实现
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@Service("ocrPictureService")
|
|
|
|
@Service("ocrPictureService")
|
|
|
|
@Slf4j
|
|
|
|
@Slf4j
|
|
|
|
public class OcrPictureServiceImpl extends BaseServiceImpl<OcrPictureMybatisDao, OcrPicture> implements OcrPictureService {
|
|
|
|
public class OcrPictureServiceImpl extends BaseServiceImpl<OcrPictureMybatisDao, OcrPicture> implements OcrPictureService {
|
|
|
@ -94,7 +88,8 @@ public class OcrPictureServiceImpl extends BaseServiceImpl<OcrPictureMybatisDao,
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@Autowired
|
|
|
|
@Autowired
|
|
|
|
DataDictionaryUtil dataDictionaryUtil;
|
|
|
|
DataDictionaryUtil dataDictionaryUtil;
|
|
|
|
public ResultVo createTaskChild(List<OcrPicture> ocrPictureList, String tenantId , UserToken sysUser, String search_month, HttpServletRequest request, String buessinessno){
|
|
|
|
|
|
|
|
|
|
|
|
public ResultVo createTaskChild(List<OcrPicture> ocrPictureList, String tenantId, UserToken sysUser, String search_month, HttpServletRequest request, String buessinessno) {
|
|
|
|
|
|
|
|
|
|
|
|
//图片错误信息
|
|
|
|
//图片错误信息
|
|
|
|
StringBuffer error = new StringBuffer();
|
|
|
|
StringBuffer error = new StringBuffer();
|
|
|
@ -106,26 +101,26 @@ public class OcrPictureServiceImpl extends BaseServiceImpl<OcrPictureMybatisDao,
|
|
|
|
//记录任务相似度为百分百的任务主键
|
|
|
|
//记录任务相似度为百分百的任务主键
|
|
|
|
List<Long> pointsList = new ArrayList<>();
|
|
|
|
List<Long> pointsList = new ArrayList<>();
|
|
|
|
//图片信息不能为空
|
|
|
|
//图片信息不能为空
|
|
|
|
if(null != ocrPictureList && !ocrPictureList.isEmpty()){
|
|
|
|
if (null != ocrPictureList && !ocrPictureList.isEmpty()) {
|
|
|
|
//生成任务包
|
|
|
|
//生成任务包
|
|
|
|
//String packageName = seqManageService.getSeqNextNo("AI任务包");
|
|
|
|
//String packageName = seqManageService.getSeqNextNo("AI任务包");
|
|
|
|
|
|
|
|
|
|
|
|
//TODO 相似度、图片查询时间未传
|
|
|
|
//TODO 相似度、图片查询时间未传
|
|
|
|
|
|
|
|
|
|
|
|
//创建任务包
|
|
|
|
//创建任务包
|
|
|
|
OcrPackagetask ocrPackagetask = this.ocrPackagetaskService.create(buessinessno,tenantId,sysUser);
|
|
|
|
OcrPackagetask ocrPackagetask = this.ocrPackagetaskService.create(buessinessno, tenantId, sysUser);
|
|
|
|
|
|
|
|
|
|
|
|
if(null == ocrPackagetask){
|
|
|
|
if (null == ocrPackagetask) {
|
|
|
|
return ResultVoUtil.error("失败。");
|
|
|
|
return ResultVoUtil.error("失败。");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//用于标记相似度是否存在百分百的情况
|
|
|
|
//用于标记相似度是否存在百分百的情况
|
|
|
|
|
|
|
|
|
|
|
|
List<OcrPicture> newList = new ArrayList<>();
|
|
|
|
List<OcrPicture> newList = new ArrayList<>();
|
|
|
|
for(OcrPicture ocrPicture:ocrPictureList){
|
|
|
|
for (OcrPicture ocrPicture : ocrPictureList) {
|
|
|
|
|
|
|
|
|
|
|
|
//如果当前图片已经生成任务包,直接跳过
|
|
|
|
//如果当前图片已经生成任务包,直接跳过
|
|
|
|
if(ocrPicture.getTaskstatus().equals("1")){
|
|
|
|
if (ocrPicture.getTaskstatus().equals("1")) {
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -138,15 +133,15 @@ public class OcrPictureServiceImpl extends BaseServiceImpl<OcrPictureMybatisDao,
|
|
|
|
|
|
|
|
|
|
|
|
boolean havePoint = false;
|
|
|
|
boolean havePoint = false;
|
|
|
|
//二次遍历进行比对
|
|
|
|
//二次遍历进行比对
|
|
|
|
for(OcrPicture ocrPictureNext:ocrPictureList){
|
|
|
|
for (OcrPicture ocrPictureNext : ocrPictureList) {
|
|
|
|
|
|
|
|
|
|
|
|
if(ocrPictureNext.getId().longValue() == ocrPicture.getId().longValue()){
|
|
|
|
if (ocrPictureNext.getId().longValue() == ocrPicture.getId().longValue()) {
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//TODO 接口请求判断重复情况
|
|
|
|
//TODO 接口请求判断重复情况
|
|
|
|
logService.addLog(103,"AI获取图片相似度接口", sysUser, "sendParams");
|
|
|
|
logService.addLog(103, "AI获取图片相似度接口", sysUser, "sendParams");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
JSONObject jsonObjectSimi = ImageClassUtil.getSimilarity(ocrPicture.getImgurl(),
|
|
|
|
JSONObject jsonObjectSimi = ImageClassUtil.getSimilarity(ocrPicture.getImgurl(),
|
|
|
@ -158,11 +153,11 @@ public class OcrPictureServiceImpl extends BaseServiceImpl<OcrPictureMybatisDao,
|
|
|
|
String resultValue = "";
|
|
|
|
String resultValue = "";
|
|
|
|
|
|
|
|
|
|
|
|
//返回内容为零,表示成功,否则表示失败
|
|
|
|
//返回内容为零,表示成功,否则表示失败
|
|
|
|
if(null != jsonObjectSimi && jsonObjectSimi.getString("code").equals("0")){
|
|
|
|
if (null != jsonObjectSimi && jsonObjectSimi.getString("code").equals("0")) {
|
|
|
|
|
|
|
|
|
|
|
|
resultValue = jsonObjectSimi.getString("similarity");
|
|
|
|
resultValue = jsonObjectSimi.getString("similarity");
|
|
|
|
ocrPictureNext.setResult(resultValue);
|
|
|
|
ocrPictureNext.setResult(resultValue);
|
|
|
|
}else{
|
|
|
|
} else {
|
|
|
|
resultValue = "0";
|
|
|
|
resultValue = "0";
|
|
|
|
ocrPictureNext.setResult(resultValue);
|
|
|
|
ocrPictureNext.setResult(resultValue);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -170,12 +165,12 @@ public class OcrPictureServiceImpl extends BaseServiceImpl<OcrPictureMybatisDao,
|
|
|
|
BigDecimal b1 = new BigDecimal(resultValue);
|
|
|
|
BigDecimal b1 = new BigDecimal(resultValue);
|
|
|
|
BigDecimal b2 = new BigDecimal("100");
|
|
|
|
BigDecimal b2 = new BigDecimal("100");
|
|
|
|
int val = b1.compareTo(b2);
|
|
|
|
int val = b1.compareTo(b2);
|
|
|
|
if(val == 0){
|
|
|
|
if (val == 0) {
|
|
|
|
havePoint = true;
|
|
|
|
havePoint = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//如果当前图片未生成任务需要临时保存
|
|
|
|
//如果当前图片未生成任务需要临时保存
|
|
|
|
if(ocrPictureNext.getTaskstatus().equals("0")){
|
|
|
|
if (ocrPictureNext.getTaskstatus().equals("0")) {
|
|
|
|
picturecompareList.add(ocrPictureNext.getId().toString());
|
|
|
|
picturecompareList.add(ocrPictureNext.getId().toString());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -189,35 +184,35 @@ public class OcrPictureServiceImpl extends BaseServiceImpl<OcrPictureMybatisDao,
|
|
|
|
ocrPicture.setPicturecompareList(picturecompareList);
|
|
|
|
ocrPicture.setPicturecompareList(picturecompareList);
|
|
|
|
|
|
|
|
|
|
|
|
//查询项目对象
|
|
|
|
//查询项目对象
|
|
|
|
if(null == ocrPicture.getCategoryid()){
|
|
|
|
if (null == ocrPicture.getCategoryid()) {
|
|
|
|
//TODO 没有对应项目,返回提示信息
|
|
|
|
//TODO 没有对应项目,返回提示信息
|
|
|
|
if(null != error && error.length() > 1){
|
|
|
|
if (null != error && error.length() > 1) {
|
|
|
|
error.append("," + ocrPicture.getImgname());
|
|
|
|
error.append("," + ocrPicture.getImgname());
|
|
|
|
}else{
|
|
|
|
} else {
|
|
|
|
error.append(ocrPicture.getImgname());
|
|
|
|
error.append(ocrPicture.getImgname());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Category category = categoryService.getById(ocrPicture.getCategoryid());
|
|
|
|
Category category = categoryService.getById(ocrPicture.getCategoryid());
|
|
|
|
if(null == category){
|
|
|
|
if (null == category) {
|
|
|
|
if(null != errorProject && errorProject.length() > 1){
|
|
|
|
if (null != errorProject && errorProject.length() > 1) {
|
|
|
|
errorProject.append("," + ocrPicture.getImgname());
|
|
|
|
errorProject.append("," + ocrPicture.getImgname());
|
|
|
|
}else {
|
|
|
|
} else {
|
|
|
|
errorProject.append(ocrPicture.getImgname());
|
|
|
|
errorProject.append(ocrPicture.getImgname());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
}else if(StringUtils.isBlank(category.getProcessdefinitionid())){
|
|
|
|
} else if (StringUtils.isBlank(category.getProcessdefinitionid())) {
|
|
|
|
if(null != errorFlow && errorFlow.length() > 1){
|
|
|
|
if (null != errorFlow && errorFlow.length() > 1) {
|
|
|
|
errorFlow.append("," + category.getCategoryname());
|
|
|
|
errorFlow.append("," + category.getCategoryname());
|
|
|
|
}else {
|
|
|
|
} else {
|
|
|
|
errorFlow.append(category.getCategoryname());
|
|
|
|
errorFlow.append(category.getCategoryname());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//创建工单,如果创建成功,增加标志,用于过滤条件使用
|
|
|
|
//创建工单,如果创建成功,增加标志,用于过滤条件使用
|
|
|
|
OcrTaskchildPicture ocrTaskchildPicture = this.ocrTaskchildPictureService.create(ocrPicture,tenantId,sysUser,ocrPackagetask.getId(),buessinessno);
|
|
|
|
OcrTaskchildPicture ocrTaskchildPicture = this.ocrTaskchildPictureService.create(ocrPicture, tenantId, sysUser, ocrPackagetask.getId(), buessinessno);
|
|
|
|
if(null != ocrTaskchildPicture){
|
|
|
|
if (null != ocrTaskchildPicture) {
|
|
|
|
|
|
|
|
|
|
|
|
//发起流程
|
|
|
|
//发起流程
|
|
|
|
flowInstanceService.startProcessInstanceById(
|
|
|
|
flowInstanceService.startProcessInstanceById(
|
|
|
@ -228,7 +223,7 @@ public class OcrPictureServiceImpl extends BaseServiceImpl<OcrPictureMybatisDao,
|
|
|
|
category.getServicename()
|
|
|
|
category.getServicename()
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
if(havePoint){
|
|
|
|
if (havePoint) {
|
|
|
|
pointsList.add(ocrTaskchildPicture.getId());
|
|
|
|
pointsList.add(ocrTaskchildPicture.getId());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -242,16 +237,16 @@ public class OcrPictureServiceImpl extends BaseServiceImpl<OcrPictureMybatisDao,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//批量更新 pointsList 主键相似度为百分百的数据
|
|
|
|
//批量更新 pointsList 主键相似度为百分百的数据
|
|
|
|
if(null != pointsList && !pointsList.isEmpty()){
|
|
|
|
if (null != pointsList && !pointsList.isEmpty()) {
|
|
|
|
this.ocrTaskchildPictureService.markPoint(pointsList);
|
|
|
|
this.ocrTaskchildPictureService.markPoint(pointsList);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(StringUtils.isNotBlank(search_month)){
|
|
|
|
if (StringUtils.isNotBlank(search_month)) {
|
|
|
|
if(StringUtils.isNotBlank(search_month) && Integer.parseInt(search_month) <= 12 && Integer.parseInt(search_month) > 0){
|
|
|
|
if (StringUtils.isNotBlank(search_month) && Integer.parseInt(search_month) <= 12 && Integer.parseInt(search_month) > 0) {
|
|
|
|
|
|
|
|
|
|
|
|
ocrPackagetask.setSearchtimes(SearchEnum.getName(Integer.parseInt(search_month)));
|
|
|
|
ocrPackagetask.setSearchtimes(SearchEnum.getName(Integer.parseInt(search_month)));
|
|
|
|
}else if(StringUtils.isNotBlank(search_month) && Integer.parseInt(search_month) > 20){
|
|
|
|
} else if (StringUtils.isNotBlank(search_month) && Integer.parseInt(search_month) > 20) {
|
|
|
|
ocrPackagetask.setSearchtimes(SearchEnum.getName((Integer.parseInt(search_month) - 20)));
|
|
|
|
ocrPackagetask.setSearchtimes(SearchEnum.getName((Integer.parseInt(search_month) - 20)));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -259,18 +254,171 @@ public class OcrPictureServiceImpl extends BaseServiceImpl<OcrPictureMybatisDao,
|
|
|
|
this.ocrPackagetaskService.updateById(ocrPackagetask);
|
|
|
|
this.ocrPackagetaskService.updateById(ocrPackagetask);
|
|
|
|
|
|
|
|
|
|
|
|
//原主图设置为任务包已经生成
|
|
|
|
//原主图设置为任务包已经生成
|
|
|
|
for(OcrPicture ocrPicture:newList){
|
|
|
|
for (OcrPicture ocrPicture : newList) {
|
|
|
|
|
|
|
|
ocrPicture.setTaskstatus("1");
|
|
|
|
|
|
|
|
this.updateById(ocrPicture);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (StringUtils.isBlank(error) && StringUtils.isBlank(errorProject) && StringUtils.isBlank(errorFlow)) {
|
|
|
|
|
|
|
|
return ResultVoUtil.success();
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String msg = (StringUtils.isBlank(error)) ? "" : error.toString() + ",图片没有对应项目,无法查重。";
|
|
|
|
|
|
|
|
msg = msg + ((StringUtils.isBlank(errorProject)) ? "" : errorProject.toString() + ",图片没有对应项目,无法查重。");
|
|
|
|
|
|
|
|
msg = msg + ((StringUtils.isBlank(errorFlow)) ? "" : errorFlow.toString() + ",项目没有配置审批流程,无法查重。");
|
|
|
|
|
|
|
|
return ResultVoUtil.success(msg);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return ResultVoUtil.error("失败。");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
public ResultVo createTaskChild(List<OcrPicture> ocrPictureList, String tenantId) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//图片错误信息
|
|
|
|
|
|
|
|
StringBuffer error = new StringBuffer();
|
|
|
|
|
|
|
|
//项目错误信息
|
|
|
|
|
|
|
|
StringBuffer errorProject = new StringBuffer();
|
|
|
|
|
|
|
|
//流程错误信息
|
|
|
|
|
|
|
|
StringBuffer errorFlow = new StringBuffer();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//记录任务相似度为百分百的任务主键
|
|
|
|
|
|
|
|
List<Long> pointsList = new ArrayList<>();
|
|
|
|
|
|
|
|
//图片信息不能为空
|
|
|
|
|
|
|
|
if (null != ocrPictureList && !ocrPictureList.isEmpty()) {
|
|
|
|
|
|
|
|
//生成任务包
|
|
|
|
|
|
|
|
//String packageName = seqManageService.getSeqNextNo("AI任务包");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//用于标记相似度是否存在百分百的情况
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<OcrPicture> newList = new ArrayList<>();
|
|
|
|
|
|
|
|
for (OcrPicture ocrPicture : ocrPictureList) {
|
|
|
|
|
|
|
|
//图片查重的比对图片集合
|
|
|
|
|
|
|
|
List<OcrPicture> compareList = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//非历史图片主键集合
|
|
|
|
|
|
|
|
List<String> picturecompareList = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
boolean havePoint = false;
|
|
|
|
|
|
|
|
//二次遍历进行比对
|
|
|
|
|
|
|
|
for (OcrPicture ocrPictureNext : ocrPictureList) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (ocrPictureNext.getId().longValue() == ocrPicture.getId().longValue()) {
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//TODO 接口请求判断重复情况
|
|
|
|
|
|
|
|
JSONObject jsonObjectSimi = ImageClassUtil.getSimilarity(ocrPicture.getImgurl(),
|
|
|
|
|
|
|
|
ocrPictureNext.getImgurl(),
|
|
|
|
|
|
|
|
null);
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
BigDecimal b1 = new BigDecimal(resultValue);
|
|
|
|
|
|
|
|
BigDecimal b2 = new BigDecimal("100");
|
|
|
|
|
|
|
|
int val = b1.compareTo(b2);
|
|
|
|
|
|
|
|
if (val == 0) {
|
|
|
|
|
|
|
|
havePoint = true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//如果当前图片未生成任务需要临时保存
|
|
|
|
|
|
|
|
if (ocrPictureNext.getTaskstatus().equals("0")) {
|
|
|
|
|
|
|
|
picturecompareList.add(ocrPictureNext.getId().toString());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
compareList.add(ocrPictureNext);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
bubbleSortOpt(compareList);
|
|
|
|
|
|
|
|
//从大到小进行排序
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
UserToken userToken = new UserToken();
|
|
|
|
|
|
|
|
userToken.setLoginname("admin");
|
|
|
|
|
|
|
|
userToken.setUsername("admin");
|
|
|
|
|
|
|
|
//创建工单,如果创建成功,增加标志,用于过滤条件使用
|
|
|
|
|
|
|
|
OcrTaskchildPicture ocrTaskchildPicture = this.ocrTaskchildPictureService.create(ocrPicture, tenantId, userToken, null, null);
|
|
|
|
|
|
|
|
if (null != ocrTaskchildPicture) {
|
|
|
|
|
|
|
|
//发起流程
|
|
|
|
|
|
|
|
MockHttpServletRequest request = new MockHttpServletRequest();
|
|
|
|
|
|
|
|
RequestContextHolder.setRequestAttributes(new ServletRequestAttributes(request));
|
|
|
|
|
|
|
|
flowInstanceService.startProcessInstanceById(
|
|
|
|
|
|
|
|
category.getProcessdefinitionid(),
|
|
|
|
|
|
|
|
null,
|
|
|
|
|
|
|
|
request,
|
|
|
|
|
|
|
|
ocrTaskchildPicture.getId().toString(),
|
|
|
|
|
|
|
|
category.getServicename()
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (havePoint) {
|
|
|
|
|
|
|
|
pointsList.add(ocrTaskchildPicture.getId());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//TODO 需要测试
|
|
|
|
|
|
|
|
ocrPicture.setTaskchildpictureid(ocrTaskchildPicture.getId().toString());
|
|
|
|
|
|
|
|
ocrPicture.setWorkStatus("1");
|
|
|
|
|
|
|
|
this.updateById(ocrPicture);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
newList.add(ocrPicture);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//批量更新 pointsList 主键相似度为百分百的数据
|
|
|
|
|
|
|
|
if (null != pointsList && !pointsList.isEmpty()) {
|
|
|
|
|
|
|
|
this.ocrTaskchildPictureService.markPoint(pointsList);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//原主图设置为任务包已经生成
|
|
|
|
|
|
|
|
for (OcrPicture ocrPicture : newList) {
|
|
|
|
ocrPicture.setTaskstatus("1");
|
|
|
|
ocrPicture.setTaskstatus("1");
|
|
|
|
this.updateById(ocrPicture);
|
|
|
|
this.updateById(ocrPicture);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if(StringUtils.isBlank(error) && StringUtils.isBlank(errorProject) && StringUtils.isBlank(errorFlow)){
|
|
|
|
if (StringUtils.isBlank(error) && StringUtils.isBlank(errorProject) && StringUtils.isBlank(errorFlow)) {
|
|
|
|
return ResultVoUtil.success();
|
|
|
|
return ResultVoUtil.success();
|
|
|
|
}else{
|
|
|
|
} else {
|
|
|
|
|
|
|
|
|
|
|
|
String msg = (StringUtils.isBlank(error))?"":error.toString() + ",图片没有对应项目,无法查重。";
|
|
|
|
String msg = (StringUtils.isBlank(error)) ? "" : error.toString() + ",图片没有对应项目,无法查重。";
|
|
|
|
msg = msg + ((StringUtils.isBlank(errorProject))?"":errorProject.toString() + ",图片没有对应项目,无法查重。");
|
|
|
|
msg = msg + ((StringUtils.isBlank(errorProject)) ? "" : errorProject.toString() + ",图片没有对应项目,无法查重。");
|
|
|
|
msg = msg + ((StringUtils.isBlank(errorFlow))?"":errorFlow.toString() + ",项目没有配置审批流程,无法查重。");
|
|
|
|
msg = msg + ((StringUtils.isBlank(errorFlow)) ? "" : errorFlow.toString() + ",项目没有配置审批流程,无法查重。");
|
|
|
|
return ResultVoUtil.success(msg);
|
|
|
|
return ResultVoUtil.success(msg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -278,71 +426,75 @@ public class OcrPictureServiceImpl extends BaseServiceImpl<OcrPictureMybatisDao,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ResultVoUtil.error("失败。");
|
|
|
|
return ResultVoUtil.error("失败。");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void bubbleSortOpt(List<OcrPicture> compareList) {
|
|
|
|
public void bubbleSortOpt(List<OcrPicture> compareList) {
|
|
|
|
|
|
|
|
|
|
|
|
if(null == compareList) {
|
|
|
|
if (null == compareList) {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
OcrPicture temp = null;
|
|
|
|
OcrPicture temp = null;
|
|
|
|
for(int i = 0; i < compareList.size() - 1; i++) {
|
|
|
|
for (int i = 0; i < compareList.size() - 1; i++) {
|
|
|
|
for(int j = 0; j < compareList.size() - i - 1; j++) {
|
|
|
|
for (int j = 0; j < compareList.size() - i - 1; j++) {
|
|
|
|
if(Double.parseDouble(compareList.get(j).getResult()) < Double.parseDouble(compareList.get(j + 1).getResult())) {
|
|
|
|
if (Double.parseDouble(compareList.get(j).getResult()) < Double.parseDouble(compareList.get(j + 1).getResult())) {
|
|
|
|
temp = compareList.get(j);
|
|
|
|
temp = compareList.get(j);
|
|
|
|
compareList.set(j,compareList.get(j + 1));
|
|
|
|
compareList.set(j, compareList.get(j + 1));
|
|
|
|
compareList.set((j + 1),temp);
|
|
|
|
compareList.set((j + 1), temp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 保存接口传来的json数据
|
|
|
|
* 保存接口传来的json数据
|
|
|
|
|
|
|
|
*
|
|
|
|
* @param jsonArray
|
|
|
|
* @param jsonArray
|
|
|
|
* @return
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public List<OcrPicture> savePicture(JSONObject jsonArray){
|
|
|
|
public List<OcrPicture> savePicture(JSONObject jsonArray) {
|
|
|
|
List<OcrPicture> list = new ArrayList<>();
|
|
|
|
List<OcrPicture> list = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return list;
|
|
|
|
return list;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
public List<OcrPicture> listPage( Wrapper<OcrPicture> queryWrapper){
|
|
|
|
|
|
|
|
|
|
|
|
public List<OcrPicture> listPage(Wrapper<OcrPicture> queryWrapper) {
|
|
|
|
|
|
|
|
|
|
|
|
long count = this.count(queryWrapper);
|
|
|
|
long count = this.count(queryWrapper);
|
|
|
|
|
|
|
|
|
|
|
|
Page<OcrPicture> ocrPicturePage = new Page<>(1,count);
|
|
|
|
Page<OcrPicture> ocrPicturePage = new Page<>(1, count);
|
|
|
|
ocrPicturePage.setMaxLimit(count);
|
|
|
|
ocrPicturePage.setMaxLimit(count);
|
|
|
|
IPage<OcrPicture> iPage = this.page(ocrPicturePage,queryWrapper);
|
|
|
|
IPage<OcrPicture> iPage = this.page(ocrPicturePage, queryWrapper);
|
|
|
|
|
|
|
|
|
|
|
|
return iPage.getRecords();
|
|
|
|
return iPage.getRecords();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public List<OcrPicture> listByTaskChild(String tenantId,String createuser,String isclose,String tasktype,String packageid){
|
|
|
|
public List<OcrPicture> listByTaskChild(String tenantId, String createuser, String isclose, String tasktype, String packageid) {
|
|
|
|
|
|
|
|
|
|
|
|
List<OcrPicture> resultPicture = new ArrayList<>();
|
|
|
|
List<OcrPicture> resultPicture = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
|
|
QueryWrapper queryWrapper = new QueryWrapper();
|
|
|
|
QueryWrapper queryWrapper = new QueryWrapper();
|
|
|
|
queryWrapper.eq("TENANTID",tenantId);
|
|
|
|
queryWrapper.eq("TENANTID", tenantId);
|
|
|
|
if(StringUtils.isNotBlank(createuser)){
|
|
|
|
if (StringUtils.isNotBlank(createuser)) {
|
|
|
|
queryWrapper.eq("CREATEUSER",createuser);
|
|
|
|
queryWrapper.eq("CREATEUSER", createuser);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if(StringUtils.isNotBlank(isclose)){
|
|
|
|
if (StringUtils.isNotBlank(isclose)) {
|
|
|
|
queryWrapper.eq("IZCLOSE",isclose);
|
|
|
|
queryWrapper.eq("IZCLOSE", isclose);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if(StringUtils.isNotBlank(tasktype)){
|
|
|
|
if (StringUtils.isNotBlank(tasktype)) {
|
|
|
|
queryWrapper.eq("TASKTYPE",tasktype);
|
|
|
|
queryWrapper.eq("TASKTYPE", tasktype);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if(StringUtils.isNotBlank(packageid)){
|
|
|
|
if (StringUtils.isNotBlank(packageid)) {
|
|
|
|
queryWrapper.eq("PACKAGEID",packageid);
|
|
|
|
queryWrapper.eq("PACKAGEID", packageid);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//查询工单/任务集合
|
|
|
|
//查询工单/任务集合
|
|
|
|
List<OcrTaskchildPicture> list = ocrTaskchildPictureService.listAll(tenantId,createuser,queryWrapper);
|
|
|
|
List<OcrTaskchildPicture> list = ocrTaskchildPictureService.listAll(tenantId, createuser, queryWrapper);
|
|
|
|
for(OcrTaskchildPicture ocrTaskchildPicture:list){
|
|
|
|
for (OcrTaskchildPicture ocrTaskchildPicture : list) {
|
|
|
|
OcrPicture ocrPicture = view(ocrTaskchildPicture);
|
|
|
|
OcrPicture ocrPicture = view(ocrTaskchildPicture);
|
|
|
|
if(null != ocrPicture){
|
|
|
|
if (null != ocrPicture) {
|
|
|
|
resultPicture.add(view(ocrTaskchildPicture));
|
|
|
|
resultPicture.add(view(ocrTaskchildPicture));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -353,25 +505,26 @@ public class OcrPictureServiceImpl extends BaseServiceImpl<OcrPictureMybatisDao,
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 查询工单图片信息
|
|
|
|
* 查询工单图片信息
|
|
|
|
|
|
|
|
*
|
|
|
|
* @return
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public List<OcrPicture> listByTaskChild(List<String> pictureidlist){
|
|
|
|
public List<OcrPicture> listByTaskChild(List<String> pictureidlist) {
|
|
|
|
List<OcrPicture> resultPicture = new ArrayList<>();
|
|
|
|
List<OcrPicture> resultPicture = new ArrayList<>();
|
|
|
|
//查询工单集合
|
|
|
|
//查询工单集合
|
|
|
|
QueryWrapper queryWrapper = new QueryWrapper();
|
|
|
|
QueryWrapper queryWrapper = new QueryWrapper();
|
|
|
|
queryWrapper.in("pictureid",pictureidlist);
|
|
|
|
queryWrapper.in("pictureid", pictureidlist);
|
|
|
|
|
|
|
|
|
|
|
|
long count = this.ocrTaskchildPictureService.count(queryWrapper);
|
|
|
|
long count = this.ocrTaskchildPictureService.count(queryWrapper);
|
|
|
|
|
|
|
|
|
|
|
|
Page<OcrTaskchildPicture> page = new Page<>(1, count);
|
|
|
|
Page<OcrTaskchildPicture> page = new Page<>(1, count);
|
|
|
|
page.setMaxLimit(count);
|
|
|
|
page.setMaxLimit(count);
|
|
|
|
|
|
|
|
|
|
|
|
IPage<OcrTaskchildPicture> iPage = this.ocrTaskchildPictureService.page(page,queryWrapper);
|
|
|
|
IPage<OcrTaskchildPicture> iPage = this.ocrTaskchildPictureService.page(page, queryWrapper);
|
|
|
|
|
|
|
|
|
|
|
|
List<OcrTaskchildPicture> list = iPage.getRecords();
|
|
|
|
List<OcrTaskchildPicture> list = iPage.getRecords();
|
|
|
|
for(OcrTaskchildPicture ocrTaskchildPicture:list){
|
|
|
|
for (OcrTaskchildPicture ocrTaskchildPicture : list) {
|
|
|
|
OcrPicture ocrPicture = view(ocrTaskchildPicture);
|
|
|
|
OcrPicture ocrPicture = view(ocrTaskchildPicture);
|
|
|
|
if(null != ocrPicture){
|
|
|
|
if (null != ocrPicture) {
|
|
|
|
resultPicture.add(view(ocrTaskchildPicture));
|
|
|
|
resultPicture.add(view(ocrTaskchildPicture));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -381,10 +534,11 @@ public class OcrPictureServiceImpl extends BaseServiceImpl<OcrPictureMybatisDao,
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 查询工单下的图片以及查重结果
|
|
|
|
* 查询工单下的图片以及查重结果
|
|
|
|
|
|
|
|
*
|
|
|
|
* @param ocrTaskchildPicture
|
|
|
|
* @param ocrTaskchildPicture
|
|
|
|
* @return
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public OcrPicture view(OcrTaskchildPicture ocrTaskchildPicture){
|
|
|
|
public OcrPicture view(OcrTaskchildPicture ocrTaskchildPicture) {
|
|
|
|
|
|
|
|
|
|
|
|
//参照图
|
|
|
|
//参照图
|
|
|
|
OcrPicture ocrPicture = this.getById(ocrTaskchildPicture.getPictureid());
|
|
|
|
OcrPicture ocrPicture = this.getById(ocrTaskchildPicture.getPictureid());
|
|
|
@ -399,24 +553,24 @@ public class OcrPictureServiceImpl extends BaseServiceImpl<OcrPictureMybatisDao,
|
|
|
|
List<OcrPicture> listCom = null;
|
|
|
|
List<OcrPicture> listCom = null;
|
|
|
|
|
|
|
|
|
|
|
|
//判断查重图片是否为空
|
|
|
|
//判断查重图片是否为空
|
|
|
|
if(StringUtils.isNotBlank(ocrTaskchildPicture.getOcpictureid())){
|
|
|
|
if (StringUtils.isNotBlank(ocrTaskchildPicture.getOcpictureid())) {
|
|
|
|
//图片比较数量不确定
|
|
|
|
//图片比较数量不确定
|
|
|
|
|
|
|
|
|
|
|
|
QueryWrapper queryWrapper = new QueryWrapper();
|
|
|
|
QueryWrapper queryWrapper = new QueryWrapper();
|
|
|
|
queryWrapper.in("id",ocrTaskchildPicture.getOcpictureid().split(","));
|
|
|
|
queryWrapper.in("id", ocrTaskchildPicture.getOcpictureid().split(","));
|
|
|
|
|
|
|
|
|
|
|
|
long count = this.count(queryWrapper);
|
|
|
|
long count = this.count(queryWrapper);
|
|
|
|
|
|
|
|
|
|
|
|
Page<OcrPicture> ocrPicturePage = new Page<>(1,count);
|
|
|
|
Page<OcrPicture> ocrPicturePage = new Page<>(1, count);
|
|
|
|
ocrPicturePage.setMaxLimit(count);
|
|
|
|
ocrPicturePage.setMaxLimit(count);
|
|
|
|
|
|
|
|
|
|
|
|
IPage<OcrPicture> iPage = this.page(ocrPicturePage,queryWrapper);
|
|
|
|
IPage<OcrPicture> iPage = this.page(ocrPicturePage, queryWrapper);
|
|
|
|
|
|
|
|
|
|
|
|
int tempco = 0;
|
|
|
|
int tempco = 0;
|
|
|
|
for(OcrPicture ocrPicture1:iPage.getRecords()){
|
|
|
|
for (OcrPicture ocrPicture1 : iPage.getRecords()) {
|
|
|
|
|
|
|
|
|
|
|
|
//比对结果
|
|
|
|
//比对结果
|
|
|
|
if(null != comResult && comResult.length > 0){
|
|
|
|
if (null != comResult && comResult.length > 0) {
|
|
|
|
ocrPicture1.setResult(comResult[tempco]);
|
|
|
|
ocrPicture1.setResult(comResult[tempco]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
tempco++;
|
|
|
|
tempco++;
|
|
|
@ -437,15 +591,15 @@ public class OcrPictureServiceImpl extends BaseServiceImpl<OcrPictureMybatisDao,
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
public void saveMain(OcrPicture ocrPicture, List<OcrPicturejob> ocrPicturejobList, List<OcrPictureNotes> ocrPictureNotesList) {
|
|
|
|
public void saveMain(OcrPicture ocrPicture, List<OcrPicturejob> ocrPicturejobList, List<OcrPictureNotes> ocrPictureNotesList) {
|
|
|
|
ocrpicturemybatisdao.insert(ocrPicture);
|
|
|
|
ocrpicturemybatisdao.insert(ocrPicture);
|
|
|
|
if(ocrPicturejobList!=null && ocrPicturejobList.size()>0) {
|
|
|
|
if (ocrPicturejobList != null && ocrPicturejobList.size() > 0) {
|
|
|
|
for(OcrPicturejob entity:ocrPicturejobList) {
|
|
|
|
for (OcrPicturejob entity : ocrPicturejobList) {
|
|
|
|
//外键设置
|
|
|
|
//外键设置
|
|
|
|
entity.setPictureid(ocrPicture.getId());
|
|
|
|
entity.setPictureid(ocrPicture.getId());
|
|
|
|
ocrPicturejobService.save(entity);
|
|
|
|
ocrPicturejobService.save(entity);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(ocrPictureNotesList!=null && ocrPictureNotesList.size()>0) {
|
|
|
|
if (ocrPictureNotesList != null && ocrPictureNotesList.size() > 0) {
|
|
|
|
for(OcrPictureNotes entity:ocrPictureNotesList) {
|
|
|
|
for (OcrPictureNotes entity : ocrPictureNotesList) {
|
|
|
|
//外键设置
|
|
|
|
//外键设置
|
|
|
|
entity.setPictureid(ocrPicture.getId());
|
|
|
|
entity.setPictureid(ocrPicture.getId());
|
|
|
|
ocrPictureNotesService.save(entity);
|
|
|
|
ocrPictureNotesService.save(entity);
|
|
|
@ -455,23 +609,23 @@ public class OcrPictureServiceImpl extends BaseServiceImpl<OcrPictureMybatisDao,
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
public void updateMain(OcrPicture ocrPicture,List<OcrPicturejob> ocrPicturejobList,List<OcrPictureNotes> ocrPictureNotesList) {
|
|
|
|
public void updateMain(OcrPicture ocrPicture, List<OcrPicturejob> ocrPicturejobList, List<OcrPictureNotes> ocrPictureNotesList) {
|
|
|
|
ocrpicturemybatisdao.updateById(ocrPicture);
|
|
|
|
ocrpicturemybatisdao.updateById(ocrPicture);
|
|
|
|
|
|
|
|
|
|
|
|
//1.先删除子表数据
|
|
|
|
//1.先删除子表数据
|
|
|
|
ocrPicturejobService .deleteByMainId(ocrPicture.getId().toString());
|
|
|
|
ocrPicturejobService.deleteByMainId(ocrPicture.getId().toString());
|
|
|
|
ocrPictureNotesService.deleteByMainId(ocrPicture.getId().toString());
|
|
|
|
ocrPictureNotesService.deleteByMainId(ocrPicture.getId().toString());
|
|
|
|
|
|
|
|
|
|
|
|
//2.子表数据重新插入
|
|
|
|
//2.子表数据重新插入
|
|
|
|
if(ocrPicturejobList!=null && ocrPicturejobList.size()>0) {
|
|
|
|
if (ocrPicturejobList != null && ocrPicturejobList.size() > 0) {
|
|
|
|
for(OcrPicturejob entity:ocrPicturejobList) {
|
|
|
|
for (OcrPicturejob entity : ocrPicturejobList) {
|
|
|
|
//外键设置
|
|
|
|
//外键设置
|
|
|
|
entity.setPictureid(ocrPicture.getId());
|
|
|
|
entity.setPictureid(ocrPicture.getId());
|
|
|
|
ocrPicturejobService.save(entity);
|
|
|
|
ocrPicturejobService.save(entity);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(ocrPictureNotesList!=null && ocrPictureNotesList.size()>0) {
|
|
|
|
if (ocrPictureNotesList != null && ocrPictureNotesList.size() > 0) {
|
|
|
|
for(OcrPictureNotes entity:ocrPictureNotesList) {
|
|
|
|
for (OcrPictureNotes entity : ocrPictureNotesList) {
|
|
|
|
//外键设置
|
|
|
|
//外键设置
|
|
|
|
entity.setPictureid(ocrPicture.getId());
|
|
|
|
entity.setPictureid(ocrPicture.getId());
|
|
|
|
ocrPictureNotesService.save(entity);
|
|
|
|
ocrPictureNotesService.save(entity);
|
|
|
@ -490,7 +644,7 @@ public class OcrPictureServiceImpl extends BaseServiceImpl<OcrPictureMybatisDao,
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
public void delBatchMain(Collection<? extends Serializable> idList) {
|
|
|
|
public void delBatchMain(Collection<? extends Serializable> idList) {
|
|
|
|
for(Serializable id:idList) {
|
|
|
|
for (Serializable id : idList) {
|
|
|
|
ocrPicturejobService.deleteByMainId(id.toString());
|
|
|
|
ocrPicturejobService.deleteByMainId(id.toString());
|
|
|
|
ocrPictureNotesService.deleteByMainId(id.toString());
|
|
|
|
ocrPictureNotesService.deleteByMainId(id.toString());
|
|
|
|
ocrpicturemybatisdao.deleteById(id);
|
|
|
|
ocrpicturemybatisdao.deleteById(id);
|
|
|
@ -499,20 +653,20 @@ public class OcrPictureServiceImpl extends BaseServiceImpl<OcrPictureMybatisDao,
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public IPage<OcrPicture> queryPageByUserSearchId(Integer pageNo, Integer pageSize, String userSearchId) {
|
|
|
|
public IPage<OcrPicture> queryPageByUserSearchId(Integer pageNo, Integer pageSize, String userSearchId) {
|
|
|
|
OcrUsersearch ocrUsersearch= ocrUsersearchService.selectByUserSearchId(userSearchId);
|
|
|
|
OcrUsersearch ocrUsersearch = ocrUsersearchService.selectByUserSearchId(userSearchId);
|
|
|
|
|
|
|
|
|
|
|
|
QueryWrapper<OcrPicture> queryWrapper = new QueryWrapper();
|
|
|
|
QueryWrapper<OcrPicture> queryWrapper = new QueryWrapper();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (OcrUsersearchchild usersearchchild : ocrUsersearch.getOcrUsersearchchildList()) {
|
|
|
|
for (OcrUsersearchchild usersearchchild : ocrUsersearch.getOcrUsersearchchildList()) {
|
|
|
|
this.formattingSearchChild(queryWrapper,usersearchchild);
|
|
|
|
this.formattingSearchChild(queryWrapper, usersearchchild);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//分页查询并组装子集数据
|
|
|
|
//分页查询并组装子集数据
|
|
|
|
Page<OcrPicture> page = new Page<OcrPicture>(pageNo, pageSize);
|
|
|
|
Page<OcrPicture> page = new Page<OcrPicture>(pageNo, pageSize);
|
|
|
|
IPage<OcrPicture> pageList = this.page(page, queryWrapper);
|
|
|
|
IPage<OcrPicture> pageList = this.page(page, queryWrapper);
|
|
|
|
for(OcrPicture ocrPicture1:pageList.getRecords()){
|
|
|
|
for (OcrPicture ocrPicture1 : pageList.getRecords()) {
|
|
|
|
if(StringUtils.isNotBlank(ocrPicture1.getPictureclassid())){
|
|
|
|
if (StringUtils.isNotBlank(ocrPicture1.getPictureclassid())) {
|
|
|
|
OcrPictureclass ocrPictureclass = ocrPictureclassService.getById(ocrPicture1.getPictureclassid());
|
|
|
|
OcrPictureclass ocrPictureclass = ocrPictureclassService.getById(ocrPicture1.getPictureclassid());
|
|
|
|
ocrPicture1.setOcrPictureclass(ocrPictureclass);
|
|
|
|
ocrPicture1.setOcrPictureclass(ocrPictureclass);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -530,13 +684,14 @@ public class OcrPictureServiceImpl extends BaseServiceImpl<OcrPictureMybatisDao,
|
|
|
|
//2.调整图片地址,补齐域名
|
|
|
|
//2.调整图片地址,补齐域名
|
|
|
|
for (OcrPicture picture : ocrPictureList) {
|
|
|
|
for (OcrPicture picture : ocrPictureList) {
|
|
|
|
picture.setCreateTime(System.currentTimeMillis()); //获取创建时间戳
|
|
|
|
picture.setCreateTime(System.currentTimeMillis()); //获取创建时间戳
|
|
|
|
picture.setImgurl(interfaceDomain+picture.getImgurl());
|
|
|
|
picture.setImgurl(interfaceDomain + picture.getImgurl());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//3.添加图片信息
|
|
|
|
//3.添加图片信息
|
|
|
|
if(this.saveBatch(ocrPictureList)){
|
|
|
|
if (this.saveBatch(ocrPictureList)) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.createTaskChild(ocrPictureList, ocrPictureList.get(0).getTenantId().toString());
|
|
|
|
return ocrPictureList.size();
|
|
|
|
return ocrPictureList.size();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
@ -544,20 +699,21 @@ public class OcrPictureServiceImpl extends BaseServiceImpl<OcrPictureMybatisDao,
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 格式化筛选关系
|
|
|
|
* 格式化筛选关系
|
|
|
|
|
|
|
|
*
|
|
|
|
* @param queryWrapper
|
|
|
|
* @param queryWrapper
|
|
|
|
* @param usersearchchild
|
|
|
|
* @param usersearchchild
|
|
|
|
* @return
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
private QueryWrapper<OcrPicture> formattingSearchChild(QueryWrapper<OcrPicture> queryWrapper,OcrUsersearchchild usersearchchild ){
|
|
|
|
private QueryWrapper<OcrPicture> formattingSearchChild(QueryWrapper<OcrPicture> queryWrapper, OcrUsersearchchild usersearchchild) {
|
|
|
|
switch (usersearchchild.getSearchRelationType()){
|
|
|
|
switch (usersearchchild.getSearchRelationType()) {
|
|
|
|
case "where":
|
|
|
|
case "where":
|
|
|
|
this.formattingSearchType(queryWrapper,usersearchchild);
|
|
|
|
this.formattingSearchType(queryWrapper, usersearchchild);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case "and":
|
|
|
|
case "and":
|
|
|
|
queryWrapper.and(wrapper->this.formattingSearchType(wrapper,usersearchchild));
|
|
|
|
queryWrapper.and(wrapper -> this.formattingSearchType(wrapper, usersearchchild));
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case "or":
|
|
|
|
case "or":
|
|
|
|
queryWrapper.or(wrapper->this.formattingSearchType(wrapper,usersearchchild));
|
|
|
|
queryWrapper.or(wrapper -> this.formattingSearchType(wrapper, usersearchchild));
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
default:
|
|
|
|
return queryWrapper;
|
|
|
|
return queryWrapper;
|
|
|
@ -567,98 +723,99 @@ public class OcrPictureServiceImpl extends BaseServiceImpl<OcrPictureMybatisDao,
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 格式化查询类型
|
|
|
|
* 格式化查询类型
|
|
|
|
|
|
|
|
*
|
|
|
|
* @param queryWrapper
|
|
|
|
* @param queryWrapper
|
|
|
|
* @param usersearchchild
|
|
|
|
* @param usersearchchild
|
|
|
|
* @return
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
private QueryWrapper<OcrPicture> formattingSearchType(QueryWrapper<OcrPicture> queryWrapper,OcrUsersearchchild usersearchchild){
|
|
|
|
private QueryWrapper<OcrPicture> formattingSearchType(QueryWrapper<OcrPicture> queryWrapper, OcrUsersearchchild usersearchchild) {
|
|
|
|
//查询类型 相等true 不相等fase
|
|
|
|
//查询类型 相等true 不相等fase
|
|
|
|
boolean queryType = "eq".equals(usersearchchild.getSearchtype());
|
|
|
|
boolean queryType = "eq".equals(usersearchchild.getSearchtype());
|
|
|
|
|
|
|
|
|
|
|
|
//1.获取检查数据,确定数据类型
|
|
|
|
//1.获取检查数据,确定数据类型
|
|
|
|
String valueType = SearchParaFormatting.clickSearchValue(usersearchchild.getSearchvalue());
|
|
|
|
String valueType = SearchParaFormatting.clickSearchValue(usersearchchild.getSearchvalue());
|
|
|
|
List<String> arrayData = null; //集合型数据
|
|
|
|
List<String> arrayData = null; //集合型数据
|
|
|
|
List<Integer> sectionInts =null; //纯数字区间型数据
|
|
|
|
List<Integer> sectionInts = null; //纯数字区间型数据
|
|
|
|
String[] sections =null; //字符串区间型数据
|
|
|
|
String[] sections = null; //字符串区间型数据
|
|
|
|
DateTime beginTime =null; //日期时间区间型数据
|
|
|
|
DateTime beginTime = null; //日期时间区间型数据
|
|
|
|
DateTime endTime=null; //日期时间区间型数据
|
|
|
|
DateTime endTime = null; //日期时间区间型数据
|
|
|
|
|
|
|
|
|
|
|
|
//2.根据数据类型,解构数据
|
|
|
|
//2.根据数据类型,解构数据
|
|
|
|
switch (valueType){
|
|
|
|
switch (valueType) {
|
|
|
|
case "array":
|
|
|
|
case "array":
|
|
|
|
//处理多文件
|
|
|
|
//处理多文件
|
|
|
|
String [] datas =usersearchchild.getSearchvalue().split(",");
|
|
|
|
String[] datas = usersearchchild.getSearchvalue().split(",");
|
|
|
|
arrayData = Arrays.asList(datas);
|
|
|
|
arrayData = Arrays.asList(datas);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case "section":
|
|
|
|
case "section":
|
|
|
|
//格式化数据,仅在做区间的时候去除空格,其他地方不进行空格去除.
|
|
|
|
//格式化数据,仅在做区间的时候去除空格,其他地方不进行空格去除.
|
|
|
|
sections =usersearchchild.getSearchvalue().trim().replaceAll("\\s+", "").split("-");
|
|
|
|
sections = usersearchchild.getSearchvalue().trim().replaceAll("\\s+", "").split("-");
|
|
|
|
//校验是否纯数字,纯数字的话,要转成int,否则比对时会有问题
|
|
|
|
//校验是否纯数字,纯数字的话,要转成int,否则比对时会有问题
|
|
|
|
sectionInts= new ArrayList<>();
|
|
|
|
sectionInts = new ArrayList<>();
|
|
|
|
for (String data : sections) {
|
|
|
|
for (String data : sections) {
|
|
|
|
if(data.matches("\\d+")){
|
|
|
|
if (data.matches("\\d+")) {
|
|
|
|
sectionInts.add(Integer.parseInt(data));
|
|
|
|
sectionInts.add(Integer.parseInt(data));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case "time":
|
|
|
|
case "time":
|
|
|
|
//格式化时间数据
|
|
|
|
//格式化时间数据
|
|
|
|
String[] times =usersearchchild.getSearchvalue().trim().replaceAll("\\s+", "").split("-");
|
|
|
|
String[] times = usersearchchild.getSearchvalue().trim().replaceAll("\\s+", "").split("-");
|
|
|
|
beginTime = DateUtil.parse(times[0],"yyyy/MM/dd");
|
|
|
|
beginTime = DateUtil.parse(times[0], "yyyy/MM/dd");
|
|
|
|
endTime = DateUtil.parse(times[1],"yyyy/MM/dd");
|
|
|
|
endTime = DateUtil.parse(times[1], "yyyy/MM/dd");
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
default:
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//3.根据查询类型 组装查询条件 相等
|
|
|
|
//3.根据查询类型 组装查询条件 相等
|
|
|
|
switch (valueType){
|
|
|
|
switch (valueType) {
|
|
|
|
case "array":
|
|
|
|
case "array":
|
|
|
|
//集合数据
|
|
|
|
//集合数据
|
|
|
|
//相等
|
|
|
|
//相等
|
|
|
|
if(queryType){
|
|
|
|
if (queryType) {
|
|
|
|
queryWrapper.in(usersearchchild.getSearchfield(),arrayData);
|
|
|
|
queryWrapper.in(usersearchchild.getSearchfield(), arrayData);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//不相等
|
|
|
|
//不相等
|
|
|
|
queryWrapper.notIn(usersearchchild.getSearchfield(),arrayData);
|
|
|
|
queryWrapper.notIn(usersearchchild.getSearchfield(), arrayData);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
case "section":
|
|
|
|
case "section":
|
|
|
|
//数字区间查询
|
|
|
|
//数字区间查询
|
|
|
|
if(sectionInts!=null && sectionInts.size()==2){
|
|
|
|
if (sectionInts != null && sectionInts.size() == 2) {
|
|
|
|
if(queryType) {
|
|
|
|
if (queryType) {
|
|
|
|
//相等
|
|
|
|
//相等
|
|
|
|
queryWrapper.between(usersearchchild.getSearchfield(),sectionInts.get(0),sectionInts.get(1));
|
|
|
|
queryWrapper.between(usersearchchild.getSearchfield(), sectionInts.get(0), sectionInts.get(1));
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//不相等
|
|
|
|
//不相等
|
|
|
|
queryWrapper.notBetween(usersearchchild.getSearchfield(),sectionInts.get(0),sectionInts.get(1));
|
|
|
|
queryWrapper.notBetween(usersearchchild.getSearchfield(), sectionInts.get(0), sectionInts.get(1));
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//字符串区间查询
|
|
|
|
//字符串区间查询
|
|
|
|
if(queryType) {
|
|
|
|
if (queryType) {
|
|
|
|
//相等
|
|
|
|
//相等
|
|
|
|
queryWrapper.between(usersearchchild.getSearchfield(),sections[0],sections[1]);
|
|
|
|
queryWrapper.between(usersearchchild.getSearchfield(), sections[0], sections[1]);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//不相等
|
|
|
|
//不相等
|
|
|
|
queryWrapper.notBetween(usersearchchild.getSearchfield(),sections[0],sections[1]);
|
|
|
|
queryWrapper.notBetween(usersearchchild.getSearchfield(), sections[0], sections[1]);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
case "time":
|
|
|
|
case "time":
|
|
|
|
//时间区间数据
|
|
|
|
//时间区间数据
|
|
|
|
//相等
|
|
|
|
//相等
|
|
|
|
if(queryType) {
|
|
|
|
if (queryType) {
|
|
|
|
queryWrapper.between(usersearchchild.getSearchfield(),beginTime.getTime(),endTime.getTime());
|
|
|
|
queryWrapper.between(usersearchchild.getSearchfield(), beginTime.getTime(), endTime.getTime());
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//不相等
|
|
|
|
//不相等
|
|
|
|
queryWrapper.notBetween(usersearchchild.getSearchfield(),beginTime.getTime(),endTime.getTime());
|
|
|
|
queryWrapper.notBetween(usersearchchild.getSearchfield(), beginTime.getTime(), endTime.getTime());
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
default:
|
|
|
|
if(queryType) {
|
|
|
|
if (queryType) {
|
|
|
|
queryWrapper.eq(usersearchchild.getSearchfield(), usersearchchild.getSearchvalue());
|
|
|
|
queryWrapper.eq(usersearchchild.getSearchfield(), usersearchchild.getSearchvalue());
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|