Subversion Repositories SmartDukaan

Rev

Rev 25027 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 25027 Rev 33247
Line 1... Line 1...
1
package com.spice.profitmandi.service.tag;
1
package com.spice.profitmandi.service.tag;
2
 
2
 
3
import java.time.LocalDateTime;
-
 
4
 
-
 
5
import java.util.ArrayList;
-
 
6
import java.util.Arrays;
-
 
7
import java.util.Collection;
-
 
8
import java.util.HashMap;
-
 
9
import java.util.HashSet;
-
 
10
import java.util.List;
-
 
11
import java.util.Map;
-
 
12
import java.util.Set;
-
 
13
import java.util.stream.Collectors;
-
 
14
 
-
 
15
import org.apache.commons.collections.CollectionUtils;
-
 
16
import org.springframework.beans.factory.annotation.Autowired;
-
 
17
import org.springframework.beans.factory.annotation.Qualifier;
-
 
18
import org.springframework.cache.annotation.Cacheable;
-
 
19
import org.springframework.stereotype.Component;
-
 
20
 
-
 
21
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
3
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
22
import com.spice.profitmandi.common.model.ProfitMandiConstants;
4
import com.spice.profitmandi.common.model.ProfitMandiConstants;
23
import com.spice.profitmandi.common.model.TagListingModel;
5
import com.spice.profitmandi.common.model.TagListingModel;
24
import com.spice.profitmandi.dao.entity.catalog.Item;
-
 
25
import com.spice.profitmandi.dao.entity.catalog.PinCodeTag;
-
 
26
import com.spice.profitmandi.dao.entity.catalog.RetailerTag;
-
 
27
import com.spice.profitmandi.dao.entity.catalog.Tag;
6
import com.spice.profitmandi.dao.entity.catalog.*;
28
import com.spice.profitmandi.dao.entity.catalog.TagListing;
-
 
29
import com.spice.profitmandi.dao.entity.dtr.Retailer;
7
import com.spice.profitmandi.dao.entity.dtr.Retailer;
30
import com.spice.profitmandi.dao.entity.inventory.VendorItemPricing;
8
import com.spice.profitmandi.dao.entity.inventory.VendorItemPricing;
31
import com.spice.profitmandi.dao.enumuration.catalog.TagType;
9
import com.spice.profitmandi.dao.enumuration.catalog.TagType;
32
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
-
 
33
import com.spice.profitmandi.dao.repository.catalog.PinCodeTagRepository;
-
 
34
import com.spice.profitmandi.dao.repository.catalog.RetailerTagRepository;
-
 
35
import com.spice.profitmandi.dao.repository.catalog.TagListingRepository;
-
 
36
import com.spice.profitmandi.dao.repository.catalog.TagRepository;
10
import com.spice.profitmandi.dao.repository.catalog.*;
37
import com.spice.profitmandi.dao.repository.dtr.RetailerRepository;
11
import com.spice.profitmandi.dao.repository.dtr.RetailerRepository;
38
import com.spice.profitmandi.dao.repository.inventory.VendorItemPricingRepository;
12
import com.spice.profitmandi.dao.repository.inventory.VendorItemPricingRepository;
-
 
13
import org.apache.commons.collections.CollectionUtils;
-
 
14
import org.springframework.beans.factory.annotation.Autowired;
-
 
15
import org.springframework.beans.factory.annotation.Qualifier;
-
 
16
import org.springframework.cache.annotation.Cacheable;
-
 
17
import org.springframework.stereotype.Component;
39
 
18
 
-
 
19
import java.time.LocalDateTime;
-
 
20
import java.util.*;
40
import in.shop2020.model.v1.inventory.VendorItemMapping;
21
import java.util.stream.Collectors;
41
 
22
 
42
@Component
23
@Component
43
public class TagServiceImpl implements TagService {
24
public class TagServiceImpl implements TagService {
44
 
25
 
45
	@Autowired
26
	@Autowired
Line 144... Line 125...
144
		}
125
		}
145
		return retailerRepository.selectByIds(retailerIds);
126
		return retailerRepository.selectByIds(retailerIds);
146
	}
127
	}
147
	
128
	
148
	@Override
129
	@Override
149
	public List<Tag> getTagsByPinCode(String pinCode) {
130
    public List<Tag> getTagsByPinCode(String pinCode) throws ProfitMandiBusinessException {
150
		Set<Integer> tagIds = this.getTagIdsByPinCode(pinCode);
131
		Set<Integer> tagIds = this.getTagIdsByPinCode(pinCode);
151
		if(tagIds.isEmpty()){
132
		if(tagIds.isEmpty()){
152
			return new ArrayList<>();
133
			return new ArrayList<>();
153
		}
134
		}
154
		return tagRepository.selectByIds(tagIds);
135
		return tagRepository.selectByIds(tagIds);
Line 173... Line 154...
173
			pinCodes.add(pinCodeTag.getPinCode());
154
			pinCodes.add(pinCodeTag.getPinCode());
174
		}
155
		}
175
		return pinCodes;
156
		return pinCodes;
176
	}
157
	}
177
	@Override
158
	@Override
178
	public List<Tag> getTagsByRetailerId(int retailerId) {
159
    public List<Tag> getTagsByRetailerId(int retailerId) throws ProfitMandiBusinessException {
179
		List<RetailerTag> retailerTags = retailerTagRepository.selectByRetailerId(retailerId);
160
		List<RetailerTag> retailerTags = retailerTagRepository.selectByRetailerId(retailerId);
180
		if(!retailerTags.isEmpty()){
161
		if(!retailerTags.isEmpty()){
181
			return new ArrayList<>();
162
			return new ArrayList<>();
182
		}
163
		}
183
		Set<Integer> tagIds = new HashSet<>();
164
		Set<Integer> tagIds = new HashSet<>();
Line 186... Line 167...
186
		}
167
		}
187
		return tagRepository.selectByIds(tagIds);
168
		return tagRepository.selectByIds(tagIds);
188
	}
169
	}
189
	
170
	
190
	@Override
171
	@Override
191
	public Set<Integer> getFofoTagIdsByPinCode(String pinCode) {
172
    public Set<Integer> getFofoTagIdsByPinCode(String pinCode) throws ProfitMandiBusinessException {
192
		List<Tag> pinCodeTags = this.getTagsByPinCode(pinCode);
173
		List<Tag> pinCodeTags = this.getTagsByPinCode(pinCode);
193
		Set<Integer> pinCodeTagIds = new HashSet<>();
174
		Set<Integer> pinCodeTagIds = new HashSet<>();
194
		for(Tag tag : pinCodeTags){
175
		for(Tag tag : pinCodeTags){
195
			if(tag.getType() == TagType.FOFO){
176
			if(tag.getType() == TagType.FOFO){
196
				pinCodeTagIds.add(tag.getId());
177
				pinCodeTagIds.add(tag.getId());
Line 228... Line 209...
228
			}
209
			}
229
		}
210
		}
230
		return itemsMap;
211
		return itemsMap;
231
	}
212
	}
232
	@Override
213
	@Override
233
	public List<Map<String, Object>> getTagListingDetail(int tagId) {
214
    public List<Map<String, Object>> getTagListingDetail(int tagId) throws ProfitMandiBusinessException {
234
		List<TagListing> tagListings = tagListingRepository.selectByTagId(tagId);
215
		List<TagListing> tagListings = tagListingRepository.selectByTagId(tagId);
235
		List<Map<String, Object>> tagListingsList = new ArrayList<>();
216
		List<Map<String, Object>> tagListingsList = new ArrayList<>();
236
		if(tagListings.isEmpty()){
217
		if(tagListings.isEmpty()){
237
			return new ArrayList<>();
218
			return new ArrayList<>();
238
		}
219
		}
Line 303... Line 284...
303
	public Set<Integer> getUserPositiveTagIds() {
284
	public Set<Integer> getUserPositiveTagIds() {
304
		List<Tag> tags = tagRepository.selectAllByUserAll(false);
285
		List<Tag> tags = tagRepository.selectAllByUserAll(false);
305
		return this.toTagIds(tags);
286
		return this.toTagIds(tags);
306
	}
287
	}
307
	@Override
288
	@Override
308
	public Set<Integer> getUserTagIdsByTagIds(Set<Integer> tagIds) {
289
    public Set<Integer> getUserTagIdsByTagIds(Set<Integer> tagIds) throws ProfitMandiBusinessException {
309
		List<RetailerTag> retailerTags = retailerTagRepository.selectByTagIds(tagIds);
290
		List<RetailerTag> retailerTags = retailerTagRepository.selectByTagIds(tagIds);
310
		Set<Integer> retailerTagIds = new HashSet<>();
291
		Set<Integer> retailerTagIds = new HashSet<>();
311
		if(retailerTags.isEmpty()){
292
		if(retailerTags.isEmpty()){
312
			return retailerTagIds;
293
			return retailerTagIds;
313
		}
294
		}