Subversion Repositories SmartDukaan

Rev

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

Rev 30133 Rev 30209
Line 1... Line 1...
1
package com.smartdukaan.cron.migrations;
1
package com.smartdukaan.cron.migrations;
2
 
2
 
3
import com.google.gson.Gson;
3
import com.google.gson.Gson;
-
 
4
import com.smartdukaan.cron.scheduled.OppoImeiActivationService;
4
import com.smartdukaan.cron.scheduled.SamsungIMEIActivationService;
5
import com.smartdukaan.cron.scheduled.SamsungIMEIActivationService;
5
import com.smartdukaan.cron.scheduled.ScheduledTasks;
6
import com.smartdukaan.cron.scheduled.ScheduledTasks;
6
import com.spice.profitmandi.common.enumuration.ItemType;
7
import com.spice.profitmandi.common.enumuration.ItemType;
7
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
8
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
8
import com.spice.profitmandi.common.model.CustomRetailer;
9
import com.spice.profitmandi.common.model.CustomRetailer;
Line 140... Line 141...
140
 
141
 
141
	@Autowired
142
	@Autowired
142
	private PaymentOptionTransactionRepository paymentOptionTransactionRepository;
143
	private PaymentOptionTransactionRepository paymentOptionTransactionRepository;
143
 
144
 
144
	@Autowired
145
	@Autowired
-
 
146
	private OppoImeiActivationService oppoImeiActivationService;
-
 
147
 
-
 
148
	@Autowired
145
	private SamsungIMEIActivationService samsungActivationService;
149
	private SamsungIMEIActivationService samsungIMEIActivationService;
146
 
150
 
147
	@Autowired
151
	@Autowired
148
	private PrebookingOrderRepository prebookingOrderRepository;
152
	private PrebookingOrderRepository prebookingOrderRepository;
149
 
153
 
150
	@Autowired
154
	@Autowired
Line 291... Line 295...
291
			endDate = LocalDate.now();
295
			endDate = LocalDate.now();
292
		} else {
296
		} else {
293
			startDate = LocalDate.now().minusMonths(ym);
297
			startDate = LocalDate.now().minusMonths(ym);
294
			endDate = startDate.plusMonths(1);
298
			endDate = startDate.plusMonths(1);
295
		}
299
		}
296
		samsungActivationService.getActivationsBetweenNew(startDate, endDate);
300
		samsungIMEIActivationService.getActivationsBetweenNew(startDate, endDate);
297
	}
301
	}
298
 
302
 
299
	public void migarateLineItemsToNewTable() throws Exception {
303
	public void migarateLineItemsToNewTable() throws Exception {
300
		LOGGER.info("Before Migrated LineItems Successfully");
304
		LOGGER.info("Before Migrated LineItems Successfully");
301
		int lineItemImeiId = 0;
305
		int lineItemImeiId = 0;
Line 460... Line 464...
460
		changePartnerInvoices();
464
		changePartnerInvoices();
461
		ByteArrayOutputStream baos = FileUtil
465
		ByteArrayOutputStream baos = FileUtil
462
				.getCSVByteStream(Arrays.asList("Order id", "Challan", "Invoice", "Quantity"), rows);
466
				.getCSVByteStream(Arrays.asList("Order id", "Challan", "Invoice", "Quantity"), rows);
463
 
467
 
464
		Utils.sendMailWithAttachment(googleMailSender,
468
		Utils.sendMailWithAttachment(googleMailSender,
465
				new String[] { "amit.gupta@shop2020.in", "sunny.yadav@smartdukaan.com" }, null,
469
				new String[]{"amit.gupta@shop2020.in", "sunny.yadav@smartdukaan.com"}, null,
466
				"Challans Converted to Invoice", "PFA", "Challans-To-Invoice.csv",
470
				"Challans Converted to Invoice", "PFA", "Challans-To-Invoice.csv",
467
				new ByteArrayResource(baos.toByteArray()));
471
				new ByteArrayResource(baos.toByteArray()));
468
		throw new Exception();
472
		throw new Exception();
469
	}
473
	}
470
 
474
 
Line 628... Line 632...
628
		driver.manage().deleteAllCookies();
632
		driver.manage().deleteAllCookies();
629
		// Specifiying pageLoadTimeout and Implicit wait
633
		// Specifiying pageLoadTimeout and Implicit wait
630
		driver.manage().timeouts().pageLoadTimeout(40, TimeUnit.SECONDS);
634
		driver.manage().timeouts().pageLoadTimeout(40, TimeUnit.SECONDS);
631
		driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
635
		driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
632
 
636
 
633
		Map<String, Set<Integer>> authUserPartnerIdMapping = csService.getAuthUserPartnerIdMapping();
637
		Map<String, List<Integer>> authUserPartnerIdMapping = csService.getAuthUserPartnerIdMapping();
634
		Set<Integer> allPartners = new HashSet<>();
638
		Set<Integer> allPartners = new HashSet<>();
635
		Map<Integer, File> partnerSnapshotMap = new HashMap<>();
639
		Map<Integer, File> partnerSnapshotMap = new HashMap<>();
636
		authUserPartnerIdMapping.values().stream().forEach(x -> allPartners.addAll(x));
640
		authUserPartnerIdMapping.values().stream().forEach(x -> allPartners.addAll(x));
637
		System.out.println(allPartners.size());
-
 
638
		for (int fofoId : allPartners) {
641
		for (int fofoId : allPartners) {
639
			driver.get("https://partners.smartdukaan.com/12dashboard34?fofoId=" + fofoId);
642
			driver.get("https://partners.smartdukaan.com/12dashboard34?fofoId=" + fofoId);
640
			File file = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE);
643
			File file = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE);
641
			partnerSnapshotMap.put(fofoId, file);
644
			partnerSnapshotMap.put(fofoId, file);
642
 
645
 
643
		}
646
		}
644
		for (Map.Entry<String, Set<Integer>> entry : authUserPartnerIdMapping.entrySet()) {
647
		for (Map.Entry<String, List<Integer>> entry : authUserPartnerIdMapping.entrySet()) {
645
			String email = entry.getKey();
648
			String email = entry.getKey();
646
			LOGGER.info("Sending mail start to {}", email);
649
			LOGGER.info("Sending mail start to {}", email);
647
			Set<Integer> partnerIds = entry.getValue();
650
			List<Integer> partnerIds = entry.getValue();
648
			StringBuffer body = new StringBuffer();
651
			StringBuffer body = new StringBuffer();
649
			Map<Integer, File> emailSnapshotMap = new HashMap<>();
652
			Map<Integer, File> emailSnapshotMap = new HashMap<>();
650
			for (int fofoId : partnerIds) {
653
			for (int fofoId : partnerIds) {
651
				body.append(String.format("<br/><img src=\"cid:%d\"/>", fofoId));
654
				body.append(String.format("<br/><img src=\"cid:%d\"/>", fofoId));
652
				emailSnapshotMap.put(fofoId, partnerSnapshotMap.get(fofoId));
655
				emailSnapshotMap.put(fofoId, partnerSnapshotMap.get(fofoId));
653
			}
656
			}
654
			Utils.sendEmbeddedHtmlMail(mailSender, new String[] { email }, new String[] {},
657
			Utils.sendEmbeddedHtmlMail(mailSender, new String[]{email}, new String[]{},
655
					String.format("Franchise Screenshots - %s", FormattingUtils.formatDate(LocalDateTime.now())),
658
					String.format("Franchise Screenshots - %s", FormattingUtils.formatDate(LocalDateTime.now())),
656
					body.toString(), emailSnapshotMap);
659
					body.toString(), emailSnapshotMap);
657
			LOGGER.info("Sent mail to {}", email);
660
			LOGGER.info("Sent mail to {}", email);
658
		}
661
		}
659
		driver.quit();
662
		driver.quit();
Line 962... Line 965...
962
				LocalDateTime.now().minusDays(15), LocalDateTime.now().plusHours(4)));
965
				LocalDateTime.now().minusDays(15), LocalDateTime.now().plusHours(4)));
963
	}
966
	}
964
 
967
 
965
	public void removeDuplicateOrders() throws Exception {
968
	public void removeDuplicateOrders() throws Exception {
966
		List<String> invoiceNumbers = Arrays.asList(/*
969
		List<String> invoiceNumbers = Arrays.asList(/*
967
													 * "DLWE066/1108", "DLWE066/299", "DLWE066/348", "HRFB004/242",
970
				 * "DLWE066/1108", "DLWE066/299", "DLWE066/348", "HRFB004/242",
968
													 * "HRFB004/243", "HRFB004/514", "HRFTB155/29", "HRJND076/1146",
971
				 * "HRFB004/243", "HRFB004/514", "HRFTB155/29", "HRJND076/1146",
969
													 * "HRJND076/966", "HRKA134/295", "HRKA134/421", "HRKK091/381",
972
				 * "HRJND076/966", "HRKA134/295", "HRKA134/421", "HRKK091/381",
970
													 * "HRMGH106/576", "HRSP056/139", "HRYN030/103", "UPGZ019/395",
973
				 * "HRMGH106/576", "HRSP056/139", "HRYN030/103", "UPGZ019/395",
971
													 * "UPHRD130/1299", "UPHRD130/456", "UPHRD130/634", "UPLKO063/897",
974
				 * "UPHRD130/1299", "UPHRD130/456", "UPHRD130/634", "UPLKO063/897",
972
													 * "UPMRT149/54", "UPSJP119/748", "UPSJP119/980", "UPSTP065/1218",
975
				 * "UPMRT149/54", "UPSJP119/748", "UPSJP119/980", "UPSTP065/1218",
973
													 * "UPSTP065/2039", "UPSTP090/437", "UPSTP120/164",
976
				 * "UPSTP065/2039", "UPSTP090/437", "UPSTP120/164",
974
													 */
977
				 */
975
				"HRMGH106/1576");
978
				"HRMGH106/1576");
976
 
979
 
977
		int totalAmount = 0;
980
		int totalAmount = 0;
978
		float saleAmount = 0;
981
		float saleAmount = 0;
979
		float schemeReverseAmount = 0;
982
		float schemeReverseAmount = 0;
Line 1099... Line 1102...
1099
		 * for (int i = 0; i < ja.length(); i++) { JSONObject c = ja.getJSONObject(i);
1102
		 * for (int i = 0; i < ja.length(); i++) { JSONObject c = ja.getJSONObject(i);
1100
		 * String geofenceId = c.getString("geofence_id"); LOGGER.info("geofenceId" +
1103
		 * String geofenceId = c.getString("geofence_id"); LOGGER.info("geofenceId" +
1101
		 * geofenceId); FofoStoreGeofence fsg = new FofoStoreGeofence();
1104
		 * geofenceId); FofoStoreGeofence fsg = new FofoStoreGeofence();
1102
		 * fsg.setFofoId(customRetailer.getPartnerId()); fsg.setGeofenceId(geofenceId);
1105
		 * fsg.setFofoId(customRetailer.getPartnerId()); fsg.setGeofenceId(geofenceId);
1103
		 * fofoStoreGeofenceRepository.persist(fsg); }
1106
		 * fofoStoreGeofenceRepository.persist(fsg); }
1104
		 * 
1107
		 *
1105
		 * }
1108
		 * }
1106
		 * 
1109
		 *
1107
		 * }
1110
		 * }
1108
		 */
1111
		 */
1109
 
1112
 
1110
	}
1113
	}
1111
 
1114
 
Line 1197... Line 1200...
1197
				.collect(Collectors.groupingBy(WarehouseScan::getInventoryItemId));
1200
				.collect(Collectors.groupingBy(WarehouseScan::getInventoryItemId));
1198
 
1201
 
1199
		for (Map.Entry<Integer, List<WarehouseScan>> mapEntry : inventoryScansMap.entrySet()) {
1202
		for (Map.Entry<Integer, List<WarehouseScan>> mapEntry : inventoryScansMap.entrySet()) {
1200
			int inventoryItemId = mapEntry.getKey();
1203
			int inventoryItemId = mapEntry.getKey();
1201
			List<WarehouseScan> duplicateScans = mapEntry.getValue().stream().filter(
1204
			List<WarehouseScan> duplicateScans = mapEntry.getValue().stream().filter(
1202
					x -> x.getOrderId() != null && x.getOrderId().equals(inventoryOrderMap.get(inventoryItemId)))
1205
							x -> x.getOrderId() != null && x.getOrderId().equals(inventoryOrderMap.get(inventoryItemId)))
1203
					.collect(Collectors.toList());
1206
					.collect(Collectors.toList());
1204
			WarehouseScan duplicateScan = duplicateScans.stream().skip(1).findFirst().get();
1207
			WarehouseScan duplicateScan = duplicateScans.stream().skip(1).findFirst().get();
1205
			warehouseScanRepository.delete(duplicateScan);
1208
			warehouseScanRepository.delete(duplicateScan);
1206
			warehouseInventoryService.addQuantity(duplicateScan.getInventoryItemId(), duplicateScan.getQuantity());
1209
			warehouseInventoryService.addQuantity(duplicateScan.getInventoryItemId(), duplicateScan.getQuantity());
1207
 
1210
 
Line 1467... Line 1470...
1467
 
1470
 
1468
	@Autowired
1471
	@Autowired
1469
	com.spice.profitmandi.dao.repository.dtr.UserRepository dtrUserRepository;
1472
	com.spice.profitmandi.dao.repository.dtr.UserRepository dtrUserRepository;
1470
 
1473
 
1471
	public void mandiiUser(String firstName, String lastName, String pan, String dob, String aadhaar, String gender,
1474
	public void mandiiUser(String firstName, String lastName, String pan, String dob, String aadhaar, String gender,
1472
			String father) throws Exception {
1475
						   String father) throws Exception {
1473
		FofoStore fs = fofoStoreRepository.selectByPan(pan);
1476
		FofoStore fs = fofoStoreRepository.selectByPan(pan);
1474
		CustomRetailer cr = retailerService.getFofoRetailer(fs.getId());
1477
		CustomRetailer cr = retailerService.getFofoRetailer(fs.getId());
1475
		com.spice.profitmandi.dao.entity.dtr.User dtrUser = dtrUserRepository.selectByEmailId(cr.getEmail());
1478
		com.spice.profitmandi.dao.entity.dtr.User dtrUser = dtrUserRepository.selectByEmailId(cr.getEmail());
1476
		MandiiUser mandiiUser = mandiiService.getUser(dtrUser.getFirstName(), dtrUser.getLastName(), father,
1479
		MandiiUser mandiiUser = mandiiService.getUser(dtrUser.getFirstName(), dtrUser.getLastName(), father,
1477
				Gender.valueOf(gender), cr.getEmail(), pan, cr.getMobileNumber(), LocalDate.parse(dob),
1480
				Gender.valueOf(gender), cr.getEmail(), pan, cr.getMobileNumber(), LocalDate.parse(dob),
Line 1489... Line 1492...
1489
			mandiiUser.setAadharNumber(aadhaar);
1492
			mandiiUser.setAadharNumber(aadhaar);
1490
		}
1493
		}
1491
		mandiiUser.setGender(Gender.valueOf(gender));
1494
		mandiiUser.setGender(Gender.valueOf(gender));
1492
		mandiiService.createAccount(cr.getBusinessName(), mandiiUser);
1495
		mandiiService.createAccount(cr.getBusinessName(), mandiiUser);
1493
	}
1496
	}
1494
	
1497
 
1495
	@Autowired
1498
	@Autowired
1496
	CreditAccountRepository creditAccountRepository;
1499
	CreditAccountRepository creditAccountRepository;
-
 
1500
 
1497
	public void mandiiUsers() throws Exception {
1501
	public void mandiiUsers() throws Exception {
1498
		List<CreditAccount> creditAccounts =  creditAccountRepository.selectAll();
1502
		List<CreditAccount> creditAccounts = creditAccountRepository.selectAll();
1499
		List<Integer> fofoIds = creditAccounts.stream().filter(x->x.getGateway().equals(Gateway.MANDII) && (x.getCreditStatus().equals(CreditStatus.UNKNOWN) || x.getCreditStatus().equals(CreditStatus.TO_BE_EVALUATED))).map(x->x.getFofoId()).collect(Collectors.toList());
1503
		List<Integer> fofoIds = creditAccounts.stream().filter(x -> x.getGateway().equals(Gateway.MANDII) && (x.getCreditStatus().equals(CreditStatus.UNKNOWN) || x.getCreditStatus().equals(CreditStatus.TO_BE_EVALUATED))).map(x -> x.getFofoId()).collect(Collectors.toList());
1500
		List<FofoStore> fsList = fofoStoreRepository.selectByRetailerIds(fofoIds);
1504
		List<FofoStore> fsList = fofoStoreRepository.selectByRetailerIds(fofoIds);
1501
		for(FofoStore store : fsList) {
1505
		for (FofoStore store : fsList) {
1502
			this.mandiiUsers(store.getPan());
1506
			this.mandiiUsers(store.getPan());
1503
		}
1507
		}
1504
		
1508
 
1505
	}
1509
	}
1506
 
1510
 
1507
	public void mandiiUsers(String pan) throws Exception {
1511
	public void mandiiUsers(String pan) throws Exception {
1508
		FofoStore fs = fofoStoreRepository.selectByPan(pan);
1512
		FofoStore fs = fofoStoreRepository.selectByPan(pan);
1509
 
1513
 
Line 1602... Line 1606...
1602
		byte[] bytes = new byte[(int) file.length()];
1606
		byte[] bytes = new byte[(int) file.length()];
1603
		fileInputStreamReader.read(bytes);
1607
		fileInputStreamReader.read(bytes);
1604
		return new String(Base64.getEncoder().encodeToString(bytes));
1608
		return new String(Base64.getEncoder().encodeToString(bytes));
1605
	}
1609
	}
1606
 
1610
 
-
 
1611
 
1607
}
1612
}
1608
 
1613
 
1609
//7015845171
1614
//7015845171
1610
1615