From d14994e10797ce5bc0d29668d358f7c5274dcc5b Mon Sep 17 00:00:00 2001
From: wujianwei <wjw@11.com>
Date: 星期三, 15 四月 2026 15:46:17 +0800
Subject: [PATCH] 新增调用外部接口api

---
 service/src/main/java/com/ruoyi/cwgl/service/impl/FundFlowServiceImpl.java |   95 +++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 95 insertions(+), 0 deletions(-)

diff --git a/service/src/main/java/com/ruoyi/cwgl/service/impl/FundFlowServiceImpl.java b/service/src/main/java/com/ruoyi/cwgl/service/impl/FundFlowServiceImpl.java
index 1121365..1b480ac 100644
--- a/service/src/main/java/com/ruoyi/cwgl/service/impl/FundFlowServiceImpl.java
+++ b/service/src/main/java/com/ruoyi/cwgl/service/impl/FundFlowServiceImpl.java
@@ -1,9 +1,15 @@
 package com.ruoyi.cwgl.service.impl;
 
+import java.util.ArrayList;
 import java.util.List;
 
 import com.ruoyi.common.utils.DateUtils;
+import com.ruoyi.common.utils.poi.ExcelUtil;
+import com.ruoyi.common.utils.file.DownloadExportUtil;
+import com.ruoyi.common.utils.file.DownloadExportUtil.ExprotStatus;
+import com.ruoyi.common.core.redis.RedisCache;
 import javax.annotation.Resource;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.stereotype.Service;
 import org.springframework.scheduling.annotation.Async;
@@ -37,6 +43,8 @@
     private FundFlowMapper fundFlowMapper;
     @Resource
     private IFundFlowLogService fundFlowLogService;
+    @Autowired
+    private RedisCache redisCache;
 
 
     /**
@@ -238,4 +246,91 @@
         
         return result;
     }
+
+    /**
+     * 瀵煎叆璧勯噾娴佹按鏁版嵁
+     *
+     * @param fundFlowList 璧勯噾娴佹按鏁版嵁鍒楄〃
+     * @return 瀵煎叆缁撴灉
+     */
+    @Override
+    public String importFundFlow(List<FundFlow> fundFlowList )
+    {
+        if (fundFlowList == null || fundFlowList.isEmpty()) {
+            throw new RuntimeException("瀵煎叆璧勯噾娴佹按鏁版嵁涓嶈兘涓虹┖");
+        }
+        
+        int successNum = 0;
+        int failureNum = 0;
+        StringBuilder successMsg = new StringBuilder();
+        StringBuilder failureMsg = new StringBuilder();
+        
+        for (FundFlow fundFlow : fundFlowList) {
+            try {
+
+
+                    // 鏂板
+                    fundFlow.setCreateTime(DateUtils.getNowDate());
+                    int result = fundFlowMapper.insertFundFlow(fundFlow);
+                    if (result > 0) {
+                        successNum++;
+                        // 璁板綍鎿嶄綔鏃ュ織
+                        FundFlowLog log = new FundFlowLog();
+                        log.setFlowId(fundFlow.getId());
+                        log.setOperation("瀵煎叆璧勯噾娴佹按锛屾祦姘村彿锛�" + fundFlow.getBankFlowNo());
+                        fundFlowLogService.insertFundFlowLog(log);
+                    } else {
+                        failureNum++;
+                        failureMsg.append("銆�").append(fundFlow.getBankFlowNo());
+                    }
+
+            } catch (Exception e) {
+                failureNum++;
+                failureMsg.append("銆�").append(fundFlow.getBankFlowNo());
+                logger.error("瀵煎叆璧勯噾娴佹按 {} 澶辫触锛歿}", fundFlow.getBankFlowNo(), e.getMessage());
+            }
+        }
+        
+        if (failureNum > 0) {
+            failureMsg.insert(0, "澶辫触鐨勬祦姘村彿锛�");
+        }
+        
+        successMsg.append("鎴愬姛瀵煎叆 " + successNum + " 鏉¤祫閲戞祦姘存暟鎹�");
+        if (failureNum > 0) {
+            successMsg.append("锛�" + failureMsg);
+        }
+        
+        return successMsg.toString();
+    }
+
+    /**
+     * 瀵煎叆璧勯噾娴佹按妯℃澘
+     * 
+     * @param exportKey 瀵煎嚭鍔熻兘鐨勫敮涓�鏍囪瘑
+     */
+    @DataSource(DataSourceType.SLAVE)
+    @Async
+    @Override
+    public void importTemplate(String exportKey) {
+        String fileName = ExcelUtil.encodeFileName("璧勯噾娴佹按瀵煎叆妯℃澘");
+
+        // 璁剧疆褰撳墠浠诲姟涓�"涓嬭浇涓�"鐘舵��
+        DownloadExportUtil.deleteDownloadFile(redisCache, exportKey, ExprotStatus.XZZ.getStatus());
+        
+        try {
+            // 鍒涘缓绌哄垪琛ㄧ敤浜庣敓鎴愭ā鏉匡紙鍙渶瑕佽〃澶达級
+            List<FundFlow> fundFlowList = new ArrayList<>();
+            
+            // 浣跨敤export鏂规硶鍒涘缓妯℃澘
+            export(FundFlow.class, exportKey, fileName, (pageNum) -> {
+                return fundFlowList;
+            });
+            
+            logger.info("瀵煎叆妯℃澘瀵煎嚭瀹屾垚: {}, file: {}", exportKey, fileName);
+        } catch (Exception e) {
+            logger.error("瀵煎叆妯℃澘瀵煎嚭澶辫触: {}, error: {}", exportKey, e.getMessage(), e);
+            DownloadExportUtil.deleteDownloadFile(redisCache, exportKey, ExprotStatus.XZYC.getStatus());
+            throw e;
+        }
+    }
 }

--
Gitblit v1.8.0