| 24081 |
govind |
1 |
package com.spice.profitmandi.dao.entity.warehouse;
|
|
|
2 |
|
|
|
3 |
import java.time.LocalDateTime;
|
|
|
4 |
|
|
|
5 |
import javax.persistence.Column;
|
|
|
6 |
import javax.persistence.Convert;
|
|
|
7 |
import javax.persistence.Entity;
|
|
|
8 |
import javax.persistence.EnumType;
|
|
|
9 |
import javax.persistence.Enumerated;
|
|
|
10 |
import javax.persistence.GeneratedValue;
|
|
|
11 |
import javax.persistence.GenerationType;
|
|
|
12 |
import javax.persistence.Id;
|
| 27723 |
tejbeer |
13 |
import javax.persistence.NamedQueries;
|
|
|
14 |
import javax.persistence.NamedQuery;
|
| 24081 |
govind |
15 |
import javax.persistence.Table;
|
|
|
16 |
|
|
|
17 |
import com.spice.profitmandi.dao.convertor.LocalDateTimeAttributeConverter;
|
|
|
18 |
|
|
|
19 |
import in.shop2020.warehouse.ScanType;
|
| 27723 |
tejbeer |
20 |
|
| 24081 |
govind |
21 |
/**
|
|
|
22 |
* This class basically contains scheme details
|
|
|
23 |
*
|
|
|
24 |
* @author Govind Kumar
|
|
|
25 |
*
|
|
|
26 |
*/
|
|
|
27 |
@Entity
|
|
|
28 |
@Table(name = "warehouse.scanNew", schema = "warehouse")
|
| 27723 |
tejbeer |
29 |
@NamedQueries({
|
|
|
30 |
@NamedQuery(name = "warehouse.selectOurPurchase", query = "select new com.spice.profitmandi.dao.model.OurPurchaseModel(li.brand, "
|
|
|
31 |
+ " sum(case when sn.scannedAt >= :today then CAST(sn.quantity * li.unitPrice AS int) else 0 end),"
|
| 27728 |
tejbeer |
32 |
+ " sum(case when sn.scannedAt >= :threedays and sn.scannedAt < :endDate then CAST(sn.quantity * li.unitPrice AS int) else 0 end),"
|
| 27749 |
tejbeer |
33 |
+ " sum(case when sn.scannedAt >= :dataDate and sn.scannedAt < :lmsEndDate then CAST(sn.quantity * li.unitPrice AS int) else 0 end),"
|
|
|
34 |
+ " sum(case when sn.scannedAt >= :mtd then CAST(sn.quantity * li.unitPrice AS int) else 0 end),"
|
| 27736 |
tejbeer |
35 |
+ " sum(case when sn.scannedAt >= :today then sn.quantity else 0 end),"
|
| 27728 |
tejbeer |
36 |
+ " sum(case when sn.scannedAt >= :threedays and sn.scannedAt < :endDate then CAST(sn.quantity AS int) else 0 end),"
|
| 27749 |
tejbeer |
37 |
+ " sum(case when sn.scannedAt >= :dataDate and sn.scannedAt <= :lmsEndDate then CAST(sn.quantity AS int) else 0 end),"
|
|
|
38 |
+ " sum(case when sn.scannedAt >= :mtd then CAST(sn.quantity AS int) else 0 end)" + " )"
|
| 27723 |
tejbeer |
39 |
+ " from WarehouseScan sn join WarehouseInventoryItem it on sn.inventoryItemId = it.id join WarehousePurchase p on it.purchaseId = p.id "
|
| 27737 |
tejbeer |
40 |
+ " join WarehousePurchaseOrder po on po.id = p.poId join WarehouseLineItem li on li.purchaseOrderId = po.id and li.itemId = it.itemId "
|
|
|
41 |
+ " where po.warehouseId in :warehouseId and sn.scannedAt >= :dataDate and sn.type = 'PURCHASE' group by li.brand"),
|
| 27723 |
tejbeer |
42 |
|
| 27749 |
tejbeer |
43 |
@NamedQuery(name = "warehouse.selectOurPurchaseItemByBrand", query = "select new com.spice.profitmandi.dao.model.OurPurchaseItemModel(po.warehouseId,li.brand,li.modelName, li.modelNumber, li.color,"
|
| 27738 |
tejbeer |
44 |
+ " sn.quantity * li.unitPrice , sn.quantity)"
|
|
|
45 |
+ " from WarehouseScan sn join WarehouseInventoryItem it on sn.inventoryItemId = it.id join WarehousePurchase p on it.purchaseId = p.id "
|
|
|
46 |
+ " join WarehousePurchaseOrder po on po.id = p.poId join WarehouseLineItem li on li.purchaseOrderId = po.id and li.itemId = it.itemId "
|
| 27749 |
tejbeer |
47 |
+ " where po.warehouseId in :warehouseId and sn.scannedAt >= :startDate and sn.scannedAt < :endDate and sn.type = 'PURCHASE'and li.brand in :brand order by li.itemId desc"),
|
| 27738 |
tejbeer |
48 |
|
| 27749 |
tejbeer |
49 |
@NamedQuery(name = "warehouse.selectTodayOurPurchaseItemByBrand", query = "select new com.spice.profitmandi.dao.model.OurPurchaseItemModel(po.warehouseId,li.brand,li.modelName, li.modelNumber, li.color,"
|
| 27738 |
tejbeer |
50 |
+ " sn.quantity * li.unitPrice , sn.quantity)"
|
|
|
51 |
+ " from WarehouseScan sn join WarehouseInventoryItem it on sn.inventoryItemId = it.id join WarehousePurchase p on it.purchaseId = p.id "
|
|
|
52 |
+ " join WarehousePurchaseOrder po on po.id = p.poId join WarehouseLineItem li on li.purchaseOrderId = po.id and li.itemId = it.itemId "
|
| 27749 |
tejbeer |
53 |
+ " where po.warehouseId in :warehouseId and sn.scannedAt >= :startDate and sn.type = 'PURCHASE'and li.brand in :brand order by li.itemId desc"),
|
| 27738 |
tejbeer |
54 |
|
| 27723 |
tejbeer |
55 |
})
|
| 24081 |
govind |
56 |
public class WarehouseScan {
|
|
|
57 |
|
|
|
58 |
@Id
|
|
|
59 |
@Column(name = "id", unique = true, updatable = false)
|
|
|
60 |
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
|
|
61 |
private int id;
|
|
|
62 |
|
|
|
63 |
@Column(name = "inventoryItemId")
|
|
|
64 |
private int inventoryItemId;
|
|
|
65 |
|
|
|
66 |
@Column(name = "quantity")
|
|
|
67 |
private Integer quantity;
|
| 27723 |
tejbeer |
68 |
|
| 24081 |
govind |
69 |
@Column(name = "orderId")
|
|
|
70 |
private Integer orderId; // The order that was fulfilled with thin scan!
|
| 27723 |
tejbeer |
71 |
|
| 24081 |
govind |
72 |
@Column(name = "warehouseId")
|
|
|
73 |
private int warehouseId;
|
| 27723 |
tejbeer |
74 |
|
| 24081 |
govind |
75 |
@Column(name = "transferLotId")
|
|
|
76 |
private Integer transferLotId;
|
| 27723 |
tejbeer |
77 |
|
| 24081 |
govind |
78 |
@Column(name = "type")
|
|
|
79 |
@Enumerated(EnumType.STRING)
|
|
|
80 |
private ScanType type;
|
| 27723 |
tejbeer |
81 |
|
| 24081 |
govind |
82 |
@Convert(converter = LocalDateTimeAttributeConverter.class)
|
|
|
83 |
@Column(name = "scannedAt")
|
|
|
84 |
private LocalDateTime scannedAt;
|
| 27723 |
tejbeer |
85 |
|
| 24081 |
govind |
86 |
@Column(name = "remarks")
|
|
|
87 |
private String remarks;
|
|
|
88 |
|
|
|
89 |
public int getId() {
|
|
|
90 |
return id;
|
|
|
91 |
}
|
|
|
92 |
|
|
|
93 |
public void setId(int id) {
|
|
|
94 |
this.id = id;
|
|
|
95 |
}
|
|
|
96 |
|
|
|
97 |
public int getInventoryItemId() {
|
|
|
98 |
return inventoryItemId;
|
|
|
99 |
}
|
|
|
100 |
|
|
|
101 |
public void setInventoryItemId(int inventoryItemId) {
|
|
|
102 |
this.inventoryItemId = inventoryItemId;
|
|
|
103 |
}
|
|
|
104 |
|
|
|
105 |
public Integer getQuantity() {
|
|
|
106 |
return quantity;
|
|
|
107 |
}
|
|
|
108 |
|
|
|
109 |
public void setQuantity(Integer quantity) {
|
|
|
110 |
this.quantity = quantity;
|
|
|
111 |
}
|
|
|
112 |
|
|
|
113 |
public Integer getOrderId() {
|
|
|
114 |
return orderId;
|
|
|
115 |
}
|
|
|
116 |
|
|
|
117 |
public void setOrderId(Integer orderId) {
|
|
|
118 |
this.orderId = orderId;
|
|
|
119 |
}
|
|
|
120 |
|
|
|
121 |
public int getWarehouseId() {
|
|
|
122 |
return warehouseId;
|
|
|
123 |
}
|
|
|
124 |
|
|
|
125 |
public void setWarehouseId(int warehouseId) {
|
|
|
126 |
this.warehouseId = warehouseId;
|
|
|
127 |
}
|
|
|
128 |
|
|
|
129 |
public Integer getTransferLotId() {
|
|
|
130 |
return transferLotId;
|
|
|
131 |
}
|
|
|
132 |
|
|
|
133 |
public void setTransferLotId(Integer transferLotId) {
|
|
|
134 |
this.transferLotId = transferLotId;
|
|
|
135 |
}
|
|
|
136 |
|
|
|
137 |
public ScanType getType() {
|
|
|
138 |
return type;
|
|
|
139 |
}
|
|
|
140 |
|
|
|
141 |
public void setType(ScanType type) {
|
|
|
142 |
this.type = type;
|
|
|
143 |
}
|
|
|
144 |
|
|
|
145 |
public LocalDateTime getScannedAt() {
|
|
|
146 |
return scannedAt;
|
|
|
147 |
}
|
|
|
148 |
|
|
|
149 |
public void setScannedAt(LocalDateTime scannedAt) {
|
|
|
150 |
this.scannedAt = scannedAt;
|
|
|
151 |
}
|
|
|
152 |
|
|
|
153 |
public String getRemarks() {
|
|
|
154 |
return remarks;
|
|
|
155 |
}
|
|
|
156 |
|
|
|
157 |
public void setRemarks(String remarks) {
|
|
|
158 |
this.remarks = remarks;
|
|
|
159 |
}
|
|
|
160 |
|
|
|
161 |
@Override
|
|
|
162 |
public int hashCode() {
|
|
|
163 |
final int prime = 31;
|
|
|
164 |
int result = 1;
|
|
|
165 |
result = prime * result + id;
|
|
|
166 |
result = prime * result + inventoryItemId;
|
|
|
167 |
result = prime * result + ((orderId == null) ? 0 : orderId.hashCode());
|
|
|
168 |
result = prime * result + ((quantity == null) ? 0 : quantity.hashCode());
|
|
|
169 |
result = prime * result + ((remarks == null) ? 0 : remarks.hashCode());
|
|
|
170 |
result = prime * result + ((scannedAt == null) ? 0 : scannedAt.hashCode());
|
|
|
171 |
result = prime * result + ((transferLotId == null) ? 0 : transferLotId.hashCode());
|
|
|
172 |
result = prime * result + ((type == null) ? 0 : type.hashCode());
|
|
|
173 |
result = prime * result + warehouseId;
|
|
|
174 |
return result;
|
|
|
175 |
}
|
|
|
176 |
|
|
|
177 |
@Override
|
|
|
178 |
public boolean equals(Object obj) {
|
|
|
179 |
if (this == obj)
|
|
|
180 |
return true;
|
|
|
181 |
if (obj == null)
|
|
|
182 |
return false;
|
|
|
183 |
if (getClass() != obj.getClass())
|
|
|
184 |
return false;
|
|
|
185 |
WarehouseScan other = (WarehouseScan) obj;
|
|
|
186 |
if (id != other.id)
|
|
|
187 |
return false;
|
|
|
188 |
if (inventoryItemId != other.inventoryItemId)
|
|
|
189 |
return false;
|
|
|
190 |
if (orderId == null) {
|
|
|
191 |
if (other.orderId != null)
|
|
|
192 |
return false;
|
|
|
193 |
} else if (!orderId.equals(other.orderId))
|
|
|
194 |
return false;
|
|
|
195 |
if (quantity == null) {
|
|
|
196 |
if (other.quantity != null)
|
|
|
197 |
return false;
|
|
|
198 |
} else if (!quantity.equals(other.quantity))
|
|
|
199 |
return false;
|
|
|
200 |
if (remarks == null) {
|
|
|
201 |
if (other.remarks != null)
|
|
|
202 |
return false;
|
|
|
203 |
} else if (!remarks.equals(other.remarks))
|
|
|
204 |
return false;
|
|
|
205 |
if (scannedAt == null) {
|
|
|
206 |
if (other.scannedAt != null)
|
|
|
207 |
return false;
|
|
|
208 |
} else if (!scannedAt.equals(other.scannedAt))
|
|
|
209 |
return false;
|
|
|
210 |
if (transferLotId == null) {
|
|
|
211 |
if (other.transferLotId != null)
|
|
|
212 |
return false;
|
|
|
213 |
} else if (!transferLotId.equals(other.transferLotId))
|
|
|
214 |
return false;
|
|
|
215 |
if (type != other.type)
|
|
|
216 |
return false;
|
|
|
217 |
if (warehouseId != other.warehouseId)
|
|
|
218 |
return false;
|
|
|
219 |
return true;
|
|
|
220 |
}
|
|
|
221 |
|
|
|
222 |
@Override
|
|
|
223 |
public String toString() {
|
|
|
224 |
return "WarehouseScan [id=" + id + ", inventoryItemId=" + inventoryItemId + ", quantity=" + quantity
|
|
|
225 |
+ ", orderId=" + orderId + ", warehouseId=" + warehouseId + ", transferLotId=" + transferLotId
|
|
|
226 |
+ ", type=" + type + ", scannedAt=" + scannedAt + ", remarks=" + remarks + "]";
|
|
|
227 |
}
|
|
|
228 |
|
|
|
229 |
}
|