| Line 9... |
Line 9... |
| 9 |
import java.util.Collections;
|
9 |
import java.util.Collections;
|
| 10 |
import java.util.HashMap;
|
10 |
import java.util.HashMap;
|
| 11 |
import java.util.HashSet;
|
11 |
import java.util.HashSet;
|
| 12 |
import java.util.List;
|
12 |
import java.util.List;
|
| 13 |
import java.util.Map;
|
13 |
import java.util.Map;
|
| - |
|
14 |
import java.util.Set;
|
| - |
|
15 |
import java.util.concurrent.TimeUnit;
|
| 14 |
import java.util.stream.Collectors;
|
16 |
import java.util.stream.Collectors;
|
| 15 |
|
17 |
|
| 16 |
import org.apache.commons.io.output.ByteArrayOutputStream;
|
18 |
import org.apache.commons.io.output.ByteArrayOutputStream;
|
| 17 |
import org.apache.commons.lang.StringUtils;
|
19 |
import org.apache.commons.lang.StringUtils;
|
| 18 |
import org.apache.logging.log4j.LogManager;
|
20 |
import org.apache.logging.log4j.LogManager;
|
| 19 |
import org.apache.logging.log4j.Logger;
|
21 |
import org.apache.logging.log4j.Logger;
|
| - |
|
22 |
import org.apache.solr.common.util.Hash;
|
| - |
|
23 |
import org.openqa.selenium.OutputType;
|
| - |
|
24 |
import org.openqa.selenium.TakesScreenshot;
|
| - |
|
25 |
import org.openqa.selenium.WebDriver;
|
| - |
|
26 |
import org.openqa.selenium.chrome.ChromeDriver;
|
| 20 |
import org.springframework.beans.factory.annotation.Autowired;
|
27 |
import org.springframework.beans.factory.annotation.Autowired;
|
| 21 |
import org.springframework.core.io.ByteArrayResource;
|
28 |
import org.springframework.core.io.ByteArrayResource;
|
| 22 |
import org.springframework.mail.javamail.JavaMailSender;
|
29 |
import org.springframework.mail.javamail.JavaMailSender;
|
| 23 |
import org.springframework.stereotype.Component;
|
30 |
import org.springframework.stereotype.Component;
|
| 24 |
import org.springframework.transaction.annotation.Transactional;
|
31 |
import org.springframework.transaction.annotation.Transactional;
|
| 25 |
|
32 |
|
| 26 |
import com.smartdukaan.cron.scheduled.ScheduledTasks;
|
33 |
import com.smartdukaan.cron.scheduled.ScheduledTasks;
|
| 27 |
import com.spice.profitmandi.common.util.FileUtil;
|
34 |
import com.spice.profitmandi.common.util.FileUtil;
|
| - |
|
35 |
import com.spice.profitmandi.common.util.FormattingUtils;
|
| 28 |
import com.spice.profitmandi.common.util.Utils;
|
36 |
import com.spice.profitmandi.common.util.Utils;
|
| 29 |
import com.spice.profitmandi.dao.entity.catalog.Scheme;
|
37 |
import com.spice.profitmandi.dao.entity.catalog.Scheme;
|
| 30 |
import com.spice.profitmandi.dao.entity.fofo.CurrentInventorySnapshot;
|
38 |
import com.spice.profitmandi.dao.entity.fofo.CurrentInventorySnapshot;
|
| 31 |
import com.spice.profitmandi.dao.entity.fofo.FofoOrder;
|
39 |
import com.spice.profitmandi.dao.entity.fofo.FofoOrder;
|
| 32 |
import com.spice.profitmandi.dao.entity.fofo.FofoOrderItem;
|
40 |
import com.spice.profitmandi.dao.entity.fofo.FofoOrderItem;
|
| Line 50... |
Line 58... |
| 50 |
import com.spice.profitmandi.dao.enumuration.catalog.AmountType;
|
58 |
import com.spice.profitmandi.dao.enumuration.catalog.AmountType;
|
| 51 |
import com.spice.profitmandi.dao.enumuration.catalog.SchemeType;
|
59 |
import com.spice.profitmandi.dao.enumuration.catalog.SchemeType;
|
| 52 |
import com.spice.profitmandi.dao.repository.GenericRepository;
|
60 |
import com.spice.profitmandi.dao.repository.GenericRepository;
|
| 53 |
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
|
61 |
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
|
| 54 |
import com.spice.profitmandi.dao.repository.catalog.SchemeRepository;
|
62 |
import com.spice.profitmandi.dao.repository.catalog.SchemeRepository;
|
| - |
|
63 |
import com.spice.profitmandi.dao.repository.cs.CsService;
|
| 55 |
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
|
64 |
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
|
| 56 |
import com.spice.profitmandi.dao.repository.fofo.CurrentInventorySnapshotRepository;
|
65 |
import com.spice.profitmandi.dao.repository.fofo.CurrentInventorySnapshotRepository;
|
| 57 |
import com.spice.profitmandi.dao.repository.fofo.DebitNoteRepository;
|
66 |
import com.spice.profitmandi.dao.repository.fofo.DebitNoteRepository;
|
| 58 |
import com.spice.profitmandi.dao.repository.fofo.FofoOrderItemRepository;
|
67 |
import com.spice.profitmandi.dao.repository.fofo.FofoOrderItemRepository;
|
| 59 |
import com.spice.profitmandi.dao.repository.fofo.FofoOrderRepository;
|
68 |
import com.spice.profitmandi.dao.repository.fofo.FofoOrderRepository;
|
| Line 97... |
Line 106... |
| 97 |
@Autowired
|
106 |
@Autowired
|
| 98 |
private LineItemRepository lineItemRepository;
|
107 |
private LineItemRepository lineItemRepository;
|
| 99 |
|
108 |
|
| 100 |
@Autowired
|
109 |
@Autowired
|
| 101 |
private SaholicInventorySnapshotRepository saholicInventorySnapshotRepository;
|
110 |
private SaholicInventorySnapshotRepository saholicInventorySnapshotRepository;
|
| - |
|
111 |
|
| - |
|
112 |
@Autowired
|
| - |
|
113 |
private CsService csService;
|
| - |
|
114 |
|
| 102 |
|
115 |
|
| 103 |
@Autowired
|
116 |
@Autowired
|
| 104 |
private SaholicReservationInventorySnapshotRepository saholicReservationInventorySnapshotRepository;
|
117 |
private SaholicReservationInventorySnapshotRepository saholicReservationInventorySnapshotRepository;
|
| 105 |
|
118 |
|
| 106 |
@Autowired
|
119 |
@Autowired
|
| Line 146... |
Line 159... |
| 146 |
@Autowired
|
159 |
@Autowired
|
| 147 |
private SchemeRepository schemeRepository;
|
160 |
private SchemeRepository schemeRepository;
|
| 148 |
|
161 |
|
| 149 |
@Autowired
|
162 |
@Autowired
|
| 150 |
private AddressRepository addressRepository;
|
163 |
private AddressRepository addressRepository;
|
| 151 |
|
164 |
|
| 152 |
@Autowired
|
165 |
@Autowired
|
| 153 |
private ScheduledTasks scheduledTasks;
|
166 |
private ScheduledTasks scheduledTasks;
|
| 154 |
|
167 |
|
| 155 |
@Autowired
|
168 |
@Autowired
|
| 156 |
private SchemeItemRepository schemeItemRepository;
|
169 |
private SchemeItemRepository schemeItemRepository;
|
| Line 666... |
Line 679... |
| 666 |
List<FofoStore> fofoStores = fofoStoreRepository.selectAll();
|
679 |
List<FofoStore> fofoStores = fofoStoreRepository.selectAll();
|
| 667 |
System.out.println("id\tcode\tactive\tname\tcity\tstate\twallet amount\tsum\twallet amount-sum");
|
680 |
System.out.println("id\tcode\tactive\tname\tcity\tstate\twallet amount\tsum\twallet amount-sum");
|
| 668 |
for (FofoStore fofoStore : fofoStores) {
|
681 |
for (FofoStore fofoStore : fofoStores) {
|
| 669 |
UserWallet uw = userWalletRepository.selectByRetailerId(fofoStore.getId());
|
682 |
UserWallet uw = userWalletRepository.selectByRetailerId(fofoStore.getId());
|
| 670 |
User user = userRepository.selectById(fofoStore.getId());
|
683 |
User user = userRepository.selectById(fofoStore.getId());
|
| 671 |
if(user==null) {
|
684 |
if (user == null) {
|
| 672 |
LOGGER.info("store does not exist", fofoStore.getCode());
|
685 |
LOGGER.info("store does not exist", fofoStore.getCode());
|
| 673 |
continue;
|
686 |
continue;
|
| 674 |
}
|
687 |
}
|
| 675 |
Address address = null;
|
688 |
Address address = null;
|
| 676 |
try {
|
689 |
try {
|
| 677 |
address = addressRepository.selectById(user.getAddressId());
|
690 |
address = addressRepository.selectById(user.getAddressId());
|
| 678 |
} catch(Exception e) {
|
691 |
} catch (Exception e) {
|
| 679 |
LOGGER.info("Could not find address for Store", fofoStore.getCode());
|
692 |
LOGGER.info("Could not find address for Store", fofoStore.getCode());
|
| 680 |
address = new Address();
|
693 |
address = new Address();
|
| 681 |
}
|
694 |
}
|
| 682 |
double sum = userWalletHistoryRepository.selectSumByWallet(uw.getId());
|
695 |
double sum = userWalletHistoryRepository.selectSumByWallet(uw.getId());
|
| 683 |
int calculated = (int)sum;
|
696 |
int calculated = (int) sum;
|
| 684 |
System.out.printf("%d\t%s\t%b\t%s\t%s\t%s\t%d\t%d\t%d%n", fofoStore.getId(), fofoStore.getCode(),
|
697 |
System.out.printf("%d\t%s\t%b\t%s\t%s\t%s\t%d\t%d\t%d%n", fofoStore.getId(), fofoStore.getCode(),
|
| 685 |
fofoStore.isActive(), address.getName(), address.getCity(), address.getState(), uw.getAmount(), calculated,
|
698 |
fofoStore.isActive(), address.getName(), address.getCity(), address.getState(), uw.getAmount(),
|
| 686 |
uw.getAmount() - calculated);
|
699 |
calculated, uw.getAmount() - calculated);
|
| 687 |
}
|
700 |
}
|
| 688 |
}
|
701 |
}
|
| 689 |
|
702 |
|
| 690 |
public void changeWarehouse() throws Exception {
|
703 |
public void changeWarehouse() throws Exception {
|
| 691 |
transactionService.moveWarehouses();
|
704 |
transactionService.moveWarehouses();
|
| 692 |
}
|
705 |
}
|
| - |
|
706 |
|
| - |
|
707 |
public void mailDashboardScreenshots() throws Exception {
|
| - |
|
708 |
System.setProperty("webdriver.chrome.driver", "/usr/bin/chromedriver");
|
| - |
|
709 |
|
| - |
|
710 |
WebDriver driver = new ChromeDriver();
|
| - |
|
711 |
driver.manage().window().maximize();
|
| - |
|
712 |
//Deleting all the cookies
|
| - |
|
713 |
driver.manage().deleteAllCookies();
|
| - |
|
714 |
//Specifiying pageLoadTimeout and Implicit wait
|
| - |
|
715 |
driver.manage().timeouts().pageLoadTimeout(40, TimeUnit.SECONDS);
|
| - |
|
716 |
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
|
| - |
|
717 |
Map<String, Set<Integer>> authUserPartnerIdMapping = csService.getAuthUserPartnerIdMapping();
|
| - |
|
718 |
Set<Integer> allPartners = new HashSet<>();
|
| - |
|
719 |
Map<Integer, String> partnerSnapshotMap = new HashMap<>();
|
| - |
|
720 |
authUserPartnerIdMapping.values().stream().forEach(x->allPartners.addAll(x));
|
| - |
|
721 |
System.out.println(allPartners.size());
|
| - |
|
722 |
for(int fofoId : allPartners) {
|
| - |
|
723 |
driver.get("https://partners.smartdukaan.com/12dashboard34?fofoId=" + fofoId);
|
| - |
|
724 |
String base64Image = ((TakesScreenshot)driver).getScreenshotAs(OutputType.BASE64);
|
| - |
|
725 |
partnerSnapshotMap.put(fofoId, base64Image);
|
| - |
|
726 |
|
| - |
|
727 |
}
|
| - |
|
728 |
for(Map.Entry<String, Set<Integer>> entry : authUserPartnerIdMapping.entrySet()) {
|
| - |
|
729 |
String email = entry.getKey();
|
| - |
|
730 |
Set<Integer> partnerIds = entry.getValue();
|
| - |
|
731 |
StringBuffer body = new StringBuffer();
|
| - |
|
732 |
for(int fofoId: partnerIds) {
|
| - |
|
733 |
body.append(String.format("<br><image src=\"%s\" />", partnerSnapshotMap.get(fofoId)));
|
| - |
|
734 |
}
|
| - |
|
735 |
Utils.sendHtmlMailWithAttachments(mailSender, new String[]{"amit.gupta@shop2020.in"}, new String[] {}, String.format("Franchise Screenshots - %s", FormattingUtils.formatDate(LocalDateTime.now())), body.toString());
|
| - |
|
736 |
}
|
| - |
|
737 |
driver.quit();
|
| - |
|
738 |
}
|
| 693 |
}
|
739 |
}
|
| 694 |
|
740 |
|
| 695 |
//7015845171
|
741 |
//7015845171
|
| 696 |
|
742 |
|