Subversion Repositories SmartDukaan

Rev

Rev 32694 | Details | Compare with Previous | Last modification | View Log | RSS feed

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