parent
61179a2f22
commit
cdef82f32f
@ -0,0 +1,171 @@
|
|||||||
|
package org.jeecg.modules.ai.controller;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.UnsupportedEncodingException;
|
||||||
|
import java.net.URLDecoder;
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import org.jeecg.common.api.vo.Result;
|
||||||
|
import org.jeecg.common.system.query.QueryGenerator;
|
||||||
|
import org.jeecg.common.util.oConvertUtils;
|
||||||
|
import org.jeecg.modules.ai.entity.PreReviewRecordsDetailTemplate;
|
||||||
|
import org.jeecg.modules.ai.service.IPreReviewRecordsDetailTemplateService;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
|
import org.jeecgframework.poi.excel.ExcelImportUtil;
|
||||||
|
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
|
||||||
|
import org.jeecgframework.poi.excel.entity.ExportParams;
|
||||||
|
import org.jeecgframework.poi.excel.entity.ImportParams;
|
||||||
|
import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
|
||||||
|
import org.jeecg.common.system.base.controller.JeecgController;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
import org.springframework.web.multipart.MultipartHttpServletRequest;
|
||||||
|
import org.springframework.web.servlet.ModelAndView;
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import org.jeecg.common.aspect.annotation.AutoLog;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description: 办事预审记录上传资料表
|
||||||
|
* @Author: jeecg-boot
|
||||||
|
* @Date: 2023-12-03
|
||||||
|
* @Version: V1.0
|
||||||
|
*/
|
||||||
|
@Api(tags="办事预审记录上传资料表")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/ai/preReviewRecordsDetailTemplate")
|
||||||
|
@Slf4j
|
||||||
|
public class PreReviewRecordsDetailTemplateController extends JeecgController<PreReviewRecordsDetailTemplate, IPreReviewRecordsDetailTemplateService> {
|
||||||
|
@Autowired
|
||||||
|
private IPreReviewRecordsDetailTemplateService preReviewRecordsDetailTemplateService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页列表查询
|
||||||
|
*
|
||||||
|
* @param preReviewRecordsDetailTemplate
|
||||||
|
* @param pageNo
|
||||||
|
* @param pageSize
|
||||||
|
* @param req
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@AutoLog(value = "办事预审记录上传资料表-分页列表查询")
|
||||||
|
@ApiOperation(value="办事预审记录上传资料表-分页列表查询", notes="办事预审记录上传资料表-分页列表查询")
|
||||||
|
@GetMapping(value = "/list")
|
||||||
|
public Result<?> queryPageList(PreReviewRecordsDetailTemplate preReviewRecordsDetailTemplate,
|
||||||
|
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
|
||||||
|
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
|
||||||
|
HttpServletRequest req) {
|
||||||
|
QueryWrapper<PreReviewRecordsDetailTemplate> queryWrapper = QueryGenerator.initQueryWrapper(preReviewRecordsDetailTemplate, req.getParameterMap());
|
||||||
|
Page<PreReviewRecordsDetailTemplate> page = new Page<PreReviewRecordsDetailTemplate>(pageNo, pageSize);
|
||||||
|
IPage<PreReviewRecordsDetailTemplate> pageList = preReviewRecordsDetailTemplateService.page(page, queryWrapper);
|
||||||
|
return Result.OK(pageList);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加
|
||||||
|
*
|
||||||
|
* @param preReviewRecordsDetailTemplate
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@AutoLog(value = "办事预审记录上传资料表-添加")
|
||||||
|
@ApiOperation(value="办事预审记录上传资料表-添加", notes="办事预审记录上传资料表-添加")
|
||||||
|
@PostMapping(value = "/add")
|
||||||
|
public Result<?> add(@RequestBody PreReviewRecordsDetailTemplate preReviewRecordsDetailTemplate) {
|
||||||
|
preReviewRecordsDetailTemplateService.save(preReviewRecordsDetailTemplate);
|
||||||
|
return Result.OK("添加成功!");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 编辑
|
||||||
|
*
|
||||||
|
* @param preReviewRecordsDetailTemplate
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@AutoLog(value = "办事预审记录上传资料表-编辑")
|
||||||
|
@ApiOperation(value="办事预审记录上传资料表-编辑", notes="办事预审记录上传资料表-编辑")
|
||||||
|
@PutMapping(value = "/edit")
|
||||||
|
public Result<?> edit(@RequestBody PreReviewRecordsDetailTemplate preReviewRecordsDetailTemplate) {
|
||||||
|
preReviewRecordsDetailTemplateService.updateById(preReviewRecordsDetailTemplate);
|
||||||
|
return Result.OK("编辑成功!");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过id删除
|
||||||
|
*
|
||||||
|
* @param id
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@AutoLog(value = "办事预审记录上传资料表-通过id删除")
|
||||||
|
@ApiOperation(value="办事预审记录上传资料表-通过id删除", notes="办事预审记录上传资料表-通过id删除")
|
||||||
|
@DeleteMapping(value = "/delete")
|
||||||
|
public Result<?> delete(@RequestParam(name="id",required=true) String id) {
|
||||||
|
preReviewRecordsDetailTemplateService.removeById(id);
|
||||||
|
return Result.OK("删除成功!");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除
|
||||||
|
*
|
||||||
|
* @param ids
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@AutoLog(value = "办事预审记录上传资料表-批量删除")
|
||||||
|
@ApiOperation(value="办事预审记录上传资料表-批量删除", notes="办事预审记录上传资料表-批量删除")
|
||||||
|
@DeleteMapping(value = "/deleteBatch")
|
||||||
|
public Result<?> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
|
||||||
|
this.preReviewRecordsDetailTemplateService.removeByIds(Arrays.asList(ids.split(",")));
|
||||||
|
return Result.OK("批量删除成功!");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过id查询
|
||||||
|
*
|
||||||
|
* @param id
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@AutoLog(value = "办事预审记录上传资料表-通过id查询")
|
||||||
|
@ApiOperation(value="办事预审记录上传资料表-通过id查询", notes="办事预审记录上传资料表-通过id查询")
|
||||||
|
@GetMapping(value = "/queryById")
|
||||||
|
public Result<?> queryById(@RequestParam(name="id",required=true) String id) {
|
||||||
|
PreReviewRecordsDetailTemplate preReviewRecordsDetailTemplate = preReviewRecordsDetailTemplateService.getById(id);
|
||||||
|
if(preReviewRecordsDetailTemplate==null) {
|
||||||
|
return Result.error("未找到对应数据");
|
||||||
|
}
|
||||||
|
return Result.OK(preReviewRecordsDetailTemplate);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导出excel
|
||||||
|
*
|
||||||
|
* @param request
|
||||||
|
* @param preReviewRecordsDetailTemplate
|
||||||
|
*/
|
||||||
|
@RequestMapping(value = "/exportXls")
|
||||||
|
public ModelAndView exportXls(HttpServletRequest request, PreReviewRecordsDetailTemplate preReviewRecordsDetailTemplate) {
|
||||||
|
return super.exportXls(request, preReviewRecordsDetailTemplate, PreReviewRecordsDetailTemplate.class, "办事预审记录上传资料表");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过excel导入数据
|
||||||
|
*
|
||||||
|
* @param request
|
||||||
|
* @param response
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
|
||||||
|
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
|
||||||
|
return super.importExcel(request, response, PreReviewRecordsDetailTemplate.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,66 @@
|
|||||||
|
package org.jeecg.modules.ai.entity;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.io.UnsupportedEncodingException;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import lombok.Data;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
import org.jeecgframework.poi.excel.annotation.Excel;
|
||||||
|
import org.jeecg.common.aspect.annotation.Dict;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description: 办事预审记录上传资料表
|
||||||
|
* @Author: jeecg-boot
|
||||||
|
* @Date: 2023-12-03
|
||||||
|
* @Version: V1.0
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@TableName("pre_review_records_detail_template")
|
||||||
|
@Accessors(chain = true)
|
||||||
|
@EqualsAndHashCode(callSuper = false)
|
||||||
|
@ApiModel(value="pre_review_records_detail_template对象", description="办事预审记录上传资料表")
|
||||||
|
public class PreReviewRecordsDetailTemplate implements Serializable {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**主键*/
|
||||||
|
@TableId(type = IdType.ASSIGN_ID)
|
||||||
|
@ApiModelProperty(value = "主键")
|
||||||
|
private java.lang.String id;
|
||||||
|
/**预审记录详情id*/
|
||||||
|
@Excel(name = "预审记录详情id", width = 15)
|
||||||
|
@ApiModelProperty(value = "预审记录详情id")
|
||||||
|
private java.lang.String recordDetailId;
|
||||||
|
/**材料编码*/
|
||||||
|
@Excel(name = "材料编码", width = 15)
|
||||||
|
@ApiModelProperty(value = "材料编码")
|
||||||
|
private java.lang.String materialCode;
|
||||||
|
/**预审事项编码*/
|
||||||
|
@Excel(name = "预审事项编码", width = 15)
|
||||||
|
@ApiModelProperty(value = "预审事项编码")
|
||||||
|
private java.lang.String eventCode;
|
||||||
|
/**模板id*/
|
||||||
|
@Excel(name = "模板id", width = 15)
|
||||||
|
@ApiModelProperty(value = "模板id")
|
||||||
|
private java.lang.String templateId;
|
||||||
|
/**上传材料地址*/
|
||||||
|
@Excel(name = "上传材料地址", width = 15)
|
||||||
|
@ApiModelProperty(value = "上传材料地址")
|
||||||
|
private java.lang.String materiaUrl;
|
||||||
|
/**ocr识别结果*/
|
||||||
|
@Excel(name = "ocr识别结果", width = 15)
|
||||||
|
@ApiModelProperty(value = "ocr识别结果")
|
||||||
|
private java.lang.String ocrResult;
|
||||||
|
/**预审结果*/
|
||||||
|
@Excel(name = "预审结果", width = 15)
|
||||||
|
@ApiModelProperty(value = "预审结果")
|
||||||
|
private java.lang.String reviewResult;
|
||||||
|
}
|
||||||
@ -0,0 +1,54 @@
|
|||||||
|
package org.jeecg.modules.ai.entity;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.io.UnsupportedEncodingException;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import lombok.Data;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
import org.jeecgframework.poi.excel.annotation.Excel;
|
||||||
|
import org.jeecg.common.aspect.annotation.Dict;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description: 材料上传模板表
|
||||||
|
* @Author: jeecg-boot
|
||||||
|
* @Date: 2023-12-02
|
||||||
|
* @Version: V1.0
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@TableName("ys_directory_material_template")
|
||||||
|
@Accessors(chain = true)
|
||||||
|
@EqualsAndHashCode(callSuper = false)
|
||||||
|
@ApiModel(value="ys_directory_material_template对象", description="材料上传模板表")
|
||||||
|
public class YsDirectoryMaterialTemplate implements Serializable {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**主键*/
|
||||||
|
@TableId(type = IdType.ASSIGN_ID)
|
||||||
|
@ApiModelProperty(value = "主键")
|
||||||
|
private java.lang.String id;
|
||||||
|
/**材料编码*/
|
||||||
|
@Excel(name = "材料编码", width = 15)
|
||||||
|
@ApiModelProperty(value = "材料编码")
|
||||||
|
private java.lang.String materialCode;
|
||||||
|
/**模板id*/
|
||||||
|
@Excel(name = "模板id", width = 15)
|
||||||
|
@ApiModelProperty(value = "模板id")
|
||||||
|
private java.lang.String templateId;
|
||||||
|
/**模板地址*/
|
||||||
|
@Excel(name = "模板地址", width = 15)
|
||||||
|
@ApiModelProperty(value = "模板地址")
|
||||||
|
private java.lang.String templateUrl;
|
||||||
|
/**排序*/
|
||||||
|
@Excel(name = "排序", width = 15)
|
||||||
|
@ApiModelProperty(value = "排序")
|
||||||
|
private java.lang.Integer sort;
|
||||||
|
}
|
||||||
@ -0,0 +1,18 @@
|
|||||||
|
package org.jeecg.modules.ai.mapper;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
import org.jeecg.modules.ai.entity.PreReviewRecordsDetailTemplate;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description: 办事预审记录上传资料表
|
||||||
|
* @Author: jeecg-boot
|
||||||
|
* @Date: 2023-12-03
|
||||||
|
* @Version: V1.0
|
||||||
|
*/
|
||||||
|
public interface PreReviewRecordsDetailTemplateMapper extends BaseMapper<PreReviewRecordsDetailTemplate> {
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,18 @@
|
|||||||
|
package org.jeecg.modules.ai.mapper;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
import org.jeecg.modules.ai.entity.YsDirectoryMaterialTemplate;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description: 材料上传模板表
|
||||||
|
* @Author: jeecg-boot
|
||||||
|
* @Date: 2023-12-02
|
||||||
|
* @Version: V1.0
|
||||||
|
*/
|
||||||
|
public interface YsDirectoryMaterialTemplateMapper extends BaseMapper<YsDirectoryMaterialTemplate> {
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,5 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="org.jeecg.modules.demo.ai.mapper.PreReviewRecordsDetailTemplateMapper">
|
||||||
|
|
||||||
|
</mapper>
|
||||||
@ -0,0 +1,5 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="org.jeecg.modules.ai.mapper.YsDirectoryMaterialTemplateMapper">
|
||||||
|
|
||||||
|
</mapper>
|
||||||
@ -0,0 +1,15 @@
|
|||||||
|
package org.jeecg.modules.ai.service;
|
||||||
|
|
||||||
|
import org.jeecg.modules.ai.entity.PreReviewRecordsDetailTemplate;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description: 办事预审记录上传资料表
|
||||||
|
* @Author: jeecg-boot
|
||||||
|
* @Date: 2023-12-03
|
||||||
|
* @Version: V1.0
|
||||||
|
*/
|
||||||
|
public interface IPreReviewRecordsDetailTemplateService extends IService<PreReviewRecordsDetailTemplate> {
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,15 @@
|
|||||||
|
package org.jeecg.modules.ai.service;
|
||||||
|
|
||||||
|
import org.jeecg.modules.ai.entity.YsDirectoryMaterialTemplate;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description: 材料上传模板表
|
||||||
|
* @Author: jeecg-boot
|
||||||
|
* @Date: 2023-12-02
|
||||||
|
* @Version: V1.0
|
||||||
|
*/
|
||||||
|
public interface IYsDirectoryMaterialTemplateService extends IService<YsDirectoryMaterialTemplate> {
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,19 @@
|
|||||||
|
package org.jeecg.modules.ai.service.impl;
|
||||||
|
|
||||||
|
import org.jeecg.modules.ai.entity.PreReviewRecordsDetailTemplate;
|
||||||
|
import org.jeecg.modules.ai.mapper.PreReviewRecordsDetailTemplateMapper;
|
||||||
|
import org.jeecg.modules.ai.service.IPreReviewRecordsDetailTemplateService;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description: 办事预审记录上传资料表
|
||||||
|
* @Author: jeecg-boot
|
||||||
|
* @Date: 2023-12-03
|
||||||
|
* @Version: V1.0
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class PreReviewRecordsDetailTemplateServiceImpl extends ServiceImpl<PreReviewRecordsDetailTemplateMapper, PreReviewRecordsDetailTemplate> implements IPreReviewRecordsDetailTemplateService {
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,19 @@
|
|||||||
|
package org.jeecg.modules.ai.service.impl;
|
||||||
|
|
||||||
|
import org.jeecg.modules.ai.entity.YsDirectoryMaterialTemplate;
|
||||||
|
import org.jeecg.modules.ai.mapper.YsDirectoryMaterialTemplateMapper;
|
||||||
|
import org.jeecg.modules.ai.service.IYsDirectoryMaterialTemplateService;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description: 材料上传模板表
|
||||||
|
* @Author: jeecg-boot
|
||||||
|
* @Date: 2023-12-02
|
||||||
|
* @Version: V1.0
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class YsDirectoryMaterialTemplateServiceImpl extends ServiceImpl<YsDirectoryMaterialTemplateMapper, YsDirectoryMaterialTemplate> implements IYsDirectoryMaterialTemplateService {
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,91 @@
|
|||||||
|
package org.jeecg.modules.system.util;
|
||||||
|
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import javax.imageio.stream.FileImageInputStream;
|
||||||
|
|
||||||
|
import org.json.JSONObject;
|
||||||
|
|
||||||
|
import com.baidu.aip.ocr.AipOcr;
|
||||||
|
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
public class BaiduUtil {
|
||||||
|
|
||||||
|
public static final String APP_ID = "23890069";
|
||||||
|
public static final String API_KEY = "ZOLqyLPBF4I0pejNpZzvzf35";
|
||||||
|
public static final String SECRET_KEY = "VR8pmnk997sDVBkMXusTDsrUksCAbb4Z";
|
||||||
|
|
||||||
|
public static AipOcr client = null;
|
||||||
|
|
||||||
|
static{
|
||||||
|
client = new AipOcr(APP_ID, API_KEY, SECRET_KEY);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 印章识别
|
||||||
|
* @param imgUrl 本地图片地址
|
||||||
|
* @return
|
||||||
|
* {
|
||||||
|
"result":[
|
||||||
|
{
|
||||||
|
"major":{
|
||||||
|
"probability":0.9989657998,
|
||||||
|
"words":"德阳玺合印章有限公司送检样章"
|
||||||
|
},
|
||||||
|
"minor":[
|
||||||
|
|
||||||
|
],
|
||||||
|
"probability":0.9393941164,
|
||||||
|
"location":{
|
||||||
|
"top":30,
|
||||||
|
"left":58,
|
||||||
|
"width":578,
|
||||||
|
"height":577
|
||||||
|
},
|
||||||
|
"type":"circle"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"log_id":1730486846918069925,
|
||||||
|
"result_num":1
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
public static JSONObject seal(String imgUrl) {
|
||||||
|
byte[] image = readImageFile(imgUrl);
|
||||||
|
// 调用印章识别
|
||||||
|
JSONObject fileResult = client.seal(image);
|
||||||
|
log.info("-----------百度识别印章fileResult----------"+fileResult);
|
||||||
|
return fileResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String args[]) {
|
||||||
|
seal("D:\\Download\\860237437.jpg");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static byte[] readImageFile(String path) {
|
||||||
|
byte[] data = null;
|
||||||
|
FileImageInputStream input = null;
|
||||||
|
try {
|
||||||
|
input = new FileImageInputStream(new File(path));
|
||||||
|
ByteArrayOutputStream output = new ByteArrayOutputStream();
|
||||||
|
byte[] buf = new byte[1024];
|
||||||
|
int numBytesRead = 0;
|
||||||
|
while ((numBytesRead = input.read(buf)) != -1) {
|
||||||
|
output.write(buf, 0, numBytesRead);
|
||||||
|
}
|
||||||
|
data = output.toByteArray();
|
||||||
|
output.close();
|
||||||
|
input.close();
|
||||||
|
} catch (FileNotFoundException ex1) {
|
||||||
|
ex1.printStackTrace();
|
||||||
|
} catch (IOException ex1) {
|
||||||
|
ex1.printStackTrace();
|
||||||
|
}
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,98 @@
|
|||||||
|
package org.jeecg.modules.system.util;
|
||||||
|
|
||||||
|
import com.huaweicloud.sdk.core.auth.ICredential;
|
||||||
|
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.Base64;
|
||||||
|
|
||||||
|
import javax.imageio.stream.FileImageInputStream;
|
||||||
|
|
||||||
|
import com.huaweicloud.sdk.core.auth.BasicCredentials;
|
||||||
|
import com.huaweicloud.sdk.core.exception.ConnectionException;
|
||||||
|
import com.huaweicloud.sdk.core.exception.RequestTimeoutException;
|
||||||
|
import com.huaweicloud.sdk.core.exception.ServiceResponseException;
|
||||||
|
import com.huaweicloud.sdk.core.http.HttpConfig;
|
||||||
|
import com.huaweicloud.sdk.ocr.v1.region.OcrRegion;
|
||||||
|
|
||||||
|
import okhttp3.MediaType;
|
||||||
|
import okhttp3.OkHttpClient;
|
||||||
|
import okhttp3.Request;
|
||||||
|
import okhttp3.RequestBody;
|
||||||
|
import okhttp3.Response;
|
||||||
|
|
||||||
|
import com.huaweicloud.sdk.ocr.v1.*;
|
||||||
|
import com.huaweicloud.sdk.ocr.v1.model.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 华为文字识别
|
||||||
|
*
|
||||||
|
* @author w
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class RecognizeGeneralTextSolution {
|
||||||
|
|
||||||
|
public static final String CLOUD_SDK_AK = "X4MNF4GUFECVS2JKQS8L";
|
||||||
|
public static final String CLOUD_SDK_SK = "7hMUh5lgdpPMUQQSRc6tM6MNsMPx1Cgsnrv1zE67";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 识别文字
|
||||||
|
*
|
||||||
|
* @param imgUrl
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static String recognizeGeneralTextSolution(String imgUrl,String classifierId) {
|
||||||
|
|
||||||
|
ICredential auth = new BasicCredentials()
|
||||||
|
.withAk(CLOUD_SDK_AK)
|
||||||
|
.withSk(CLOUD_SDK_SK)
|
||||||
|
.withProjectId("7c9b49b201734164a4f1efef5e1e46e0");
|
||||||
|
|
||||||
|
OcrClient client = OcrClient.newBuilder()
|
||||||
|
.withCredential(auth)
|
||||||
|
.withRegion(OcrRegion.valueOf("cn-north-4"))
|
||||||
|
.build();
|
||||||
|
|
||||||
|
RecognizeCustomTemplateRequest request = new RecognizeCustomTemplateRequest();
|
||||||
|
CustomTemplateRequestBody body = new CustomTemplateRequestBody();
|
||||||
|
body.setClassifierId(classifierId);
|
||||||
|
body.setImage(readImageFile(imgUrl));
|
||||||
|
request.withBody(body);
|
||||||
|
try {
|
||||||
|
RecognizeCustomTemplateResponse response = client.recognizeCustomTemplate(request);
|
||||||
|
return response.toString();
|
||||||
|
} catch (ConnectionException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (RequestTimeoutException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (ServiceResponseException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String args[]) throws Exception {
|
||||||
|
|
||||||
|
recognizeGeneralTextSolution("D:\\Download\\178171512_1099943536_259_194.jpg","b9b1de0e-6601-11ee-88fb-0255ac100240");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String readImageFile(String path) {
|
||||||
|
String base64 = null;
|
||||||
|
try {
|
||||||
|
File imageFile = new File(path);
|
||||||
|
FileInputStream fileInputStream = new FileInputStream(imageFile);
|
||||||
|
byte[] imageBytes = new byte[(int) imageFile.length()];
|
||||||
|
fileInputStream.read(imageBytes);
|
||||||
|
fileInputStream.close();
|
||||||
|
base64 = Base64.getEncoder().encodeToString(imageBytes);
|
||||||
|
} catch (FileNotFoundException ex1) {
|
||||||
|
ex1.printStackTrace();
|
||||||
|
} catch (IOException ex1) {
|
||||||
|
ex1.printStackTrace();
|
||||||
|
}
|
||||||
|
return base64;
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in new issue