feat: 实现银行流水转换方法 fromResponse()
This commit is contained in:
@@ -3,7 +3,11 @@ package com.ruoyi.ccdi.project.domain.entity;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.ruoyi.lsfx.domain.response.GetBankStatementResponse.BankStatementItem;
|
||||
import lombok.Data;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
@@ -20,6 +24,8 @@ import java.util.Date;
|
||||
@TableName("ccdi_bank_statement")
|
||||
public class CcdiBankStatement implements Serializable {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(CcdiBankStatement.class);
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@@ -160,4 +166,48 @@ public class CcdiBankStatement implements Serializable {
|
||||
|
||||
/** 创建者 */
|
||||
private Long createdBy;
|
||||
|
||||
/**
|
||||
* 从流水分析接口响应转换为实体
|
||||
*
|
||||
* @param item 流水分析接口返回的流水项
|
||||
* @return 流水实体,如果 item 为 null 则返回 null
|
||||
*/
|
||||
public static CcdiBankStatement fromResponse(BankStatementItem item) {
|
||||
// 1. 空值检查
|
||||
if (item == null) {
|
||||
log.warn("流水项为空,无法转换");
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
// 2. 创建实体对象
|
||||
CcdiBankStatement entity = new CcdiBankStatement();
|
||||
|
||||
// 3. 使用 BeanUtils 复制同名字段
|
||||
BeanUtils.copyProperties(item, entity);
|
||||
|
||||
// 4. 手动映射字段名不一致的情况
|
||||
entity.setLeAccountNo(item.getAccountMaskNo());
|
||||
entity.setCustomerAccountNo(item.getCustomerAccountMaskNo());
|
||||
entity.setLeAccountName(item.getLeName());
|
||||
entity.setAmountDr(item.getDrAmount());
|
||||
entity.setAmountCr(item.getCrAmount());
|
||||
entity.setAmountBalance(item.getBalanceAmount());
|
||||
entity.setTrxFlag(item.getTransFlag());
|
||||
entity.setTrxType(item.getTransTypeId());
|
||||
entity.setCustomerLeId(item.getCustomerId());
|
||||
entity.setCustomerAccountName(item.getCustomerName());
|
||||
|
||||
// 5. 特殊字段处理
|
||||
entity.setMetaJson(null); // 根据文档要求强制设为 null
|
||||
|
||||
// 注意:project_id 需要在 Service 层根据业务逻辑设置
|
||||
|
||||
return entity;
|
||||
} catch (Exception e) {
|
||||
log.error("流水数据转换失败, bankStatementId={}", item.getBankStatementId(), e);
|
||||
throw new RuntimeException("流水数据转换失败", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user