|
|
|
@ -1,5 +1,7 @@
|
|
|
|
|
package cn.jyjz.xiaoyao.ocr.service.impl;
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.date.DateTime;
|
|
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
|
|
import cn.jyjz.flowable.domain.vo.FlowInstanceVo;
|
|
|
|
|
import cn.jyjz.flowable.service.IFlowInstanceService;
|
|
|
|
|
import cn.jyjz.xiaoyao.abase.service.SeqManageService;
|
|
|
|
@ -23,6 +25,8 @@ import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
|
|
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.poi.hpsf.Decimal;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
@ -37,6 +41,7 @@ import java.io.Serializable;
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
|
import java.text.DecimalFormat;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Arrays;
|
|
|
|
|
import java.util.Collection;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
/**
|
|
|
|
@ -47,12 +52,12 @@ import java.util.List;
|
|
|
|
|
public class OcrPictureServiceImpl extends BaseServiceImpl<OcrPictureMybatisDao, OcrPicture> implements OcrPictureService {
|
|
|
|
|
@Resource
|
|
|
|
|
private OcrPictureMybatisDao ocrpicturemybatisdao;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
private OcrPicturejobService ocrPicturejobService;
|
|
|
|
|
@Resource
|
|
|
|
|
private OcrPictureNotesService ocrPictureNotesService;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
private OcrPackagetaskService ocrPackagetaskService;
|
|
|
|
|
@Resource
|
|
|
|
@ -63,102 +68,108 @@ public class OcrPictureServiceImpl extends BaseServiceImpl<OcrPictureMybatisDao,
|
|
|
|
|
private OcrTaskchildPictureService ocrTaskchildPictureService;
|
|
|
|
|
@Resource
|
|
|
|
|
IFlowInstanceService flowInstanceService;
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
private OcrUsersearchService ocrUsersearchService;
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
private OcrPictureclassService ocrPictureclassService;
|
|
|
|
|
@Resource
|
|
|
|
|
private CategoryService categoryService;
|
|
|
|
|
public ResultVo createTaskChild(List<OcrPicture> ocrPictureList, String tenantId , UserToken sysUser, String search_month, HttpServletRequest request, String buessinessno){
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//图片错误信息
|
|
|
|
|
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任务包");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//TODO 相似度、图片查询时间未传
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//创建任务包
|
|
|
|
|
OcrPackagetask ocrPackagetask = this.ocrPackagetaskService.create(buessinessno,tenantId,sysUser);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(null == ocrPackagetask){
|
|
|
|
|
return ResultVoUtil.error("失败。");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//用于标记相似度是否存在百分百的情况
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<OcrPicture> newList = new ArrayList<>();
|
|
|
|
|
for(OcrPicture ocrPicture:ocrPictureList){
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//如果当前图片已经生成任务包,直接跳过
|
|
|
|
|
if(ocrPicture.getTaskstatus().equals("1")){
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//图片查重的比对图片集合
|
|
|
|
|
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 接口请求判断重复情况
|
|
|
|
|
logService.addLog(103,"AI获取图片相似度接口", sysUser, "sendParams");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 没有对应项目,返回提示信息
|
|
|
|
@ -185,11 +196,11 @@ public class OcrPictureServiceImpl extends BaseServiceImpl<OcrPictureMybatisDao,
|
|
|
|
|
}
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//创建工单,如果创建成功,增加标志,用于过滤条件使用
|
|
|
|
|
OcrTaskchildPicture ocrTaskchildPicture = this.ocrTaskchildPictureService.create(ocrPicture,tenantId,sysUser,ocrPackagetask.getId(),buessinessno);
|
|
|
|
|
if(null != ocrTaskchildPicture){
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//发起流程
|
|
|
|
|
flowInstanceService.startProcessInstanceById(
|
|
|
|
|
category.getProcessdefinitionid(),
|
|
|
|
@ -198,29 +209,29 @@ public class OcrPictureServiceImpl extends BaseServiceImpl<OcrPictureMybatisDao,
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(StringUtils.isNotBlank(search_month)){
|
|
|
|
|
if(StringUtils.isNotBlank(search_month) && Integer.parseInt(search_month) <= 12 && Integer.parseInt(search_month) > 0){
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ocrPackagetask.setSearchtimes(SearchEnum.getName(Integer.parseInt(search_month)));
|
|
|
|
|
}else if(StringUtils.isNotBlank(search_month) && Integer.parseInt(search_month) > 20){
|
|
|
|
|
ocrPackagetask.setSearchtimes(SearchEnum.getName((Integer.parseInt(search_month) - 20)));
|
|
|
|
@ -228,29 +239,29 @@ public class OcrPictureServiceImpl extends BaseServiceImpl<OcrPictureMybatisDao,
|
|
|
|
|
}
|
|
|
|
|
ocrPackagetask.setPictureno(ocrPictureList.size());
|
|
|
|
|
this.ocrPackagetaskService.updateById(ocrPackagetask);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//原主图设置为任务包已经生成
|
|
|
|
|
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 void bubbleSortOpt(List<OcrPicture> compareList) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(null == compareList) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
@ -272,43 +283,43 @@ public class OcrPictureServiceImpl extends BaseServiceImpl<OcrPictureMybatisDao,
|
|
|
|
|
*/
|
|
|
|
|
public List<OcrPicture> savePicture(JSONObject jsonArray){
|
|
|
|
|
List<OcrPicture> list = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return list;
|
|
|
|
|
}
|
|
|
|
|
public List<OcrPicture> listPage( Wrapper<OcrPicture> queryWrapper){
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
long count = this.count(queryWrapper);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Page<OcrPicture> ocrPicturePage = new Page<>(1,count);
|
|
|
|
|
ocrPicturePage.setMaxLimit(count);
|
|
|
|
|
IPage<OcrPicture> iPage = this.page(ocrPicturePage,queryWrapper);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return iPage.getRecords();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public List<OcrPicture> listByTaskChild(String tenantId,String createuser,String isclose,String tasktype,String packageid){
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<OcrPicture> resultPicture = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QueryWrapper queryWrapper = new QueryWrapper();
|
|
|
|
|
queryWrapper.eq("TENANTID",tenantId);
|
|
|
|
|
if(StringUtils.isNotBlank(createuser)){
|
|
|
|
|
queryWrapper.eq("CREATEUSER",createuser);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(StringUtils.isNotBlank(isclose)){
|
|
|
|
|
queryWrapper.eq("IZCLOSE",isclose);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(StringUtils.isNotBlank(tasktype)){
|
|
|
|
|
queryWrapper.eq("TASKTYPE",tasktype);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(StringUtils.isNotBlank(packageid)){
|
|
|
|
|
queryWrapper.eq("PACKAGEID",packageid);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//查询工单/任务集合
|
|
|
|
|
List<OcrTaskchildPicture> list = ocrTaskchildPictureService.listAll(tenantId,createuser,queryWrapper);
|
|
|
|
|
for(OcrTaskchildPicture ocrTaskchildPicture:list){
|
|
|
|
@ -317,11 +328,11 @@ public class OcrPictureServiceImpl extends BaseServiceImpl<OcrPictureMybatisDao,
|
|
|
|
|
resultPicture.add(view(ocrTaskchildPicture));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return resultPicture;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 查询工单图片信息
|
|
|
|
|
* @return
|
|
|
|
@ -331,14 +342,14 @@ public class OcrPictureServiceImpl extends BaseServiceImpl<OcrPictureMybatisDao,
|
|
|
|
|
//查询工单集合
|
|
|
|
|
QueryWrapper queryWrapper = new QueryWrapper();
|
|
|
|
|
queryWrapper.in("pictureid",pictureidlist);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
long count = this.ocrTaskchildPictureService.count(queryWrapper);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Page<OcrTaskchildPicture> page = new Page<>(1, count);
|
|
|
|
|
page.setMaxLimit(count);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
IPage<OcrTaskchildPicture> iPage = this.ocrTaskchildPictureService.page(page,queryWrapper);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<OcrTaskchildPicture> list = iPage.getRecords();
|
|
|
|
|
for(OcrTaskchildPicture ocrTaskchildPicture:list){
|
|
|
|
|
OcrPicture ocrPicture = view(ocrTaskchildPicture);
|
|
|
|
@ -346,64 +357,64 @@ public class OcrPictureServiceImpl extends BaseServiceImpl<OcrPictureMybatisDao,
|
|
|
|
|
resultPicture.add(view(ocrTaskchildPicture));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return resultPicture;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 查询工单下的图片以及查重结果
|
|
|
|
|
* @param ocrTaskchildPicture
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public OcrPicture view(OcrTaskchildPicture ocrTaskchildPicture){
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//参照图
|
|
|
|
|
OcrPicture ocrPicture = this.getById(ocrTaskchildPicture.getPictureid());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ocrPicture.setOcrTaskchildPicture(ocrTaskchildPicture);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//图片比对结果
|
|
|
|
|
String result = ocrTaskchildPicture.getPictureresult();
|
|
|
|
|
String[] comResult = result.split(",");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//比较图
|
|
|
|
|
List<OcrPicture> listCom = null;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//判断查重图片是否为空
|
|
|
|
|
if(StringUtils.isNotBlank(ocrTaskchildPicture.getOcpictureid())){
|
|
|
|
|
//图片比较数量不确定
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QueryWrapper queryWrapper = new QueryWrapper();
|
|
|
|
|
queryWrapper.in("id",ocrTaskchildPicture.getOcpictureid().split(","));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
long count = this.count(queryWrapper);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Page<OcrPicture> ocrPicturePage = new Page<>(1,count);
|
|
|
|
|
ocrPicturePage.setMaxLimit(count);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
IPage<OcrPicture> iPage = this.page(ocrPicturePage,queryWrapper);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int tempco = 0;
|
|
|
|
|
for(OcrPicture ocrPicture1:iPage.getRecords()){
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//比对结果
|
|
|
|
|
if(null != comResult && comResult.length > 0){
|
|
|
|
|
ocrPicture1.setResult(comResult[tempco]);
|
|
|
|
|
}
|
|
|
|
|
tempco++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
listCom = iPage.getRecords();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ocrPicture.setListCom(listCom);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return ocrPicture;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
|
public void saveMain(OcrPicture ocrPicture, List<OcrPicturejob> ocrPicturejobList, List<OcrPictureNotes> ocrPictureNotesList) {
|
|
|
|
@ -423,16 +434,16 @@ public class OcrPictureServiceImpl extends BaseServiceImpl<OcrPictureMybatisDao,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
|
public void updateMain(OcrPicture ocrPicture,List<OcrPicturejob> ocrPicturejobList,List<OcrPictureNotes> ocrPictureNotesList) {
|
|
|
|
|
ocrpicturemybatisdao.updateById(ocrPicture);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//1.先删除子表数据
|
|
|
|
|
ocrPicturejobService .deleteByMainId(ocrPicture.getId().toString());
|
|
|
|
|
ocrPictureNotesService.deleteByMainId(ocrPicture.getId().toString());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//2.子表数据重新插入
|
|
|
|
|
if(ocrPicturejobList!=null && ocrPicturejobList.size()>0) {
|
|
|
|
|
for(OcrPicturejob entity:ocrPicturejobList) {
|
|
|
|
@ -449,7 +460,7 @@ public class OcrPictureServiceImpl extends BaseServiceImpl<OcrPictureMybatisDao,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
|
public void delMain(String id) {
|
|
|
|
@ -457,7 +468,7 @@ public class OcrPictureServiceImpl extends BaseServiceImpl<OcrPictureMybatisDao,
|
|
|
|
|
ocrPictureNotesService.deleteByMainId(id);
|
|
|
|
|
ocrpicturemybatisdao.deleteById(id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
|
public void delBatchMain(Collection<? extends Serializable> idList) {
|
|
|
|
@ -467,6 +478,188 @@ public class OcrPictureServiceImpl extends BaseServiceImpl<OcrPictureMybatisDao,
|
|
|
|
|
ocrpicturemybatisdao.deleteById(id);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public IPage<OcrPicture> queryPageByUserSearchId(Integer pageNo, Integer pageSize, String userSearchId) {
|
|
|
|
|
OcrUsersearch ocrUsersearch= ocrUsersearchService.selectByUserSearchId(userSearchId);
|
|
|
|
|
|
|
|
|
|
QueryWrapper<OcrPicture> queryWrapper = new QueryWrapper();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (OcrUsersearchchild usersearchchild : ocrUsersearch.getOcrUsersearchchildList()) {
|
|
|
|
|
this.formattingSearchChild(queryWrapper,usersearchchild);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
//分页查询并组装子集数据
|
|
|
|
|
Page<OcrPicture> page = new Page<OcrPicture>(pageNo, pageSize);
|
|
|
|
|
IPage<OcrPicture> pageList = this.page(page, queryWrapper);
|
|
|
|
|
for(OcrPicture ocrPicture1:pageList.getRecords()){
|
|
|
|
|
if(StringUtils.isNotBlank(ocrPicture1.getPictureclassid())){
|
|
|
|
|
OcrPictureclass ocrPictureclass = ocrPictureclassService.getById(ocrPicture1.getPictureclassid());
|
|
|
|
|
ocrPicture1.setOcrPictureclass(ocrPictureclass);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return pageList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 格式化筛选关系
|
|
|
|
|
* @param queryWrapper
|
|
|
|
|
* @param usersearchchild
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
private QueryWrapper<OcrPicture> formattingSearchChild(QueryWrapper<OcrPicture> queryWrapper,OcrUsersearchchild usersearchchild ){
|
|
|
|
|
switch (usersearchchild.getSearchRelationType()){
|
|
|
|
|
case "where":
|
|
|
|
|
this.formattingSearchType(queryWrapper,usersearchchild);
|
|
|
|
|
break;
|
|
|
|
|
case "and":
|
|
|
|
|
queryWrapper.and(wrapper->this.formattingSearchType(wrapper,usersearchchild));
|
|
|
|
|
break;
|
|
|
|
|
case "or":
|
|
|
|
|
queryWrapper.or(wrapper->this.formattingSearchType(wrapper,usersearchchild));
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
return queryWrapper;
|
|
|
|
|
}
|
|
|
|
|
return queryWrapper;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 格式化查询类型
|
|
|
|
|
* @param queryWrapper
|
|
|
|
|
* @param usersearchchild
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
private QueryWrapper<OcrPicture> formattingSearchType(QueryWrapper<OcrPicture> queryWrapper,OcrUsersearchchild usersearchchild){
|
|
|
|
|
//查询类型 相等true 不相等fase
|
|
|
|
|
boolean queryType = "eq".equals(usersearchchild.getSearchtype());
|
|
|
|
|
|
|
|
|
|
//1.获取检查数据,确定数据类型
|
|
|
|
|
String valueType = clickSearchValue(usersearchchild.getSearchvalue());
|
|
|
|
|
List<String> arrayData = null; //集合型数据
|
|
|
|
|
List<Integer> sectionInts =null; //纯数字区间型数据
|
|
|
|
|
String[] sections =null; //字符串区间型数据
|
|
|
|
|
DateTime beginTime =null; //日期时间区间型数据
|
|
|
|
|
DateTime endTime=null; //日期时间区间型数据
|
|
|
|
|
|
|
|
|
|
//2.根据数据类型,解构数据
|
|
|
|
|
switch (valueType){
|
|
|
|
|
case "array":
|
|
|
|
|
//处理多文件
|
|
|
|
|
String [] datas =usersearchchild.getSearchvalue().split(",");
|
|
|
|
|
arrayData = Arrays.asList(datas);
|
|
|
|
|
break;
|
|
|
|
|
case "section":
|
|
|
|
|
//格式化数据,仅在做区间的时候去除空格,其他地方不进行空格去除.
|
|
|
|
|
sections =usersearchchild.getSearchvalue().trim().replaceAll("\\s+", "").split("-");
|
|
|
|
|
//校验是否纯数字,纯数字的话,要转成int,否则比对时会有问题
|
|
|
|
|
sectionInts= new ArrayList<>();
|
|
|
|
|
for (String data : sections) {
|
|
|
|
|
if(data.matches("\\d+")){
|
|
|
|
|
sectionInts.add(Integer.parseInt(data));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case "time":
|
|
|
|
|
//格式化时间数据
|
|
|
|
|
String[] times =usersearchchild.getSearchvalue().trim().replaceAll("\\s+", "").split("-");
|
|
|
|
|
beginTime = DateUtil.parse(times[0],"yyyy/MM/dd");
|
|
|
|
|
endTime = DateUtil.parse(times[1],"yyyy/MM/dd");
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//3.根据查询类型 组装查询条件 相等
|
|
|
|
|
switch (valueType){
|
|
|
|
|
case "array":
|
|
|
|
|
//集合数据
|
|
|
|
|
//相等
|
|
|
|
|
if(queryType){
|
|
|
|
|
queryWrapper.in(usersearchchild.getSearchfield(),arrayData);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
//不相等
|
|
|
|
|
queryWrapper.notIn(usersearchchild.getSearchfield(),arrayData);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case "section":
|
|
|
|
|
//数字区间查询
|
|
|
|
|
if(sectionInts!=null && sectionInts.size()==2){
|
|
|
|
|
if(queryType) {
|
|
|
|
|
//相等
|
|
|
|
|
queryWrapper.between(usersearchchild.getSearchfield(),sectionInts.get(0),sectionInts.get(1));
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
//不相等
|
|
|
|
|
queryWrapper.notBetween(usersearchchild.getSearchfield(),sectionInts.get(0),sectionInts.get(1));
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//字符串区间查询
|
|
|
|
|
if(queryType) {
|
|
|
|
|
//相等
|
|
|
|
|
queryWrapper.between(usersearchchild.getSearchfield(),sections[0],sections[1]);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
//不相等
|
|
|
|
|
queryWrapper.notBetween(usersearchchild.getSearchfield(),sections[0],sections[1]);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case "time":
|
|
|
|
|
//时间区间数据
|
|
|
|
|
//相等
|
|
|
|
|
if(queryType) {
|
|
|
|
|
queryWrapper.between(usersearchchild.getSearchfield(),beginTime.getTime(),endTime.getTime());
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
//不相等
|
|
|
|
|
queryWrapper.notBetween(usersearchchild.getSearchfield(),beginTime.getTime(),endTime.getTime());
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
if(queryType) {
|
|
|
|
|
queryWrapper.eq(usersearchchild.getSearchfield(), usersearchchild.getSearchvalue());
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
queryWrapper.ne(usersearchchild.getSearchfield(), usersearchchild.getSearchvalue());
|
|
|
|
|
}
|
|
|
|
|
return queryWrapper;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 检查数据类型 不同类型处理方案不同
|
|
|
|
|
* 集合型 格式: xxx,xxx (array)
|
|
|
|
|
* 区间型 格式: xxx-xxx (section)
|
|
|
|
|
* 时间区间型 格式: xxxx/xx/xx-xxxx/xx/xx (time)
|
|
|
|
|
* 通用型 格式: xxxx (text)
|
|
|
|
|
* @param searchvalue
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
private String clickSearchValue(String searchvalue){
|
|
|
|
|
searchvalue = searchvalue.trim().replaceAll("\\s+", "");
|
|
|
|
|
//1.判断是否为数组格式
|
|
|
|
|
if(searchvalue.indexOf(",")>0){
|
|
|
|
|
return "array";
|
|
|
|
|
}
|
|
|
|
|
//2.判断是否为区间
|
|
|
|
|
if(searchvalue.indexOf("-")>0){
|
|
|
|
|
String [] datas = searchvalue.split("-");
|
|
|
|
|
if(datas!=null && datas.length==2){
|
|
|
|
|
//2.1 判断是时间区间,还是数字区间
|
|
|
|
|
try {
|
|
|
|
|
DateTime beginTime = DateUtil.parse(datas[0],"yyyy/MM/dd");
|
|
|
|
|
DateTime endTime = DateUtil.parse(datas[0],"yyyy/MM/dd");
|
|
|
|
|
if(beginTime!=null && endTime!=null){
|
|
|
|
|
return "time";
|
|
|
|
|
}
|
|
|
|
|
}catch (Exception e){
|
|
|
|
|
}
|
|
|
|
|
return "section";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//3.都不是就按text文本处理
|
|
|
|
|
return "text";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|