Subversion Repositories SmartDukaan

Rev

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

Rev 27215 Rev 27217
Line 16... Line 16...
16
import java.util.HashSet;
16
import java.util.HashSet;
17
import java.util.List;
17
import java.util.List;
18
import java.util.Map;
18
import java.util.Map;
19
import java.util.Optional;
19
import java.util.Optional;
20
import java.util.Set;
20
import java.util.Set;
21
import java.util.function.Function;
-
 
22
import java.util.stream.Collectors;
21
import java.util.stream.Collectors;
23
 
22
 
24
import javax.mail.MessagingException;
23
import javax.mail.MessagingException;
25
import javax.mail.internet.InternetAddress;
24
import javax.mail.internet.InternetAddress;
26
import javax.mail.internet.MimeMessage;
25
import javax.mail.internet.MimeMessage;
Line 83... Line 82...
83
import com.spice.profitmandi.dao.entity.fofo.FofoOrder;
82
import com.spice.profitmandi.dao.entity.fofo.FofoOrder;
84
import com.spice.profitmandi.dao.entity.fofo.FofoOrderItem;
83
import com.spice.profitmandi.dao.entity.fofo.FofoOrderItem;
85
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
84
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
86
import com.spice.profitmandi.dao.entity.fofo.InventoryItem;
85
import com.spice.profitmandi.dao.entity.fofo.InventoryItem;
87
import com.spice.profitmandi.dao.entity.fofo.PartnerDailyInvestment;
86
import com.spice.profitmandi.dao.entity.fofo.PartnerDailyInvestment;
88
import com.spice.profitmandi.dao.entity.fofo.PartnerTypeChange;
-
 
89
import com.spice.profitmandi.dao.entity.fofo.Purchase;
87
import com.spice.profitmandi.dao.entity.fofo.Purchase;
90
import com.spice.profitmandi.dao.entity.fofo.ScanRecord;
88
import com.spice.profitmandi.dao.entity.fofo.ScanRecord;
91
import com.spice.profitmandi.dao.entity.fofo.SchemeInOut;
89
import com.spice.profitmandi.dao.entity.fofo.SchemeInOut;
92
import com.spice.profitmandi.dao.entity.inventory.SaholicCIS;
90
import com.spice.profitmandi.dao.entity.inventory.SaholicCIS;
93
import com.spice.profitmandi.dao.entity.inventory.SaholicPOItem;
91
import com.spice.profitmandi.dao.entity.inventory.SaholicPOItem;
Line 2020... Line 2018...
2020
			LOGGER.info("regionIds" + regionIds);
2018
			LOGGER.info("regionIds" + regionIds);
2021
			if (regionIds.size() == 0) {
2019
			if (regionIds.size() == 0) {
2022
				LOGGER.info("No region found for partner {}", fofoId);
2020
				LOGGER.info("No region found for partner {}", fofoId);
2023
				continue;
2021
				continue;
2024
			}
2022
			}
2025
			/*
-
 
2026
			 * List<Integer> focusedModelCatalogId =
-
 
2027
			 * focusedModelRepository.selectAllByRegionIds(regionIds).stream() .map(x ->
-
 
2028
			 * x.getCatalogId()).collect(Collectors.toList());
-
 
2029
			 * LOGGER.info("focusedModelCatalogId" + focusedModelCatalogId); Map<String,
-
 
2030
			 * Object> equalsMap = new HashMap<>(); equalsMap.put("categoryId", 10006);
-
 
2031
			 * equalsMap.put("brand", brands);
-
 
2032
			 * 
-
 
2033
			 * Map<String, List<?>> notEqualsMap = new HashMap<>();
-
 
2034
			 * 
-
 
2035
			 * Map<String, Object> equalsJoinMap = new HashMap<>();
-
 
2036
			 * equalsJoinMap.put("catalogId", focusedModelCatalogId);
-
 
2037
			 * 
-
 
2038
			 * Map<String, List<?>> notEqualsJoinMap = new HashMap<>();
-
 
2039
			 */
-
 
2040
 
-
 
2041
			/*
-
 
2042
			 * List<Integer> catalogIds = itemRepository .selectItems(FocusedModel.class,
-
 
2043
			 * "catalogItemId", "catalogId", equalsMap, notEqualsMap, equalsJoinMap,
-
 
2044
			 * notEqualsJoinMap, "minimumQty") .stream().map(x ->
-
 
2045
			 * x.getCatalogId()).collect(Collectors.toList());
-
 
2046
			 * 
-
 
2047
			 */
-
 
2048
			Map<Integer, Optional<Integer>> focusedCatalogIdAndQtyMap = focusedModelRepository
2023
			Map<Integer, Optional<Integer>> focusedCatalogIdAndQtyMap = focusedModelRepository
2049
					.selectAllByRegionIds(regionIds).stream().collect(Collectors.groupingBy(FocusedModel::getCatalogId,
2024
					.selectAllByRegionIds(regionIds).stream().collect(Collectors.groupingBy(FocusedModel::getCatalogId,
2050
							Collectors.mapping(FocusedModel::getMinimumQty, Collectors.maxBy(Integer::compareTo))));
2025
							Collectors.mapping(FocusedModel::getMinimumQty, Collectors.maxBy(Integer::compareTo))));
2051
 
2026
 
2052
			/*
-
 
2053
			 * Map<Integer, Integer> focusedCatalogIdAndQtyMap =
-
 
2054
			 * focusedModelRepository.selectAll().stream() .collect(Collectors.toMap(x ->
-
 
2055
			 * x.getCatalogId(), x -> x.getMinimumQty()));
-
 
2056
			 */
-
 
2057
 
-
 
2058
			LOGGER.info("focusedCatalogIdAndQtyMap" + focusedCatalogIdAndQtyMap);
2027
			LOGGER.info("focusedCatalogIdAndQtyMap" + focusedCatalogIdAndQtyMap);
2059
 
2028
 
2060
			for (Map.Entry<Integer, Optional<Integer>> entry : focusedCatalogIdAndQtyMap.entrySet()) {
2029
			for (Map.Entry<Integer, Optional<Integer>> entry : focusedCatalogIdAndQtyMap.entrySet()) {
2061
				int minQty = entry.getValue().get();
2030
				int minQty = entry.getValue().get();
2062
				int inStockQty = 0;
2031
				int inStockQty = 0;
Line 2267... Line 2236...
2267
		System.out.println(leadsToNotify);
2236
		System.out.println(leadsToNotify);
2268
 
2237
 
2269
		String templateMessage = "Lead followup for %s %s, %s is due by %s";
2238
		String templateMessage = "Lead followup for %s %s, %s is due by %s";
2270
		DateTimeFormatter timeFormatter = DateTimeFormatter.ofPattern("h:m a");
2239
		DateTimeFormatter timeFormatter = DateTimeFormatter.ofPattern("h:m a");
2271
		for (Lead lead : leadsToNotify) {
2240
		for (Lead lead : leadsToNotify) {
2272
			if (authUserKeyMap.get(lead.getAuthId()) == null) {
2241
			if (authUserKeyMap.get(lead.getAssignTo()) == null) {
-
 
2242
				LOGGER.info("Assignee no longer part of system {}", lead.getAssignTo());
2273
				continue;
2243
				continue;
2274
			}
2244
			}
2275
			String notificationMessage = String.format(templateMessage, lead.getFirstName(), lead.getLastName(),
2245
			String notificationMessage = String.format(templateMessage, lead.getFirstName(), lead.getLastName(),
2276
					lead.getAddress(), timeFormatter.format(lead.getLeadActivity().getSchelduleTimestamp()));
2246
					lead.getAddress(), timeFormatter.format(lead.getLeadActivity().getSchelduleTimestamp()));
2277
			SendNotificationModel sendNotificationModel = new SendNotificationModel();
2247
			SendNotificationModel sendNotificationModel = new SendNotificationModel();