refactor(pdf-extract): 移除旧pdfInfo字段,改用独立pdf属性存储位置信息
- 在PositionedTextStripper中添加elements字段的Getter以便外部访问 - 删除QmsInspectionStandard相关类中旧的pdfInfo字段及相关JSON序列化逻辑 - 新增QmsInspectionStandardItemContent、VO、QO类中pdfPageNum、pdfX、pdfY、pdfWidth和pdfHeight属性 - 在QmsInspectionStandardControllerService和QmsInspectionStandardItemControllerService中调整属性赋值逻辑,改用新字段替代pdfInfo - 优化部分代码导入,移除未使用的JSONUtil和TextPosition引用
This commit is contained in:
parent
f74139ff61
commit
ba571b994c
|
|
@ -4,7 +4,6 @@ import jakarta.validation.Valid;
|
||||||
import jakarta.validation.constraints.NotBlank;
|
import jakarta.validation.constraints.NotBlank;
|
||||||
import jakarta.validation.constraints.NotNull;
|
import jakarta.validation.constraints.NotNull;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import model.TextPosition;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
@ -147,7 +146,7 @@ public class QmsInspectionStandardSaveQO {
|
||||||
/**
|
/**
|
||||||
* 排序号
|
* 排序号
|
||||||
*/
|
*/
|
||||||
private Integer sortNo=0;
|
private Integer sortNo = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 检测项名称
|
* 检测项名称
|
||||||
|
|
@ -165,15 +164,35 @@ public class QmsInspectionStandardSaveQO {
|
||||||
*/
|
*/
|
||||||
private String legend;
|
private String legend;
|
||||||
|
|
||||||
/**
|
|
||||||
* PDF信息
|
|
||||||
*/
|
|
||||||
private TextPosition pdfInfo;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 判定类型,0:直接判定;1:测量值
|
* 判定类型,0:直接判定;1:测量值
|
||||||
*/
|
*/
|
||||||
@NotNull(message = "判定类型不能为空")
|
@NotNull(message = "判定类型不能为空")
|
||||||
private Integer judgmentType;
|
private Integer judgmentType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PDF页码
|
||||||
|
*/
|
||||||
|
private Integer pdfPageNum;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PDF x轴起始位置
|
||||||
|
*/
|
||||||
|
private Float pdfX;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PDF y轴起始位置
|
||||||
|
*/
|
||||||
|
private Float pdfY;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PDF宽度
|
||||||
|
*/
|
||||||
|
private Float pdfWidth;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PDF高度
|
||||||
|
*/
|
||||||
|
private Float pdfHeight;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
package com.nflg.qms.admin.pojo.vo;
|
package com.nflg.qms.admin.pojo.vo;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import model.TextPosition;
|
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
|
@ -36,16 +35,36 @@ public class QmsInspectionStandardItemContentVO {
|
||||||
*/
|
*/
|
||||||
private String legend;
|
private String legend;
|
||||||
|
|
||||||
/**
|
|
||||||
* PDF信息
|
|
||||||
*/
|
|
||||||
private TextPosition pdfInfo;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 判定类型,0:直接判定;1:测量值
|
* 判定类型,0:直接判定;1:测量值
|
||||||
*/
|
*/
|
||||||
private Integer judgmentType;
|
private Integer judgmentType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PDF页码
|
||||||
|
*/
|
||||||
|
private Integer pdfPageNum;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PDF x轴起始位置
|
||||||
|
*/
|
||||||
|
private Float pdfX;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PDF y轴起始位置
|
||||||
|
*/
|
||||||
|
private Float pdfY;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PDF宽度
|
||||||
|
*/
|
||||||
|
private Float pdfWidth;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PDF高度
|
||||||
|
*/
|
||||||
|
private Float pdfHeight;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建人姓名
|
* 创建人姓名
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@ package com.nflg.qms.admin.service;
|
||||||
import cn.hutool.core.collection.CollectionUtil;
|
import cn.hutool.core.collection.CollectionUtil;
|
||||||
import cn.hutool.core.convert.Convert;
|
import cn.hutool.core.convert.Convert;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.hutool.json.JSONUtil;
|
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.nflg.qms.admin.pojo.qo.QmsPdfExtractRegionQO;
|
import com.nflg.qms.admin.pojo.qo.QmsPdfExtractRegionQO;
|
||||||
|
|
@ -26,7 +25,6 @@ import com.nflg.wms.repository.service.*;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import model.DimensionResult;
|
import model.DimensionResult;
|
||||||
import model.TextPosition;
|
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import service.PdfExtractionService;
|
import service.PdfExtractionService;
|
||||||
|
|
@ -304,9 +302,11 @@ public class QmsInspectionStandardControllerService {
|
||||||
vo.setName(content.getName());
|
vo.setName(content.getName());
|
||||||
vo.setTestStandard(content.getTestStandard());
|
vo.setTestStandard(content.getTestStandard());
|
||||||
vo.setLegend(content.getLegend());
|
vo.setLegend(content.getLegend());
|
||||||
if (StrUtil.isNotBlank(content.getPdfInfo())) {
|
vo.setPdfPageNum(content.getPdfPageNum());
|
||||||
vo.setPdfInfo(JSONUtil.toBean(content.getPdfInfo(), TextPosition.class));
|
vo.setPdfX(content.getPdfX());
|
||||||
}
|
vo.setPdfY(content.getPdfY());
|
||||||
|
vo.setPdfWidth(content.getPdfWidth());
|
||||||
|
vo.setPdfHeight(content.getPdfHeight());
|
||||||
vo.setJudgmentType(content.getJudgmentType());
|
vo.setJudgmentType(content.getJudgmentType());
|
||||||
vo.setCreateUserName(content.getCreateUserName());
|
vo.setCreateUserName(content.getCreateUserName());
|
||||||
vo.setCreateTime(content.getCreateTime());
|
vo.setCreateTime(content.getCreateTime());
|
||||||
|
|
@ -681,11 +681,14 @@ public class QmsInspectionStandardControllerService {
|
||||||
if (qo.getLegend() != null) {
|
if (qo.getLegend() != null) {
|
||||||
content.setLegend(qo.getLegend());
|
content.setLegend(qo.getLegend());
|
||||||
}
|
}
|
||||||
if (qo.getPdfInfo() != null) {
|
|
||||||
content.setPdfInfo(JSONUtil.toJsonStr(qo.getPdfInfo()));
|
|
||||||
}
|
|
||||||
content.setJudgmentType(qo.getJudgmentType());
|
content.setJudgmentType(qo.getJudgmentType());
|
||||||
|
|
||||||
|
content.setPdfPageNum(qo.getPdfPageNum());
|
||||||
|
content.setPdfX(qo.getPdfX());
|
||||||
|
content.setPdfY(qo.getPdfY());
|
||||||
|
content.setPdfWidth(qo.getPdfWidth());
|
||||||
|
content.setPdfHeight(qo.getPdfHeight());
|
||||||
|
|
||||||
content.setUpdateUserId(userId);
|
content.setUpdateUserId(userId);
|
||||||
content.setUpdateUserName(userName);
|
content.setUpdateUserName(userName);
|
||||||
content.setUpdateTime(now);
|
content.setUpdateTime(now);
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,5 @@
|
||||||
package com.nflg.qms.admin.service;
|
package com.nflg.qms.admin.service;
|
||||||
|
|
||||||
import cn.hutool.core.util.StrUtil;
|
|
||||||
import cn.hutool.json.JSONUtil;
|
|
||||||
import com.nflg.wms.common.exception.NflgException;
|
import com.nflg.wms.common.exception.NflgException;
|
||||||
import com.nflg.qms.admin.pojo.vo.QmsInspectionStandardItemContentVO;
|
import com.nflg.qms.admin.pojo.vo.QmsInspectionStandardItemContentVO;
|
||||||
import com.nflg.wms.repository.entity.QmsInspectionStandardItem;
|
import com.nflg.wms.repository.entity.QmsInspectionStandardItem;
|
||||||
|
|
@ -10,7 +8,6 @@ import com.nflg.wms.repository.service.IQmsInspectionStandardItemContentService;
|
||||||
import com.nflg.wms.repository.service.IQmsInspectionStandardItemService;
|
import com.nflg.wms.repository.service.IQmsInspectionStandardItemService;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import model.TextPosition;
|
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
@ -62,9 +59,11 @@ public class QmsInspectionStandardItemControllerService {
|
||||||
vo.setName(content.getName());
|
vo.setName(content.getName());
|
||||||
vo.setTestStandard(content.getTestStandard());
|
vo.setTestStandard(content.getTestStandard());
|
||||||
vo.setLegend(content.getLegend());
|
vo.setLegend(content.getLegend());
|
||||||
if (StrUtil.isNotBlank(content.getPdfInfo())) {
|
vo.setPdfPageNum(content.getPdfPageNum());
|
||||||
vo.setPdfInfo(JSONUtil.toBean(content.getPdfInfo(), TextPosition.class));
|
vo.setPdfX(content.getPdfX());
|
||||||
}
|
vo.setPdfY(content.getPdfY());
|
||||||
|
vo.setPdfWidth(content.getPdfWidth());
|
||||||
|
vo.setPdfHeight(content.getPdfHeight());
|
||||||
vo.setJudgmentType(content.getJudgmentType());
|
vo.setJudgmentType(content.getJudgmentType());
|
||||||
vo.setCreateUserName(content.getCreateUserName());
|
vo.setCreateUserName(content.getCreateUserName());
|
||||||
vo.setCreateTime(content.getCreateTime());
|
vo.setCreateTime(content.getCreateTime());
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
package extraction;
|
package extraction;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
import model.TextElement;
|
import model.TextElement;
|
||||||
import org.apache.pdfbox.pdmodel.PDPage;
|
import org.apache.pdfbox.pdmodel.PDPage;
|
||||||
import org.apache.pdfbox.pdmodel.common.PDRectangle;
|
import org.apache.pdfbox.pdmodel.common.PDRectangle;
|
||||||
|
|
@ -11,6 +12,7 @@ import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class PositionedTextStripper extends PDFTextStripper {
|
public class PositionedTextStripper extends PDFTextStripper {
|
||||||
|
@Getter
|
||||||
private final List<TextElement> elements = new ArrayList<>();
|
private final List<TextElement> elements = new ArrayList<>();
|
||||||
private int currentPage = 0;
|
private int currentPage = 0;
|
||||||
private float currentPageWidth = 0;
|
private float currentPageWidth = 0;
|
||||||
|
|
@ -53,7 +55,4 @@ public class PositionedTextStripper extends PDFTextStripper {
|
||||||
super.writeString(text, textPositions);
|
super.writeString(text, textPositions);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<TextElement> getElements() {
|
|
||||||
return elements;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,47 +0,0 @@
|
||||||
package model;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public class TextPosition {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 页码
|
|
||||||
*/
|
|
||||||
private int pageNum;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* x轴起始位置
|
|
||||||
*/
|
|
||||||
private float x;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* y轴起始位置
|
|
||||||
*/
|
|
||||||
private float y;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 宽度
|
|
||||||
*/
|
|
||||||
private float width;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 高度
|
|
||||||
*/
|
|
||||||
private float height;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 页宽
|
|
||||||
*/
|
|
||||||
private float pageWidth;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 页高
|
|
||||||
*/
|
|
||||||
private float pageHeight;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 序号
|
|
||||||
*/
|
|
||||||
private int sortOrder;
|
|
||||||
}
|
|
||||||
|
|
@ -51,16 +51,36 @@ public class QmsInspectionStandardItemContent implements Serializable {
|
||||||
*/
|
*/
|
||||||
private String legend;
|
private String legend;
|
||||||
|
|
||||||
/**
|
|
||||||
* PDF信息
|
|
||||||
*/
|
|
||||||
private String pdfInfo;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 判定类型,0:直接判定;1:测量值
|
* 判定类型,0:直接判定;1:测量值
|
||||||
*/
|
*/
|
||||||
private Integer judgmentType;
|
private Integer judgmentType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PDF页码
|
||||||
|
*/
|
||||||
|
private Integer pdfPageNum;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PDF x轴起始位置
|
||||||
|
*/
|
||||||
|
private Float pdfX;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PDF y轴起始位置
|
||||||
|
*/
|
||||||
|
private Float pdfY;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PDF宽度
|
||||||
|
*/
|
||||||
|
private Float pdfWidth;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PDF高度
|
||||||
|
*/
|
||||||
|
private Float pdfHeight;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建人ID
|
* 创建人ID
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue