Subversion Repositories SmartDukaan

Rev

Rev 34409 | Rev 34568 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 34409 Rev 34516
Line 1545... Line 1545...
1545
                coi.setCatalogId(Integer.parseInt(record.get(1)));
1545
                coi.setCatalogId(Integer.parseInt(record.get(1)));
1546
                coi.setSchemePayout(Integer.parseInt(record.get(2)));
1546
                coi.setSchemePayout(Integer.parseInt(record.get(2)));
1547
                coi.setDealerPayout(Integer.parseInt(record.get(3)));
1547
                coi.setDealerPayout(Integer.parseInt(record.get(3)));
1548
                coi.setOfferType(OfferType.valueOf(record.get(6)));
1548
                coi.setOfferType(OfferType.valueOf(record.get(6)));
1549
                coi.setCustomerOfferId(offerId);
1549
                coi.setCustomerOfferId(offerId);
-
 
1550
                coi.setAdditionalInfo(String.valueOf(record.get(7)));
1550
                coi.setCreatedTimestamp(LocalDateTime.now());
1551
                coi.setCreatedTimestamp(LocalDateTime.now());
1551
 
1552
 
1552
                customerOfferItemRepository.persist(coi);
1553
                customerOfferItemRepository.persist(coi);
1553
 
1554
 
1554
            }
1555
            }
1555
            coi.setSchemePayout(Integer.parseInt(record.get(2)));
1556
            coi.setSchemePayout(Integer.parseInt(record.get(2)));
1556
            coi.setDealerPayout(Integer.parseInt(record.get(3)));
1557
            coi.setDealerPayout(Integer.parseInt(record.get(3)));
1557
            coi.setOfferType(OfferType.valueOf(record.get(6)));
1558
            coi.setOfferType(OfferType.valueOf(record.get(6)));
-
 
1559
            coi.setAdditionalInfo(String.valueOf(record.get(7)));
1558
            coi.setCustomerOfferId(offerId);
1560
            coi.setCustomerOfferId(offerId);
1559
            coi.setUpdatedTimestamp(LocalDateTime.now());
1561
            coi.setUpdatedTimestamp(LocalDateTime.now());
1560
 
1562
 
1561
            LOGGER.info(record.get(4));
1563
            LOGGER.info(record.get(4));
1562
 
1564
 
Line 1625... Line 1627...
1625
        LocalDate startDate = customerOfferItemModel.getStartDate().toLocalDate();
1627
        LocalDate startDate = customerOfferItemModel.getStartDate().toLocalDate();
1626
        LocalDate endDate = customerOfferItemModel.getEndDate().toLocalDate();
1628
        LocalDate endDate = customerOfferItemModel.getEndDate().toLocalDate();
1627
        CustomerOfferItem coi = new CustomerOfferItem();
1629
        CustomerOfferItem coi = new CustomerOfferItem();
1628
        coi.setCatalogId(customerOfferItemModel.getCatalogId());
1630
        coi.setCatalogId(customerOfferItemModel.getCatalogId());
1629
        coi.setSchemePayout(customerOfferItemModel.getSchemePayout());
1631
        coi.setSchemePayout(customerOfferItemModel.getSchemePayout());
-
 
1632
        coi.setAdditionalInfo(customerOfferItemModel.getAdditionalInfo());
1630
        coi.setDealerPayout(customerOfferItemModel.getDealerPayout());
1633
        coi.setDealerPayout(customerOfferItemModel.getDealerPayout());
1631
        coi.setOfferType(customerOfferItemModel.getOfferType());
1634
        coi.setOfferType(customerOfferItemModel.getOfferType());
1632
        coi.setCustomerOfferId(customerOfferItemModel.getOfferId());
1635
        coi.setCustomerOfferId(customerOfferItemModel.getOfferId());
1633
        coi.setUpdatedTimestamp(LocalDateTime.now());
1636
        coi.setUpdatedTimestamp(LocalDateTime.now());
1634
        coi.setCreatedTimestamp(LocalDateTime.now());
1637
        coi.setCreatedTimestamp(LocalDateTime.now());
Line 1676... Line 1679...
1676
        List<List<?>> rows = new ArrayList<>();
1679
        List<List<?>> rows = new ArrayList<>();
1677
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd-MM-yyyy");
1680
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd-MM-yyyy");
1678
 
1681
 
1679
        for (CustomerOfferItem coi : cois) {
1682
        for (CustomerOfferItem coi : cois) {
1680
            rows.add(Arrays.asList(coi.getId(), coi.getCatalogId(), coi.getSchemePayout(), coi.getDealerPayout(),
1683
            rows.add(Arrays.asList(coi.getId(), coi.getCatalogId(), coi.getSchemePayout(), coi.getDealerPayout(),
1681
                    coi.getStartDate().format(formatter), coi.getEndDate().format(formatter), coi.getOfferType()));
1684
                    coi.getStartDate().format(formatter), coi.getEndDate().format(formatter), coi.getOfferType(), coi.getAdditionalInfo()));
1682
 
1685
 
1683
        }
1686
        }
1684
 
1687
 
1685
        org.apache.commons.io.output.ByteArrayOutputStream baos = FileUtil.getCSVByteStream(
1688
        org.apache.commons.io.output.ByteArrayOutputStream baos = FileUtil.getCSVByteStream(
1686
                Arrays.asList("id", "Catalog Id", "Scheme Payout", "Dealer Payout", "Start Date", "End Date", "Offer Type"), rows);
1689
                Arrays.asList("id", "Catalog Id", "Scheme Payout", "Dealer Payout", "Start Date", "End Date", "Offer Type", "Additional Info"), rows);
1687
 
1690
 
1688
        final HttpHeaders headers = new HttpHeaders();
1691
        final HttpHeaders headers = new HttpHeaders();
1689
        headers.set("Content-Type", "text/csv");
1692
        headers.set("Content-Type", "text/csv");
1690
        headers.set("Content-disposition", "inline; filename=customer-offer-template.csv");
1693
        headers.set("Content-disposition", "inline; filename=customer-offer-template.csv");
1691
        headers.setContentLength(baos.toByteArray().length);
1694
        headers.setContentLength(baos.toByteArray().length);