| 21713 |
ashik.ali |
1 |
package com.spice.profitmandi.dao.entity.catalog;
|
| 21552 |
ashik.ali |
2 |
|
| 32230 |
amit.gupta |
3 |
import com.spice.profitmandi.common.enumuration.ItemType;
|
|
|
4 |
import in.shop2020.model.v1.catalog.status;
|
|
|
5 |
|
|
|
6 |
import javax.persistence.*;
|
| 31065 |
tejbeer |
7 |
import java.io.Serializable;
|
| 31846 |
tejbeer |
8 |
import java.time.LocalDateTime;
|
| 31065 |
tejbeer |
9 |
import java.util.Arrays;
|
|
|
10 |
import java.util.List;
|
|
|
11 |
|
| 21552 |
ashik.ali |
12 |
/**
|
|
|
13 |
* This class basically contains item details
|
| 30121 |
amit.gupta |
14 |
*
|
| 21552 |
ashik.ali |
15 |
* @author ashikali
|
|
|
16 |
*/
|
| 29707 |
tejbeer |
17 |
|
| 31846 |
tejbeer |
18 |
@NamedQueries({@NamedQuery(name = "Item.selectItemByLikes", query = "select new com.spice.profitmandi.common.model.CustomItemModel(" + " i.id, i.brand, i.modelName, i.modelNumber, i.color" + " ) from Item i join CurrentInventorySnapshot cis on i.id = cis.itemId " + " where cis.fofoId = :fofoId and cis.availability > 0 and REPLACE(CONCAT(i.brand,' ', ifnull(i.modelName, ' '), ' ', ifnull(i.modelNumber, ' ')), ' ', ' ') like CONCAT('%',:query,'%')"),
|
| 30121 |
amit.gupta |
19 |
|
| 31846 |
tejbeer |
20 |
@NamedQuery(name = "Item.selectCatalogIdByMopRange", query = "select i.catalogItemId" + " from Item i join TagListing tl on tl.itemId = i.id " + " where tl.mop between :startPrice and :endPrice and i.categoryId=10006 group by i.catalogItemId"),
|
| 30492 |
amit.gupta |
21 |
|
| 31846 |
tejbeer |
22 |
@NamedQuery(name = "Item.selectAllBrands", query = "select distinct" + " i.brand from Item i join TagListing tl on tl.itemId = i.id " + " where i.categoryId=:categoryId"), @NamedQuery(name = "Item.selectAllCategories", query = "select distinct" + " i.categoryId from Item i join TagListing tl on tl.itemId = i.id "), @NamedQuery(name = "Item.selectAllModels", query = "select " + " i from Item i join TagListing tl on tl.itemId = i.id where i.brand in :brands and i.categoryId = :categoryId")})
|
| 21552 |
ashik.ali |
23 |
@Entity
|
| 31846 |
tejbeer |
24 |
@Table(name = "catalog.item")
|
| 29707 |
tejbeer |
25 |
public class Item implements Serializable {
|
|
|
26 |
|
| 31846 |
tejbeer |
27 |
public static final List<String> SMART_PG = Arrays.asList("85171300", "85171290");
|
| 31065 |
tejbeer |
28 |
|
| 31846 |
tejbeer |
29 |
private static final long serialVersionUID = 1L;
|
| 29707 |
tejbeer |
30 |
|
| 31846 |
tejbeer |
31 |
public Item() {
|
|
|
32 |
}
|
| 29707 |
tejbeer |
33 |
|
| 31846 |
tejbeer |
34 |
@Id
|
|
|
35 |
@Column(name = "id", columnDefinition = "int(11)")
|
|
|
36 |
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
|
|
37 |
private int id;
|
| 29707 |
tejbeer |
38 |
|
| 31846 |
tejbeer |
39 |
@Column(name = "brand", length = 100)
|
|
|
40 |
private String brand;
|
| 29707 |
tejbeer |
41 |
|
| 31846 |
tejbeer |
42 |
@Column(name = "status")
|
|
|
43 |
@Enumerated(EnumType.ORDINAL)
|
|
|
44 |
private status status;
|
| 29707 |
tejbeer |
45 |
|
| 31846 |
tejbeer |
46 |
@Column(name = "product_group", length = 100)
|
|
|
47 |
private String productGroup;
|
| 29707 |
tejbeer |
48 |
|
| 31846 |
tejbeer |
49 |
@Column(name = "model_name", length = 100)
|
|
|
50 |
private String modelName;
|
| 29707 |
tejbeer |
51 |
|
| 31846 |
tejbeer |
52 |
@Column(name = "model_number", length = 100)
|
|
|
53 |
private String modelNumber;
|
| 29707 |
tejbeer |
54 |
|
| 31846 |
tejbeer |
55 |
@Column(name = "color", length = 20)
|
|
|
56 |
private String color;
|
| 29707 |
tejbeer |
57 |
|
| 31846 |
tejbeer |
58 |
@Column(name = "catalog_item_id")
|
|
|
59 |
private int catalogItemId;
|
| 29707 |
tejbeer |
60 |
|
| 31846 |
tejbeer |
61 |
@Column(name = "weight")
|
|
|
62 |
private Double weight;
|
| 29707 |
tejbeer |
63 |
|
| 31846 |
tejbeer |
64 |
@Column(name = "category")
|
|
|
65 |
private int categoryId;
|
| 29707 |
tejbeer |
66 |
|
| 31846 |
tejbeer |
67 |
@Column(name = "startDate")
|
|
|
68 |
private LocalDateTime startDate;
|
| 29707 |
tejbeer |
69 |
|
| 31846 |
tejbeer |
70 |
public int getCategoryId() {
|
|
|
71 |
return categoryId;
|
|
|
72 |
}
|
| 23426 |
amit.gupta |
73 |
|
| 31846 |
tejbeer |
74 |
public void setCategoryId(int categoryId) {
|
|
|
75 |
this.categoryId = categoryId;
|
|
|
76 |
}
|
| 29707 |
tejbeer |
77 |
|
| 31846 |
tejbeer |
78 |
@Enumerated(EnumType.STRING)
|
|
|
79 |
@Column(name = "type")
|
|
|
80 |
private ItemType type;
|
| 29707 |
tejbeer |
81 |
|
| 31846 |
tejbeer |
82 |
@Column(name = "hsnCode")
|
|
|
83 |
private String hsnCode;
|
| 29707 |
tejbeer |
84 |
|
| 31846 |
tejbeer |
85 |
@Column(name = "sellingPrice")
|
|
|
86 |
private Float sellingPrice;
|
| 31821 |
amit.gupta |
87 |
|
| 31846 |
tejbeer |
88 |
public String getProductGroup() {
|
|
|
89 |
return productGroup;
|
|
|
90 |
}
|
| 29707 |
tejbeer |
91 |
|
| 31846 |
tejbeer |
92 |
public void setProductGroup(String productGroup) {
|
|
|
93 |
this.productGroup = productGroup;
|
|
|
94 |
}
|
| 29707 |
tejbeer |
95 |
|
| 31846 |
tejbeer |
96 |
public int getId() {
|
|
|
97 |
return id;
|
|
|
98 |
}
|
| 29707 |
tejbeer |
99 |
|
| 31846 |
tejbeer |
100 |
@Column
|
|
|
101 |
private Float mrp;
|
| 29707 |
tejbeer |
102 |
|
| 31846 |
tejbeer |
103 |
public void setId(int id) {
|
|
|
104 |
this.id = id;
|
|
|
105 |
}
|
| 29707 |
tejbeer |
106 |
|
| 31846 |
tejbeer |
107 |
public String getBrand() {
|
|
|
108 |
return brand;
|
|
|
109 |
}
|
| 29707 |
tejbeer |
110 |
|
| 31846 |
tejbeer |
111 |
public void setBrand(String brand) {
|
|
|
112 |
this.brand = brand;
|
|
|
113 |
}
|
| 29707 |
tejbeer |
114 |
|
| 31846 |
tejbeer |
115 |
public String getModelName() {
|
|
|
116 |
return modelName;
|
|
|
117 |
}
|
| 29707 |
tejbeer |
118 |
|
| 31846 |
tejbeer |
119 |
public void setModelName(String modelName) {
|
|
|
120 |
this.modelName = modelName;
|
|
|
121 |
}
|
| 29707 |
tejbeer |
122 |
|
| 31846 |
tejbeer |
123 |
public String getModelNumber() {
|
|
|
124 |
return modelNumber;
|
|
|
125 |
}
|
| 29707 |
tejbeer |
126 |
|
| 31846 |
tejbeer |
127 |
public void setModelNumber(String modelNumber) {
|
|
|
128 |
this.modelNumber = modelNumber;
|
|
|
129 |
}
|
| 29707 |
tejbeer |
130 |
|
| 31846 |
tejbeer |
131 |
public String getColor() {
|
|
|
132 |
if (color != null && (color.startsWith("f_") || color.startsWith("F_"))) {
|
|
|
133 |
return color.substring(2);
|
|
|
134 |
}
|
|
|
135 |
return color;
|
|
|
136 |
}
|
| 29707 |
tejbeer |
137 |
|
| 31846 |
tejbeer |
138 |
public String getColorNatural() {
|
|
|
139 |
return this.color;
|
|
|
140 |
}
|
| 29707 |
tejbeer |
141 |
|
| 31846 |
tejbeer |
142 |
public void setColor(String color) {
|
|
|
143 |
this.color = color;
|
|
|
144 |
}
|
| 29707 |
tejbeer |
145 |
|
| 31846 |
tejbeer |
146 |
public ItemType getType() {
|
|
|
147 |
return type;
|
|
|
148 |
}
|
| 29707 |
tejbeer |
149 |
|
| 31846 |
tejbeer |
150 |
public void setType(ItemType type) {
|
|
|
151 |
this.type = type;
|
|
|
152 |
}
|
| 29707 |
tejbeer |
153 |
|
| 31846 |
tejbeer |
154 |
public String getHsnCode() {
|
|
|
155 |
return hsnCode;
|
|
|
156 |
}
|
| 29707 |
tejbeer |
157 |
|
| 31846 |
tejbeer |
158 |
public void setHsnCode(String hsnCode) {
|
|
|
159 |
this.hsnCode = hsnCode;
|
|
|
160 |
}
|
| 29707 |
tejbeer |
161 |
|
| 31846 |
tejbeer |
162 |
public int getCatalogItemId() {
|
|
|
163 |
return catalogItemId;
|
|
|
164 |
}
|
| 29707 |
tejbeer |
165 |
|
| 31846 |
tejbeer |
166 |
public Double getWeight() {
|
|
|
167 |
return weight;
|
|
|
168 |
}
|
| 29707 |
tejbeer |
169 |
|
| 31846 |
tejbeer |
170 |
public void setWeight(Double weight) {
|
|
|
171 |
this.weight = weight;
|
|
|
172 |
}
|
| 29707 |
tejbeer |
173 |
|
| 31846 |
tejbeer |
174 |
public void setCatalogItemId(int catalogItemId) {
|
|
|
175 |
this.catalogItemId = catalogItemId;
|
|
|
176 |
}
|
| 29707 |
tejbeer |
177 |
|
| 31846 |
tejbeer |
178 |
public Float getSellingPrice() {
|
|
|
179 |
return sellingPrice;
|
|
|
180 |
}
|
| 29707 |
tejbeer |
181 |
|
| 31846 |
tejbeer |
182 |
public void setSellingPrice(Float sellingPrice) {
|
|
|
183 |
this.sellingPrice = sellingPrice;
|
|
|
184 |
}
|
| 29707 |
tejbeer |
185 |
|
| 31065 |
tejbeer |
186 |
|
| 31846 |
tejbeer |
187 |
public LocalDateTime getStartDate() {
|
|
|
188 |
return startDate;
|
|
|
189 |
}
|
| 29707 |
tejbeer |
190 |
|
| 31846 |
tejbeer |
191 |
public void setStartDate(LocalDateTime startDate) {
|
|
|
192 |
this.startDate = startDate;
|
|
|
193 |
}
|
| 29707 |
tejbeer |
194 |
|
| 31846 |
tejbeer |
195 |
public String getItemDescription() {
|
|
|
196 |
StringBuilder itemString = new StringBuilder();
|
|
|
197 |
if (this.getBrand() != null && !this.getBrand().isEmpty()) {
|
|
|
198 |
itemString.append(this.getBrand().trim());
|
|
|
199 |
}
|
|
|
200 |
itemString.append(" ");
|
|
|
201 |
if (this.getModelName() != null && !this.getModelName().isEmpty()) {
|
|
|
202 |
itemString.append(this.getModelName().trim());
|
|
|
203 |
}
|
|
|
204 |
if (this.getModelNumber() != null && !this.getModelNumber().isEmpty()) {
|
|
|
205 |
itemString.append(" ");
|
|
|
206 |
itemString.append(this.getModelNumber().trim());
|
|
|
207 |
}
|
|
|
208 |
if (this.getColor() != null && !this.getColor().isEmpty() && !this.getColor().trim().equals("f_")) {
|
|
|
209 |
itemString.append(" ");
|
|
|
210 |
itemString.append(this.getColor().trim());
|
|
|
211 |
}
|
|
|
212 |
return itemString.toString().replaceAll("\\s+", " ").trim();
|
|
|
213 |
}
|
| 29707 |
tejbeer |
214 |
|
| 31846 |
tejbeer |
215 |
public boolean isSmartPhone() {
|
|
|
216 |
return SMART_PG.contains(this.getHsnCode());
|
|
|
217 |
}
|
| 29707 |
tejbeer |
218 |
|
| 32230 |
amit.gupta |
219 |
public String getModel() {
|
|
|
220 |
StringBuilder itemString = new StringBuilder();
|
|
|
221 |
if (this.getModelName() != null && !this.getModelName().isEmpty()) {
|
|
|
222 |
itemString.append(this.getModelName().trim());
|
|
|
223 |
}
|
|
|
224 |
if (this.getModelNumber() != null && !this.getModelNumber().isEmpty()) {
|
|
|
225 |
itemString.append(" ");
|
|
|
226 |
itemString.append(this.getModelNumber().trim());
|
|
|
227 |
}
|
|
|
228 |
|
|
|
229 |
return itemString.toString().replaceAll("\\s+", " ").trim();
|
|
|
230 |
|
|
|
231 |
}
|
|
|
232 |
|
| 31846 |
tejbeer |
233 |
public String getItemDescriptionNoColor() {
|
|
|
234 |
StringBuilder itemString = new StringBuilder();
|
|
|
235 |
if (this.getBrand() != null && !this.getBrand().isEmpty()) {
|
|
|
236 |
itemString.append(this.getBrand().trim());
|
|
|
237 |
}
|
|
|
238 |
itemString.append(" ");
|
|
|
239 |
if (this.getModelName() != null && !this.getModelName().isEmpty()) {
|
|
|
240 |
itemString.append(this.getModelName().trim());
|
|
|
241 |
}
|
|
|
242 |
if (this.getModelNumber() != null && !this.getModelNumber().isEmpty()) {
|
|
|
243 |
itemString.append(" ");
|
|
|
244 |
itemString.append(this.getModelNumber().trim());
|
|
|
245 |
}
|
| 29707 |
tejbeer |
246 |
|
| 31846 |
tejbeer |
247 |
return itemString.toString().replaceAll("\\s+", " ").trim();
|
|
|
248 |
}
|
| 29707 |
tejbeer |
249 |
|
| 31846 |
tejbeer |
250 |
@Override
|
|
|
251 |
public int hashCode() {
|
|
|
252 |
final int prime = 31;
|
|
|
253 |
int result = 1;
|
|
|
254 |
result = prime * result + ((brand == null) ? 0 : brand.hashCode());
|
|
|
255 |
result = prime * result + catalogItemId;
|
|
|
256 |
result = prime * result + categoryId;
|
|
|
257 |
result = prime * result + ((color == null) ? 0 : color.hashCode());
|
|
|
258 |
result = prime * result + ((hsnCode == null) ? 0 : hsnCode.hashCode());
|
|
|
259 |
result = prime * result + id;
|
|
|
260 |
result = prime * result + ((modelName == null) ? 0 : modelName.hashCode());
|
|
|
261 |
result = prime * result + ((modelNumber == null) ? 0 : modelNumber.hashCode());
|
|
|
262 |
result = prime * result + ((productGroup == null) ? 0 : productGroup.hashCode());
|
|
|
263 |
result = prime * result + ((sellingPrice == null) ? 0 : sellingPrice.hashCode());
|
|
|
264 |
result = prime * result + ((startDate == null) ? 0 : startDate.hashCode());
|
|
|
265 |
result = prime * result + ((status == null) ? 0 : status.hashCode());
|
|
|
266 |
result = prime * result + ((type == null) ? 0 : type.hashCode());
|
|
|
267 |
result = prime * result + ((weight == null) ? 0 : weight.hashCode());
|
|
|
268 |
return result;
|
|
|
269 |
}
|
| 29707 |
tejbeer |
270 |
|
| 31846 |
tejbeer |
271 |
@Override
|
|
|
272 |
public boolean equals(Object obj) {
|
|
|
273 |
if (this == obj) return true;
|
|
|
274 |
if (obj == null) return false;
|
|
|
275 |
if (getClass() != obj.getClass()) return false;
|
|
|
276 |
Item other = (Item) obj;
|
|
|
277 |
if (brand == null) {
|
|
|
278 |
if (other.brand != null) return false;
|
|
|
279 |
} else if (!brand.equals(other.brand)) return false;
|
|
|
280 |
if (catalogItemId != other.catalogItemId) return false;
|
|
|
281 |
if (categoryId != other.categoryId) return false;
|
|
|
282 |
if (color == null) {
|
|
|
283 |
if (other.color != null) return false;
|
|
|
284 |
} else if (!color.equals(other.color)) return false;
|
|
|
285 |
if (hsnCode == null) {
|
|
|
286 |
if (other.hsnCode != null) return false;
|
|
|
287 |
} else if (!hsnCode.equals(other.hsnCode)) return false;
|
|
|
288 |
if (id != other.id) return false;
|
|
|
289 |
if (modelName == null) {
|
|
|
290 |
if (other.modelName != null) return false;
|
|
|
291 |
} else if (!modelName.equals(other.modelName)) return false;
|
|
|
292 |
if (modelNumber == null) {
|
|
|
293 |
if (other.modelNumber != null) return false;
|
|
|
294 |
} else if (!modelNumber.equals(other.modelNumber)) return false;
|
|
|
295 |
if (productGroup == null) {
|
|
|
296 |
if (other.productGroup != null) return false;
|
|
|
297 |
} else if (!productGroup.equals(other.productGroup)) return false;
|
|
|
298 |
if (sellingPrice == null) {
|
|
|
299 |
if (other.sellingPrice != null) return false;
|
|
|
300 |
} else if (!sellingPrice.equals(other.sellingPrice)) return false;
|
|
|
301 |
if (startDate == null) {
|
|
|
302 |
if (other.startDate != null) return false;
|
|
|
303 |
} else if (!startDate.equals(other.startDate)) return false;
|
|
|
304 |
if (status != other.status) return false;
|
|
|
305 |
if (type != other.type) return false;
|
|
|
306 |
if (weight == null) {
|
|
|
307 |
if (other.weight != null) return false;
|
|
|
308 |
} else if (!weight.equals(other.weight)) return false;
|
|
|
309 |
return true;
|
|
|
310 |
}
|
| 31767 |
amit.gupta |
311 |
|
| 31846 |
tejbeer |
312 |
@Override
|
|
|
313 |
public String toString() {
|
|
|
314 |
return "Item [id=" + id + ", brand=" + brand + ", status=" + status + ", productGroup=" + productGroup + ", modelName=" + modelName + ", modelNumber=" + modelNumber + ", color=" + color + ", catalogItemId=" + catalogItemId + ", weight=" + weight + ", categoryId=" + categoryId + ", startDate=" + startDate + ", type=" + type + ", hsnCode=" + hsnCode + ", sellingPrice=" + sellingPrice + "]";
|
|
|
315 |
}
|
| 31821 |
amit.gupta |
316 |
|
| 31846 |
tejbeer |
317 |
public status getStatus() {
|
|
|
318 |
return status;
|
|
|
319 |
}
|
|
|
320 |
|
|
|
321 |
public void setStatus(status status) {
|
|
|
322 |
this.status = status;
|
|
|
323 |
}
|
|
|
324 |
|
|
|
325 |
public boolean isAnyColor() {
|
|
|
326 |
if (this.color != null) {
|
|
|
327 |
String lowerCaseColor = this.color.toLowerCase();
|
|
|
328 |
return lowerCaseColor.equals("any color") || lowerCaseColor.equals("f_any color") || lowerCaseColor.equals("any colour") || lowerCaseColor.equals("f_any colour");
|
|
|
329 |
}
|
|
|
330 |
return false;
|
|
|
331 |
}
|
|
|
332 |
|
|
|
333 |
public Float getMrp() {
|
|
|
334 |
return mrp;
|
|
|
335 |
}
|
|
|
336 |
|
|
|
337 |
public void setMrp(Float mrp) {
|
|
|
338 |
this.mrp = mrp;
|
|
|
339 |
}
|
| 21552 |
ashik.ali |
340 |
}
|