Commit 0681cfb0 authored by alex yao's avatar alex yao

feat:MinerU Api

parent 3afdbbbe
package cn.com.poc.ai_data_audit.convert;
import cn.com.poc.ai_data_audit.model.BizAiDataAuditRuleModel;
import cn.com.poc.ai_data_audit.entity.BizAiDataAuditRuleEntity;
import cn.com.poc.ai_data_audit.dto.BizAiDataAuditRuleDto;
public class BizAiDataAuditRuleConvert {
public static BizAiDataAuditRuleEntity modelToEntity(BizAiDataAuditRuleModel model){
BizAiDataAuditRuleEntity entity = new BizAiDataAuditRuleEntity();
entity.setDataAuditRuleId(model.getDataAuditRuleId());
entity.setDataAuditRuleType(model.getDataAuditRuleType());
entity.setFirstFile(model.getFirstFile());
entity.setFirstField(model.getFirstField());
entity.setSecondFile(model.getSecondFile());
entity.setSecondField(model.getSecondField());
entity.setRuleDesc(model.getRuleDesc());
entity.setIsDeleted(model.getIsDeleted());
entity.setCreator(model.getCreator());
entity.setCreatedTime(model.getCreatedTime());
entity.setModifier(model.getModifier());
entity.setModifiedTime(model.getModifiedTime());
entity.setSysVersion(model.getSysVersion());
return entity;
}
public static BizAiDataAuditRuleModel entityToModel(BizAiDataAuditRuleEntity entity){
BizAiDataAuditRuleModel model = new BizAiDataAuditRuleModel();
model.setDataAuditRuleId(entity.getDataAuditRuleId());
model.setDataAuditRuleType(entity.getDataAuditRuleType());
model.setFirstFile(entity.getFirstFile());
model.setFirstField(entity.getFirstField());
model.setSecondFile(entity.getSecondFile());
model.setSecondField(entity.getSecondField());
model.setRuleDesc(entity.getRuleDesc());
model.setIsDeleted(entity.getIsDeleted());
model.setCreator(entity.getCreator());
model.setCreatedTime(entity.getCreatedTime());
model.setModifier(entity.getModifier());
model.setModifiedTime(entity.getModifiedTime());
model.setSysVersion(entity.getSysVersion());
return model;
}
public static BizAiDataAuditRuleDto entityToDto(BizAiDataAuditRuleEntity entity){
BizAiDataAuditRuleDto dto = new BizAiDataAuditRuleDto();
dto.setDataAuditRuleId(entity.getDataAuditRuleId());
dto.setDataAuditRuleType(entity.getDataAuditRuleType());
dto.setFirstFile(entity.getFirstFile());
dto.setFirstField(entity.getFirstField());
dto.setSecondFile(entity.getSecondFile());
dto.setSecondField(entity.getSecondField());
dto.setRuleDesc(entity.getRuleDesc());
dto.setIsDeleted(entity.getIsDeleted());
dto.setCreator(entity.getCreator());
dto.setCreatedTime(entity.getCreatedTime());
dto.setModifier(entity.getModifier());
dto.setModifiedTime(entity.getModifiedTime());
dto.setSysVersion(entity.getSysVersion());
return dto;
}
public static BizAiDataAuditRuleEntity dtoToEntity(BizAiDataAuditRuleDto dto){
BizAiDataAuditRuleEntity entity = new BizAiDataAuditRuleEntity();
entity.setDataAuditRuleId(dto.getDataAuditRuleId());
entity.setDataAuditRuleType(dto.getDataAuditRuleType());
entity.setFirstFile(dto.getFirstFile());
entity.setFirstField(dto.getFirstField());
entity.setSecondFile(dto.getSecondFile());
entity.setSecondField(dto.getSecondField());
entity.setRuleDesc(dto.getRuleDesc());
entity.setIsDeleted(dto.getIsDeleted());
entity.setCreator(dto.getCreator());
entity.setCreatedTime(dto.getCreatedTime());
entity.setModifier(dto.getModifier());
entity.setModifiedTime(dto.getModifiedTime());
entity.setSysVersion(dto.getSysVersion());
return entity;
}
}
\ No newline at end of file
package cn.com.poc.ai_data_audit.dto;
public class BizAiDataAuditRuleDto {
private static final long serialVersionUID = 1L;
/** data_audit_rule_id
*
*/
private java.lang.Integer dataAuditRuleId;
public java.lang.Integer getDataAuditRuleId(){
return this.dataAuditRuleId;
}
public void setDataAuditRuleId(java.lang.Integer dataAuditRuleId){
this.dataAuditRuleId = dataAuditRuleId;
}
/** data_audit_rule_type
*类型:
字段对字段:c2c
字段对文件:f2c
文件对文件:f2f
*/
private java.lang.String dataAuditRuleType;
public java.lang.String getDataAuditRuleType(){
return this.dataAuditRuleType;
}
public void setDataAuditRuleType(java.lang.String dataAuditRuleType){
this.dataAuditRuleType = dataAuditRuleType;
}
/** first_file
*第一个文件
*/
private java.lang.Integer firstFile;
public java.lang.Integer getFirstFile(){
return this.firstFile;
}
public void setFirstFile(java.lang.Integer firstFile){
this.firstFile = firstFile;
}
/** first_field
*第一个字段
*/
private java.lang.String firstField;
public java.lang.String getFirstField(){
return this.firstField;
}
public void setFirstField(java.lang.String firstField){
this.firstField = firstField;
}
/** second_file
*第二个文件
*/
private java.lang.Integer secondFile;
public java.lang.Integer getSecondFile(){
return this.secondFile;
}
public void setSecondFile(java.lang.Integer secondFile){
this.secondFile = secondFile;
}
/** second_field
*第二个字段
*/
private java.lang.String secondField;
public java.lang.String getSecondField(){
return this.secondField;
}
public void setSecondField(java.lang.String secondField){
this.secondField = secondField;
}
/** rule_desc
*规则描述
*/
private java.lang.String ruleDesc;
public java.lang.String getRuleDesc(){
return this.ruleDesc;
}
public void setRuleDesc(java.lang.String ruleDesc){
this.ruleDesc = ruleDesc;
}
/** is_deleted
*是否删除 1、Y 是 2、N 否
*/
private java.lang.String isDeleted;
public java.lang.String getIsDeleted(){
return this.isDeleted;
}
public void setIsDeleted(java.lang.String isDeleted){
this.isDeleted = isDeleted;
}
/** CREATOR
*创建人
*/
private java.lang.String creator;
public java.lang.String getCreator(){
return this.creator;
}
public void setCreator(java.lang.String creator){
this.creator = creator;
}
/** CREATED_TIME
*创建时间
*/
private java.util.Date createdTime;
public java.util.Date getCreatedTime(){
return this.createdTime;
}
public void setCreatedTime(java.util.Date createdTime){
this.createdTime = createdTime;
}
/** MODIFIER
*修改人
*/
private java.lang.String modifier;
public java.lang.String getModifier(){
return this.modifier;
}
public void setModifier(java.lang.String modifier){
this.modifier = modifier;
}
/** MODIFIED_TIME
*修改时间
*/
private java.util.Date modifiedTime;
public java.util.Date getModifiedTime(){
return this.modifiedTime;
}
public void setModifiedTime(java.util.Date modifiedTime){
this.modifiedTime = modifiedTime;
}
/** SYS_VERSION
*乐观锁,版本号
*/
private java.lang.Integer sysVersion;
public java.lang.Integer getSysVersion(){
return this.sysVersion;
}
public void setSysVersion(java.lang.Integer sysVersion){
this.sysVersion = sysVersion;
}
}
\ No newline at end of file
package cn.com.poc.ai_data_audit.entity;
public class BizAiDataAuditRuleEntity {
private static final long serialVersionUID = 1L;
/** data_audit_rule_id
*
*/
private java.lang.Integer dataAuditRuleId;
public java.lang.Integer getDataAuditRuleId(){
return this.dataAuditRuleId;
}
public void setDataAuditRuleId(java.lang.Integer dataAuditRuleId){
this.dataAuditRuleId = dataAuditRuleId;
}
/** data_audit_rule_type
*类型:
字段对字段:c2c
字段对文件:f2c
文件对文件:f2f
*/
private java.lang.String dataAuditRuleType;
public java.lang.String getDataAuditRuleType(){
return this.dataAuditRuleType;
}
public void setDataAuditRuleType(java.lang.String dataAuditRuleType){
this.dataAuditRuleType = dataAuditRuleType;
}
/** first_file
*第一个文件
*/
private java.lang.Integer firstFile;
public java.lang.Integer getFirstFile(){
return this.firstFile;
}
public void setFirstFile(java.lang.Integer firstFile){
this.firstFile = firstFile;
}
/** first_field
*第一个字段
*/
private java.lang.String firstField;
public java.lang.String getFirstField(){
return this.firstField;
}
public void setFirstField(java.lang.String firstField){
this.firstField = firstField;
}
/** second_file
*第二个文件
*/
private java.lang.Integer secondFile;
public java.lang.Integer getSecondFile(){
return this.secondFile;
}
public void setSecondFile(java.lang.Integer secondFile){
this.secondFile = secondFile;
}
/** second_field
*第二个字段
*/
private java.lang.String secondField;
public java.lang.String getSecondField(){
return this.secondField;
}
public void setSecondField(java.lang.String secondField){
this.secondField = secondField;
}
/** rule_desc
*规则描述
*/
private java.lang.String ruleDesc;
public java.lang.String getRuleDesc(){
return this.ruleDesc;
}
public void setRuleDesc(java.lang.String ruleDesc){
this.ruleDesc = ruleDesc;
}
/** is_deleted
*是否删除 1、Y 是 2、N 否
*/
private java.lang.String isDeleted;
public java.lang.String getIsDeleted(){
return this.isDeleted;
}
public void setIsDeleted(java.lang.String isDeleted){
this.isDeleted = isDeleted;
}
/** CREATOR
*创建人
*/
private java.lang.String creator;
public java.lang.String getCreator(){
return this.creator;
}
public void setCreator(java.lang.String creator){
this.creator = creator;
}
/** CREATED_TIME
*创建时间
*/
private java.util.Date createdTime;
public java.util.Date getCreatedTime(){
return this.createdTime;
}
public void setCreatedTime(java.util.Date createdTime){
this.createdTime = createdTime;
}
/** MODIFIER
*修改人
*/
private java.lang.String modifier;
public java.lang.String getModifier(){
return this.modifier;
}
public void setModifier(java.lang.String modifier){
this.modifier = modifier;
}
/** MODIFIED_TIME
*修改时间
*/
private java.util.Date modifiedTime;
public java.util.Date getModifiedTime(){
return this.modifiedTime;
}
public void setModifiedTime(java.util.Date modifiedTime){
this.modifiedTime = modifiedTime;
}
/** SYS_VERSION
*乐观锁,版本号
*/
private java.lang.Integer sysVersion;
public java.lang.Integer getSysVersion(){
return this.sysVersion;
}
public void setSysVersion(java.lang.Integer sysVersion){
this.sysVersion = sysVersion;
}
}
\ No newline at end of file
package cn.com.poc.ai_data_audit.model;
import java.io.Serializable;
import cn.com.yict.framemax.data.model.BaseModelClass;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Id;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import javax.persistence.Version;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
/**
* Model class for biz_ai_data_audit_rule
*
*/
@Entity
@Table(name = "biz_ai_data_audit_rule")
@DynamicInsert
@DynamicUpdate
public class BizAiDataAuditRuleModel extends BaseModelClass implements Serializable {
private static final long serialVersionUID = 1L;
/** data_audit_rule_id
*
*/
private java.lang.Integer dataAuditRuleId;
@Column(name = "data_audit_rule_id",length = 10)
@Id @GeneratedValue(strategy = GenerationType.AUTO)
public java.lang.Integer getDataAuditRuleId(){
return this.dataAuditRuleId;
}
public void setDataAuditRuleId(java.lang.Integer dataAuditRuleId){
this.dataAuditRuleId = dataAuditRuleId;
super.addValidField("dataAuditRuleId");
}
/** data_audit_rule_type
*类型:
字段对字段:c2c
字段对文件:f2c
文件对文件:f2f
*/
private java.lang.String dataAuditRuleType;
@Column(name = "data_audit_rule_type",length = 255)
public java.lang.String getDataAuditRuleType(){
return this.dataAuditRuleType;
}
public void setDataAuditRuleType(java.lang.String dataAuditRuleType){
this.dataAuditRuleType = dataAuditRuleType;
super.addValidField("dataAuditRuleType");
}
/** first_file
*第一个文件
*/
private java.lang.Integer firstFile;
@Column(name = "first_file",length = 10)
public java.lang.Integer getFirstFile(){
return this.firstFile;
}
public void setFirstFile(java.lang.Integer firstFile){
this.firstFile = firstFile;
super.addValidField("firstFile");
}
/** first_field
*第一个字段
*/
private java.lang.String firstField;
@Column(name = "first_field",length = 255)
public java.lang.String getFirstField(){
return this.firstField;
}
public void setFirstField(java.lang.String firstField){
this.firstField = firstField;
super.addValidField("firstField");
}
/** second_file
*第二个文件
*/
private java.lang.Integer secondFile;
@Column(name = "second_file",length = 10)
public java.lang.Integer getSecondFile(){
return this.secondFile;
}
public void setSecondFile(java.lang.Integer secondFile){
this.secondFile = secondFile;
super.addValidField("secondFile");
}
/** second_field
*第二个字段
*/
private java.lang.String secondField;
@Column(name = "second_field",length = 1073741824)
public java.lang.String getSecondField(){
return this.secondField;
}
public void setSecondField(java.lang.String secondField){
this.secondField = secondField;
super.addValidField("secondField");
}
/** rule_desc
*规则描述
*/
private java.lang.String ruleDesc;
@Column(name = "rule_desc",length = 255)
public java.lang.String getRuleDesc(){
return this.ruleDesc;
}
public void setRuleDesc(java.lang.String ruleDesc){
this.ruleDesc = ruleDesc;
super.addValidField("ruleDesc");
}
/** is_deleted
*是否删除 1、Y 是 2、N 否
*/
private java.lang.String isDeleted;
@Column(name = "is_deleted",length = 1)
public java.lang.String getIsDeleted(){
return this.isDeleted;
}
public void setIsDeleted(java.lang.String isDeleted){
this.isDeleted = isDeleted;
super.addValidField("isDeleted");
}
/** CREATOR
*创建人
*/
private java.lang.String creator;
@Column(name = "CREATOR",length = 225)
public java.lang.String getCreator(){
return this.creator;
}
public void setCreator(java.lang.String creator){
this.creator = creator;
super.addValidField("creator");
}
/** CREATED_TIME
*创建时间
*/
private java.util.Date createdTime;
@Column(name = "CREATED_TIME",length = 19)
public java.util.Date getCreatedTime(){
return this.createdTime;
}
public void setCreatedTime(java.util.Date createdTime){
this.createdTime = createdTime;
super.addValidField("createdTime");
}
/** MODIFIER
*修改人
*/
private java.lang.String modifier;
@Column(name = "MODIFIER",length = 225)
public java.lang.String getModifier(){
return this.modifier;
}
public void setModifier(java.lang.String modifier){
this.modifier = modifier;
super.addValidField("modifier");
}
/** MODIFIED_TIME
*修改时间
*/
private java.util.Date modifiedTime;
@Column(name = "MODIFIED_TIME",length = 19)
public java.util.Date getModifiedTime(){
return this.modifiedTime;
}
public void setModifiedTime(java.util.Date modifiedTime){
this.modifiedTime = modifiedTime;
super.addValidField("modifiedTime");
}
/** SYS_VERSION
*乐观锁,版本号
*/
private java.lang.Integer sysVersion;
@Column(name = "SYS_VERSION",length = 10)
@Version
public java.lang.Integer getSysVersion(){
return this.sysVersion;
}
public void setSysVersion(java.lang.Integer sysVersion){
this.sysVersion = sysVersion;
super.addValidField("sysVersion");
}
}
\ No newline at end of file
select
data_audit_rule_id,
data_audit_rule_type,
first_file,
first_field,
second_file,
second_field,
rule_desc,
is_deleted,
CREATOR,
CREATED_TIME,
MODIFIER,
MODIFIED_TIME,
SYS_VERSION
from
biz_ai_data_audit_rule
where is_deleted = 'N'
<< and data_audit_rule_id in (:ids) >>
\ No newline at end of file
package cn.com.poc.ai_data_audit.query;
import java.io.Serializable;
/**
* Query Condition class for AiDataAuditRuleQuery
*/
public class AiDataAuditRuleQueryCondition implements Serializable{
private static final long serialVersionUID = 1L;
private java.lang.Long[] ids;
public java.lang.Long[] getIds(){
return this.ids;
}
public void setIds(java.lang.Long[] ids){
this.ids = ids;
}
}
\ No newline at end of file
package cn.com.poc.ai_data_audit.query;
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import cn.com.yict.framemax.data.model.BaseItemClass;
/**
* Query Item class for AiDataAuditRuleQuery
*/
@Entity
public class AiDataAuditRuleQueryItem extends BaseItemClass implements Serializable{
private static final long serialVersionUID = 1L;
/** data_audit_rule_id
*data_audit_rule_id
*/
private java.lang.Integer dataAuditRuleId;
@Column(name = "data_audit_rule_id")
public java.lang.Integer getDataAuditRuleId(){
return this.dataAuditRuleId;
}
public void setDataAuditRuleId(java.lang.Integer dataAuditRuleId){
this.dataAuditRuleId = dataAuditRuleId;
}
/** data_audit_rule_type
*data_audit_rule_type
*/
private java.lang.String dataAuditRuleType;
@Column(name = "data_audit_rule_type")
public java.lang.String getDataAuditRuleType(){
return this.dataAuditRuleType;
}
public void setDataAuditRuleType(java.lang.String dataAuditRuleType){
this.dataAuditRuleType = dataAuditRuleType;
}
/** first_file
*first_file
*/
private java.lang.Integer firstFile;
@Column(name = "first_file")
public java.lang.Integer getFirstFile(){
return this.firstFile;
}
public void setFirstFile(java.lang.Integer firstFile){
this.firstFile = firstFile;
}
/** first_field
*first_field
*/
private java.lang.String firstField;
@Column(name = "first_field")
public java.lang.String getFirstField(){
return this.firstField;
}
public void setFirstField(java.lang.String firstField){
this.firstField = firstField;
}
/** second_file
*second_file
*/
private java.lang.Integer secondFile;
@Column(name = "second_file")
public java.lang.Integer getSecondFile(){
return this.secondFile;
}
public void setSecondFile(java.lang.Integer secondFile){
this.secondFile = secondFile;
}
/** second_field
*second_field
*/
private java.lang.String secondField;
@Column(name = "second_field")
public java.lang.String getSecondField(){
return this.secondField;
}
public void setSecondField(java.lang.String secondField){
this.secondField = secondField;
}
/** rule_desc
*rule_desc
*/
private java.lang.String ruleDesc;
@Column(name = "rule_desc")
public java.lang.String getRuleDesc(){
return this.ruleDesc;
}
public void setRuleDesc(java.lang.String ruleDesc){
this.ruleDesc = ruleDesc;
}
/** is_deleted
*is_deleted
*/
private java.lang.String isDeleted;
@Column(name = "is_deleted")
public java.lang.String getIsDeleted(){
return this.isDeleted;
}
public void setIsDeleted(java.lang.String isDeleted){
this.isDeleted = isDeleted;
}
/** CREATOR
*CREATOR
*/
private java.lang.String creator;
@Column(name = "CREATOR")
public java.lang.String getCreator(){
return this.creator;
}
public void setCreator(java.lang.String creator){
this.creator = creator;
}
/** CREATED_TIME
*CREATED_TIME
*/
private java.util.Date createdTime;
@Column(name = "CREATED_TIME")
public java.util.Date getCreatedTime(){
return this.createdTime;
}
public void setCreatedTime(java.util.Date createdTime){
this.createdTime = createdTime;
}
/** MODIFIER
*MODIFIER
*/
private java.lang.String modifier;
@Column(name = "MODIFIER")
public java.lang.String getModifier(){
return this.modifier;
}
public void setModifier(java.lang.String modifier){
this.modifier = modifier;
}
/** MODIFIED_TIME
*MODIFIED_TIME
*/
private java.util.Date modifiedTime;
@Column(name = "MODIFIED_TIME")
public java.util.Date getModifiedTime(){
return this.modifiedTime;
}
public void setModifiedTime(java.util.Date modifiedTime){
this.modifiedTime = modifiedTime;
}
/** SYS_VERSION
*SYS_VERSION
*/
private java.lang.Integer sysVersion;
@Column(name = "SYS_VERSION")
public java.lang.Integer getSysVersion(){
return this.sysVersion;
}
public void setSysVersion(java.lang.Integer sysVersion){
this.sysVersion = sysVersion;
}
}
\ No newline at end of file
package cn.com.poc.ai_data_audit.repository;
import cn.com.yict.framemax.data.repository.Repository;
import cn.com.poc.ai_data_audit.model.BizAiDataAuditRuleModel;
public interface BizAiDataAuditRuleRepository extends Repository<BizAiDataAuditRuleModel,java.lang.Integer> {
}
\ No newline at end of file
package cn.com.poc.ai_data_audit.rest;
import cn.com.yict.framemax.core.rest.BaseRest;
import cn.com.poc.ai_data_audit.dto.BizAiDataAuditRuleDto;
import cn.com.yict.framemax.data.model.PagingInfo;
import java.util.Collection;
import java.util.List;
import cn.com.yict.framemax.web.permission.Access;
import cn.com.yict.framemax.web.permission.Permission;
import org.springframework.web.bind.annotation.RequestBody;
public interface BizAiDataAuditRuleRest extends BaseRest {
BizAiDataAuditRuleDto getById(java.lang.Integer id) throws Exception;
List<BizAiDataAuditRuleDto> getList(BizAiDataAuditRuleDto example,PagingInfo pagingInfo) throws Exception;
BizAiDataAuditRuleDto save(BizAiDataAuditRuleDto dto) throws Exception;
BizAiDataAuditRuleDto update(BizAiDataAuditRuleDto dto) throws Exception;
void deletedById(java.lang.Integer id) throws Exception;
}
\ No newline at end of file
package cn.com.poc.ai_data_audit.rest.impl;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.stereotype.Component;
import cn.com.poc.ai_data_audit.rest.BizAiDataAuditRuleRest;
import cn.com.poc.ai_data_audit.service.BizAiDataAuditRuleService;
import cn.com.poc.ai_data_audit.dto.BizAiDataAuditRuleDto;
import cn.com.poc.ai_data_audit.entity.BizAiDataAuditRuleEntity;
import cn.com.yict.framemax.data.model.PagingInfo;
import cn.com.poc.ai_data_audit.convert.BizAiDataAuditRuleConvert;
import java.util.stream.Collectors;
import org.springframework.util.Assert;
@Component
public class BizAiDataAuditRuleRestImpl implements BizAiDataAuditRuleRest {
@Resource
private BizAiDataAuditRuleService service;
public BizAiDataAuditRuleDto getById(java.lang.Integer id) throws Exception{
Assert.notNull(id);
return BizAiDataAuditRuleConvert.entityToDto(service.get(id));
}
public List<BizAiDataAuditRuleDto> getList(BizAiDataAuditRuleDto dto,PagingInfo pagingInfo) throws Exception{
return service
.findByExample(BizAiDataAuditRuleConvert.dtoToEntity(dto),pagingInfo)
.stream()
.map(BizAiDataAuditRuleConvert::entityToDto)
.collect(Collectors.toList());
}
public BizAiDataAuditRuleDto save(BizAiDataAuditRuleDto dto) throws Exception{
Assert.notNull(dto);
BizAiDataAuditRuleEntity entity = BizAiDataAuditRuleConvert.dtoToEntity(dto);
return BizAiDataAuditRuleConvert.entityToDto(service.save(entity));
}
public BizAiDataAuditRuleDto update(BizAiDataAuditRuleDto dto) throws Exception{
Assert.notNull(dto);
BizAiDataAuditRuleEntity entity = BizAiDataAuditRuleConvert.dtoToEntity(dto);
return BizAiDataAuditRuleConvert.entityToDto(service.update(entity));
}
public void deletedById(java.lang.Integer id) throws Exception{
Assert.notNull(id);
service.deletedById(id);
}
}
\ No newline at end of file
package cn.com.poc.ai_data_audit.service;
import cn.com.poc.ai_data_audit.query.AiDataAuditRuleQueryCondition;
import cn.com.poc.ai_data_audit.query.AiDataAuditRuleQueryItem;
import cn.com.yict.framemax.core.service.BaseService;
import cn.com.poc.ai_data_audit.entity.BizAiDataAuditRuleEntity;
import cn.com.yict.framemax.data.model.PagingInfo;
import java.util.Collection;
import java.util.List;
public interface BizAiDataAuditRuleService extends BaseService {
BizAiDataAuditRuleEntity get(java.lang.Integer id) throws Exception;
List<BizAiDataAuditRuleEntity> findByExample(BizAiDataAuditRuleEntity example, PagingInfo pagingInfo) throws Exception;
BizAiDataAuditRuleEntity save(BizAiDataAuditRuleEntity entity) throws Exception;
BizAiDataAuditRuleEntity update(BizAiDataAuditRuleEntity entity) throws Exception;
void deletedById(java.lang.Integer id) throws Exception;
List<AiDataAuditRuleQueryItem> aiDataAuditRuleQueryItemList(AiDataAuditRuleQueryCondition condition, PagingInfo pagingInfo) throws Exception;
}
\ No newline at end of file
package cn.com.poc.ai_data_audit.service.impl;
import cn.com.poc.ai_data_audit.query.AiDataAuditRuleQueryCondition;
import cn.com.poc.ai_data_audit.query.AiDataAuditRuleQueryItem;
import cn.com.yict.framemax.core.service.impl.BaseServiceImpl;
import cn.com.poc.ai_data_audit.service.BizAiDataAuditRuleService;
import cn.com.poc.ai_data_audit.model.BizAiDataAuditRuleModel;
import cn.com.poc.ai_data_audit.entity.BizAiDataAuditRuleEntity;
import cn.com.poc.ai_data_audit.convert.BizAiDataAuditRuleConvert;
import cn.com.poc.ai_data_audit.repository.BizAiDataAuditRuleRepository;
import cn.com.yict.framemax.data.model.PagingInfo;
import org.springframework.stereotype.Service;
import org.apache.commons.collections4.CollectionUtils;
import java.util.ArrayList;
import java.util.stream.Collectors;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.util.Assert;
@Service
public class BizAiDataAuditRuleServiceImpl extends BaseServiceImpl
implements BizAiDataAuditRuleService {
@Resource
private BizAiDataAuditRuleRepository repository;
public BizAiDataAuditRuleEntity get(java.lang.Integer id) throws Exception {
Assert.notNull(id);
BizAiDataAuditRuleModel model = this.repository.get(id);
if (model == null) {
return null;
}
if ("Y".equals(model.getIsDeleted())) {
return null;
}
return BizAiDataAuditRuleConvert.modelToEntity(model);
}
public List<BizAiDataAuditRuleEntity> findByExample(BizAiDataAuditRuleEntity example, PagingInfo pagingInfo) throws Exception {
List<BizAiDataAuditRuleEntity> result = new ArrayList<BizAiDataAuditRuleEntity>();
BizAiDataAuditRuleModel model = new BizAiDataAuditRuleModel();
if (example != null) {
model = BizAiDataAuditRuleConvert.entityToModel(example);
}
model.setIsDeleted("N");
List<BizAiDataAuditRuleModel> models = this.repository.findByExample(model, pagingInfo);
if (CollectionUtils.isNotEmpty(models)) {
result = models.stream().map(BizAiDataAuditRuleConvert::modelToEntity).collect(Collectors.toList());
}
return result;
}
public BizAiDataAuditRuleEntity save(BizAiDataAuditRuleEntity entity) throws Exception {
Assert.notNull(entity);
entity.setDataAuditRuleId(null);
entity.setIsDeleted("N");
BizAiDataAuditRuleModel model = BizAiDataAuditRuleConvert.entityToModel(entity);
BizAiDataAuditRuleModel saveModel = this.repository.save(model);
return BizAiDataAuditRuleConvert.modelToEntity(saveModel);
}
public BizAiDataAuditRuleEntity update(BizAiDataAuditRuleEntity entity) throws Exception {
Assert.notNull(entity);
Assert.notNull(entity.getDataAuditRuleId(), "update pk can not be null");
BizAiDataAuditRuleModel model = this.repository.get(entity.getDataAuditRuleId());
if (entity.getDataAuditRuleType() != null) {
model.setDataAuditRuleType(entity.getDataAuditRuleType());
}
if (entity.getFirstFile() != null) {
model.setFirstFile(entity.getFirstFile());
}
if (entity.getFirstField() != null) {
model.setFirstField(entity.getFirstField());
}
if (entity.getSecondFile() != null) {
model.setSecondFile(entity.getSecondFile());
}
if (entity.getSecondField() != null) {
model.setSecondField(entity.getSecondField());
}
if (entity.getRuleDesc() != null) {
model.setRuleDesc(entity.getRuleDesc());
}
if (entity.getIsDeleted() != null) {
model.setIsDeleted(entity.getIsDeleted());
}
if (entity.getCreator() != null) {
model.setCreator(entity.getCreator());
}
if (entity.getCreatedTime() != null) {
model.setCreatedTime(entity.getCreatedTime());
}
if (entity.getModifier() != null) {
model.setModifier(entity.getModifier());
}
if (entity.getModifiedTime() != null) {
model.setModifiedTime(entity.getModifiedTime());
}
if (entity.getSysVersion() != null) {
model.setSysVersion(entity.getSysVersion());
}
BizAiDataAuditRuleModel saveModel = this.repository.save(model);
return BizAiDataAuditRuleConvert.modelToEntity(saveModel);
}
public void deletedById(java.lang.Integer id) throws Exception {
Assert.notNull(id);
BizAiDataAuditRuleModel model = this.repository.get(id);
if (model != null) {
if ("N".equals(model.getIsDeleted())) {
model.setIsDeleted("Y");
this.repository.save(model);
}
}
}
@Override
public List<AiDataAuditRuleQueryItem> aiDataAuditRuleQueryItemList(AiDataAuditRuleQueryCondition condition, PagingInfo pagingInfo) throws Exception {
return this.sqlDao.query(condition, AiDataAuditRuleQueryItem.class, pagingInfo);
}
}
\ No newline at end of file
package cn.com.poc.common.utils;
import cn.com.gsst.dify_client.DifyClientFactory;
import cn.com.gsst.dify_client.DifyWorkflowClient;
import cn.com.gsst.dify_client.enums.FileTransferMethod;
import cn.com.gsst.dify_client.enums.FileType;
import cn.com.gsst.dify_client.enums.ResponseMode;
import cn.com.gsst.dify_client.model.file.FileInfo;
import cn.com.gsst.dify_client.model.workflow.WorkflowRunRequest;
import cn.com.gsst.dify_client.model.workflow.WorkflowRunResponse;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
/**
* MD表格/表单转 json
*
* @author alex.yao
* @date 2025/10/30
*/
public class MD2Json {
private static String DIFY_BASE_URL = "https://dify.gsstcloud.com/v1";
private static Logger logger = LoggerFactory.getLogger(MD2Json.class);
public static String md2json(String md) {
Map<String, Object> inputs = new LinkedHashMap<>();
inputs.put("document", md);
List<FileInfo> files = new ArrayList<>();
files.add(FileInfo.builder()
.type(FileType.DOCUMENT)
.transferMethod(FileTransferMethod.REMOTE_URL)
.build());
try {
DifyWorkflowClient workflowClient = DifyClientFactory.createWorkflowClient(DIFY_BASE_URL, "app-pYQciBixUQCmSpVTMDCMD0Uj");
WorkflowRunRequest workflowRunRequest = new WorkflowRunRequest();
workflowRunRequest.setResponseMode(ResponseMode.BLOCKING);
workflowRunRequest.setInputs(inputs);
workflowRunRequest.setUser("ModelLink");
WorkflowRunResponse workflowRunResponse = workflowClient.runWorkflow(workflowRunRequest);
Map<String, Object> outputs = workflowRunResponse.getData().getOutputs();
if (outputs.containsKey("text")) {
Object text = outputs.get("text");
JSONObject jsonObject = JSON.parseObject(text.toString());
if (jsonObject.containsKey("paper") && !jsonObject.getBoolean("paper")) {
logger.info("------------ md to json could not paper -------------");
return StringUtils.EMPTY;
}
return jsonObject.toJSONString();
}
logger.error("------------- md to json error , text is null -------------");
return StringUtils.EMPTY;
} catch (Exception e) {
logger.error("------------- md to json error -------------", e);
return StringUtils.EMPTY;
}
}
}
package cn.com.poc.message.entity;
import java.util.List;
import java.util.Map;
/**
* 香港机场-PDF解析消息
*
* @author alex.yao
* @date 2025/10/30
*/
public class AirportPDFPaperMessage {
// 1. 规则列表
private List<Integer> ruleIdList;
// 2. 文件映射
private Map<String, String> fileMap;
public List<Integer> getRuleIdList() {
return ruleIdList;
}
public void setRuleIdList(List<Integer> ruleIdList) {
this.ruleIdList = ruleIdList;
}
public Map<String, String> getFileMap() {
return fileMap;
}
public void setFileMap(Map<String, String> fileMap) {
this.fileMap = fileMap;
}
}
package cn.com.poc.message.entity;
/**
* @author alex.yao
* @date 2025/10/30
*/
public class OCRMessage {
private Long id;
private String fileURL;
private String md5;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getMd5() {
return md5;
}
public void setMd5(String md5) {
this.md5 = md5;
}
public String getFileURL() {
return fileURL;
}
public void setFileURL(String fileURL) {
this.fileURL = fileURL;
}
}
package cn.com.poc.message.entity;
/**
* @author alex.yao
* @date 2025/10/30
*/
public class OCRStatusMessage {
private Long id;
private String status;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
}
package cn.com.poc.message.service;
import cn.com.poc.message.entity.AirportPDFPaperMessage;
import cn.com.yict.framemax.core.service.BaseService;
/**
* @author alex.yao
* @date 2025/10/30
*/
public interface AirportConsumerService extends BaseService {
/**
* 推送PDF解析消息任务
*
* @param message
* @return
*/
void pdfPaper(AirportPDFPaperMessage message) throws Exception;
}
package cn.com.poc.message.service;
import cn.com.poc.message.entity.AirportPDFPaperMessage;
import cn.com.yict.framemax.core.service.BaseService;
/**
* @author alex.yao
* @date 2025/10/30
*/
public interface AirportProducerService extends BaseService {
/**
* 推送PDF解析消息任务
*
* @param message
* @return
*/
AirportPDFPaperMessage pdfPaper(AirportPDFPaperMessage message);
}
package cn.com.poc.message.service;
import cn.com.poc.message.entity.OCRMessage;
import cn.com.poc.message.entity.OCRStatusMessage;
import cn.com.yict.framemax.core.service.BaseService;
/**
* @author alex.yao
* @date 2025/10/30
*/
public interface OCRConsumerService extends BaseService {
void OCR(OCRMessage message) throws Exception;
void updateStatus(OCRStatusMessage message) throws Exception;
}
package cn.com.poc.message.service;
import cn.com.poc.message.entity.OCRMessage;
import cn.com.poc.message.entity.OCRStatusMessage;
import cn.com.yict.framemax.core.service.BaseService;
/**
* @author alex.yao
* @date 2025/10/30
*/
public interface OCRProducerService extends BaseService {
OCRMessage OCR(OCRMessage message);
OCRStatusMessage updateStatus(OCRStatusMessage message);
}
package cn.com.poc.message.service.impl;
import cn.com.gsst.dify_client.DifyChatClient;
import cn.com.gsst.dify_client.DifyClientFactory;
import cn.com.gsst.dify_client.enums.ResponseMode;
import cn.com.gsst.dify_client.model.chat.ChatMessage;
import cn.com.gsst.dify_client.model.chat.ChatMessageResponse;
import cn.com.poc.ai_data_audit.entity.BizAiDataAuditFileEntity;
import cn.com.poc.ai_data_audit.query.AiDataAuditRuleQueryCondition;
import cn.com.poc.ai_data_audit.query.AiDataAuditRuleQueryItem;
import cn.com.poc.ai_data_audit.service.BizAiDataAuditFileService;
import cn.com.poc.ai_data_audit.service.BizAiDataAuditRuleService;
import cn.com.poc.common.utils.DocumentLoad;
import cn.com.poc.common.utils.StringUtils;
import cn.com.poc.equity.service.BizPointDeductionRulesService;
import cn.com.poc.message.entity.AirportPDFPaperMessage;
import cn.com.poc.message.service.AirportConsumerService;
import cn.com.poc.message.topic.AirportTopic;
import cn.com.poc.ocr.entity.BizFileOcrCacheEntity;
import cn.com.poc.ocr.service.BizFileOcrCacheService;
import cn.com.yict.framemax.core.exception.BusinessException;
import cn.com.yict.framemax.tumbleweed.client.annotation.Consumer;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.io.File;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
/**
* @author alex.yao
* @date 2025/10/30
*/
@Service
public class AirportConsumerServiceImpl implements AirportConsumerService {
private String DIFY_BASE_URL = "https://dify.gsstcloud.com/v1";
private ThreadPoolExecutor executor = new ThreadPoolExecutor(10, 20, 10L,
TimeUnit.SECONDS,
new java.util.concurrent.ArrayBlockingQueue<>(5),
new ThreadFactoryBuilder().setNameFormat("pdf-paper-%d").build(),
new ThreadPoolExecutor.DiscardOldestPolicy());
@Resource
private BizFileOcrCacheService bizFileOcrCacheService;
@Resource
private BizAiDataAuditFileService bizAiDataAuditFileService;
@Resource
private BizAiDataAuditRuleService bizAiDataAuditRuleService;
@Override
@Consumer(topic = AirportTopic.AIRPORT_PDF_PAPER_TOPIC)
public void pdfPaper(AirportPDFPaperMessage message) throws Exception {
List<String> results = new CopyOnWriteArrayList<>();
List<Integer> ruleIdList = message.getRuleIdList();
AiDataAuditRuleQueryCondition aiDataAuditRuleQueryCondition = new AiDataAuditRuleQueryCondition();
aiDataAuditRuleQueryCondition.setIds(ruleIdList.toArray(new Long[ruleIdList.size()]));
List<AiDataAuditRuleQueryItem> aiDataAuditRuleQueryItems = bizAiDataAuditRuleService.aiDataAuditRuleQueryItemList(aiDataAuditRuleQueryCondition, null);
CountDownLatch countDownLatch = new CountDownLatch(aiDataAuditRuleQueryItems.size());
try {
//
for (AiDataAuditRuleQueryItem aiDataAuditRuleQueryItem : aiDataAuditRuleQueryItems) {
String ruleType = aiDataAuditRuleQueryItem.getDataAuditRuleType();
if (ruleType.equals("c2c")) {
c2c(aiDataAuditRuleQueryItem, results, countDownLatch);
} else if (ruleType.equals("c2f")) {
c2f(aiDataAuditRuleQueryItem, results, countDownLatch);
} else if (ruleType.equals("f2f")) {
f2f(aiDataAuditRuleQueryItem, results, countDownLatch);
} else {
countDownLatch.countDown();
}
}
countDownLatch.await();
} catch (Exception e) {
throw new BusinessException(e.getMessage());
}
}
// 字段对字段
private void c2c(AiDataAuditRuleQueryItem aiDataAuditRuleQueryItem, List<String> results, CountDownLatch countDownLatch) {
executor.submit(() -> {
try {
String ruleDesc = aiDataAuditRuleQueryItem.getRuleDesc();// 规则描述
Integer firstFile = aiDataAuditRuleQueryItem.getFirstFile();// 文件1
String firstField = aiDataAuditRuleQueryItem.getFirstField();// 字段1
Integer secondFile = aiDataAuditRuleQueryItem.getSecondFile();// 文件2
String secondField = aiDataAuditRuleQueryItem.getSecondField();// 字段2
String firstFileContent = StringUtils.EMPTY;
String secondFileContent = StringUtils.EMPTY;
// 找到文件 并下载对应的md 或 json 文件
BizAiDataAuditFileEntity firstAuditFileEntity = bizAiDataAuditFileService.get(firstFile);
BizFileOcrCacheEntity bizFileOcrCacheEntity = new BizFileOcrCacheEntity();
bizFileOcrCacheEntity.setMd5(firstAuditFileEntity.getMd5());
List<BizFileOcrCacheEntity> firstocrCacheEntities = bizFileOcrCacheService.findByExample(bizFileOcrCacheEntity, null);
BizFileOcrCacheEntity firstFileOcrCacheEntity = firstocrCacheEntities.get(0);
String firstMdFileUrl = firstFileOcrCacheEntity.getMdFileUrl();
String firstJsonFileUrl = firstFileOcrCacheEntity.getJsonFileUrl();
if (StringUtils.isNotBlank(firstJsonFileUrl)) {
File file = DocumentLoad.downloadURLDocument(StringUtils.isBlank(firstJsonFileUrl) ? firstMdFileUrl : firstJsonFileUrl);
firstFileContent = DocumentLoad.documentToText(file);
}
BizAiDataAuditFileEntity secondAuditFileEntity = bizAiDataAuditFileService.get(secondFile);
bizFileOcrCacheEntity = new BizFileOcrCacheEntity();
bizFileOcrCacheEntity.setMd5(secondAuditFileEntity.getMd5());
List<BizFileOcrCacheEntity> secondOcrCacheEntities = bizFileOcrCacheService.findByExample(bizFileOcrCacheEntity, null);
BizFileOcrCacheEntity secondFileOcrCacheEntity = secondOcrCacheEntities.get(0);
String secondMdFileUrl = firstFileOcrCacheEntity.getMdFileUrl();
String secondJsonFileUrl = firstFileOcrCacheEntity.getJsonFileUrl();
if (StringUtils.isNotBlank(secondJsonFileUrl)) {
File file = DocumentLoad.downloadURLDocument(StringUtils.isBlank(secondJsonFileUrl) ? secondMdFileUrl : secondJsonFileUrl);
secondFileContent = DocumentLoad.documentToText(file);
}
// 执行工作流
Map<String, Object> inputs = new LinkedHashMap<>();
inputs.put("rule", ruleDesc);
inputs.put("doc1", firstFileContent);
inputs.put("doc2", secondFileContent);
inputs.put("filed_1", firstField);
inputs.put("filed_2", secondField);
// 创建聊天客户端
DifyChatClient chatClient = DifyClientFactory.createChatClient(DIFY_BASE_URL, "app-1MRun3ecfLOzFS96xcWYCOOX");
// 创建聊天消息
ChatMessage message = ChatMessage.builder()
.query("run")
.user("0")
.inputs(inputs)
.conversationId(StringUtils.EMPTY)
.responseMode(ResponseMode.BLOCKING)
.build();
// 发送消息并获取响应
ChatMessageResponse response = chatClient.sendChatMessage(message);
String result = response.getAnswer();
results.add(result);
} catch (Exception e) {
throw new RuntimeException(e);
} finally {
countDownLatch.countDown();
}
});
}
// 字段对文件
private void c2f(AiDataAuditRuleQueryItem aiDataAuditRuleQueryItem, List<String> results, CountDownLatch countDownLatch) {
countDownLatch.countDown();
}
// 文件对文件
private void f2f(AiDataAuditRuleQueryItem aiDataAuditRuleQueryItem, List<String> results, CountDownLatch countDownLatch) {
countDownLatch.countDown();
}
}
package cn.com.poc.message.service.impl;
import cn.com.poc.message.entity.AirportPDFPaperMessage;
import cn.com.poc.message.service.AirportProducerService;
import cn.com.poc.message.topic.AirportTopic;
import cn.com.yict.framemax.tumbleweed.client.annotation.Producer;
import org.springframework.stereotype.Service;
/**
* @author alex.yao
* @date 2025/10/30
*/
@Service
public class AirportProducerServiceImpl implements AirportProducerService {
@Override
@Producer(topic = AirportTopic.AIRPORT_PDF_PAPER_TOPIC)
public AirportPDFPaperMessage pdfPaper(AirportPDFPaperMessage message) {
return message;
}
}
package cn.com.poc.message.service.impl;
import cn.com.poc.common.model.BizFileUploadRecordModel;
import cn.com.poc.common.service.BizFileUploadRecordService;
import cn.com.poc.common.service.BosConfigService;
import cn.com.poc.common.utils.DocumentLoad;
import cn.com.poc.common.utils.MD2Json;
import cn.com.poc.common.utils.UUIDTool;
import cn.com.poc.message.entity.OCRMessage;
import cn.com.poc.message.entity.OCRStatusMessage;
import cn.com.poc.message.service.OCRConsumerService;
import cn.com.poc.message.service.OCRProducerService;
import cn.com.poc.message.topic.OCRTopic;
import cn.com.poc.ocr.entity.BizFileOcrCacheEntity;
import cn.com.poc.ocr.service.BizFileOcrCacheService;
import cn.com.poc.thirdparty.resource.minerU.MinerUResponse;
import cn.com.poc.thirdparty.resource.minerU.api.MinerUAPI;
import cn.com.yict.framemax.tumbleweed.client.annotation.Consumer;
import cn.hutool.core.io.FileUtil;
import cn.hutool.crypto.digest.MD5;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
/**
* @author alex.yao
* @date 2025/10/30
*/
@Service
public class OCRConsumerServiceImpl implements OCRConsumerService {
private Logger logger = LoggerFactory.getLogger(OCRConsumerService.class);
@Resource
private MinerUAPI minerUAPI;
@Resource
private BizFileOcrCacheService bizFileOcrCacheService;
@Resource
private BosConfigService bosConfigService;
@Resource
private BizFileUploadRecordService bizFileUploadRecordService;
@Resource
private OCRProducerService ocrProducerService;
@Override
@Consumer(topic = OCRTopic.PARSE_PDF)
public void OCR(OCRMessage message) throws Exception {
OCRStatusMessage ocrStatusMessage = new OCRStatusMessage();
ocrStatusMessage.setId(message.getId());
ocrStatusMessage.setStatus("parsing");
ocrProducerService.updateStatus(ocrStatusMessage);
File file = DocumentLoad.downloadURLDocument(message.getFileURL());
MinerUResponse minerUResponse = new MinerUResponse();
minerUResponse.setFiles(file);
try {
Object o = minerUAPI.parsePDF(minerUResponse);
//
String md = "";
String json = MD2Json.md2json(md);
BizFileOcrCacheEntity updateEntity = bizFileOcrCacheService.get(message.getId());
updateEntity.setParseStatus("complete");
updateEntity.setJsonFileUrl(createFileAndUploadBos(md, "txt"));
updateEntity.setMdFileUrl(createFileAndUploadBos(md, "md"));
bizFileOcrCacheService.update(updateEntity);
} catch (Exception e) {
logger.error("----------- OCR 失败 {} ----------", e.getMessage());
OCRStatusMessage errorOcrStatusMessage = new OCRStatusMessage();
errorOcrStatusMessage.setId(message.getId());
errorOcrStatusMessage.setStatus("fail");
ocrProducerService.updateStatus(errorOcrStatusMessage);
}
}
@Override
@Consumer(topic = OCRTopic.UPDATE_STATUS)
public void updateStatus(OCRStatusMessage message) throws Exception {
logger.info("update ocr status , id:{} , status:{}", message.getId(), message.getStatus());
BizFileOcrCacheEntity bizFileOcrCacheEntity = bizFileOcrCacheService.get(message.getId());
bizFileOcrCacheEntity.setParseStatus(message.getStatus());
bizFileOcrCacheService.update(bizFileOcrCacheEntity);
}
private String createFileAndUploadBos(String content, String suffix) throws IOException {
String fileName = UUIDTool.getUUID();
File tempFile = File.createTempFile(fileName, suffix);
FileOutputStream fileOutputStream = new FileOutputStream(tempFile);
fileOutputStream.write(content.getBytes());
fileOutputStream.flush();
BufferedInputStream inputStream = FileUtil.getInputStream(tempFile);
byte[] bytes = new byte[inputStream.available()];
inputStream.read(bytes);
String md5 = MD5.create().digestHex(bytes);
String upload = bosConfigService.upload(inputStream, fileName, null);
BizFileUploadRecordModel bizFileUploadRecordModel = new BizFileUploadRecordModel();
bizFileUploadRecordModel.setFileName(fileName);
bizFileUploadRecordModel.setFileUrl(upload);
bizFileUploadRecordModel.setMd5(md5);
bizFileUploadRecordModel.setCoverSheetUrl("");
bizFileUploadRecordService.save(bizFileUploadRecordModel);
fileOutputStream.close();
inputStream.close();
tempFile.delete();
return upload;
}
}
package cn.com.poc.message.service.impl;
import cn.com.poc.message.entity.OCRMessage;
import cn.com.poc.message.entity.OCRStatusMessage;
import cn.com.poc.message.service.OCRProducerService;
import cn.com.poc.message.topic.OCRTopic;
import cn.com.yict.framemax.core.service.BaseService;
import cn.com.yict.framemax.tumbleweed.client.annotation.Producer;
import cn.com.yict.framemax.tumbleweed.constant.PublishPoint;
import org.springframework.stereotype.Service;
/**
* @author alex.yao
* @date 2025/10/30
*/
@Service
public class OCRProducerServiceImpl implements OCRProducerService {
@Override
@Producer(topic = OCRTopic.PARSE_PDF)
public OCRMessage OCR(OCRMessage message) {
return message;
}
@Override
@Producer(topic = OCRTopic.UPDATE_STATUS, publishPoint = PublishPoint.PUBLISH_REAL_TIME)
public OCRStatusMessage updateStatus(OCRStatusMessage message) {
return message;
}
}
package cn.com.poc.message.topic;
/**
* @author alex.yao
* @date 2025/10/30
*/
public interface AirportTopic {
String AIRPORT_PDF_PAPER_TOPIC = "AIRPORT_PDF_PAPER_TOPIC";
}
package cn.com.poc.message.topic;
/**
* @author alex.yao
* @date 2025/10/30
*/
public interface OCRTopic {
String PARSE_PDF = "PARSE_PDF";
String UPDATE_STATUS = "UPDATE_STATUS";
}
package cn.com.poc.ocr.convert;
import cn.com.poc.ocr.model.BizFileOcrCacheModel;
import cn.com.poc.ocr.entity.BizFileOcrCacheEntity;
import cn.com.poc.ocr.dto.BizFileOcrCacheDto;
public class BizFileOcrCacheConvert {
public static BizFileOcrCacheEntity modelToEntity(BizFileOcrCacheModel model) {
BizFileOcrCacheEntity entity = new BizFileOcrCacheEntity();
entity.setId(model.getId());
entity.setMd5(model.getMd5());
entity.setParseStatus(model.getParseStatus());
entity.setFileUrl(model.getFileUrl());
entity.setMdFileUrl(model.getMdFileUrl());
entity.setJsonFileUrl(model.getJsonFileUrl());
entity.setIsDeleted(model.getIsDeleted());
entity.setCreator(model.getCreator());
entity.setCreatedTime(model.getCreatedTime());
entity.setModifier(model.getModifier());
entity.setModifiedTime(model.getModifiedTime());
entity.setSysVersion(model.getSysVersion());
return entity;
}
public static BizFileOcrCacheModel entityToModel(BizFileOcrCacheEntity entity) {
BizFileOcrCacheModel model = new BizFileOcrCacheModel();
model.setId(entity.getId());
model.setMd5(entity.getMd5());
model.setFileUrl(entity.getFileUrl());
model.setParseStatus(entity.getParseStatus());
model.setMdFileUrl(entity.getMdFileUrl());
model.setJsonFileUrl(entity.getJsonFileUrl());
model.setIsDeleted(entity.getIsDeleted());
model.setCreator(entity.getCreator());
model.setCreatedTime(entity.getCreatedTime());
model.setModifier(entity.getModifier());
model.setModifiedTime(entity.getModifiedTime());
model.setSysVersion(entity.getSysVersion());
return model;
}
public static BizFileOcrCacheDto entityToDto(BizFileOcrCacheEntity entity) {
BizFileOcrCacheDto dto = new BizFileOcrCacheDto();
dto.setId(entity.getId());
dto.setMd5(entity.getMd5());
dto.setFileUrl(entity.getFileUrl());
dto.setParseStatus(entity.getParseStatus());
dto.setMdFileUrl(entity.getMdFileUrl());
dto.setJsonFileUrl(entity.getJsonFileUrl());
dto.setIsDeleted(entity.getIsDeleted());
dto.setCreator(entity.getCreator());
dto.setCreatedTime(entity.getCreatedTime());
dto.setModifier(entity.getModifier());
dto.setModifiedTime(entity.getModifiedTime());
dto.setSysVersion(entity.getSysVersion());
return dto;
}
public static BizFileOcrCacheEntity dtoToEntity(BizFileOcrCacheDto dto) {
BizFileOcrCacheEntity entity = new BizFileOcrCacheEntity();
entity.setId(dto.getId());
entity.setMd5(dto.getMd5());
entity.setFileUrl(dto.getFileUrl());
entity.setParseStatus(dto.getParseStatus());
entity.setMdFileUrl(dto.getMdFileUrl());
entity.setJsonFileUrl(dto.getJsonFileUrl());
entity.setIsDeleted(dto.getIsDeleted());
entity.setCreator(dto.getCreator());
entity.setCreatedTime(dto.getCreatedTime());
entity.setModifier(dto.getModifier());
entity.setModifiedTime(dto.getModifiedTime());
entity.setSysVersion(dto.getSysVersion());
return entity;
}
}
\ No newline at end of file
package cn.com.poc.ocr.dto;
public class BizFileOcrCacheDto {
private static final long serialVersionUID = 1L;
/** id
*主键id
*/
private java.lang.Long id;
public java.lang.Long getId(){
return this.id;
}
public void setId(java.lang.Long id){
this.id = id;
}
/** md5
*文件MD5
*/
private java.lang.String md5;
public java.lang.String getMd5(){
return this.md5;
}
public void setMd5(java.lang.String md5){
this.md5 = md5;
}
/**
* parse_status
* 解析状态 : create-已创建 queuing-排队中 parsing -解析中 complete-完成 fail-失败
*/
private String parseStatus;
public String getParseStatus() {
return parseStatus;
}
public void setParseStatus(String parseStatus) {
this.parseStatus = parseStatus;
}
/** file_url
*源文件地址
*/
private java.lang.String fileUrl;
public java.lang.String getFileUrl(){
return this.fileUrl;
}
public void setFileUrl(java.lang.String fileUrl){
this.fileUrl = fileUrl;
}
/** md_file_url
*OCR后MD文件地址
*/
private java.lang.String mdFileUrl;
public java.lang.String getMdFileUrl(){
return this.mdFileUrl;
}
public void setMdFileUrl(java.lang.String mdFileUrl){
this.mdFileUrl = mdFileUrl;
}
/** json_file_url
*提取json后文件url
*/
private java.lang.String jsonFileUrl;
public java.lang.String getJsonFileUrl(){
return this.jsonFileUrl;
}
public void setJsonFileUrl(java.lang.String jsonFileUrl){
this.jsonFileUrl = jsonFileUrl;
}
/** is_deleted
*是否删除 Y 是 N 否
*/
private java.lang.String isDeleted;
public java.lang.String getIsDeleted(){
return this.isDeleted;
}
public void setIsDeleted(java.lang.String isDeleted){
this.isDeleted = isDeleted;
}
/** CREATOR
*创建人
*/
private java.lang.String creator;
public java.lang.String getCreator(){
return this.creator;
}
public void setCreator(java.lang.String creator){
this.creator = creator;
}
/** CREATED_TIME
*创建时间
*/
private java.util.Date createdTime;
public java.util.Date getCreatedTime(){
return this.createdTime;
}
public void setCreatedTime(java.util.Date createdTime){
this.createdTime = createdTime;
}
/** MODIFIER
*修改人
*/
private java.lang.String modifier;
public java.lang.String getModifier(){
return this.modifier;
}
public void setModifier(java.lang.String modifier){
this.modifier = modifier;
}
/** MODIFIED_TIME
*修改时间
*/
private java.util.Date modifiedTime;
public java.util.Date getModifiedTime(){
return this.modifiedTime;
}
public void setModifiedTime(java.util.Date modifiedTime){
this.modifiedTime = modifiedTime;
}
/** SYS_VERSION
*乐观锁,版本号
*/
private java.lang.Integer sysVersion;
public java.lang.Integer getSysVersion(){
return this.sysVersion;
}
public void setSysVersion(java.lang.Integer sysVersion){
this.sysVersion = sysVersion;
}
}
\ No newline at end of file
package cn.com.poc.ocr.entity;
public class BizFileOcrCacheEntity {
private static final long serialVersionUID = 1L;
/** id
*主键id
*/
private java.lang.Long id;
public java.lang.Long getId(){
return this.id;
}
public void setId(java.lang.Long id){
this.id = id;
}
/** md5
*文件MD5
*/
private java.lang.String md5;
public java.lang.String getMd5(){
return this.md5;
}
public void setMd5(java.lang.String md5){
this.md5 = md5;
}
/**
* parse_status
* 解析状态 : create-已创建 queuing-排队中 parsing -解析中 complete-完成 fail-失败
*/
private String parseStatus;
public String getParseStatus() {
return parseStatus;
}
public void setParseStatus(String parseStatus) {
this.parseStatus = parseStatus;
}
/** file_url
*源文件地址
*/
private java.lang.String fileUrl;
public java.lang.String getFileUrl(){
return this.fileUrl;
}
public void setFileUrl(java.lang.String fileUrl){
this.fileUrl = fileUrl;
}
/** md_file_url
*OCR后MD文件地址
*/
private java.lang.String mdFileUrl;
public java.lang.String getMdFileUrl(){
return this.mdFileUrl;
}
public void setMdFileUrl(java.lang.String mdFileUrl){
this.mdFileUrl = mdFileUrl;
}
/** json_file_url
*提取json后文件url
*/
private java.lang.String jsonFileUrl;
public java.lang.String getJsonFileUrl(){
return this.jsonFileUrl;
}
public void setJsonFileUrl(java.lang.String jsonFileUrl){
this.jsonFileUrl = jsonFileUrl;
}
/** is_deleted
*是否删除 Y 是 N 否
*/
private java.lang.String isDeleted;
public java.lang.String getIsDeleted(){
return this.isDeleted;
}
public void setIsDeleted(java.lang.String isDeleted){
this.isDeleted = isDeleted;
}
/** CREATOR
*创建人
*/
private java.lang.String creator;
public java.lang.String getCreator(){
return this.creator;
}
public void setCreator(java.lang.String creator){
this.creator = creator;
}
/** CREATED_TIME
*创建时间
*/
private java.util.Date createdTime;
public java.util.Date getCreatedTime(){
return this.createdTime;
}
public void setCreatedTime(java.util.Date createdTime){
this.createdTime = createdTime;
}
/** MODIFIER
*修改人
*/
private java.lang.String modifier;
public java.lang.String getModifier(){
return this.modifier;
}
public void setModifier(java.lang.String modifier){
this.modifier = modifier;
}
/** MODIFIED_TIME
*修改时间
*/
private java.util.Date modifiedTime;
public java.util.Date getModifiedTime(){
return this.modifiedTime;
}
public void setModifiedTime(java.util.Date modifiedTime){
this.modifiedTime = modifiedTime;
}
/** SYS_VERSION
*乐观锁,版本号
*/
private java.lang.Integer sysVersion;
public java.lang.Integer getSysVersion(){
return this.sysVersion;
}
public void setSysVersion(java.lang.Integer sysVersion){
this.sysVersion = sysVersion;
}
}
\ No newline at end of file
package cn.com.poc.ocr.model;
import java.io.Serializable;
import cn.com.yict.framemax.data.model.BaseModelClass;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Id;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import javax.persistence.Version;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
/**
* Model class for biz_file_ocr_cache
* 文件OCR结果缓存
*/
@Entity
@Table(name = "biz_file_ocr_cache")
@DynamicInsert
@DynamicUpdate
public class BizFileOcrCacheModel extends BaseModelClass implements Serializable {
private static final long serialVersionUID = 1L;
/**
* id
* 主键id
*/
private java.lang.Long id;
@Column(name = "id", length = 19)
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
public java.lang.Long getId() {
return this.id;
}
public void setId(java.lang.Long id) {
this.id = id;
super.addValidField("id");
}
/**
* md5
* 文件MD5
*/
private java.lang.String md5;
@Column(name = "md5", length = 200)
public java.lang.String getMd5() {
return this.md5;
}
public void setMd5(java.lang.String md5) {
this.md5 = md5;
super.addValidField("md5");
}
/**
* parse_status
* 解析状态 : create-已创建 queuing-排队中 parsing -解析中 complete-完成 fail-失败
*/
private String parseStatus;
@Column(name = "parse_status", length = 10)
public String getParseStatus() {
return parseStatus;
}
public void setParseStatus(String parseStatus) {
this.parseStatus = parseStatus;
super.addValidField("parseStatus");
}
/**
* file_url
* 源文件地址
*/
private java.lang.String fileUrl;
@Column(name = "file_url", length = 200)
public java.lang.String getFileUrl() {
return this.fileUrl;
}
public void setFileUrl(java.lang.String fileUrl) {
this.fileUrl = fileUrl;
super.addValidField("fileUrl");
}
/**
* md_file_url
* OCR后MD文件地址
*/
private java.lang.String mdFileUrl;
@Column(name = "md_file_url", length = 200)
public java.lang.String getMdFileUrl() {
return this.mdFileUrl;
}
public void setMdFileUrl(java.lang.String mdFileUrl) {
this.mdFileUrl = mdFileUrl;
super.addValidField("mdFileUrl");
}
/**
* json_file_url
* 提取json后文件url
*/
private java.lang.String jsonFileUrl;
@Column(name = "json_file_url", length = 200)
public java.lang.String getJsonFileUrl() {
return this.jsonFileUrl;
}
public void setJsonFileUrl(java.lang.String jsonFileUrl) {
this.jsonFileUrl = jsonFileUrl;
super.addValidField("jsonFileUrl");
}
/**
* is_deleted
* 是否删除 Y 是 N 否
*/
private java.lang.String isDeleted;
@Column(name = "is_deleted", length = 1)
public java.lang.String getIsDeleted() {
return this.isDeleted;
}
public void setIsDeleted(java.lang.String isDeleted) {
this.isDeleted = isDeleted;
super.addValidField("isDeleted");
}
/**
* CREATOR
* 创建人
*/
private java.lang.String creator;
@Column(name = "CREATOR", length = 50)
public java.lang.String getCreator() {
return this.creator;
}
public void setCreator(java.lang.String creator) {
this.creator = creator;
super.addValidField("creator");
}
/**
* CREATED_TIME
* 创建时间
*/
private java.util.Date createdTime;
@Column(name = "CREATED_TIME", length = 19)
public java.util.Date getCreatedTime() {
return this.createdTime;
}
public void setCreatedTime(java.util.Date createdTime) {
this.createdTime = createdTime;
super.addValidField("createdTime");
}
/**
* MODIFIER
* 修改人
*/
private java.lang.String modifier;
@Column(name = "MODIFIER", length = 50)
public java.lang.String getModifier() {
return this.modifier;
}
public void setModifier(java.lang.String modifier) {
this.modifier = modifier;
super.addValidField("modifier");
}
/**
* MODIFIED_TIME
* 修改时间
*/
private java.util.Date modifiedTime;
@Column(name = "MODIFIED_TIME", length = 19)
public java.util.Date getModifiedTime() {
return this.modifiedTime;
}
public void setModifiedTime(java.util.Date modifiedTime) {
this.modifiedTime = modifiedTime;
super.addValidField("modifiedTime");
}
/**
* SYS_VERSION
* 乐观锁,版本号
*/
private java.lang.Integer sysVersion;
@Column(name = "SYS_VERSION", length = 10)
@Version
public java.lang.Integer getSysVersion() {
return this.sysVersion;
}
public void setSysVersion(java.lang.Integer sysVersion) {
this.sysVersion = sysVersion;
super.addValidField("sysVersion");
}
}
\ No newline at end of file
package cn.com.poc.ocr.repository;
import cn.com.yict.framemax.data.repository.Repository;
import cn.com.poc.ocr.model.BizFileOcrCacheModel;
public interface BizFileOcrCacheRepository extends Repository<BizFileOcrCacheModel,java.lang.Long> {
}
\ No newline at end of file
package cn.com.poc.ocr.rest;
import cn.com.yict.framemax.core.rest.BaseRest;
import cn.com.poc.ocr.dto.BizFileOcrCacheDto;
import cn.com.yict.framemax.data.model.PagingInfo;
import java.util.Collection;
import java.util.List;
import cn.com.yict.framemax.web.permission.Access;
import cn.com.yict.framemax.web.permission.Permission;
import org.springframework.web.bind.annotation.RequestBody;
public interface BizFileOcrCacheRest extends BaseRest {
BizFileOcrCacheDto getById(java.lang.Long id) throws Exception;
List<BizFileOcrCacheDto> getList(BizFileOcrCacheDto example,PagingInfo pagingInfo) throws Exception;
BizFileOcrCacheDto save(BizFileOcrCacheDto dto) throws Exception;
BizFileOcrCacheDto update(BizFileOcrCacheDto dto) throws Exception;
void deletedById(java.lang.Long id) throws Exception;
}
\ No newline at end of file
package cn.com.poc.ocr.rest.impl;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.stereotype.Component;
import cn.com.poc.ocr.rest.BizFileOcrCacheRest;
import cn.com.poc.ocr.service.BizFileOcrCacheService;
import cn.com.poc.ocr.dto.BizFileOcrCacheDto;
import cn.com.poc.ocr.entity.BizFileOcrCacheEntity;
import cn.com.yict.framemax.data.model.PagingInfo;
import cn.com.poc.ocr.convert.BizFileOcrCacheConvert;
import java.util.stream.Collectors;
import org.springframework.util.Assert;
@Component
public class BizFileOcrCacheRestImpl implements BizFileOcrCacheRest {
@Resource
private BizFileOcrCacheService service;
public BizFileOcrCacheDto getById(java.lang.Long id) throws Exception{
Assert.notNull(id);
return BizFileOcrCacheConvert.entityToDto(service.get(id));
}
public List<BizFileOcrCacheDto> getList(BizFileOcrCacheDto dto,PagingInfo pagingInfo) throws Exception{
return service
.findByExample(BizFileOcrCacheConvert.dtoToEntity(dto),pagingInfo)
.stream()
.map(BizFileOcrCacheConvert::entityToDto)
.collect(Collectors.toList());
}
public BizFileOcrCacheDto save(BizFileOcrCacheDto dto) throws Exception{
Assert.notNull(dto);
BizFileOcrCacheEntity entity = BizFileOcrCacheConvert.dtoToEntity(dto);
return BizFileOcrCacheConvert.entityToDto(service.save(entity));
}
public BizFileOcrCacheDto update(BizFileOcrCacheDto dto) throws Exception{
Assert.notNull(dto);
BizFileOcrCacheEntity entity = BizFileOcrCacheConvert.dtoToEntity(dto);
return BizFileOcrCacheConvert.entityToDto(service.update(entity));
}
public void deletedById(java.lang.Long id) throws Exception{
Assert.notNull(id);
service.deletedById(id);
}
}
\ No newline at end of file
package cn.com.poc.ocr.scheduler;
import cn.com.poc.common.constant.CommonConstant;
import cn.com.poc.common.utils.StringUtils;
import cn.com.poc.message.entity.OCRMessage;
import cn.com.poc.message.service.OCRProducerService;
import cn.com.poc.ocr.entity.BizFileOcrCacheEntity;
import cn.com.poc.ocr.service.BizFileOcrCacheService;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.List;
/**
* OCR服务
*
* @author alex.yao
* @date 2025/10/30
*/
@Component
public class OCRScheduler {
@Resource
private BizFileOcrCacheService bizFileOcrCacheService;
@Resource
private OCRProducerService ocrProducerService;
@Scheduled(fixedDelay = 10000)
public void taskStatusUpdate() throws Exception {
BizFileOcrCacheEntity bizFileOcrCacheEntity = new BizFileOcrCacheEntity();
bizFileOcrCacheEntity.setParseStatus("create");
bizFileOcrCacheEntity.setIsDeleted(CommonConstant.IsDeleted.N);
List<BizFileOcrCacheEntity> fileOcrCacheEntities = bizFileOcrCacheService.findByExample(bizFileOcrCacheEntity, null);
if (CollectionUtils.isNotEmpty(fileOcrCacheEntities)) {
for (BizFileOcrCacheEntity fileOcrCacheEntity : fileOcrCacheEntities) {
if (fileOcrCacheEntity.getParseStatus().equals("create")) {
if (StringUtils.isBlank(fileOcrCacheEntity.getMdFileUrl())) {
fileOcrCacheEntity.setParseStatus("queuing");
bizFileOcrCacheService.update(fileOcrCacheEntity);
OCRMessage message = new OCRMessage();
message.setId(fileOcrCacheEntity.getId());
message.setFileURL(fileOcrCacheEntity.getFileUrl());
message.setMd5(fileOcrCacheEntity.getMd5());
ocrProducerService.OCR(message);
} else {
fileOcrCacheEntity.setParseStatus("complete");
bizFileOcrCacheService.update(fileOcrCacheEntity);
}
}
}
}
}
}
package cn.com.poc.ocr.service;
import cn.com.yict.framemax.core.service.BaseService;
import cn.com.poc.ocr.entity.BizFileOcrCacheEntity;
import cn.com.yict.framemax.data.model.PagingInfo;
import java.util.Collection;
import java.util.List;
public interface BizFileOcrCacheService extends BaseService {
BizFileOcrCacheEntity get(java.lang.Long id) throws Exception;
List<BizFileOcrCacheEntity> findByExample(BizFileOcrCacheEntity example,PagingInfo pagingInfo) throws Exception;
BizFileOcrCacheEntity save(BizFileOcrCacheEntity entity) throws Exception;
BizFileOcrCacheEntity update(BizFileOcrCacheEntity entity) throws Exception;
void deletedById(java.lang.Long id) throws Exception;
}
\ No newline at end of file
package cn.com.poc.ocr.service.impl;
import cn.com.yict.framemax.core.service.impl.BaseServiceImpl;
import cn.com.poc.ocr.service.BizFileOcrCacheService;
import cn.com.poc.ocr.model.BizFileOcrCacheModel;
import cn.com.poc.ocr.entity.BizFileOcrCacheEntity;
import cn.com.poc.ocr.convert.BizFileOcrCacheConvert;
import cn.com.poc.ocr.repository.BizFileOcrCacheRepository;
import cn.com.yict.framemax.data.model.PagingInfo;
import org.springframework.stereotype.Service;
import org.apache.commons.collections4.CollectionUtils;
import java.util.ArrayList;
import java.util.stream.Collectors;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.util.Assert;
@Service
public class BizFileOcrCacheServiceImpl extends BaseServiceImpl
implements BizFileOcrCacheService {
@Resource
private BizFileOcrCacheRepository repository;
public BizFileOcrCacheEntity get(java.lang.Long id) throws Exception {
Assert.notNull(id);
BizFileOcrCacheModel model = this.repository.get(id);
if (model == null) {
return null;
}
if ("Y".equals(model.getIsDeleted())) {
return null;
}
return BizFileOcrCacheConvert.modelToEntity(model);
}
public List<BizFileOcrCacheEntity> findByExample(BizFileOcrCacheEntity example, PagingInfo pagingInfo) throws Exception {
List<BizFileOcrCacheEntity> result = new ArrayList<BizFileOcrCacheEntity>();
BizFileOcrCacheModel model = new BizFileOcrCacheModel();
if (example != null) {
model = BizFileOcrCacheConvert.entityToModel(example);
}
model.setIsDeleted("N");
List<BizFileOcrCacheModel> models = this.repository.findByExample(model, pagingInfo);
if (CollectionUtils.isNotEmpty(models)) {
result = models.stream().map(BizFileOcrCacheConvert::modelToEntity).collect(Collectors.toList());
}
return result;
}
public BizFileOcrCacheEntity save(BizFileOcrCacheEntity entity) throws Exception {
Assert.notNull(entity);
entity.setId(null);
entity.setIsDeleted("N");
BizFileOcrCacheModel model = BizFileOcrCacheConvert.entityToModel(entity);
BizFileOcrCacheModel saveModel = this.repository.save(model);
return BizFileOcrCacheConvert.modelToEntity(saveModel);
}
public BizFileOcrCacheEntity update(BizFileOcrCacheEntity entity) throws Exception {
Assert.notNull(entity);
Assert.notNull(entity.getId(), "update pk can not be null");
BizFileOcrCacheModel model = this.repository.get(entity.getId());
if (entity.getMd5() != null) {
model.setMd5(entity.getMd5());
}
if (entity.getFileUrl() != null) {
model.setFileUrl(entity.getFileUrl());
}
if (entity.getParseStatus() != null) {
model.setParseStatus(entity.getParseStatus());
}
if (entity.getMdFileUrl() != null) {
model.setMdFileUrl(entity.getMdFileUrl());
}
if (entity.getJsonFileUrl() != null) {
model.setJsonFileUrl(entity.getJsonFileUrl());
}
if (entity.getIsDeleted() != null) {
model.setIsDeleted(entity.getIsDeleted());
}
if (entity.getCreator() != null) {
model.setCreator(entity.getCreator());
}
if (entity.getCreatedTime() != null) {
model.setCreatedTime(entity.getCreatedTime());
}
if (entity.getModifier() != null) {
model.setModifier(entity.getModifier());
}
if (entity.getModifiedTime() != null) {
model.setModifiedTime(entity.getModifiedTime());
}
if (entity.getSysVersion() != null) {
model.setSysVersion(entity.getSysVersion());
}
BizFileOcrCacheModel saveModel = this.repository.save(model);
return BizFileOcrCacheConvert.modelToEntity(saveModel);
}
public void deletedById(java.lang.Long id) throws Exception {
Assert.notNull(id);
BizFileOcrCacheModel model = this.repository.get(id);
if (model != null) {
if ("N".equals(model.getIsDeleted())) {
model.setIsDeleted("Y");
this.repository.save(model);
}
}
}
}
\ No newline at end of file
package cn.com.poc.common;
import cn.com.poc.common.utils.MD2Json;
import cn.com.yict.framemax.core.spring.SingleContextInitializer;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.web.WebAppConfiguration;
/**
* @author alex.yao
* @date 2025/10/30
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(initializers = SingleContextInitializer.class)
@WebAppConfiguration
public class UtilTest {
@Test
public void test_md2jsonToPaperIsFalse() {
String md = "OCR技术的演进,正在进入一场“终局之战”:一边是DeepSeek以大模型为武器的激进突围,另一边是百度以生态与数据壁垒构筑的稳固防线。这不仅是技术路线的分歧,更是AI时代对“认知边界”的重新定义。本文将从技术架构、产品策略与行业格局三方面,解析这场OCR领域的关键博弈。\n" +
"\n" +
"\n" +
"在AI技术上,OCR(光学字符识别)一度是个传统甚至有点无聊的赛道。它就像一个勤勤恳恳的“数字档案员”,埋头从图片里提取文本。但现在,这个赛道突然变得无比“性感”。\n" +
"\n" +
"因为它的核心任务已经变了。\n" +
"\n" +
"一场关于文档智能的“范式革命”已经打响。近期,DeepSeek和百度相继亮出的“王牌”,不仅仅是技术迭代,更是两种截然不同的AI发展哲学的正面碰撞。\n" +
"\n" +
"作为产品经理,我们必须看懂:这场对决的表象之下,隐藏着文档AI市场未来的两条“生死线”。这关乎我们未来是选择一个“革命性”的标准,还是一个“极致好用”的工具。\n" +
"\n" +
"1. DeepSeek的豪赌:一场“AI为AI”的标准之战\n" +
"DeepSeek-OCR瞄准的痛点,不是你的业务流程,而是AI自己。\n" +
"\n" +
"大型语言模型(LLM,Large Language Model)非常强大,但它们有两个“致命”缺陷:\n" +
"\n" +
"成本高昂:处理海量文档(即“长上下文”)时,Token(代币)消耗是天文数字。\n" +
"理解肤浅:传统的OCR“喂”给LLM的是一长串纯文本。这等于把一本图文并茂、布局精良的杂志撕碎,只保留文字,完全“丢失”了版式、表格、图表等关键的「二维空间信息」。\n" +
"DeepSeek的解决方案叫“光学压缩”(Contexts Optical Compression),这是一个极具“革命性”甚至“攻击性”的思路。\n" +
"\n" +
"它不提取文本,而是将整个文档页面——包含所有布局、表格、公式和图片——直接“压缩”成一种高密度的“视觉Token”(视觉代币)。\n" +
"\n" +
"打个比方,它不是在“复述”这本书的内容,而是给LLM提供了一个「高保真的缩略图」。一个原本需要数千个文本Token才能表示的页面,现在可能只需要一百到几百个视觉Token。\n" +
"\n" +
"这带来的好处是双重的:\n" +
"\n" +
"成本骤降:Token数量级减少,处理效率(吞吐量)暴增。\n" +
"理解保真:AI第一次能“看”到原始的版式,它知道这是一个表格,那是一个分栏。\n" +
"DeepSeek的战略意图是「AI for AI」。它真正的用户是“AI模型本身”。它在赌自己的这套“视觉压缩标准”能成为下一代AI处理海量知识的基石,成为AI世界的“PDF”。\n" +
"\n" +
"但这正是一场豪赌。作为PM,我们能立刻看穿它的GTM(Go-to-Market,推向市场)难题:它在试图建立一个“专有标准”。它如何说服全世界的AI开发者(比如OpenAI、Anthropic,乃至百度自己)放弃他们苦心经营的视觉编码器,转而“适配”它的压缩标准?\n" +
"\n" +
"这就像一场操作系统之战。DeepSeek的成功,取决于它能否快速建立一个“开发者生态”,让它的“视觉Token”成为AI-Native(AI原生)知识库的“新事实标准”。如果赌赢了,它将掌握下一代AI的“数据入口”;如果赌输了,它就只是一个“屠龙之技”。\n" +
"\n" +
"2. 百度的堡垒:一座“AI为商业”的工程巅峰\n" +
"与DeepSeek的“未来主义”豪赌不同,百度的哲学完全相反,它立足于“当下”。\n" +
"\n" +
"百度PaddleOCR-VL的目标用户不是未来的AI,而是「今天」的企业。它的用户是正在灯下审核那张「手写金额模糊不清」的发票的财务、是正在处理「跨页合并单元格」的金融分析师、是正在录入「印刷体与手写体混合」保单的运营。\n" +
"\n" +
"这些用户不需要“光学压缩”这么性感的概念,他们需要的是“稳定”、“精准”,以及“立刻能用”。\n" +
"\n" +
"因此,百度走的是一条“工程即SOTA(State-of-the-Art,顶尖水平)”的务实路线。它推出的VLM(多模态视觉语言模型),就是为了攻克企业文档里那些最硬的骨头。\n" +
"\n" +
"百度的战略是构建「AI for Business」的坚固堡垒。\n" +
"\n" +
"它通过在权威基准测试上“屠榜”,向市场证明:在解决企业真实、复杂、棘手的文档解析问题上,我是最可靠的。这份“可靠性”就是它最深的护城河。\n" +
"\n" +
"同时,百度强大的生态(飞桨PaddlePaddle深度学习平台)和成熟的商业化部署方案(公有云、私有化部署、离线SDK),使其能快速将这种SOTA能力转化为“企业级解决方案”。它不是在“卖模型”,它是在“卖集成”,卖一个可以直接「嵌入」到你现有ERP(Enterprise Resource Planning,企业资源计划)、财务软件和业务流中的“即战力”。\n" +
"\n" +
"但百度同样面临一个“SOTA陷阱”。这个陷阱源于经典的“创新者窘境”。百度今天引以为傲的“极限精度”(比如比通用模型高5%的准确率),是它投入巨大工程资源“卷”出来的。\n" +
"\n" +
"但当3-5年后,通用的GPT-6或文心N代模型「开箱即用」就能解决95%的文档任务时,企业是否还愿意为百度那“额外5%”的极限精度,支付高昂的定制和私有化部署费用?\n" +
"\n" +
"当“足够好”的通用AI变得触手可及时,专业工具的生存空间就会被严重挤压。百度的“堡垒”要想不被攻破,就必须在通用AI彻底成熟前,完成从“卖工具”到“锁定工作流”的转型。\n" +
"\n" +
"3. PM的战场:从“技术边界”到“用户习惯”\n" +
"作为产品经理,在技术选型之外,我们还有两个更重要的战场:\n" +
"\n" +
"战场一:厘清“技术边界”\n" +
"我们必须停止将所有“看图”的任务都称为OCR。这是最容易犯的认知错误。\n" +
"\n" +
"皮肤诊断、衣料识别:这是典型的CV(ComputerVision,计算机视觉)任务。它的核心是“模式识别”和“图像分类”,与读取字符无关。\n" +
"辅助视障人士:这是一个“混合应用”的绝佳范例。当用户需要“阅读”菜单时,调用OCR;当用户需要“避开”障碍物时,调用CV的“物体检测”。\n" +
"PM的职责,就是精准定义“用户要解决的问题”,然后匹配正确的AI能力。把一个CV问题交给OCR团队,无异于缘木求鱼。\n" +
"\n" +
"战场二:攻克“用户习惯”的最后一公里\n" +
"这可能是比技术本身更难的挑战。VLM的终局是“自然语言交互”,但我们当下的用户,是被“字段框”驯化了二十年的财务和法务。\n" +
"\n" +
"我们如何将一个习惯了“在‘金额’字段框里审核数字”的财务人员,平稳过渡到“在一个聊天框里向AI提问”的全新交互模式?\n" +
"\n" +
"「用户的操作习惯」是比技术更难攻克的堡垒。\n" +
"\n" +
"我们的解决方案不该是“革命”式的替换,而应是“渐进式”的引导。\n" +
"\n" +
"“可信UI”(TrustableUI):这是转型的第一步。当VLM分析完一份合同,它不应只给出一个“答案”。它必须在原始文档上「高亮」它引用的关键证据,并给出“置信度”打分。这就像一个“Diff视图”(差异对比),它帮助用户建立信任,将角色从“数据录入员”平滑过渡到「AI审核员」。\n" +
"“混合式交互”(HybridInteraction):不要强迫用户二选一。保留用户熟悉的“字段框”,但同时在旁边提供一个“AI助手”聊天框。让用户可以继续点击字段,也可以随时输入:“帮我找出这家供应商过去6个月的所有发票”。让新旧两种交互模式并存,用“体验优势”自然引导用户迁移。\n" +
"聚焦“JTBD”(Jobs-to-be-Done):我们的终极目标不是“识别”。用户的“待办任务”不是“OCR一张发票”,而是“在月底前合规地关闭账目”。这意味着我们的产品必须超越“提取”,深入到“校验”、“审批”、“归档”乃至“支付”的整个「工作流」。\n" +
"4. 未来的“三步曲”:谁将定义OCR的终局?\n" +
"这场对决的真正走向,将关乎我们未来如何与信息交互。\n" +
"\n" +
"第一阶段:「混合并行期」 (2025-2026)市场将明显分化。百度的“工程派”VLM将继续主导对“可靠性”要求极高的企业级结构化工作流(如财税、保单、物流单据)。 与此同时,DeepSeek的“革命派”方案将在非结构化领域(如科研、法律电子取证、R&D)爆发。在这些场景下,「理解500页的PDF技术文档」远比“提取3个字段”更重要。\n" +
"\n" +
"第二阶段:「通用模型侵蚀期」 (2027-2028)通用VLM(如GPT-6或同等模型)将变得极其强大,它们的“泛用性”将严重“挤压”纯粹靠模型精度获利的服务商。 百度的生存空间,取决于它是否已成功转型为“深度嵌入业务的工作流SaaS”。它的护城河将不再是“模型精度”,而是「流程锁定」和“数据合规”。\n" +
"\n" +
"第三阶段:「感知即智能期」 (2029年以后)“OCR”这个词汇将逐渐消失。就像我们今天不再谈论“上网”一样,AI处理文档将成为一种“本能”,一种像“水电煤”一样的基础感知能力。\n" +
"\n" +
"这背后是一个更宏大的叙事:这一切都是在为“AI Agents”制造“眼睛”。\n" +
"\n" +
"一个“全自动财务审计Agent”必须具备“阅读”财报和发票的能力。我们今天所分析的,正是这些未来智能体的“感知引擎”。\n" +
"\n" +
"对于产品经理而言,这场对决的启示是:我们必须停止只关注“提取”的准确率。我们真正要设计的,是一个全新的、基于“智能感知”的工作流。\n" +
"\n" +
"在这场关乎“AI之眼”的终局之战中,DeepSeek和百度,刚刚分别从“未来”和“现在”两个方向,同时吹响了号角。\n" +
"\n" +
"本文由 @靠谱瓦叔 原创发布于人人都是产品经理。未经作者许可,禁止转载\n" +
"\n" +
"题图来自Unsplash,基于CC0协议";
System.out.println(MD2Json.md2json(md));
}
@Test
public void test_md2json() {
String md = "# Work Permit Extension Details\n" +
"\n" +
"REQ250219010\n" +
"\n" +
"New\n" +
"\n" +
"WPO Validation\n" +
"\n" +
"Pending Approval\n" +
"\n" +
"Approved/Closed\n" +
"\n" +
"Application Details\n" +
"\n" +
"Review & Comment\n" +
"\n" +
"WPO Notes\n" +
"\n" +
"Extension History\n" +
"\n" +
"# Parent Work Permit\n" +
"\n" +
"PARENT WORK PERMIT NO.\n" +
"\n" +
"WP056183\n" +
"\n" +
"# Contract Information\n" +
"\n" +
"CONTRACT TYPE*\n" +
"\n" +
"Airport Authority Hong Kong\n" +
"\n" +
"CONTRACT NO.\n" +
"\n" +
"CR13/68/1\n" +
"\n" +
"CONTRACT TITLE\n" +
"\n" +
"Design, Supply and Installation of Smart Passenger Security Screening System at HKIA\n" +
"\n" +
"# Sponsoring Organization\n" +
"\n" +
"ORGANIZATION*\n" +
"\n" +
"Airport Authority Hong Kong\n" +
"\n" +
"REPRESENTATIVE 1*\n" +
"\n" +
"Tony S Y Chan\n" +
"\n" +
"MOBILE NO.\n" +
"\n" +
"OFFICE NO.\n" +
"\n" +
"63431672\n" +
"\n" +
"21836157\n" +
"\n" +
"EMAIL ADDRESS\n" +
"\n" +
"tony.sy.chan@hkairport.com\n" +
"\n" +
"More Sponsor\n" +
"\n" +
"# Contractor Information\n" +
"\n" +
"ORGANIZATION*\n" +
"\n" +
"Nuctech Hong Kong Company Limited\n" +
"\n" +
"REPRESENTATIVE\n" +
"\n" +
"Liu Chao\n" +
"\n" +
"OFFICE NO.\n" +
"\n" +
"31534542\n" +
"\n" +
"MOBILE NO.\n" +
"\n" +
"68815681\n" +
"\n" +
"EMAIL ADDRESS\n" +
"\n" +
"liuchao1@nuctech.com\n" +
"\n" +
"# Safety Representative Information\n" +
"\n" +
"REPRESENTATIVE\n" +
"\n" +
"Cheung Ka Yuen\n" +
"\n" +
"OFFICE NO. \\*\n" +
"\n" +
"2877 1933\n" +
"\n" +
"MOBILE NO. *\n" +
"\n" +
"62850087\n" +
"\n" +
"EMAIL ADDRESS\n" +
"\n" +
"cheungkayuen@nuctech.com\n" +
"\n" +
"# Work Details\n" +
"\n" +
"DESCRIPTION*\n" +
"\n" +
"Approve\n" +
"\n" +
"Reject\n" +
"\n" +
"Cancel Application\n" +
"\n" +
"Endorsers\n" +
"\n" +
"+\n" +
"\n" +
"Claire W N Chiu\n" +
"\n" +
"CHIUCWN@hkairport.com\n" +
"\n" +
"<\n" +
"\n" +
"Cher S Y Lau\n" +
"\n" +
"cher.lau@hkairport.com\n" +
"\n" +
"<\n" +
"\n" +
"Tommy C F Lee\n" +
"\n" +
"tommy.lee@hkairport.com\n" +
"\n" +
"<\n" +
"\n" +
"Approval Status\n" +
"\n" +
"No approvals requested yet.\n" +
"\n" +
"Sponsor Confirmation Status\n" +
"\n" +
"Tony S Y Chan\n" +
"\n" +
"Approved at 2025-02-19\n" +
"\n" +
"14:49:15\n" +
"\n" +
"Attachments\n" +
"\n" +
"Download All\n" +
"\n" +
"1. Work Programme - Work Progra\n" +
"\n" +
"mme for L7DIH Phase 2b.pdf\n" +
"\n" +
"Dismantle the existing X-ray Machines and Archway Metal Detectors in South Departure Immigration Hall and North Departure Immigration Hall. Delivery, installation, T&C for the new CT X-ray Machines, Archway Metal Detectors, Full Body Scanners, Explosives Trace Detectors, and Bottle Liquid Scanners.\n" +
"\n" +
"NO. OF WORKERS\n" +
"\n" +
"20\n" +
"\n" +
"# Proposed Working Date\n" +
"\n" +
"START DATE\n" +
"\n" +
"23-Feb-2025\n" +
"\n" +
"END DATE\n" +
"\n" +
"X\n" +
"\n" +
"30-Jun-2025\n" +
"\n" +
"X\n" +
"\n" +
"# Proposed Working Hours\n" +
"\n" +
"START TIME*\n" +
"\n" +
"00:00\n" +
"\n" +
"X\n" +
"\n" +
"23:59\n" +
"\n" +
"X\n" +
"\n" +
"# Work Method Statement\n" +
"\n" +
"TITLE\n" +
"\n" +
"Method Statement For L7DIH Phase 2\n" +
"\n" +
"DOCUMENT NO.\n" +
"\n" +
"REVISION (IF ANY)\n" +
"\n" +
"DATE\n" +
"\n" +
"22-Jul-2024\n" +
"\n" +
"![](https://cdn-mineru.openxlab.org.cn/result/2025-10-29/749571bc-546a-49c9-a42b-deb9e5c924ce/666dca006937e9b45b4498102698cf75834a712a2ceb200b05bef151bd446959.jpg)\n" +
"\n" +
"# Safety Plan / Safety Method Statement\n" +
"\n" +
"TITLE\n" +
"\n" +
"Safety Method Statement for DIH PHASE II\n" +
"\n" +
"DOCUMENT NO.\n" +
"\n" +
"REVISION (IF ANY)\n" +
"\n" +
"DATE\n" +
"\n" +
"6-Aug-2024\n" +
"\n" +
"×\n" +
"\n" +
"# Risk Assessment\n" +
"\n" +
"TITLE*\n" +
"\n" +
"Risk Assessment Report for DIH PHASE II\n" +
"\n" +
"REVISION (IF ANY)\n" +
"\n" +
"APPROVAL DATE\n" +
"\n" +
"6-Aug-2024\n" +
"\n" +
"X\n" +
"\n" +
"# Work Permit Processing Fee\n" +
"\n" +
"CONTRACT SUM*\n" +
"\n" +
"$ 808714200\n" +
"\n" +
"WORK PERMIT PROCESSING FEE\n" +
"\n" +
"$ 0\n" +
"\n" +
"# Insurance\n" +
"\n" +
"OCWIP / SELF-ARRANGED *\n" +
"\n" +
"OCWIP\n" +
"\n" +
"Self-arranged\n" +
"\n" +
"DECLARATION NO.\n" +
"\n" +
"# FRTMO Equipment\n" +
"\n" +
"REQUEST TO BORROW FRTMO EQUIPMENT*\n" +
"\n" +
"Yes \n" +
"No\n" +
"\n" +
"# Proposed Work Locations\n" +
"\n" +
"MAP OF PROPOSED WORK LOCATIONS *\n" +
"\n" +
"![](https://cdn-mineru.openxlab.org.cn/result/2025-10-29/749571bc-546a-49c9-a42b-deb9e5c924ce/77c73c104a853bbb2a62ac64dece4506ee48c85ed4c4d67d64aa5f5aad26bb66.jpg)\n" +
"\n" +
"Select Work Areas\n" +
"\n" +
"INDOOR ZONES\n" +
"\n" +
"Terminal 1/7/06,10\n" +
"\n" +
"LOCATION DESCRIPTION *\n" +
"\n" +
"South Departure Immigration Hall Zone10\n" +
"\n" +
"North Departure Immigration Hall Zone 06\n" +
"\n" +
"AREAS*\n" +
"\n" +
"AIRFIELD AREA \n" +
"TERMINAL (NON-RESTRICTED AREA) \n" +
"CARRIAGEWAY\n" +
"\n" +
"LANDSIDE AREA \n" +
"LANDSCAPE \n" +
"BAGGAGE HALL\n" +
"\n" +
"TERMINAL (RESTRICTED AREA) \n" +
"FOOTPATH \n" +
"APM AREA\n" +
"\n" +
"# High Risk Activities\n" +
"\n" +
"INVOLVED HIGH RISK ACTIVITIES\n" +
"\n" +
"Yes\n" +
"\n" +
"No\n" +
"\n" +
"ELECTRICAL HAZARD WORK \n" +
"HANDLING OF HAZARDOUS SUBSTANCES \n" +
"WORK IN CONFINED SPACE\n" +
"\n" +
"EXCAVATION WORK \n" +
"HOT WORK \n" +
"WORKING AT HEIGHT\n" +
"\n" +
"FIRE ISOLATION \n" +
"ROAD WORK AT 80KM/H SPEED LIMIT \n" +
"OTHERS\n" +
"\n" +
"PLEASE SPECIFY *\n" +
"\n" +
"Exposure to X-ray\n" +
"\n" +
"# Fire Warden\n" +
"\n" +
"NAME OF FIRE WARDEN\n" +
"\n" +
"MOBILE NO.\n" +
"\n" +
"# System Change Request\n" +
"\n" +
"INVOLVED SYSTEM CHANGE\n" +
"\n" +
"Yes \n" +
"No\n" +
"\n" +
"# Document Submission\n" +
"\n" +
"1. WORK PROGRAMME *\n" +
"\n" +
"1. Work Programme - Work Programme for L7DIH Phase 2b.pdf\n" +
"\n" +
"Delete\n" +
"\n" +
"2. SAFETY ORGANISATION CHART\n" +
"\n" +
"Choose File No file chosen\n" +
"\n" +
"3. RISK ASSESSMENT\n" +
"\n" +
"Choose File No file chosen\n" +
"\n" +
"4. TEMPORARY TRAFFIC MANAGEMENT PLAN\n" +
"\n" +
"Choose File No file chosen\n" +
"\n" +
"5. OTHER RELATED DOCUMENTS\n" +
"\n" +
"Choose File No file chosen";
System.out.println(MD2Json.md2json(md));
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment