| Line 718... |
Line 718... |
| 718 |
} catch (IOException ioException) {
|
718 |
} catch (IOException ioException) {
|
| 719 |
LOGGER.error("Unable to generate excel file", ioException);
|
719 |
LOGGER.error("Unable to generate excel file", ioException);
|
| 720 |
}
|
720 |
}
|
| 721 |
}
|
721 |
}
|
| 722 |
|
722 |
|
| 723 |
public static List<PartnerTargetModel> parseFromExcel(InputStream inputStream) throws Exception {
|
- |
|
| 724 |
|
- |
|
| 725 |
List<PartnerTargetModel> partnerTargetModels = new ArrayList<>();
|
- |
|
| 726 |
XSSFWorkbook myWorkBook = null;
|
- |
|
| 727 |
try {
|
- |
|
| 728 |
// FileInputStream fileInputStream = new
|
- |
|
| 729 |
// FileInputStream("/home/ashikali/tag_listing1.xlsx");
|
- |
|
| 730 |
myWorkBook = new XSSFWorkbook(inputStream);
|
- |
|
| 731 |
|
- |
|
| 732 |
myWorkBook.setMissingCellPolicy(MissingCellPolicy.RETURN_BLANK_AS_NULL);
|
- |
|
| 733 |
// Return first sheet from the XLSX workbook
|
- |
|
| 734 |
XSSFSheet mySheet = myWorkBook.getSheetAt(0);
|
- |
|
| 735 |
LOGGER.info("rowCellNum {}", mySheet.getLastRowNum());
|
- |
|
| 736 |
|
- |
|
| 737 |
for (int rowNumber = 1; rowNumber <= mySheet.getLastRowNum(); rowNumber++) {
|
- |
|
| 738 |
XSSFRow row = mySheet.getRow(rowNumber);
|
- |
|
| 739 |
LOGGER.info("row {}", row);
|
- |
|
| 740 |
PartnerTargetModel partnerTargetModel = new PartnerTargetModel();
|
- |
|
| 741 |
|
- |
|
| 742 |
if (row.getCell(0) != null && row.getCell(0).getCellTypeEnum() == CellType.NUMERIC) {
|
- |
|
| 743 |
partnerTargetModel.setFofoId((int) row.getCell(0).getNumericCellValue());
|
- |
|
| 744 |
} else {
|
- |
|
| 745 |
ProfitMandiBusinessException profitMandiBusinessException = new ProfitMandiBusinessException(
|
- |
|
| 746 |
FOFO_ID, row.getCell(0).toString(), "TGLSTNG_VE_1010");
|
- |
|
| 747 |
LOGGER.error("Excel file parse error : ", profitMandiBusinessException);
|
- |
|
| 748 |
throw profitMandiBusinessException;
|
- |
|
| 749 |
}
|
- |
|
| 750 |
if (row.getCell(3) != null && row.getCell(3).getCellTypeEnum() == CellType.NUMERIC) {
|
- |
|
| 751 |
partnerTargetModel.setTargetValue((int) row.getCell(3).getNumericCellValue());
|
- |
|
| 752 |
} else {
|
- |
|
| 753 |
ProfitMandiBusinessException profitMandiBusinessException = new ProfitMandiBusinessException(
|
- |
|
| 754 |
TARGET_VALUE, row.getCell(8), "TGLSTNG_VE_1010");
|
- |
|
| 755 |
LOGGER.error("Excel file parse error : ", profitMandiBusinessException);
|
- |
|
| 756 |
throw profitMandiBusinessException;
|
- |
|
| 757 |
}
|
- |
|
| 758 |
|
- |
|
| 759 |
partnerTargetModels.add(partnerTargetModel);
|
- |
|
| 760 |
}
|
- |
|
| 761 |
myWorkBook.close();
|
- |
|
| 762 |
} catch (IOException ioException) {
|
- |
|
| 763 |
ioException.printStackTrace();
|
- |
|
| 764 |
throw new ProfitMandiBusinessException(ProfitMandiConstants.EXCEL_FILE, ioException.getMessage(),
|
- |
|
| 765 |
"EXL_VE_1000");
|
- |
|
| 766 |
} finally {
|
- |
|
| 767 |
if (myWorkBook != null) {
|
- |
|
| 768 |
try {
|
- |
|
| 769 |
myWorkBook.close();
|
- |
|
| 770 |
} catch (IOException e) {
|
- |
|
| 771 |
// TODO Auto-generated catch block
|
- |
|
| 772 |
e.printStackTrace();
|
- |
|
| 773 |
}
|
- |
|
| 774 |
}
|
- |
|
| 775 |
}
|
- |
|
| 776 |
return partnerTargetModels;
|
- |
|
| 777 |
}
|
- |
|
| 778 |
|
- |
|
| 779 |
public static void writeDailySaleReportVsTargetForPartner(Map<Integer, String> targetIdAndTargetNameMap,
|
723 |
public static void writeDailySaleReportVsTargetForPartner(Map<Integer, String> targetIdAndTargetNameMap,
|
| 780 |
Map<Integer, Float> targetIdAndtargetValuesMap, Map<Integer, Double> targetIdAndsaleValuesMap,
|
724 |
Map<Integer, Float> targetIdAndtargetValuesMap, Map<Integer, Double> targetIdAndsaleValuesMap,
|
| 781 |
Map<Integer, CustomRetailer> targetIdAndCustomRetailerMap, Map<Integer, String> targetIdAndSlabNamesMap,
|
725 |
Map<Integer, CustomRetailer> targetIdAndCustomRetailerMap, Map<Integer, String> targetIdAndSlabNamesMap,
|
| 782 |
Map<Integer, Double> targetIdAndsaleValuesPercentageMap,
|
726 |
Map<Integer, Double> targetIdAndsaleValuesPercentageMap,
|
| 783 |
Map<Integer, Float> targetIdAndtargetdailyAverageSaleMap,
|
727 |
Map<Integer, Float> targetIdAndtargetdailyAverageSaleMap,
|