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 | 158 ++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 156 insertions(+), 2 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 52c85d8..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;
@@ -17,7 +23,9 @@
import com.ruoyi.cwgl.mapper.FundFlowMapper;
import com.ruoyi.cwgl.domain.FundFlow;
+import com.ruoyi.cwgl.domain.FundFlowLog;
import com.ruoyi.cwgl.service.IFundFlowService;
+import com.ruoyi.cwgl.service.IFundFlowLogService;
import com.ruoyi.common.core.text.Convert;
/**
@@ -33,6 +41,10 @@
protected final Logger logger = LoggerFactory.getLogger(getClass());
@Resource
private FundFlowMapper fundFlowMapper;
+ @Resource
+ private IFundFlowLogService fundFlowLogService;
+ @Autowired
+ private RedisCache redisCache;
/**
@@ -103,7 +115,17 @@
public int insertFundFlow(FundFlow fundFlow)
{
fundFlow.setCreateTime(DateUtils.getNowDate());
- return fundFlowMapper.insertFundFlow(fundFlow);
+ int result = fundFlowMapper.insertFundFlow(fundFlow);
+
+ // 璁板綍鎿嶄綔鏃ュ織
+ if (result > 0) {
+ FundFlowLog log = new FundFlowLog();
+ log.setFlowId(fundFlow.getId());
+ log.setOperation("鏂板璧勯噾娴佹按锛屾祦姘村彿锛�" + fundFlow.getBankFlowNo());
+ fundFlowLogService.insertFundFlowLog(log);
+ }
+
+ return result;
}
/**
@@ -129,7 +151,17 @@
public int updateFundFlow(FundFlow fundFlow)
{
fundFlow.setUpdateTime(DateUtils.getNowDate());
- return fundFlowMapper.updateFundFlow(fundFlow);
+ int result = fundFlowMapper.updateFundFlow(fundFlow);
+
+ // 璁板綍鎿嶄綔鏃ュ織
+ if (result > 0) {
+ FundFlowLog log = new FundFlowLog();
+ log.setFlowId(fundFlow.getId());
+ log.setOperation("淇敼璧勯噾娴佹按锛屾祦姘村彿锛�" + fundFlow.getBankFlowNo());
+ fundFlowLogService.insertFundFlowLog(log);
+ }
+
+ return result;
}
/**
@@ -179,4 +211,126 @@
{
return fundFlowMapper.deleteFundFlowById(id);
}
+
+ /**
+ * 纭璧勯噾娴佹按锛堝皢鐘舵�佹敼涓哄緟璁ら锛�
+ *
+ * @param id 璧勯噾娴佹按ID
+ * @return 缁撴灉
+ */
+ @Override
+ public int confirmFundFlow(Integer id)
+ {
+ // 鍏堟煡璇㈣祫閲戞祦姘翠俊鎭�
+ FundFlow fundFlow = fundFlowMapper.selectFundFlowById(id);
+ if (fundFlow == null) {
+ throw new RuntimeException("璧勯噾娴佹按涓嶅瓨鍦�");
+ }
+
+ // 鍒ゆ柇鐘舵�佹槸鍚︿负0锛堟甯革級鎵嶈兘纭
+ if (!"0".equals(fundFlow.getStatus())) {
+ throw new RuntimeException("鍙湁鐘舵�佷负鑽夌鐨勮祫閲戞祦姘存墠鑳界‘璁�");
+ }
+
+ // 灏嗙姸鎬佹敼涓�"1"锛堝緟璁ら锛�
+ fundFlow.setStatus("1");
+ int result = fundFlowMapper.updateFundFlow(fundFlow);
+
+ // 璁板綍鎿嶄綔鏃ュ織
+ if (result > 0) {
+ FundFlowLog log = new FundFlowLog();
+ log.setFlowId(id);
+ log.setOperation("纭璧勯噾娴佹按锛屾祦姘村彿锛�" + fundFlow.getBankFlowNo() + "锛岀姸鎬佷粠鑽夌鏀逛负寰呰棰�");
+ fundFlowLogService.insertFundFlowLog(log);
+ }
+
+ 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