From 8c215c8be0f5076e8c95daf1b2203440ca7dfcad Mon Sep 17 00:00:00 2001
From: yxh <172933527@qq.com>
Date: 星期五, 23 十月 2026 13:42:50 +0800
Subject: [PATCH] 修改了报销校验

---
 ruoyi-admin/src/main/java/com/ruoyi/web/controller/project/ServiceReimbursementdetailController.java |   81 ++++++++++++++++++++++++++++++++++++----
 1 files changed, 72 insertions(+), 9 deletions(-)

diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/project/ServiceReimbursementdetailController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/project/ServiceReimbursementdetailController.java
index 313f3fe..ed619ef 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/project/ServiceReimbursementdetailController.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/project/ServiceReimbursementdetailController.java
@@ -52,7 +52,7 @@
      * 鏌ヨ鎶ラ攢鐢宠鏄庣粏鍒楄〃
      */
     @ApiOperation("鏌ヨ鎶ラ攢鐢宠鏄庣粏鍒楄〃")
-    //@PreAuthorize("@ss.hasPermi('project:reimbursementdetail:list')")
+    //// @PreAuthorize("@ss.hasPermi('project:reimbursementdetail:list')")
     @GetMapping("/list")
     public TableDataInfo list(ServiceReimbursementdetail serviceReimbursementdetail) {
         startPage();
@@ -65,7 +65,7 @@
      * 瀵煎嚭鎶ラ攢鐢宠鏄庣粏鍒楄〃
      */
     @ApiOperation("瀵煎嚭鎶ラ攢鐢宠鏄庣粏鍒楄〃")
-    //@PreAuthorize("@ss.hasPermi('project:reimbursementdetail:export')")
+    //// @PreAuthorize("@ss.hasPermi('project:reimbursementdetail:export')")
     @Log(title = "鎶ラ攢鐢宠鏄庣粏", businessType = BusinessType.EXPORT)
     @GetMapping("/export")
     public AjaxResult export(ServiceReimbursementdetail serviceReimbursementdetail) {
@@ -87,7 +87,7 @@
      * 鑾峰彇鎶ラ攢鐢宠鏄庣粏璇︾粏淇℃伅
      */
     @ApiOperation("鑾峰彇鎶ラ攢鐢宠鏄庣粏璇︾粏淇℃伅")
-    //@PreAuthorize("@ss.hasPermi('project:reimbursementdetail:query')")
+    //// @PreAuthorize("@ss.hasPermi('project:reimbursementdetail:query')")
     @GetMapping(value = "/{id}")
     public AjaxResult getInfo(@PathVariable("id") Long id) {
         return AjaxResult.success(serviceReimbursementdetailService.getById(id));
@@ -97,11 +97,26 @@
      * 鏂板鎶ラ攢鐢宠鏄庣粏
      */
     @ApiOperation("鏂板鎶ラ攢鐢宠鏄庣粏")
-    //@PreAuthorize("@ss.hasPermi('project:reimbursementdetail:add')")
+    //// @PreAuthorize("@ss.hasPermi('project:reimbursementdetail:add')")
     @Log(title = "鎶ラ攢鐢宠鏄庣粏", businessType = BusinessType.INSERT)
-    @PostMapping
+    @PostMapping("/add")
     @RepeatSubmit
     public AjaxResult add(@RequestBody ServiceReimbursementdetailVO serviceReimbursementdetailVO) {
+        // 2026-10-15锛氶檮浠舵枃浠跺悕瑙勮寖浜屾鏍¢獙锛堜笌鍓嶇 opo-web/src/utils/fileNameCheck.js 鍚屽彛寰勶紝
+        // 鐩殑鏄槻姝㈢粫杩囧墠绔洿鎺ヨ皟鎺ュ彛淇濆瓨涓嶅悎瑙勯檮浠跺悕锛夈�傛柊澧炲満鏅病鏈夊巻鍙查檮浠讹紝鐢ㄤ弗鏍兼ā寮忋��
+        // 娉ㄦ剰锛歀ist 涓虹┖鏃跺繀椤诲洖閫�鏍¢獙瀛楃涓插瓧娈碉紙annexfiles / invoicefiles锛夛紝
+        // 鍚﹀垯鍙紶瀛楃涓插瓧娈靛氨鑳界粫杩囨牎楠岋紙鎺ュ彛灞傞潰鐨勭粫杩囧彛锛夈��
+        String invoiceJson = CollectionUtils.isEmpty(serviceReimbursementdetailVO.getInvoicefilesList())
+                ? serviceReimbursementdetailVO.getInvoicefiles()
+                : JSON.toJSONString(serviceReimbursementdetailVO.getInvoicefilesList());
+        String annexJson = CollectionUtils.isEmpty(serviceReimbursementdetailVO.getAnnexfilesList())
+                ? serviceReimbursementdetailVO.getAnnexfiles()
+                : JSON.toJSONString(serviceReimbursementdetailVO.getAnnexfilesList());
+        String nameError = com.ruoyi.project.common.AttachmentNameValidator
+                .checkJsonList(invoiceJson, annexJson);
+        if (nameError != null) {
+            return AjaxResult.error("闄勪欢鏂囦欢鍚嶄笉绗﹀悎瑕佹眰锛屾棤娉曚繚瀛橈細" + nameError);
+        }
         ServiceReimbursementdetail serviceReimbursementdetail = DtoConversionUtils.sourceToTarget(serviceReimbursementdetailVO, ServiceReimbursementdetail.class);
         //灏嗗墠绔紶鏉ョ殑闄勪欢闆嗗悎杞垚瀛楃涓�
         if (!CollectionUtils.isEmpty(serviceReimbursementdetailVO.getAnnexfilesList())) {
@@ -110,18 +125,37 @@
         if (!CollectionUtils.isEmpty(serviceReimbursementdetailVO.getInvoicefilesList())) {
             serviceReimbursementdetail.setInvoicefiles(JSON.toJSONString(serviceReimbursementdetailVO.getInvoicefilesList()));
         }
-        return toAjax(serviceReimbursementdetailService.save(serviceReimbursementdetail));
+        boolean save = serviceReimbursementdetailService.save(serviceReimbursementdetail);
+        return AjaxResult.success(serviceReimbursementdetail);
     }
 
     /**
      * 淇敼鎶ラ攢鐢宠鏄庣粏
      */
     @ApiOperation("淇敼鎶ラ攢鐢宠鏄庣粏")
-    //@PreAuthorize("@ss.hasPermi('project:reimbursementdetail:edit')")
+    //// @PreAuthorize("@ss.hasPermi('project:reimbursementdetail:edit')")
     @Log(title = "淇敼鐢宠鏄庣粏", businessType = BusinessType.UPDATE)
     @PostMapping("/updateRDlList")
     public AjaxResult updateRDlList(@RequestBody List<ServiceReimbursementdetail> serviceReimbursementdetails) {
         for (ServiceReimbursementdetail serviceReimbursementdetail : serviceReimbursementdetails) {
+            // 2026-10-15锛氶檮浠舵枃浠跺悕瑙勮寖浜屾鏍¢獙锛堝彧鏍¢獙鏈鍙樻洿鐨勯檮浠讹紝鍘嗗彶闄勪欢鏀捐锛�
+            java.util.Set<String> existingNames = new java.util.HashSet<>();
+            if (serviceReimbursementdetail.getId() != null) {
+                ServiceReimbursementdetail oldDetail = serviceReimbursementdetailService
+                        .getById(serviceReimbursementdetail.getId());
+                if (oldDetail != null) {
+                    existingNames.addAll(com.ruoyi.project.common.AttachmentNameValidator
+                            .collectNames(oldDetail.getInvoicefiles()));
+                    existingNames.addAll(com.ruoyi.project.common.AttachmentNameValidator
+                            .collectNames(oldDetail.getAnnexfiles()));
+                }
+            }
+            String nameError = com.ruoyi.project.common.AttachmentNameValidator.checkJsonListForUpdate(
+                    existingNames, serviceReimbursementdetail.getInvoicefiles(),
+                    serviceReimbursementdetail.getAnnexfiles());
+            if (nameError != null) {
+                return AjaxResult.error("闄勪欢鏂囦欢鍚嶄笉绗﹀悎瑕佹眰锛屾棤娉曚繚瀛橈細" + nameError);
+            }
             serviceReimbursementdetailService.saveOrUpdate(serviceReimbursementdetail);
 
         }
@@ -132,11 +166,36 @@
      * 淇敼鎶ラ攢鐢宠鏄庣粏
      */
     @ApiOperation("淇敼鎶ラ攢鐢宠鏄庣粏")
-    //@PreAuthorize("@ss.hasPermi('project:reimbursementdetail:edit')")
+    //// @PreAuthorize("@ss.hasPermi('project:reimbursementdetail:edit')")
     @Log(title = "鎶ラ攢鐢宠鏄庣粏", businessType = BusinessType.UPDATE)
     @PostMapping("/reimbursementdetailEdit")
     //@RepeatSubmit
     public AjaxResult edit(@RequestBody ServiceReimbursementdetailVO serviceReimbursementdetailVO) {
+        // 2026-10-15锛氶檮浠舵枃浠跺悕瑙勮寖浜屾鏍¢獙锛堜笌鍓嶇 fileNameCheck 鍚屽彛寰勶紝闃叉缁曡繃鍓嶇锛夈��
+        // 淇敼鍦烘櫙鎸変笟鍔″彛寰�"鍙牎楠屾湰娆″彉鏇寸殑闄勪欢"锛氫繚瀛樺墠宸插瓨鍦ㄧ殑鍘嗗彶闄勪欢鍚嶄笉鍙備笌鏍¢獙锛岄伩鍏嶅崱浣忚�佸崟鎹��
+        java.util.Set<String> existingNames = new java.util.HashSet<>();
+        if (serviceReimbursementdetailVO.getId() != null) {
+            ServiceReimbursementdetail oldDetail = serviceReimbursementdetailService
+                    .getById(serviceReimbursementdetailVO.getId());
+            if (oldDetail != null) {
+                existingNames.addAll(com.ruoyi.project.common.AttachmentNameValidator
+                        .collectNames(oldDetail.getInvoicefiles()));
+                existingNames.addAll(com.ruoyi.project.common.AttachmentNameValidator
+                        .collectNames(oldDetail.getAnnexfiles()));
+            }
+        }
+        // List 涓虹┖鏃跺洖閫�鏍¢獙瀛楃涓插瓧娈碉紙annexfiles / invoicefiles锛夛紝鍫典綇"鍙紶瀛楃涓插瓧娈�"鐨勭粫杩囧彛
+        String invoiceJson = CollectionUtils.isEmpty(serviceReimbursementdetailVO.getInvoicefilesList())
+                ? serviceReimbursementdetailVO.getInvoicefiles()
+                : JSON.toJSONString(serviceReimbursementdetailVO.getInvoicefilesList());
+        String annexJson = CollectionUtils.isEmpty(serviceReimbursementdetailVO.getAnnexfilesList())
+                ? serviceReimbursementdetailVO.getAnnexfiles()
+                : JSON.toJSONString(serviceReimbursementdetailVO.getAnnexfilesList());
+        String nameError = com.ruoyi.project.common.AttachmentNameValidator
+                .checkJsonListForUpdate(existingNames, invoiceJson, annexJson);
+        if (nameError != null) {
+            return AjaxResult.error("闄勪欢鏂囦欢鍚嶄笉绗﹀悎瑕佹眰锛屾棤娉曚繚瀛橈細" + nameError);
+        }
         if (serviceReimbursementdetailVO.getTrafficexpense() == null) {
             serviceReimbursementdetailVO.setTrafficexpense(new BigDecimal(0));
         }
@@ -162,10 +221,14 @@
         if (!CollectionUtils.isEmpty(serviceReimbursementdetailVO.getAnnexfilesList())) {
             //瀵瑰墠绔紶杩囨潵鐨勬暟缁勶紝杩涜JSON搴忓垪鍖栵紝骞惰祴鍊肩粰Annexfiles
             serviceReimbursementdetail.setAnnexfiles(JSON.toJSONString(serviceReimbursementdetailVO.getAnnexfilesList()));
+        } else {
+            serviceReimbursementdetail.setAnnexfiles(null);
         }
         if (!CollectionUtils.isEmpty(serviceReimbursementdetailVO.getInvoicefilesList())) {
             //瀵瑰墠绔紶杩囨潵鐨勬暟缁勶紝杩涜JSON搴忓垪鍖栵紝骞惰祴鍊肩粰Invoicefiles
             serviceReimbursementdetail.setInvoicefiles(JSON.toJSONString(serviceReimbursementdetailVO.getInvoicefilesList()));
+        } else {
+            serviceReimbursementdetail.setInvoicefiles(null);
         }
         return toAjax(serviceReimbursementdetailService.updateById(serviceReimbursementdetail));
     }
@@ -174,7 +237,7 @@
      * 鍒犻櫎鎶ラ攢鐢宠鏄庣粏
      */
     @ApiOperation("鍒犻櫎鎶ラ攢鐢宠鏄庣粏")
-    //@PreAuthorize("@ss.hasPermi('project:reimbursementdetail:remove')")
+    //// @PreAuthorize("@ss.hasPermi('project:reimbursementdetail:remove')")
     @Log(title = "鎶ラ攢鐢宠鏄庣粏", businessType = BusinessType.DELETE)
     @GetMapping("/remove/{ids}")
     public AjaxResult remove(@PathVariable Long[] ids) {

--
Gitblit v1.9.3