Subversion Repositories SmartDukaan

Rev

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

Rev 31238 Rev 31317
Line 223... Line 223...
223
	@Autowired
223
	@Autowired
224
	SaholicCISTableRepository saholicCISTableRepository;
224
	SaholicCISTableRepository saholicCISTableRepository;
225
 
225
 
226
	@RequestMapping(value = "/open-indent/save", method = RequestMethod.POST)
226
	@RequestMapping(value = "/open-indent/save", method = RequestMethod.POST)
227
	public String saveOpenIndent(HttpServletRequest request, Model model, @RequestParam int catalogId,
227
	public String saveOpenIndent(HttpServletRequest request, Model model, @RequestParam int catalogId,
228
								 @RequestParam int itemQty, @RequestParam int fofoId) throws Exception {
228
			@RequestParam int itemQty, @RequestParam int fofoId) throws Exception {
229
		if (fofoId == 0) {
229
		if (fofoId == 0) {
230
 
230
 
231
			LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
231
			LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
232
			fofoId = loginDetails.getFofoId();
232
			fofoId = loginDetails.getFofoId();
233
 
233
 
Line 245... Line 245...
245
		model.addAttribute("response1", mvcResponseSender.createResponseString(false));
245
		model.addAttribute("response1", mvcResponseSender.createResponseString(false));
246
		return "response";
246
		return "response";
247
	}
247
	}
248
 
248
 
249
	private void saveMonthlyPlanned(MonthlyPlanned monthlyPlanned, int fofoId, LocalDate currentMonthDate,
249
	private void saveMonthlyPlanned(MonthlyPlanned monthlyPlanned, int fofoId, LocalDate currentMonthDate,
250
									int catalogId, int itemQty) {
250
			int catalogId, int itemQty) {
251
		if (monthlyPlanned == null) {
251
		if (monthlyPlanned == null) {
252
			monthlyPlanned = new MonthlyPlanned();
252
			monthlyPlanned = new MonthlyPlanned();
253
			monthlyPlanned.setFofoId(fofoId);
253
			monthlyPlanned.setFofoId(fofoId);
254
			monthlyPlanned.setYearMonth(currentMonthDate);
254
			monthlyPlanned.setYearMonth(currentMonthDate);
255
			monthlyPlannedRepository.persist(monthlyPlanned);
255
			monthlyPlannedRepository.persist(monthlyPlanned);
Line 283... Line 283...
283
 
283
 
284
	}
284
	}
285
 
285
 
286
	@RequestMapping(value = "/open-indent/confirm", method = RequestMethod.POST)
286
	@RequestMapping(value = "/open-indent/confirm", method = RequestMethod.POST)
287
	public String confirmOpenIndent(HttpServletRequest request,
287
	public String confirmOpenIndent(HttpServletRequest request,
288
									@RequestParam(required = false, defaultValue = "0") int fofoId, Model model) throws Exception {
288
			@RequestParam(required = false, defaultValue = "0") int fofoId, Model model) throws Exception {
289
 
289
 
290
		if (fofoId == 0) {
290
		if (fofoId == 0) {
291
			LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
291
			LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
292
			fofoId = loginDetails.getFofoId();
292
			fofoId = loginDetails.getFofoId();
293
		}
293
		}
Line 339... Line 339...
339
				Arrays.asList("Partner Id", "Partner Name", "Model Name", "Qty"),
339
				Arrays.asList("Partner Id", "Partner Name", "Model Name", "Qty"),
340
				plannedModel.stream()
340
				plannedModel.stream()
341
						.map(x -> Arrays.asList(x.getFofoId(), x.getStoreName(), x.getItemDescription(), x.getQty()))
341
						.map(x -> Arrays.asList(x.getFofoId(), x.getStoreName(), x.getItemDescription(), x.getQty()))
342
						.collect(Collectors.toList()));
342
						.collect(Collectors.toList()));
343
		LOGGER.info("baos" + baos);
343
		LOGGER.info("baos" + baos);
344
		Utils.sendMailWithAttachments(googleMailSender, new String[]{customRetailer.getEmail()},
344
		Utils.sendMailWithAttachments(googleMailSender, new String[] { customRetailer.getEmail() },
345
				ccemails.toArray(new String[ccemails.size()]), bccemails.toArray(new String[bccemails.size()]),
345
				ccemails.toArray(new String[ccemails.size()]), bccemails.toArray(new String[bccemails.size()]),
346
				"Planned Indent", "PFA",
346
				"Planned Indent", "PFA",
347
				new Attachment[]{new Attachment("PlannedIndent.csv", new ByteArrayResource(baos.toByteArray())),});
347
				new Attachment[] { new Attachment("PlannedIndent.csv", new ByteArrayResource(baos.toByteArray())), });
348
 
348
 
349
	}
349
	}
350
 
350
 
351
	@RequestMapping(value = "/indent/download", method = RequestMethod.GET)
351
	@RequestMapping(value = "/indent/download", method = RequestMethod.GET)
352
	public ResponseEntity<ByteArrayResource> downloadIndent(HttpServletRequest request, Model model,
352
	public ResponseEntity<ByteArrayResource> downloadIndent(HttpServletRequest request, Model model,
353
															@RequestParam(required = false, defaultValue = "0") int fofoId,
353
			@RequestParam(required = false, defaultValue = "0") int fofoId,
354
															@RequestParam(defaultValue = "TEN_LAC") CounterSize counterSize) throws Exception {
354
			@RequestParam(defaultValue = "TEN_LAC") CounterSize counterSize) throws Exception {
355
		LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
355
		LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
356
		Set<Integer> roleIds = loginDetails.getRoleIds();
356
		Set<Integer> roleIds = loginDetails.getRoleIds();
357
		LOGGER.info("Counter size is {}", counterSize);
357
		LOGGER.info("Counter size is {}", counterSize);
358
		LOGGER.info("Fofo Id is {}", fofoId);
358
		LOGGER.info("Fofo Id is {}", fofoId);
359
 
359
 
Line 465... Line 465...
465
 
465
 
466
	}
466
	}
467
 
467
 
468
	@RequestMapping(value = "/itemsByCatalogId")
468
	@RequestMapping(value = "/itemsByCatalogId")
469
	public String getItemsByCatalogId(HttpServletRequest request, Model model,
469
	public String getItemsByCatalogId(HttpServletRequest request, Model model,
470
									  @RequestParam(required = false) int catalogId, @RequestParam(required = false) int itemId)
470
			@RequestParam(required = false) int catalogId, @RequestParam(required = false) int itemId)
471
			throws ProfitMandiBusinessException {
471
			throws ProfitMandiBusinessException {
472
		if (catalogId == 0) {
472
		if (catalogId == 0) {
473
			catalogId = itemRepository.selectById(itemId).getCatalogItemId();
473
			catalogId = itemRepository.selectById(itemId).getCatalogItemId();
474
		}
474
		}
475
		List<Item> items = itemRepository.selectAllByCatalogItemId(catalogId);
475
		List<Item> items = itemRepository.selectAllByCatalogItemId(catalogId);
Line 490... Line 490...
490
 
490
 
491
	}
491
	}
492
 
492
 
493
	@RequestMapping(value = "/hotdealsitemsByCatalogId")
493
	@RequestMapping(value = "/hotdealsitemsByCatalogId")
494
	public String getHotdealsitemsByCatalogId(HttpServletRequest request, Model model,
494
	public String getHotdealsitemsByCatalogId(HttpServletRequest request, Model model,
495
											  @RequestParam(required = false) int catalogId, @RequestParam(required = false) int itemId)
495
			@RequestParam(required = false) int catalogId, @RequestParam(required = false) int itemId)
496
			throws ProfitMandiBusinessException {
496
			throws ProfitMandiBusinessException {
497
		if (catalogId == 0) {
497
		if (catalogId == 0) {
498
			catalogId = itemRepository.selectById(itemId).getCatalogItemId();
498
			catalogId = itemRepository.selectById(itemId).getCatalogItemId();
499
		}
499
		}
500
		List<Item> items = itemRepository.selectAllByCatalogItemId(catalogId);
500
		List<Item> items = itemRepository.selectAllByCatalogItemId(catalogId);
Line 532... Line 532...
532
		}
532
		}
533
		LOGGER.info("Order removed count is {}", orderRemovedCount);
533
		LOGGER.info("Order removed count is {}", orderRemovedCount);
534
		return lastOrdersList;
534
		return lastOrdersList;
535
	}
535
	}
536
 
536
 
537
	//Clean up the saholic cis table
537
	// Clean up the saholic cis table
538
	@RequestMapping(value = "/indent/confirm-pause", method = RequestMethod.POST)
538
	@RequestMapping(value = "/indent/confirm-pause", method = RequestMethod.POST)
539
	public String updateTagListing(HttpServletRequest request, Model model, @RequestBody String jsonArrayString)
539
	public String updateTagListing(HttpServletRequest request, Model model, @RequestBody String jsonArrayString)
540
			throws Exception {
540
			throws Exception {
541
		JSONArray jsonArray = new JSONArray(jsonArrayString);
541
		JSONArray jsonArray = new JSONArray(jsonArrayString);
542
		for (int i = 0; i < jsonArray.length(); i++) {
542
		for (int i = 0; i < jsonArray.length(); i++) {
Line 546... Line 546...
546
			if (tl == null) {
546
			if (tl == null) {
547
				continue;
547
				continue;
548
			} else {
548
			} else {
549
				tl.setActive(obj.getBoolean("active"));
549
				tl.setActive(obj.getBoolean("active"));
550
				if (!tl.isActive()) {
550
				if (!tl.isActive()) {
551
					saholicCISTableRepository.selectAllByItemId(tl.getItemId()).stream().forEach(x -> saholicCISTableRepository.delete(x));
551
					saholicCISTableRepository.selectAllByItemId(tl.getItemId()).stream()
-
 
552
							.forEach(x -> saholicCISTableRepository.delete(x));
552
				}
553
				}
553
			}
554
			}
554
		}
555
		}
555
		model.addAttribute("response1", true);
556
		model.addAttribute("response1", true);
556
		return "response";
557
		return "response";
Line 625... Line 626...
625
				PaymentStatus.SUCCESS, null, paymentAttributes);
626
				PaymentStatus.SUCCESS, null, paymentAttributes);
626
	}
627
	}
627
 
628
 
628
	@RequestMapping(value = "/indent/loadIndent")
629
	@RequestMapping(value = "/indent/loadIndent")
629
	public String loadOpenIndent(HttpServletRequest request, Model model,
630
	public String loadOpenIndent(HttpServletRequest request, Model model,
630
								 @RequestParam(required = false, defaultValue = "0") int fofoId,
631
			@RequestParam(required = false, defaultValue = "0") int fofoId,
631
								 @RequestParam(defaultValue = "TEN_LAC") CounterSize counterSize) throws Exception {
632
			@RequestParam(defaultValue = "TEN_LAC") CounterSize counterSize) throws Exception {
632
 
633
 
633
		LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
634
		LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
634
		Set<Integer> roleIds = loginDetails.getRoleIds();
635
		Set<Integer> roleIds = loginDetails.getRoleIds();
635
		LOGGER.info("Counter size is {}", counterSize);
636
		LOGGER.info("Counter size is {}", counterSize);
636
		LOGGER.info("Fofo Id is {}", fofoId);
637
		LOGGER.info("Fofo Id is {}", fofoId);
Line 713... Line 714...
713
		if (LocalDate.now().isAfter(LocalDate.now().withDayOfMonth(PLANNING_OPEN_DAY))) {
714
		if (LocalDate.now().isAfter(LocalDate.now().withDayOfMonth(PLANNING_OPEN_DAY))) {
714
			planningMonthDate = LocalDate.now().plusMonths(1).withDayOfMonth(1);
715
			planningMonthDate = LocalDate.now().plusMonths(1).withDayOfMonth(1);
715
			monthlyPlanned = monthlyPlannedRepository.selectByFofoIdYearMonth(fofoId, planningMonthDate);
716
			monthlyPlanned = monthlyPlannedRepository.selectByFofoIdYearMonth(fofoId, planningMonthDate);
716
			LOGGER.info("monthlyPlanned2" + monthlyPlanned);
717
			LOGGER.info("monthlyPlanned2" + monthlyPlanned);
717
			fofoOrderIds = fofoOrderRepository.selectByFofoIdBetweenCreatedTimeStamp(loginDetails.getFofoId(),
718
			fofoOrderIds = fofoOrderRepository.selectByFofoIdBetweenCreatedTimeStamp(loginDetails.getFofoId(),
718
							LocalDateTime.now().minusDays(15), LocalDateTime.now()).stream().map(x -> x.getId())
719
					LocalDateTime.now().minusDays(15), LocalDateTime.now()).stream().map(x -> x.getId())
719
					.collect(Collectors.toList());
720
					.collect(Collectors.toList());
720
 
721
 
721
			model.addAttribute("planningMonth", LocalDate.now().plusMonths(1).getMonth());
722
			model.addAttribute("planningMonth", LocalDate.now().plusMonths(1).getMonth());
722
		} else {
723
		} else {
723
			planningMonthDate = LocalDate.now().withDayOfMonth(1);
724
			planningMonthDate = LocalDate.now().withDayOfMonth(1);
Line 725... Line 726...
725
			monthlyPlanned = monthlyPlannedRepository.selectByFofoIdYearMonth(fofoId, planningMonthDate);
726
			monthlyPlanned = monthlyPlannedRepository.selectByFofoIdYearMonth(fofoId, planningMonthDate);
726
			model.addAttribute("planningMonth", planningMonthDate.getMonth());
727
			model.addAttribute("planningMonth", planningMonthDate.getMonth());
727
			model.addAttribute("mtd", true);
728
			model.addAttribute("mtd", true);
728
			model.addAttribute("freezed", true);
729
			model.addAttribute("freezed", true);
729
			fofoOrderIds = fofoOrderRepository.selectByFofoIdBetweenCreatedTimeStamp(loginDetails.getFofoId(),
730
			fofoOrderIds = fofoOrderRepository.selectByFofoIdBetweenCreatedTimeStamp(loginDetails.getFofoId(),
730
							curDate.withDayOfMonth(1), curDate.with(LocalTime.MAX)).stream().map(x -> x.getId())
731
					curDate.withDayOfMonth(1), curDate.with(LocalTime.MAX)).stream().map(x -> x.getId())
731
					.collect(Collectors.toList());
732
					.collect(Collectors.toList());
732
			LOGGER.info("monthlyPlanned1" + monthlyPlanned);
733
			LOGGER.info("monthlyPlanned1" + monthlyPlanned);
733
		}
734
		}
734
 
735
 
735
		Map<Integer, Integer> plannedDetailMap = null;
736
		Map<Integer, Integer> plannedDetailMap = null;
Line 957... Line 958...
957
 
958
 
958
	}
959
	}
959
 
960
 
960
	@RequestMapping(value = "/indent/loadIndentPreviousMonth")
961
	@RequestMapping(value = "/indent/loadIndentPreviousMonth")
961
	public String previousMonthLoadOpenIndent(HttpServletRequest request, Model model,
962
	public String previousMonthLoadOpenIndent(HttpServletRequest request, Model model,
962
											  @RequestParam(required = false, defaultValue = "0") int fofoId,
963
			@RequestParam(required = false, defaultValue = "0") int fofoId,
963
											  @RequestParam(defaultValue = "TEN_LAC") CounterSize counterSize) throws Exception {
964
			@RequestParam(defaultValue = "TEN_LAC") CounterSize counterSize) throws Exception {
964
		LocalDate planMonthStart = null;
965
		LocalDate planMonthStart = null;
965
		if (LocalDate.now().isAfter(LocalDate.now().withDayOfMonth(PLANNING_OPEN_DAY))) {
966
		if (LocalDate.now().isAfter(LocalDate.now().withDayOfMonth(PLANNING_OPEN_DAY))) {
966
			planMonthStart = LocalDate.now().plusMonths(1).withDayOfMonth(1);
967
			planMonthStart = LocalDate.now().plusMonths(1).withDayOfMonth(1);
967
		} else {
968
		} else {
968
			planMonthStart = LocalDate.now().withDayOfMonth(1);
969
			planMonthStart = LocalDate.now().withDayOfMonth(1);
Line 1201... Line 1202...
1201
		return regionMap;
1202
		return regionMap;
1202
	}
1203
	}
1203
 
1204
 
1204
	@RequestMapping(value = "/getFocusedModel", method = RequestMethod.GET)
1205
	@RequestMapping(value = "/getFocusedModel", method = RequestMethod.GET)
1205
	public String getFocusedModel(HttpServletRequest request,
1206
	public String getFocusedModel(HttpServletRequest request,
1206
								  @RequestParam(name = "offset", defaultValue = "0") int offset,
1207
			@RequestParam(name = "offset", defaultValue = "0") int offset,
1207
								  @RequestParam(name = "limit", defaultValue = "10") int limit, Model model)
1208
			@RequestParam(name = "limit", defaultValue = "10") int limit, Model model)
1208
			throws ProfitMandiBusinessException {
1209
			throws ProfitMandiBusinessException {
1209
 
1210
 
1210
		long size = 0;
1211
		long size = 0;
1211
		List<FocusedModel> focusedModels = focusedModelRepository.selectAll(offset, limit);
1212
		List<FocusedModel> focusedModels = focusedModelRepository.selectAll(offset, limit);
1212
 
1213
 
Line 1242... Line 1243...
1242
		return "focused_model";
1243
		return "focused_model";
1243
	}
1244
	}
1244
 
1245
 
1245
	@RequestMapping(value = "/getPaginatedFocusedModel", method = RequestMethod.GET)
1246
	@RequestMapping(value = "/getPaginatedFocusedModel", method = RequestMethod.GET)
1246
	public String getPaginatedFocusedModel(HttpServletRequest request,
1247
	public String getPaginatedFocusedModel(HttpServletRequest request,
1247
										   @RequestParam(name = "offset", defaultValue = "0") int offset,
1248
			@RequestParam(name = "offset", defaultValue = "0") int offset,
1248
										   @RequestParam(name = "limit", defaultValue = "10") int limit, Model model)
1249
			@RequestParam(name = "limit", defaultValue = "10") int limit, Model model)
1249
			throws ProfitMandiBusinessException {
1250
			throws ProfitMandiBusinessException {
1250
		LOGGER.info("requested offset=[{}], limit = [{}]", offset, limit);
1251
		LOGGER.info("requested offset=[{}], limit = [{}]", offset, limit);
1251
		List<FocusedModel> focusedModels = focusedModelRepository.selectAll(offset, limit);
1252
		List<FocusedModel> focusedModels = focusedModelRepository.selectAll(offset, limit);
1252
 
1253
 
1253
		if (!focusedModels.isEmpty()) {
1254
		if (!focusedModels.isEmpty()) {
Line 1328... Line 1329...
1328
 
1329
 
1329
	}
1330
	}
1330
 
1331
 
1331
	@RequestMapping(value = "/focusedModel", method = RequestMethod.POST)
1332
	@RequestMapping(value = "/focusedModel", method = RequestMethod.POST)
1332
	public String focusedModel(HttpServletRequest request, @RequestParam int catalogId,
1333
	public String focusedModel(HttpServletRequest request, @RequestParam int catalogId,
1333
							   @RequestParam(name = "recommended", defaultValue = "0") int recommended,
1334
			@RequestParam(name = "recommended", defaultValue = "0") int recommended,
1334
							   @RequestParam(name = "minimumQty", defaultValue = "0") int minimumQty,
1335
			@RequestParam(name = "minimumQty", defaultValue = "0") int minimumQty,
1335
							   @RequestParam(name = "obvrecommend", defaultValue = "0") int obvrecommend,
1336
			@RequestParam(name = "obvrecommend", defaultValue = "0") int obvrecommend,
1336
							   @RequestParam(name = "obvminimum", defaultValue = "0") int obvminimum, @RequestParam int regionId,
1337
			@RequestParam(name = "obvminimum", defaultValue = "0") int obvminimum, @RequestParam int regionId,
1337
							   Model model) throws ProfitMandiBusinessException {
1338
			Model model) throws ProfitMandiBusinessException {
1338
 
1339
 
1339
		FocusedModel fm = new FocusedModel();
1340
		FocusedModel fm = new FocusedModel();
1340
		fm.setCatalogId(catalogId);
1341
		fm.setCatalogId(catalogId);
1341
		fm.setMinimumQty(minimumQty);
1342
		fm.setMinimumQty(minimumQty);
1342
		fm.setRecommendedQty(recommended);
1343
		fm.setRecommendedQty(recommended);
Line 1348... Line 1349...
1348
		return "focused_model";
1349
		return "focused_model";
1349
	}
1350
	}
1350
 
1351
 
1351
	@RequestMapping(value = "/removeItem", method = RequestMethod.DELETE)
1352
	@RequestMapping(value = "/removeItem", method = RequestMethod.DELETE)
1352
	public String removeFocusedModelItem(HttpServletRequest request,
1353
	public String removeFocusedModelItem(HttpServletRequest request,
1353
										 @RequestParam(name = "id", defaultValue = "0") int id, Model model) throws Exception {
1354
			@RequestParam(name = "id", defaultValue = "0") int id, Model model) throws Exception {
1354
 
1355
 
1355
		focusedModelRepository.deleteById(id);
1356
		focusedModelRepository.deleteById(id);
1356
		model.addAttribute("response1", mvcResponseSender.createResponseString(true));
1357
		model.addAttribute("response1", mvcResponseSender.createResponseString(true));
1357
		return "response";
1358
		return "response";
1358
	}
1359
	}
1359
 
1360
 
1360
	@RequestMapping(value = "/getPartnerloadContent")
1361
	@RequestMapping(value = "/getPartnerloadContent")
1361
	public String getPartnerloadContent(HttpServletRequest request, Model model,
1362
	public String getPartnerloadContent(HttpServletRequest request, Model model,
1362
										@RequestParam(required = false, defaultValue = "0") int fofoId,
1363
			@RequestParam(required = false, defaultValue = "0") int fofoId,
1363
										@RequestParam(defaultValue = "TEN_LAC") CounterSize counterSize) throws Exception {
1364
			@RequestParam(defaultValue = "TEN_LAC") CounterSize counterSize) throws Exception {
1364
 
1365
 
1365
		LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
1366
		LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
1366
		Set<Integer> roleIds = loginDetails.getRoleIds();
1367
		Set<Integer> roleIds = loginDetails.getRoleIds();
1367
		LOGGER.info("Counter size is {}", counterSize);
1368
		LOGGER.info("Counter size is {}", counterSize);
1368
		LOGGER.info("Fofo Id is {}", fofoId);
1369
		LOGGER.info("Fofo Id is {}", fofoId);
Line 1446... Line 1447...
1446
		if (LocalDate.now().isAfter(LocalDate.now().withDayOfMonth(PLANNING_OPEN_DAY))) {
1447
		if (LocalDate.now().isAfter(LocalDate.now().withDayOfMonth(PLANNING_OPEN_DAY))) {
1447
			currentMonthDate = LocalDate.now().plusMonths(1).withDayOfMonth(1);
1448
			currentMonthDate = LocalDate.now().plusMonths(1).withDayOfMonth(1);
1448
			monthlyPlanned = monthlyPlannedRepository.selectByFofoIdYearMonth(fofoId, currentMonthDate);
1449
			monthlyPlanned = monthlyPlannedRepository.selectByFofoIdYearMonth(fofoId, currentMonthDate);
1449
			LOGGER.info("monthlyPlanned2" + monthlyPlanned);
1450
			LOGGER.info("monthlyPlanned2" + monthlyPlanned);
1450
			fofoOrderIds = fofoOrderRepository.selectByFofoIdBetweenCreatedTimeStamp(loginDetails.getFofoId(),
1451
			fofoOrderIds = fofoOrderRepository.selectByFofoIdBetweenCreatedTimeStamp(loginDetails.getFofoId(),
1451
							LocalDateTime.now().minusDays(15), LocalDateTime.now()).stream().map(x -> x.getId())
1452
					LocalDateTime.now().minusDays(15), LocalDateTime.now()).stream().map(x -> x.getId())
1452
					.collect(Collectors.toList());
1453
					.collect(Collectors.toList());
1453
 
1454
 
1454
			model.addAttribute("planningMonth", LocalDate.now().plusMonths(1).getMonth());
1455
			model.addAttribute("planningMonth", LocalDate.now().plusMonths(1).getMonth());
1455
		} else {
1456
		} else {
1456
			currentMonthDate = LocalDate.now().withDayOfMonth(1);
1457
			currentMonthDate = LocalDate.now().withDayOfMonth(1);
Line 1458... Line 1459...
1458
			monthlyPlanned = monthlyPlannedRepository.selectByFofoIdYearMonth(fofoId, currentMonthDate);
1459
			monthlyPlanned = monthlyPlannedRepository.selectByFofoIdYearMonth(fofoId, currentMonthDate);
1459
			model.addAttribute("planningMonth", currentMonthDate.getMonth());
1460
			model.addAttribute("planningMonth", currentMonthDate.getMonth());
1460
			model.addAttribute("mtd", true);
1461
			model.addAttribute("mtd", true);
1461
			model.addAttribute("freezed", true);
1462
			model.addAttribute("freezed", true);
1462
			fofoOrderIds = fofoOrderRepository.selectByFofoIdBetweenCreatedTimeStamp(loginDetails.getFofoId(),
1463
			fofoOrderIds = fofoOrderRepository.selectByFofoIdBetweenCreatedTimeStamp(loginDetails.getFofoId(),
1463
							curDate.withDayOfMonth(1), curDate.with(LocalTime.MAX)).stream().map(x -> x.getId())
1464
					curDate.withDayOfMonth(1), curDate.with(LocalTime.MAX)).stream().map(x -> x.getId())
1464
					.collect(Collectors.toList());
1465
					.collect(Collectors.toList());
1465
			LOGGER.info("monthlyPlanned1" + monthlyPlanned);
1466
			LOGGER.info("monthlyPlanned1" + monthlyPlanned);
1466
		}
1467
		}
1467
 
1468
 
1468
		Map<Integer, Integer> plannedDetailMap = null;
1469
		Map<Integer, Integer> plannedDetailMap = null;
Line 1507... Line 1508...
1507
						Collectors.mapping(y -> y.getId(), Collectors.toList())));
1508
						Collectors.mapping(y -> y.getId(), Collectors.toList())));
1508
		for (Entry<Integer, List<Integer>> catalogItem : catalogItemIdMap.entrySet()) {
1509
		for (Entry<Integer, List<Integer>> catalogItem : catalogItemIdMap.entrySet()) {
1509
			List<Integer> itemIds = catalogItem.getValue();
1510
			List<Integer> itemIds = catalogItem.getValue();
1510
			int availability = 0;
1511
			int availability = 0;
1511
			for (Integer itemId : itemIds) {
1512
			for (Integer itemId : itemIds) {
1512
				List<SaholicCISTable> saholicCISTableList = saholicCISTableRepository.selectByItemWarehouse(itemId, fofoStore.getWarehouseId());
1513
				List<SaholicCISTable> saholicCISTableList = saholicCISTableRepository.selectByItemWarehouse(itemId,
-
 
1514
						fofoStore.getWarehouseId());
1513
				if (saholicCISTableList != null) {
1515
				if (saholicCISTableList != null) {
-
 
1516
					availability += saholicCISTableList.stream()
1514
					availability += saholicCISTableList.stream().collect(Collectors.summingInt(x -> x.getAvailability()));
1517
							.collect(Collectors.summingInt(x -> x.getAvailability()));
1515
				}
1518
				}
1516
			}
1519
			}
1517
			Integer catalogItemId = catalogItem.getKey();
1520
			Integer catalogItemId = catalogItem.getKey();
1518
			ourStockAvailability.put(catalogItemId, availability);
1521
			ourStockAvailability.put(catalogItemId, availability);
1519
		}
1522
		}
Line 1705... Line 1708...
1705
 
1708
 
1706
		List<String> brands = Arrays.asList("Vivo", "Samsung", "Oppo", "Tecno", "Itel", "OnePlus", "Lava", "Realme",
1709
		List<String> brands = Arrays.asList("Vivo", "Samsung", "Oppo", "Tecno", "Itel", "OnePlus", "Lava", "Realme",
1707
				"Xiaomi", "Nokia");
1710
				"Xiaomi", "Nokia");
1708
 
1711
 
1709
		AuthUser authUser = authRepository.selectByEmailOrMobile(email);
1712
		AuthUser authUser = authRepository.selectByEmailOrMobile(email);
1710
		Map<String, Set<Integer>> storeGuyMap = csService.getAuthUserPartnerIdMapping();
-
 
1711
 
-
 
1712
		Set<Integer> fofoIds = storeGuyMap.get(authUser.getEmailId());
1713
		Set<Integer> fofoIds = csService.getAuthFofoIds(email);
1713
 
-
 
1714
		if (emails.contains(authUser.getEmailId())) {
-
 
1715
			fofoIds = storeGuyMap.get("tarun.verma@smartdukaan.com");
-
 
1716
			LOGGER.info("fofoIds" + fofoIds);
-
 
1717
		}
-
 
1718
 
1714
 
1719
		Map<Integer, PartnerDailyInvestment> partnerDailyInvestmentMap = new HashMap<>();
1715
		Map<Integer, PartnerDailyInvestment> partnerDailyInvestmentMap = new HashMap<>();
1720
 
1716
 
1721
		Map<Integer, Map<String, Double>> fofoIdBrandAmountMap = new HashMap<>();
1717
		Map<Integer, Map<String, Double>> fofoIdBrandAmountMap = new HashMap<>();
1722
 
1718
 
Line 1852... Line 1848...
1852
		return "partner-brandwise-detail";
1848
		return "partner-brandwise-detail";
1853
	}
1849
	}
1854
 
1850
 
1855
	@RequestMapping(value = "/changeActivationType", method = RequestMethod.POST)
1851
	@RequestMapping(value = "/changeActivationType", method = RequestMethod.POST)
1856
	public String changeActivationType(HttpServletRequest request, @RequestParam String code,
1852
	public String changeActivationType(HttpServletRequest request, @RequestParam String code,
1857
									   @RequestParam ActivationType activationType, Model model) throws Exception {
1853
			@RequestParam ActivationType activationType, Model model) throws Exception {
1858
 
1854
 
1859
		FofoStore fofoStore = fofoStoreRepository.selectByStoreCode(code);
1855
		FofoStore fofoStore = fofoStoreRepository.selectByStoreCode(code);
1860
 
1856
 
1861
		fofoStore.setActivationType(activationType);
1857
		fofoStore.setActivationType(activationType);
1862
 
1858
 
Line 1902... Line 1898...
1902
		return "response";
1898
		return "response";
1903
	}
1899
	}
1904
 
1900
 
1905
	@RequestMapping(value = "/getPartnerShortageStock", method = RequestMethod.GET)
1901
	@RequestMapping(value = "/getPartnerShortageStock", method = RequestMethod.GET)
1906
	public String getPartnerShortageStock(HttpServletRequest request,
1902
	public String getPartnerShortageStock(HttpServletRequest request,
1907
										  @RequestParam(required = false, defaultValue = "") String brand, @RequestParam int fofoId, Model model)
1903
			@RequestParam(required = false, defaultValue = "") String brand, @RequestParam int fofoId, Model model)
1908
			throws Exception {
1904
			throws Exception {
1909
 
1905
 
1910
 
-
 
1911
		Map<Integer, Map<Integer, List<SaholicPOItem>>> warehousePoItemAvailabilityMap = saholicInventoryService
1906
		Map<Integer, Map<Integer, List<SaholicPOItem>>> warehousePoItemAvailabilityMap = saholicInventoryService
1912
				.getSaholicPOItems();
1907
				.getSaholicPOItems();
1913
 
1908
 
1914
		List<FocusedModelShortageModel> focusedModelShortageList = new ArrayList<>();
1909
		List<FocusedModelShortageModel> focusedModelShortageList = new ArrayList<>();
1915
		CustomRetailer customRetailer = retailerService.getFofoRetailer(fofoId);
1910
		CustomRetailer customRetailer = retailerService.getFofoRetailer(fofoId);
Line 1994... Line 1989...
1994
			List<Item> items = itemRepository.selectAllByCatalogItemId(entry.getKey());
1989
			List<Item> items = itemRepository.selectAllByCatalogItemId(entry.getKey());
1995
 
1990
 
1996
			if (brand.equals("undefined") || items.get(0).getBrand().equals(brand)) {
1991
			if (brand.equals("undefined") || items.get(0).getBrand().equals(brand)) {
1997
 
1992
 
1998
				FocusedModelShortageModel fm = this.getFocusedModelShortage(entry.getValue().get(), entry.getKey(),
1993
				FocusedModelShortageModel fm = this.getFocusedModelShortage(entry.getValue().get(), entry.getKey(),
1999
						processingOrderMap, grnPendingOrdersMap, catalogIdAndQtyMap, fofoId, warehousePoItemAvailabilityMap, items, customRetailer);
1994
						processingOrderMap, grnPendingOrdersMap, catalogIdAndQtyMap, fofoId,
-
 
1995
						warehousePoItemAvailabilityMap, items, customRetailer);
2000
 
1996
 
2001
				focusedModelShortageList.add(fm);
1997
				focusedModelShortageList.add(fm);
2002
			} else if (brand.equals("accessories")) {
1998
			} else if (brand.equals("accessories")) {
2003
 
1999
 
2004
				if (items.get(0).getCategoryId() != ProfitMandiConstants.MOBILE_CATEGORY_ID) {
2000
				if (items.get(0).getCategoryId() != ProfitMandiConstants.MOBILE_CATEGORY_ID) {
2005
					if (items.get(0).getCategoryId() != 0) {
2001
					if (items.get(0).getCategoryId() != 0) {
2006
						Category category = categoryRepository.selectById(items.get(0).getCategoryId());
2002
						Category category = categoryRepository.selectById(items.get(0).getCategoryId());
2007
 
2003
 
2008
						if (category.getParentCategoryId() == 10011) {
2004
						if (category.getParentCategoryId() == 10011) {
2009
							FocusedModelShortageModel fm = this.getFocusedModelShortage(entry.getValue().get(),
2005
							FocusedModelShortageModel fm = this.getFocusedModelShortage(entry.getValue().get(),
2010
									entry.getKey(), processingOrderMap, grnPendingOrdersMap, catalogIdAndQtyMap, fofoId
2006
									entry.getKey(), processingOrderMap, grnPendingOrdersMap, catalogIdAndQtyMap, fofoId,
2011
									, warehousePoItemAvailabilityMap, items,
2007
									warehousePoItemAvailabilityMap, items, customRetailer);
2012
									customRetailer);
-
 
2013
 
2008
 
2014
							focusedModelShortageList.add(fm);
2009
							focusedModelShortageList.add(fm);
2015
 
2010
 
2016
						}
2011
						}
2017
					}
2012
					}
Line 2027... Line 2022...
2027
						Category category = categoryRepository.selectById(items.get(0).getCategoryId());
2022
						Category category = categoryRepository.selectById(items.get(0).getCategoryId());
2028
 
2023
 
2029
						if (category.getParentCategoryId() == 14200) {
2024
						if (category.getParentCategoryId() == 14200) {
2030
							FocusedModelShortageModel fm = this.getFocusedModelShortage(entry.getValue().get(),
2025
							FocusedModelShortageModel fm = this.getFocusedModelShortage(entry.getValue().get(),
2031
									entry.getKey(), processingOrderMap, grnPendingOrdersMap, catalogIdAndQtyMap, fofoId,
2026
									entry.getKey(), processingOrderMap, grnPendingOrdersMap, catalogIdAndQtyMap, fofoId,
2032
									warehousePoItemAvailabilityMap, items,
2027
									warehousePoItemAvailabilityMap, items, customRetailer);
2033
									customRetailer);
-
 
2034
 
2028
 
2035
							focusedModelShortageList.add(fm);
2029
							focusedModelShortageList.add(fm);
2036
 
2030
 
2037
						}
2031
						}
2038
					}
2032
					}
Line 2089... Line 2083...
2089
		return "partner-stock";
2083
		return "partner-stock";
2090
 
2084
 
2091
	}
2085
	}
2092
 
2086
 
2093
	private List<PartnerStockDescriptionModel> getBrandItemwiseDescription(String brand,
2087
	private List<PartnerStockDescriptionModel> getBrandItemwiseDescription(String brand,
2094
																		   Map<Integer, Integer> catalogIdAndQtyMap) throws ProfitMandiBusinessException {
2088
			Map<Integer, Integer> catalogIdAndQtyMap) throws ProfitMandiBusinessException {
2095
		List<PartnerStockDescriptionModel> inStocks = new ArrayList<>();
2089
		List<PartnerStockDescriptionModel> inStocks = new ArrayList<>();
2096
 
2090
 
2097
		for (Entry<Integer, Integer> inStock : catalogIdAndQtyMap.entrySet()) {
2091
		for (Entry<Integer, Integer> inStock : catalogIdAndQtyMap.entrySet()) {
2098
			List<Item> items = itemRepository.selectAllByCatalogItemId(inStock.getKey());
2092
			List<Item> items = itemRepository.selectAllByCatalogItemId(inStock.getKey());
2099
 
2093
 
Line 2146... Line 2140...
2146
 
2140
 
2147
		return inStocks;
2141
		return inStocks;
2148
	}
2142
	}
2149
 
2143
 
2150
	private FocusedModelShortageModel getFocusedModelShortage(int qty, int catalogId,
2144
	private FocusedModelShortageModel getFocusedModelShortage(int qty, int catalogId,
2151
															  Map<Integer, Integer> processingOrderMap, Map<Integer, Integer> grnPendingOrdersMap,
2145
			Map<Integer, Integer> processingOrderMap, Map<Integer, Integer> grnPendingOrdersMap,
2152
															  Map<Integer, Integer> catalogIdAndQtyMap, int fofoId,
2146
			Map<Integer, Integer> catalogIdAndQtyMap, int fofoId,
2153
															  Map<Integer, Map<Integer, List<SaholicPOItem>>> warehousePoItemAvailabilityMap, List<Item> items,
2147
			Map<Integer, Map<Integer, List<SaholicPOItem>>> warehousePoItemAvailabilityMap, List<Item> items,
2154
															  CustomRetailer customRetailer) throws ProfitMandiBusinessException {
2148
			CustomRetailer customRetailer) throws ProfitMandiBusinessException {
2155
 
2149
 
2156
		int minQty = qty;
2150
		int minQty = qty;
2157
		int inStockQty = 0;
2151
		int inStockQty = 0;
2158
		int processingQty = 0;
2152
		int processingQty = 0;
2159
		int grnPendingQty = 0;
2153
		int grnPendingQty = 0;
Line 2176... Line 2170...
2176
		int totalQty = processingQty + grnPendingQty + inStockQty;
2170
		int totalQty = processingQty + grnPendingQty + inStockQty;
2177
 
2171
 
2178
		int shortageQty = minQty - totalQty;
2172
		int shortageQty = minQty - totalQty;
2179
		FofoStore fofoStore = fofoStoreRepository.selectByRetailerId(fofoId);
2173
		FofoStore fofoStore = fofoStoreRepository.selectByRetailerId(fofoId);
2180
 
2174
 
2181
 
-
 
2182
		Map<Integer, List<SaholicPOItem>> poItemAvailabilityMap = warehousePoItemAvailabilityMap
2175
		Map<Integer, List<SaholicPOItem>> poItemAvailabilityMap = warehousePoItemAvailabilityMap
2183
				.get(fofoStore.getWarehouseId());
2176
				.get(fofoStore.getWarehouseId());
2184
 
2177
 
2185
		for (Item it : items) {
2178
		for (Item it : items) {
2186
			List<SaholicCISTable> currentAvailability = saholicCISTableRepository.selectByItemWarehouse(it.getId(), fofoStore.getWarehouseId());
2179
			List<SaholicCISTable> currentAvailability = saholicCISTableRepository.selectByItemWarehouse(it.getId(),
-
 
2180
					fofoStore.getWarehouseId());
2187
			List<SaholicPOItem> poItemAvailability = null;
2181
			List<SaholicPOItem> poItemAvailability = null;
2188
 
2182
 
2189
			if (poItemAvailabilityMap != null) {
2183
			if (poItemAvailabilityMap != null) {
2190
				poItemAvailability = poItemAvailabilityMap.get(it.getId());
2184
				poItemAvailability = poItemAvailabilityMap.get(it.getId());
2191
			}
2185
			}
Line 2224... Line 2218...
2224
		return "send-po-notification";
2218
		return "send-po-notification";
2225
	}
2219
	}
2226
 
2220
 
2227
	@RequestMapping(value = "/indent/send-po-notification", method = RequestMethod.POST)
2221
	@RequestMapping(value = "/indent/send-po-notification", method = RequestMethod.POST)
2228
	public String sendPONotification(HttpServletRequest request, @RequestBody POItemWarehouseModel poItemWarehouseModel,
2222
	public String sendPONotification(HttpServletRequest request, @RequestBody POItemWarehouseModel poItemWarehouseModel,
2229
									 Model model) throws Exception {
2223
			Model model) throws Exception {
2230
 
2224
 
2231
		Map<Integer, Item> selectedCatalogItemMap = itemRepository
2225
		Map<Integer, Item> selectedCatalogItemMap = itemRepository
2232
				.selectAllByCatalogIds(new HashSet<>(poItemWarehouseModel.getCatalogIds())).stream()
2226
				.selectAllByCatalogIds(new HashSet<>(poItemWarehouseModel.getCatalogIds())).stream()
2233
				.collect(Collectors.toMap(x -> x.getCatalogItemId(), x -> x, (existing, replacement) -> existing));
2227
				.collect(Collectors.toMap(x -> x.getCatalogItemId(), x -> x, (existing, replacement) -> existing));
2234
 
2228