Subversion Repositories SmartDukaan

Rev

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

Rev 27739 Rev 27749
Line 1314... Line 1314...
1314
		poModel.setThreedaysValue(poThreedaysValue);
1314
		poModel.setThreedaysValue(poThreedaysValue);
1315
		poModel.setSevendaysValue(poSevendaysValue);
1315
		poModel.setSevendaysValue(poSevendaysValue);
1316
		poModel.setSevendaysQty(poSevendaysQty);
1316
		poModel.setSevendaysQty(poSevendaysQty);
1317
		poModel.setThreedaysQty(poThreedaysQty);
1317
		poModel.setThreedaysQty(poThreedaysQty);
1318
		poModel.setTodayQty(poTodayQty);
1318
		poModel.setTodayQty(poTodayQty);
1319
 
-
 
1320
		openPO.add(poModel);
1319
		openPO.add(poModel);
1321
 
1320
 
1322
		long purtodayValue = 0;
1321
		long purtodayValue = 0;
1323
		long purthreedaysValue = 0;
1322
		long purthreedaysValue = 0;
1324
		long purfifteendaysValue = 0;
1323
		long purlmsValue = 0;
1325
		long purmtd = 0;
1324
		long purmtd = 0;
1326
		long purtodayQty = 0;
1325
		long purtodayQty = 0;
1327
		long purthreedaysQty = 0;
1326
		long purthreedaysQty = 0;
1328
		long purfifteendaysQty = 0;
1327
		long purlmsQty = 0;
1329
		long purmtdQty = 0;
1328
		long purmtdQty = 0;
1330
 
1329
 
1331
		List<OurPurchaseModel> purchase = warehouseScanRepository.selectOurPurchase(warehouseIds);
1330
		List<OurPurchaseModel> purchase = warehouseScanRepository.selectOurPurchase(warehouseIds);
1332
 
1331
 
1333
		for (OurPurchaseModel pm : purchase) {
1332
		for (OurPurchaseModel pm : purchase) {
1334
			purtodayValue += pm.getTodayValue();
1333
			purtodayValue += pm.getTodayValue();
1335
			purthreedaysValue += pm.getThreedaysValue();
1334
			purthreedaysValue += pm.getThreedaysValue();
1336
			purfifteendaysValue += pm.getFifteendaysValue();
1335
			purlmsValue += pm.getLms();
1337
			purmtd += pm.getMtd();
1336
			purmtd += pm.getMtd();
1338
			purtodayQty += pm.getTodayQty();
1337
			purtodayQty += pm.getTodayQty();
1339
			poThreedaysQty += pm.getThreedaysQty();
1338
			purthreedaysQty += pm.getThreedaysQty();
1340
			purfifteendaysQty += pm.getFifteendaysQty();
1339
			purlmsQty += pm.getLmsQty();
1341
			purmtdQty += pm.getMtdQty();
1340
			purmtdQty += pm.getMtdQty();
1342
		}
1341
		}
1343
		OurPurchaseModel omp = new OurPurchaseModel();
1342
		OurPurchaseModel omp = new OurPurchaseModel();
1344
		omp.setBrand("Total Values");
1343
		omp.setBrand("Total Values");
1345
		omp.setTodayValue(purtodayValue);
1344
		omp.setTodayValue(purtodayValue);
1346
		omp.setThreedaysValue(purthreedaysValue);
1345
		omp.setThreedaysValue(purthreedaysValue);
1347
		omp.setFifteendaysValue(purfifteendaysValue);
1346
		omp.setLms(purlmsValue);
1348
		omp.setMtd(purmtd);
1347
		omp.setMtd(purmtd);
1349
		omp.setTodayQty(purtodayQty);
1348
		omp.setTodayQty(purtodayQty);
1350
		omp.setThreedaysQty(purthreedaysQty);
1349
		omp.setThreedaysQty(purthreedaysQty);
1351
		omp.setFifteendaysQty(purfifteendaysQty);
1350
		omp.setLmsQty(purlmsQty);
1352
		omp.setMtdQty(purmtdQty);
1351
		omp.setMtdQty(purmtdQty);
1353
		purchase.add(omp);
1352
		purchase.add(omp);
-
 
1353
 
1354
		List<BrandWiseTertiaryModel> tertiary = fofoOrderRepository.selectGroupByBrandPartnerTertiary(warehouseIds);
1354
		List<BrandWiseTertiaryModel> tertiary = fofoOrderRepository.selectGroupByBrandPartnerTertiary(warehouseIds);
1355
		long tertodayValue = 0;
1355
		long tertodayValue = 0;
1356
		long terthreedaysValue = 0;
1356
		long terthreedaysValue = 0;
1357
		long termtd = 0;
1357
		long termtd = 0;
1358
		long terlmtd = 0;
1358
		long terlmtd = 0;
-
 
1359
		long terlms = 0;
1359
		long tertodayQty = 0;
1360
		long tertodayQty = 0;
1360
		long terthreedaysQty = 0;
1361
		long terthreedaysQty = 0;
1361
		long termtdQty = 0;
1362
		long termtdQty = 0;
1362
		long terlmtdQty = 0;
1363
		long terlmtdQty = 0;
-
 
1364
		long terlmsQty = 0;
1363
		for (BrandWiseTertiaryModel btm : tertiary) {
1365
		for (BrandWiseTertiaryModel btm : tertiary) {
1364
			tertodayValue += btm.getTodayValue();
1366
			tertodayValue += btm.getTodayValue();
1365
			terthreedaysValue += btm.getThreedaysValue();
1367
			terthreedaysValue += btm.getThreedaysValue();
1366
			termtd += btm.getMtd();
1368
			termtd += btm.getMtd();
1367
			terlmtd += btm.getLmtd();
1369
			terlmtd += btm.getLmtd();
-
 
1370
			terlms += btm.getLms();
1368
			tertodayQty += btm.getTodayQty();
1371
			tertodayQty += btm.getTodayQty();
1369
			terthreedaysQty += btm.getThreedaysQty();
1372
			terthreedaysQty += btm.getThreedaysQty();
1370
			termtdQty += btm.getMtdQty();
1373
			termtdQty += btm.getMtdQty();
1371
			terlmtdQty += btm.getLmtdQty();
1374
			terlmtdQty += btm.getLmtdQty();
-
 
1375
			terlmsQty += btm.getLmsQty();
1372
		}
1376
		}
1373
		BrandWiseTertiaryModel bwt = new BrandWiseTertiaryModel();
1377
		BrandWiseTertiaryModel bwt = new BrandWiseTertiaryModel();
1374
		bwt.setBrand("Total Values");
1378
		bwt.setBrand("Total Values");
1375
		bwt.setTodayValue(tertodayValue);
1379
		bwt.setTodayValue(tertodayValue);
1376
		bwt.setThreedaysValue(terthreedaysValue);
1380
		bwt.setThreedaysValue(terthreedaysValue);
1377
		bwt.setMtd(termtd);
1381
		bwt.setMtd(termtd);
1378
		bwt.setLmtd(terlmtd);
1382
		bwt.setLmtd(terlmtd);
-
 
1383
		bwt.setLms(terlms);
1379
		bwt.setTodayQty(tertodayQty);
1384
		bwt.setTodayQty(tertodayQty);
1380
		bwt.setThreedaysQty(terthreedaysQty);
1385
		bwt.setThreedaysQty(terthreedaysQty);
1381
		bwt.setMtdQty(termtdQty);
1386
		bwt.setMtdQty(termtdQty);
1382
		bwt.setLmtdQty(terlmtdQty);
1387
		bwt.setLmtdQty(terlmtdQty);
-
 
1388
		bwt.setLmsQty(terlmsQty);
1383
		tertiary.add(bwt);
1389
		tertiary.add(bwt);
-
 
1390
 
1384
		List<SecondaryOrderBillingModel> billing = orderRepository.selectAllBilledOrderGroupByBrand(warehouseIds);
1391
		List<SecondaryOrderBillingModel> billing = orderRepository.selectAllBilledOrderGroupByBrand(warehouseIds);
1385
		long sectodayValue = 0;
1392
		long sectodayValue = 0;
1386
		long secthreedaysValue = 0;
1393
		long secthreedaysValue = 0;
1387
		long secmtd = 0;
1394
		long secmtd = 0;
1388
		long seclmtd = 0;
1395
		long seclmtd = 0;
-
 
1396
		long seclms = 0;
1389
		long sectodayQty = 0;
1397
		long sectodayQty = 0;
1390
		long secthreedaysQty = 0;
1398
		long secthreedaysQty = 0;
1391
		long secmtdQty = 0;
1399
		long secmtdQty = 0;
1392
		long seclmtdQty = 0;
1400
		long seclmtdQty = 0;
-
 
1401
		long seclmsQty = 0;
1393
		for (SecondaryOrderBillingModel sbm : billing) {
1402
		for (SecondaryOrderBillingModel sbm : billing) {
1394
			sectodayValue += sbm.getTodayValue();
1403
			sectodayValue += sbm.getTodayValue();
1395
			secthreedaysValue += sbm.getThreedaysValue();
1404
			secthreedaysValue += sbm.getThreedaysValue();
1396
			secmtd += sbm.getMtd();
1405
			secmtd += sbm.getMtd();
1397
			seclmtd += sbm.getLmtd();
1406
			seclmtd += sbm.getLmtd();
-
 
1407
			seclms += sbm.getLms();
1398
			sectodayQty += sbm.getTodayQty();
1408
			sectodayQty += sbm.getTodayQty();
1399
			secthreedaysQty += sbm.getThreedaysQty();
1409
			secthreedaysQty += sbm.getThreedaysQty();
1400
			secmtdQty += sbm.getMtdQty();
1410
			secmtdQty += sbm.getMtdQty();
1401
			seclmtdQty += sbm.getLmtdQty();
1411
			seclmtdQty += sbm.getLmtdQty();
-
 
1412
			seclmsQty += sbm.getLmsQty();
1402
		}
1413
		}
1403
 
1414
 
1404
		SecondaryOrderBillingModel som = new SecondaryOrderBillingModel();
1415
		SecondaryOrderBillingModel som = new SecondaryOrderBillingModel();
1405
		som.setBrand("Total Values");
1416
		som.setBrand("Total Values");
1406
		som.setTodayValue(sectodayValue);
1417
		som.setTodayValue(sectodayValue);
1407
		som.setThreedaysValue(secthreedaysValue);
1418
		som.setThreedaysValue(secthreedaysValue);
1408
		som.setMtd(secmtd);
1419
		som.setMtd(secmtd);
1409
		som.setLmtd(seclmtd);
1420
		som.setLmtd(seclmtd);
-
 
1421
		som.setLms(seclms);
1410
		som.setTodayQty(sectodayQty);
1422
		som.setTodayQty(sectodayQty);
1411
		som.setThreedaysQty(secthreedaysQty);
1423
		som.setThreedaysQty(secthreedaysQty);
1412
		som.setMtdQty(secmtdQty);
1424
		som.setMtdQty(secmtdQty);
1413
		som.setLmtdQty(seclmtdQty);
1425
		som.setLmtdQty(seclmtdQty);
-
 
1426
		som.setLmsQty(seclmsQty);
1414
		billing.add(som);
1427
		billing.add(som);
1415
		LOGGER.info("openPO" + openPO);
1428
		LOGGER.info("openPO" + openPO);
1416
		LOGGER.info("purchase" + purchase);
1429
		LOGGER.info("purchase" + purchase);
1417
		LOGGER.info("tertiary" + tertiary);
1430
		LOGGER.info("tertiary" + tertiary);
1418
		LOGGER.info("billing" + billing);
1431
		LOGGER.info("billing" + billing);
Line 1429... Line 1442...
1429
	}
1442
	}
1430
 
1443
 
1431
	@RequestMapping(value = "/getOpenPoItemByBrand", method = RequestMethod.GET)
1444
	@RequestMapping(value = "/getOpenPoItemByBrand", method = RequestMethod.GET)
1432
	public String Inventory(HttpServletRequest request,
1445
	public String Inventory(HttpServletRequest request,
1433
			@RequestParam(name = "warehouseIds", required = true, defaultValue = "0") List<Integer> warehouseIds,
1446
			@RequestParam(name = "warehouseIds", required = true, defaultValue = "0") List<Integer> warehouseIds,
-
 
1447
			@RequestParam(name = "brand", required = true, defaultValue = "") List<String> brand, int timeValue,
1434
			String brand, int timeValue, Model model) throws Exception {
1448
			Model model) throws Exception {
1435
		model.addAttribute("warehouseId", warehouseIds);
1449
		model.addAttribute("warehouseId", warehouseIds);
1436
		LOGGER.info("warehouseIds" + warehouseIds);
1450
		LOGGER.info("warehouseIds" + warehouseIds);
1437
 
1451
 
1438
		Map<Integer, String> warehouseMap = ProfitMandiConstants.WAREHOUSE_MAP;
1452
		Map<Integer, String> warehouseMap = ProfitMandiConstants.WAREHOUSE_MAP;
1439
		if (warehouseIds.contains(0)) {
1453
		if (warehouseIds.contains(0)) {
1440
			warehouseIds.addAll(warehouseMap.keySet());
1454
			warehouseIds.addAll(warehouseMap.keySet());
1441
		}
1455
		}
-
 
1456
		LOGGER.info("brand" + brand);
-
 
1457
 
-
 
1458
		if (brand.contains("Total Values")) {
-
 
1459
			List<String> poBrands = warehousePurchaseOrderRepository.selectOpenPol(warehouseIds).stream()
-
 
1460
					.map(x -> x.getBrand()).collect(Collectors.toList());
-
 
1461
 
-
 
1462
			brand.addAll(poBrands);
-
 
1463
		}
-
 
1464
 
-
 
1465
		LOGGER.info("brand" + brand);
1442
		LocalDateTime curDate = LocalDate.now().atStartOfDay();
1466
		LocalDateTime curDate = LocalDate.now().atStartOfDay();
1443
		List<OpenPoItemModel> openPOItem = null;
1467
		List<OpenPoItemModel> openPOItem = null;
1444
		if (timeValue != 0) {
1468
		if (timeValue != 0) {
1445
			openPOItem = warehousePurchaseOrderRepository.selectOpenPoItem(warehouseIds, brand,
1469
			openPOItem = warehousePurchaseOrderRepository.selectOpenPoItem(warehouseIds, brand,
1446
					curDate.minusDays(timeValue), curDate);
1470
					curDate.minusDays(timeValue), curDate);
Line 1456... Line 1480...
1456
	}
1480
	}
1457
 
1481
 
1458
	@RequestMapping(value = "/getOurPurchaseItemByBrand", method = RequestMethod.GET)
1482
	@RequestMapping(value = "/getOurPurchaseItemByBrand", method = RequestMethod.GET)
1459
	public String getOurPurchaseItemByBrand(HttpServletRequest request,
1483
	public String getOurPurchaseItemByBrand(HttpServletRequest request,
1460
			@RequestParam(name = "warehouseIds", required = true, defaultValue = "0") List<Integer> warehouseIds,
1484
			@RequestParam(name = "warehouseIds", required = true, defaultValue = "0") List<Integer> warehouseIds,
-
 
1485
			@RequestParam(name = "brand", required = true, defaultValue = "") List<String> brand, int timeValue,
1461
			String brand, int timeValue, Model model) throws Exception {
1486
			Model model) throws Exception {
1462
		model.addAttribute("warehouseId", warehouseIds);
1487
		model.addAttribute("warehouseId", warehouseIds);
1463
		LOGGER.info("warehouseIds" + warehouseIds);
1488
		LOGGER.info("warehouseIds" + warehouseIds);
1464
 
1489
 
1465
		Map<Integer, String> warehouseMap = ProfitMandiConstants.WAREHOUSE_MAP;
1490
		Map<Integer, String> warehouseMap = ProfitMandiConstants.WAREHOUSE_MAP;
1466
		if (warehouseIds.contains(0)) {
1491
		if (warehouseIds.contains(0)) {
1467
			warehouseIds.addAll(warehouseMap.keySet());
1492
			warehouseIds.addAll(warehouseMap.keySet());
1468
		}
1493
		}
1469
		LocalDateTime curDate = LocalDate.now().atStartOfDay();
1494
		LocalDateTime curDate = LocalDate.now().atStartOfDay();
-
 
1495
 
-
 
1496
		if (brand.contains("Total Values")) {
-
 
1497
			List<String> purchasebrands = warehouseScanRepository.selectOurPurchase(warehouseIds).stream()
-
 
1498
					.map(x -> x.getBrand()).collect(Collectors.toList());
-
 
1499
 
-
 
1500
			brand.addAll(purchasebrands);
-
 
1501
		}
1470
		List<OurPurchaseItemModel> ourPurchaseItem = null;
1502
		List<OurPurchaseItemModel> ourPurchaseItem = null;
1471
		if (timeValue != 0) {
1503
		if (timeValue != 0) {
1472
			if (timeValue != 1) {
1504
			if (timeValue == 1) {
1473
				ourPurchaseItem = warehouseScanRepository.selectOurPurchaseItemByBrand(warehouseIds, brand,
1505
				ourPurchaseItem = warehouseScanRepository.selectOurPurchaseItemByBrand(warehouseIds, brand,
1474
						curDate.minusDays(timeValue), curDate);
1506
						curDate.withDayOfMonth(1), curDate.plusDays(1));
-
 
1507
 
-
 
1508
			} else if (timeValue == -1) {
-
 
1509
 
-
 
1510
				ourPurchaseItem = warehouseScanRepository.selectOurPurchaseItemByBrand(warehouseIds, brand,
-
 
1511
						curDate.minusMonths(1).withDayOfMonth(1), curDate.withDayOfMonth(1));
-
 
1512
 
1475
			} else {
1513
			} else {
1476
				ourPurchaseItem = warehouseScanRepository.selectOurPurchaseItemByBrand(warehouseIds, brand,
1514
				ourPurchaseItem = warehouseScanRepository.selectOurPurchaseItemByBrand(warehouseIds, brand,
1477
						curDate.withDayOfMonth(1), curDate.plusDays(1));
1515
						curDate.minusDays(timeValue), curDate);
-
 
1516
 
1478
			}
1517
			}
1479
		} else {
1518
		} else {
1480
			ourPurchaseItem = warehouseScanRepository.selectTodayOurPurchaseItemByBrand(warehouseIds, brand, curDate);
1519
			ourPurchaseItem = warehouseScanRepository.selectTodayOurPurchaseItemByBrand(warehouseIds, brand, curDate);
1481
		}
1520
		}
1482
		LOGGER.info("ourPurchaseItem" + ourPurchaseItem);
1521
		LOGGER.info("ourPurchaseItem" + ourPurchaseItem);
1483
 
1522
 
1484
		model.addAttribute("ourPurchaseItem", ourPurchaseItem);
1523
		model.addAttribute("ourPurchaseItem", ourPurchaseItem);
-
 
1524
		model.addAttribute("warehouseMap", warehouseMap);
1485
 
1525
 
1486
		return "inventory-listing-purchase-item";
1526
		return "inventory-listing-purchase-item";
1487
 
1527
 
1488
	}
1528
	}
1489
 
1529
 
1490
	@RequestMapping(value = "/getSecondaryBillingItemByBrand", method = RequestMethod.GET)
1530
	@RequestMapping(value = "/getSecondaryBillingItemByBrand", method = RequestMethod.GET)
1491
	public String getSecondaryBillingItemByBrand(HttpServletRequest request,
1531
	public String getSecondaryBillingItemByBrand(HttpServletRequest request,
1492
			@RequestParam(name = "warehouseIds", required = true, defaultValue = "0") List<Integer> warehouseIds,
1532
			@RequestParam(name = "warehouseIds", required = true, defaultValue = "0") List<Integer> warehouseIds,
-
 
1533
			@RequestParam(name = "brand", required = true, defaultValue = "") List<String> brand, int timeValue,
1493
			String brand, int timeValue, Model model) throws Exception {
1534
			Model model) throws Exception {
1494
		model.addAttribute("warehouseId", warehouseIds);
1535
		model.addAttribute("warehouseId", warehouseIds);
1495
		LOGGER.info("warehouseIds" + warehouseIds);
1536
		LOGGER.info("warehouseIds" + warehouseIds);
1496
 
1537
 
1497
		Map<Integer, String> warehouseMap = ProfitMandiConstants.WAREHOUSE_MAP;
1538
		Map<Integer, String> warehouseMap = ProfitMandiConstants.WAREHOUSE_MAP;
1498
		if (warehouseIds.contains(0)) {
1539
		if (warehouseIds.contains(0)) {
1499
			warehouseIds.addAll(warehouseMap.keySet());
1540
			warehouseIds.addAll(warehouseMap.keySet());
1500
		}
1541
		}
1501
		LocalDateTime curDate = LocalDate.now().atStartOfDay();
1542
		LocalDateTime curDate = LocalDate.now().atStartOfDay();
-
 
1543
		int dayOfMonth = curDate.getDayOfMonth();
-
 
1544
		LocalDateTime startOfMonth = curDate.withDayOfMonth(1);
-
 
1545
		int lengthOfMonth = YearMonth.from(startOfMonth.minusMonths(1)).lengthOfMonth();
-
 
1546
 
-
 
1547
		if (brand.contains("Total Values")) {
-
 
1548
			List<String> billingbrands = orderRepository.selectAllBilledOrderGroupByBrand(warehouseIds).stream()
-
 
1549
					.map(x -> x.getBrand()).collect(Collectors.toList());
-
 
1550
 
-
 
1551
			brand.addAll(billingbrands);
-
 
1552
		}
1502
		List<SecondaryOrderItemBillingModel> billedItem = null;
1553
		List<SecondaryOrderItemBillingModel> billedItem = null;
1503
		if (timeValue != 0) {
1554
		if (timeValue != 0) {
1504
			if (timeValue == 1) {
1555
			if (timeValue == 1) {
1505
				billedItem = orderRepository.selectAllBilledOrderItemByBrand(warehouseIds, brand,
1556
				billedItem = orderRepository.selectAllBilledOrderItemByBrand(warehouseIds, brand,
1506
						curDate.withDayOfMonth(1), curDate.plusDays(1));
1557
						curDate.withDayOfMonth(1), curDate.plusDays(1));
1507
 
1558
 
1508
			} else if (timeValue == 2) {
1559
			} else if (timeValue == 2) {
-
 
1560
				LOGGER.info("curDate" + curDate.withDayOfMonth(1).minusMonths(1));
-
 
1561
				LOGGER.info("curDate" + curDate.minusMonths(1).plusDays(Math.min(dayOfMonth, lengthOfMonth)));
-
 
1562
 
1509
				billedItem = orderRepository.selectAllBilledOrderItemByBrand(warehouseIds, brand,
1563
				billedItem = orderRepository.selectAllBilledOrderItemByBrand(warehouseIds, brand,
1510
						curDate.withDayOfMonth(1).minusMonths(1),
1564
						curDate.withDayOfMonth(1).minusMonths(1),
-
 
1565
						startOfMonth.minusMonths(1).plusDays(Math.min(dayOfMonth, lengthOfMonth)));
-
 
1566
			} else if (timeValue == -1) {
-
 
1567
				billedItem = orderRepository.selectAllBilledOrderItemByBrand(warehouseIds, brand,
1511
						curDate.with(LocalTime.MAX).minusMonths(1).plusDays(1));
1568
						curDate.minusMonths(1).withDayOfMonth(1), startOfMonth);
1512
 
-
 
1513
			} else {
1569
			} else {
-
 
1570
 
1514
				billedItem = orderRepository.selectAllBilledOrderItemByBrand(warehouseIds, brand,
1571
				billedItem = orderRepository.selectAllBilledOrderItemByBrand(warehouseIds, brand,
1515
						curDate.minusDays(timeValue), curDate);
1572
						curDate.minusDays(timeValue), curDate);
1516
			}
1573
			}
1517
 
1574
 
1518
		} else {
1575
		} else {
Line 1527... Line 1584...
1527
	}
1584
	}
1528
 
1585
 
1529
	@RequestMapping(value = "/getPartnerTertiaryItemByBrand", method = RequestMethod.GET)
1586
	@RequestMapping(value = "/getPartnerTertiaryItemByBrand", method = RequestMethod.GET)
1530
	public String getPartnerTertiaryItemByBrand(HttpServletRequest request,
1587
	public String getPartnerTertiaryItemByBrand(HttpServletRequest request,
1531
			@RequestParam(name = "warehouseIds", required = true, defaultValue = "0") List<Integer> warehouseIds,
1588
			@RequestParam(name = "warehouseIds", required = true, defaultValue = "0") List<Integer> warehouseIds,
-
 
1589
			@RequestParam(name = "brand", required = true, defaultValue = "") List<String> brand, int timeValue,
1532
			String brand, int timeValue, Model model) throws Exception {
1590
			Model model) throws Exception {
1533
		model.addAttribute("warehouseId", warehouseIds);
1591
		model.addAttribute("warehouseId", warehouseIds);
1534
		LOGGER.info("warehouseIds" + warehouseIds);
1592
		LOGGER.info("warehouseIds" + warehouseIds);
1535
 
1593
 
1536
		Map<Integer, String> warehouseMap = ProfitMandiConstants.WAREHOUSE_MAP;
1594
		Map<Integer, String> warehouseMap = ProfitMandiConstants.WAREHOUSE_MAP;
1537
		if (warehouseIds.contains(0)) {
1595
		if (warehouseIds.contains(0)) {
1538
			warehouseIds.addAll(warehouseMap.keySet());
1596
			warehouseIds.addAll(warehouseMap.keySet());
1539
		}
1597
		}
1540
		LocalDateTime curDate = LocalDate.now().atStartOfDay();
1598
		LocalDateTime curDate = LocalDate.now().atStartOfDay();
1541
		int dayOfMonth = curDate.getDayOfMonth();
1599
		int dayOfMonth = curDate.getDayOfMonth();
1542
		LocalDateTime startOfMonth = curDate.withDayOfMonth(1);
1600
		LocalDateTime startOfMonth = curDate.withDayOfMonth(1);
1543
		int lengthOfMonth = YearMonth.from(startOfMonth).lengthOfMonth();
1601
		int lengthOfMonth = YearMonth.from(startOfMonth.minusMonths(1)).lengthOfMonth();
-
 
1602
		if (brand.contains("Total Values")) {
-
 
1603
			List<String> tertiaryBrands = fofoOrderRepository.selectGroupByBrandPartnerTertiary(warehouseIds).stream()
-
 
1604
					.map(x -> x.getBrand()).collect(Collectors.toList());
1544
 
1605
 
-
 
1606
			brand.addAll(tertiaryBrands);
-
 
1607
		}
1545
		List<BrandItemWiseTertiaryModel> tertiaryItem = null;
1608
		List<BrandItemWiseTertiaryModel> tertiaryItem = null;
1546
		if (timeValue != 0) {
1609
		if (timeValue != 0) {
1547
			if (timeValue == 1) {
1610
			if (timeValue == 1) {
-
 
1611
 
1548
				tertiaryItem = fofoOrderRepository.selectItemPartnerTertiaryByBrand(warehouseIds, brand,
1612
				tertiaryItem = fofoOrderRepository.selectItemPartnerTertiaryByBrand(warehouseIds, brand,
1549
						curDate.withDayOfMonth(1), curDate.plusDays(1));
1613
						curDate.withDayOfMonth(1), curDate.plusDays(1));
1550
 
1614
 
1551
			} else if (timeValue == 2) {
1615
			} else if (timeValue == 2) {
1552
				LOGGER.info("curDate" + curDate.withDayOfMonth(1).minusMonths(1));
1616
				LOGGER.info("curDate" + startOfMonth.minusMonths(1));
1553
				LOGGER.info("curDate" + curDate.minusMonths(1).plusDays(Math.min(dayOfMonth, lengthOfMonth)));
1617
				LOGGER.info("curDate" + startOfMonth.minusMonths(1).plusDays(Math.min(dayOfMonth, lengthOfMonth)));
1554
 
1618
 
1555
				tertiaryItem = fofoOrderRepository.selectItemPartnerTertiaryByBrand(warehouseIds, brand,
1619
				tertiaryItem = fofoOrderRepository.selectItemPartnerTertiaryByBrand(warehouseIds, brand,
1556
						curDate.withDayOfMonth(1).minusMonths(1),
1620
						startOfMonth.minusMonths(1),
1557
						startOfMonth.minusMonths(1).plusDays(Math.min(dayOfMonth, lengthOfMonth)));
1621
						startOfMonth.minusMonths(1).plusDays(Math.min(dayOfMonth, lengthOfMonth)));
1558
 
1622
 
-
 
1623
			} else if (timeValue == -1) {
-
 
1624
				LOGGER.info("date" + curDate.minusMonths(1).withDayOfMonth(1));
-
 
1625
				LOGGER.info("date" + curDate.minusMonths(1).withDayOfMonth(lengthOfMonth).plusDays(1));
-
 
1626
 
-
 
1627
				tertiaryItem = fofoOrderRepository.selectItemPartnerTertiaryByBrand(warehouseIds, brand,
-
 
1628
						curDate.minusMonths(1).withDayOfMonth(1), startOfMonth);
1559
			} else {
1629
			} else {
1560
				tertiaryItem = fofoOrderRepository.selectItemPartnerTertiaryByBrand(warehouseIds, brand,
1630
				tertiaryItem = fofoOrderRepository.selectItemPartnerTertiaryByBrand(warehouseIds, brand,
1561
						curDate.minusDays(timeValue), curDate);
1631
						curDate.minusDays(timeValue), curDate);
1562
			}
1632
			}
1563
 
1633