From 488f68731390cc019f7c288ad3c8465aac30bcc9 Mon Sep 17 00:00:00 2001
From: 吴羡 <16976746+Xian-TT3@user.noreply.gitee.com>
Date: 星期四, 15 十月 2026 11:55:44 +0800
Subject: [PATCH] 方法验证后端恢复为本地版本:移除合并进来的 Word 表单字段(标准名称/标准编号/验证项目/验证内容JSON)、getCurrentWorkFiles 接口、字段校验与程序化导出,恢复本地 poi-tl 模板导出实现;数据库多出的 4 列保留不再使用
---
cnas-process/src/main/java/com/ruoyi/process/service/impl/ProcessMethodVerifyServiceImpl.java | 139 ----------------------------------------------
1 files changed, 1 insertions(+), 138 deletions(-)
diff --git a/cnas-process/src/main/java/com/ruoyi/process/service/impl/ProcessMethodVerifyServiceImpl.java b/cnas-process/src/main/java/com/ruoyi/process/service/impl/ProcessMethodVerifyServiceImpl.java
index bd55586..ca298cb 100644
--- a/cnas-process/src/main/java/com/ruoyi/process/service/impl/ProcessMethodVerifyServiceImpl.java
+++ b/cnas-process/src/main/java/com/ruoyi/process/service/impl/ProcessMethodVerifyServiceImpl.java
@@ -2,9 +2,6 @@
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.StrUtil;
-import cn.hutool.json.JSONArray;
-import cn.hutool.json.JSONObject;
-import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
@@ -32,11 +29,6 @@
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
-import org.apache.poi.xwpf.usermodel.ParagraphAlignment;
-import org.apache.poi.xwpf.usermodel.XWPFDocument;
-import org.apache.poi.xwpf.usermodel.XWPFParagraph;
-import org.apache.poi.xwpf.usermodel.XWPFTable;
-import org.apache.poi.xwpf.usermodel.XWPFTableCell;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletResponse;
@@ -49,9 +41,6 @@
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
-import java.util.LinkedHashSet;
-import java.util.Objects;
-import java.util.Set;
/**
* 鏍囧噯鏂规硶楠岃瘉
@@ -114,7 +103,6 @@
if (methodVerifyDto.getOperationType() == null) {
throw new ErrorException("璇烽�夋嫨鏄彉鏇磋繕鏄獙璇�");
}
- validateWordVerification(methodVerifyDto);
// 鏂板
baseMapper.insert(methodVerifyDto);
@@ -160,37 +148,6 @@
return processMethodVerifyDto;
}
- @Override
- public List<ProcessMethodVerifyWorkFile> getCurrentWorkFiles(String userIds) {
- List<ProcessMethodVerifyWorkFile> files = new ArrayList<>();
- if (StringUtils.isBlank(userIds)) return files;
-
- Set<Integer> ids = new LinkedHashSet<>();
- for (String value : StrUtil.split(userIds, ",")) {
- try {
- ids.add(Integer.valueOf(value.trim()));
- } catch (NumberFormatException e) {
- throw new ErrorException("妫�娴嬩汉鍛業D鏃犳晥");
- }
- }
- if (ids.size() > 5) throw new ErrorException("鏈�澶氶�夋嫨5鍚嶆娴嬩汉鍛�");
-
- for (Integer userId : ids) {
- ProcessMethodVerifyWorkFile file = processMethodVerifyWorkFileMapper.selectLatestAuthorization(userId);
- if (file == null) continue;
- file.setUserId(userId);
- if (StringUtils.isBlank(file.getFileUrl())) {
- file.setFileName("鏈笂浼犱笂宀楄瘉涔�");
- file.setType(0);
- } else {
- file.setFileName(file.getFileUrl());
- file.setType(file.getFileUrl().matches("(?i).*\\.(png|jpe?g|gif|bmp|webp)$") ? 1 : 2);
- }
- files.add(file);
- }
- return files;
- }
-
/**
* 淇敼鏍囧噯鏂规硶楠岃瘉
*
@@ -199,7 +156,6 @@
*/
@Override
public boolean updateMethodVerify(ProcessMethodVerifyDto methodVerifyDto) {
- validateWordVerification(methodVerifyDto);
baseMapper.updateById(methodVerifyDto);
// 鍒犻櫎涓婂矖璇�
@@ -332,14 +288,6 @@
public void exportMethodVerify(Integer methodVerifyId, HttpServletResponse response) {
// 鑾峰彇鏍囧噯鏂规硶鏇存柊楠岃瘉鏁版嵁
ProcessMethodVerify processMethodVerify = baseMapper.selectById(methodVerifyId);
- if (processMethodVerify == null) {
- throw new ErrorException("鏂规硶楠岃瘉璁板綍涓嶅瓨鍦�");
- }
- if (Objects.equals(processMethodVerify.getOperationType(), 1)
- && StringUtils.isNotBlank(processMethodVerify.getVerificationContent())) {
- exportWordVerification(processMethodVerify, response);
- return;
- }
// 灏嗗唴閮ㄥ瓧娈佃浆鎹㈡垚灞曠ず鍒皐ord涓殑瀵硅薄
ProcessMethodVerifyExportWordDto exportWordTemplate = getExportWordTemplate(processMethodVerify);
@@ -402,91 +350,6 @@
e.printStackTrace();
throw new RuntimeException("瀵煎嚭澶辫触");
}
- }
-
- /** 鏂扮増鏂规硶楠岃瘉涓昏〃瀵煎嚭锛涘師濮嬭褰曞拰楠岃瘉缁撴灉浠嶄綔涓洪檮浠朵繚瀛樸�� */
- private void exportWordVerification(ProcessMethodVerify verify, HttpServletResponse response) {
- JSONObject content = JSONUtil.parseObj(verify.getVerificationContent());
- String[][] checks = {
- {"personnel", "1. 浜哄憳鑳藉姏"}, {"equipment", "2. 妫�娴嬭澶�"},
- {"reagents", "3. 璇曞墏瑕佹眰"}, {"conditions", "4. 璇曢獙鏉′欢"},
- {"sample", "5. 鏍峰搧澶勭疆"}, {"steps", "6. 璇曢獙姝ラ"},
- {"processing", "7. 鏁版嵁澶勭悊"}, {"qualityControl", "璐ㄩ噺鎺у埗鏂规硶"},
- {"result", "鏂规硶楠岃瘉缁撴灉"}
- };
- try (XWPFDocument document = new XWPFDocument()) {
- XWPFParagraph title = document.createParagraph();
- title.setAlignment(ParagraphAlignment.CENTER);
- title.createRun().setText("鏂规硶楠岃瘉璁板綍");
-
- XWPFTable basic = document.createTable(2, 4);
- setCells(basic, 0, "鏍囧噯鍚嶇О", verify.getStandardName(), "鏍囧噯缂栧彿", verify.getStandardCode());
- setCells(basic, 1, "楠岃瘉椤圭洰", verify.getVerifyItem(), "", "");
-
- XWPFTable table = document.createTable(checks.length + 1, 4);
- setCells(table, 0, "楠岃瘉鍐呭", "鏂规硶瑕佹眰", "瀹為獙瀹よ兘鍔�", "鏄惁婊¤冻");
- JSONArray entries = content.getJSONArray("checks");
- for (int i = 0; i < checks.length; i++) {
- JSONObject entry = findCheck(entries, checks[i][0]);
- Integer satisfied = entry == null ? null : entry.getInt("satisfied");
- setCells(table, i + 1, checks[i][1], field(entry, "requirement"),
- field(entry, "capability"), satisfied == null ? "" : satisfied == 1 ? "鏄�" : "鍚�");
- }
-
- XWPFTable conclusion = document.createTable(1, 2);
- setCells(conclusion, 0, "楠岃瘉缁撹", field(content, "conclusion"));
- XWPFTable decisions = document.createTable(2, 4);
- setCells(decisions, 0, "璇勫鎰忚", field(content, "reviewDecision"),
- "璇勫浜哄憳锛�" + field(content, "reviewer"), field(content, "reviewDate"));
- setCells(decisions, 1, "瀹℃壒鎰忚", field(content, "approvalDecision"),
- "鎶�鏈礋璐d汉锛�" + field(content, "approver"), field(content, "approvalDate"));
-
- document.createParagraph().createRun().setText("闄勪欢1 鍘熷璁板綍锛涢檮浠�2 楠岃瘉缁撴灉锛堥檮浠跺湪绯荤粺涓煡鐪嬶級");
- response.setContentType("application/vnd.openxmlformats-officedocument.wordprocessingml.document");
- String fileName = URLEncoder.encode("鏂规硶楠岃瘉璁板綍", "UTF-8");
- response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".docx");
- document.write(response.getOutputStream());
- } catch (Exception e) {
- throw new RuntimeException("瀵煎嚭鏂规硶楠岃瘉璁板綍澶辫触", e);
- }
- }
-
- private JSONObject findCheck(JSONArray entries, String key) {
- if (entries == null) return null;
- for (Object value : entries) {
- JSONObject check = JSONUtil.parseObj(value);
- if (key.equals(check.getStr("key"))) return check;
- }
- return null;
- }
-
- private String field(JSONObject object, String key) {
- return object == null ? "" : StrUtil.nullToEmpty(object.getStr(key));
- }
-
- private void setCells(XWPFTable table, int row, String... values) {
- for (int i = 0; i < values.length; i++) {
- XWPFTableCell cell = table.getRow(row).getCell(i);
- cell.setText(StrUtil.nullToEmpty(values[i]));
- }
- }
-
- private void validateWordVerification(ProcessMethodVerifyDto verify) {
- // 娌℃湁 verificationContent 鐨勬棫璁板綍缁х画鐢辨棫琛ㄥ崟缁存姢銆�
- if (!Objects.equals(verify.getOperationType(), 1)
- || StringUtils.isBlank(verify.getVerificationContent())) return;
- if (StringUtils.isBlank(verify.getStandardName())
- || StringUtils.isBlank(verify.getStandardCode())
- || StringUtils.isBlank(verify.getVerifyItem())) {
- throw new ErrorException("璇峰~鍐欐爣鍑嗗悕绉般�佹爣鍑嗙紪鍙峰拰楠岃瘉椤圭洰");
- }
- try {
- JSONUtil.parseObj(verify.getVerificationContent());
- } catch (Exception e) {
- throw new ErrorException("鏂规硶楠岃瘉鍐呭鏍煎紡閿欒");
- }
- // 淇濈暀鏃у垪渚涚幇鏈変緷璧� method_name 鐨勬煡璇娇鐢ㄣ��
- verify.setMethodName(verify.getStandardName());
}
private ProcessMethodVerifyExportWordDto getExportWordTemplate(ProcessMethodVerify processMethodVerify) {
@@ -561,7 +424,7 @@
User user = userMapper.selectById(userId);
ProcessMethodVerifyWorkFile workFile = new ProcessMethodVerifyWorkFile();
workFile.setMethodVerifyId(methodVerifyDto.getMethodVerifyId());
- workFile.setType(workName.matches("(?i).*\\.(png|jpe?g|gif|bmp|webp)$") ? 1 : 2);
+ workFile.setType(1);
workFile.setFileUrl(workName);
workFile.setFileName(workName);
workFile.setUserId(user.getId());
--
Gitblit v1.9.3