Subversion Repositories SmartDukaan

Rev

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

Rev 26963 Rev 26978
Line 66... Line 66...
66
import com.spice.profitmandi.dao.entity.fofo.SuggestedPo;
66
import com.spice.profitmandi.dao.entity.fofo.SuggestedPo;
67
import com.spice.profitmandi.dao.entity.fofo.SuggestedPoDetail;
67
import com.spice.profitmandi.dao.entity.fofo.SuggestedPoDetail;
68
import com.spice.profitmandi.dao.entity.transaction.Order;
68
import com.spice.profitmandi.dao.entity.transaction.Order;
69
import com.spice.profitmandi.dao.entity.transaction.UserWallet;
69
import com.spice.profitmandi.dao.entity.transaction.UserWallet;
70
import com.spice.profitmandi.dao.entity.user.User;
70
import com.spice.profitmandi.dao.entity.user.User;
-
 
71
import com.spice.profitmandi.dao.enumuration.cs.EscalationType;
71
import com.spice.profitmandi.dao.repository.auth.AuthRepository;
72
import com.spice.profitmandi.dao.repository.auth.AuthRepository;
72
import com.spice.profitmandi.dao.repository.catalog.FocusedModelRepository;
73
import com.spice.profitmandi.dao.repository.catalog.FocusedModelRepository;
73
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
74
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
74
import com.spice.profitmandi.dao.repository.catalog.TagListingRepository;
75
import com.spice.profitmandi.dao.repository.catalog.TagListingRepository;
75
import com.spice.profitmandi.dao.repository.cs.CsService;
76
import com.spice.profitmandi.dao.repository.cs.CsService;
Line 220... Line 221...
220
	@Autowired
221
	@Autowired
221
	private NotificationService notificationService;
222
	private NotificationService notificationService;
222
 
223
 
223
	@RequestMapping(value = "/open-indent/save", method = RequestMethod.POST)
224
	@RequestMapping(value = "/open-indent/save", method = RequestMethod.POST)
224
	public String saveOpenIndent(HttpServletRequest request, Model model, @RequestParam int catalogId,
225
	public String saveOpenIndent(HttpServletRequest request, Model model, @RequestParam int catalogId,
225
			@RequestParam int itemQty) throws Exception {
226
			@RequestParam int itemQty, @RequestParam int fofoId) throws Exception {
226
		LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
227
		LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
227
		LocalDate currentMonthDate = LocalDate.now();
228
		LocalDate currentMonthDate = LocalDate.now();
228
		MonthlyPlanned monthlyPlanned = null;
229
		MonthlyPlanned monthlyPlanned = null;
229
 
230
 
230
		if (LocalDate.now().isAfter(LocalDate.now().withDayOfMonth(PLANNING_OPEN_DAY))) {
231
		if (LocalDate.now().isAfter(LocalDate.now().withDayOfMonth(PLANNING_OPEN_DAY))) {
231
			currentMonthDate = LocalDate.now().plusMonths(1).withDayOfMonth(1);
232
			currentMonthDate = LocalDate.now().plusMonths(1).withDayOfMonth(1);
232
			monthlyPlanned = monthlyPlannedRepository.selectByFofoIdYearMonth(loginDetails.getFofoId(),
233
			monthlyPlanned = monthlyPlannedRepository.selectByFofoIdYearMonth(fofoId, currentMonthDate);
233
					currentMonthDate);
234
			LOGGER.info("monthlyPlanned" + monthlyPlanned);
234
 
-
 
235
			saveMonthlyPlanned(monthlyPlanned, loginDetails.getFofoId(), currentMonthDate, catalogId, itemQty);
235
			saveMonthlyPlanned(monthlyPlanned, fofoId, currentMonthDate, catalogId, itemQty);
236
		}
236
		}
237
		model.addAttribute("response", mvcResponseSender.createResponseString(false));
237
		model.addAttribute("response", mvcResponseSender.createResponseString(false));
238
		return "response";
238
		return "response";
239
	}
239
	}
240
 
240
 
Line 315... Line 315...
315
			pm.setFofoId(fofoId);
315
			pm.setFofoId(fofoId);
316
			plannedModel.add(pm);
316
			plannedModel.add(pm);
317
			LOGGER.info("plannedModel" + plannedModel);
317
			LOGGER.info("plannedModel" + plannedModel);
318
 
318
 
319
		}
319
		}
-
 
320
		List<String> ccemails = new ArrayList<>();
-
 
321
		LOGGER.info("ccemails" + ccemails);
320
		List<String> emails = csService.getAuthUserByPartnerId(fofoId);
322
		Map<EscalationType, String> emailEsclationType = csService.getAuthUserAndEsclationTypeByPartnerId(fofoId);
-
 
323
		LOGGER.info("emailEsclationType" + emailEsclationType);
321
		emails.add(customRetailer.getEmail());
324
		ccemails.add(emailEsclationType.get(EscalationType.L1));
322
 
-
 
-
 
325
		ccemails.add(emailEsclationType.get(EscalationType.L2));
323
		LOGGER.info("emails" + emails);
326
		LOGGER.info("ccemails" + ccemails);
324
 
-
 
-
 
327
		List<String> bccemails = new ArrayList<>();
-
 
328
		bccemails.add(emailEsclationType.get(EscalationType.L3));
-
 
329
		LOGGER.info("bccemails" + bccemails);
325
		ByteArrayOutputStream baos = FileUtil.getCSVByteStream(
330
		ByteArrayOutputStream baos = FileUtil.getCSVByteStream(
326
				Arrays.asList("Partner Id", "Partner Name", "Model Name", "Qty"),
331
				Arrays.asList("Partner Id", "Partner Name", "Model Name", "Qty"),
327
				plannedModel.stream()
332
				plannedModel.stream()
328
						.map(x -> Arrays.asList(x.getFofoId(), x.getStoreName(), x.getItemDescription(), x.getQty()))
333
						.map(x -> Arrays.asList(x.getFofoId(), x.getStoreName(), x.getItemDescription(), x.getQty()))
329
						.collect(Collectors.toList()));
334
						.collect(Collectors.toList()));
330
		LOGGER.info("baos" + baos);
335
		LOGGER.info("baos" + baos);
331
		Utils.sendMailWithAttachments(googleMailSender, emails.toArray(new String[emails.size()]), null,
336
		Utils.sendMailWithAttachments(googleMailSender, new String[] { customRetailer.getEmail() },
-
 
337
				ccemails.toArray(new String[ccemails.size()]), bccemails.toArray(new String[bccemails.size()]),
332
				"Planned Indent", "PFA",
338
				"Planned Indent", "PFA",
333
				new Attachment[] { new Attachment("PlannedIndent.csv", new ByteArrayResource(baos.toByteArray())), });
339
				new Attachment[] { new Attachment("PlannedIndent.csv", new ByteArrayResource(baos.toByteArray())), });
334
 
340
 
335
	}
341
	}
336
 
342
 
Line 572... Line 578...
572
			model.addAttribute("freezed", true);
578
			model.addAttribute("freezed", true);
573
			fofoOrderIds = fofoOrderRepository.selectByFofoIdBetweenCreatedTimeStamp(loginDetails.getFofoId(),
579
			fofoOrderIds = fofoOrderRepository.selectByFofoIdBetweenCreatedTimeStamp(loginDetails.getFofoId(),
574
					curDate.withDayOfMonth(1), curDate.with(LocalTime.MAX)).stream().map(x -> x.getId())
580
					curDate.withDayOfMonth(1), curDate.with(LocalTime.MAX)).stream().map(x -> x.getId())
575
					.collect(Collectors.toList());
581
					.collect(Collectors.toList());
576
			LOGGER.info("monthlyPlanned1" + monthlyPlanned);
582
			LOGGER.info("monthlyPlanned1" + monthlyPlanned);
577
		} 
583
		}
578
 
584
 
579
		Map<Integer, Integer> plannedDetailMap = null;
585
		Map<Integer, Integer> plannedDetailMap = null;
580
		if (monthlyPlanned != null) {
586
		if (monthlyPlanned != null) {
581
			plannedDetailMap = plannedDetailRepository.selectByPlannedId(monthlyPlanned.getId()).stream()
587
			plannedDetailMap = plannedDetailRepository.selectByPlannedId(monthlyPlanned.getId()).stream()
582
					.collect(Collectors.toMap(x -> x.getCatalogId(), x -> x.getQuantity()));
588
					.collect(Collectors.toMap(x -> x.getCatalogId(), x -> x.getQuantity()));
Line 799... Line 805...
799
		Map<Integer, CatalogListingModel> catalogListingMap = new HashMap<>();
805
		Map<Integer, CatalogListingModel> catalogListingMap = new HashMap<>();
800
 
806
 
801
		Map<Integer, FocusedModel> focusedModelMap = focusedModelRepository.selectAll().stream()
807
		Map<Integer, FocusedModel> focusedModelMap = focusedModelRepository.selectAll().stream()
802
				.collect(Collectors.toMap(FocusedModel::getCatalogId, Function.identity()));
808
				.collect(Collectors.toMap(FocusedModel::getCatalogId, Function.identity()));
803
 
809
 
804
		MonthlyPlanned monthlyPlanned = monthlyPlannedRepository.selectByFofoIdYearMonth(fofoId, planMonthStart.minusMonths(1));
810
		MonthlyPlanned monthlyPlanned = monthlyPlannedRepository.selectByFofoIdYearMonth(fofoId,
-
 
811
				planMonthStart.minusMonths(1));
805
		model.addAttribute("planningMonth", planMonthStart.minusMonths(1).getMonth());
812
		model.addAttribute("planningMonth", planMonthStart.minusMonths(1).getMonth());
806
		model.addAttribute("previousPlanningMonth", planMonthStart.minusMonths(1).getMonth());
813
		model.addAttribute("previousPlanningMonth", planMonthStart.minusMonths(1).getMonth());
807
		model.addAttribute("currentPlanningMonth", planMonthStart.getMonth());
814
		model.addAttribute("currentPlanningMonth", planMonthStart.getMonth());
808
 
815
 
809
		Map<Integer, Integer> plannedDetailMap = null;
816
		Map<Integer, Integer> plannedDetailMap = null;
Line 814... Line 821...
814
		}
821
		}
815
 
822
 
816
		LOGGER.info("plannedDetailMap" + plannedDetailMap);
823
		LOGGER.info("plannedDetailMap" + plannedDetailMap);
817
		List<Integer> fofoOrderIds = fofoOrderRepository
824
		List<Integer> fofoOrderIds = fofoOrderRepository
818
				.selectByFofoIdBetweenCreatedTimeStamp(loginDetails.getFofoId(),
825
				.selectByFofoIdBetweenCreatedTimeStamp(loginDetails.getFofoId(),
819
						planMonthStart.minusMonths(1).atStartOfDay(),
826
						planMonthStart.minusMonths(1).atStartOfDay(), planMonthStart.atStartOfDay())
820
						planMonthStart.atStartOfDay())
-
 
821
				.stream().map(x -> x.getId()).collect(Collectors.toList());
827
				.stream().map(x -> x.getId()).collect(Collectors.toList());
822
 
828
 
823
		LOGGER.info("fofoOrderIds" + fofoOrderIds);
829
		LOGGER.info("fofoOrderIds" + fofoOrderIds);
824
		Map<String, Object> equalsJoinMap = new HashMap<>();
830
		Map<String, Object> equalsJoinMap = new HashMap<>();
825
		equalsJoinMap.put("orderId", fofoOrderIds);
831
		equalsJoinMap.put("orderId", fofoOrderIds);