sen
5 天以前 672811c5b1e1bb73845278ec07d9262d9dc40f7f
Merge remote-tracking branch 'origin/cwxt_master' into cwxt_master
6个文件已修改
158 ■■■■■ 已修改文件
service/src/main/java/com/ruoyi/cwgl/controller/FundFlowController.java 26 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service/src/main/java/com/ruoyi/cwgl/domain/FundFlow.java 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service/src/main/java/com/ruoyi/cwgl/mapper/FundFlowMapper.java 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service/src/main/java/com/ruoyi/cwgl/service/IFundFlowService.java 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service/src/main/java/com/ruoyi/cwgl/service/impl/FundFlowServiceImpl.java 95 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service/src/main/resources/mapper/cwgl/FundFlowMapper.xml 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service/src/main/java/com/ruoyi/cwgl/controller/FundFlowController.java
@@ -19,6 +19,7 @@
import com.ruoyi.cwgl.domain.FundFlow;
import com.ruoyi.cwgl.service.IFundFlowService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import org.springframework.web.multipart.MultipartFile;
import com.ruoyi.common.core.page.TableDataInfo;
/**
@@ -116,4 +117,29 @@
    {
        return toAjax(fundFlowService.confirmFundFlow(id));
    }
    /**
     * 导入资金流水Excel
     */
    @PreAuthorize("@ss.hasPermi('cwgl:fundFlow:import')")
    @Log(title = "资金流水", businessType = BusinessType.IMPORT)
    @PostMapping("/importData")
    public AjaxResult importData(MultipartFile file ) throws Exception
    {
        ExcelUtil<FundFlow> util = new ExcelUtil<FundFlow>(FundFlow.class);
        List<FundFlow> fundFlowList = util.importExcel(file.getInputStream());
        String message = fundFlowService.importFundFlow(fundFlowList);
        return AjaxResult.success(message);
    }
    /**
     * 下载导入资金流水模板
     */
    @PreAuthorize("@ss.hasPermi('cwgl:fundFlow:import')")
    @GetMapping("/importTemplate")
    public AjaxResult importTemplate(String exportKey)
    {
        fundFlowService.importTemplate(exportKey);
        return AjaxResult.success("导出请求成功,请稍后点击下载...!");
    }
}
service/src/main/java/com/ruoyi/cwgl/domain/FundFlow.java
@@ -23,7 +23,7 @@
    /** 银行流水号 */
    @Excel(name = "银行流水号")
    @Excel(name = "核心流水号")
        @TableField("bank_flow_no")
    private String bankFlowNo;
@@ -72,14 +72,14 @@
    /** 对方账号 */
    @Excel(name = "对方账号")
    @Excel(name = "交易对手账户")
        @TableField("counterparty_account")
    private String counterpartyAccount;
    /** 对方户名 */
    @Excel(name = "对方户名")
    @Excel(name = "交易对手名称")
        @TableField("counterparty_name")
    private String counterpartyName;
@@ -87,7 +87,7 @@
    /** 交易日期 */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @Excel(name = "交易日期", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
    @Excel(name = "交易时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
        @TableField("transaction_date")
    private Date transactionDate;
service/src/main/java/com/ruoyi/cwgl/mapper/FundFlowMapper.java
@@ -84,4 +84,12 @@
     * @return 结果
     */
    public int deleteFundFlowByIds(Integer[] ids);
    /**
     * 根据银行流水号查询资金流水
     *
     * @param bankFlowNo 银行流水号
     * @return 资金流水
     */
    public FundFlow selectFundFlowByBankFlowNo(String bankFlowNo);
}
service/src/main/java/com/ruoyi/cwgl/service/IFundFlowService.java
@@ -107,4 +107,20 @@
     * @return 结果
     */
    public int confirmFundFlow(Integer id);
    /**
     * 导入资金流水数据
     *
     * @param fundFlowList 资金流水数据列表
     * @param updateSupport 是否支持更新
     * @return 导入结果
     */
    public String importFundFlow(List<FundFlow> fundFlowList  );
    /**
     * 导入资金流水模板
     *
     * @param exportKey 导出功能的唯一标识
     */
    public void importTemplate(String exportKey);
}
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;
        }
    }
}
service/src/main/resources/mapper/cwgl/FundFlowMapper.xml
@@ -206,4 +206,9 @@
        </foreach>
    </delete>
    <select id="selectFundFlowByBankFlowNo" parameterType="String" resultMap="FundFlowResult">
        <include refid="selectFundFlowVo"/>
        where thisTab.bank_flow_no = #{bankFlowNo}
    </select>
</mapper>