From 08be30bda841df3af65428547186513a3d7b1f42 Mon Sep 17 00:00:00 2001
From: liding <756868258@qq.com>
Date: 星期二, 27 十月 2026 17:47:56 +0800
Subject: [PATCH] feat(report): 完善报告退回流程及新增 PDF 预览功能 - 新增退回到报告审核环节,支持退回至检验任务或报告审核两种目标
---
inspect-server/src/main/java/com/ruoyi/inspect/service/impl/SealUsageLedgerServiceImpl.java | 7
inspect-server/src/main/java/com/ruoyi/inspect/vo/InsOrderPlanVO.java | 3
inspect-server/src/main/resources/mapper/InsSampleMapper.xml | 8
inspect-server/src/main/java/com/ruoyi/inspect/pojo/InsReportReturnRecord.java | 70 ++++++
inspect-server/src/main/java/com/ruoyi/inspect/mapper/InsReportReturnRecordMapper.java | 7
inspect-server/src/main/java/com/ruoyi/inspect/controller/InsReportController.java | 21 +
inspect-server/src/main/resources/mapper/InsOrderRatesMapper.xml | 3
inspect-server/src/main/java/com/ruoyi/inspect/util/ReportSealLayoutUtil.java | 178 +++++++++++++++
inspect-server/src/main/java/com/ruoyi/inspect/service/InsReportService.java | 10
inspect-server/src/main/resources/mapper/InsReportMapper.xml | 12
inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsReportServiceImpl.java | 316 ++++++++++++++++++++++++++--
inspect-server/src/main/java/com/ruoyi/inspect/pojo/InsReport.java | 10
inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsOrderPlanServiceImpl.java | 6
13 files changed, 597 insertions(+), 54 deletions(-)
diff --git a/inspect-server/src/main/java/com/ruoyi/inspect/controller/InsReportController.java b/inspect-server/src/main/java/com/ruoyi/inspect/controller/InsReportController.java
index f204673..15dc7bc 100644
--- a/inspect-server/src/main/java/com/ruoyi/inspect/controller/InsReportController.java
+++ b/inspect-server/src/main/java/com/ruoyi/inspect/controller/InsReportController.java
@@ -167,6 +167,14 @@
insReportService.download(id, reportType, reportPageDto.getCreateOrderUser(), response);
}
+ @Operation(summary = "鎸� Word 鍘熷鍒嗛〉鎺掔増棰勮鎶ュ憡 PDF")
+ @GetMapping("/preview")
+ @PreAuthorize("@ss.hasPermi('business:reportPreparation')")
+ @PersonalScope(permsName = "business:reportPreparation", objectName = ReportPageDto.class, paramName = "createOrderUser")
+ public void preview(Integer id, Integer reportType, ReportPageDto reportPageDto, HttpServletResponse response) {
+ insReportService.preview(id, reportType, reportPageDto.getCreateOrderUser(), response);
+ }
+
@Operation(summary = "閲嶆柊鐢熸垚鎶ュ憡")
@PostMapping("/regenerate")
// @PreAuthorize("@ss.hasPermi('business:reportPreparation')")
@@ -182,16 +190,13 @@
return Result.success(insReportService.upAll(file));
}
- /**
- * 閫�鍥炲埌妫�楠屼换鍔�
- * @param id
- * @return
- */
- @Operation(summary = "閫�鍥炲埌妫�楠屼换鍔�")
+ @Operation(summary = "閫�鍥炲埌妫�楠屼换鍔℃垨鎶ュ憡瀹℃牳")
@PostMapping("/sendBackTask")
public Result sendBackTask(@RequestBody Map<String, Object> param){
- Integer id = (Integer) param.get("id");
- return Result.success(insReportService.sendBackTask(id));
+ Integer id = toInteger(param.get("id"));
+ String target = param.get("target") == null ? null : String.valueOf(param.get("target"));
+ String reason = param.get("reason") == null ? null : String.valueOf(param.get("reason"));
+ return Result.success(insReportService.sendBackTask(id, target, reason));
}
/**
diff --git a/inspect-server/src/main/java/com/ruoyi/inspect/mapper/InsReportReturnRecordMapper.java b/inspect-server/src/main/java/com/ruoyi/inspect/mapper/InsReportReturnRecordMapper.java
new file mode 100644
index 0000000..18c8e9c
--- /dev/null
+++ b/inspect-server/src/main/java/com/ruoyi/inspect/mapper/InsReportReturnRecordMapper.java
@@ -0,0 +1,7 @@
+package com.ruoyi.inspect.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.ruoyi.inspect.pojo.InsReportReturnRecord;
+
+public interface InsReportReturnRecordMapper extends BaseMapper<InsReportReturnRecord> {
+}
diff --git a/inspect-server/src/main/java/com/ruoyi/inspect/pojo/InsReport.java b/inspect-server/src/main/java/com/ruoyi/inspect/pojo/InsReport.java
index 91c3e88..b2673d4 100644
--- a/inspect-server/src/main/java/com/ruoyi/inspect/pojo/InsReport.java
+++ b/inspect-server/src/main/java/com/ruoyi/inspect/pojo/InsReport.java
@@ -48,6 +48,12 @@
@Schema(description = "妫�楠屾姤鍛婂湴鍧�")
private String inspectionUrl;
+ @Schema(description = "鎵瑰噯鍓嶇殑妫�娴嬫姤鍛婂鏍哥鍦板潃")
+ private String reviewUrl;
+
+ @Schema(description = "鎵瑰噯鍓嶇殑妫�楠屾姤鍛婂鏍哥鍦板潃")
+ private String reviewInspectionUrl;
+
/**
* 鎵嬪姩涓婁紶鎶ュ憡鍦板潃
*/
@@ -65,7 +71,7 @@
private String inspectionTempUrlPdf;
/**
- * 1锛氭壒鍑� 0锛氫笉鎵瑰噯
+ * 1锛氭壒鍑� 0锛氫笉鎵瑰噯 2锛氬凡閫�鍥�
*/
@Schema(description = "鎵瑰噯鐘舵��")
private Integer isRatify;
@@ -74,7 +80,7 @@
private String ratifyTell;
/**
- * 1锛氬鏍搁�氳繃 0锛氬鏍镐笉閫氳繃
+ * 1锛氬鏍搁�氳繃 0锛氬鏍镐笉閫氳繃 2锛氬凡閫�鍥�
*/
@Schema(description = "瀹℃牳鐘舵��")
private Integer isExamine;
diff --git a/inspect-server/src/main/java/com/ruoyi/inspect/pojo/InsReportReturnRecord.java b/inspect-server/src/main/java/com/ruoyi/inspect/pojo/InsReportReturnRecord.java
new file mode 100644
index 0000000..6c058b4
--- /dev/null
+++ b/inspect-server/src/main/java/com/ruoyi/inspect/pojo/InsReportReturnRecord.java
@@ -0,0 +1,70 @@
+package com.ruoyi.inspect.pojo;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.time.LocalDateTime;
+
+/**
+ * 鎶ュ憡閫�鍥炲墠鐨勫鎵圭姸鎬佸拰鏂囦欢蹇収锛岀敤浜庤拷婧巻鍙叉壒鍑嗙増鏈��
+ */
+@Data
+@TableName("ins_report_return_record")
+@Schema(description = "鎶ュ憡閫�鍥炶褰�")
+public class InsReportReturnRecord implements Serializable {
+ @Schema(description = "涓婚敭")
+ @TableId(type = IdType.AUTO)
+ private Long id;
+
+ @Schema(description = "鎶ュ憡ID")
+ private Integer reportId;
+
+ @Schema(description = "妫�楠屽崟ID")
+ private Integer insOrderId;
+
+ @Schema(description = "閫�鍥炲墠鑺傜偣锛欰PPROVED 宸叉壒鍑嗭紝REPORT_REVIEW 鎶ュ憡瀹℃牳锛孯EPORT_APPROVAL 鎶ュ憡鎵瑰噯")
+ private String fromStage;
+
+ @Schema(description = "鐩爣鑺傜偣锛欼NSPECTION_TASK 妫�楠屼换鍔★紝REPORT_REVIEW 鎶ュ憡瀹℃牳")
+ private String targetStage;
+
+ @Schema(description = "閫�鍥炲師鍥�")
+ private String returnReason;
+
+ @Schema(description = "閫�鍥炲墠鎻愪氦鐘舵�侊細0 寰呮彁浜わ紝1 宸叉彁浜�")
+ private Integer state;
+
+ @Schema(description = "閫�鍥炲墠瀹℃牳鐘舵�侊細0 涓嶉�氳繃锛�1 閫氳繃锛�2 宸查��鍥�")
+ private Integer isExamine;
+
+ @Schema(description = "閫�鍥炲墠瀹℃牳鏃堕棿")
+ private LocalDateTime examineTime;
+
+ @Schema(description = "閫�鍥炲墠鎵瑰噯鐘舵�侊細0 涓嶆壒鍑嗭紝1 鎵瑰噯锛�2 宸查��鍥�")
+ private Integer isRatify;
+
+ @Schema(description = "閫�鍥炲墠鎵瑰噯鏃堕棿")
+ private LocalDateTime ratifyTime;
+
+ @Schema(description = "閫�鍥炲墠妫�娴嬫姤鍛婃枃浠跺湴鍧�")
+ private String reportUrl;
+
+ @Schema(description = "閫�鍥炲墠妫�楠屾姤鍛婃枃浠跺湴鍧�")
+ private String inspectionUrl;
+
+ @Schema(description = "閫�鍥炲墠妫�娴嬫姤鍛婁复鏃堕瑙堝湴鍧�")
+ private String tempUrlPdf;
+
+ @Schema(description = "閫�鍥炲墠妫�楠屾姤鍛婁复鏃堕瑙堝湴鍧�")
+ private String inspectionTempUrlPdf;
+
+ @Schema(description = "閫�鍥炴搷浣滀汉鐢ㄦ埛ID")
+ private Integer operatorId;
+
+ @Schema(description = "閫�鍥炶褰曞垱寤烘椂闂�")
+ private LocalDateTime createTime;
+}
diff --git a/inspect-server/src/main/java/com/ruoyi/inspect/service/InsReportService.java b/inspect-server/src/main/java/com/ruoyi/inspect/service/InsReportService.java
index 13a6cd9..ba2edc1 100644
--- a/inspect-server/src/main/java/com/ruoyi/inspect/service/InsReportService.java
+++ b/inspect-server/src/main/java/com/ruoyi/inspect/service/InsReportService.java
@@ -50,6 +50,9 @@
*/
void download(Integer id, Integer reportType, Integer createOrderUser, HttpServletResponse response);
+ /** 涓� Word 涓嬭浇鐩稿悓鐨勬暟鎹寖鍥达紝浣跨敤鍥哄畾鍒嗛〉鐨� PDF 淇濈暀鎶ュ憡鐗堝紡銆� */
+ void preview(Integer id, Integer reportType, Integer createOrderUser, HttpServletResponse response);
+
int upAll(MultipartFile file) throws IOException;
/**
@@ -63,11 +66,10 @@
Long getUnqualifiedCount(InsOrder insOrder);
/**
- * 閫�鍥炲埌妫�楠屼换鍔�
- * @param id
- * @return
+ * 閫�鍥炴姤鍛婃祦绋嬨��
+ * target锛欼NSPECTION_TASK 閫�鍥炴楠屼换鍔★紱REPORT_REVIEW 閫�鍥炴姤鍛婂鏍搞��
*/
- boolean sendBackTask(Integer id);
+ boolean sendBackTask(Integer id, String target, String reason);
/**
* 鎶ュ憡瀵煎嚭
diff --git a/inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsOrderPlanServiceImpl.java b/inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsOrderPlanServiceImpl.java
index 39a0061..74f8661 100644
--- a/inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsOrderPlanServiceImpl.java
+++ b/inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsOrderPlanServiceImpl.java
@@ -1856,11 +1856,13 @@
}
// 妫�楠屼汉鍛樻彁浜ゅ鏍告椂涓嶇敓鎴愭姤鍛婏紱鍏ㄩ儴璇曢獙瀹ゅ鏍搁�氳繃鍚庣敓鎴愭姤鍛娿��
- if (report == null || StringUtils.isBlank(report.getUrl())) {
+ boolean returnedFromReport = report != null && Objects.equals(report.getIsPass(), 0);
+ if (report == null || StringUtils.isBlank(report.getUrl()) || returnedFromReport) {
this.generateReport(orderId, DETECTION_REPORT, writeUserId);
}
// 鐩寸粦妯℃澘璁㈠崟鍚屾椂鐢熸垚妫�楠屾姤鍛婏紝涓や唤鏂囦欢鍏辩敤鍚屼竴鏉″鎵硅褰曘��
- if (directTemplateOrder && (report == null || StringUtils.isBlank(report.getInspectionUrl()))) {
+ if (directTemplateOrder && (report == null || StringUtils.isBlank(report.getInspectionUrl())
+ || returnedFromReport)) {
this.generateReport(orderId, INSPECTION_REPORT, writeUserId);
}
report = insReportMapper.selectOne(Wrappers.<InsReport>lambdaQuery()
diff --git a/inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsReportServiceImpl.java b/inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsReportServiceImpl.java
index 14df655..b7cfbbc 100644
--- a/inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsReportServiceImpl.java
+++ b/inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsReportServiceImpl.java
@@ -35,6 +35,7 @@
import com.ruoyi.common.constant.InsOrderTypeConstants;
import com.ruoyi.common.constant.MenuJumpPathConstants;
import com.ruoyi.common.core.domain.Result;
+import com.ruoyi.common.core.domain.entity.User;
import com.ruoyi.common.core.domain.entity.SysMenu;
import com.ruoyi.common.core.domain.entity.InformationNotification;
import com.ruoyi.common.utils.DateImageUtil;
@@ -103,11 +104,18 @@
private static final int DETECTION_REPORT = 0;
private static final int INSPECTION_REPORT = 1;
+ private static final String RETURN_TO_INSPECTION_TASK = "INSPECTION_TASK";
+ private static final String RETURN_TO_REPORT_REVIEW = "REPORT_REVIEW";
+ private static final int RETURNED_STATUS = 2;
@Resource
private UserMapper userMapper;
@Resource
private InsReportMapper insReportMapper;
+ @Resource
+ private InsReportEditSessionMapper insReportEditSessionMapper;
+ @Resource
+ private InsReportReturnRecordMapper insReportReturnRecordMapper;
@Resource
private SealUsageLedgerService sealUsageLedgerService;
@Resource
@@ -446,6 +454,9 @@
if (Objects.equals(insReport.getIsRatify(), 1)) {
throw new ErrorException("鎶ュ憡宸叉壒鍑嗭紝璇峰嬁閲嶅鎿嶄綔");
}
+ if (!Objects.equals(insReport.getState(), 1) || !Objects.equals(insReport.getIsExamine(), 1)) {
+ throw new ErrorException("鎶ュ憡灏氭湭瀹℃牳閫氳繃锛屼笉鑳芥壒鍑�");
+ }
if (Objects.equals(insReport.getExamineUserId(), SecurityUtils.getUserId().intValue())) {
throw new ErrorException("瀹℃牳浜哄拰鎵瑰噯浜轰笉鑳戒负鍚屼竴浜猴紝璇烽噸鏂伴�夋嫨鎵瑰噯浜�");
}
@@ -499,10 +510,21 @@
}
});
- //濡傛灉鎵瑰噯涓嶉�氳繃 鐩存帴閫�鍥炲埌鎻愪氦浜洪偅杈瑰幓
- insReport.setState(0);
- insReport.setIsExamine(0);
- return insReportMapper.updateById(insReport);
+ // 鎵瑰噯涓嶉�氳繃鐩存帴閫�鍥炴姤鍛婂鏍革紝鐢卞師瀹℃牳浜轰慨鏀瑰悗閲嶆柊瀹℃牳銆佹壒鍑嗐��
+ recordReportReturn(insReport, "REPORT_APPROVAL", RETURN_TO_REPORT_REVIEW,
+ StringUtils.isBlank(ratifyTell) ? "鎵瑰噯涓嶉�氳繃" : ratifyTell, insReport.getRatifyTime());
+ insReport.setState(1);
+ insReport.setExamineTell(ratifyTell);
+ int affected = insReportMapper.updateById(insReport);
+ if (affected != 1) {
+ throw new ErrorException("鎶ュ憡閫�鍥炲鏍稿け璐�");
+ }
+ insReportMapper.update(null, Wrappers.<InsReport>lambdaUpdate()
+ .eq(InsReport::getId, id)
+ .set(InsReport::getIsExamine, RETURNED_STATUS)
+ .set(InsReport::getExamineTime, insReport.getRatifyTime()));
+ expireReportEditSessions(id);
+ return affected;
}
//鑾峰彇鎵瑰噯浜虹殑绛惧悕鍦板潃
String signatureUrl;
@@ -552,6 +574,7 @@
insReport.setReportSealName(reportSeal == null ? null : reportSeal.getName());
insReport.setSeamSealId(seamSeal == null ? null : seamSeal.getId());
insReport.setSeamSealName(seamSeal == null ? null : seamSeal.getName());
+ prepareApprovalCopies(insReport);
String primaryReportUrl = getPrimaryReportUrl(insReport);
String finalUrl = primaryReportUrl.replace("/word", wordUrl);
@@ -740,6 +763,37 @@
.collect(Collectors.toList());
}
+ /** 鎵瑰噯绔犲彧鍐欏叆鍓湰锛屼繚鐣欐棤鎵瑰噯绔犵殑瀹℃牳绋跨敤浜庢壒鍑嗗悗閫�鍥炰慨鏀广�� */
+ private void prepareApprovalCopies(InsReport report) {
+ String primarySource = getPrimaryReportUrl(report);
+ String inspectionSource = report.getInspectionUrl();
+ report.setReviewUrl(primarySource);
+ report.setReviewInspectionUrl(inspectionSource);
+ report.setUrlS(copyReportForApproval(primarySource));
+ if (StringUtils.isNotBlank(inspectionSource)) {
+ report.setInspectionUrl(copyReportForApproval(inspectionSource));
+ }
+ }
+
+ private String copyReportForApproval(String sourceUrl) {
+ try {
+ Path source = Paths.get(sourceUrl.replace("/word", wordUrl));
+ if (!Files.exists(source)) {
+ throw new ErrorException("寰呮壒鍑嗘姤鍛婃枃浠朵笉瀛樺湪");
+ }
+ String fileName = "approved-" + UUID.randomUUID() + ".docx";
+ Path target = Paths.get(wordUrl, fileName);
+ Files.createDirectories(target.getParent());
+ Files.copy(source, target, StandardCopyOption.REPLACE_EXISTING);
+ return "/word/" + fileName;
+ } catch (ErrorException e) {
+ throw e;
+ } catch (Exception e) {
+ log.error("鍒涘缓鎶ュ憡鎵瑰噯鍓湰澶辫触: {}", sourceUrl, e);
+ throw new ErrorException("鍒涘缓鎶ュ憡鎵瑰噯鍓湰澶辫触");
+ }
+ }
+
private void refreshTemporaryPreviews(InsReport report) {
String primaryPdf = wordToPdfTemp(getPrimaryReportUrl(report).replace("/word", wordUrl));
if (StringUtils.isBlank(primaryPdf)) {
@@ -865,6 +919,82 @@
log.error("涓嬭浇鎶ュ憡澶辫触锛宺eportId={}", id, e);
throw new ErrorException("鎶ュ憡涓嬭浇澶辫触");
}
+ }
+
+ @Override
+ public void preview(Integer id, Integer reportType, Integer createOrderUser, HttpServletResponse response) {
+ int type = reportType == null ? DETECTION_REPORT : reportType;
+ if (id == null || (type != DETECTION_REPORT && type != INSPECTION_REPORT)) {
+ throw new ErrorException("鎶ュ憡鎴栨姤鍛婄被鍨嬩笉姝g‘");
+ }
+ InsReport report = insReportMapper.selectDownloadableReport(id, createOrderUser);
+ if (report == null) {
+ throw new ErrorException("鎶ュ憡涓嶅瓨鍦ㄣ�佸皻鏈敓鎴愭垨鏃犳潈鏌ョ湅");
+ }
+ String sourceUrl = type == INSPECTION_REPORT ? report.getInspectionUrl() : getPrimaryReportUrl(report);
+ if (StringUtils.isBlank(sourceUrl)) {
+ throw new ErrorException("鎶ュ憡鏂囦欢灏氭湭鐢熸垚");
+ }
+ try {
+ Path source = resolvePreviewFile(sourceUrl);
+ Path pdf;
+ if (Objects.equals(report.getIsRatify(), 1)) {
+ // 宸叉壒鍑嗘姤鍛婂繀椤讳娇鐢ㄦ壒鍑嗘椂鐢熸垚鐨� PDF锛屼繚鐣� PDF 涓撶敤鐨� MA 绔犲拰楠戠紳绔犮��
+ // inspectionTempUrlPdf 鍙兘浠嶆寚鍚戝鏍搁樁娈电殑涓存椂绋匡紝涓嶈兘浣滀负鏈夌珷鎶ュ憡杩斿洖銆�
+ pdf = resolvePreviewFile(sourceUrl.replaceFirst("(?i)\\.docx?$", ".pdf"));
+ if (pdf == null) {
+ throw new ErrorException("鏈夌珷鎶ュ憡 PDF 涓嶅瓨鍦紝璇烽噸鏂版壒鍑嗙敓鎴�");
+ }
+ } else {
+ pdf = resolvePreviewFile(type == INSPECTION_REPORT
+ ? report.getInspectionTempUrlPdf() : report.getTempUrlPdf());
+ if (source == null) throw new ErrorException("Word 鎶ュ憡鏂囦欢涓嶅瓨鍦�");
+ if (pdf == null || Files.getLastModifiedTime(pdf).compareTo(Files.getLastModifiedTime(source)) < 0) {
+ // 缂哄皯棰勮鎴� Word 鏇存柊鍚庡啀杞崲锛涘悓涓�鐗堟湰閲嶅鏌ョ湅澶嶇敤缂撳瓨锛屼笉鏀瑰鎵规暟鎹��
+ Path directory = Paths.get(wordUrl).toAbsolutePath().normalize().resolve("preview");
+ Files.createDirectories(directory);
+ String version = source + ":" + Files.size(source) + ":" + Files.getLastModifiedTime(source);
+ String name = UUID.nameUUIDFromBytes(version.getBytes(java.nio.charset.StandardCharsets.UTF_8)) + ".pdf";
+ pdf = directory.resolve(name);
+ if (!Files.isRegularFile(pdf)) {
+ Path temporary = Files.createTempFile(directory, "report-", ".pdf");
+ try {
+ if (wordToPdf(source.toString(), temporary.toString()) == null) {
+ throw new ErrorException("鎶ュ憡杞� PDF 澶辫触锛岃鑱旂郴绠$悊鍛�");
+ }
+ Files.move(temporary, pdf, StandardCopyOption.REPLACE_EXISTING);
+ } finally {
+ Files.deleteIfExists(temporary);
+ }
+ }
+ }
+ }
+ String filename = (StringUtils.isBlank(report.getCode()) ? "鎶ュ憡" : report.getCode())
+ .replaceAll("[\\\\/:*?\"<>|\\p{Cntrl}]", "-")
+ + (type == INSPECTION_REPORT ? "-妫�楠屾姤鍛�.pdf" : "-妫�娴嬫姤鍛�.pdf");
+ response.setContentType("application/pdf");
+ response.setHeader("Content-Disposition", "inline; filename*=UTF-8''"
+ + URLEncoder.encode(filename, "UTF-8").replace("+", "%20"));
+ response.setHeader("Cache-Control", "no-store");
+ response.setContentLengthLong(Files.size(pdf));
+ Files.copy(pdf, response.getOutputStream());
+ } catch (IOException e) {
+ log.error("鎶ュ憡棰勮澶辫触锛宺eportId={}", id, e);
+ throw new ErrorException("鎶ュ憡棰勮澶辫触锛岃鑱旂郴绠$悊鍛�");
+ }
+ }
+
+ /** 鍙鍙栨姤鍛婄洰褰曞唴鐨勬枃浠讹紝缂哄け鏂囦欢浜ょ敱璋冪敤鏂瑰鐞嗐�� */
+ private Path resolvePreviewFile(String url) throws IOException {
+ if (StringUtils.isBlank(url)) return null;
+ String path = url.replace('\\', '/');
+ if (!path.startsWith("/word/")) throw new ErrorException("鎶ュ憡鏂囦欢鍦板潃涓嶆纭�");
+ Path root = Paths.get(wordUrl).toAbsolutePath().normalize();
+ Path file = root.resolve(path.substring("/word/".length())).normalize();
+ if (!file.startsWith(root)) throw new ErrorException("鎶ュ憡鏂囦欢鍦板潃涓嶆纭�");
+ if (!Files.isRegularFile(file)) return null;
+ if (!file.toRealPath().startsWith(root.toRealPath())) throw new ErrorException("鎶ュ憡鏂囦欢鍦板潃涓嶆纭�");
+ return file;
}
//鎵归噺涓婁紶
@@ -1234,38 +1364,172 @@
return unqualifiedCount;
}
- /**
- * 閫�鍥炲埌妫�楠屼换鍔�
- * @param id
- * @return
- */
@Override
@Transactional(rollbackFor = Exception.class)
- public boolean sendBackTask(Integer id) {
- InsReport report = insReportMapper.selectById(id);
+ public boolean sendBackTask(Integer id, String target, String reason) {
+ if (id == null || (!RETURN_TO_INSPECTION_TASK.equals(target)
+ && !RETURN_TO_REPORT_REVIEW.equals(target))) {
+ throw new ErrorException("閫�鍥炲弬鏁颁笉姝g‘");
+ }
+ if (StringUtils.isBlank(reason)) {
+ throw new ErrorException("璇疯緭鍏ラ��鍥炲師鍥�");
+ }
+
+ InsReport report = insReportMapper.selectOne(Wrappers.<InsReport>lambdaQuery()
+ .eq(InsReport::getId, id)
+ .last("FOR UPDATE"));
if (report == null || report.getInsOrderId() == null) {
throw new ErrorException("鎶ュ憡涓嶅瓨鍦ㄦ垨鏈叧鑱旀楠屽崟");
}
-
- // 鎶ュ憡鐢辫鍗曚笅鍚勮瘯楠屽鍏卞悓褰㈡垚锛涢��鍥炴椂鍏ㄩ儴鎭㈠涓哄緟澶嶆牳锛岄伩鍏嶅彧闅忔満閫�鍥炰竴涓瘯楠屽銆�
- insOrderStateMapper.update(null, Wrappers.<InsOrderState>lambdaUpdate()
- .eq(InsOrderState::getInsOrderId, report.getInsOrderId())
- .set(InsOrderState::getInsState, 4));
-
- InsSampleUser sampleUser = insSampleUserMapper.selectOne(Wrappers.<InsSampleUser>lambdaQuery()
- .eq(InsSampleUser::getInsSampleId, report.getInsOrderId())
- .orderByDesc(InsSampleUser::getId)
- .last("limit 1"));
- if (sampleUser != null) {
- insSampleUserMapper.deleteById(sampleUser.getId());
+ if (!Objects.equals(report.getIsPass(), 1)) {
+ throw new ErrorException("鎶ュ憡宸查��鍑烘姤鍛婃祦绋嬶紝璇峰嬁閲嶅閫�鍥�");
}
- // 淇敼鎶ュ憡琛屼负鏈樉绀�
+ LocalDateTime returnTime = LocalDateTime.now();
+ recordReportReturn(report, target, reason, returnTime);
+
+ if (RETURN_TO_REPORT_REVIEW.equals(target)) {
+ if (!Objects.equals(report.getIsRatify(), 1)) {
+ throw new ErrorException("鍙湁宸叉壒鍑嗘姤鍛婂彲浠ラ��鍥炲埌鎶ュ憡瀹℃牳");
+ }
+ String reviewUrl = report.getReviewUrl();
+ String reviewInspectionUrl = report.getReviewInspectionUrl();
+ if (StringUtils.isBlank(reviewUrl)) {
+ reviewUrl = prepareLegacyApprovedReportForReview(report,
+ StringUtils.isNotBlank(report.getUrlS()) ? report.getUrlS() : report.getUrl());
+ if (StringUtils.isNotBlank(report.getInspectionUrl())) {
+ reviewInspectionUrl = prepareLegacyApprovedReportForReview(report, report.getInspectionUrl());
+ }
+ }
+ int affected = insReportMapper.update(null, Wrappers.<InsReport>lambdaUpdate()
+ .eq(InsReport::getId, id)
+ .eq(InsReport::getIsRatify, 1)
+ .set(InsReport::getState, 1)
+ .set(InsReport::getIsExamine, RETURNED_STATUS)
+ .set(InsReport::getExamineTime, returnTime)
+ .set(InsReport::getExamineTell, reason)
+ .set(InsReport::getIsRatify, RETURNED_STATUS)
+ .set(InsReport::getRatifyTime, returnTime)
+ .set(InsReport::getRatifyTell, reason)
+ .set(InsReport::getUrlS, Objects.equals(reviewUrl, report.getUrl()) ? null : reviewUrl)
+ .set(StringUtils.isNotBlank(reviewInspectionUrl), InsReport::getInspectionUrl,
+ reviewInspectionUrl)
+ .set(InsReport::getReviewUrl, null)
+ .set(InsReport::getReviewInspectionUrl, null)
+ .set(InsReport::getTempUrlPdf, null)
+ .set(InsReport::getInspectionTempUrlPdf, null));
+ if (affected != 1) {
+ throw new ErrorException("鎶ュ憡鐘舵�佸凡鍙樺寲锛岃鍒锋柊鍚庨噸璇�");
+ }
+ expireReportEditSessions(id);
+ return true;
+ }
+
+ if (!Objects.equals(report.getState(), 1) && !Objects.equals(report.getIsRatify(), 1)) {
+ throw new ErrorException("褰撳墠鎶ュ憡涓嶅湪瀹℃牳鎴栧凡鎵瑰噯鐘舵�侊紝涓嶈兘閫�鍥炴楠屼换鍔�");
+ }
+
+ InsOrder order = insOrderMapper.selectById(report.getInsOrderId());
+ if (order == null) {
+ throw new ErrorException("鎶ュ憡鍏宠仈鐨勬楠屽崟涓嶅瓨鍦�");
+ }
+ boolean hadApproval = report.getIsRatify() != null;
+
+ // 鎭㈠璁㈠崟涓荤姸鎬侊紝鍚﹀垯妫�楠屼换鍔℃煡璇㈣姹� io.state=1 鏃朵粛鏃犳硶鎵惧埌璇ヤ换鍔°��
+ insOrderMapper.update(null, Wrappers.<InsOrder>lambdaUpdate()
+ .eq(InsOrder::getId, report.getInsOrderId())
+ .set(InsOrder::getState, 1)
+ .set(InsOrder::getInsState, 4));
+
+ // 鏁翠唤鎶ュ憡鐢辫鍗曚笅鍚勮瘯楠屽鍏卞悓褰㈡垚锛岄��鍥炲悗鍚勬楠屽鍧囧洖鍒板彲淇敼銆侀噸鏂版彁浜ゅ鏍哥殑鐘舵�併��
+ insOrderStateMapper.update(null, Wrappers.<InsOrderState>lambdaUpdate()
+ .eq(InsOrderState::getInsOrderId, report.getInsOrderId())
+ .set(InsOrderState::getInsState, 4)
+ .set(InsOrderState::getVerifyUser, null)
+ .set(InsOrderState::getVerifyTell, reason));
+
+ // 鍙挙閿�澶嶆牳浜轰换鍔★紝淇濈暀鍚勬楠屽鍘熸楠屼汉锛岄伩鍏嶉��鍥炲悗浠诲姟鏃犱汉鍙銆�
+ insSampleUserMapper.delete(Wrappers.<InsSampleUser>lambdaQuery()
+ .eq(InsSampleUser::getInsSampleId, report.getInsOrderId())
+ .eq(InsSampleUser::getState, 1));
+
+ // 鎶ュ憡鏆傛椂閫�鍑虹紪鍒跺垪琛ㄣ�傚師濮嬫暟鎹鏍搁�氳繃鍚庯紝鐜版湁娴佺▼浼氭仮澶嶆姤鍛婂苟閲嶆柊鎻愪氦瀹℃牳銆�
insReportMapper.update(null, Wrappers.<InsReport>lambdaUpdate()
.eq(InsReport::getId, id)
- .set(InsReport::getIsPass, 0));
+ .set(InsReport::getIsPass, 0)
+ .set(InsReport::getState, 0)
+ .set(InsReport::getIsExamine, RETURNED_STATUS)
+ .set(InsReport::getExamineTime, returnTime)
+ .set(InsReport::getExamineTell, reason)
+ .set(InsReport::getIsRatify, hadApproval ? RETURNED_STATUS : null)
+ .set(InsReport::getRatifyTime, hadApproval ? returnTime : null)
+ .set(InsReport::getRatifyTell, reason)
+ .set(InsReport::getUrlS, null)
+ .set(InsReport::getReviewUrl, null)
+ .set(InsReport::getReviewInspectionUrl, null)
+ .set(InsReport::getTempUrlPdf, null)
+ .set(InsReport::getInspectionTempUrlPdf, null));
- return false;
+ expireReportEditSessions(id);
+ return true;
+ }
+
+ private String prepareLegacyApprovedReportForReview(InsReport report, String approvedUrl) {
+ if (StringUtils.isBlank(approvedUrl)) {
+ throw new ErrorException("鍘嗗彶鎵瑰噯鎶ュ憡鏂囦欢涓嶅瓨鍦紝鏃犳硶閫�鍥炴姤鍛婂鏍�");
+ }
+ try {
+ Path source = Paths.get(approvedUrl.replace("/word", wordUrl));
+ String fileName = "returned-" + UUID.randomUUID() + ".docx";
+ Path target = Paths.get(wordUrl, fileName);
+ Files.copy(source, target, StandardCopyOption.REPLACE_EXISTING);
+
+ ReportSealLayoutUtil.restoreForReview(target.toString());
+ return "/word/" + fileName;
+ } catch (Exception e) {
+ log.error("鍘嗗彶鎵瑰噯鎶ュ憡鎭㈠瀹℃牳绋垮け璐�: {}", approvedUrl, e);
+ throw new ErrorException("鍘嗗彶鎵瑰噯鎶ュ憡鏃犳硶娓呴櫎鏃ф壒鍑嗕俊鎭紝璇烽��鍥炴楠屼换鍔¢噸鏂扮敓鎴�");
+ }
+ }
+
+ private void recordReportReturn(InsReport report, String target, String reason,
+ LocalDateTime returnTime) {
+ recordReportReturn(report,
+ Objects.equals(report.getIsRatify(), 1) ? "APPROVED" : "REPORT_REVIEW",
+ target, reason, returnTime);
+ }
+
+ private void recordReportReturn(InsReport report, String fromStage, String target, String reason,
+ LocalDateTime returnTime) {
+ InsReportReturnRecord record = new InsReportReturnRecord();
+ record.setReportId(report.getId());
+ record.setInsOrderId(report.getInsOrderId());
+ record.setFromStage(fromStage);
+ record.setTargetStage(target);
+ record.setReturnReason(reason.trim());
+ record.setState(report.getState());
+ record.setIsExamine(report.getIsExamine());
+ record.setExamineTime(report.getExamineTime());
+ record.setIsRatify(report.getIsRatify());
+ record.setRatifyTime(report.getRatifyTime());
+ record.setReportUrl(StringUtils.isNotBlank(report.getUrlS()) ? report.getUrlS() : report.getUrl());
+ record.setInspectionUrl(report.getInspectionUrl());
+ record.setTempUrlPdf(report.getTempUrlPdf());
+ record.setInspectionTempUrlPdf(report.getInspectionTempUrlPdf());
+ record.setOperatorId(SecurityUtils.getUserId().intValue());
+ record.setCreateTime(returnTime);
+ if (insReportReturnRecordMapper.insert(record) != 1) {
+ throw new ErrorException("鎶ュ憡閫�鍥炶褰曚繚瀛樺け璐�");
+ }
+ }
+
+ private void expireReportEditSessions(Integer reportId) {
+ insReportEditSessionMapper.update(null, Wrappers.<InsReportEditSession>lambdaUpdate()
+ .eq(InsReportEditSession::getReportId, reportId)
+ .in(InsReportEditSession::getStatus, "EDITING", "SAVED", "FAILED", "SAVE_REQUESTED")
+ .set(InsReportEditSession::getStatus, "EXPIRED")
+ .set(InsReportEditSession::getMessage, "鎶ュ憡宸查��鍥�")
+ .set(InsReportEditSession::getUpdateTime, LocalDateTime.now()));
}
/**
diff --git a/inspect-server/src/main/java/com/ruoyi/inspect/service/impl/SealUsageLedgerServiceImpl.java b/inspect-server/src/main/java/com/ruoyi/inspect/service/impl/SealUsageLedgerServiceImpl.java
index fbd0487..0269148 100644
--- a/inspect-server/src/main/java/com/ruoyi/inspect/service/impl/SealUsageLedgerServiceImpl.java
+++ b/inspect-server/src/main/java/com/ruoyi/inspect/service/impl/SealUsageLedgerServiceImpl.java
@@ -1,6 +1,7 @@
package com.ruoyi.inspect.service.impl;
import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.framework.exception.ErrorException;
@@ -93,6 +94,12 @@
|| StringUtils.isBlank(report.getSealNames())) {
throw new ErrorException("鎶ュ憡鎵瑰噯淇℃伅涓嶅畬鏁达紝鏃犳硶鐢熸垚鐢ㄥ嵃鍙拌处");
}
+ // 鎶ュ憡閫�鍥炲悗閲嶆柊鎵瑰噯浠嶅睘浜庡悓涓�浠芥姤鍛婏紱淇濈暀棣栨鎵瑰噯鐢熸垚鐨勭嫭绔嬬敤鍗拌褰曪紝
+ // 閬垮厤鍞竴閿啿绐佸鑷撮噸鏂版壒鍑嗕簨鍔℃暣浣撳洖婊氥��
+ if (ledgerMapper.selectCount(Wrappers.<SealUsageLedger>lambdaQuery()
+ .eq(SealUsageLedger::getReportId, report.getId())) > 0) {
+ return;
+ }
User ratifyUser = userMapper.selectById(report.getRatifyUserId());
if (ratifyUser == null || StringUtils.isBlank(ratifyUser.getName())) {
throw new ErrorException("鎵句笉鍒版姤鍛婃壒鍑嗕汉锛屾棤娉曠敓鎴愮敤鍗板彴璐�");
diff --git a/inspect-server/src/main/java/com/ruoyi/inspect/util/ReportSealLayoutUtil.java b/inspect-server/src/main/java/com/ruoyi/inspect/util/ReportSealLayoutUtil.java
index 9791a1e..5f81971 100644
--- a/inspect-server/src/main/java/com/ruoyi/inspect/util/ReportSealLayoutUtil.java
+++ b/inspect-server/src/main/java/com/ruoyi/inspect/util/ReportSealLayoutUtil.java
@@ -1,6 +1,8 @@
package com.ruoyi.inspect.util;
import com.aspose.words.Document;
+import com.aspose.words.Cell;
+import com.aspose.words.CompositeNode;
import com.aspose.words.LayoutCollector;
import com.aspose.words.LayoutEnumerator;
import com.aspose.words.License;
@@ -11,6 +13,7 @@
import com.aspose.words.Paragraph;
import com.aspose.words.RelativeHorizontalPosition;
import com.aspose.words.RelativeVerticalPosition;
+import com.aspose.words.Run;
import com.aspose.words.SaveFormat;
import com.aspose.words.Section;
import com.aspose.words.Shape;
@@ -75,6 +78,98 @@
document.save(wordPath, SaveFormat.DOCX);
}
+ /** 浠庡巻鍙叉壒鍑嗙涓竻闄ゆ壒鍑嗗唴瀹癸紝鎭㈠閲嶆柊鎵瑰噯鎵�闇�鐨勫崰浣嶇銆� */
+ public static void restoreForReview(String wordPath) throws Exception {
+ applyAsposeLicense();
+ Document document = new Document(wordPath);
+ List<Shape> shapes = imageShapes(document);
+ Shape signatureShape = null;
+ List<Shape> dateShapes = new ArrayList<>();
+ for (Shape shape : shapes) {
+ if (hasPlaceholderMarker(shape, "ratifyUrl")) {
+ signatureShape = shape;
+ continue;
+ }
+ if (hasPlaceholderMarker(shape, "ratifyDateUrl")) {
+ dateShapes.add(shape);
+ continue;
+ }
+ // 鎵瑰噯鏃舵坊鍔犵殑鎶ュ憡绔犲拰 MA 绔犳寜椤甸潰娴姩瀹氫綅锛屾寜浣嶇疆娓呯悊鑰岄潪姣旇緝鍥剧墖瀛楄妭銆�
+ if (isApprovalSeal(shape)) {
+ shape.remove();
+ }
+ }
+ if (signatureShape != null) {
+ replaceWithPlaceholder(document, signatureShape, "{{@ratifyUrl}}");
+ } else if (!restoreApprovalCellPlaceholder(document)) {
+ throw new IllegalStateException("鏈壘鍒版壒鍑嗘爮锛屾棤娉曟仮澶嶆壒鍑嗙鍚嶅崰浣嶇");
+ }
+ // 閮ㄥ垎鎶ュ憡妯℃澘娌℃湁鎵瑰噯鏃ユ湡鍥剧墖锛屾壒鍑嗘椂闂翠粎瀛樺湪鏁版嵁搴撲腑銆�
+ for (Shape dateShape : dateShapes) {
+ replaceWithPlaceholder(document, dateShape, "{{@ratifyDateUrl}}");
+ }
+ document.save(wordPath, SaveFormat.DOCX);
+ }
+
+ private static boolean isApprovalSeal(Shape shape) throws Exception {
+ return shape.getWrapType() != WrapType.INLINE
+ && shape.getRelativeHorizontalPosition() == RelativeHorizontalPosition.PAGE
+ && shape.getRelativeVerticalPosition() == RelativeVerticalPosition.PAGE
+ && shape.getWidth() >= 50D && shape.getWidth() <= 140D
+ && shape.getHeight() >= 50D && shape.getHeight() <= 140D;
+ }
+
+ private static boolean restoreApprovalCellPlaceholder(Document document) throws Exception {
+ NodeCollection cells = document.getChildNodes(NodeType.CELL, true);
+ for (int i = 0; i < cells.getCount(); i++) {
+ Cell label = (Cell) cells.get(i);
+ if (!"鎵瑰噯".equals(label.getText().replace("\r", "").replace("\u0007", "").trim())) {
+ continue;
+ }
+ Node sibling = label.getNextSibling();
+ if (!(sibling instanceof Cell)) {
+ continue;
+ }
+ Cell signatureCell = (Cell) sibling;
+ for (Shape shape : imageShapesIn(signatureCell)) {
+ shape.remove();
+ }
+ Paragraph paragraph = signatureCell.getFirstParagraph();
+ if (paragraph == null) {
+ throw new IllegalStateException("鎵瑰噯绛惧悕鍗曞厓鏍肩己灏戞钀�");
+ }
+ if (!signatureCell.getText().contains("{{@ratifyUrl}}")) {
+ paragraph.appendChild(new Run(document, "{{@ratifyUrl}}"));
+ }
+ return true;
+ }
+ return false;
+ }
+
+ private static List<Shape> imageShapesIn(Cell cell) throws Exception {
+ List<Shape> result = new ArrayList<>();
+ NodeCollection nodes = cell.getChildNodes(NodeType.SHAPE, true);
+ for (int i = 0; i < nodes.getCount(); i++) {
+ Shape shape = (Shape) nodes.get(i);
+ if (shape.hasImage()) {
+ result.add(shape);
+ }
+ }
+ return result;
+ }
+
+ private static boolean hasPlaceholderMarker(Shape shape, String marker) throws Exception {
+ String alternativeText = shape.getAlternativeText();
+ return alternativeText != null && alternativeText.contains(marker);
+ }
+
+ @SuppressWarnings({"rawtypes", "unchecked"})
+ private static void replaceWithPlaceholder(Document document, Shape shape, String placeholder) {
+ CompositeNode parent = (CompositeNode) shape.getParentNode();
+ parent.insertBefore(new Run(document, placeholder), shape);
+ shape.remove();
+ }
+
private static void applyAsposeLicense() throws Exception {
try (InputStream inputStream = ReportSealLayoutUtil.class.getResourceAsStream("/lib/license.xml")) {
if (inputStream == null) {
@@ -93,7 +188,7 @@
return null;
}
Path path = java.nio.file.Paths.get(imagePath);
- return Files.isRegularFile(path) ? Files.readAllBytes(path) : null;
+ return Files.readAllBytes(path);
}
private static void removeMatchingImages(Document document, byte[] imageBytes) throws Exception {
@@ -115,12 +210,18 @@
private static void addCoverReportSeal(Document document, String imagePath) throws Exception {
Paragraph anchor = firstBodyParagraph(document);
+ LayoutCollector collector = new LayoutCollector(document);
+ Paragraph company = findPageCompanyParagraph(document, collector, 1);
+ Rectangle2D rectangle = company == null ? null : getLayoutRectangle(document, collector, company);
PageSetup pageSetup = document.getFirstSection().getPageSetup();
double[] size = fitImage(imagePath, REPORT_MAX_WIDTH, REPORT_MAX_HEIGHT);
Shape shape = createFloatingImage(document, imagePath, size[0], size[1]);
- shape.setLeft(pageSetup.getLeftMargin() + 20D);
- shape.setTop(pageSetup.getPageHeight() - pageSetup.getBottomMargin()
- - size[1] - POSITION_GAP);
+ shape.setLeft((pageSetup.getPageWidth() - size[0]) / 2D);
+ // 灏侀潰绔犱笌搴曢儴鏈烘瀯鍚嶇О閲嶅彔锛岄殢鍚嶇О鐨勫疄闄呮帓鐗堜綅缃Щ鍔ㄣ��
+ double preferredTop = rectangle == null
+ ? pageSetup.getPageHeight() - pageSetup.getBottomMargin() - size[1] - POSITION_GAP
+ : rectangle.getCenterY() - size[1] / 2D;
+ shape.setTop(clamp(preferredTop, 0D, pageSetup.getPageHeight() - size[1]));
shape.setBehindText(true);
anchor.appendChild(shape);
}
@@ -157,7 +258,9 @@
private static void addLastPageReportSeal(Document document, String imagePath) throws Exception {
int lastPage = document.getPageCount();
LayoutCollector collector = new LayoutCollector(document);
- Paragraph anchor = findLastPageAnchor(document, collector, lastPage);
+ Paragraph title = findResultTitle(document);
+ // 缁撴灉琛ㄥ彲鑳借法椤碉紝绔犲簲璺熼殢缁撴灉鏍囬锛屼笉鑳借窡闅忔渶鍚庝竴椤电殑鈥滄姤鍛婄粨鏉熲�濄��
+ Paragraph anchor = title == null ? findLastPageAnchor(document, collector, lastPage) : title;
if (anchor == null) {
return;
}
@@ -167,11 +270,23 @@
Shape shape = createFloatingImage(document, imagePath, size[0], size[1]);
shape.setLeft((pageSetup.getPageWidth() - size[0]) / 2D);
Rectangle2D rectangle = getLayoutRectangle(document, collector, anchor);
- double preferredTop = rectangle == null
- ? pageSetup.getPageHeight() - pageSetup.getBottomMargin() - size[1] - POSITION_GAP
- : rectangle.getY() + rectangle.getHeight() + POSITION_GAP;
+ double preferredTop;
+ if (title != null) {
+ Paragraph company = findPageCompanyParagraph(document, collector, collector.getStartPageIndex(title));
+ Rectangle2D companyRectangle = company == null ? null : getLayoutRectangle(document, collector, company);
+ // 绔犵殑涓績瀵瑰噯鏈烘瀯鍚嶇О涓庣粨鏋滄爣棰樼粍鎴愮殑鍖哄煙锛屽厑璁镐几鍏ヤ笂椤佃竟璺濄��
+ double headingTop = companyRectangle == null || rectangle == null
+ ? (rectangle == null ? pageSetup.getTopMargin() : rectangle.getY())
+ : Math.min(companyRectangle.getY(), rectangle.getY());
+ double headingBottom = rectangle == null ? headingTop : rectangle.getMaxY();
+ preferredTop = (headingTop + headingBottom - size[1]) / 2D;
+ } else {
+ preferredTop = rectangle == null
+ ? pageSetup.getPageHeight() - pageSetup.getBottomMargin() - size[1] - POSITION_GAP
+ : rectangle.getY() + rectangle.getHeight() + POSITION_GAP;
+ }
shape.setTop(clamp(preferredTop,
- pageSetup.getTopMargin(),
+ title == null ? pageSetup.getTopMargin() : 0D,
pageSetup.getPageHeight() - pageSetup.getBottomMargin() - size[1]));
shape.setBehindText(true);
anchor.appendChild(shape);
@@ -180,7 +295,14 @@
private static Shape createFloatingImage(Document document, String imagePath,
double width, double height) throws Exception {
Shape shape = new Shape(document, ShapeType.IMAGE);
- shape.getImageData().setImage(imagePath);
+ // Aspose 15 浼氭妸 Linux 鐨� / 寮�澶磋矾寰勫綋浣滅浉瀵硅矾寰勶紝鍙兘鐢熸垚绌哄浘鐗囦笖涓嶆姤閿欍��
+ // 閫氳繃娴佸祵鍏ョ湡瀹炲浘鐗囧唴瀹癸紝閬垮厤璺緞琚寜鏂囨。鐨勮祫婧愬湴鍧�鍐嶆瑙f瀽銆�
+ try (InputStream imageStream = Files.newInputStream(java.nio.file.Paths.get(imagePath))) {
+ shape.getImageData().setImage(imageStream);
+ }
+ if (!shape.hasImage()) {
+ throw new IllegalStateException("鎶ュ憡鍗扮珷鍥剧墖宓屽叆澶辫触");
+ }
shape.setWidth(width);
shape.setHeight(height);
shape.setWrapType(WrapType.NONE);
@@ -220,6 +342,42 @@
return fallback;
}
+ private static Paragraph findPageCompanyParagraph(Document document, LayoutCollector collector, int page)
+ throws Exception {
+ Paragraph company = null;
+ NodeCollection paragraphs = document.getChildNodes(NodeType.PARAGRAPH, true);
+ for (int i = 0; i < paragraphs.getCount(); i++) {
+ Paragraph paragraph = (Paragraph) paragraphs.get(i);
+ if (paragraph.getAncestor(NodeType.BODY) != null
+ && paragraph.getAncestor(NodeType.CELL) == null
+ && collector.getStartPageIndex(paragraph) == page
+ && normalizedText(paragraph).endsWith("鍏徃")) {
+ company = paragraph;
+ }
+ }
+ return company;
+ }
+
+ private static Paragraph findResultTitle(Document document) throws Exception {
+ NodeCollection paragraphs = document.getChildNodes(NodeType.PARAGRAPH, true);
+ for (int i = 0; i < paragraphs.getCount(); i++) {
+ Paragraph paragraph = (Paragraph) paragraphs.get(i);
+ if (paragraph.getAncestor(NodeType.BODY) == null
+ || paragraph.getAncestor(NodeType.CELL) != null) {
+ continue;
+ }
+ String text = normalizedText(paragraph);
+ if ("妫�楠岀粨鏋�".equals(text) || "妫�娴嬬粨鏋�".equals(text)) {
+ return paragraph;
+ }
+ }
+ return null;
+ }
+
+ private static String normalizedText(Paragraph paragraph) {
+ return paragraph.getText().replaceAll("[\\s\\u3000]+", "");
+ }
+
private static Paragraph findBodyParagraphContaining(Document document, String text,
LayoutCollector collector, Integer page)
throws Exception {
diff --git a/inspect-server/src/main/java/com/ruoyi/inspect/vo/InsOrderPlanVO.java b/inspect-server/src/main/java/com/ruoyi/inspect/vo/InsOrderPlanVO.java
index 9cdb715..c5f34c5 100644
--- a/inspect-server/src/main/java/com/ruoyi/inspect/vo/InsOrderPlanVO.java
+++ b/inspect-server/src/main/java/com/ruoyi/inspect/vo/InsOrderPlanVO.java
@@ -63,6 +63,9 @@
@Schema(description = "鐞嗙敱")
private String verifyTell;
+ @Schema(description = "鎶ュ憡閫�鍥炲埌妫�楠屼换鍔$殑鏉ユ簮锛欰PPROVED 涓烘壒鍑嗙幆鑺傦紝REPORT_REVIEW 涓哄鏍哥幆鑺�")
+ private String reportReturnSource;
+
private String sonLaboratory;
diff --git a/inspect-server/src/main/resources/mapper/InsOrderRatesMapper.xml b/inspect-server/src/main/resources/mapper/InsOrderRatesMapper.xml
index 4791cf3..3db1be3 100644
--- a/inspect-server/src/main/resources/mapper/InsOrderRatesMapper.xml
+++ b/inspect-server/src/main/resources/mapper/InsOrderRatesMapper.xml
@@ -17,6 +17,7 @@
left join ins_order_standard_template iost on iost.ins_order_id = io.id
left join standard_template st on st.id = iost.template_id
where iost.id is not null
+ and io.state != 5
group by io.id) a
<if test="ew.customSqlSegment != null and ew.customSqlSegment != ''">
${ew.customSqlSegment}
@@ -27,8 +28,10 @@
<select id="selectTemplateRatesDetail" resultType="com.ruoyi.inspect.dto.TemplateRateDto">
select iost.number, iost.name, COALESCE(st.price, 0) as price
from ins_order_standard_template iost
+ join ins_order io on io.id = iost.ins_order_id
left join standard_template st on st.id = iost.template_id
where iost.ins_order_id = #{insOrderId}
+ and io.state != 5
order by iost.sort, iost.id
</select>
diff --git a/inspect-server/src/main/resources/mapper/InsReportMapper.xml b/inspect-server/src/main/resources/mapper/InsReportMapper.xml
index 3b9e27b..ffd96ba 100644
--- a/inspect-server/src/main/resources/mapper/InsReportMapper.xml
+++ b/inspect-server/src/main/resources/mapper/InsReportMapper.xml
@@ -49,6 +49,10 @@
<if test='queryStatus == 2'>
and ir.state = 1 and ir.is_examine = 1 and (ir.is_ratify != 1 or ir.is_ratify is null)
</if>
+ <!-- 宸查��鍥� -->
+ <if test='queryStatus == 3'>
+ and (ir.is_examine = 2 or ir.is_ratify = 2)
+ </if>
</if>
group by ir.id
) a
@@ -102,11 +106,11 @@
case when state = 0 then '寰呮彁浜�' when state = 1 then '宸叉彁浜�' else '' end state,
examine_user,
DATE_FORMAT(examine_time, '%Y-%m-%d %H:%i:%s') examine_time,
- case when is_examine = 0 then '涓嶉�氳繃' when is_examine = 1 then '閫氳繃' else '' end is_examine,
+ case when is_examine = 0 then '涓嶉�氳繃' when is_examine = 1 then '閫氳繃' when is_examine = 2 then '宸查��鍥�' else '' end is_examine,
examine_tell,
ratify_user,
DATE_FORMAT(ratify_time, '%Y-%m-%d %H:%i:%s') ratify_time,
- case when is_ratify = 0 then '涓嶆壒鍑�' when is_ratify = 1 then '鎵瑰噯' else '' end is_ratify,
+ case when is_ratify = 0 then '涓嶆壒鍑�' when is_ratify = 1 then '鎵瑰噯' when is_ratify = 2 then '宸查��鍥�' else '' end is_ratify,
ratify_tell
from (
select
@@ -147,6 +151,10 @@
<if test='queryStatus == 2'>
and ir.state = 1 and ir.is_examine = 1 and (ir.is_ratify != 1 or ir.is_ratify is null)
</if>
+ <!-- 宸查��鍥� -->
+ <if test='queryStatus == 3'>
+ and (ir.is_examine = 2 or ir.is_ratify = 2)
+ </if>
</if>
group by ir.id
) a
diff --git a/inspect-server/src/main/resources/mapper/InsSampleMapper.xml b/inspect-server/src/main/resources/mapper/InsSampleMapper.xml
index 60b24f3..7abb16d 100644
--- a/inspect-server/src/main/resources/mapper/InsSampleMapper.xml
+++ b/inspect-server/src/main/resources/mapper/InsSampleMapper.xml
@@ -195,6 +195,13 @@
ELSE ios.ins_state
END AS ins_state,
ios.verify_tell,
+ CASE WHEN ios.ins_state = 4 AND a.report_is_pass = 0 THEN (
+ SELECT rr.from_stage
+ FROM ins_report_return_record rr
+ WHERE rr.ins_order_id = a.id AND rr.target_stage = 'INSPECTION_TASK'
+ ORDER BY rr.id DESC
+ LIMIT 1
+ ) ELSE NULL END AS report_return_source,
verify_user
FROM
(
@@ -240,6 +247,7 @@
io.type_source,
io.ifs_inventory_id,
ira.id ins_report_id,
+ ira.is_pass report_is_pass,
ira.url,
ira.url_s,
ira.temp_url_pdf,
--
Gitblit v1.9.3