Subversion Repositories SmartDukaan

Rev

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

Rev 34152 Rev 34176
Line 41... Line 41...
41
import com.spice.profitmandi.service.FofoUser;
41
import com.spice.profitmandi.service.FofoUser;
42
import com.spice.profitmandi.service.PartnerInvestmentService;
42
import com.spice.profitmandi.service.PartnerInvestmentService;
43
import com.spice.profitmandi.service.PartnerStatsService;
43
import com.spice.profitmandi.service.PartnerStatsService;
44
import com.spice.profitmandi.service.SshServer.SSHService;
44
import com.spice.profitmandi.service.SshServer.SSHService;
45
import com.spice.profitmandi.service.authentication.RoleManager;
45
import com.spice.profitmandi.service.authentication.RoleManager;
-
 
46
import com.spice.profitmandi.service.catalog.BrandsService;
46
import com.spice.profitmandi.service.integrations.psismart.PsiSmartService;
47
import com.spice.profitmandi.service.integrations.psismart.PsiSmartService;
47
import com.spice.profitmandi.service.inventory.InventoryService;
48
import com.spice.profitmandi.service.inventory.InventoryService;
48
import com.spice.profitmandi.service.offers.OfferService;
49
import com.spice.profitmandi.service.offers.OfferService;
49
import com.spice.profitmandi.service.scheme.SchemeService;
50
import com.spice.profitmandi.service.scheme.SchemeService;
50
import com.spice.profitmandi.service.transaction.TransactionService;
51
import com.spice.profitmandi.service.transaction.TransactionService;
Line 83... Line 84...
83
 
84
 
84
@Controller
85
@Controller
85
@Transactional(rollbackOn = Throwable.class)
86
@Transactional(rollbackOn = Throwable.class)
86
public class DashboardController {
87
public class DashboardController {
87
 
88
 
88
    List<String> emails = Arrays.asList("kamini.sharma@smartdukaan.com", "neeraj.gupta@smartdukaan.com", "amit.gupta@smartdukaan.com", "ranu.rajput@smartdukaan.com", "vikas.jangra@smartdukaan.com", "tejus.lohani@smartdukaan.com","aman.gupta@smartdukaan.com");
89
    List<String> emails = Arrays.asList("kamini.sharma@smartdukaan.com", "neeraj.gupta@smartdukaan.com", "amit.gupta@smartdukaan.com", "ranu.rajput@smartdukaan.com", "vikas.jangra@smartdukaan.com", "tejus.lohani@smartdukaan.com", "aman.gupta@smartdukaan.com");
89
 
90
 
90
    @Value("${web.api.host}")
91
    @Value("${web.api.host}")
91
    private String webApiHost;
92
    private String webApiHost;
92
 
93
 
93
    @Value("${web.api.scheme}")
94
    @Value("${web.api.scheme}")
Line 232... Line 233...
232
    private SamsungUpgradeOfferRepository samsungUpgradeOfferRepository;
233
    private SamsungUpgradeOfferRepository samsungUpgradeOfferRepository;
233
    private static final Logger LOGGER = LogManager.getLogger(DashboardController.class);
234
    private static final Logger LOGGER = LogManager.getLogger(DashboardController.class);
234
 
235
 
235
    @Autowired
236
    @Autowired
236
    private SSHService sshService;
237
    private SSHService sshService;
-
 
238
    @Autowired
-
 
239
    BrandsService brandsService;
237
 
240
 
238
    @RequestMapping(value = "/12dashboard34", method = RequestMethod.GET)
241
    @RequestMapping(value = "/12dashboard34", method = RequestMethod.GET)
239
    public String dashboard1(HttpServletRequest request, Model model, @RequestParam int fofoId) throws Exception {
242
    public String dashboard1(HttpServletRequest request, Model model, @RequestParam int fofoId) throws Exception {
240
        boolean isAdmin = false;
243
        boolean isAdmin = false;
241
        model.addAttribute("isAdmin", isAdmin);
244
        model.addAttribute("isAdmin", isAdmin);
Line 273... Line 276...
273
            for (int i = 0; i <= 5; i++) {
276
            for (int i = 0; i <= 5; i++) {
274
                LocalDateTime startOfMonth = LocalDateTime.now().withDayOfMonth(1).minusMonths(i);
277
                LocalDateTime startOfMonth = LocalDateTime.now().withDayOfMonth(1).minusMonths(i);
275
                monthValueMap.put(i, startOfMonth.format(DateTimeFormatter.ofPattern("MMM''uu")));
278
                monthValueMap.put(i, startOfMonth.format(DateTimeFormatter.ofPattern("MMM''uu")));
276
            }
279
            }
277
            LOGGER.info("monthValueMap" + monthValueMap);
280
            LOGGER.info("monthValueMap" + monthValueMap);
-
 
281
            Set<String> brands = brandsService.getBrandsToDisplay(3).stream().map(x -> x.getName()).collect(Collectors.toSet());
-
 
282
            brands.addAll(itemRepository.selectAllBrands(ProfitMandiConstants.LED_CATEGORY_ID));
-
 
283
            brands.addAll(itemRepository.selectAllBrands(ProfitMandiConstants.SMART_WATCH_CATEGORY_ID));
-
 
284
            brands.add("Live Demo");
-
 
285
            model.addAttribute("brands", brands);
278
            model.addAttribute("monthValueMap", monthValueMap);
286
            model.addAttribute("monthValueMap", monthValueMap);
279
            model.addAttribute("investments", fofoUser.getInvestments(fofoId));
287
            model.addAttribute("investments", fofoUser.getInvestments(fofoId));
280
            model.addAttribute("isInvestmentOk", partnerInvestmentService.isInvestmentOk(fofoId, ProfitMandiConstants.MIN_INVESTMENT_PERCENTAGE, ProfitMandiConstants.CUTOFF_INVESTMENT));
288
            model.addAttribute("isInvestmentOk", partnerInvestmentService.isInvestmentOk(fofoId, ProfitMandiConstants.MIN_INVESTMENT_PERCENTAGE, ProfitMandiConstants.CUTOFF_INVESTMENT));
281
        } catch (ProfitMandiBusinessException e) {
289
        } catch (ProfitMandiBusinessException e) {
282
            LOGGER.error("FofoStore Code not found of fofoId {}", fofoId);
290
            LOGGER.error("FofoStore Code not found of fofoId {}", fofoId);
Line 381... Line 389...
381
                List<LineItem> grnPendingLineItemIds = openOrders.stream().filter(x -> x.getStatus().equals(DELIVERY_SUCCESS)).map(x -> x.getLineItem()).collect(Collectors.toList());
389
                List<LineItem> grnPendingLineItemIds = openOrders.stream().filter(x -> x.getStatus().equals(DELIVERY_SUCCESS)).map(x -> x.getLineItem()).collect(Collectors.toList());
382
 
390
 
383
                long imeiActivationPendingCount = 0;
391
                long imeiActivationPendingCount = 0;
384
                long imeiActivationPendingValue = 0;
392
                long imeiActivationPendingValue = 0;
385
                //Only delivered orders should be visible
393
                //Only delivered orders should be visible
386
                List<Integer> grnPendingOrderIds = openOrders.stream().filter(x-> x.getStatus().equals(DELIVERY_SUCCESS)).map(x -> x.getId()).collect(Collectors.toList());
394
                List<Integer> grnPendingOrderIds = openOrders.stream().filter(x -> x.getStatus().equals(DELIVERY_SUCCESS)).map(x -> x.getId()).collect(Collectors.toList());
387
                if (grnPendingOrderIds.size() > 0) {
395
                if (grnPendingOrderIds.size() > 0) {
388
                    List<ImeiActivationTimestampModel> imeiActivationTimestampModels = activatedImeiRepository.selectActivatedImeisByOrders(grnPendingOrderIds);
396
                    List<ImeiActivationTimestampModel> imeiActivationTimestampModels = activatedImeiRepository.selectActivatedImeisByOrders(grnPendingOrderIds);
389
                    imeiActivationPendingCount = imeiActivationTimestampModels.size();
397
                    imeiActivationPendingCount = imeiActivationTimestampModels.size();
390
                    imeiActivationPendingValue = imeiActivationTimestampModels.stream().collect(Collectors.summingDouble(x -> x.getSellingPrice())).longValue();
398
                    imeiActivationPendingValue = imeiActivationTimestampModels.stream().collect(Collectors.summingDouble(x -> x.getSellingPrice())).longValue();
391
                }
399
                }
Line 503... Line 511...
503
                    monthValueMap.put(i, startOfMonth.format(DateTimeFormatter.ofPattern("MMM''uu")));
511
                    monthValueMap.put(i, startOfMonth.format(DateTimeFormatter.ofPattern("MMM''uu")));
504
                }
512
                }
505
 
513
 
506
                MonthlyTarget monthlyTarget = monthlyTargetRepository.selectByDateAndFofoId(YearMonth.now(), fofoId);
514
                MonthlyTarget monthlyTarget = monthlyTargetRepository.selectByDateAndFofoId(YearMonth.now(), fofoId);
507
                model.addAttribute("monthlyTarget", monthlyTarget);
515
                model.addAttribute("monthlyTarget", monthlyTarget);
508
 
-
 
-
 
516
                Set<String> brands = brandsService.getBrandsToDisplay(3).stream().map(x -> x.getName()).collect(Collectors.toSet());
-
 
517
                brands.addAll(itemRepository.selectAllBrands(ProfitMandiConstants.LED_CATEGORY_ID));
-
 
518
                brands.addAll(itemRepository.selectAllBrands(ProfitMandiConstants.SMART_WATCH_CATEGORY_ID));
-
 
519
                brands.add("Live Demo");
-
 
520
                model.addAttribute("brands", brands);
509
                model.addAttribute("monthValueMap", monthValueMap);
521
                model.addAttribute("monthValueMap", monthValueMap);
510
                model.addAttribute("month", 0);
522
                model.addAttribute("month", 0);
511
                model.addAttribute("hygienePercentage", (hygieneCount * 100) / (invalidHygieneCount + hygieneCount));
523
                model.addAttribute("hygienePercentage", (hygieneCount * 100) / (invalidHygieneCount + hygieneCount));
512
                model.addAttribute("monthDays", LocalDate.now().minusDays(1).lengthOfMonth());
524
                model.addAttribute("monthDays", LocalDate.now().minusDays(1).lengthOfMonth());
513
                model.addAttribute("dayOfMonth", LocalDate.now().minusDays(1).getDayOfMonth());
525
                model.addAttribute("dayOfMonth", LocalDate.now().minusDays(1).getDayOfMonth());
Line 1284... Line 1296...
1284
        return "warehouse_brand_item_stock";
1296
        return "warehouse_brand_item_stock";
1285
    }
1297
    }
1286
 
1298
 
1287
    @RequestMapping(value = "/getWarehouseWiseItemStock", method = RequestMethod.GET)
1299
    @RequestMapping(value = "/getWarehouseWiseItemStock", method = RequestMethod.GET)
1288
    public String getWarehouseWiseItemStock(HttpServletRequest request, Model
1300
    public String getWarehouseWiseItemStock(HttpServletRequest request, Model
1289
            model, @RequestParam(name="warehouseId") List<Integer> warehouseIds, @RequestParam List<String> brands, @RequestParam String
1301
            model, @RequestParam(name = "warehouseId") List<Integer> warehouseIds, @RequestParam List<String> brands, @RequestParam String
1290
                                                    category) throws Exception {
1302
                                                    category) throws Exception {
1291
        Map<Integer, String> warehouseMap = ProfitMandiConstants.WAREHOUSE_MAP;
1303
        Map<Integer, String> warehouseMap = ProfitMandiConstants.WAREHOUSE_MAP;
1292
        if (warehouseIds.contains(0)) {
1304
        if (warehouseIds.contains(0)) {
1293
            warehouseIds.addAll(warehouseMap.keySet());
1305
            warehouseIds.addAll(warehouseMap.keySet());
1294
        }
1306
        }
Line 1441... Line 1453...
1441
        }
1453
        }
1442
        List<Notification> notifications = null;
1454
        List<Notification> notifications = null;
1443
 
1455
 
1444
        List<NotificationCampaign> notificationCampaigns = notificationCampaignRepository.getNotifications(messageType, userId, offset, limit);
1456
        List<NotificationCampaign> notificationCampaigns = notificationCampaignRepository.getNotifications(messageType, userId, offset, limit);
1445
        LOGGER.info("messageType" + messageType);
1457
        LOGGER.info("messageType" + messageType);
1446
        if(messageType != null){
1458
        if (messageType != null) {
1447
        notifications = fofoUser.getNotifications(notificationCampaigns, messageType);
1459
            notifications = fofoUser.getNotifications(notificationCampaigns, messageType);
1448
 
1460
 
1449
        model.addAttribute("notifications", notifications);
1461
            model.addAttribute("notifications", notifications);
1450
 
1462
 
1451
        LOGGER.info("notifications" + notifications);}
1463
            LOGGER.info("notifications" + notifications);
-
 
1464
        }
1452
        return "notification-template";
1465
        return "notification-template";
1453
    }
1466
    }
1454
 
1467
 
1455
    @RequestMapping(value = "/notifyDocument/documentId", method = RequestMethod.GET)
1468
    @RequestMapping(value = "/notifyDocument/documentId", method = RequestMethod.GET)
1456
    public ResponseEntity<?> retailerDocumentById(HttpServletRequest request,
1469
    public ResponseEntity<?> retailerDocumentById(HttpServletRequest request,
Line 1467... Line 1480...
1467
        return responseSender.ok(document);
1480
        return responseSender.ok(document);
1468
    }
1481
    }
1469
 
1482
 
1470
    @Autowired
1483
    @Autowired
1471
    PsiSmartService psiSmartService;
1484
    PsiSmartService psiSmartService;
-
 
1485
 
1472
    @RequestMapping(value = "/psi/auth-endpoint", method = RequestMethod.GET)
1486
    @RequestMapping(value = "/psi/auth-endpoint", method = RequestMethod.GET)
1473
    public ResponseEntity<?> getPartnerPSIUrl(HttpServletRequest request) throws Exception {
1487
    public ResponseEntity<?> getPartnerPSIUrl(HttpServletRequest request) throws Exception {
1474
        LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
1488
        LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
1475
        CustomRetailer customRetailer = retailerService.getAllFofoRetailers().get(loginDetails.getFofoId());
1489
        CustomRetailer customRetailer = retailerService.getAllFofoRetailers().get(loginDetails.getFofoId());
1476
        return responseSender.ok(psiSmartService.getRegistrationEndPoint(customRetailer.getMobileNumber()));
1490
        return responseSender.ok(psiSmartService.getRegistrationEndPoint(customRetailer.getMobileNumber()));
Line 1857... Line 1871...
1857
        String email = loginDetails.getEmailId();
1871
        String email = loginDetails.getEmailId();
1858
        Set<Integer> authFofoIds = csService1.getAuthFofoIds(email, true);
1872
        Set<Integer> authFofoIds = csService1.getAuthFofoIds(email, true);
1859
 
1873
 
1860
        Set<Integer> fofoIdlist = fofoStoreRepository.selectActiveStores().stream().filter(x -> !x.isInternal()).map(x -> x.getId()).collect(Collectors.toSet());
1874
        Set<Integer> fofoIdlist = fofoStoreRepository.selectActiveStores().stream().filter(x -> !x.isInternal()).map(x -> x.getId()).collect(Collectors.toSet());
1861
        Set<Integer> fofoIds = null;
1875
        Set<Integer> fofoIds = null;
1862
        if(authFofoIds != null){
1876
        if (authFofoIds != null) {
1863
            fofoIds = authFofoIds.stream().filter(x -> fofoIdlist.contains(x)).collect(Collectors.toSet());
1877
            fofoIds = authFofoIds.stream().filter(x -> fofoIdlist.contains(x)).collect(Collectors.toSet());
1864
        }
1878
        }
1865
 
1879
 
1866
 
1880
 
1867
        Map<Integer, Double> last3MonthSale = fofoOrderItemRepository.selectSumMopGroupByRetailer(
1881
        Map<Integer, Double> last3MonthSale = fofoOrderItemRepository.selectSumMopGroupByRetailer(
Line 1941... Line 1955...
1941
 
1955
 
1942
        Set<Integer> authFofoIds = csService1.getAuthFofoIds(email, true);
1956
        Set<Integer> authFofoIds = csService1.getAuthFofoIds(email, true);
1943
 
1957
 
1944
        Set<Integer> fofoIdlist = fofoStoreRepository.selectActiveStores().stream().filter(x -> !x.isInternal()).map(x -> x.getId()).collect(Collectors.toSet());
1958
        Set<Integer> fofoIdlist = fofoStoreRepository.selectActiveStores().stream().filter(x -> !x.isInternal()).map(x -> x.getId()).collect(Collectors.toSet());
1945
        Set<Integer> fofoIds = null;
1959
        Set<Integer> fofoIds = null;
1946
        if(authFofoIds != null){
1960
        if (authFofoIds != null) {
1947
            fofoIds = authFofoIds.stream().filter(x -> fofoIdlist.contains(x)).collect(Collectors.toSet());
1961
            fofoIds = authFofoIds.stream().filter(x -> fofoIdlist.contains(x)).collect(Collectors.toSet());
1948
        }
1962
        }
1949
 
1963
 
1950
        Map<Integer, Double> last3MonthS = orderRepository.selectBillingDatesBetweenSumGroupByRetailerId(
1964
        Map<Integer, Double> last3MonthS = orderRepository.selectBillingDatesBetweenSumGroupByRetailerId(
1951
                LocalDateTime.now().withDayOfMonth(1).minusMonths(2), LocalDateTime.now());
1965
                LocalDateTime.now().withDayOfMonth(1).minusMonths(2), LocalDateTime.now());