| Line 1898... |
Line 1898... |
| 1898 |
LOGGER.info("chartMap" + gson.toJson(cm));
|
1898 |
LOGGER.info("chartMap" + gson.toJson(cm));
|
| 1899 |
model.addAttribute("chartMap", gson.toJson(cm));
|
1899 |
model.addAttribute("chartMap", gson.toJson(cm));
|
| 1900 |
return "brand-wise-mobile-lmp-chart";
|
1900 |
return "brand-wise-mobile-lmp-chart";
|
| 1901 |
}
|
1901 |
}
|
| 1902 |
|
1902 |
|
| 1903 |
@RequestMapping(value = "/getCountByCategory", method = RequestMethod.GET)
|
1903 |
@RequestMapping(value = "/getSaleCountByMilestone", method = RequestMethod.GET)
|
| 1904 |
public String getCountByCategory(HttpServletRequest request,
|
1904 |
public String getSaleCountByMilestone(HttpServletRequest request,
|
| 1905 |
@RequestParam(required = false, defaultValue = "0") int warehouseId, Model model) throws Exception {
|
1905 |
@RequestParam(required = false, defaultValue = "0") int warehouseId, Model model) throws Exception {
|
| 1906 |
|
1906 |
|
| 1907 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
1907 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 1908 |
String email = loginDetails.getEmailId();
|
1908 |
String email = loginDetails.getEmailId();
|
| 1909 |
|
- |
|
| 1910 |
Set<Integer> fofoIds = csService.getAuthFofoIds(email);
|
1909 |
Set<Integer> fofoIds = csService.getAuthFofoIds(email);
|
| - |
|
1910 |
Map<Integer, Double> last3MonthSale = fofoOrderItemRepository.selectSumMopGroupByRetailer(
|
| - |
|
1911 |
LocalDateTime.now().withDayOfMonth(1).minusMonths(2), LocalDateTime.now(), 0, false);
|
| 1911 |
|
1912 |
|
| 1912 |
if (fofoIds != null && fofoIds.size() > 0) {
|
1913 |
if (fofoIds != null && fofoIds.size() > 0) {
|
| - |
|
1914 |
if (warehouseId != 0) {
|
| - |
|
1915 |
fofoIds = fofoStoreRepository.selectPartnerByfofoIdAndWarehouse(new ArrayList<>(fofoIds), warehouseId)
|
| - |
|
1916 |
.stream().map(x -> x).collect(Collectors.toSet());
|
| - |
|
1917 |
}
|
| 1913 |
Map<Integer, PartnerDetailModel> partnerStats = adminUser.getPartnersStatDataFromFile();
|
1918 |
Map<Integer, PartnerDetailModel> partnerStats = adminUser.getPartnersStatDataFromFile();
|
| 1914 |
if (partnerStats != null) {
|
1919 |
if (partnerStats != null) {
|
| 1915 |
|
- |
|
| 1916 |
List<PartnerDetailModel> partnerDetails = fofoIds.stream().filter(x -> partnerStats.containsKey(x))
|
1920 |
List<PartnerDetailModel> partnerDetails = fofoIds.stream().filter(x -> partnerStats.containsKey(x))
|
| 1917 |
.map(x -> partnerStats.get(x)).collect(Collectors.toList());
|
1921 |
.map(x -> partnerStats.get(x)).collect(Collectors.toList());
|
| 1918 |
|
- |
|
| 1919 |
Map<Integer, Double> last3MonthSale = fofoOrderItemRepository.selectSumMopGroupByRetailer(
|
- |
|
| 1920 |
LocalDateTime.now().withDayOfMonth(1).minusMonths(6), LocalDateTime.now(), 0, false);
|
- |
|
| 1921 |
|
- |
|
| 1922 |
Map<Milestone, Long> lmsMap = new HashMap<>();
|
1922 |
Map<Milestone, Long> avg3Monthlms = new HashMap<>();
|
| 1923 |
if (!last3MonthSale.isEmpty()) {
|
1923 |
if (!last3MonthSale.isEmpty()) {
|
| 1924 |
|
- |
|
| 1925 |
int days = 60 + LocalDateTime.now().getDayOfMonth();
|
1924 |
int days = 60 + LocalDateTime.now().getDayOfMonth();
|
| 1926 |
|
- |
|
| 1927 |
for (Entry<Integer, Double> last3MonthEntry : last3MonthSale.entrySet()) {
|
1925 |
for (Entry<Integer, Double> last3MonthEntry : last3MonthSale.entrySet()) {
|
| 1928 |
if (fofoIds.contains(last3MonthEntry.getKey())) {
|
1926 |
if (fofoIds.contains(last3MonthEntry.getKey())) {
|
| 1929 |
|
- |
|
| 1930 |
Double monthSale = last3MonthEntry.getValue();
|
1927 |
Double monthSale = last3MonthEntry.getValue();
|
| 1931 |
|
- |
|
| 1932 |
if (monthSale == null) {
|
1928 |
if (monthSale == null) {
|
| 1933 |
monthSale = (double) 0;
|
1929 |
monthSale = (double) 0;
|
| 1934 |
|
1930 |
|
| 1935 |
}
|
1931 |
}
|
| 1936 |
|
- |
|
| 1937 |
double avg3MonthSale = (monthSale / days) * 30;
|
1932 |
double avg3MonthSale = (monthSale / days) * 30;
|
| 1938 |
Milestone milestone = Milestone.get((int) avg3MonthSale);
|
1933 |
Milestone milestone = Milestone.get((int) avg3MonthSale);
|
| 1939 |
|
- |
|
| 1940 |
long value = 0;
|
1934 |
long value = 0;
|
| 1941 |
|
- |
|
| 1942 |
if (lmsMap.containsKey(milestone)) {
|
1935 |
if (avg3Monthlms.containsKey(milestone)) {
|
| 1943 |
value = lmsMap.get(milestone) + 1;
|
1936 |
value = avg3Monthlms.get(milestone) + 1;
|
| 1944 |
lmsMap.put(milestone, value);
|
1937 |
avg3Monthlms.put(milestone, value);
|
| 1945 |
} else {
|
1938 |
} else {
|
| 1946 |
lmsMap.put(milestone, value + 1);
|
1939 |
avg3Monthlms.put(milestone, value + 1);
|
| 1947 |
|
1940 |
|
| 1948 |
}
|
1941 |
}
|
| 1949 |
}
|
1942 |
}
|
| 1950 |
|
1943 |
|
| 1951 |
}
|
1944 |
}
|
| 1952 |
|
1945 |
|
| 1953 |
}
|
1946 |
}
|
| 1954 |
|
- |
|
| 1955 |
LOGGER.info("last3MonthSale" + last3MonthSale);
|
- |
|
| 1956 |
|
- |
|
| 1957 |
LOGGER.info("partnerDetails" + partnerDetails);
|
- |
|
| 1958 |
|
1947 |
|
| 1959 |
if (partnerDetails != null) {
|
1948 |
if (partnerDetails != null) {
|
| 1960 |
|
1949 |
|
| 1961 |
Map<Milestone, Long> mtdMap = partnerDetails.stream()
|
1950 |
Map<Milestone, Long> mtdMap = partnerDetails.stream()
|
| 1962 |
.collect(Collectors.groupingBy(x -> x.getMtdValue(), Collectors.counting()));
|
1951 |
.collect(Collectors.groupingBy(x -> Milestone.get(x.getMtd()), Collectors.counting()));
|
| 1963 |
Map<Milestone, Long> lmtdMap = partnerDetails.stream()
|
1952 |
Map<Milestone, Long> lmtdMap = partnerDetails.stream()
|
| 1964 |
.collect(Collectors.groupingBy(x -> Milestone.get(x.getLmtd()), Collectors.counting()));
|
1953 |
.collect(Collectors.groupingBy(x -> Milestone.get(x.getLmtd()), Collectors.counting()));
|
| 1965 |
|
1954 |
|
| 1966 |
LOGGER.info("mtdMap" + mtdMap);
|
- |
|
| 1967 |
|
- |
|
| 1968 |
LOGGER.info("lmtdMap" + lmtdMap);
|
1955 |
Map<Milestone, Long> lmsMap = partnerDetails.stream()
|
| 1969 |
|
- |
|
| 1970 |
LOGGER.info("lmsMap" + lmsMap);
|
1956 |
.collect(Collectors.groupingBy(x -> Milestone.get(x.getLms()), Collectors.counting()));
|
| 1971 |
|
1957 |
|
| 1972 |
model.addAttribute("mtdMap", mtdMap);
|
1958 |
model.addAttribute("mtdMap", mtdMap);
|
| 1973 |
model.addAttribute("lmtdMap", lmtdMap);
|
1959 |
model.addAttribute("lmtdMap", lmtdMap);
|
| - |
|
1960 |
model.addAttribute("avg3Monthlms", avg3Monthlms);
|
| 1974 |
model.addAttribute("lmsMap", lmsMap);
|
1961 |
model.addAttribute("lmsMap", lmsMap);
|
| 1975 |
|
1962 |
|
| 1976 |
}
|
1963 |
}
|
| 1977 |
|
1964 |
|
| 1978 |
}
|
1965 |
}
|
| 1979 |
}
|
1966 |
}
|
| 1980 |
|
1967 |
|
| 1981 |
model.addAttribute("warehouseMap", ProfitMandiConstants.WAREHOUSE_MAP);
|
1968 |
model.addAttribute("warehouseMap", ProfitMandiConstants.WAREHOUSE_MAP);
|
| - |
|
1969 |
model.addAttribute("warehouseId", warehouseId);
|
| 1982 |
for (Milestone currency : Milestone.values()) {
|
1970 |
model.addAttribute("milestones", Milestone.values());
|
| - |
|
1971 |
|
| 1983 |
LOGGER.info("mtdMap" + currency.name());
|
1972 |
return "sale-milestone";
|
| - |
|
1973 |
|
| - |
|
1974 |
}
|
| - |
|
1975 |
|
| - |
|
1976 |
@RequestMapping(value = "/getPurchaseCountByMileStone", method = RequestMethod.GET)
|
| - |
|
1977 |
public String getPurchaseCountByMileStone(HttpServletRequest request,
|
| - |
|
1978 |
@RequestParam(required = false, defaultValue = "0") int warehouseId, Model model) throws Exception {
|
| 1984 |
|
1979 |
|
| - |
|
1980 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| - |
|
1981 |
String email = loginDetails.getEmailId();
|
| - |
|
1982 |
Set<Integer> fofoIds = csService.getAuthFofoIds(email);
|
| - |
|
1983 |
Map<Integer, Double> last3MonthS = orderRepository.selectBillingDatesBetweenSumGroupByRetailerId(
|
| - |
|
1984 |
LocalDateTime.now().withDayOfMonth(1).minusMonths(2), LocalDateTime.now());
|
| - |
|
1985 |
|
| - |
|
1986 |
if (fofoIds != null && fofoIds.size() > 0) {
|
| - |
|
1987 |
if (warehouseId != 0) {
|
| - |
|
1988 |
fofoIds = fofoStoreRepository.selectPartnerByfofoIdAndWarehouse(new ArrayList<>(fofoIds), warehouseId)
|
| - |
|
1989 |
.stream().map(x -> x).collect(Collectors.toSet());
|
| - |
|
1990 |
}
|
| - |
|
1991 |
Map<Integer, PartnerDetailModel> partnerStats = adminUser.getPartnersStatDataFromFile();
|
| - |
|
1992 |
if (partnerStats != null) {
|
| - |
|
1993 |
List<PartnerDetailModel> partnerDetails = fofoIds.stream().filter(x -> partnerStats.containsKey(x))
|
| - |
|
1994 |
.map(x -> partnerStats.get(x)).collect(Collectors.toList());
|
| - |
|
1995 |
Map<Milestone, Long> avg3MonthS = new HashMap<>();
|
| - |
|
1996 |
if (!last3MonthS.isEmpty()) {
|
| - |
|
1997 |
int days = 60 + LocalDateTime.now().getDayOfMonth();
|
| - |
|
1998 |
for (Entry<Integer, Double> last3MonthSEntry : last3MonthS.entrySet()) {
|
| - |
|
1999 |
if (fofoIds.contains(last3MonthSEntry.getKey())) {
|
| - |
|
2000 |
Double monthSec = last3MonthSEntry.getValue();
|
| - |
|
2001 |
if (monthSec == null) {
|
| - |
|
2002 |
monthSec = (double) 0;
|
| - |
|
2003 |
|
| - |
|
2004 |
}
|
| - |
|
2005 |
double avg3MonthSale = (monthSec / days) * 30;
|
| - |
|
2006 |
Milestone milestone = Milestone.get((int) avg3MonthSale);
|
| - |
|
2007 |
long value = 0;
|
| - |
|
2008 |
if (avg3MonthS.containsKey(milestone)) {
|
| - |
|
2009 |
value = avg3MonthS.get(milestone) + 1;
|
| - |
|
2010 |
avg3MonthS.put(milestone, value);
|
| - |
|
2011 |
} else {
|
| - |
|
2012 |
avg3MonthS.put(milestone, value + 1);
|
| - |
|
2013 |
|
| - |
|
2014 |
}
|
| - |
|
2015 |
}
|
| - |
|
2016 |
|
| - |
|
2017 |
}
|
| - |
|
2018 |
|
| - |
|
2019 |
}
|
| - |
|
2020 |
|
| - |
|
2021 |
if (partnerDetails != null) {
|
| - |
|
2022 |
|
| - |
|
2023 |
Map<Milestone, Long> smtdMap = partnerDetails.stream().collect(
|
| - |
|
2024 |
Collectors.groupingBy(x -> Milestone.get(x.getSecondarymtd()), Collectors.counting()));
|
| - |
|
2025 |
Map<Milestone, Long> slmtdMap = partnerDetails.stream().collect(
|
| - |
|
2026 |
Collectors.groupingBy(x -> Milestone.get(x.getSecondarylmtd()), Collectors.counting()));
|
| - |
|
2027 |
Map<Milestone, Long> lmsMap = partnerDetails.stream().collect(
|
| - |
|
2028 |
Collectors.groupingBy(x -> Milestone.get(x.getSecondarylms()), Collectors.counting()));
|
| - |
|
2029 |
|
| - |
|
2030 |
model.addAttribute("smtdMap", smtdMap);
|
| - |
|
2031 |
model.addAttribute("slmtdMap", slmtdMap);
|
| - |
|
2032 |
model.addAttribute("avg3MonthS", avg3MonthS);
|
| - |
|
2033 |
model.addAttribute("lmsMap", lmsMap);
|
| - |
|
2034 |
|
| - |
|
2035 |
}
|
| - |
|
2036 |
|
| - |
|
2037 |
}
|
| 1985 |
}
|
2038 |
}
|
| 1986 |
|
2039 |
|
| - |
|
2040 |
model.addAttribute("warehouseMap", ProfitMandiConstants.WAREHOUSE_MAP);
|
| 1987 |
model.addAttribute("warehouseId", warehouseId);
|
2041 |
model.addAttribute("warehouseId", warehouseId);
|
| 1988 |
|
- |
|
| 1989 |
model.addAttribute("milestones", Milestone.values());
|
2042 |
model.addAttribute("milestones", Milestone.values());
|
| 1990 |
|
2043 |
|
| 1991 |
return "milestone";
|
2044 |
return "purchase-milestone";
|
| 1992 |
|
2045 |
|
| 1993 |
}
|
2046 |
}
|
| 1994 |
|
2047 |
|
| 1995 |
@RequestMapping(value = "/getActivatedModelWarehouseWise", method = RequestMethod.GET)
|
2048 |
@RequestMapping(value = "/getActivatedModelWarehouseWise", method = RequestMethod.GET)
|
| 1996 |
public String getActivatedModelWarehouseWise(HttpServletRequest request, Model model, @RequestParam String brand)
|
2049 |
public String getActivatedModelWarehouseWise(HttpServletRequest request, Model model, @RequestParam String brand)
|