From 8ad863082097ffdcab4a8e7f426d344a1fe6f892 Mon Sep 17 00:00:00 2001
From: 吴羡 <16976746+Xian-TT3@user.noreply.gitee.com>
Date: 星期六, 07 十一月 2026 00:27:02 +0800
Subject: [PATCH] 修复人员管理接口校验与导出,完善设备保养计划与文件受控功能

---
 cnas-personnel/src/main/java/com/ruoyi/personnel/service/impl/PersonPersonnelCapacityServiceImpl.java |   63 +++++++++++++++++++++++++------
 1 files changed, 51 insertions(+), 12 deletions(-)

diff --git a/cnas-personnel/src/main/java/com/ruoyi/personnel/service/impl/PersonPersonnelCapacityServiceImpl.java b/cnas-personnel/src/main/java/com/ruoyi/personnel/service/impl/PersonPersonnelCapacityServiceImpl.java
index 2974840..d10a4bd 100644
--- a/cnas-personnel/src/main/java/com/ruoyi/personnel/service/impl/PersonPersonnelCapacityServiceImpl.java
+++ b/cnas-personnel/src/main/java/com/ruoyi/personnel/service/impl/PersonPersonnelCapacityServiceImpl.java
@@ -29,6 +29,7 @@
 
 import jakarta.annotation.Resource;
 import jakarta.servlet.http.HttpServletResponse;
+import java.io.File;
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.net.URLEncoder;
@@ -69,19 +70,35 @@
      */
     @Override
     public void exportPersonnelCapacity(Integer id, HttpServletResponse response) {
+        if (id == null) {
+            throw new ErrorException("缂哄皯浜哄憳鑳藉姏璁板綍id");
+        }
         PersonPersonnelCapacityExportDto capacityExportDto = baseMapper.selectExportPersonnelCapacity(id);
+        if (capacityExportDto == null) {
+            throw new ErrorException("浜哄憳鑳藉姏璁板綍涓嶅瓨鍦ㄦ垨宸茶鍒犻櫎");
+        }
 
         // 纭浜�
         String confirmUrl = null;
         if (capacityExportDto.getConfirmOperatingPersonnelId() != null) {
-            confirmUrl = userMapper.selectById(capacityExportDto.getConfirmOperatingPersonnelId()).getSignatureUrl();
+            User confirmUser = userMapper.selectById(capacityExportDto.getConfirmOperatingPersonnelId());
+            if (confirmUser == null) {
+                throw new ErrorException("纭浜轰笉瀛樺湪鎴栧凡琚垹闄わ紝鏃犳硶瀵煎嚭");
+            }
+            confirmUrl = confirmUser.getSignatureUrl();
             if (StringUtils.isBlank(confirmUrl)) {
-                throw new ErrorException("缂哄皯纭浜虹鍚�");
+                throw new ErrorException("纭浜鸿繕娌℃湁涓婁紶绛惧悕锛屾棤娉曞鍑�");
+            }
+            if (!new File(imgUrl + "/" + confirmUrl).exists()) {
+                throw new ErrorException("纭浜虹鍚嶆枃浠朵笉瀛樺湪锛岃璁╃‘璁や汉閲嶆柊涓婁紶");
             }
         }
 
         // 鑾峰彇璺緞
         InputStream inputStream = this.getClass().getResourceAsStream("/static/personnel-capacity.docx");
+        if (inputStream == null) {
+            throw new ErrorException("浜哄憳鑳藉姏瀵煎嚭妯℃澘涓嶅瓨鍦�");
+        }
         ConfigureBuilder builder = Configure.builder();
         builder.useSpringEL(true);
         String finalConfirmUrl = confirmUrl;
@@ -95,8 +112,8 @@
 
         try {
             response.setContentType("application/msword");
-            String fileName = URLEncoder.encode(
-                    "浜哄憳鑳藉姏", "UTF-8");
+            String userName = StringUtils.isBlank(capacityExportDto.getUserName()) ? "浜哄憳鑳藉姏" : capacityExportDto.getUserName() + "浜哄憳鑳藉姏璁ゅ畾";
+            String fileName = URLEncoder.encode(userName, "UTF-8");
             response.setHeader("Content-disposition",
                     "attachment;filename=" + fileName + ".docx");
             OutputStream os = response.getOutputStream();
@@ -117,17 +134,40 @@
     @Override
     @Transactional(rollbackFor = Exception.class)
     public void submitConfirmPersonnelCapability(PersonPersonnelCapacity personPersonnelCapacity) {
+        if (personPersonnelCapacity.getUserId() == null) {
+            throw new ErrorException("缂哄皯浜哄憳");
+        }
         if (personPersonnelCapacity.getConfirmOperatingPersonnelId() == null) {
             throw new ErrorException("缂哄皯纭浜�");
         }
         User formUser = userMapper.selectById(personPersonnelCapacity.getUserId());
+        if (formUser == null) {
+            throw new ErrorException("浜哄憳涓嶅瓨鍦ㄦ垨宸茶鍒犻櫎锛屾棤娉曟彁浜�");
+        }
+        User confirmUser = userMapper.selectById(personPersonnelCapacity.getConfirmOperatingPersonnelId());
+        if (confirmUser == null) {
+            throw new ErrorException("纭浜轰笉瀛樺湪鎴栧凡琚垹闄わ紝鏃犳硶鎻愪氦");
+        }
+        if (personPersonnelCapacity.getId() != null) {
+            PersonPersonnelCapacity existing = this.getById(personPersonnelCapacity.getId());
+            if (existing == null) {
+                throw new ErrorException("浜哄憳鑳藉姏璁板綍涓嶅瓨鍦ㄦ垨宸茶鍒犻櫎");
+            }
+            if (existing.getConfirmDate() != null) {
+                throw new ErrorException("璇ヨ褰曞凡纭锛屼笉鑳介噸澶嶆彁浜�");
+            }
+        }
 
         Integer userId = SecurityUtils.getUserId().intValue();
         User user = userMapper.selectById(userId);
+        // 鎻愪氦鍜岀‘璁ゆ棩鏈熷垎寮�锛氱‘璁ゆ棩鏈熷彧鍦ㄧ‘璁ゆ搷浣滄椂鐢辩郴缁熷啓鍏�
+        personPersonnelCapacity.setConfirmDate(null);
+        this.saveOrUpdate(personPersonnelCapacity);
+
         // 娑堟伅鍙戦��
         InformationNotification info = new InformationNotification();
         // 鍙戦�佷汉
-        info.setCreateUser(user.getName());
+        info.setCreateUser(user != null ? user.getName() : "");
         info.setMessageType("6");
         info.setTheme("CNAS浜哄憳鑳藉姏纭閫氱煡");
         info.setContent(formUser.getName() + "鐨勪汉鍛樿兘鍔涘緟纭");
@@ -136,22 +176,21 @@
         info.setConsigneeId(personPersonnelCapacity.getConfirmOperatingPersonnelId());
         info.setJumpPath(MenuJumpPathConstants.PERSONNEL);
         informationNotificationService.addInformationNotification(info);
-        this.saveOrUpdate(personPersonnelCapacity);
 
         // 鍙戦�佷紒涓氬井淇¢�氱煡
         threadPoolTaskExecutor.execute(() -> {
-            // 鏌ヨ鎺ユ敹浜�
-            User personnel = userMapper.selectById(personPersonnelCapacity.getConfirmOperatingPersonnelId());
-
+            if (confirmUser.getAccount() == null || confirmUser.getAccount().trim().isEmpty()) {
+                return;
+            }
             String message = "";
             message += "CNAS浜哄憳鑳藉姏纭閫氱煡";
-            message += "\n璇峰幓璧勬簮绠$悊-浜哄憳-浜哄憳鑳藉姏濉啓";
+            message += "\n璇峰幓璧勬簮瑕佹眰-浜哄憳-浜哄憳绠$悊-浜哄憳鑳藉姏濉啓";
             message += "\n" + formUser.getName() + "鐨勪汉鍛樿兘鍔涘緟纭";
             //鍙戦�佷紒涓氬井淇℃秷鎭�氱煡
             try {
-                WxCpUtils.inform(personnel.getAccount(), message, null);
+                WxCpUtils.inform(confirmUser.getAccount(), message, null);
             } catch (Exception e) {
-                throw new RuntimeException(e);
+                e.printStackTrace();
             }
         });
 

--
Gitblit v1.9.3