fix: 图片检索、一件查重

1.图片查询、一键查重-检索条件统一封装格式化
2.修改检索条件枚举映射类SearchConfigEnum,部分字段有大写转为小写
dev
shuliYao 1 year ago
parent 46cc5d61d2
commit f0b15e9510

@ -3,26 +3,22 @@ package cn.jyjz.xiaoyao.ocr.controller;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import cn.jyjz.xiaoyao.admin.service.LogService;
import cn.jyjz.xiaoyao.common.base.util.RequestBaseUtil;
import cn.jyjz.xiaoyao.common.base.vo.UserToken;
import cn.jyjz.xiaoyao.common.mybatisplus.util.SearchQueryFormat;
import cn.jyjz.xiaoyao.ocr.dataobject.OcrPicture;
import cn.jyjz.xiaoyao.ocr.dataobject.OcrPictureclass;
import cn.jyjz.xiaoyao.ocr.dataobject.OcrTaskchildPicture;
import cn.jyjz.xiaoyao.ocr.service.OcrPictureService;
import cn.jyjz.xiaoyao.ocr.service.OcrPictureclassService;
import cn.jyjz.xiaoyao.ocr.service.OcrTaskchildPictureService;
import cn.jyjz.xiaoyao.ocr.util.DataUtil;
import cn.jyjz.xiaoyao.ocr.util.SearchConfigEnum;
import cn.jyjz.xiaoyao.ocr.util.SearchParaFormatting;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
@ -32,15 +28,11 @@ import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import cn.jyjz.xiaoyao.admin.service.UserService;
import cn.jyjz.xiaoyao.common.base.service.UserTokenService;
import cn.jyjz.xiaoyao.common.base.controller.BaseController;
import cn.jyjz.xiaoyao.common.base.param.ParamterPage;
import cn.jyjz.xiaoyao.common.base.util.requestFormat.SearchQuery;
import cn.jyjz.xiaoyao.common.base.vo.ResultVo;
import cn.jyjz.xiaoyao.common.base.vo.ResultVoUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@ -148,11 +140,15 @@ public class OcrPictureController extends BaseController{
String buessinessno = req.getParameter("buessinessno");
//搜索时间段
// String search_month = req.getParameter("search_month");
// if(StringUtils.isNotBlank(search_month) && Integer.parseInt(search_month) <= 12 && Integer.parseInt(search_month) > 0){
// queryWrapper.le("create_time", DataUtil.afterDateByMonth(Integer.parseInt(search_month)));
// }else if(StringUtils.isNotBlank(search_month) && Integer.parseInt(search_month) > 20){
// queryWrapper.le("create_time",DataUtil.afterDateByWeek(Integer.parseInt(search_month) - 20));
// }
String search_month = req.getParameter("search_month");
if(StringUtils.isNotBlank(search_month) && Integer.parseInt(search_month) <= 12 && Integer.parseInt(search_month) > 0){
queryWrapper.le("create_time", DataUtil.afterDateByMonth(Integer.parseInt(search_month)));
}else if(StringUtils.isNotBlank(search_month) && Integer.parseInt(search_month) > 20){
queryWrapper.le("create_time",DataUtil.afterDateByWeek(Integer.parseInt(search_month) - 20));
queryWrapper.le("create_time",DataUtil.afterDateByMonth(Integer.parseInt(search_month)));
}
//判断是否需要查询历史记录
@ -160,6 +156,18 @@ public class OcrPictureController extends BaseController{
queryWrapper.eq("taskstatus", search_history);
}
//根据参数枚举获取检索参数并映射为数据库的字段的key-v map
Map<String,Object> paraMap = new HashMap<>();
for(SearchConfigEnum config : SearchConfigEnum.values()){
String searchvalue = req.getParameter(config.getId());
if(StringUtils.isNotBlank(searchvalue)){
paraMap.put(config.getMeaning(),searchvalue);
}
}
//调用查询参数解析方法解析为queryWrapper
queryWrapper = SearchParaFormatting.searchParaParse(queryWrapper,paraMap);
queryWrapper.eq("tenant_id",tenantId);
List<OcrPicture> pageList = ocrPictureService.listPage(queryWrapper);
@ -173,7 +181,6 @@ public class OcrPictureController extends BaseController{
}else{
return ResultVoUtil.error("没有查重数据。");
}
//return Result.error("失败。");
}
/**
@ -217,41 +224,16 @@ public class OcrPictureController extends BaseController{
queryWrapper.le("create_time",DataUtil.afterDateByMonth(Integer.parseInt(search_month)));
}
//根据参数枚举获取检索参数并映射为数据库的字段的key-v map
Map<String,Object> paraMap = new HashMap<>();
for(SearchConfigEnum config : SearchConfigEnum.values()){
//相似度不在搜索范围内
if(!config.getId().equals("izSimilarity")){
String searchvalue = req.getParameter(config.getId());
if(StringUtils.isNotBlank(searchvalue)){
if(config.getId().equals("izYear")){
//针对年份搜索,需要拆分
String[] year = searchvalue.split(",");
//当前数据必须是两条
if(year.length == 2){
java.text.SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
Date start = null;
Date end = null;
try {
start = sdf.parse(year[0]);
end = sdf.parse(year[1]);
} catch (ParseException e) {
continue;
}
queryWrapper.ge(config.getMeaning(),start);
queryWrapper.le(config.getMeaning(),end);
}
}else{
queryWrapper.eq(config.getMeaning(),searchvalue);
}
}
String searchvalue = req.getParameter(config.getId());
if(StringUtils.isNotBlank(searchvalue)){
paraMap.put(config.getMeaning(),searchvalue);
}
}
//调用查询参数解析方法解析为queryWrapper
queryWrapper = SearchParaFormatting.searchParaParse(queryWrapper,paraMap);
queryWrapper.eq("tenant_id",tenantId);
Page<OcrPicture> page = new Page<OcrPicture>(pageNo, pageSize);

@ -16,6 +16,7 @@ import cn.jyjz.xiaoyao.ocr.dataobject.*;
import cn.jyjz.xiaoyao.ocr.service.*;
import cn.jyjz.xiaoyao.ocr.util.ImageClassUtil;
import cn.jyjz.xiaoyao.ocr.util.SearchEnum;
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;
@ -536,7 +537,7 @@ public class OcrPictureServiceImpl extends BaseServiceImpl<OcrPictureMybatisDao,
boolean queryType = "eq".equals(usersearchchild.getSearchtype());
//1.获取检查数据,确定数据类型
String valueType = clickSearchValue(usersearchchild.getSearchvalue());
String valueType = SearchParaFormatting.clickSearchValue(usersearchchild.getSearchvalue());
List<String> arrayData = null; //集合型数据
List<Integer> sectionInts =null; //纯数字区间型数据
String[] sections =null; //字符串区间型数据
@ -627,39 +628,5 @@ public class OcrPictureServiceImpl extends BaseServiceImpl<OcrPictureMybatisDao,
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";
}
}

@ -34,10 +34,10 @@ import java.util.*;
public class OcrTaskchildPictureServiceImpl extends BaseServiceImpl<OcrTaskchildPictureMybatisDao, OcrTaskchildPicture> implements OcrTaskchildPictureService {
@Resource
private OcrTaskchildPictureMybatisDao ocrtaskchildpicturemybatisdao;
@Resource
private OcrPictureService ocrPictureService;
@Resource
IFlowTaskService iFlowTaskService;
/**
@ -46,17 +46,17 @@ public class OcrTaskchildPictureServiceImpl extends BaseServiceImpl<OcrTaskchild
* @return
*/
public ResultVo trueorfalse(String childpictureids, String packageid, String iztrueorfalse, String judgeid, String judgedesc){
String[] cps = childpictureids.split(",");
List<OcrPicture> saveList =new ArrayList<>();
StringBuffer historyPname = new StringBuffer();
StringBuffer taskType = new StringBuffer();
for(String childpictureid:cps){
OcrTaskchildPicture old = this.listPicturePackageId(childpictureid,Long.parseLong(packageid));
//如果是历史图片,不允许进行设置
if(old.isIzHistory()){
if(historyPname.length() > 0){
@ -72,37 +72,37 @@ public class OcrTaskchildPictureServiceImpl extends BaseServiceImpl<OcrTaskchild
taskType.append(old.getOcrPicture().getImgname());
}
}
OcrPicture ocrPicture = old.getOcrPicture();
ocrPicture.setJudgeid(Long.parseLong(judgeid));
ocrPicture.setJudgedesc(judgedesc);
ocrPicture.setIztrueorfalse(Integer.parseInt(iztrueorfalse));
ocrPicture.setUpdateTime(System.currentTimeMillis());
saveList.add(ocrPicture);
}
if(StringUtils.isNotBlank(historyPname.toString())){
return ResultVoUtil.error(historyPname.toString() + "为历史数据,不能标记。");
}
else if(StringUtils.isNotBlank(taskType.toString())){
return ResultVoUtil.error( taskType.toString() + "已经审批,不能标记。");
}
return this.ocrPictureService.updateBatchById(saveList)?ResultVoUtil.success():ResultVoUtil.error();
}
public ResultVo clearmark(String childpictureids, String packageid){
String[] cps = childpictureids.split(",");
List<OcrPicture> saveList =new ArrayList<>();
StringBuffer historyPname = new StringBuffer();
StringBuffer taskType = new StringBuffer();
for(String childpictureid:cps){
OcrTaskchildPicture old = this.listPicturePackageId(childpictureid,Long.parseLong(packageid));
//如果是历史图片,不允许进行设置
if(old.isIzHistory()){
if(historyPname.length() > 0){
@ -118,26 +118,26 @@ public class OcrTaskchildPictureServiceImpl extends BaseServiceImpl<OcrTaskchild
taskType.append(old.getOcrPicture().getImgname());
}
}
OcrPicture ocrPicture = old.getOcrPicture();
ocrPicture.setJudgeid(null);
ocrPicture.setJudgedesc(null);
ocrPicture.setIztrueorfalse(null);
ocrPicture.setUpdateTime(System.currentTimeMillis());
saveList.add(ocrPicture);
}
if(StringUtils.isNotBlank(historyPname.toString())){
return ResultVoUtil.error(historyPname.toString() + "为历史数据,不能清除标记。");
}
else if(StringUtils.isNotBlank(taskType.toString())){
return ResultVoUtil.error( taskType.toString() + "已经审批,不能清除标记。");
}
return this.ocrPictureService.updateBatchById(saveList)?ResultVoUtil.success():ResultVoUtil.error();
}
/**
*
* @param childpictureid
@ -145,7 +145,7 @@ public class OcrTaskchildPictureServiceImpl extends BaseServiceImpl<OcrTaskchild
*/
public boolean pass(String childpictureid,OcrTaskchildPicture ocrTaskchildPicture){
OcrTaskchildPicture old = this.getById(childpictureid);
//判断当前图片是否在任务包中,如果不在任务保重,不允许设置图片真假
if(!old.getPackageid().equals(ocrTaskchildPicture.getPackageid())){
return false;
@ -161,12 +161,12 @@ public class OcrTaskchildPictureServiceImpl extends BaseServiceImpl<OcrTaskchild
// if(StringUtils.isNotBlank(ocrTaskchildPicture.getPicturecompare())){
// old.setPicturecompare(ocrTaskchildPicture.getPicturecompare());
// }
old.setUpdatetime(System.currentTimeMillis());
return this.updateById(old);
}
/**
*
* @param formid
@ -177,19 +177,19 @@ public class OcrTaskchildPictureServiceImpl extends BaseServiceImpl<OcrTaskchild
QueryWrapper queryWrapper = new QueryWrapper();
queryWrapper.in("ID",formid);
List<OcrTaskchildPicture> list = this.ocrtaskchildpicturemybatisdao.selectList(queryWrapper);
//目前没有做其他信息返回,如果需要再做修改
for(OcrTaskchildPicture ocrTaskchildPicture:list){
//判断审批人是否为当前登录用户
if(userToken.getLoginname().equals(ocrTaskchildPicture.getAssignee())){
}else{
return false;
}
}
return true;
}
/**
*
* @param formid
@ -199,7 +199,7 @@ public class OcrTaskchildPictureServiceImpl extends BaseServiceImpl<OcrTaskchild
QueryWrapper queryWrapper = new QueryWrapper();
queryWrapper.in("ID",formid);
List<OcrTaskchildPicture> list = this.ocrtaskchildpicturemybatisdao.selectList(queryWrapper);
//目前没有做其他信息返回,如果需要再做修改
for(OcrTaskchildPicture ocrTaskchildPicture:list){
//判断当前审批状态为拒绝或者通过的,不允许再做审批
@ -207,7 +207,7 @@ public class OcrTaskchildPictureServiceImpl extends BaseServiceImpl<OcrTaskchild
|| ocrTaskchildPicture.getStates().intValue() == SystemConstantsOa.OA_STATUS_TYPE_REFUSE ){
return false;
}else{
}
}
return true;
@ -215,18 +215,18 @@ public class OcrTaskchildPictureServiceImpl extends BaseServiceImpl<OcrTaskchild
@Override
public List<OcrTaskchildPicture> listAll(String tenantId, String createUser, QueryWrapper queryWrapper){
long count = this.count(queryWrapper);
Page<OcrTaskchildPicture> page = new Page<>(1, count);
page.setMaxLimit(count);
IPage<OcrTaskchildPicture> iPage = this.page(page,queryWrapper);
return iPage.getRecords();
}
/**
*
* @param taskids
@ -236,7 +236,7 @@ public class OcrTaskchildPictureServiceImpl extends BaseServiceImpl<OcrTaskchild
UpdateWrapper updateWrapper = new UpdateWrapper();
updateWrapper.set("HAVEPOINTS",1);
updateWrapper.in("ID",taskids);
return this.update(updateWrapper);
}
@ -249,13 +249,13 @@ public class OcrTaskchildPictureServiceImpl extends BaseServiceImpl<OcrTaskchild
QueryWrapper<OcrTaskchildPicture> queryWrapperNew = new QueryWrapper<>();
queryWrapperNew.eq("HAVEPOINTS","1");
queryWrapperNew.eq("PACKAGEID",packageid);
List<OcrTaskchildPicture> list = this.ocrtaskchildpicturemybatisdao.selectList(queryWrapperNew);
this.formatTask(list,packageid);
return list;
}
/**
*
* @param fromid
@ -265,34 +265,34 @@ public class OcrTaskchildPictureServiceImpl extends BaseServiceImpl<OcrTaskchild
OcrTaskchildPicture ocrTaskchildPicture = this.getById(fromid);
//查询图片对象
OcrPicture ocrPicture = this.ocrPictureService.selectDtoById(ocrTaskchildPicture.getPictureid());
// String pictureids = ocrTaskchildPicture.getPicturecompare();
// String[] splitPictureids = pictureids.split(",");
// List<String> listPictureids = Arrays.asList(splitPictureids);
// //设置是否为历史信息
// ocrTaskchildPicture.setIzHistory(listPictureids.contains(ocrPicture.getPictureid())?false:true);
//如果当前任务的任务包主键一致,说明不是历史数据,如果不一致,说明是历史数据
if(packageid.toString().equals(ocrTaskchildPicture.getPackageid().toString())){
ocrTaskchildPicture.setIzHistory(false);
}else{
ocrTaskchildPicture.setIzHistory(true);
}
//查询审批流节点信息
List<Task> taskList = iFlowTaskService.nowRunTask(ocrTaskchildPicture.getProcessinstanceid(),ocrTaskchildPicture.getProcessdefinitionid());
if(null != taskList && !taskList.isEmpty()) {
ocrTaskchildPicture.setTaskId(taskList.get(0).getId());
}
//获取当前真假标记
ocrTaskchildPicture.setIztrueorfalse(ocrPicture.getIztrueorfalse());
//是否已经审批
ocrTaskchildPicture.setWorkStatus(ocrPicture.getWorkStatus());
ocrTaskchildPicture.setOcrPicture(ocrPicture);
return ocrTaskchildPicture;
}
/**
@ -303,30 +303,30 @@ public class OcrTaskchildPictureServiceImpl extends BaseServiceImpl<OcrTaskchild
*/
public IPage<OcrTaskchildPicture> listByPackageId(String taskchildpictureid, ParamterPage paramterPage,QueryWrapper queryWrapper,String orderbyname,String orderbyvalue,String packageid,String tenantId ){
Page<OcrTaskchildPicture> page = new Page<>(paramterPage.getStart(), paramterPage.getPagesize());
//当前显示的任务对象
OcrTaskchildPicture mainOcrTaskchildPicture = this.getById(taskchildpictureid);
//判断当前图片是否为历史图片
if(!packageid.equals(mainOcrTaskchildPicture.getPackageid().toString())){
QueryWrapper<OcrTaskchildPicture> queryWrapperNew = new QueryWrapper<>();
queryWrapperNew.eq("TENANTID",tenantId);
queryWrapperNew.eq("PACKAGEID",packageid);
//查询非历史图片存在的集合
IPage<OcrTaskchildPicture> pageNew = this.selectSearchListPage(paramterPage,queryWrapperNew);
//如果是历史图片,从非历史图片存在的集合中随机选取一个
if(!pageNew.getRecords().isEmpty()){
mainOcrTaskchildPicture = pageNew.getRecords().get(0);
}
}
//不包含当前选中的图片
queryWrapper.ne("ID",taskchildpictureid);
queryWrapper.eq("TENANTID",tenantId);
if(StringUtils.isNotBlank(orderbyname) && orderbyname.equals("asc")){
if(StringUtils.isNotBlank(orderbyvalue) && orderbyvalue.equals("pictureResult")){
@ -334,28 +334,28 @@ public class OcrTaskchildPictureServiceImpl extends BaseServiceImpl<OcrTaskchild
}else if(StringUtils.isNotBlank(orderbyvalue) && orderbyvalue.equals("fromuptime")){
queryWrapper.orderByAsc("FROMUPTIME");
}
}else if(StringUtils.isNotBlank(orderbyname) && orderbyname.equals("desc")){
if(StringUtils.isNotBlank(orderbyvalue) && orderbyvalue.equals("pictureResult")){
queryWrapper.orderByDesc("FIELD(PICTUREID,"+ mainOcrTaskchildPicture.getOcpictureid() +")");
}else if(StringUtils.isNotBlank(orderbyvalue) && orderbyvalue.equals("fromuptime")){
queryWrapper.orderByDesc("FROMUPTIME");
}
}else{
queryWrapper.in("PICTUREID",mainOcrTaskchildPicture.getOcpictureid().split(","));
}
queryWrapper.in("PICTUREID",mainOcrTaskchildPicture.getOcpictureid().split(","));
IPage<OcrTaskchildPicture> iPage = this.page(page,queryWrapper);
this.formatTask(iPage.getRecords(),packageid);
return iPage;
}
/**
*
* @param list
@ -363,7 +363,7 @@ public class OcrTaskchildPictureServiceImpl extends BaseServiceImpl<OcrTaskchild
*/
private void formatTask(List<OcrTaskchildPicture> list,String packageid){
for(OcrTaskchildPicture ocrTaskchildPicture:list){
//查询审批流节点信息
List<Task> taskList = iFlowTaskService.nowRunTask(ocrTaskchildPicture.getProcessinstanceid(),ocrTaskchildPicture.getProcessdefinitionid());
if(null != taskList && !taskList.isEmpty()) {
@ -375,25 +375,25 @@ public class OcrTaskchildPictureServiceImpl extends BaseServiceImpl<OcrTaskchild
// List<String> listPictureids = Arrays.asList(splitPictureids);
// //设置是否为历史信息
// ocrTaskchildPicture.setIzHistory(listPictureids.contains(ocrTaskchildPicture.getPictureid())?false:true);
//如果当前任务的任务包主键一致,说明不是历史数据,如果不一致,说明是历史数据
if(packageid.equals(ocrTaskchildPicture.getPackageid().toString())){
ocrTaskchildPicture.setIzHistory(false);
}else{
ocrTaskchildPicture.setIzHistory(true);
}
OcrPicture ocrPicture = this.ocrPictureService.selectDtoById(ocrTaskchildPicture.getPictureid());
//获取当前真假标记
ocrTaskchildPicture.setIztrueorfalse(ocrPicture.getIztrueorfalse());
//是否已经审批
ocrTaskchildPicture.setWorkStatus(ocrPicture.getWorkStatus());
ocrTaskchildPicture.setOcrPicture(ocrPicture);
}
}
/**
*
* @param id
@ -407,7 +407,7 @@ public class OcrTaskchildPictureServiceImpl extends BaseServiceImpl<OcrTaskchild
}
return false;
}
/**
*
* @param ocrPicture
@ -427,13 +427,13 @@ public class OcrTaskchildPictureServiceImpl extends BaseServiceImpl<OcrTaskchild
ocrTaskchildPicture.setCreatedate(System.currentTimeMillis());
ocrTaskchildPicture.setPackageid(packageid);
ocrTaskchildPicture.setCategoryid(ocrPicture.getCategoryid());
ocrTaskchildPicture.setFromsourceid(ocrPicture.getField4());
ocrTaskchildPicture.setFromuptime(ocrPicture.getUptime());
ocrTaskchildPicture.setFromplanid(ocrPicture.getPlanid());
ocrTaskchildPicture.setFromprojectid(ocrPicture.getProjectid());
ocrTaskchildPicture.setFromuserid(ocrPicture.getUpuserid());
StringBuffer pcid = new StringBuffer();
StringBuffer result = new StringBuffer();
for(OcrPicture comp:ocrPicture.getListCom()){
@ -445,25 +445,25 @@ public class OcrTaskchildPictureServiceImpl extends BaseServiceImpl<OcrTaskchild
result.append("," + comp.getResult());
}
}
ocrTaskchildPicture.setOcpictureid(pcid.toString());
ocrTaskchildPicture.setPictureresult(result.toString());
ocrTaskchildPicture.setPicturecompare(String.join(",",ocrPicture.getPicturecompareList()));
return this.save(ocrTaskchildPicture)?ocrTaskchildPicture:null;
}
/**
*
* @param query
* @return
*/
public List<OcrTaskchildPicture> listFinal(Map<String, Object> query){
return this.ocrtaskchildpicturemybatisdao.listFinal(query);
}
/**
* \
* @param taskchildid
@ -471,16 +471,16 @@ public class OcrTaskchildPictureServiceImpl extends BaseServiceImpl<OcrTaskchild
*/
public OcrPicture findOcrPictureByTaskchildid(String taskchildid){
OcrTaskchildPicture ocrTaskchildPicture = this.ocrtaskchildpicturemybatisdao.selectById(taskchildid);
if(null == ocrTaskchildPicture){
return null;
}
OcrPicture ocrPicture = ocrPictureService.selectDtoById(ocrTaskchildPicture.getPictureid());
return ocrPicture;
}
/**
*
* @param query

@ -9,7 +9,7 @@ import java.text.SimpleDateFormat;
import java.util.Date;
public enum SearchConfigEnum {
//所属项目
PROJECT("izproject","projectIdName"),
//拜访客户类型
@ -30,28 +30,28 @@ public enum SearchConfigEnum {
FIELD9("izproductname","field9"),
//拜访项目类别
FIELD17("izprojecttype","field17"),
//所属项目、拜访客户类型、拜访客户级别、拜访客户名称、拜访项目类别、任务来源、任务状态、拜访省份/直辖市、、厂商、产品名称、
//提报人
UPUSERSEARCH("izUpuser","upName"),
UPUSERSEARCH("izupuser","upName"),
//所属计划
PLANSEARCH("izPlan","planName"),
PLANSEARCH("izplan","planName"),
//相似度
SIMISEARCH("izSimilarity","pictureresult"),
SIMISEARCH("izsimilarity","pictureresult"),
//分类搜索
CLASSISEARCH("izShow","classificationid"),
CLASSISEARCH("izshow","classificationid"),
//是否展示年份
YEARSEARCH("izYear","upTime"),
YEARSEARCH("izyear","upTime"),
//图片类型
TYPESEARCH("izPicturetype","pictureclassid"),
TYPESEARCH("izpicturetype","pictureclassid"),
//发布地区、拜访城市
AREASEARCH("izvisitcity","releaseArea"),
THREEWEEKdd("izYeardddd","upTime");
private String id;
private String meaning;
SearchConfigEnum(String id, String meaning) {
this.id = id;
this.meaning = meaning;
@ -64,23 +64,23 @@ public enum SearchConfigEnum {
}
return null;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getMeaning() {
return meaning;
}
public void setMeaning(String meaning) {
this.meaning = meaning;
}
/**
*
* @param req
@ -88,7 +88,7 @@ public enum SearchConfigEnum {
*/
public static void fomarQueryWrapper(HttpServletRequest req, QueryWrapper queryWrapper){
for(SearchConfigEnum config : SearchConfigEnum.values()){
//相似度不在搜索范围内
if(!config.getId().equals("izSimilarity")){
String searchvalue = req.getParameter(config.getId());
@ -107,7 +107,7 @@ public enum SearchConfigEnum {
} catch (ParseException e) {
continue;
}
queryWrapper.ge(config.getMeaning(),start);
queryWrapper.le(config.getMeaning(),end);
}
@ -115,11 +115,11 @@ public enum SearchConfigEnum {
}else{
queryWrapper.eq(config.getMeaning(),searchvalue);
}
}
}
}
}
}

@ -0,0 +1,149 @@
package cn.jyjz.xiaoyao.ocr.util;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import cn.jyjz.xiaoyao.common.base.util.StringUtils;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
/**
* QueryWrapper
* :
* : xxx,xxx (array)
* : xxx-xxx (section)
* xxxx/xx/xx-xxxx/xx/xx (time)
* : xxxx (text)
* @author hugh(shuli.yao) 1397940314@qq.com
* @version 1.0
* @date 2024/3/12 10:49
*/
public class SearchParaFormatting {
/**
* queryWrapper
* @param queryWrapper
* @param para
* @return
*/
public static QueryWrapper searchParaParse(QueryWrapper queryWrapper, Map<String,Object> para){
for (String key : para.keySet()) {
Object value = para.get(key);
if(value==null || StringUtils.isEmpty(value.toString())){
continue;
}
//检查数据原始类型,字符串还是整型、或小数
String paraValueType = "str";
if (value instanceof Integer) {
paraValueType = "int";
}else if(value instanceof Double){
paraValueType = "double";
}
//参数统一先转换成 字符串进行解析
String searchValue =value.toString();
//1.获取检查数据,确定数据类型
String valueType = SearchParaFormatting.clickSearchValue(searchValue);
List<String> arrayData = null; //集合型数据
List<Integer> sectionInts =null; //纯数字区间型数据
String[] sections =null; //字符串区间型数据
DateTime beginTime =null; //日期时间区间型数据
DateTime endTime=null; //日期时间区间型数据
//2.根据数据类型,解构数据
switch (valueType){
case "array":
//处理多文件
String [] datas =searchValue.split(",");
arrayData = Arrays.asList(datas);
break;
case "section":
//格式化数据,仅在做区间的时候去除空格,其他地方不进行空格去除.
sections =searchValue.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 =searchValue.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":
//集合数据
queryWrapper.in(key,arrayData);
break;
case "section":
//数字区间查询
if(sectionInts!=null && sectionInts.size()==2){
//相等
queryWrapper.between(key,sectionInts.get(0),sectionInts.get(1));
break;
}
queryWrapper.between(key,sections[0],sections[1]);
break;
case "time":
//时间区间数据
//相等
queryWrapper.between(key,beginTime.getTime(),endTime.getTime());
break;
default:
if("int".equals(paraValueType)){
queryWrapper.eq(key, Integer.parseInt(searchValue));
}else if("double".equals(paraValueType)){
queryWrapper.eq(key, Double.parseDouble(searchValue));
}else{
queryWrapper.eq(key, searchValue);
}
}
}
return queryWrapper;
}
/**
*
* @param searchvalue
* @return
*/
public static 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";
}
}
Loading…
Cancel
Save