From e91d1f0251d30dc3c59b38d5318266357a64c12c Mon Sep 17 00:00:00 2001
From: liusheng <337615773@qq.com>
Date: 星期三, 20 九月 2023 09:52:40 +0800
Subject: [PATCH] 代码提交

---
 ruoyi-project/src/main/java/com/ruoyi/project/service/impl/ServiceReimbursementServiceImpl.java |   77 +++++++++++++++++++++++---------------
 1 files changed, 46 insertions(+), 31 deletions(-)

diff --git a/ruoyi-project/src/main/java/com/ruoyi/project/service/impl/ServiceReimbursementServiceImpl.java b/ruoyi-project/src/main/java/com/ruoyi/project/service/impl/ServiceReimbursementServiceImpl.java
index e46998b..e2427b8 100644
--- a/ruoyi-project/src/main/java/com/ruoyi/project/service/impl/ServiceReimbursementServiceImpl.java
+++ b/ruoyi-project/src/main/java/com/ruoyi/project/service/impl/ServiceReimbursementServiceImpl.java
@@ -148,7 +148,7 @@
         Map<String, Object> columnMap = new HashMap<>();
         columnMap.put("rbid", id);
         //鑾峰彇璇︽儏鏁版嵁
-         List<ServiceReimbursementdetail> details = serviceReimbursementdetailMapper.selectByMap(columnMap);
+        List<ServiceReimbursementdetail> details = serviceReimbursementdetailMapper.selectByMap(columnMap);
         log.info("serviceReimbursementdetailMapper.selectByMap鏂规硶鐨勮繑鍙傚弬 :{}", CollectionUtils.isEmpty(details) ? null : details.size());
         //鑾峰彇鏀粯鏁版嵁
         List<ServiceReimbursementpayee> serviceReimbursementpayees = reimbursementpayeeMapper.selectByMap(columnMap);
@@ -173,7 +173,14 @@
             uploadOAFileAndUpdateDb(serviceReimbursementdetailShareds.get(i));
         }
 
-        detailSharedService.saveBatch(serviceReimbursementdetailShareds);
+//        detailSharedService.saveBatch(serviceReimbursementdetailShareds);
+        for (ServiceReimbursementdetailShared serviceReimbursementdetailShared : serviceReimbursementdetailShareds) {
+            if (ObjectUtils.isNotEmpty(serviceReimbursementdetailShared)) {
+                detailSharedService.save(serviceReimbursementdetailShared);
+            } else {
+                log.info("serviceReimbursementdetailShared涓虹┖浜�");
+            }
+        }
 
         //灏唖erviceReimbursementpayee琛ㄩ噷鐨刬d璧嬪�肩粰Rpid; 灏唖erviceReimbursementShared閲岀殑ID璧嬪�肩粰RBID,骞跺皢serviceReimbursementpayeeShared琛ㄩ噷鐨刬d缃┖锛岀敱鏁版嵁搴撻噸鏂扮敓鎴�
         for (int i = 0; i < serviceReimbursementpayees.size(); i++) {
@@ -181,8 +188,14 @@
             serviceReimbursementpayeeShareds.get(i).setRbid(serviceReimbursementShared.getId());
             serviceReimbursementpayeeShareds.get(i).setId(null);
         }
-        payeeSharedService.saveBatch(serviceReimbursementpayeeShareds);
 
+        for (ServiceReimbursementpayeeShared serviceReimbursementpayeeShared : serviceReimbursementpayeeShareds) {
+            if (ObjectUtils.isNotEmpty(serviceReimbursementpayeeShared)) {
+                payeeSharedService.save(serviceReimbursementpayeeShared);
+            } else {
+                log.info("serviceReimbursementpayeeShared涓虹┖浜嗭紒");
+            }
+        }
         return true;
     }
 
@@ -239,38 +252,40 @@
 
         List<RbDetailFile> parseArray2 = new ArrayList<>();
         List<RbDetailFile> parseArray = JSON.parseArray(remShare.getAnnexfiles(), RbDetailFile.class);
-        for (int i = 0; i < parseArray.size(); i++) {
-            RbDetailFile rbDetailFile = parseArray.get(i);
+        if (!CollectionUtils.isEmpty(parseArray)) {
+            for (int i = 0; i < parseArray.size(); i++) {
+                RbDetailFile rbDetailFile = parseArray.get(i);
 
-            log.info("filePath鐨勪慨鏀�:{}", filePath);
-            String url = rbDetailFile.getUrl();
-            //file鐢ㄧ殑鏄粷瀵逛綅缃�
-            String substring = url.substring(url.indexOf("/profile/upload") + "/profile/upload".length());
-            String strFile = rbDetailFile.getUrl().replace(filePath, "/profile/upload");
-            System.out.println("reimbursement鏈嶅姟鐨刦ilePath + substring鏄贡鐮佸悧: " + filePath + substring);
-            File filetest = new File(filePath + substring);
-            try {
-                log.info("璇锋眰绗笁鏂圭殑鍏ュ弬strFile : {}, strFUrl : {}", strFile, filePath);
-                String struploadResult = HttpClientKit.sendPostWithFile(filetest, strFUrl);
-                log.info("绗笁鏂逛紶鍥炵殑鏁版嵁: {}", struploadResult);
-                if (StringUtils.isEmpty(struploadResult)) {
-                    log.info("HttpClientKit.sendPostWithFile 璇锋眰涓虹┖浜� filetest:{},  strFUrl:{} ", filetest, strFUrl);
-                    return 0;
-                }
+                log.info("filePath鐨勪慨鏀�:{}", filePath);
+                String url = rbDetailFile.getUrl();
+                //file鐢ㄧ殑鏄粷瀵逛綅缃�
+                String substring = url.substring(url.indexOf("/profile/upload") + "/profile/upload".length());
+                String strFile = rbDetailFile.getUrl().replace(filePath, "/profile/upload");
+                System.out.println("reimbursement鏈嶅姟鐨刦ilePath + substring鏄贡鐮佸悧: " + filePath + substring);
+                File filetest = new File(filePath + substring);
+                try {
+                    log.info("璇锋眰绗笁鏂圭殑鍏ュ弬strFile : {}, strFUrl : {}", strFile, filePath);
+                    String struploadResult = HttpClientKit.sendPostWithFile(filetest, strFUrl);
+                    log.info("绗笁鏂逛紶鍥炵殑鏁版嵁: {}", struploadResult);
+                    if (StringUtils.isEmpty(struploadResult)) {
+                        log.info("HttpClientKit.sendPostWithFile 璇锋眰涓虹┖浜� filetest:{},  strFUrl:{} ", filetest, strFUrl);
+                        return 0;
+                    }
 
-                //鑾峰彇fileid
-                JSONObject jsonR = JSONObject.parseObject(struploadResult);
-                JSONArray jsonArr = jsonR.getJSONArray("atts");
-                log.info("绗笁鏂逛紶鍥炵殑鏁版嵁鑾峰彇鐨刟tts : {}", jsonArr);
-                for (int j = 0; j < jsonArr.size(); j++) {
-                    JSONObject jsonRet = jsonArr.getJSONObject(j);
-                    rbDetailFile.setFileid(jsonRet.get("fileUrl").toString());
+                    //鑾峰彇fileid
+                    JSONObject jsonR = JSONObject.parseObject(struploadResult);
+                    JSONArray jsonArr = jsonR.getJSONArray("atts");
+                    log.info("绗笁鏂逛紶鍥炵殑鏁版嵁鑾峰彇鐨刟tts : {}", jsonArr);
+                    for (int j = 0; j < jsonArr.size(); j++) {
+                        JSONObject jsonRet = jsonArr.getJSONObject(j);
+                        rbDetailFile.setFileid(jsonRet.get("fileUrl").toString());
+                    }
+                } catch (Exception e) {
+                    e.printStackTrace();
+                    log.error("HttpClientKit.sendPostWithFile 鎶ラ敊浜� : " + e.getMessage());
                 }
-            } catch (Exception e) {
-                e.printStackTrace();
-                log.error("HttpClientKit.sendPostWithFile 鎶ラ敊浜� : " + e.getMessage());
+                parseArray2.add(rbDetailFile);
             }
-            parseArray2.add(rbDetailFile);
         }
         remShare.setAnnexfiles(JSON.toJSONString(parseArray2));
         log.info("ServiceReimbursementdetailShared 鏄惁鍔犱笂浜唂ileid : {}", remShare);

--
Gitblit v1.9.3