出差新增检索
This commit is contained in:
@@ -40,6 +40,11 @@ public class HrmSealReqController extends BaseController {
|
||||
return R.ok(service.queryById(bizId));
|
||||
}
|
||||
|
||||
@GetMapping("/{bizId}/pdfPages")
|
||||
public R<Integer> pdfPages(@PathVariable @NotNull Long bizId) {
|
||||
return R.ok(service.queryPdfPageTotal(bizId));
|
||||
}
|
||||
|
||||
@Log(title = "用印申请", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public R<HrmSealReqVo> add(@Validated @RequestBody HrmSealReqBo bo) {
|
||||
|
||||
@@ -7,7 +7,6 @@ import com.ruoyi.common.core.domain.BaseEntity;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 用印申请
|
||||
@@ -15,7 +14,7 @@ import java.io.Serializable;
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName("hrm_seal_req")
|
||||
public class HrmSealReq extends BaseEntity implements Serializable {
|
||||
public class HrmSealReq extends BaseEntity {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@@ -29,7 +28,7 @@ public class HrmSealReq extends BaseEntity implements Serializable {
|
||||
/** 项目ID */
|
||||
private Long projectId;
|
||||
|
||||
/** 用印类型(公章/合同章/财务章等) */
|
||||
/** 用印类型(对应印章文件名) */
|
||||
private String sealType;
|
||||
|
||||
/** 用途说明 */
|
||||
|
||||
@@ -24,7 +24,7 @@ public class HrmSealReqBo extends BaseEntity {
|
||||
/** 项目ID */
|
||||
private Long projectId;
|
||||
|
||||
/** 用印类型 */
|
||||
/** 用印类型(对应印章文件名) */
|
||||
@NotBlank(message = "用印类型不能为空")
|
||||
private String sealType;
|
||||
|
||||
|
||||
@@ -88,6 +88,9 @@ public class HrmSealReqVo implements Serializable {
|
||||
@Excel(name = "回执附件ID列表")
|
||||
private String receiptFileIds;
|
||||
|
||||
@Excel(name = "PDF页数")
|
||||
private Integer pdfPageTotal;
|
||||
|
||||
@Excel(name = "状态")
|
||||
private String status;
|
||||
|
||||
|
||||
@@ -13,6 +13,8 @@ public interface IHrmSealReqService {
|
||||
|
||||
HrmSealReqVo queryById(Long bizId);
|
||||
|
||||
Integer queryPdfPageTotal(Long bizId);
|
||||
|
||||
TableDataInfo<HrmSealReqVo> queryPageList(HrmSealReqBo bo, PageQuery pageQuery);
|
||||
|
||||
List<HrmSealReqVo> queryList(HrmSealReqBo bo);
|
||||
|
||||
@@ -21,6 +21,8 @@ import com.ruoyi.hrm.service.IHrmSealReqService;
|
||||
import com.ruoyi.oss.core.OssClient;
|
||||
import com.ruoyi.oss.entity.UploadResult;
|
||||
import com.ruoyi.oss.factory.OssFactory;
|
||||
import com.ruoyi.system.domain.vo.SysOssVo;
|
||||
import com.ruoyi.system.mapper.SysOssMapper;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.pdfbox.pdmodel.PDDocument;
|
||||
@@ -28,7 +30,6 @@ import org.apache.pdfbox.pdmodel.PDPage;
|
||||
import org.apache.pdfbox.pdmodel.PDPageContentStream;
|
||||
import org.apache.pdfbox.pdmodel.common.PDRectangle;
|
||||
import org.apache.pdfbox.pdmodel.graphics.image.PDImageXObject;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@@ -48,10 +49,59 @@ public class HrmSealReqServiceImpl implements IHrmSealReqService {
|
||||
private final HrmSealReqMapper baseMapper;
|
||||
private final StampProperties stampProperties;
|
||||
private final IHrmFlowInstanceService flowInstanceService;
|
||||
private final SysOssMapper sysOssMapper;
|
||||
|
||||
@Override
|
||||
public HrmSealReqVo queryById(Long bizId) {
|
||||
return baseMapper.selectVoWithProjectById(bizId);
|
||||
HrmSealReqVo vo = baseMapper.selectVoWithProjectById(bizId);
|
||||
if (vo != null) {
|
||||
vo.setPdfPageTotal(queryPdfPageTotal(bizId));
|
||||
}
|
||||
return vo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer queryPdfPageTotal(Long bizId) {
|
||||
HrmSealReqVo vo = baseMapper.selectVoWithProjectById(bizId);
|
||||
String applyFileIds = vo != null ? vo.getApplyFileIds() : null;
|
||||
if (applyFileIds == null || applyFileIds.trim().isEmpty()) {
|
||||
return 0;
|
||||
}
|
||||
String firstFileId = applyFileIds.split(",")[0].trim();
|
||||
if (firstFileId.isEmpty()) {
|
||||
return 0;
|
||||
}
|
||||
String fileUrl = resolveSealPdfUrl(firstFileId);
|
||||
if (fileUrl == null || fileUrl.trim().isEmpty()) {
|
||||
return 0;
|
||||
}
|
||||
try (InputStream inputStream = getObject(fileUrl); PDDocument document = PDDocument.load(inputStream)) {
|
||||
return document.getNumberOfPages();
|
||||
} catch (Exception e) {
|
||||
log.warn("查询用印PDF页数失败 bizId={}, fileId={}, fileUrl={}", bizId, firstFileId, fileUrl, e);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
private String resolveObjectKey(String fileRef) {
|
||||
if (fileRef == null) {
|
||||
return null;
|
||||
}
|
||||
String ref = fileRef.trim();
|
||||
if (ref.isEmpty()) {
|
||||
return ref;
|
||||
}
|
||||
if (ref.startsWith("http://") || ref.startsWith("https://")) {
|
||||
int idx = ref.indexOf("/files/");
|
||||
if (idx >= 0) {
|
||||
return ref.substring(idx + "/files/".length());
|
||||
}
|
||||
idx = ref.indexOf("/files%2F");
|
||||
if (idx >= 0) {
|
||||
return ref.substring(idx + "/files%2F".length());
|
||||
}
|
||||
}
|
||||
return ref;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -269,6 +319,17 @@ public class HrmSealReqServiceImpl implements IHrmSealReqService {
|
||||
}
|
||||
}
|
||||
|
||||
private String resolveSealPdfUrl(String ossIdText) {
|
||||
try {
|
||||
Long ossId = Long.valueOf(ossIdText);
|
||||
SysOssVo sysOss = sysOssMapper.selectVoById(ossId);
|
||||
return sysOss != null ? sysOss.getUrl() : null;
|
||||
} catch (Exception e) {
|
||||
log.warn("解析用印PDF文件地址失败 ossIdText={}", ossIdText, e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private InputStream getObject(String url) {
|
||||
OssClient storage = OssFactory.instance();
|
||||
return storage.getObjectContent(url);
|
||||
|
||||
Reference in New Issue
Block a user