Subversion Repositories SmartDukaan

Rev

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

Rev 21926 Rev 22009
Line 9... Line 9...
9
import org.apache.commons.collections.CollectionUtils;
9
import org.apache.commons.collections.CollectionUtils;
10
import org.springframework.beans.factory.annotation.Autowired;
10
import org.springframework.beans.factory.annotation.Autowired;
11
import org.springframework.stereotype.Component;
11
import org.springframework.stereotype.Component;
12
 
12
 
13
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
13
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
14
import com.spice.profitmandi.dao.entity.fofo.RetailerTag;
-
 
15
import com.spice.profitmandi.dao.entity.fofo.TagListing;
14
import com.spice.profitmandi.dao.entity.fofo.TagListing;
16
import com.spice.profitmandi.dao.entity.user.Address;
15
import com.spice.profitmandi.dao.entity.user.Address;
17
import com.spice.profitmandi.dao.repository.dtr.RetailerRegisteredAddressRepository;
16
import com.spice.profitmandi.dao.repository.dtr.RetailerRegisteredAddressRepository;
18
import com.spice.profitmandi.dao.repository.fofo.PinCodeTagRepository;
17
import com.spice.profitmandi.dao.repository.fofo.PinCodeTagRepository;
19
import com.spice.profitmandi.dao.repository.fofo.RetailerTagRepository;
18
import com.spice.profitmandi.dao.repository.fofo.RetailerTagRepository;
Line 50... Line 49...
50
		try {
49
		try {
51
			
50
			
52
			addressId = retailerRegisteredAddressRepository.selectAddressIdByRetailerId(retailerId);
51
			addressId = retailerRegisteredAddressRepository.selectAddressIdByRetailerId(retailerId);
53
			Address retailerAddress = addressRepository.selectById(addressId);
52
			Address retailerAddress = addressRepository.selectById(addressId);
54
			Set<Integer> pinCodeTagIds = tagService.getFofoTagIdsByPinCode(retailerAddress.getPinCode());
53
			Set<Integer> pinCodeTagIds = tagService.getFofoTagIdsByPinCode(retailerAddress.getPinCode());
55
			if(pinCodeTagIds.isEmpty()){
54
			Set<Integer> pinNegativeTagIds = tagService.getPinCodeNegativeTagIds();
56
				return itemIdPrice;
55
			Set<Integer> pinCodeIntersection = new HashSet<>(CollectionUtils.intersection(pinCodeTagIds, pinNegativeTagIds));
57
			}
56
			
-
 
57
			Set<Integer> filterPinCodeTagIds = new HashSet<>(CollectionUtils.subtract(pinNegativeTagIds, pinCodeIntersection));
58
			Set<Integer> pinPositiveTagIds = tagService.getPinCodePositiveTagIds();
58
			Set<Integer> pinPositiveTagIds = tagService.getPinCodePositiveTagIds();
59
			if(pinPositiveTagIds.isEmpty()){
59
			filterPinCodeTagIds.addAll(pinPositiveTagIds);
60
				return itemIdPrice;
-
 
61
			}
-
 
62
			Set<Integer> pinCodeIntersection = (Set<Integer>)CollectionUtils.intersection(pinCodeTagIds, pinPositiveTagIds);
-
 
63
			Set<Integer> pinCodeUnion = (Set<Integer>) CollectionUtils.union(pinCodeTagIds, pinPositiveTagIds);
-
 
64
			Set<Integer> filterPinCodeTagIds = (Set<Integer>)CollectionUtils.subtract(pinCodeUnion, pinCodeIntersection);
-
 
65
			if(filterPinCodeTagIds.isEmpty()){
60
			if(filterPinCodeTagIds.isEmpty()){
66
				return itemIdPrice;
61
				return itemIdPrice;
67
			}
62
			}
68
			List<RetailerTag> retailerTags = retailerTagRepository.selectByTagIds(filterPinCodeTagIds);
63
			Set<Integer> retailerTagIds = tagService.getUserTagIdsByTagIds(filterPinCodeTagIds);
69
			if(retailerTags.isEmpty()){
-
 
70
				return itemIdPrice;
-
 
71
			}
-
 
72
			Set<Integer> retailerTagIds = new HashSet<>();
64
			Set<Integer> userNegativeTagIds = tagService.getUserNegativeTagIds();
73
			for(RetailerTag retailerTag : retailerTags){
65
			Set<Integer> userIntersection = new HashSet<>(CollectionUtils.intersection(retailerTagIds, userNegativeTagIds));
74
				retailerTagIds.add(retailerTag.getTagId());
66
			Set<Integer> filterUserTagIds = new HashSet<>(CollectionUtils.subtract(userNegativeTagIds, userIntersection));
75
			}
-
 
76
			Set<Integer> userPositiveTagIds = tagService.getUserPositiveTagIds();
67
			Set<Integer> userPositiveTagIds = tagService.getUserPositiveTagIds();
77
			Set<Integer> userIntersection = (Set<Integer>)CollectionUtils.intersection(retailerTagIds, userPositiveTagIds);
-
 
78
			Set<Integer> userUnion = (Set<Integer>)CollectionUtils.union(retailerTagIds, userPositiveTagIds);
68
			filterUserTagIds.addAll(userPositiveTagIds);
79
			Set<Integer> filterUserTagIds = (Set<Integer>)CollectionUtils.subtract(userUnion, userIntersection);
-
 
80
			if(filterUserTagIds.isEmpty()){
69
			if(filterUserTagIds.isEmpty()){
81
				return itemIdPrice;
70
				return itemIdPrice;
82
			}
71
			}
83
			List<TagListing> tagListings = tagListingRepository.selectByItemIdsAndTagIds(itemIds, filterUserTagIds);
72
			List<TagListing> tagListings = tagListingRepository.selectByItemIdsAndTagIds(itemIds, filterUserTagIds);
84
			
73