From aa2ea3a0dd21ef2f1d258311287864125ed9512c Mon Sep 17 00:00:00 2001 From: sunchenliang <2532527871@qq.com> Date: Sun, 17 Mar 2024 16:40:18 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=9B=BE=E7=89=87=E6=9C=AC?= =?UTF-8?q?=E5=9C=B0=E5=8C=96=E5=AD=98=E5=82=A8=E5=8F=8A=E4=B8=80=E9=94=AE?= =?UTF-8?q?=E6=9F=A5=E9=87=8D=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ocr/controller/OcrPictureController.java | 559 +++++++------- .../xiaoyao/ocr/dataobject/OcrPicture.java | 707 +++++++++--------- .../ocr/service/OcrPictureService.java | 2 + .../service/impl/OcrPictureServiceImpl.java | 176 +++-- .../impl/OcrTaskchildPictureServiceImpl.java | 30 +- .../cn/jyjz/xiaoyao/ocr/thread/TaskQueue.java | 4 +- .../xiaoyao/ocr/thread/TaskThreadPool.java | 40 +- .../thread/tasks/PictureImgToLocalTask.java | 17 +- .../xiaoyao/ocr/util/DownloadImgUtil.java | 5 +- .../src/main/resources/application-dev.yml | 17 +- .../src/main/resources/application-pro.yml | 2 +- 11 files changed, 842 insertions(+), 717 deletions(-) diff --git a/jyjz-system/jyjz-system-oa/src/main/java/cn/jyjz/xiaoyao/ocr/controller/OcrPictureController.java b/jyjz-system/jyjz-system-oa/src/main/java/cn/jyjz/xiaoyao/ocr/controller/OcrPictureController.java index d2880b6f..e1340a90 100644 --- a/jyjz-system/jyjz-system-oa/src/main/java/cn/jyjz/xiaoyao/ocr/controller/OcrPictureController.java +++ b/jyjz-system/jyjz-system-oa/src/main/java/cn/jyjz/xiaoyao/ocr/controller/OcrPictureController.java @@ -8,6 +8,7 @@ import java.util.List; import java.util.Map; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; + import cn.jyjz.xiaoyao.admin.service.LogService; import cn.jyjz.xiaoyao.common.base.util.RequestBaseUtil; import cn.jyjz.xiaoyao.common.base.vo.UserToken; @@ -38,292 +39,292 @@ 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_图片管理") +@Api(tags = "ocr_图片管理") @RestController @RequestMapping("/ocr/ocrPicture") -public class OcrPictureController extends BaseController{ - - private Logger log = LoggerFactory.getLogger(this.getClass()); - - @Resource - private OcrPictureService ocrPictureService; - @Resource - private OcrPictureclassService ocrPictureclassService; - @Resource - private OcrTaskchildPictureService ocrTaskchildPictureService; - @Resource - private UserTokenService userTokenService; - @Resource - private UserService userService; - @Resource - private LogService logService; - /** - * 工单查询 - * - * @param req - * @return - */ - //@AutoLog(value = "ocr_picture-分页列表查询") - @ApiOperation(value="关闭工单", notes="关闭工单") - @GetMapping(value = "/closeorder") - public ResultVo> closeorder(@RequestParam(name="orderid",required=true) String orderid, - HttpServletRequest req) { - return ocrTaskchildPictureService.closeOrder(orderid)?ResultVoUtil.success():ResultVoUtil.error("失败"); - } - - /** - * 工单查询@MM1vvPNHRprA7ScHnwE+WG6yz7hcA/u3tzMj6pSdvwc= - *@MM1vvPNHRprA7ScHnwE+WG6yz7hcA/u3tzMj6pSdvwc= - * @param ocrPicture - * @param req - * @return - */ - //@AutoLog(value = "ocr_picture-分页列表查询") - @ApiOperation(value="任务查询", notes="任务查询") - @ApiImplicitParams({ - @ApiImplicitParam(paramType = "header", name = "X-Tenant-Id", value = "租户主键,用户登录时的信息“tenantList”中获得。", dataType = "String", required = true), - @ApiImplicitParam(paramType = "path",name = "izClose", value = "是否关闭,0:关闭,1:开启", required = true), - @ApiImplicitParam(paramType = "path",name = "tasktype", value = "任务状态,1:待审批:2:审批中 :3:合格 :4:不合格", required = true) - }) - @GetMapping(value = "/listorder") - public ResultVo> listorder(OcrPicture ocrPicture, - @RequestParam(name="izClose") String izClose, - @RequestParam(name="tasktype") String tasktype, - HttpServletRequest req) { - //租户主键,由前端页面传送 - String tenantId = req.getHeader("X-Tenant-Id"); - if(StringUtils.isBlank(tenantId)){ - return ResultVoUtil.error("租户主键不能为空"); - } - - //获取当前登录人 - UserToken userToken = this.userTokenService.getUserToken(RequestBaseUtil.getToken(req)); - - List pageList = ocrPictureService.listByTaskChild(tenantId,userToken.getLoginname(),izClose,tasktype,null); - - return ResultVoUtil.success(pageList); - } - - /** - * 工单查询 - * - * @param ocrPicture - * @param req - * @return - */ - //@AutoLog(value = "ocr_picture-分页列表查询") - @ApiOperation(value="一键查重", notes="一键查重") - @ApiImplicitParams({ - @ApiImplicitParam(paramType = "header", name = "X-Tenant-Id", value = "租户主键,用户登录时的信息“tenantList”中获得。", dataType = "String", required = true), - @ApiImplicitParam(paramType = "path",name = "search_month", value = "搜索时间,21,一周内,22:两周内,1:进一个月,2:进两个月,3:近三个月、6:近六个月、9:近九个月、12:近12个月", required = true), - @ApiImplicitParam(paramType = "path",name = "search_history", value = "是否查询历史记录,0:不查询,1:查询", required = true) - }) - @GetMapping(value = "/createorder") - public ResultVo createorder(OcrPicture ocrPicture, - HttpServletRequest req) { - - //获取当前登录人 - UserToken userToken = this.userTokenService.getUserToken(RequestBaseUtil.getToken(req)); - - //租户主键,由前端页面传送 - String tenantId = req.getHeader("X-Tenant-Id"); - if(StringUtils.isBlank(tenantId)){ - return ResultVoUtil.error("租户主键不能为空"); - } - - QueryWrapper queryWrapper = new QueryWrapper<>(); - - //是否查询历史记录 - String search_history = req.getParameter("search_history"); - - //任务包名称 - String buessinessno = req.getParameter("buessinessno"); - - //搜索时间段 +public class OcrPictureController extends BaseController { + + private Logger log = LoggerFactory.getLogger(this.getClass()); + + @Resource + private OcrPictureService ocrPictureService; + @Resource + private OcrPictureclassService ocrPictureclassService; + @Resource + private OcrTaskchildPictureService ocrTaskchildPictureService; + @Resource + private UserTokenService userTokenService; + @Resource + private UserService userService; + @Resource + private LogService logService; + + /** + * 工单查询 + * + * @param req + * @return + */ + //@AutoLog(value = "ocr_picture-分页列表查询") + @ApiOperation(value = "关闭工单", notes = "关闭工单") + @GetMapping(value = "/closeorder") + public ResultVo> closeorder(@RequestParam(name = "orderid", required = true) String orderid, + HttpServletRequest req) { + return ocrTaskchildPictureService.closeOrder(orderid) ? ResultVoUtil.success() : ResultVoUtil.error("失败"); + } + + /** + * 工单查询@MM1vvPNHRprA7ScHnwE+WG6yz7hcA/u3tzMj6pSdvwc= + * + * @param ocrPicture + * @param req + * @return + * @MM1vvPNHRprA7ScHnwE+WG6yz7hcA/u3tzMj6pSdvwc= + */ + //@AutoLog(value = "ocr_picture-分页列表查询") + @ApiOperation(value = "任务查询", notes = "任务查询") + @ApiImplicitParams({ + @ApiImplicitParam(paramType = "header", name = "X-Tenant-Id", value = "租户主键,用户登录时的信息“tenantList”中获得。", dataType = "String", required = true), + @ApiImplicitParam(paramType = "path", name = "izClose", value = "是否关闭,0:关闭,1:开启", required = true), + @ApiImplicitParam(paramType = "path", name = "tasktype", value = "任务状态,1:待审批:2:审批中 :3:合格 :4:不合格", required = true) + }) + @GetMapping(value = "/listorder") + public ResultVo> listorder(OcrPicture ocrPicture, + @RequestParam(name = "izClose") String izClose, + @RequestParam(name = "tasktype") String tasktype, + HttpServletRequest req) { + //租户主键,由前端页面传送 + String tenantId = req.getHeader("X-Tenant-Id"); + if (StringUtils.isBlank(tenantId)) { + return ResultVoUtil.error("租户主键不能为空"); + } + + //获取当前登录人 + UserToken userToken = this.userTokenService.getUserToken(RequestBaseUtil.getToken(req)); + + List pageList = ocrPictureService.listByTaskChild(tenantId, userToken.getLoginname(), izClose, tasktype, null); + + return ResultVoUtil.success(pageList); + } + + /** + * 工单查询 + * + * @param ocrPicture + * @param req + * @return + */ + //@AutoLog(value = "ocr_picture-分页列表查询") + @ApiOperation(value = "一键查重", notes = "一键查重") + @ApiImplicitParams({ + @ApiImplicitParam(paramType = "header", name = "X-Tenant-Id", value = "租户主键,用户登录时的信息“tenantList”中获得。", dataType = "String", required = true), + @ApiImplicitParam(paramType = "path", name = "search_month", value = "搜索时间,21,一周内,22:两周内,1:进一个月,2:进两个月,3:近三个月、6:近六个月、9:近九个月、12:近12个月", required = true), + @ApiImplicitParam(paramType = "path", name = "search_history", value = "是否查询历史记录,0:不查询,1:查询", required = true) + }) + @GetMapping(value = "/createorder") + public ResultVo createorder(OcrPicture ocrPicture, + HttpServletRequest req) { + + //获取当前登录人 + UserToken userToken = this.userTokenService.getUserToken(RequestBaseUtil.getToken(req)); + + //租户主键,由前端页面传送 + String tenantId = req.getHeader("X-Tenant-Id"); + if (StringUtils.isBlank(tenantId)) { + return ResultVoUtil.error("租户主键不能为空"); + } + + QueryWrapper queryWrapper = new QueryWrapper<>(); + + //是否查询历史记录 + String search_history = req.getParameter("search_history"); + + //任务包名称 + 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))); - } - - //判断是否需要查询历史记录 - if(search_history.equals("0")){ - queryWrapper.eq("taskstatus", search_history); - } - - - //根据参数枚举,获取检索参数,并映射为数据库的字段的key-v map - Map 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 pageList = ocrPictureService.listPage(queryWrapper); - - if(null != pageList && !pageList.isEmpty()){ - if(pageList.size() == 1){ - return ResultVoUtil.error("查重数据至少要有两条。"); - }else{ - return ocrPictureService.createTaskChild(pageList,tenantId,userToken,search_month, req,buessinessno); - } - }else{ - return ResultVoUtil.error("没有查重数据。"); - } - } - - /** - * 分页列表查询 - * - * @param ocrPicture - * @param pageNo - * @param pageSize - * @param req - * @return - */ - //@AutoLog(value = "ocr_picture-分页列表查询") - @ApiOperation(value="图片分页列表查询", notes="图片分页列表查询@MMlvuvNARprA7ScHnwE+WFPWEBliKUwgUPHdB2Ue9Bw=") - @ApiImplicitParams({ - @ApiImplicitParam(paramType = "header", name = "X-Tenant-Id", value = "租户主键,用户登录时的信息“tenantList”中获得。", dataType = "String", required = true), - @ApiImplicitParam(paramType = "path",name = "search_month", value = "搜索时间,3:近三个月、6:近六个月、9:近九个月、12:近12个月、99:一年以上(全部)", required = true), - @ApiImplicitParam(paramType = "path",name = "search_history", value = "是否查询历史记录,0:不查询,1:查询", required = true) - }) - @GetMapping(value = "/list") - public ResultVo> queryPageList(OcrPicture ocrPicture, - @RequestParam(name="pageNo", defaultValue="1") Integer pageNo, - @RequestParam(name="pageSize", defaultValue="10") Integer pageSize, - HttpServletRequest req) { - //租户主键,由前端页面传送 - String tenantId = req.getHeader("X-Tenant-Id"); - if(StringUtils.isBlank(tenantId)){ - return ResultVoUtil.error("租户主键不能为空"); - } - - QueryWrapper queryWrapper = new QueryWrapper<>(); - - //是否查询历史记录 - String search_history = req.getParameter("search_history"); - //判断是否需要查询历史记录 - if(search_history.equals("0")){ - queryWrapper.eq("taskstatus", search_history); - } - - 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))); - } - - //根据参数枚举,获取检索参数,并映射为数据库的字段的key-v map - Map paraMap = new HashMap<>(); - for(SearchConfigEnum config : SearchConfigEnum.values()){ - String searchvalue = req.getParameter(config.getId()); - if(!StringUtils.isEmpty(searchvalue)){ - paraMap.put(config.getMeaning(),searchvalue); - } - } - //调用查询参数解析方法,解析为queryWrapper - queryWrapper = SearchParaFormatting.searchParaParse(queryWrapper,paraMap); - - queryWrapper.eq("tenant_id",tenantId); - Page page = new Page(pageNo, pageSize); - IPage pageList = ocrPictureService.page(page, queryWrapper); - - for(OcrPicture ocrPicture1:pageList.getRecords()){ - if(StringUtils.isNotBlank(ocrPicture1.getPictureclassid())){ - OcrPictureclass ocrPictureclass = this.ocrPictureclassService.getById(ocrPicture1.getPictureclassid()); - ocrPicture1.setOcrPictureclass(ocrPictureclass); - } - - } - - return ResultVoUtil.success(pageList); - } - - /** - * 分页列表查询 - * - * @param pageNo - * @param pageSize - * @param req - * @return - */ - @ApiOperation(value="图片分页列表查询-根据用户预设检索条件查询", notes="") - @ApiImplicitParams({ - @ApiImplicitParam(paramType = "header", name = "X-Tenant-Id", value = "租户主键,用户登录时的信息“tenantList”中获得。", dataType = "String", required = true), - @ApiImplicitParam(paramType = "path",name = "userSearchId", value = "预设检索条件id", required = true), - }) - @GetMapping(value = "/listByUserSearchId") - public ResultVo> queryPageByUserSearchId( - @RequestParam(name="pageNo", defaultValue="1") Integer pageNo, - @RequestParam(name="pageSize", defaultValue="10") Integer pageSize, - HttpServletRequest req) { - - //租户主键,由前端页面传送 - String tenantId = req.getHeader("X-Tenant-Id"); - if(StringUtils.isBlank(tenantId)){ - return ResultVoUtil.error("租户主键不能为空"); - } - - //获取用户预设检索条件id - String userSearchId = req.getParameter("userSearchId"); - IPage pageList = ocrPictureService.queryPageByUserSearchId(pageNo,pageSize,userSearchId); - return ResultVoUtil.success(pageList); - } - - - /** - * 分页列表查询 - * - * @param ocrPicture - * @return - */ - //@AutoLog(value = "ocr_picture-分页列表查询") - @ApiOperation(value="图片信息接收", notes="图片信息接收") - @PostMapping(value = "/loadpicture") - public ResultVo loadpicture(OcrPicture ocrPicture, - HttpServletRequest request) { - - BufferedReader streamReader = null; - try { - streamReader = new BufferedReader( new InputStreamReader(request.getInputStream(),"UTF-8")); - } catch (IOException e) { - log.error("【数据接收】jsonFormatError:{}",e); - logService.addLog(101,"接收数据失败。",null,null); - ResultVoUtil.error("失败"); - } - StringBuilder sb = new StringBuilder(); - String inputStr; - try { - while ((inputStr = streamReader.readLine()) != null) { - sb.append(inputStr); - } - } catch (IOException e) { - log.error("【数据接收】jsonFormatError:{}",e); - logService.addLog(101,"接收数据失败。",null,null); - } - - logService.addLog(101,"接收数据成功。",null,null); - - JSONObject jsonArray = JSONObject.parseObject(sb.toString()); - - //TODO 结束json数据,并持久化 - //this.ocrPictureService - //TODO AI获取图片分类接口 - - logService.addLog(102,"AI获取图片分类接口。",null,null); - - return ResultVoUtil.success(); - } + 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))); + } + + //判断是否需要查询历史记录 + if (search_history.equals("0")) { + queryWrapper.eq("taskstatus", search_history); + } + + + //根据参数枚举,获取检索参数,并映射为数据库的字段的key-v map + Map 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 pageList = ocrPictureService.listPage(queryWrapper); + if (null != pageList && !pageList.isEmpty()) { + if (pageList.size() == 1) { + return ResultVoUtil.error("查重数据至少要有两条。"); + } else { + return ocrPictureService.createPackageTask(pageList, tenantId, userToken, search_month, req, buessinessno); + } + } else { + return ResultVoUtil.error("没有查重数据。"); + } + } + + /** + * 分页列表查询 + * + * @param ocrPicture + * @param pageNo + * @param pageSize + * @param req + * @return + */ + //@AutoLog(value = "ocr_picture-分页列表查询") + @ApiOperation(value = "图片分页列表查询", notes = "图片分页列表查询@MMlvuvNARprA7ScHnwE+WFPWEBliKUwgUPHdB2Ue9Bw=") + @ApiImplicitParams({ + @ApiImplicitParam(paramType = "header", name = "X-Tenant-Id", value = "租户主键,用户登录时的信息“tenantList”中获得。", dataType = "String", required = true), + @ApiImplicitParam(paramType = "path", name = "search_month", value = "搜索时间,3:近三个月、6:近六个月、9:近九个月、12:近12个月、99:一年以上(全部)", required = true), + @ApiImplicitParam(paramType = "path", name = "search_history", value = "是否查询历史记录,0:不查询,1:查询", required = true) + }) + @GetMapping(value = "/list") + public ResultVo> queryPageList(OcrPicture ocrPicture, + @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, + @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize, + HttpServletRequest req) { + //租户主键,由前端页面传送 + String tenantId = req.getHeader("X-Tenant-Id"); + if (StringUtils.isBlank(tenantId)) { + return ResultVoUtil.error("租户主键不能为空"); + } + + QueryWrapper queryWrapper = new QueryWrapper<>(); + + //是否查询历史记录 + String search_history = req.getParameter("search_history"); + //判断是否需要查询历史记录 + if (search_history.equals("0")) { + queryWrapper.eq("taskstatus", search_history); + } + + 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))); + } + + //根据参数枚举,获取检索参数,并映射为数据库的字段的key-v map + Map paraMap = new HashMap<>(); + for (SearchConfigEnum config : SearchConfigEnum.values()) { + String searchvalue = req.getParameter(config.getId()); + if (!StringUtils.isEmpty(searchvalue)) { + paraMap.put(config.getMeaning(), searchvalue); + } + } + //调用查询参数解析方法,解析为queryWrapper + queryWrapper = SearchParaFormatting.searchParaParse(queryWrapper, paraMap); + + queryWrapper.eq("tenant_id", tenantId); + Page page = new Page(pageNo, pageSize); + IPage pageList = ocrPictureService.page(page, queryWrapper); + + for (OcrPicture ocrPicture1 : pageList.getRecords()) { + if (StringUtils.isNotBlank(ocrPicture1.getPictureclassid())) { + OcrPictureclass ocrPictureclass = this.ocrPictureclassService.getById(ocrPicture1.getPictureclassid()); + ocrPicture1.setOcrPictureclass(ocrPictureclass); + } + + } + + return ResultVoUtil.success(pageList); + } + + /** + * 分页列表查询 + * + * @param pageNo + * @param pageSize + * @param req + * @return + */ + @ApiOperation(value = "图片分页列表查询-根据用户预设检索条件查询", notes = "") + @ApiImplicitParams({ + @ApiImplicitParam(paramType = "header", name = "X-Tenant-Id", value = "租户主键,用户登录时的信息“tenantList”中获得。", dataType = "String", required = true), + @ApiImplicitParam(paramType = "path", name = "userSearchId", value = "预设检索条件id", required = true), + }) + @GetMapping(value = "/listByUserSearchId") + public ResultVo> queryPageByUserSearchId( + @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, + @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize, + HttpServletRequest req) { + + //租户主键,由前端页面传送 + String tenantId = req.getHeader("X-Tenant-Id"); + if (StringUtils.isBlank(tenantId)) { + return ResultVoUtil.error("租户主键不能为空"); + } + + //获取用户预设检索条件id + String userSearchId = req.getParameter("userSearchId"); + IPage pageList = ocrPictureService.queryPageByUserSearchId(pageNo, pageSize, userSearchId); + return ResultVoUtil.success(pageList); + } + + + /** + * 分页列表查询 + * + * @param ocrPicture + * @return + */ + //@AutoLog(value = "ocr_picture-分页列表查询") + @ApiOperation(value = "图片信息接收", notes = "图片信息接收") + @PostMapping(value = "/loadpicture") + public ResultVo loadpicture(OcrPicture ocrPicture, + HttpServletRequest request) { + + BufferedReader streamReader = null; + try { + streamReader = new BufferedReader(new InputStreamReader(request.getInputStream(), "UTF-8")); + } catch (IOException e) { + log.error("【数据接收】jsonFormatError:{}", e); + logService.addLog(101, "接收数据失败。", null, null); + ResultVoUtil.error("失败"); + } + StringBuilder sb = new StringBuilder(); + String inputStr; + try { + while ((inputStr = streamReader.readLine()) != null) { + sb.append(inputStr); + } + } catch (IOException e) { + log.error("【数据接收】jsonFormatError:{}", e); + logService.addLog(101, "接收数据失败。", null, null); + } + + logService.addLog(101, "接收数据成功。", null, null); + + JSONObject jsonArray = JSONObject.parseObject(sb.toString()); + + //TODO 结束json数据,并持久化 + //this.ocrPictureService + //TODO AI获取图片分类接口 + + logService.addLog(102, "AI获取图片分类接口。", null, null); + + return ResultVoUtil.success(); + } } diff --git a/jyjz-system/jyjz-system-oa/src/main/java/cn/jyjz/xiaoyao/ocr/dataobject/OcrPicture.java b/jyjz-system/jyjz-system-oa/src/main/java/cn/jyjz/xiaoyao/ocr/dataobject/OcrPicture.java index fcc737ed..378d50e9 100644 --- a/jyjz-system/jyjz-system-oa/src/main/java/cn/jyjz/xiaoyao/ocr/dataobject/OcrPicture.java +++ b/jyjz-system/jyjz-system-oa/src/main/java/cn/jyjz/xiaoyao/ocr/dataobject/OcrPicture.java @@ -26,373 +26,382 @@ import java.util.stream.Stream; import java.util.stream.Collectors; - @Data @Builder @NoArgsConstructor @AllArgsConstructor @Schema(name = "图片信息表", title = "图片信息表") -@ApiModel(value="图片信息表", description="图片信息表") +@ApiModel(value = "图片信息表", description = "图片信息表") @TableName(value = "ocr_picture") -public class OcrPicture implements BaseDto,java.io.Serializable { - - private static final long serialVersionUID = -10378331243377607L; - @ApiModelProperty(value ="主键") - @TableId(value = "id",type = IdType.ASSIGN_ID) - @JsonSerialize(using = ToStringSerializer.class) - @TableField(value="ID") - private Long id; - - @ApiModelProperty(value ="创建人") - @TableField(value="create_by") - private String createBy; - - @ApiModelProperty(value ="创建时间") - @TableField(value="create_time") - @JsonSerialize(using = DateSerializer.class) - private Long createTime; - - @ApiModelProperty(value ="修改人") - @TableField(value="update_by") - private String updateBy; - - @ApiModelProperty(value ="修改时间") - @TableField(value="update_time") - @JsonSerialize(using = DateSerializer.class) - private Long updateTime; - - @ApiModelProperty(value ="分类表主键--通过“图片分类”字段做匹配,如果没有自动添加") - @TableField(value="classificationid") - private String classificationid; - - @ApiModelProperty(value ="图片类型--通过“AI图片分类接口获得”") - @TableField(value="pictureclassid") - private String pictureclassid; - - @Schema(description = "图片类型相似度,图片类型--通过“AI图片分类接口获得”") - @TableField(value="pictureclassscores") - private String pictureclassscores; - - @ApiModelProperty(value ="图片真假0:假,1:真") - @TableField(value="iztrueorfalse",updateStrategy = FieldStrategy.IGNORED) - private Integer iztrueorfalse; - - @ApiModelProperty(value ="选判真假原因id,从字典表中获得,其他时,当前字段为零") - @TableField(value="judgeid",updateStrategy = FieldStrategy.IGNORED) - @JsonSerialize(using = ToStringSerializer.class) - private Long judgeid; - - @ApiModelProperty(value ="图片为假的其他原因,长度不超过50个汉字") - @TableField(value="judgedesc",updateStrategy = FieldStrategy.IGNORED) - private String judgedesc; - - @ApiModelProperty(value ="公司ID") - @JsonSerialize(using = ToStringSerializer.class) - @TableField(value="tenant_id") - private Long tenantId; - - @ApiModelProperty(value ="公司状态") - @TableField(value="tenantstatus") - private String tenantstatus; - - @ApiModelProperty(value ="公司代码,第三方系统") - @TableField(value="plantCode") - private String plantcode; - - @ApiModelProperty(value ="公司名称") - @TableField(value="tenantname") - private String tenantname; - - @ApiModelProperty(value ="业务主体ID--图片主键") - @TableField(value="pictureid") - private String pictureid; - - @ApiModelProperty(value ="业务主体名称--图片成名") - @TableField(value="picturename") - private String picturename; - - @ApiModelProperty(value ="图片名称") - @TableField(value="imgName") - private String imgname; - - @ApiModelProperty(value ="图片地址") - @TableField(value="imgUrl") - private String imgurl; - - @ApiModelProperty(value ="业务主体状态") - @TableField(value="picturestatus") - private String picturestatus; - - @ApiModelProperty(value ="源项目id") - @TableField(value="projectId") - private String projectid; - - @ApiModelProperty(value ="项目名称") - @TableField(value="projectIdName") - private String projectidname; - - @ApiModelProperty(value ="项目状态") - @TableField(value="projectstatus") - private String projectstatus; - - @ApiModelProperty(value ="源计划id") - @TableField(value="planId") - private String planid; - - @ApiModelProperty(value ="计划名称") - @TableField(value="planName") - private String planname; - - @ApiModelProperty(value ="计划状态") - @TableField(value="planstatus") - private String planstatus; - - @ApiModelProperty(value ="所属子计划ID") - @TableField(value="planchildid") - private String planchildid; - - @ApiModelProperty(value ="所属子计划名称") - @TableField(value="planchildname") - private String planchildname; - - @ApiModelProperty(value ="所属子计划状态") - @TableField(value="planchildstatus") - private String planchildstatus; - - @ApiModelProperty(value ="上传时间") - @JsonSerialize(using = DateNotimeSerializer.class) - @TableField(value="upTime") - private Long uptime; - - @ApiModelProperty(value ="生成时间") - @JsonSerialize(using = DateNotimeSerializer.class) - @TableField(value="genTime") - private Long gentime; +public class OcrPicture implements BaseDto, java.io.Serializable { + + private static final long serialVersionUID = -10378331243377607L; + @ApiModelProperty(value = "主键") + @TableId(value = "id", type = IdType.ASSIGN_ID) + @JsonSerialize(using = ToStringSerializer.class) + @TableField(value = "ID") + private Long id; + + @ApiModelProperty(value = "创建人") + @TableField(value = "create_by") + private String createBy; + + @ApiModelProperty(value = "创建时间") + @TableField(value = "create_time") + @JsonSerialize(using = DateSerializer.class) + private Long createTime; + + @ApiModelProperty(value = "修改人") + @TableField(value = "update_by") + private String updateBy; + + @ApiModelProperty(value = "修改时间") + @TableField(value = "update_time") + @JsonSerialize(using = DateSerializer.class) + private Long updateTime; + + @ApiModelProperty(value = "分类表主键--通过“图片分类”字段做匹配,如果没有自动添加") + @TableField(value = "classificationid") + private String classificationid; + + @ApiModelProperty(value = "图片类型--通过“AI图片分类接口获得”") + @TableField(value = "pictureclassid") + private String pictureclassid; + + @Schema(description = "图片类型相似度,图片类型--通过“AI图片分类接口获得”") + @TableField(value = "pictureclassscores") + private String pictureclassscores; + + @ApiModelProperty(value = "图片真假0:假,1:真") + @TableField(value = "iztrueorfalse", updateStrategy = FieldStrategy.IGNORED) + private Integer iztrueorfalse; + + @ApiModelProperty(value = "选判真假原因id,从字典表中获得,其他时,当前字段为零") + @TableField(value = "judgeid", updateStrategy = FieldStrategy.IGNORED) + @JsonSerialize(using = ToStringSerializer.class) + private Long judgeid; + + @ApiModelProperty(value = "图片为假的其他原因,长度不超过50个汉字") + @TableField(value = "judgedesc", updateStrategy = FieldStrategy.IGNORED) + private String judgedesc; + + @ApiModelProperty(value = "公司ID") + @JsonSerialize(using = ToStringSerializer.class) + @TableField(value = "tenant_id") + private Long tenantId; + + @ApiModelProperty(value = "公司状态") + @TableField(value = "tenantstatus") + private String tenantstatus; + + @ApiModelProperty(value = "公司代码,第三方系统") + @TableField(value = "plantCode") + private String plantcode; + + @ApiModelProperty(value = "公司名称") + @TableField(value = "tenantname") + private String tenantname; + + @ApiModelProperty(value = "业务主体ID--图片主键") + @TableField(value = "pictureid") + private String pictureid; + + @ApiModelProperty(value = "业务主体名称--图片成名") + @TableField(value = "picturename") + private String picturename; + + @ApiModelProperty(value = "图片名称") + @TableField(value = "imgName") + private String imgname; + + @ApiModelProperty(value = "图片地址") + @TableField(value = "imgUrl") + private String imgurl; + + @ApiModelProperty(value = "业务主体状态") + @TableField(value = "picturestatus") + private String picturestatus; + + @ApiModelProperty(value = "源项目id") + @TableField(value = "projectId") + private String projectid; + + @ApiModelProperty(value = "项目名称") + @TableField(value = "projectIdName") + private String projectidname; + + @ApiModelProperty(value = "项目状态") + @TableField(value = "projectstatus") + private String projectstatus; + + @ApiModelProperty(value = "源计划id") + @TableField(value = "planId") + private String planid; + + @ApiModelProperty(value = "计划名称") + @TableField(value = "planName") + private String planname; + + @ApiModelProperty(value = "计划状态") + @TableField(value = "planstatus") + private String planstatus; + + @ApiModelProperty(value = "所属子计划ID") + @TableField(value = "planchildid") + private String planchildid; + + @ApiModelProperty(value = "所属子计划名称") + @TableField(value = "planchildname") + private String planchildname; + + @ApiModelProperty(value = "所属子计划状态") + @TableField(value = "planchildstatus") + private String planchildstatus; + + @ApiModelProperty(value = "上传时间") + @JsonSerialize(using = DateNotimeSerializer.class) + @TableField(value = "upTime") + private Long uptime; + + @ApiModelProperty(value = "生成时间") + @JsonSerialize(using = DateNotimeSerializer.class) + @TableField(value = "genTime") + private Long gentime; + + @ApiModelProperty(value = "色彩空间") + @TableField(value = "space") + private String space; + + @ApiModelProperty(value = "来源") + @TableField(value = "source") + private String source; - @ApiModelProperty(value ="色彩空间") - @TableField(value="space") - private String space; + @ApiModelProperty(value = "上报者头像--接口传送") + @TableField(value = "upHead") + private String uphead; - @ApiModelProperty(value ="来源") - @TableField(value="source") - private String source; + @ApiModelProperty(value = "上报人主键") + @TableField(value = "upuserid") + private String upuserid; - @ApiModelProperty(value ="上报者头像--接口传送") - @TableField(value="upHead") - private String uphead; + @ApiModelProperty(value = "上报者名称--接口传送") + @TableField(value = "upName") + private String upname; - @ApiModelProperty(value ="上报人主键") - @TableField(value="upuserid") - private String upuserid; + @ApiModelProperty(value = "发布地区,拜访城市,城市名称,例如:北京市、天津市、石家庄市") + @TableField(value = "releaseArea") + private String releasearea; - @ApiModelProperty(value ="上报者名称--接口传送") - @TableField(value="upName") - private String upname; + @ApiModelProperty(value = "拜访省份") + @TableField(value = "releaseProvince") + private String releaseprovince; - @ApiModelProperty(value ="发布地区,拜访城市,城市名称,例如:北京市、天津市、石家庄市") - @TableField(value="releaseArea") - private String releasearea; + @ApiModelProperty(value = "任务id") + @TableField(value = "remark") + private String remark; - @ApiModelProperty(value ="拜访省份") - @TableField(value="releaseProvince") - private String releaseprovince; + @ApiModelProperty(value = "任务名称,源系统") + @TableField(value = "taskName") + private String taskname; - @ApiModelProperty(value ="任务id") - @TableField(value="remark") - private String remark; + @ApiModelProperty(value = "是否已经生成任务,0:否,1:是") + @TableField(value = "taskstatus") + private String taskstatus; - @ApiModelProperty(value ="任务名称,源系统") - @TableField(value="taskName") - private String taskname; + @ApiModelProperty(value = "是否已经审批,0:未生成,1:审批中,2:已审批") + @TableField(value = "work_status") + private String workStatus; - @ApiModelProperty(value ="是否已经生成任务,0:否,1:是") - @TableField(value="taskstatus") - private String taskstatus; + @ApiModelProperty(value = "现项目ID") + @TableField(value = "categoryid") + private Long categoryid; - @ApiModelProperty(value ="是否已经审批,0:未生成,1:审批中,2:已审批") - @TableField(value="work_status") - private String workStatus; + @ApiModelProperty(value = "任务-工单主键") + @TableField(value = "taskchildpictureid") + private String taskchildpictureid; - @ApiModelProperty(value ="现项目ID") - @TableField(value="categoryid") - private Long categoryid; + @ApiModelProperty(value = "提报人") + @TableField(value = "field1") + private String field1; - @ApiModelProperty(value ="任务-工单主键") - @TableField(value="taskchildpictureid") - private String taskchildpictureid; + @ApiModelProperty(value = "拜访客户类型") + @TableField(value = "field2") + private String field2; - @ApiModelProperty(value ="提报人") - @TableField(value="field1") - private String field1; - - @ApiModelProperty(value ="拜访客户类型") - @TableField(value="field2") - private String field2; - - @ApiModelProperty(value ="拜访客户名称,终端名称,例如中日友好医院") - @TableField(value="field3") - private String field3; - - @ApiModelProperty(value ="任务来源") - @TableField(value="field4") - private String field4; - - @ApiModelProperty(value ="厂商") - @TableField(value="field5") - private String field5; - - @ApiModelProperty(value ="拜访客户级别") - @TableField(value="field6") - private String field6; - - @ApiModelProperty(value ="科室名称") - @TableField(value="field7") - private String field7; - - @ApiModelProperty(value ="拜访小结") - @TableField(value="field8") - private String field8; - - @ApiModelProperty(value ="产品名称") - @TableField(value="field9") - private String field9; - - @ApiModelProperty(value ="地区,定位信息,例如北京市朝阳区文苑路10号") - @TableField(value="field10") - private String field10; - - @ApiModelProperty(value ="拜访日期") - @TableField(value="field11") - private String field11; - - @ApiModelProperty(value ="定位距离") - @TableField(value="field12") - private String field12; - - @ApiModelProperty(value ="病历号") - @TableField(value="field13") - private String field13; - - @ApiModelProperty(value ="是否重复") - @TableField(value="field14") - private String field14; - - @ApiModelProperty(value ="任务类型") - @TableField(value="field15") - private String field15; - - @ApiModelProperty(value ="任务状态") - @TableField(value="field16") - private String field16; - - - @Schema(description = "拜访项目类别") - @TableField(value="field17") - private String field17; - - @Schema(description = "备用字段") - @TableField(value="field18") - private String field18; - - @ApiModelProperty(value = "图片查重的比对图片集合") - @TableField(exist = false) - private List listCom; - - @ApiModelProperty(value = "非历史图片主键集合") - @TableField(exist = false) - private List picturecompareList; - - @ApiModelProperty(value = "图片对应的工单对象") - @TableField(exist = false) - private OcrTaskchildPicture ocrTaskchildPicture; - - @ApiModelProperty(value = "当前图片与参考图比对结果") - //当前图片与参考图比对结果 - @TableField(exist = false) - private String result; - - //图片分类 - @TableField(exist = false) - private OcrPictureclass ocrPictureclass; - - //保存当前登录用户的数据权限范围的搜索条件 - @TableField(exist = false) - @JsonIgnore - private SearchQuery searchQueryrolesShowleave; - - @TableField(exist = false) - @JsonIgnore - private final Map query = Stream.of( - new SimpleEntry<>("ID","id"), - new SimpleEntry<>("create_by","createBy"), - new SimpleEntry<>("create_time","createTime"), - new SimpleEntry<>("update_by","updateBy"), - new SimpleEntry<>("update_time","updateTime"), - new SimpleEntry<>("classificationid","classificationid"), - new SimpleEntry<>("pictureclassid","pictureclassid"), - new SimpleEntry<>("pictureclassscores","pictureclassscores"), - new SimpleEntry<>("iztrueorfalse","iztrueorfalse"), - new SimpleEntry<>("judgeid","judgeid"), - new SimpleEntry<>("judgedesc","judgedesc"), - new SimpleEntry<>("tenant_id","tenantId"), - new SimpleEntry<>("tenantstatus","tenantstatus"), - new SimpleEntry<>("plantCode","plantcode"), - new SimpleEntry<>("tenantname","tenantname"), - new SimpleEntry<>("pictureid","pictureid"), - new SimpleEntry<>("picturename","picturename"), - new SimpleEntry<>("imgName","imgname"), - new SimpleEntry<>("imgUrl","imgurl"), - new SimpleEntry<>("picturestatus","picturestatus"), - new SimpleEntry<>("projectId","projectid"), - new SimpleEntry<>("projectIdName","projectidname"), - new SimpleEntry<>("projectstatus","projectstatus"), - new SimpleEntry<>("planId","planid"), - new SimpleEntry<>("planName","planname"), - new SimpleEntry<>("planstatus","planstatus"), - new SimpleEntry<>("planchildid","planchildid"), - new SimpleEntry<>("planchildname","planchildname"), - new SimpleEntry<>("planchildstatus","planchildstatus"), - new SimpleEntry<>("upTime","uptime"), - new SimpleEntry<>("genTime","gentime"), - new SimpleEntry<>("space","space"), - new SimpleEntry<>("source","source"), - new SimpleEntry<>("upHead","uphead"), - new SimpleEntry<>("upuserid","upuserid"), - new SimpleEntry<>("upName","upname"), - new SimpleEntry<>("releaseArea","releasearea"), - new SimpleEntry<>("releaseProvince","releaseprovince"), - new SimpleEntry<>("remark","remark"), - new SimpleEntry<>("taskName","taskname"), - new SimpleEntry<>("taskstatus","taskstatus"), - new SimpleEntry<>("work_status","workStatus"), - new SimpleEntry<>("categoryid","categoryid"), - new SimpleEntry<>("taskchildpictureid","taskchildpictureid"), - new SimpleEntry<>("field1","field1"), - new SimpleEntry<>("field2","field2"), - new SimpleEntry<>("field3","field3"), - new SimpleEntry<>("field4","field4"), - new SimpleEntry<>("field5","field5"), - new SimpleEntry<>("field6","field6"), - new SimpleEntry<>("field7","field7"), - new SimpleEntry<>("field8","field8"), - new SimpleEntry<>("field9","field9"), - new SimpleEntry<>("field10","field10"), - new SimpleEntry<>("field11","field11"), - new SimpleEntry<>("field12","field12"), - new SimpleEntry<>("field13","field13"), - new SimpleEntry<>("field14","field14"), - new SimpleEntry<>("field15","field15"), - new SimpleEntry<>("field16","field16"), - new SimpleEntry<>("field17","field17"), - new SimpleEntry<>("field18","field18") - ) - .collect(Collectors.toMap(SimpleEntry::getKey, SimpleEntry::getValue)); - @Override - public String getQueryFiled(String filedname){ - String obj = null; - if(null != query && query.size() > 0){ - obj = query.get(filedname); - } - return obj; - } + @ApiModelProperty(value = "拜访客户名称,终端名称,例如中日友好医院") + @TableField(value = "field3") + private String field3; + + @ApiModelProperty(value = "任务来源") + @TableField(value = "field4") + private String field4; + + @ApiModelProperty(value = "厂商") + @TableField(value = "field5") + private String field5; + + @ApiModelProperty(value = "拜访客户级别") + @TableField(value = "field6") + private String field6; + + @ApiModelProperty(value = "科室名称") + @TableField(value = "field7") + private String field7; + + @ApiModelProperty(value = "拜访小结") + @TableField(value = "field8") + private String field8; + + @ApiModelProperty(value = "产品名称") + @TableField(value = "field9") + private String field9; + + @ApiModelProperty(value = "地区,定位信息,例如北京市朝阳区文苑路10号") + @TableField(value = "field10") + private String field10; + + @ApiModelProperty(value = "拜访日期") + @TableField(value = "field11") + private String field11; + + @ApiModelProperty(value = "定位距离") + @TableField(value = "field12") + private String field12; + + @ApiModelProperty(value = "病历号") + @TableField(value = "field13") + private String field13; + + @ApiModelProperty(value = "是否重复") + @TableField(value = "field14") + private String field14; + + @ApiModelProperty(value = "任务类型") + @TableField(value = "field15") + private String field15; + + @ApiModelProperty(value = "任务状态") + @TableField(value = "field16") + private String field16; + + + @Schema(description = "拜访项目类别") + @TableField(value = "field17") + private String field17; + + @Schema(description = "备用字段") + @TableField(value = "field18") + private String field18; + + @Schema(description = "本地图片地址") + @TableField(value = "local_pictrue_url") + private String localpictrueurl; + + @Schema(description = "是否已下载到本地") + @TableField(value = "is_download") + private Integer isdownload; + + @ApiModelProperty(value = "图片查重的比对图片集合") + @TableField(exist = false) + private List listCom; + + @ApiModelProperty(value = "非历史图片主键集合") + @TableField(exist = false) + private List picturecompareList; + + @ApiModelProperty(value = "图片对应的工单对象") + @TableField(exist = false) + private OcrTaskchildPicture ocrTaskchildPicture; + + @ApiModelProperty(value = "当前图片与参考图比对结果") + //当前图片与参考图比对结果 + @TableField(exist = false) + private String result; + + //图片分类 + @TableField(exist = false) + private OcrPictureclass ocrPictureclass; + + //保存当前登录用户的数据权限范围的搜索条件 + @TableField(exist = false) + @JsonIgnore + private SearchQuery searchQueryrolesShowleave; + + @TableField(exist = false) + @JsonIgnore + private final Map query = Stream.of( + new SimpleEntry<>("ID", "id"), + new SimpleEntry<>("create_by", "createBy"), + new SimpleEntry<>("create_time", "createTime"), + new SimpleEntry<>("update_by", "updateBy"), + new SimpleEntry<>("update_time", "updateTime"), + new SimpleEntry<>("classificationid", "classificationid"), + new SimpleEntry<>("pictureclassid", "pictureclassid"), + new SimpleEntry<>("pictureclassscores", "pictureclassscores"), + new SimpleEntry<>("iztrueorfalse", "iztrueorfalse"), + new SimpleEntry<>("judgeid", "judgeid"), + new SimpleEntry<>("judgedesc", "judgedesc"), + new SimpleEntry<>("tenant_id", "tenantId"), + new SimpleEntry<>("tenantstatus", "tenantstatus"), + new SimpleEntry<>("plantCode", "plantcode"), + new SimpleEntry<>("tenantname", "tenantname"), + new SimpleEntry<>("pictureid", "pictureid"), + new SimpleEntry<>("picturename", "picturename"), + new SimpleEntry<>("imgName", "imgname"), + new SimpleEntry<>("imgUrl", "imgurl"), + new SimpleEntry<>("picturestatus", "picturestatus"), + new SimpleEntry<>("projectId", "projectid"), + new SimpleEntry<>("projectIdName", "projectidname"), + new SimpleEntry<>("projectstatus", "projectstatus"), + new SimpleEntry<>("planId", "planid"), + new SimpleEntry<>("planName", "planname"), + new SimpleEntry<>("planstatus", "planstatus"), + new SimpleEntry<>("planchildid", "planchildid"), + new SimpleEntry<>("planchildname", "planchildname"), + new SimpleEntry<>("planchildstatus", "planchildstatus"), + new SimpleEntry<>("upTime", "uptime"), + new SimpleEntry<>("genTime", "gentime"), + new SimpleEntry<>("space", "space"), + new SimpleEntry<>("source", "source"), + new SimpleEntry<>("upHead", "uphead"), + new SimpleEntry<>("upuserid", "upuserid"), + new SimpleEntry<>("upName", "upname"), + new SimpleEntry<>("releaseArea", "releasearea"), + new SimpleEntry<>("releaseProvince", "releaseprovince"), + new SimpleEntry<>("remark", "remark"), + new SimpleEntry<>("taskName", "taskname"), + new SimpleEntry<>("taskstatus", "taskstatus"), + new SimpleEntry<>("work_status", "workStatus"), + new SimpleEntry<>("categoryid", "categoryid"), + new SimpleEntry<>("taskchildpictureid", "taskchildpictureid"), + new SimpleEntry<>("field1", "field1"), + new SimpleEntry<>("field2", "field2"), + new SimpleEntry<>("field3", "field3"), + new SimpleEntry<>("field4", "field4"), + new SimpleEntry<>("field5", "field5"), + new SimpleEntry<>("field6", "field6"), + new SimpleEntry<>("field7", "field7"), + new SimpleEntry<>("field8", "field8"), + new SimpleEntry<>("field9", "field9"), + new SimpleEntry<>("field10", "field10"), + new SimpleEntry<>("field11", "field11"), + new SimpleEntry<>("field12", "field12"), + new SimpleEntry<>("field13", "field13"), + new SimpleEntry<>("field14", "field14"), + new SimpleEntry<>("field15", "field15"), + new SimpleEntry<>("field16", "field16"), + new SimpleEntry<>("field17", "field17"), + new SimpleEntry<>("field18", "field18"), + new SimpleEntry<>("localpictrueurl", "localpictrueurl") + ) + .collect(Collectors.toMap(SimpleEntry::getKey, SimpleEntry::getValue)); + + @Override + public String getQueryFiled(String filedname) { + String obj = null; + if (null != query && query.size() > 0) { + obj = query.get(filedname); + } + return obj; + } } diff --git a/jyjz-system/jyjz-system-oa/src/main/java/cn/jyjz/xiaoyao/ocr/service/OcrPictureService.java b/jyjz-system/jyjz-system-oa/src/main/java/cn/jyjz/xiaoyao/ocr/service/OcrPictureService.java index 5be4b015..aef5c043 100644 --- a/jyjz-system/jyjz-system-oa/src/main/java/cn/jyjz/xiaoyao/ocr/service/OcrPictureService.java +++ b/jyjz-system/jyjz-system-oa/src/main/java/cn/jyjz/xiaoyao/ocr/service/OcrPictureService.java @@ -96,4 +96,6 @@ public interface OcrPictureService extends BaseService { * @return */ int savePictures(List ocrPictureList); + + ResultVo createPackageTask(List pageList, String tenantId, UserToken userToken, String searchMonth, HttpServletRequest req, String buessinessno); } diff --git a/jyjz-system/jyjz-system-oa/src/main/java/cn/jyjz/xiaoyao/ocr/service/impl/OcrPictureServiceImpl.java b/jyjz-system/jyjz-system-oa/src/main/java/cn/jyjz/xiaoyao/ocr/service/impl/OcrPictureServiceImpl.java index a0514067..e175384e 100644 --- a/jyjz-system/jyjz-system-oa/src/main/java/cn/jyjz/xiaoyao/ocr/service/impl/OcrPictureServiceImpl.java +++ b/jyjz-system/jyjz-system-oa/src/main/java/cn/jyjz/xiaoyao/ocr/service/impl/OcrPictureServiceImpl.java @@ -13,12 +13,15 @@ import cn.jyjz.xiaoyao.oa.from.service.CategoryService; import cn.jyjz.xiaoyao.ocr.dataDao.OcrPictureMybatisDao; import cn.jyjz.xiaoyao.ocr.dataobject.*; import cn.jyjz.xiaoyao.ocr.service.*; +import cn.jyjz.xiaoyao.ocr.thread.TaskQueue; +import cn.jyjz.xiaoyao.ocr.thread.entity.PictureImgToLocalEntity; import cn.jyjz.xiaoyao.ocr.util.DataDictionaryUtil; import cn.jyjz.xiaoyao.ocr.util.ImageClassUtil; import cn.jyjz.xiaoyao.ocr.util.SearchEnum; import cn.jyjz.xiaoyao.ocr.util.SearchParaFormatting; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.Wrapper; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; @@ -48,6 +51,9 @@ import java.util.List; @Service("ocrPictureService") @Slf4j public class OcrPictureServiceImpl extends BaseServiceImpl implements OcrPictureService { + + @Value("${ocr.api.wly.localImagePath}") + private String localImagePath; @Resource private OcrPictureMybatisDao ocrpicturemybatisdao; @@ -273,79 +279,175 @@ public class OcrPictureServiceImpl extends BaseServiceImpl ocrPictureList, String tenantId) { + public ResultVo createPackageTask(List 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 pointsList = new ArrayList<>(); //图片信息不能为空 if (null != ocrPictureList && !ocrPictureList.isEmpty()) { //生成任务包 //String packageName = seqManageService.getSeqNextNo("AI任务包"); - + //创建任务包 + OcrPackagetask ocrPackagetask = this.ocrPackagetaskService.create(buessinessno, tenantId, sysUser); + if (null == ocrPackagetask) { + return ResultVoUtil.error("失败。"); + } //用于标记相似度是否存在百分百的情况 - List newList = new ArrayList<>(); for (OcrPicture ocrPicture : ocrPictureList) { + //如果当前图片已经生成任务包,直接跳过 + if (ocrPicture.getTaskstatus().equals("1")) { + continue; + } //图片查重的比对图片集合 List compareList = new ArrayList<>(); - //非历史图片主键集合 List 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(), + logService.addLog(103, "AI获取图片相似度接口", sysUser, "sendParams"); + JSONObject jsonObjectSimi = ImageClassUtil.getSimilarity(StringUtils.isBlank(ocrPicture.getLocalpictrueurl()) ? ocrPicture.getImgurl() : ocrPicture.getLocalpictrueurl(), + StringUtils.isBlank(ocrPicture.getLocalpictrueurl()) ? ocrPictureNext.getImgurl() : ocrPicture.getLocalpictrueurl(), 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; + } + //创建工单,如果创建成功,增加标志,用于过滤条件使用 + OcrTaskchildPicture ocrTaskchildPicture = this.updateTaskChild(ocrPicture, ocrPackagetask.getId(), buessinessno); + if (null != ocrTaskchildPicture) { + if (havePoint) { + pointsList.add(ocrTaskchildPicture.getId()); + } + } + 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))); + } + } + 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 OcrTaskchildPicture updateTaskChild(OcrPicture ocrPicture, Long packageid, String buessinessno) { + OcrTaskchildPicture ocrTaskchildPicture = ocrTaskchildPictureService.getOne(new LambdaQueryWrapper().eq(OcrTaskchildPicture::getPictureid, ocrPicture.getId())); + ocrTaskchildPicture.setBuessinessno(buessinessno); + ocrTaskchildPicture.setPackageid(packageid); + StringBuffer pcid = new StringBuffer(); + StringBuffer result = new StringBuffer(); + for (OcrPicture comp : ocrPicture.getListCom()) { + if (null == pcid || pcid.toString().length() < 1) { + pcid.append(comp.getId()); + result.append(comp.getResult()); + } else { + pcid.append("," + comp.getId()); + result.append("," + comp.getResult()); + } + } + ocrTaskchildPicture.setOcpictureid(pcid.toString()); + ocrTaskchildPicture.setPictureresult(result.toString()); + ocrTaskchildPicture.setPicturecompare(String.join(",", ocrPicture.getPicturecompareList())); + return ocrTaskchildPictureService.updateById(ocrTaskchildPicture) ? ocrTaskchildPicture : null; + } + + public ResultVo createTaskChild(List ocrPictureList, String tenantId) { + //图片错误信息 + StringBuffer error = new StringBuffer(); + //项目错误信息 + StringBuffer errorProject = new StringBuffer(); + //流程错误信息 + StringBuffer errorFlow = new StringBuffer(); + //图片信息不能为空 + if (null != ocrPictureList && !ocrPictureList.isEmpty()) { + //用于标记相似度是否存在百分百的情况 + List newList = new ArrayList<>(); + for (OcrPicture ocrPicture : ocrPictureList) { + boolean havePoint = false; //查询项目对象 if (null == ocrPicture.getCategoryid()) { //TODO 没有对应项目,返回提示信息 @@ -388,41 +490,19 @@ public class OcrPictureServiceImpl extends BaseServiceImpl ocrPictureList) { //1.字典数据 解析入库 boolean b = dataDictionaryUtil.pictureDataDictionarySaveArray(ocrPictureList); @@ -687,18 +766,27 @@ public class OcrPictureServiceImpl extends BaseServiceImpl list) { + for (OcrPicture ocrPicture : list) { + PictureImgToLocalEntity entity = new PictureImgToLocalEntity(); + entity.setPictureId(ocrPicture.getId()); + entity.setImgUrl(ocrPicture.getImgurl()); + String imgurl = ocrPicture.getImgurl(); + entity.setLocalPath(localImagePath + imgurl.substring(imgurl.lastIndexOf("/"))); + TaskQueue.pictureImgToLocalPushData(entity); + } + } + /** * 格式化筛选关系 * diff --git a/jyjz-system/jyjz-system-oa/src/main/java/cn/jyjz/xiaoyao/ocr/service/impl/OcrTaskchildPictureServiceImpl.java b/jyjz-system/jyjz-system-oa/src/main/java/cn/jyjz/xiaoyao/ocr/service/impl/OcrTaskchildPictureServiceImpl.java index fe18e9aa..c9321364 100644 --- a/jyjz-system/jyjz-system-oa/src/main/java/cn/jyjz/xiaoyao/ocr/service/impl/OcrTaskchildPictureServiceImpl.java +++ b/jyjz-system/jyjz-system-oa/src/main/java/cn/jyjz/xiaoyao/ocr/service/impl/OcrTaskchildPictureServiceImpl.java @@ -455,21 +455,21 @@ public class OcrTaskchildPictureServiceImpl extends BaseServiceImpl