Subversion Repositories SmartDukaan

Rev

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

Rev 35243 Rev 35309
Line 1374... Line 1374...
1374
        logger.info("getting the user resonse {} ",userInfo);
1374
        logger.info("getting the user resonse {} ",userInfo);
1375
        Map<String, MonthSaleModel> monthSaleMap = new HashMap<>();
1375
        Map<String, MonthSaleModel> monthSaleMap = new HashMap<>();
1376
        LocalDateTime curDate = LocalDate.now().atStartOfDay();
1376
        LocalDateTime curDate = LocalDate.now().atStartOfDay();
1377
        int dayOfMonth = curDate.getDayOfMonth();
1377
        int dayOfMonth = curDate.getDayOfMonth();
1378
        YearMonth yearMonth = YearMonth.now();
1378
        YearMonth yearMonth = YearMonth.now();
1379
        for (int i = 1; i <= 6; i++) {
1379
        for (int i = 0; i <= 6; i++) {
1380
            LocalDateTime startOfMonth = curDate.withDayOfMonth(1).minusMonths(i);
1380
            LocalDateTime startOfMonth = curDate.withDayOfMonth(1).minusMonths(i);
1381
            int lengthOfMonth = YearMonth.from(startOfMonth).lengthOfMonth();
1381
            int lengthOfMonth = YearMonth.from(startOfMonth).lengthOfMonth();
1382
            logger.info("Start of previous Month {}, start of next month Month {}", startOfMonth, startOfMonth.plusMonths(1));
1382
            logger.info("Start of previous Month {}, start of next month Month {}", startOfMonth, startOfMonth.plusMonths(1));
1383
            double monthSales = fofoOrderItemRepository.selectSumMopGroupByRetailer(startOfMonth, startOfMonth.plusMonths(1), fofoId, false).get(fofoId);
1383
            double monthSales = fofoOrderItemRepository.selectSumMopGroupByRetailer(startOfMonth, startOfMonth.plusMonths(1), fofoId, false).get(fofoId);
1384
            double mtdSales = fofoOrderItemRepository.selectSumMopGroupByRetailer(startOfMonth, startOfMonth.plusDays(Math.min(dayOfMonth, lengthOfMonth)), fofoId, false).get(fofoId);
1384
            double mtdSales = fofoOrderItemRepository.selectSumMopGroupByRetailer(startOfMonth, startOfMonth.plusDays(Math.min(dayOfMonth, lengthOfMonth)), fofoId, false).get(fofoId);
Line 1395... Line 1395...
1395
    @RequestMapping(value = "/getBrandwisePartnerSale", method = RequestMethod.GET)
1395
    @RequestMapping(value = "/getBrandwisePartnerSale", method = RequestMethod.GET)
1396
    @ResponseBody
1396
    @ResponseBody
1397
    public ResponseEntity<?> getBrandwisePartnerSale(HttpServletRequest request, @RequestParam(name = "month", required = true, defaultValue = "0") int month, Model model) throws Exception {
1397
    public ResponseEntity<?> getBrandwisePartnerSale(HttpServletRequest request, @RequestParam(name = "month", required = true, defaultValue = "0") int month, Model model) throws Exception {
1398
        UserInfo userInfo = (UserInfo) request.getAttribute("userInfo");
1398
        UserInfo userInfo = (UserInfo) request.getAttribute("userInfo");
1399
        int fofoId = userInfo.getRetailerId();
1399
        int fofoId = userInfo.getRetailerId();
1400
        if (month < 1 || month > 12) {
-
 
1401
            throw new IllegalArgumentException("Month must be between 1 and 12");
-
 
1402
        }
-
 
1403
        List<BrandWisePartnerSaleModel> brandWisePartnerSaleModels = fofoStoreRepository.selectBrandWiseMonthlyPartnerSale(Collections.singletonList(fofoId), month);
1400
        List<BrandWisePartnerSaleModel> brandWisePartnerSaleModels = fofoStoreRepository.selectBrandWiseMonthlyPartnerSale(Collections.singletonList(fofoId), month);
1404
        List<Map<String, Object>> response = new ArrayList<>();
1401
        List<Map<String, Object>> response = new ArrayList<>();
1405
        for (BrandWisePartnerSaleModel m : brandWisePartnerSaleModels) {
1402
        for (BrandWisePartnerSaleModel m : brandWisePartnerSaleModels) {
1406
            Map<String, Object> row = new HashMap<>();
1403
            Map<String, Object> row = new HashMap<>();
1407
            row.put("brand", m.getBrand());
1404
            row.put("brand", m.getBrand());
Line 1420... Line 1417...
1420
    @RequestMapping(value = "/getBrandItemwisePartnerSale", method = RequestMethod.GET)
1417
    @RequestMapping(value = "/getBrandItemwisePartnerSale", method = RequestMethod.GET)
1421
    @ResponseBody
1418
    @ResponseBody
1422
    public ResponseEntity<?> getBrandItemwisePartnerSale(HttpServletRequest request, @RequestParam(name = "month", required = true, defaultValue = "0") int month, @RequestParam(name = "brand") String brand) throws Exception {
1419
    public ResponseEntity<?> getBrandItemwisePartnerSale(HttpServletRequest request, @RequestParam(name = "month", required = true, defaultValue = "0") int month, @RequestParam(name = "brand") String brand) throws Exception {
1423
        UserInfo userInfo = (UserInfo) request.getAttribute("userInfo");
1420
        UserInfo userInfo = (UserInfo) request.getAttribute("userInfo");
1424
        int fofoId = userInfo.getRetailerId();
1421
        int fofoId = userInfo.getRetailerId();
1425
        if (month < 1 || month > 12) {
-
 
1426
            throw new IllegalArgumentException("Month must be between 1 and 12");
-
 
1427
        }
-
 
1428
        List<BrandItemWisePartnerSaleModel> brandItemWisePartnerSaleModels = fofoStoreRepository.selectPartnerBrandItemMonthlySale(Collections.singletonList(fofoId), month, brand);
1422
        List<BrandItemWisePartnerSaleModel> brandItemWisePartnerSaleModels = fofoStoreRepository.selectPartnerBrandItemMonthlySale(Collections.singletonList(fofoId), month, brand);
1429
        logger.info("getting brandwise item sale {}",brandItemWisePartnerSaleModels);
1423
        logger.info("getting brandwise item sale {}",brandItemWisePartnerSaleModels);
1430
        return responseSender.ok(brandItemWisePartnerSaleModels);
1424
        return responseSender.ok(brandItemWisePartnerSaleModels);
1431
    }
1425
    }
1432
 
1426