diff --git a/micro-modules/micro-bfs/pom.xml b/micro-modules/micro-bfs/pom.xml index af34113..fa37e93 100644 --- a/micro-modules/micro-bfs/pom.xml +++ b/micro-modules/micro-bfs/pom.xml @@ -159,7 +159,11 @@ com.sinosoft micro-common-mq - + + com.oracle.database.jdbc + ojdbc11 + 21.9.0.0 + diff --git a/micro-modules/micro-bfs/src/main/java/com/sinosoft/bfs/config/EbsDataSourceConfig.java b/micro-modules/micro-bfs/src/main/java/com/sinosoft/bfs/config/EbsDataSourceConfig.java new file mode 100644 index 0000000..4fa7a01 --- /dev/null +++ b/micro-modules/micro-bfs/src/main/java/com/sinosoft/bfs/config/EbsDataSourceConfig.java @@ -0,0 +1,47 @@ +package com.sinosoft.bfs.config; + +import com.zaxxer.hikari.HikariDataSource; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import javax.sql.DataSource; + +import org.springframework.context.annotation.Configuration; +@Configuration +public class EbsDataSourceConfig { + /* @Value("${ebs.datasource.url}") + private String url; + + @Value("${ebs.datasource.username}") + private String username; + + @Value("${ebs.datasource.password}") + private String password; + + @Value("${ebs.datasource.driver-class-name:oracle.jdbc.OracleDriver}") + private String driverClassName; + + @Value("${ebs.datasource.maximum-pool-size:10}") + private int maximumPoolSize; + + @Value("${ebs.datasource.minimum-idle:5}") + private int minimumIdle; + + @Bean(name = "ebsDataSource") + public DataSource ebsDataSource() { + HikariDataSource dataSource = new HikariDataSource(); + dataSource.setJdbcUrl(url); + dataSource.setUsername(username); + dataSource.setPassword(password); + dataSource.setDriverClassName(driverClassName); + dataSource.setMaximumPoolSize(maximumPoolSize); + dataSource.setMinimumIdle(minimumIdle); + dataSource.setConnectionTimeout(30000); + dataSource.setIdleTimeout(600000); + dataSource.setMaxLifetime(1800000); + dataSource.addDataSourceProperty("cachePrepStmts", "true"); + dataSource.addDataSourceProperty("prepStmtCacheSize", "250"); + dataSource.addDataSourceProperty("prepStmtCacheSqlLimit", "2048"); + return dataSource; + } +*/ +} diff --git a/micro-modules/micro-bfs/src/main/java/com/sinosoft/bfs/controller/FIBusnessQuryController.java b/micro-modules/micro-bfs/src/main/java/com/sinosoft/bfs/controller/FIBusnessQuryController.java index f389082..89583e5 100644 --- a/micro-modules/micro-bfs/src/main/java/com/sinosoft/bfs/controller/FIBusnessQuryController.java +++ b/micro-modules/micro-bfs/src/main/java/com/sinosoft/bfs/controller/FIBusnessQuryController.java @@ -7,6 +7,7 @@ import com.alibaba.fastjson.JSONObject; import com.sinosoft.bfs.api.domain.bo.RemoteSupplierInfoBo; import com.sinosoft.bfs.api.domain.vo.RemoteSupplierInfoVo; import com.sinosoft.bfs.core.datatrans.FindataToGather; +import com.sinosoft.bfs.core.datatrans.GatherToEbs; import com.sinosoft.bfs.core.datatrans.GatherToSap; import com.sinosoft.bfs.domain.FiBusinessData; import com.sinosoft.bfs.domain.bo.*; @@ -45,6 +46,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.concurrent.CompletableFuture; +import java.util.stream.Collectors; /** * 业务查询控制器 @@ -71,7 +73,8 @@ public class FIBusnessQuryController { private final RemoteManageComService manageComService; private final IFiBusinessDataService fiBusinessDataService; private final ExportTaskManager exportTaskManager; - + private final GatherToEbs gatherToEbs; + private final IFiCerdataGatherService gatherService; /** * 科目余额查询 @@ -166,7 +169,14 @@ public class FIBusnessQuryController { @PostMapping("/accountingCertificateId") public R accountingCertificateId(AccountingGatherBo bo) { findataToGather.convertToGather(bo); - gatherToSap.SendToSAP(); + // gatherToSap.SendToSAP(); + //需要考虑借贷一致,也需要考虑会不会数据太多导致系统OOM,所以考虑按凭证类型处理 + List certificateList = gatherService.getCertificate(); + for (String certificate : certificateList) { + List gatherVoList = gatherService.queryListByCertificate(certificate); + gatherToEbs.sendToEbs(gatherVoList); + } + return R.ok(); } diff --git a/micro-modules/micro-bfs/src/main/java/com/sinosoft/bfs/core/datatrans/GatherToEbs.java b/micro-modules/micro-bfs/src/main/java/com/sinosoft/bfs/core/datatrans/GatherToEbs.java new file mode 100644 index 0000000..1c05dfd --- /dev/null +++ b/micro-modules/micro-bfs/src/main/java/com/sinosoft/bfs/core/datatrans/GatherToEbs.java @@ -0,0 +1,52 @@ +package com.sinosoft.bfs.core.datatrans; + + +import com.sinosoft.bfs.core.constant.BFSConstants; +import com.sinosoft.bfs.domain.vo.FiCerdataGatherVo; +import com.sinosoft.bfs.service.IEbsVoucherPushService; +import com.sinosoft.bfs.service.IFiCerdataGatherService; +import com.sinosoft.common.core.exception.ServiceException; +import groovy.util.logging.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.cloud.context.config.annotation.RefreshScope; +import org.springframework.stereotype.Service; +import java.util.List; + +import static cn.dev33.satoken.SaManager.log; + +@Service +@Slf4j +@RefreshScope +public class GatherToEbs { + @Autowired + private IFiCerdataGatherService gatherService; + + @Autowired + private IEbsVoucherPushService iEbsVoucherPushService; + + + + + public void sendToEbs(List value) { + try { + log.info("开始推送凭证到EBS,共{}条数据", value.size()); + iEbsVoucherPushService.pushVouchersToEbs(value); + value.forEach(vo -> { + vo.setStatus(BFSConstants.STATUS_SUCCESS); + vo.setReturnType("S"); + vo.setReturnMsg("成功推送到EBS"); + }); + gatherService.updateBatch(value); + log.info("成功推送{}条凭证到EBS", value.size()); + } catch (Exception e) { + log.error("推送凭证到EBS失败", e); + value.forEach(vo -> { + vo.setStatus(BFSConstants.STATUS_FAILED); + vo.setReturnMsg("推送EBS失败:" + e.getMessage()); + }); + gatherService.updateBatch(value); + throw new ServiceException("推送凭证到EBS失败:" + e.getMessage()); + } + } + +} diff --git a/micro-modules/micro-bfs/src/main/java/com/sinosoft/bfs/domain/EbsGlInterface.java b/micro-modules/micro-bfs/src/main/java/com/sinosoft/bfs/domain/EbsGlInterface.java new file mode 100644 index 0000000..6dc3e82 --- /dev/null +++ b/micro-modules/micro-bfs/src/main/java/com/sinosoft/bfs/domain/EbsGlInterface.java @@ -0,0 +1,83 @@ +package com.sinosoft.bfs.domain; + +import lombok.Data; +import lombok.Getter; +import lombok.Setter; + +import java.math.BigDecimal; +import java.util.Date; +@Setter +@Getter +public class EbsGlInterface { + private Long interfaceId; + private String status; + private String ledgerFlag; + private Date accountingDate; + private String currencyCode; + private Date dateCreated; + private String actualFlag; + private String sourceBatchId; + private Long sourceLineId; + private String userJeCategoryName; + private String userJeSourceName; + private Date currencyConversionDate; + private String userCurrencyConversionType; + private BigDecimal currencyConversionRate; + private String importFlag; + private Date importDate; + private String errorMessage; + private Date lastUpdateDate; + private String docSeqNum; + private String createdBy; + private String lastUpdateBy; + private String segment1; + private String segment2; + private String segment3; + private String segment4; + private String segment5; + private String segment6; + private String segment7; + private String segment8; + private String segment9; + private String segment10; + private String segment11; + private BigDecimal enteredDr; + private BigDecimal enteredCr; + private BigDecimal accountedDr; + private BigDecimal accountedCr; + private Long docSequenceValue; + private String reference1; + private String reference2; + private String reference3; + private String reference4; + private String reference5; + private String reference10; + private Long jeBatchId; + private String periodName; + private Long jeHeaderId; + private Long jeLineNum; + private Long chartOfAccountsId; + private String functionalCurrencyCode; + private String warningCode; + private BigDecimal statAmount; + private Long groupId; + private Long requestId; + private Long setOfBooksId; + private String attributeCategory; + private String attribute1; + private String attribute2; + private String attribute3; + private String attribute4; + private String attribute5; + private String attribute6; + private String attribute7; + private String attribute8; + private String attribute9; + private String attribute10; + private String attribute11; + private String attribute12; + private String attribute13; + private String attribute14; + private String attribute15; + +} diff --git a/micro-modules/micro-bfs/src/main/java/com/sinosoft/bfs/service/IEbsVoucherPushService.java b/micro-modules/micro-bfs/src/main/java/com/sinosoft/bfs/service/IEbsVoucherPushService.java new file mode 100644 index 0000000..5f6657d --- /dev/null +++ b/micro-modules/micro-bfs/src/main/java/com/sinosoft/bfs/service/IEbsVoucherPushService.java @@ -0,0 +1,9 @@ +package com.sinosoft.bfs.service; +import com.sinosoft.bfs.domain.vo.FiCerdataGatherVo; + +import java.util.List; +public interface IEbsVoucherPushService { + void pushVouchersToEbs(List voucherList); + + void pushVouchersToEbsByBatchNo(List voucherList); +} diff --git a/micro-modules/micro-bfs/src/main/java/com/sinosoft/bfs/service/impl/EbsVoucherPushServiceImpl.java b/micro-modules/micro-bfs/src/main/java/com/sinosoft/bfs/service/impl/EbsVoucherPushServiceImpl.java new file mode 100644 index 0000000..e5835e7 --- /dev/null +++ b/micro-modules/micro-bfs/src/main/java/com/sinosoft/bfs/service/impl/EbsVoucherPushServiceImpl.java @@ -0,0 +1,332 @@ +package com.sinosoft.bfs.service.impl; +import com.sinosoft.bfs.domain.EbsGlInterface; +import com.sinosoft.bfs.domain.vo.FiCerdataGatherVo; +import com.sinosoft.bfs.service.IEbsVoucherPushService; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import java.math.BigDecimal; +import java.sql.*; +import java.time.LocalDate; +import java.time.format.DateTimeFormatter; +import java.util.Date; +import java.util.List; +import java.util.concurrent.atomic.AtomicLong; + +import static cn.dev33.satoken.SaManager.log; +@Service +public class EbsVoucherPushServiceImpl implements IEbsVoucherPushService{ + // private final DataSource ebsDataSource; + + @Value("${ebs.sequence.interface_id:CUX_GL_INTERFACE_GRP_S}") + private String interfaceIdSequence; + + @Value("${ebs.default.ledger_flag:old}") + private String defaultLedgerFlag; + + @Value("${ebs.default.actual_flag:A}") + private String defaultActualFlag; + + @Value("${ebs.default.currency_code:CNY}") + private String defaultCurrencyCode; + + @Value("${ebs.default.user_je_category_name:General}") + private String defaultJeCategoryName; + + @Value("${ebs.default.user_je_source_name:BFS}") + private String defaultJeSourceName; + + @Value("${ebs.default.currency_conversion_type:USER}") + private String defaultCurrencyConversionType; + + @Value("${ebs.default.import_flag:N}") + private String defaultImportFlag; + + @Value("${ebs.default.created_by:BFS_SYSTEM}") + private String defaultCreatedBy; + + @Value("${ebs.chart_of_accounts_id:101}") + private Long defaultChartOfAccountsId; + + @Value("${ebs.set_of_books_id:1}") + private Long defaultSetOfBooksId; + + private static final AtomicLong sequenceGenerator = new AtomicLong(0); + +/* public EbsVoucherPushServiceImpl(@Qualifier("ebsDataSource") DataSource ebsDataSource) { + this.ebsDataSource = ebsDataSource; + }*/ + + @Override + @Transactional(rollbackFor = Exception.class) + public void pushVouchersToEbs(List voucherList) { + if (voucherList == null || voucherList.isEmpty()) { + log.warn("凭证列表为空,无需推送"); + return; + } + + log.info("开始推送凭证到EBS,共{}条数据", voucherList.size()); + + String sql = buildInsertSql(); + + /*try (Connection conn = ebsDataSource.getConnection(); + PreparedStatement pstmt = conn.prepareStatement(sql)) { + + conn.setAutoCommit(false); + + int batchCount = 0; + for (FiCerdataGatherVo voucher : voucherList) { + try { + EbsGlInterface ebsData = convertToEbsInterface(voucher); + setParameters(pstmt, ebsData); + pstmt.addBatch(); + batchCount++; + + if (batchCount % 100 == 0) { + pstmt.executeBatch(); + log.info("已批量插入{}条凭证数据", batchCount); + } + } catch (Exception e) { + log.error("转换凭证数据失败,voucherId:{}", voucher.getId(), e); + throw new RuntimeException("转换凭证数据失败", e); + } + } + + if (batchCount % 100 != 0) { + pstmt.executeBatch(); + } + + conn.commit(); + log.info("成功推送{}条凭证到EBS", voucherList.size()); + + } catch (SQLException e) { + log.error("推送凭证到EBS失败", e); + throw new RuntimeException("推送凭证到EBS失败", e); + }*/ + } + + @Override + public void pushVouchersToEbsByBatchNo(List voucherList) { + pushVouchersToEbs(voucherList); + } + + private String buildInsertSql() { + return "INSERT INTO CUX.CUX_GL_INTERFACE_GRP (" + + "INTERFACE_ID, STATUS, LEDGER_FLAG, ACCOUNTING_DATE, CURRENCY_CODE, " + + "DATE_CREATED, ACTUAL_FLAG, SOURCE_BATCH_ID, SOURCE_LINE_ID, " + + "USER_JE_CATEGORY_NAME, USER_JE_SOURCE_NAME, CURRENCY_CONVERSION_DATE, " + + "USER_CURRENCY_CONVERSION_TYPE, CURRENCY_CONVERSION_RATE, IMPORT_FLAG, " + + "IMPORT_DATE, ERROR_MESSAGE, LAST_UPDATE_DATE, DOC_SEQ_NUM, CREATED_BY, " + + "LAST_UPDATE_BY, SEGMENT1, SEGMENT2, SEGMENT3, SEGMENT4, SEGMENT5, " + + "SEGMENT6, SEGMENT7, SEGMENT8, SEGMENT9, SEGMENT10, SEGMENT11, " + + "ENTERED_DR, ENTERED_CR, ACCOUNTED_DR, ACCOUNTED_CR, DOC_SEQUENCE_VALUE, " + + "REFERENCE1, REFERENCE2, REFERENCE3, REFERENCE4, REFERENCE5, REFERENCE10, " + + "JE_BATCH_ID, PERIOD_NAME, JE_HEADER_ID, JE_LINE_NUM, CHART_OF_ACCOUNTS_ID, " + + "FUNCTIONAL_CURRENCY_CODE, WARNING_CODE, STAT_AMOUNT, GROUP_ID, REQUEST_ID, " + + "SET_OF_BOOKS_ID, ATTRIBUTE_CATEGORY, ATTRIBUTE1, ATTRIBUTE2, ATTRIBUTE3, " + + "ATTRIBUTE4, ATTRIBUTE5, ATTRIBUTE6, ATTRIBUTE7, ATTRIBUTE8, ATTRIBUTE9, " + + "ATTRIBUTE10, ATTRIBUTE11, ATTRIBUTE12, ATTRIBUTE13, ATTRIBUTE14, ATTRIBUTE15" + + ") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, " + + "?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, " + + "?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; + } + + private EbsGlInterface convertToEbsInterface(FiCerdataGatherVo voucher) { + EbsGlInterface ebs = new EbsGlInterface(); + + long interfaceId = generateInterfaceId(); + ebs.setInterfaceId(interfaceId); + ebs.setStatus("NEW"); + ebs.setLedgerFlag(defaultLedgerFlag); + ebs.setAccountingDate(voucher.getAccountDate()); + ebs.setCurrencyCode(defaultCurrencyCode); + ebs.setDateCreated(new Date()); + ebs.setActualFlag(defaultActualFlag); + + String sourceBatchId = generateSourceBatchId(voucher); + ebs.setSourceBatchId(sourceBatchId); + ebs.setSourceLineId(interfaceId); + // 凭证类别名称 + ebs.setUserJeCategoryName(voucher.getCertificateId()); + // 凭证来源名称 + ebs.setUserJeSourceName(defaultJeSourceName); + ebs.setCurrencyConversionDate(voucher.getAccountDate()); + ebs.setUserCurrencyConversionType(defaultCurrencyConversionType); + ebs.setCurrencyConversionRate(BigDecimal.ONE); + ebs.setImportFlag(defaultImportFlag); + ebs.setImportDate(null); + ebs.setErrorMessage(null); + ebs.setLastUpdateDate(new Date()); + ebs.setDocSeqNum(String.valueOf(interfaceId)); + ebs.setCreatedBy(null); + ebs.setLastUpdateBy(null); + + setSegments(ebs, voucher); + + if (isDebit(voucher)) { + ebs.setEnteredDr(voucher.getAmount()); + ebs.setEnteredCr(BigDecimal.ZERO); + ebs.setAccountedDr(voucher.getAmount()); + ebs.setAccountedCr(BigDecimal.ZERO); + } else { + ebs.setEnteredDr(BigDecimal.ZERO); + ebs.setEnteredCr(voucher.getAmount()); + ebs.setAccountedDr(BigDecimal.ZERO); + ebs.setAccountedCr(voucher.getAmount()); + } + + ebs.setDocSequenceValue(interfaceId); + //待定,凭证批名规则后续与财务沟通确定 + //ebs.setReference1(voucher.getBatchNo()); + //可为空,批描述后续与财务沟通确定 + // ebs.setReference2(voucher.getCertificateId() + "-" + voucher.getCertificateName()); + ebs.setReference3(voucher.getManageCom()); + ebs.setReference4(voucher.getCostCenter()); + ebs.setReference5(voucher.getFinItemCode()); + //凭证行摘要,具体摘要需要何信息待财务确定 + // ebs.setReference10(voucher.getBusinessDataId() != null ? String.valueOf(voucher.getBusinessDataId()) : null); + + String periodName = extractPeriodName(voucher.getAccountDate()); + ebs.setPeriodName(periodName); + + ebs.setChartOfAccountsId(null); + ebs.setFunctionalCurrencyCode(null); + ebs.setWarningCode(null); + ebs.setStatAmount(BigDecimal.ZERO); + ebs.setGroupId(null); + ebs.setRequestId(null); + ebs.setSetOfBooksId(null); + + setAttributes(ebs, voucher); + + return ebs; + } + + private void setParameters(PreparedStatement pstmt, EbsGlInterface ebs) throws SQLException { + int index = 1; + pstmt.setLong(index++, ebs.getInterfaceId()); + pstmt.setString(index++, ebs.getStatus()); + pstmt.setString(index++, ebs.getLedgerFlag()); + pstmt.setDate(index++, ebs.getAccountingDate() != null ? new java.sql.Date(ebs.getAccountingDate().getTime()) : null); + pstmt.setString(index++, ebs.getCurrencyCode()); + pstmt.setDate(index++, ebs.getDateCreated() != null ? new java.sql.Date(ebs.getDateCreated().getTime()) : null); + pstmt.setString(index++, ebs.getActualFlag()); + pstmt.setString(index++, ebs.getSourceBatchId()); + pstmt.setLong(index++, ebs.getSourceLineId()); + pstmt.setString(index++, ebs.getUserJeCategoryName()); + pstmt.setString(index++, ebs.getUserJeSourceName()); + pstmt.setDate(index++, ebs.getCurrencyConversionDate() != null ? new java.sql.Date(ebs.getCurrencyConversionDate().getTime()) : null); + pstmt.setString(index++, ebs.getUserCurrencyConversionType()); + pstmt.setBigDecimal(index++, ebs.getCurrencyConversionRate()); + pstmt.setString(index++, ebs.getImportFlag()); + pstmt.setDate(index++, ebs.getImportDate() != null ? new java.sql.Date(ebs.getImportDate().getTime()) : null); + pstmt.setString(index++, ebs.getErrorMessage()); + pstmt.setDate(index++, ebs.getLastUpdateDate() != null ? new java.sql.Date(ebs.getLastUpdateDate().getTime()) : null); + pstmt.setString(index++, ebs.getDocSeqNum()); + pstmt.setString(index++, ebs.getCreatedBy()); + pstmt.setString(index++, ebs.getLastUpdateBy()); + + pstmt.setString(index++, ebs.getSegment1()); + pstmt.setString(index++, ebs.getSegment2()); + pstmt.setString(index++, ebs.getSegment3()); + pstmt.setString(index++, ebs.getSegment4()); + pstmt.setString(index++, ebs.getSegment5()); + pstmt.setString(index++, ebs.getSegment6()); + pstmt.setString(index++, ebs.getSegment7()); + pstmt.setString(index++, ebs.getSegment8()); + pstmt.setString(index++, ebs.getSegment9()); + pstmt.setString(index++, ebs.getSegment10()); + pstmt.setString(index++, ebs.getSegment11()); + + pstmt.setBigDecimal(index++, ebs.getEnteredDr()); + pstmt.setBigDecimal(index++, ebs.getEnteredCr()); + pstmt.setBigDecimal(index++, ebs.getAccountedDr()); + pstmt.setBigDecimal(index++, ebs.getAccountedCr()); + pstmt.setLong(index++, ebs.getDocSequenceValue() != null ? ebs.getDocSequenceValue() : 0); + + pstmt.setString(index++, ebs.getReference1()); + pstmt.setString(index++, ebs.getReference2()); + pstmt.setString(index++, ebs.getReference3()); + pstmt.setString(index++, ebs.getReference4()); + pstmt.setString(index++, ebs.getReference5()); + pstmt.setString(index++, ebs.getReference10()); + + pstmt.setLong(index++, ebs.getJeBatchId() != null ? ebs.getJeBatchId() : 0); + pstmt.setString(index++, ebs.getPeriodName()); + pstmt.setLong(index++, ebs.getJeHeaderId() != null ? ebs.getJeHeaderId() : 0); + pstmt.setLong(index++, ebs.getJeLineNum() != null ? ebs.getJeLineNum() : 0); + pstmt.setLong(index++, ebs.getChartOfAccountsId()); + pstmt.setString(index++, ebs.getFunctionalCurrencyCode()); + pstmt.setString(index++, ebs.getWarningCode()); + pstmt.setBigDecimal(index++, ebs.getStatAmount()); + pstmt.setLong(index++, ebs.getGroupId() != null ? ebs.getGroupId() : 0); + pstmt.setLong(index++, ebs.getRequestId() != null ? ebs.getRequestId() : 0); + pstmt.setLong(index++, ebs.getSetOfBooksId()); + pstmt.setString(index++, ebs.getAttributeCategory()); + pstmt.setString(index++, ebs.getAttribute1()); + pstmt.setString(index++, ebs.getAttribute2()); + pstmt.setString(index++, ebs.getAttribute3()); + pstmt.setString(index++, ebs.getAttribute4()); + pstmt.setString(index++, ebs.getAttribute5()); + pstmt.setString(index++, ebs.getAttribute6()); + pstmt.setString(index++, ebs.getAttribute7()); + pstmt.setString(index++, ebs.getAttribute8()); + pstmt.setString(index++, ebs.getAttribute9()); + pstmt.setString(index++, ebs.getAttribute10()); + pstmt.setString(index++, ebs.getAttribute11()); + pstmt.setString(index++, ebs.getAttribute12()); + pstmt.setString(index++, ebs.getAttribute13()); + pstmt.setString(index++, ebs.getAttribute14()); + pstmt.setString(index++, ebs.getAttribute15()); + } + + private long generateInterfaceId() { + return System.currentTimeMillis() * 1000 + sequenceGenerator.incrementAndGet(); + } + + private String generateSourceBatchId(FiCerdataGatherVo voucher) { + // return "BFS_" + voucher.getBatchNo() + "_" + System.currentTimeMillis(); + return "BFS_" + "_" + System.currentTimeMillis(); + } + + private void setSegments(EbsGlInterface ebs, FiCerdataGatherVo voucher) { + ebs.setSegment1(voucher.getManageCom()); + ebs.setSegment2(voucher.getCostCenter()); + ebs.setSegment3(voucher.getFinItemCode()); + ebs.setSegment4(voucher.getIntraBranch()); + ebs.setSegment5(voucher.getReconCode()); + ebs.setSegment6(voucher.getRiskCode()); + ebs.setSegment7(voucher.getCashFlow()); + ebs.setSegment8(""); + ebs.setSegment9(""); + ebs.setSegment10(""); + ebs.setSegment11(""); + } + + private void setAttributes(EbsGlInterface ebs, FiCerdataGatherVo voucher) { + ebs.setAttributeCategory("BFS_VOUCHER"); + ebs.setAttribute1(voucher.getId() != null ? String.valueOf(voucher.getId()) : null); + ebs.setAttribute2(voucher.getCertificateId()); + ebs.setAttribute3(voucher.getCostId()); + ebs.setAttribute4(voucher.getFiscalYear()); + ebs.setAttribute5(voucher.getFiscalMonth()); + ebs.setAttribute6(voucher.getVchrSmmry()); + ebs.setAttribute7(voucher.getTaxCode()); + ebs.setAttribute8(voucher.getTaxRate()); + ebs.setAttribute9(voucher.getBudget()); + ebs.setAttribute10(voucher.getAccountMark()); + } + + private boolean isDebit(FiCerdataGatherVo voucher) { + return "D".equals(voucher.getFinItemType()) || "借".equals(voucher.getFinItemType()); + } + + private String extractPeriodName(Date accountDate) { + if (accountDate == null) { + return LocalDate.now().format(DateTimeFormatter.ofPattern("yyyy-MM")); + } + LocalDate localDate = new java.sql.Date(accountDate.getTime()).toLocalDate(); + return localDate.format(DateTimeFormatter.ofPattern("yyyy-MM")); + } + +} diff --git a/micro-modules/micro-bfs/src/main/resources/application.yml b/micro-modules/micro-bfs/src/main/resources/application.yml index 42c86a9..deaef13 100644 --- a/micro-modules/micro-bfs/src/main/resources/application.yml +++ b/micro-modules/micro-bfs/src/main/resources/application.yml @@ -35,3 +35,31 @@ spring: - optional:nacos:datasource.yml - optional:nacos:external-systems.yml - optional:nacos:${spring.application.name}.yml +# EBS数据库配置 +##ebs: + ## datasource: + ## url: jdbc:oracle:thin:@//10.1.205.100:1521/EBSDB + ## username: apps + ## password: your_password + ## driver-class-name: oracle.jdbc.OracleDriver + ## maximum-pool-size: 10 + ## minimum-idle: 5 + + # 序列名称(如果使用Oracle序列) + ## sequence: + ## interface_id: CUX_GL_INTERFACE_GRP_S + + # 默认值配置 + ##default: + ## ledger_flag: old + ## actual_flag: A + ## currency_code: CNY + ## user_je_category_name: General + ## user_je_source_name: BFS + ## currency_conversion_type: USER + ## import_flag: N + ## created_by: BFS_SYSTEM + + # 会计科目结构ID + ## chart_of_accounts_id: 101 + ## set_of_books_id: 1