Subversion Repositories SmartDukaan

Rev

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

Rev 29709 Rev 29711
Line 1491... Line 1491...
1491
 
1491
 
1492
	@Autowired
1492
	@Autowired
1493
	PartnerTypeChangeService partnerTypeChangeService;
1493
	PartnerTypeChangeService partnerTypeChangeService;
1494
	public void runMe() {
1494
	public void runMe() {
1495
		System.out.println("runme ==== " +   fofoOrderItemRepository.selectSumMopGroupByRetailer(LocalDate.of(2021, 11, 1).atStartOfDay(), LocalDate.of(2021, 12, 1).atStartOfDay(), 175138408, false));
1495
		System.out.println("runme ==== " +   fofoOrderItemRepository.selectSumMopGroupByRetailer(LocalDate.of(2021, 11, 1).atStartOfDay(), LocalDate.of(2021, 12, 1).atStartOfDay(), 175138408, false));
1496
		System.out.println("change " + 
-
 
1497
 
-
 
1498
	private Map<CreateOfferRequest, List<PartnerTargetModel>> parseFromExcel(String fileName) throws ProfitMandiBusinessException {
-
 
1499
 
-
 
1500
		Map<CreateOfferRequest, List<PartnerTargetModel>> offerPartnerTargetMap =  new HashMap<>();
-
 
1501
		XSSFWorkbook myWorkBook = null;
-
 
1502
		try {
-
 
1503
			FileInputStream fileInputStream = new FileInputStream(fileName);
-
 
1504
			myWorkBook = new XSSFWorkbook(fileInputStream);
-
 
1505
			myWorkBook.setMissingCellPolicy(MissingCellPolicy.RETURN_BLANK_AS_NULL);
-
 
1506
			for(int i=0; i< myWorkBook.getNumberOfSheets();i++) {
-
 
1507
				
-
 
1508
				XSSFSheet mySheet = myWorkBook.getSheetAt(i);
-
 
1509
				int offerId = Integer.parseInt(mySheet.getSheetName());
-
 
1510
				CreateOfferRequest existingOffer = offerService.getOffer(offerId);
-
 
1511
				List<PartnerTargetModel> partnerTargetModels = new ArrayList<>();
-
 
1512
				offerPartnerTargetMap.put(existingOffer, partnerTargetModels);
-
 
1513
 
-
 
1514
				LOGGER.info("rowCellNum {}", mySheet.getLastRowNum());
-
 
1515
				for (int rowNumber = 1; rowNumber <= mySheet.getLastRowNum(); rowNumber++) {
-
 
1516
					XSSFRow row = mySheet.getRow(rowNumber);
-
 
1517
					LOGGER.info("row {}", row);
-
 
1518
					PartnerTargetModel partnerTargetModel = new PartnerTargetModel();
-
 
1519
 
-
 
1520
					if (row.getCell(0) != null && row.getCell(0).getCellTypeEnum() == CellType.NUMERIC) {
-
 
1521
						partnerTargetModel.setFofoId((int) row.getCell(0).getNumericCellValue());
-
 
1522
					} else {
-
 
1523
						ProfitMandiBusinessException profitMandiBusinessException = new ProfitMandiBusinessException(
-
 
1524
								"FOFO ID", row.getCell(0).toString(), "TGLSTNG_VE_1010");
-
 
1525
						LOGGER.error("Excel file parse error : ", profitMandiBusinessException);
-
 
1526
						throw profitMandiBusinessException;
-
 
1527
					}
-
 
1528
					List<Integer> targets = new ArrayList<>();
-
 
1529
					for (int cellNumber = 1; cellNumber <= existingOffer.getTargetSlabs().size(); cellNumber++) {
-
 
1530
						if (row.getCell(cellNumber) != null
-
 
1531
								&& row.getCell(cellNumber).getCellTypeEnum() == CellType.NUMERIC) {
-
 
1532
							targets.add((int) row.getCell(cellNumber).getNumericCellValue());
-
 
1533
						} else {
-
 
1534
							ProfitMandiBusinessException profitMandiBusinessException = new ProfitMandiBusinessException(
-
 
1535
									"Target Column issue at " + rowNumber + ", " + cellNumber, row.getCell(cellNumber),
-
 
1536
									"Invalid target");
-
 
1537
							LOGGER.error("Excel file parse error : ", profitMandiBusinessException);
-
 
1538
							throw profitMandiBusinessException;
-
 
1539
						}
-
 
1540
					}
-
 
1541
					partnerTargetModel.setTargets(targets);
-
 
1542
					partnerTargetModels.add(partnerTargetModel);
-
 
1543
				}
-
 
1544
			}
-
 
1545
			myWorkBook.close();
-
 
1546
		} catch ( ProfitMandiBusinessException pbse) {
-
 
1547
			throw pbse;
-
 
1548
		} catch (IOException ioException) {
-
 
1549
			ioException.printStackTrace();
-
 
1550
			throw new ProfitMandiBusinessException(ProfitMandiConstants.EXCEL_FILE, ioException.getMessage(),
-
 
1551
					"EXL_VE_1000");
-
 
1552
		} finally {
-
 
1553
			if (myWorkBook != null) {
-
 
1554
				try {
-
 
1555
					myWorkBook.close();
-
 
1556
				} catch (IOException e) {
-
 
1557
					// TODO Auto-generated catch block
-
 
1558
					e.printStackTrace();
-
 
1559
				}
-
 
1560
			}
-
 
1561
		}
-
 
1562
		LOGGER.info("offerPartnerTargetMap {}", offerPartnerTargetMap);
-
 
1563
		return offerPartnerTargetMap;
-
 
1564
	}
-
 
1565
  partnerTypeChangeService.getTypeOnDate(175138408, LocalDate.now()));
1496
		System.out.println("change " +  partnerTypeChangeService.getTypeOnDate(175138408, LocalDate.now()));
1566
	}
1497
	}
1567
 
1498
 
1568
	public void createOffers(FileInputStream stream) throws Exception {
1499
	public void createOffers(FileInputStream stream) throws Exception {
1569
		offerService.createOffers(stream);
1500
		offerService.createOffers(stream);
1570
	}
1501
	}