package gr.piraeusbank.max.parser.parser.ergo; import com.opencsv.bean.CsvToBean; import…
- User
package gr.piraeusbank.max.parser.parser.ergo;
import com.opencsv.bean.CsvToBean; import com.opencsv.bean.CsvToBeanBuilder; import gr.piraeusbank.max.parser.domain.intranet.csv.ergo.ErgoDetailImportMappingStrategy; import gr.piraeusbank.max.parser.domain.intranet.csv.ergo.ErgoHeaderImportMappingStrategy; import gr.piraeusbank.max.parser.exception.MaxParserException; import gr.piraeusbank.max.parser.parser.MaxParser; import gr.piraeusbank.max.parser.parser.ParserErrors; import gr.piraeusbank.max.parser.service.MaxWrapperDb; import gr.piraeusbank.max.parser.util.Cache; import gr.piraeusbank.max.parser.util.Transform; import io.lsn.meru.importmodel.domain.holder.ImportRecord; import io.lsn.meru.importmodel.domain.invoice.Invoice; import io.lsn.meru.importmodel.domain.policy.Policy; import lombok.extern.slf4j.Slf4j;
import java.io.; import java.nio.charset.Charset; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.util.; import java.util.function.Function; import java.util.stream.Collectors; import java.util.stream.Stream;
@Slf4j public class ErgoAutoParser extends ErgoParser implements MaxParser { private final String marketLob; private final Integer year; private final Integer month; private final String daysRange; private final MaxWrapperDb maxWrapperDb; private List headerPathList; private List detailPathList; private List parsedHeaderEntries = new ArrayList<>(); private List parsedDetailEntries = new ArrayList<>(); private final ParserErrors parserErrors = new ParserErrors();
codepublic ErgoAutoParser(String marketLob, Integer year, Integer month, String daysRange, MaxWrapperDb maxWrapperDb) { this.marketLob = marketLob; this.year = year; this.month = month; this.daysRange = daysRange; this.maxWrapperDb = maxWrapperDb; } private String getPath() { return "//2869s3/ReportsBlueByte/001 BACK OFFICE ΗΛΕΚΤΡΟΝΙΚΑ ΑΡΧΕΙΑ/ERGO/" + year + "/" + Transform.transformIntegerToGreekMonth(month) + '/' + daysRange + "/"; } @Override public MaxParser readInput() throws Exception { log.info("Reading Header Data TXT files from path: {}", getPath()); List<String> filePaths = getFilePathsList(); getHeaderAndDetailPathList(filePaths);/* // Perhaps do the read input for all the processes of parsing the headers and details // Do the magic for this batch final CompletableFuture future = new CompletableFuture<>(); futures.add(future); threadPool.submit(() -> {*/
- Assistant
Based on the provided code, I see that the values for
commissions paandcommissions pbare assigned to the same variablesinvoice.setCommissionPa(new BigDecimal(replaceDoubleQuotesAndCommas(line[6])))andinvoice.setCommissionPb(new BigDecimal(replaceDoubleQuotesAndCommas(line[8])))respectively.To resolve this issue, you need to make sure that you are assigning the correct values from the CSV file to the respective variables. Double-check the indices of the columns in the CSV file that correspond to
commissions paandcommissions pband update the code accordingly.If the indices are correct, you should also check the values in the CSV file to ensure that they are indeed different for
commissions paandcommissions pb. If the values in the CSV file are the same, that would explain why they are being assigned the same value in the code. - User
- Assistant
Based on the provided code, it seems that you are using two separate
CsvToBeanBuilderinstances with different mapping strategies (ErgoHeaderImportMappingStrategyandErgoDetailImportMappingStrategy) for parsing the header and detail CSV files. Since both mapping strategies implement the sameMappingStrategy<ImportRecord>interface, there shouldn't be any conflicts when it comes to obtainingImportRecordobjects after parsing.The
CsvToBeaninstances created by theCsvToBeanBuilderwill use the appropriate mapping strategy based on the builder used. Therefore, when you callcsvToBean.parse(), it will parse the CSV file using the corresponding mapping strategy and return a list ofImportRecordobjects specific to that mapping