feat: 解决一件查重 创建审核任务和比对相似度结果有问题

pull/1/head
shuliYao 2 years ago
parent ed91a64ee1
commit c9636fac90

@ -1,42 +1,21 @@
package cn.jyjz.xiaoyao.ocr.controller; package cn.jyjz.xiaoyao.ocr.controller;
import cn.jyjz.xiaoyao.abase.service.FtperrorService;
import cn.jyjz.xiaoyao.admin.service.UserService;
import cn.jyjz.xiaoyao.common.base.config.XiaoyaoConfig;
import cn.jyjz.xiaoyao.common.base.controller.BaseController; import cn.jyjz.xiaoyao.common.base.controller.BaseController;
import cn.jyjz.xiaoyao.common.base.service.UserTokenService; import cn.jyjz.xiaoyao.common.base.service.UserTokenService;
import cn.jyjz.xiaoyao.common.base.util.RequestBaseUtil; import cn.jyjz.xiaoyao.common.base.util.RequestBaseUtil;
import cn.jyjz.xiaoyao.common.base.vo.ResultVo; import cn.jyjz.xiaoyao.common.base.vo.ResultVo;
import cn.jyjz.xiaoyao.common.base.vo.ResultVoUtil; import cn.jyjz.xiaoyao.common.base.vo.ResultVoUtil;
import cn.jyjz.xiaoyao.common.base.vo.UserToken; import cn.jyjz.xiaoyao.common.base.vo.UserToken;
import cn.jyjz.xiaoyao.ocr.dataobject.OcrCheckDuplicate;
import cn.jyjz.xiaoyao.ocr.dataobject.OcrPicture;
import cn.jyjz.xiaoyao.ocr.dataobject.OcrTaskPackage; import cn.jyjz.xiaoyao.ocr.dataobject.OcrTaskPackage;
import cn.jyjz.xiaoyao.ocr.dto.OcrTaskPackageDto; import cn.jyjz.xiaoyao.ocr.dto.OcrTaskPackageDto;
import cn.jyjz.xiaoyao.ocr.service.IOcrCheckDuplicateResultService;
import cn.jyjz.xiaoyao.ocr.service.IOcrCheckDuplicateService;
import cn.jyjz.xiaoyao.ocr.service.IOcrTaskPackageService; import cn.jyjz.xiaoyao.ocr.service.IOcrTaskPackageService;
import cn.jyjz.xiaoyao.ocr.service.OcrPictureService;
import cn.jyjz.xiaoyao.ocr.util.SearchConfigEnum;
import cn.jyjz.xiaoyao.ocr.util.SearchParaFormatting;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/** /**
* <p> * <p>

@ -0,0 +1,304 @@
package cn.jyjz.xiaoyao.ocr.controller;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
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.OcrConfiguration;
import cn.jyjz.xiaoyao.ocr.dataobject.OcrUsersearch;
import cn.jyjz.xiaoyao.ocr.dataobject.OcrUsersearchchild;
import cn.jyjz.xiaoyao.ocr.service.OcrUsersearchService;
import cn.jyjz.xiaoyao.ocr.service.OcrUsersearchchildService;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.*;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
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;
import com.baomidou.mybatisplus.core.metadata.IPage;
@Api(tags="ocr-过滤条件管理")
@RestController
@RequestMapping("/ocr/ocrUsersearch")
public class OcrUsersearchController extends BaseController{
private Logger log = LoggerFactory.getLogger(this.getClass());
@Resource
private OcrUsersearchService ocrUsersearchService;
@Resource
private OcrUsersearchchildService ocrUsersearchchildService;
@Resource
private UserTokenService userTokenService;
@Resource
private UserService userService;
/**
*
*
* @param pageNo
* @param pageSize
* @param request
* @return
*/
@ApiOperation(value="过滤条件列表", notes="过滤条件列表")
@ApiImplicitParams({
@ApiImplicitParam(paramType = "header", name = "X-Tenant-Id", value = "租户主键,用户登录时的信息“tenantList”中获得。", dataType = "String", required = true)
})
@GetMapping(value = "/list")
public ResultVo<IPage<OcrUsersearch>> queryPageList(@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
@RequestParam(name="type") @ApiParam(value = "类型(首页为0终审为1)", required = true) Integer type,
HttpServletRequest request) {
//获取当前登录人
UserToken userToken = this.userTokenService.getUserToken(RequestBaseUtil.getToken(request));
ParamterPage paramterPage = new ParamterPage();
paramterPage.setPagesize(pageSize);
paramterPage.setStart(pageNo);
//租户主键,由前端页面传送
String tenantId = request.getHeader("X-Tenant-Id");
if(StringUtils.isBlank(tenantId)){
return ResultVoUtil.error("租户主键不能为空");
}
OcrUsersearch ocrUsersearch = new OcrUsersearch();
SearchQuery searchQuery = this.getParametersStartingWithToSearchJson(request, "search_");
QueryWrapper<OcrUsersearch> queryWrapper = SearchQueryFormat.queryStringFormat(searchQuery,ocrUsersearch);
queryWrapper.eq("USERID",userToken.getUserid());
queryWrapper.eq("TENANTID",tenantId);
queryWrapper.eq("TYPE",type);
queryWrapper.orderByDesc(Arrays.asList("IZTOP","REORDER"));
IPage<OcrUsersearch> pageList = ocrUsersearchService.selectSearchListPage(paramterPage, queryWrapper);
for(OcrUsersearch ocrUsersearch1:pageList.getRecords()){
List<OcrUsersearchchild> ocrUsersearchchildList = ocrUsersearchchildService.selectByMainId(ocrUsersearch1.getId().toString());
ocrUsersearch1.setOcrUsersearchchildList(ocrUsersearchchildList);
}
return ResultVoUtil.success(pageList);
}
/**
*
*
* @param ocrUsersearch
* @return
*/
@ApiOperation(value="添加过滤条件", notes="添加过滤条件")
@ApiImplicitParams({
@ApiImplicitParam(paramType = "header", name = "X-Tenant-Id", value = "租户主键,用户登录时的信息“tenantList”中获得。", dataType = "String", required = true)
})
@PostMapping(value = "/add")
public ResultVo<String> add(@RequestBody OcrUsersearch ocrUsersearch, HttpServletRequest req) {
//租户主键,由前端页面传送
String tenantId = req.getHeader("X-Tenant-Id");
if(StringUtils.isBlank(tenantId)){
return ResultVoUtil.error("租户主键不能为空");
}
//获取当前登录人
UserToken userToken = this.userTokenService.getUserToken(RequestBaseUtil.getToken(req));
ocrUsersearch.setUserid(Long.parseLong(userToken.getUserid()));
ocrUsersearch.setCreatetime(System.currentTimeMillis());
ocrUsersearch.setCreateby(userToken.getLoginname());
ocrUsersearch.setTenantid(Long.parseLong(tenantId));
ocrUsersearch.setReorder(this.ocrUsersearchService.getReorder(ocrUsersearch.getUserid(),ocrUsersearch.getType()));
ocrUsersearch.setType(ocrUsersearch.getType());
if(null != ocrUsersearch.getId()){
this.ocrUsersearchService.removeByIds(ocrUsersearch.getId().toString());
}
this.ocrUsersearchService.save(ocrUsersearch);
if(null != ocrUsersearch.getOcrUsersearchchildList()){
for(OcrUsersearchchild ocrUsersearchchild:ocrUsersearch.getOcrUsersearchchildList()){
ocrUsersearchchild.setUsersearchid(ocrUsersearch.getId());
}
this.ocrUsersearchchildService.saveBatch(ocrUsersearch.getOcrUsersearchchildList());
}
return ResultVoUtil.success("添加成功!");
}
/**
*
*
* @param ocrUsersearch
* @return
*/
@ApiOperation(value="修改过滤条件", notes="修改过滤条件")
@ApiImplicitParams({
@ApiImplicitParam(paramType = "header", name = "X-Tenant-Id", value = "租户主键,用户登录时的信息“tenantList”中获得。", dataType = "String", required = true)
})
@PostMapping(value = "/edit")
public ResultVo<String> edit(@RequestBody OcrUsersearch ocrUsersearch, HttpServletRequest req) {
//租户主键,由前端页面传送
String tenantId = req.getHeader("X-Tenant-Id");
if(StringUtils.isBlank(tenantId)){
return ResultVoUtil.error("租户主键不能为空");
}
OcrUsersearch old = this.ocrUsersearchService.getById(ocrUsersearch.getId());
if(null == old){
return ResultVoUtil.error("数据错误。");
}
//获取当前登录人
UserToken userToken = this.userTokenService.getUserToken(RequestBaseUtil.getToken(req));
ocrUsersearch.setUserid(old.getUserid());
ocrUsersearch.setCreatetime(old.getCreatetime());
ocrUsersearch.setCreateby(old.getCreateby());
ocrUsersearch.setTenantid(old.getTenantid());
ocrUsersearch.setReorder(old.getReorder());
ocrUsersearch.setIztop(old.getIztop());
ocrUsersearch.setUpdateby(userToken.getLoginname());
ocrUsersearch.setUpdatetime(System.currentTimeMillis());
if(null != ocrUsersearch.getId()){
this.ocrUsersearchService.removeChildByIds(ocrUsersearch.getId().toString());
}
this.ocrUsersearchService.updateById(ocrUsersearch);
if(null != ocrUsersearch.getOcrUsersearchchildList()){
for(OcrUsersearchchild ocrUsersearchchild:ocrUsersearch.getOcrUsersearchchildList()){
ocrUsersearchchild.setUsersearchid(ocrUsersearch.getId());
}
this.ocrUsersearchchildService.saveBatch(ocrUsersearch.getOcrUsersearchchildList());
}
return ResultVoUtil.success("添加成功!");
}
/**
*
*
* @return
*/
@ApiOperation(value="调整顺序", notes="调整顺序")
@ApiImplicitParams({
@ApiImplicitParam(paramType = "header", name = "X-Tenant-Id", value = "租户主键,用户登录时的信息“tenantList”中获得。", dataType = "String", required = true),
@ApiImplicitParam(paramType = "path",name = "searchid", value = "个人过滤主键", required = true),
@ApiImplicitParam(paramType = "path",name = "reorder", value = "排序数值,数值越大越靠前", required = true)
})
@GetMapping(value = "/reorder")
public ResultVo<String> reorder( HttpServletRequest req ,
@RequestParam(name="searchid", required = true) String searchid,
@RequestParam(name="reorder", defaultValue="1") Integer reorder) {
OcrUsersearch old = this.ocrUsersearchService.getById(searchid);
if(null == old){
return ResultVoUtil.error("数据错误。");
}
old.setReorder(reorder);
return this.ocrUsersearchService.updateById(old)?ResultVoUtil.success():ResultVoUtil.error();
}
/**
*
*
* @return
*/
@ApiOperation(value="收藏", notes="收藏")
@ApiImplicitParams({
@ApiImplicitParam(paramType = "header", name = "X-Tenant-Id", value = "租户主键,用户登录时的信息“tenantList”中获得。", dataType = "String", required = true),
@ApiImplicitParam(paramType = "path",name = "searchid", value = "个人过滤主键", required = true)
})
@GetMapping(value = "/collect")
public ResultVo<String> collect( HttpServletRequest req) {
String searchid = req.getParameter("searchid");
OcrUsersearch old = this.ocrUsersearchService.getById(searchid);
if(null == old){
return ResultVoUtil.error("数据错误。");
}
old.setIztop(1);
return this.ocrUsersearchService.updateById(old)?ResultVoUtil.success():ResultVoUtil.error();
}
/**
*
*
* @return
*/
@ApiOperation(value="取消收藏", notes="取消收藏")
@ApiImplicitParams({
@ApiImplicitParam(paramType = "header", name = "X-Tenant-Id", value = "租户主键,用户登录时的信息“tenantList”中获得。", dataType = "String", required = true),
@ApiImplicitParam(paramType = "path",name = "searchid", value = "个人过滤主键", required = true)
})
@GetMapping(value = "/collectreset")
public ResultVo<String> collectreset(HttpServletRequest req) {
String searchid = req.getParameter("searchid");
OcrUsersearch old = this.ocrUsersearchService.getById(searchid);
if(null == old){
return ResultVoUtil.error("数据错误。");
}
old.setIztop(0);
return this.ocrUsersearchService.updateById(old)?ResultVoUtil.success():ResultVoUtil.error();
}
/**
*
*
* @param ids
* @return
*/
@ApiOperation(value="批量删除过滤条件-通过id", notes="批量删除过滤条件-通过id")
@GetMapping(value = "/deleteBatch")
public ResultVo<String> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
return this.ocrUsersearchService.removeByIds(ids)?ResultVoUtil.success("批量删除成功!"):ResultVoUtil.error();
}
/**
* id
*
* @param id
* @return
*/
//@AutoLog(value = "ocr_usersearch-通过id查询")
@ApiOperation(value="查询过滤条件详情-通过id", notes="查询过滤条件详情-通过id")
@GetMapping(value = "/queryById")
public ResultVo<OcrUsersearch> queryById(@RequestParam(name="id",required=true) String id) {
OcrUsersearch ocrUsersearch = ocrUsersearchService.getById(id);
List<OcrUsersearchchild> list = ocrUsersearchchildService.selectByMainId(id);
ocrUsersearch.setOcrUsersearchchildList(list);
if(ocrUsersearch==null) {
return ResultVoUtil.error("未找到对应数据");
}
return ResultVoUtil.success(ocrUsersearch);
}
}

@ -70,7 +70,7 @@ public class OcrCheckDuplicateServiceImpl extends ServiceImpl<OcrCheckDuplicateM
private LogService logService; private LogService logService;
@Resource @Resource
private OcrTaskchildPictureService taskchildPictureService; private OcrTaskchildPictureService ocrTaskchildPictureService;
@Value("${image.classifyPath}") @Value("${image.classifyPath}")
private String classifyPath; private String classifyPath;
@ -220,12 +220,12 @@ public class OcrCheckDuplicateServiceImpl extends ServiceImpl<OcrCheckDuplicateM
String strId = ocrPicture.getId() + ":" + ocrPictureNext.getId(); String strId = ocrPicture.getId() + ":" + ocrPictureNext.getId();
String strNextId = ocrPictureNext.getId() + ":" + ocrPicture.getId(); String strNextId = ocrPictureNext.getId() + ":" + ocrPicture.getId();
if (compareMap.containsKey(strId) || compareMap.containsKey(strNextId)) { if (compareMap.containsKey(strId) || compareMap.containsKey(strNextId)) {
resultValue = resultMap.get(strId) == null ? compareMap.get(strNextId) : compareMap.get(strId); resultValue = compareMap.get(strId) == null ? compareMap.get(strNextId) : compareMap.get(strId);
} else { } else {
String img = org.apache.commons.lang3.StringUtils.isBlank(ocrPicture.getImgHash()) ? org.apache.commons.lang3.StringUtils.isBlank(ocrPicture.getLocalpictrueurl()) ? ocrPicture.getImgurl() : ocrPicture.getLocalpictrueurl() : ocrPicture.getImgHash(); String img = org.apache.commons.lang3.StringUtils.isBlank(ocrPicture.getImgHash()) ? org.apache.commons.lang3.StringUtils.isBlank(ocrPicture.getLocalpictrueurl()) ? ocrPicture.getImgurl() : ocrPicture.getLocalpictrueurl() : ocrPicture.getImgHash();
String imgNext = org.apache.commons.lang3.StringUtils.isBlank(ocrPictureNext.getImgHash()) ? org.apache.commons.lang3.StringUtils.isBlank(ocrPictureNext.getLocalpictrueurl()) ? ocrPictureNext.getImgurl() : ocrPictureNext.getLocalpictrueurl() : ocrPictureNext.getImgHash(); String imgNext = org.apache.commons.lang3.StringUtils.isBlank(ocrPictureNext.getImgHash()) ? org.apache.commons.lang3.StringUtils.isBlank(ocrPictureNext.getLocalpictrueurl()) ? ocrPictureNext.getImgurl() : ocrPictureNext.getLocalpictrueurl() : ocrPictureNext.getImgHash();
resultValue = HashCompareUtil.cmpHash(img, imgNext); resultValue = HashCompareUtil.cmpHash(img, imgNext);
resultMap.put(strId, resultValue); compareMap.put(strId, resultValue);
} }
ocrPictureNext.setResult(resultValue); ocrPictureNext.setResult(resultValue);
BigDecimal b1 = new BigDecimal(resultValue); BigDecimal b1 = new BigDecimal(resultValue);
@ -254,7 +254,7 @@ public class OcrCheckDuplicateServiceImpl extends ServiceImpl<OcrCheckDuplicateM
} }
if (CollectionUtils.isNotEmpty(ocrPictureList)) { if (CollectionUtils.isNotEmpty(ocrPictureList)) {
taskchildPictureService.createTask(ocrPictureList, ocrPictureList.get(0).getTenantId().toString(), sysUser); ocrTaskchildPictureService.createTask(ocrPictureList, ocrPictureList.get(0).getTenantId().toString(), sysUser);
} }
//批量入库 //批量入库
boolean b = checkDuplicateResultService.saveOrUpdateBatch(saveList); boolean b = checkDuplicateResultService.saveOrUpdateBatch(saveList);

@ -550,19 +550,19 @@ public class OcrTaskchildPictureServiceImpl extends BaseServiceImpl<OcrTaskchild
StringBuffer pcid = new StringBuffer(); StringBuffer pcid = new StringBuffer();
StringBuffer result = new StringBuffer(); StringBuffer result = new StringBuffer();
for (OcrPicture comp : ocrPicture.getListCom()) { // for (OcrPicture comp : ocrPicture.getListCom()) {
if (null == pcid || pcid.toString().length() < 1) { // if (null == pcid || pcid.toString().length() < 1) {
pcid.append(comp.getId()); // pcid.append(comp.getId());
result.append(comp.getResult()); // result.append(comp.getResult());
} else { // } else {
pcid.append("," + comp.getId()); // pcid.append("," + comp.getId());
result.append("," + comp.getResult()); // result.append("," + comp.getResult());
} // }
} // }
//
ocrTaskchildPicture.setOcpictureid(pcid.toString()); // ocrTaskchildPicture.setOcpictureid(pcid.toString());
ocrTaskchildPicture.setPictureresult(result.toString()); // ocrTaskchildPicture.setPictureresult(result.toString());
ocrTaskchildPicture.setPicturecompare(String.join(",", ocrPicture.getPicturecompareList())); // ocrTaskchildPicture.setPicturecompare(String.join(",", ocrPicture.getPicturecompareList()));
return this.save(ocrTaskchildPicture) ? ocrTaskchildPicture : null; return this.save(ocrTaskchildPicture) ? ocrTaskchildPicture : null;
} }

Loading…
Cancel
Save