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