| 33772 |
amit.gupta |
1 |
package com.spice.profitmandi.dao.entity.catalog;
|
|
|
2 |
|
|
|
3 |
import javax.persistence.*;
|
|
|
4 |
import java.time.LocalDateTime;
|
|
|
5 |
import java.util.Objects;
|
|
|
6 |
|
| 35343 |
ranu |
7 |
|
|
|
8 |
@NamedQueries({
|
|
|
9 |
@NamedQuery(name = "Catalog.findOtherORNullCategoryAndInStock", query = "select i.catalogItemId "
|
|
|
10 |
+ " from WarehouseInventoryItem wi "
|
|
|
11 |
+ " join Item i on i.id = wi.itemId"
|
|
|
12 |
+ " left join CategorisedCatalog cc on cc.catalogId = i.catalogItemId and cc.endDate is null "
|
| 35356 |
ranu |
13 |
+ " where ((cc.status is null OR cc.status = 'OTHER' OR cc.status = 'SLOWMOVING')) and i.categoryId in (10006,10009,10010) and i.brand= :brand group by i.catalogItemId having sum(wi.currentQuantity) > 0"),
|
| 35343 |
ranu |
14 |
|
|
|
15 |
@NamedQuery(name = "Catalog.findOtherORNullCategoryAndPartnerInStock", query = "select i.catalogItemId "
|
|
|
16 |
+ " from CurrentInventorySnapshot cis "
|
|
|
17 |
+ " join Item i on i.id = cis.itemId"
|
|
|
18 |
+ " left join CategorisedCatalog cc on cc.catalogId = i.catalogItemId and cc.endDate is null "
|
| 35356 |
ranu |
19 |
+ " where ((cc.status is null OR cc.status = 'OTHER' OR cc.status = 'SLOWMOVING')) and i.categoryId in (10006,10009,10010) and i.brand= :brand and cis.fofoId = :fofoId group by i.catalogItemId having sum(cis.availability) > 0"),
|
| 35357 |
ranu |
20 |
|
| 35365 |
ranu |
21 |
@NamedQuery(name = "Catalog.findAllWithEOLWithOutStock", query = "select i.catalogItemId "
|
| 35359 |
ranu |
22 |
+ " from Item i "
|
|
|
23 |
+ " left join WarehouseInventoryItem wi on i.id = wi.itemId"
|
| 35357 |
ranu |
24 |
+ " left join CategorisedCatalog cc on cc.catalogId = i.catalogItemId and cc.endDate is null "
|
| 35426 |
ranu |
25 |
+ " where ((cc.status is null OR cc.status = 'OTHER' OR cc.status = 'SLOWMOVING')) and i.categoryId in (10006,10009,10010) group by i.catalogItemId having (sum(wi.currentQuantity) = 0 OR sum(wi.currentQuantity) IS NULL)"),
|
| 35357 |
ranu |
26 |
|
| 35487 |
ranu |
27 |
@NamedQuery(name = "Catalog.selectAllStatusAndBrandWise", query = "select c.id" +
|
|
|
28 |
" from Catalog c " +
|
|
|
29 |
" join CategorisedCatalog cc on c.id = cc.catalogId and cc.endDate is null" +
|
|
|
30 |
" where cc.status in (:statuses) and c.brand in :brands"),
|
| 35426 |
ranu |
31 |
|
| 35501 |
ranu |
32 |
@NamedQuery(name = "Catalog.selectAllGoodStockBrandWise", query = "SELECT DISTINCT c " +
|
|
|
33 |
"FROM Catalog c " +
|
|
|
34 |
" JOIN Item i ON i.catalogItemId = c.id " +
|
|
|
35 |
" JOIN CategorisedCatalog cc ON c.id = cc.catalogId and cc.endDate is null " +
|
|
|
36 |
" JOIN WarehouseInventoryItem wi ON wi.itemId = i.id " +
|
|
|
37 |
" WHERE " +
|
|
|
38 |
" i.categoryId IN (10006) " +
|
|
|
39 |
" AND (wi.lastScanType NOT IN (:scanTypes) OR wi.lastScanType IS NULL) " +
|
|
|
40 |
" " +
|
|
|
41 |
" AND ( " +
|
|
|
42 |
" (cc.status NOT IN (:movingStatus) AND cc.status IS NOT NULL) " +
|
|
|
43 |
" OR " +
|
|
|
44 |
" wi.currentQuantity > 0 " +
|
|
|
45 |
" ) " +
|
|
|
46 |
" and c.brand = :brand " +
|
|
|
47 |
" GROUP BY c.id"),
|
| 35487 |
ranu |
48 |
|
| 35501 |
ranu |
49 |
|
| 35426 |
ranu |
50 |
@NamedQuery(
|
|
|
51 |
name = "Catalog.findAllWithNoGoodStock",
|
|
|
52 |
query = "select i.catalogItemId "
|
|
|
53 |
+ " from Item i "
|
|
|
54 |
+ " left join WarehouseInventoryItem wi on i.id = wi.itemId "
|
|
|
55 |
+ " left join CategorisedCatalog cc on cc.catalogId = i.catalogItemId and cc.endDate is null "
|
|
|
56 |
+ " where (cc.status is null OR cc.status = 'OTHER' OR cc.status = 'SLOWMOVING') "
|
|
|
57 |
+ " and i.categoryId in (10006, 10009, 10010) "
|
|
|
58 |
+ " group by i.catalogItemId "
|
|
|
59 |
+ " having "
|
|
|
60 |
+ " sum(case when (wi.lastScanType is null OR wi.lastScanType NOT IN (:scanTypes)) "
|
|
|
61 |
+ " then wi.currentQuantity else 0 end) = 0 "
|
|
|
62 |
+ " OR sum(wi.currentQuantity) IS NULL"
|
|
|
63 |
)
|
|
|
64 |
|
| 35343 |
ranu |
65 |
})
|
|
|
66 |
|
| 33772 |
amit.gupta |
67 |
@Entity
|
|
|
68 |
@Table(name = "catalog.catalog")
|
|
|
69 |
public class Catalog {
|
|
|
70 |
@Id
|
|
|
71 |
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
|
|
72 |
@Column(name = "id", columnDefinition = "int(11)")
|
|
|
73 |
private int id;
|
|
|
74 |
|
|
|
75 |
@Column(name="brand_id")
|
|
|
76 |
private int brandId;
|
|
|
77 |
|
|
|
78 |
@Column
|
|
|
79 |
private String brand;
|
|
|
80 |
|
|
|
81 |
@Column(name="model_number")
|
|
|
82 |
private String modelNumber;
|
|
|
83 |
|
|
|
84 |
@Column(name="model_name")
|
|
|
85 |
private String modelName;
|
|
|
86 |
|
| 33888 |
ranu |
87 |
@Column(name = "category_id")
|
|
|
88 |
private int categoryId;
|
|
|
89 |
|
| 33772 |
amit.gupta |
90 |
@Column(name="created_by")
|
|
|
91 |
private String createdBy;
|
|
|
92 |
|
|
|
93 |
@Column
|
|
|
94 |
private LocalDateTime created;
|
|
|
95 |
|
|
|
96 |
public int getId() {
|
|
|
97 |
return id;
|
|
|
98 |
}
|
|
|
99 |
|
|
|
100 |
public void setId(int id) {
|
|
|
101 |
this.id = id;
|
|
|
102 |
}
|
|
|
103 |
|
|
|
104 |
public int getBrandId() {
|
|
|
105 |
return brandId;
|
|
|
106 |
}
|
|
|
107 |
|
|
|
108 |
public void setBrandId(int brandId) {
|
|
|
109 |
this.brandId = brandId;
|
|
|
110 |
}
|
|
|
111 |
|
|
|
112 |
public String getBrand() {
|
|
|
113 |
return brand;
|
|
|
114 |
}
|
|
|
115 |
|
|
|
116 |
public void setBrand(String brand) {
|
|
|
117 |
this.brand = brand;
|
|
|
118 |
}
|
|
|
119 |
|
|
|
120 |
public String getModelNumber() {
|
|
|
121 |
return modelNumber;
|
|
|
122 |
}
|
|
|
123 |
|
|
|
124 |
public void setModelNumber(String modelNumber) {
|
|
|
125 |
this.modelNumber = modelNumber;
|
|
|
126 |
}
|
|
|
127 |
|
|
|
128 |
public String getModelName() {
|
|
|
129 |
return modelName;
|
|
|
130 |
}
|
|
|
131 |
|
|
|
132 |
public void setModelName(String modelName) {
|
|
|
133 |
this.modelName = modelName;
|
|
|
134 |
}
|
|
|
135 |
|
|
|
136 |
public String getCreatedBy() {
|
|
|
137 |
return createdBy;
|
|
|
138 |
}
|
|
|
139 |
|
|
|
140 |
public void setCreatedBy(String createdBy) {
|
|
|
141 |
this.createdBy = createdBy;
|
|
|
142 |
}
|
|
|
143 |
|
|
|
144 |
public LocalDateTime getCreated() {
|
|
|
145 |
return created;
|
|
|
146 |
}
|
|
|
147 |
|
|
|
148 |
public void setCreated(LocalDateTime created) {
|
|
|
149 |
this.created = created;
|
|
|
150 |
}
|
|
|
151 |
|
| 33888 |
ranu |
152 |
public int getCategoryId() {
|
|
|
153 |
return categoryId;
|
|
|
154 |
}
|
|
|
155 |
|
|
|
156 |
public void setCategoryId(int categoryId) {
|
|
|
157 |
this.categoryId = categoryId;
|
|
|
158 |
}
|
|
|
159 |
|
| 33772 |
amit.gupta |
160 |
@Override
|
|
|
161 |
public boolean equals(Object o) {
|
|
|
162 |
if (this == o) return true;
|
|
|
163 |
if (o == null || getClass() != o.getClass()) return false;
|
|
|
164 |
Catalog catalog = (Catalog) o;
|
| 33888 |
ranu |
165 |
return id == catalog.id && brandId == catalog.brandId && categoryId == catalog.categoryId && Objects.equals(brand, catalog.brand) && Objects.equals(modelNumber, catalog.modelNumber) && Objects.equals(modelName, catalog.modelName) && Objects.equals(createdBy, catalog.createdBy) && Objects.equals(created, catalog.created);
|
| 33772 |
amit.gupta |
166 |
}
|
|
|
167 |
|
|
|
168 |
@Override
|
| 33888 |
ranu |
169 |
public int hashCode() {
|
|
|
170 |
return Objects.hash(id, brandId, brand, modelNumber, modelName, categoryId, createdBy, created);
|
|
|
171 |
}
|
|
|
172 |
|
| 33916 |
amit.gupta |
173 |
public String getDescription() {
|
|
|
174 |
StringBuilder itemString = new StringBuilder();
|
|
|
175 |
if (this.getBrand() != null && !this.getBrand().isEmpty()) {
|
|
|
176 |
itemString.append(this.getBrand().trim());
|
|
|
177 |
}
|
|
|
178 |
itemString.append(" ");
|
|
|
179 |
if (this.getModelName() != null && !this.getModelName().isEmpty()) {
|
|
|
180 |
itemString.append(this.getModelName().trim());
|
|
|
181 |
}
|
|
|
182 |
if (this.getModelNumber() != null && !this.getModelNumber().isEmpty()) {
|
|
|
183 |
itemString.append(" ");
|
|
|
184 |
itemString.append(this.getModelNumber().trim());
|
|
|
185 |
}
|
|
|
186 |
|
|
|
187 |
return itemString.toString().replaceAll("\\s+", " ").trim();
|
|
|
188 |
}
|
|
|
189 |
|
| 35188 |
amit |
190 |
public String getDescriptionNoBrand() {
|
|
|
191 |
StringBuilder itemString = new StringBuilder();
|
|
|
192 |
itemString.append(" ");
|
|
|
193 |
if (this.getModelName() != null && !this.getModelName().isEmpty()) {
|
|
|
194 |
itemString.append(this.getModelName().trim());
|
|
|
195 |
}
|
|
|
196 |
if (this.getModelNumber() != null && !this.getModelNumber().isEmpty()) {
|
|
|
197 |
itemString.append(" ");
|
|
|
198 |
itemString.append(this.getModelNumber().trim());
|
|
|
199 |
}
|
|
|
200 |
|
|
|
201 |
return itemString.toString().replaceAll("\\s+", " ").trim();
|
|
|
202 |
}
|
|
|
203 |
|
| 33888 |
ranu |
204 |
@Override
|
| 33772 |
amit.gupta |
205 |
public String toString() {
|
|
|
206 |
return "Catalog{" +
|
|
|
207 |
"id=" + id +
|
|
|
208 |
", brandId=" + brandId +
|
|
|
209 |
", brand='" + brand + '\'' +
|
|
|
210 |
", modelNumber='" + modelNumber + '\'' +
|
|
|
211 |
", modelName='" + modelName + '\'' +
|
| 33888 |
ranu |
212 |
", categoryId=" + categoryId +
|
| 33772 |
amit.gupta |
213 |
", createdBy='" + createdBy + '\'' +
|
|
|
214 |
", created=" + created +
|
|
|
215 |
'}';
|
|
|
216 |
}
|
|
|
217 |
|
|
|
218 |
}
|
|
|
219 |
|