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