Я могу создать файл, но выходной файл не содержит разделителя, он имеет разделитель фиксированной длины. Как мне использовать мой разделитель, указанный в beanio json
Ниже приведен код, который я пытался записать в файл, но он не дает ожидаемого результата
String qualifiedChannelName = programId + "_" + channel;
BeanWriter out = factory.createWriter(qualifiedChannelName, new File("D:\\dataengine\\files\\40287a35725ae63e0172934c765d0014\\tm.txt"));
for (Transaction e : transactions) {
out.write(e);
}
out.flush();
out.close();
Это это мой формат файла bean io
[ { \"key\": \"beanio.transaction.sku.streamname\", \"value\": \"SKU\" }, { \"key\": \"beanio.transaction.payment.streamname\", \"value\": \"PAYMENT\" }, { \"key\": \"transaction.payment.identifier\", \"value\": \"12\" }, { \"key\": \"transaction.sku.identifier\", \"value\": \"11\" }, { \"key\": \"create.ghost.customer.from.card\", \"value\": \"true\" }, { \"key\": \"beanio.fileHeadercustomer.streamname\", \"value\": \"Header\" }, { \"key\": \"tenant.useHeader\", \"value\": \"false\" }, { \"key\": \"beanio.fileHeaderTransaction.streamname\", \"value\": \"Header\" }, { \"key\": \"transaction.fileheader.identifier\", \"value\": \"00\" }, { \"key\": \"beanio.card.streamname\", \"value\": \"Card\" }, { \"key\": \"customer.record.identifier\", \"value\": \"10\" }, { \"key\": \"beanio.transaction.streamname\", \"value\": \"Transaction\" }, { \"key\": \"card.fileheader.identifier\", \"value\": \"00\" }, { \"key\": \"customer.fileheader.identifier\", \"value\": \"00\" }, { \"key\": \"beanio.account.streamname\", \"value\": \"\" }, { \"key\": \"beanio.configuration\", \"value\": \"\\u003C?xml version=\\\"1.0\\\"?> <beanio xmlns=\\\"http://www.beanio.org/2012/03\\\" xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" xsi:schemaLocation=\\\"http://www.beanio.org/2012/03 http://www.beanio.org/2012/03/mapping.xsd\\\"> <stream name=\\\"40287a35725ae63e0172934c765d0014_AJIO_ONLINE\\\" format=\\\"delimited\\\"> <parser class=\\\"com.loylty.dataacquisition.util.CustomDelimitedBeanIOParserFactory\\\"> <property name=\\\"customDelimiter\\\" value=\\\"\\\\\\\\^\\\"><\\/property> <\\/parser> <typeHandler type=\\\"java.util.Date\\\" class=\\\"com.loylty.dataacquisition.util.CustomDateTypeHandler\\\"> <property name=\\\"pattern\\\" value=\\\"dd-MMM-yyyy\\\"/> <\\/typeHandler> <typeHandler type=\\\"java.math.BigDecimal\\\" class=\\\"com.loylty.dataacquisition.util.BigDecimalHandler\\\"/> <typeHandler name=\\\"negativeHandler\\\" class=\\\"com.loylty.dataacquisition.util.NegativeBigDecimalHandler\\\"/> <record name=\\\"Transaction\\\" class=\\\"com.loylty.dataacquisition.entities.Transaction\\\" maxLength=\\\"17\\\" minLength=\\\"17\\\" > <field name=\\\"paymentProcessor\\\" trim=\\\"true\\\" lazy=\\\"true\\\" maxLength=\\\"100\\\" /> <field name=\\\"transactionId\\\" trim=\\\"true\\\" lazy=\\\"true\\\" maxLength=\\\"100\\\" /> <field name=\\\"merchantName\\\" trim=\\\"true\\\" lazy=\\\"true\\\" maxLength=\\\"100\\\" /> <field name=\\\"merchantTransactionId\\\" trim=\\\"true\\\" lazy=\\\"true\\\" maxLength=\\\"100\\\" /> <field name=\\\"terminalId\\\" trim=\\\"true\\\" lazy=\\\"true\\\" maxLength=\\\"100\\\" /> <field name=\\\"merchantId\\\" trim=\\\"true\\\" lazy=\\\"true\\\" maxLength=\\\"100\\\" /> <field name=\\\"terminalOwnerName\\\" trim=\\\"true\\\" lazy=\\\"true\\\" maxLength=\\\"100\\\" /> <field name=\\\"first6DigitCard\\\" trim=\\\"true\\\" lazy=\\\"true\\\" maxLength=\\\"100\\\" /> <field name=\\\"last4DigitCard\\\" trim=\\\"true\\\" lazy=\\\"true\\\" maxLength=\\\"100\\\" /> <field name=\\\"cardTypeCode\\\" trim=\\\"true\\\" lazy=\\\"true\\\" maxLength=\\\"100\\\" /> <field name=\\\"cardIssuer\\\" trim=\\\"true\\\" lazy=\\\"true\\\" maxLength=\\\"100\\\" /> <field name=\\\"acquirerId\\\" trim=\\\"true\\\" lazy=\\\"true\\\" maxLength=\\\"100\\\" /> <field name=\\\"transactionType\\\" trim=\\\"true\\\" lazy=\\\"true\\\" maxLength=\\\"100\\\" /> <field name=\\\"transactionAmount\\\" trim=\\\"true\\\" lazy=\\\"true\\\" maxLength=\\\"100\\\" /> <field name=\\\"transactionDate\\\" trim=\\\"true\\\" lazy=\\\"true\\\" maxLength=\\\"100\\\" /> <field name=\\\"transactionTime\\\" regex=\\\"([01]?[0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9]\\\" trim=\\\"true\\\" lazy=\\\"true\\\" maxLength=\\\"100\\\" /> <field name=\\\"postDate\\\" trim=\\\"true\\\" lazy=\\\"true\\\" maxLength=\\\"100\\\" /> <\\/record> <\\/stream> <stream name=\\\"40287a35725ae63e0172934c765d0014_AJIO_ONLINE_REFUND\\\" format=\\\"delimited\\\"> <parser class=\\\"com.loylty.dataacquisition.util.CustomDelimitedBeanIOParserFactory\\\"> <property name=\\\"customDelimiter\\\" value=\\\"\\\\\\\\^\\\"><\\/property> <\\/parser> <typeHandler type=\\\"java.util.Date\\\" class=\\\"com.loylty.dataacquisition.util.CustomDateTypeHandler\\\"> <property name=\\\"pattern\\\" value=\\\"dd-MMM-yyyy\\\"/> <\\/typeHandler> <typeHandler type=\\\"java.math.BigDecimal\\\" class=\\\"com.loylty.dataacquisition.util.BigDecimalHandler\\\"/> <typeHandler name=\\\"negativeHandler\\\" class=\\\"com.loylty.dataacquisition.util.NegativeBigDecimalHandler\\\"/> <record name=\\\"Transaction\\\" class=\\\"com.loylty.dataacquisition.entities.Transaction\\\" maxLength=\\\"17\\\" minLength=\\\"17\\\" > <field name=\\\"paymentProcessor\\\" trim=\\\"true\\\" lazy=\\\"true\\\" maxLength=\\\"100\\\" /> <field name=\\\"transactionId\\\" trim=\\\"true\\\" lazy=\\\"true\\\" maxLength=\\\"100\\\" /> <field name=\\\"merchantName\\\" trim=\\\"true\\\" lazy=\\\"true\\\" maxLength=\\\"100\\\" /> <field name=\\\"merchantTransactionId\\\" trim=\\\"true\\\" lazy=\\\"true\\\" maxLength=\\\"100\\\" /> <field name=\\\"terminalId\\\" trim=\\\"true\\\" lazy=\\\"true\\\" maxLength=\\\"100\\\" /> <field name=\\\"merchantId\\\" trim=\\\"true\\\" lazy=\\\"true\\\" maxLength=\\\"100\\\" /> <field name=\\\"terminalOwnerName\\\" trim=\\\"true\\\" lazy=\\\"true\\\" maxLength=\\\"100\\\" /> <field name=\\\"first6DigitCard\\\" trim=\\\"true\\\" lazy=\\\"true\\\" maxLength=\\\"100\\\" /> <field name=\\\"last4DigitCard\\\" trim=\\\"true\\\" lazy=\\\"true\\\" maxLength=\\\"100\\\" /> <field name=\\\"cardTypeCode\\\" trim=\\\"true\\\" lazy=\\\"true\\\" maxLength=\\\"100\\\" /> <field name=\\\"cardIssuer\\\" trim=\\\"true\\\" lazy=\\\"true\\\" maxLength=\\\"100\\\" /> <field name=\\\"acquirerId\\\" trim=\\\"true\\\" lazy=\\\"true\\\" maxLength=\\\"100\\\" /> <field name=\\\"transactionType\\\" trim=\\\"true\\\" lazy=\\\"true\\\" maxLength=\\\"100\\\" /> <field name=\\\"transactionAmount\\\" trim=\\\"true\\\" lazy=\\\"true\\\" maxLength=\\\"100\\\" /> <field name=\\\"transactionDate\\\" trim=\\\"true\\\" lazy=\\\"true\\\" maxLength=\\\"100\\\" /> <field name=\\\"transactionTime\\\" regex=\\\"([01]?[0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9]\\\" trim=\\\"true\\\" lazy=\\\"true\\\" maxLength=\\\"100\\\" /> <field name=\\\"postDate\\\" trim=\\\"true\\\" lazy=\\\"true\\\" maxLength=\\\"100\\\" /> <\\/record> <\\/stream> <\\/beanio>\\r\\n\" }, { \"key\": \"beanio.fileHeaderaccount.streamname\", \"value\": \"\" }, { \"key\": \"account.fileheader.identifier\", \"value\": \"00\" }, { \"key\": \"beanio.customer.streamname\", \"value\": \"Customer\" }, { \"key\": \"account.record.identifier\", \"value\": \"11\" }, { \"key\": \"card.record.identifier\", \"value\": \"12\" }, { \"key\": \"camel.routes\", \"value\": \"\\u003C?xml version=\\\"1.0\\\"?> <routes xmlns=\\\"http://camel.apache.org/schema/spring\\\"> <route startupOrder=\\\"1\\\" id=\\\"download\\\" autoStartup=\\\"false\\\"> <from uri=\\\"sftp://lradmin@192.168.250.204:22/../../../../files/40287a35725ae63e0172934c765d0014/sftp?password=Lrp@1234&sendEmptyMessageWhenIdle=true&move=.done&delay=15000&readLock=readLockCheckInterval&disconnectOnBatchComplete=true\\\" /> <choice> <when> <simple>${header.CamelFileNameOnly} == null<\\/simple> <\\/when> <otherwise> <to uri =\\\"file:/dataengine/files/40287a35725ae63e0172934c765d0014\\\" /> <\\/otherwise> <\\/choice> <onCompletion> <filter> <log message=\\\"download thread completed\\\"><\\/log> <simple>${property.CamelBatchComplete} == true<\\/simple> <to uri=\\\"direct:completeddownload\\\"/> <\\/filter> <\\/onCompletion> <\\/route> <route id=\\\"handback\\\" autoStartup=\\\"false\\\"> <from uri =\\\"file:/dataengine/files/40287a35725ae63e0172934c765d0014?include=.*\\\\.handback&delay=15000&sendEmptyMessageWhenIdle=true\\\" /> <choice> <when> <simple>${body} == null<\\/simple> <\\/when> <otherwise> <to uri=\\\"sftp://lradmin@192.168.250.204:22/../../files/40287a35725ae63e0172934c765d0014/handback?password=Lrp@1234&sendEmptyMessageWhenIdle=true&disconnectOnBatchComplete=true\\\" /> <\\/otherwise> <\\/choice> <onCompletion> <filter> <log message=\\\"HandBack thread completed\\\"><\\/log> <simple>${property.CamelBatchComplete} == true<\\/simple> <to uri=\\\"direct:completedhandback\\\"/> <\\/filter> <\\/onCompletion> <\\/route> <route> <from uri=\\\"direct:completeddownload\\\" /> <to uri=\\\"controlbus:route?routeId=download&action=stop&async=true\\\" /> <\\/route> <route> <from uri=\\\"direct:completedhandback\\\" /> <to uri=\\\"controlbus:route?routeId=handback&action=stop&async=true\\\" /> <\\/route> <route startupOrder=\\\"2\\\" id=\\\"AJIO_ONLINE\\\" autoStartup=\\\"false\\\"> <from uri=\\\"file:/dataengine/files/40287a35725ae63e0172934c765d0014/?include=POS.*\\\\.txt&sendEmptyMessageWhenIdle=true&delay=5000&sortBy=date:file:yyyyMMdd;file:name\\\"/> <onCompletion> <filter> <simple>${property.CamelBatchComplete} == true<\\/simple> <to uri=\\\"direct:completedAJIO_ONLINE\\\"/> <\\/filter> <\\/onCompletion> <setHeader headerName=\\\"fileType\\\"> <simple>TRANSACTION<\\/simple> <\\/setHeader> <setheader headerName=\\\"channel\\\"> <simple>AJIO_ONLINE<\\/simple> <\\/setheader> <setHeader headerName=\\\"programId\\\"> <simple>40287a35725ae63e0172934c765d0014<\\/simple> <\\/setHeader> <to uri=\\\"bean:genericFileProcessorImpl?method=processOnlinePartner\\\"/> <\\/route> <route> <from uri=\\\"direct:completedAJIO_ONLINE\\\" /> <to uri=\\\"controlbus:route?routeId=AJIO_ONLINE&action=stop&async=true\\\" /> <\\/route> <route startupOrder=\\\"3\\\" id=\\\"AJIO_ONLINE_REFUND\\\" autoStartup=\\\"false\\\"> <from uri=\\\"file:/dataengine/files/40287a35725ae63e0172934c765d0014/?include=refundpos.*\\\\.txt&sendEmptyMessageWhenIdle=true&delay=5000&sortBy=date:file:yyyyMMdd;file:name\\\"/> <onCompletion> <filter> <simple>${property.CamelBatchComplete} == true<\\/simple> <to uri=\\\"direct:completedAJIO_ONLINE_REFUND\\\"/> <\\/filter> <\\/onCompletion> <setHeader headerName=\\\"fileType\\\"> <simple>REFUND<\\/simple> <\\/setHeader> <setheader headerName=\\\"channel\\\"> <simple>AJIO_ONLINE_REFUND<\\/simple> <\\/setheader> <setHeader headerName=\\\"programId\\\"> <simple>40287a35725ae63e0172934c765d0014<\\/simple> <\\/setHeader> <to uri=\\\"bean:genericFileProcessorImpl?method=processOnlinePartner\\\"/> <\\/route> <route> <from uri=\\\"direct:completedAJIO_ONLINE_REFUND\\\" /> <to uri=\\\"controlbus:route?routeId=AJIO_ONLINE_REFUND&action=stop&async=true\\\" /> <\\/route> <\\/routes>\" }, { \"key\": \"create.ghost.account.from.card\", \"value\": \"true\" }, { \"key\": \"beanio.fileHeadercard.streamname\", \"value\": \"\" }, { \"key\": \"transaction.record.identifier\", \"value\": \"10\" } ]
ТРАНЗАКЦИЯ. JAVA
public class Transaction {
private String header;
private String uniqueCustomerId;
private String debitCardnumber;
private String first4digitAccountnumber;
private String last4digitsAccountnumber;
private String terminalId;
private String merchantId;
private Date transactionDate;
private String transactionTime;
private String postDate;
private String terminalLocation;
private String terminalOwnerName;
private String terminalCity;
private String terminalState;
private String terminalCountry;
private BigDecimal transactionAmount;
private String transactionId;
private String acquirerId;
private String first6DigitCard;
private String last4DigitCard;
private String merchantCategorycode;
private String transactionType;
private boolean isCardValidated = false;
private boolean isAccountValidated = false;
private boolean isCustomerValidated = false;
private boolean isBinValidated = false;
private String accountNumber;
private String storeId;
private String storeCode;
private String cashier;
private String posId;
private String source;
private String isSuccessful;
private String responseCode;
private String currencyCode;
private BigDecimal fee;
private String addressLine1;
private String addressLine2;
private BigDecimal settlementAmount;
private String zip;
private String atmTransactionType;
// BOM
private String cardTypeCode;
// Transaction Meta info
private String fileName; // supplied by camel in exchange object
private String channel; // supplied by client during config
private FileType objectType; // supplied by client during config
// Some random attributes ?
private BigDecimal transactionInitialAmount;
private BigDecimal vatAmount;
private BigDecimal redeemAmount;
private BigDecimal voucherAmount;
public String getCardTypeCode() {
return cardTypeCode;
}
public void setCardTypeCode(String cardTypeCode) {
this.cardTypeCode = cardTypeCode;
}
private BigDecimal netPayable;
private BigDecimal tax;
private BigDecimal discountAmount;
private BigDecimal redeemedAmount;
private String redemptionReferenceId;
private String recordData;
// Refund related attributes
private String originalTransactionId;
private Date originalTransactionDate;
private String originalTransactionTime;
private BigDecimal originalAmount;
// Non-transaction attributes
private String eventName;
private String eventCategory;
private int points;
private List<TransactionPayment> transactionPayments;
private List<TransactionSKU> transactionSKUs;
private Map<String, Float> transactionTax;
private int version;
private BigDecimal adjustmentAmount;
// Yes DC
private String primaryCardIdentifier;
// PHFL and HDFC Exclusive
private String category;
private String product;
// TMB
private String isOnlineTransaction;
private Long fileId;
// AJIO(ONLINE_PARTNER TXNS field)
private String merchantName;
private String merchantTransactionId;
private String cardIssuer;
private String lrTransactionId;
private String partnerProgramId;
private String paymentProcessor;
}
СУЩЕСТВУЮЩИЙ ВЫХОД
BILLDESK RUR28350404633 AJIO pay_sp_4a7caa2b-28bf-11ea-83ae-f1c5f19c7fb3 BDR00001 0000000BDR00001 AJIO 324145 4164 SALE 1401.0 24-Mar-2020 13:58:52
ОЖИДАЕМЫЙ ВЫХОД
BILLDESK^RUR28350404633^AJIO^pay_sp_4a7caa2b-28bf-11ea-83ae-f1c5f19c7fb3^BDR00001^0000000BDR00001^AJIO^324145^4164^SALE^1401.0^24-Mar-2020^13:58:52^