Subversion Repositories SmartDukaan

Rev

Rev 28474 | Rev 30160 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
21714 ashik.ali 1
package com.spice.profitmandi.dao.entity.fofo;
21596 ashik.ali 2
 
3
import java.io.Serializable;
25726 amit.gupta 4
import java.time.LocalDate;
21596 ashik.ali 5
import java.time.LocalDateTime;
22243 ashik.ali 6
import java.time.format.DateTimeFormatter;
21596 ashik.ali 7
 
8
import javax.persistence.Column;
22009 ashik.ali 9
import javax.persistence.Convert;
21596 ashik.ali 10
import javax.persistence.Entity;
11
import javax.persistence.GeneratedValue;
12
import javax.persistence.GenerationType;
13
import javax.persistence.Id;
27579 tejbeer 14
import javax.persistence.NamedQueries;
15
import javax.persistence.NamedQuery;
21596 ashik.ali 16
import javax.persistence.Table;
25083 amit.gupta 17
import javax.persistence.Transient;
21596 ashik.ali 18
 
22009 ashik.ali 19
import com.spice.profitmandi.dao.convertor.LocalDateTimeAttributeConverter;
20
 
21596 ashik.ali 21
@Entity
27579 tejbeer 22
@Table(name = "fofo.fofo_order", schema = "fofo")
21596 ashik.ali 23
 
27579 tejbeer 24
@NamedQueries({
25
 
26
		@NamedQuery(name = "FofoOrder.SelectItemWiseTertiary", query = "select new com.spice.profitmandi.dao.model.ItemWiseTertiaryModel(foi.brand,"
27586 tejbeer 27
				+ "foi.modelName, foi.modelNumber, foi.color, foi.quantity, foi.mop)"
27579 tejbeer 28
				+ " from FofoOrder fo join FofoOrderItem foi on fo.id = foi.orderId where fo.cancelledTimestamp is null and fo.fofoId = :fofoId"
29
				+ " and fo.createTimestamp between :startDate and :endDate"),
30
 
27723 tejbeer 31
		@NamedQuery(name = "FofoOrder.selectGroupByBrandPartnerTertiary", query = "select new com.spice.profitmandi.dao.model.BrandWiseTertiaryModel(foi.brand, "
32
				+ "sum(case when foi.createTimestamp >= :today then CAST(foi.quantity*foi.mop  AS int) else 0 end),"
27728 tejbeer 33
				+ "sum(case when foi.createTimestamp >= :threedays  and foi.createTimestamp < :endDate  then CAST(foi.quantity*foi.mop  AS int) else 0 end),"
27723 tejbeer 34
				+ "sum(case when concat(year(foi.createTimestamp), month(foi.createTimestamp))= :mtd  then CAST(foi.quantity*foi.mop  AS int) else 0 end),"
35
				+ "sum(case when foi.createTimestamp between  :lmtdStartDate and :lmtdEndDate  then CAST(foi.quantity*foi.mop  AS int) else 0 end),"
27748 tejbeer 36
				+ "sum(case when foi.createTimestamp between  :lmtdStartDate and :lmsEndDate  then CAST(foi.quantity*foi.mop  AS int) else 0 end),"
27723 tejbeer 37
				+ "sum(case when foi.createTimestamp >= :today then foi.quantity else 0 end),"
27728 tejbeer 38
				+ "sum(case when foi.createTimestamp >= :threedays and foi.createTimestamp < :endDate then foi.quantity else 0 end),"
27723 tejbeer 39
				+ "sum(case when concat(year(foi.createTimestamp), month(foi.createTimestamp))= :mtd  then foi.quantity else 0 end), "
27748 tejbeer 40
				+ "sum(case when foi.createTimestamp between  :lmtdStartDate and :lmtdEndDate then foi.quantity else 0 end),"
41
				+ "sum(case when foi.createTimestamp between  :lmtdStartDate and :lmsEndDate  then foi.quantity else 0 end)"
42
				+ "	)"
43
				+ " from FofoStore fs join FofoOrder fo on fs.id = fo.fofoId join FofoOrderItem foi on foi.orderId = fo.id  join Item i on i.id = foi.itemId "
44
				+ "  where fo.cancelledTimestamp is null and fs.active = true "
27723 tejbeer 45
				+ " and foi.createTimestamp >= :lmtdStartDate and fs.warehouseId in :warehouseId"
27748 tejbeer 46
				+ " group by foi.brand "),
27723 tejbeer 47
 
27738 tejbeer 48
		@NamedQuery(name = "FofoOrder.selectItemPartnerTertiaryByBrand", query = "select new com.spice.profitmandi.dao.model.BrandItemWiseTertiaryModel(foi.brand, i.modelName,"
49
				+ " i.modelNumber, i.color, foi.quantity*foi.mop, foi.quantity)"
50
				+ " from FofoStore fs join FofoOrder fo on fs.id = fo.fofoId join FofoOrderItem foi on foi.orderId = fo.id  join "
27748 tejbeer 51
				+ " Item i on i.id = foi.itemId where fo.cancelledTimestamp is null and fs.active = true "
52
				+ " and foi.createTimestamp >= :startDate and foi.createTimestamp < :endDate and fs.warehouseId in :warehouseId and foi.brand in :brand order by foi.itemId desc"),
27738 tejbeer 53
 
54
		@NamedQuery(name = "FofoOrder.selectTodayItemPartnerTertiaryByBrand", query = "select new com.spice.profitmandi.dao.model.BrandItemWiseTertiaryModel(foi.brand, i.modelName,"
55
				+ " i.modelNumber, i.color, foi.quantity*foi.mop, foi.quantity)"
56
				+ " from FofoStore fs join FofoOrder fo on fs.id = fo.fofoId join FofoOrderItem foi on foi.orderId = fo.id  join "
27748 tejbeer 57
				+ " Item i on i.id = foi.itemId where fo.cancelledTimestamp is null and fs.active = true "
58
				+ " and foi.createTimestamp >= :startDate and fs.warehouseId in :warehouseId and foi.brand in :brand order by foi.itemId desc"),
27738 tejbeer 59
 
28008 tejbeer 60
		@NamedQuery(name = "FofoOrder.selectValueOfActivatedImeis", query = "select new com.spice.profitmandi.common.model.ActivatedImeisWithSellingPrice("
61
				+ "  fo.fofoId, foi.brand, sum(CAST(foi.mop  AS int) * foi.quantity)) "
62
				+ " from FofoOrder fo join FofoOrderItem foi on fo.id = foi.orderId join FofoLineItem fli on foi.id = fli.fofoOrderItemId join ActivatedImei ai on "
63
				+ " fli.serialNumber = ai.serialNumber where  fo.createTimestamp between :startDate and :endDate and  fo.fofoId = :fofoId and fo.cancelledTimestamp is null group by foi.brand"),
28020 tejbeer 64
 
28004 tejbeer 65
		@NamedQuery(name = "FofoOrder.selectPartnersSaleByCatalogId", query = "select new com.spice.profitmandi.dao.model.FofoIdQtyModel("
28020 tejbeer 66
				+ "  fs.warehouseId, fs.id,sum(case when foi.quantity is null then 0 else  foi.quantity end))"
28004 tejbeer 67
				+ " from FofoStore fs  join FofoOrder fo on fs.id = fo.fofoId  "
68
				+ " join FofoOrderItem foi on foi.orderId = fo.id join  TagListing tl on tl.itemId = foi.itemId "
69
				+ " join Item i on i.id = tl.itemId"
28020 tejbeer 70
				+ " where fs.active = 1 and fs.internal = 0 and fo.cancelledTimestamp is null and fo.createTimestamp > :startDate and i.catalogItemId in :catalogItemId and  i.categoryId=10006 group by fs.id"),
27884 tejbeer 71
 
28004 tejbeer 72
		@NamedQuery(name = "FofoOrder.selectPartnersSaleByRange", query = "select new com.spice.profitmandi.dao.model.FofoIdItemDetailModel("
28020 tejbeer 73
				+ " fs.warehouseId, fs.id,sum(case when foi.quantity is null then 0 else  foi.quantity end),i.brand,i.modelName,i.modelNumber,i.catalogItemId)"
28004 tejbeer 74
				+ " from FofoStore fs  join FofoOrder fo on fs.id = fo.fofoId  "
75
				+ " join FofoOrderItem foi on foi.orderId = fo.id join TagListing tl on tl.itemId = foi.itemId "
76
				+ " join Item i on i.id = tl.itemId"
77
				+ " where fs.active = 1 and fs.internal = 0 and fo.cancelledTimestamp is null "
78
				+ " and fo.createTimestamp > :startDate and tl.mop between :startPrice and :endPrice and  i.categoryId=10006 group by fs.id,i.catalogItemId,i.brand,i.modelName,i.modelNumber"),
79
 
28032 tejbeer 80
		@NamedQuery(name = "FofoOrder.selectPartnersSaleItemByCatalogIdFofoId", query = "select new com.spice.profitmandi.dao.model.FofoIdItemDetailModel("
81
				+ "  fs.warehouseId, fs.id,sum(foi.quantity),i.brand,i.modelName,i.modelNumber,i.catalogItemId)"
82
				+ " from FofoStore fs  join FofoOrder fo on fs.id = fo.fofoId  "
83
				+ " join FofoOrderItem foi on foi.orderId = fo.id join  TagListing tl on tl.itemId = foi.itemId "
84
				+ " join Item i on i.id = tl.itemId"
85
				+ " where fs.active = 1 and fs.internal = 0 and fo.cancelledTimestamp is null and fo.createTimestamp > :startDate and i.catalogItemId in :catalogItemId and  i.categoryId=10006 and fs.id = :fofoId group by i.catalogItemId, i.brand,i.modelName,i.modelNumber"),
86
 
28474 tejbeer 87
		@NamedQuery(name = "FofoOrder.selectSaleByCatalogId", query = "select new com.spice.profitmandi.dao.model.FofoIdCatalogQtyModel("
88
				+ "  fs.warehouseId, fs.id,i.catalogItemId, sum(case when foi.quantity is null then 0 else  foi.quantity end))"
89
				+ " from FofoStore fs  join FofoOrder fo on fs.id = fo.fofoId  "
90
				+ " join FofoOrderItem foi on foi.orderId = fo.id join  TagListing tl on tl.itemId = foi.itemId "
91
				+ " join Item i on i.id = tl.itemId"
28477 tejbeer 92
				+ " where fs.active = 1 and fs.internal = 0 and fo.cancelledTimestamp is null and fo.createTimestamp > :startDate and i.catalogItemId in :catalogItemId and fs.warehouseId in :warehouseId and  i.categoryId=10006 group by i.catalogItemId, fs.id"),
28474 tejbeer 93
 
27579 tejbeer 94
})
95
public class FofoOrder implements Serializable {
96
 
21596 ashik.ali 97
	private static final long serialVersionUID = 1L;
98
 
99
	@Id
100
	@Column(name = "id")
101
	@GeneratedValue(strategy = GenerationType.IDENTITY)
102
	private int id;
27579 tejbeer 103
 
21596 ashik.ali 104
	@Column(name = "fofo_id")
105
	private int fofoId;
27579 tejbeer 106
 
21596 ashik.ali 107
	@Column(name = "customer_id")
108
	private int customerId;
27579 tejbeer 109
 
21710 ashik.ali 110
	@Column(name = "customer_address_id")
111
	private int customerAddressId;
27579 tejbeer 112
 
23369 ashik.ali 113
	@Column(name = "customer_gst_number")
114
	private String customerGstNumber;
27579 tejbeer 115
 
21596 ashik.ali 116
	@Column(name = "total_amount")
117
	private float totalAmount;
27579 tejbeer 118
 
21609 ashik.ali 119
	@Column(name = "invoice_number", length = 50)
21596 ashik.ali 120
	private String invoiceNumber;
27579 tejbeer 121
 
22859 ashik.ali 122
	@Column(name = "cashback")
123
	private float cashback;
27579 tejbeer 124
 
22009 ashik.ali 125
	@Convert(converter = LocalDateTimeAttributeConverter.class)
21596 ashik.ali 126
	@Column(name = "create_timestamp")
27579 tejbeer 127
	private LocalDateTime createTimestamp = LocalDateTime.now();
128
 
24264 amit.gupta 129
	@Convert(converter = LocalDateTimeAttributeConverter.class)
130
	@Column(name = "cancelled_timestamp")
27579 tejbeer 131
	private LocalDateTime cancelledTimestamp;
132
 
133
	// @Convert(converter = LocalDateTimeAttributeConverter.class)
134
	// @Column(name = "billing_timestamp")
25083 amit.gupta 135
	@Transient
27579 tejbeer 136
	private LocalDateTime billingTimestamp;
137
 
26817 amit.gupta 138
	@Transient
25083 amit.gupta 139
	private FofoOrderItem orderItem;
27579 tejbeer 140
 
25726 amit.gupta 141
	@Transient
142
	private LocalDate dateOfBirth;
27579 tejbeer 143
 
25726 amit.gupta 144
	public LocalDate getDateOfBirth() {
145
		return dateOfBirth;
146
	}
27579 tejbeer 147
 
25726 amit.gupta 148
	public void setDateOfBirth(LocalDate dateOfBirth) {
149
		this.dateOfBirth = dateOfBirth;
150
	}
27579 tejbeer 151
 
25083 amit.gupta 152
	public FofoOrderItem getOrderItem() {
153
		return orderItem;
154
	}
27579 tejbeer 155
 
25083 amit.gupta 156
	public void setOrderItem(FofoOrderItem orderItem) {
157
		this.orderItem = orderItem;
158
	}
27579 tejbeer 159
 
24264 amit.gupta 160
	public LocalDateTime getCancelledTimestamp() {
161
		return cancelledTimestamp;
162
	}
27579 tejbeer 163
 
24264 amit.gupta 164
	public void setCancelledTimestamp(LocalDateTime cancelledTimestamp) {
165
		this.cancelledTimestamp = cancelledTimestamp;
166
	}
27579 tejbeer 167
 
21984 kshitij.so 168
	public int getId() {
169
		return id;
170
	}
27579 tejbeer 171
 
21984 kshitij.so 172
	public void setId(int id) {
173
		this.id = id;
174
	}
27579 tejbeer 175
 
21984 kshitij.so 176
	public int getFofoId() {
177
		return fofoId;
178
	}
27579 tejbeer 179
 
21984 kshitij.so 180
	public void setFofoId(int fofoId) {
181
		this.fofoId = fofoId;
182
	}
27579 tejbeer 183
 
21984 kshitij.so 184
	public int getCustomerId() {
185
		return customerId;
186
	}
27579 tejbeer 187
 
21984 kshitij.so 188
	public void setCustomerId(int customerId) {
189
		this.customerId = customerId;
190
	}
27579 tejbeer 191
 
21984 kshitij.so 192
	public int getCustomerAddressId() {
193
		return customerAddressId;
194
	}
27579 tejbeer 195
 
21984 kshitij.so 196
	public void setCustomerAddressId(int customerAddressId) {
197
		this.customerAddressId = customerAddressId;
198
	}
27579 tejbeer 199
 
23369 ashik.ali 200
	public String getCustomerGstNumber() {
201
		return customerGstNumber;
202
	}
27579 tejbeer 203
 
23369 ashik.ali 204
	public void setCustomerGstNumber(String customerGstNumber) {
205
		this.customerGstNumber = customerGstNumber;
206
	}
27579 tejbeer 207
 
21984 kshitij.so 208
	public float getTotalAmount() {
209
		return totalAmount;
210
	}
27579 tejbeer 211
 
21984 kshitij.so 212
	public void setTotalAmount(float totalAmount) {
213
		this.totalAmount = totalAmount;
214
	}
27579 tejbeer 215
 
21984 kshitij.so 216
	public String getInvoiceNumber() {
217
		return invoiceNumber;
218
	}
27579 tejbeer 219
 
21984 kshitij.so 220
	public void setInvoiceNumber(String invoiceNumber) {
221
		this.invoiceNumber = invoiceNumber;
222
	}
27579 tejbeer 223
 
22859 ashik.ali 224
	public float getCashback() {
225
		return cashback;
226
	}
27579 tejbeer 227
 
22859 ashik.ali 228
	public void setCashback(float cashback) {
229
		this.cashback = cashback;
230
	}
27579 tejbeer 231
 
21984 kshitij.so 232
	public LocalDateTime getCreateTimestamp() {
233
		return createTimestamp;
234
	}
27579 tejbeer 235
 
21984 kshitij.so 236
	public void setCreateTimestamp(LocalDateTime createTimestamp) {
237
		this.createTimestamp = createTimestamp;
238
	}
27579 tejbeer 239
 
240
	public String getFormattedDate() {
241
		DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd-MM-yyyy HH:mm");
22243 ashik.ali 242
		return this.createTimestamp.format(formatter);
27579 tejbeer 243
	}
244
 
21924 ashik.ali 245
	@Override
22009 ashik.ali 246
	public int hashCode() {
247
		final int prime = 31;
248
		int result = 1;
26817 amit.gupta 249
		result = prime * result + ((billingTimestamp == null) ? 0 : billingTimestamp.hashCode());
250
		result = prime * result + ((cancelledTimestamp == null) ? 0 : cancelledTimestamp.hashCode());
251
		result = prime * result + Float.floatToIntBits(cashback);
252
		result = prime * result + ((createTimestamp == null) ? 0 : createTimestamp.hashCode());
253
		result = prime * result + customerAddressId;
254
		result = prime * result + ((customerGstNumber == null) ? 0 : customerGstNumber.hashCode());
255
		result = prime * result + customerId;
256
		result = prime * result + ((dateOfBirth == null) ? 0 : dateOfBirth.hashCode());
257
		result = prime * result + fofoId;
22009 ashik.ali 258
		result = prime * result + id;
26817 amit.gupta 259
		result = prime * result + ((invoiceNumber == null) ? 0 : invoiceNumber.hashCode());
260
		result = prime * result + ((orderItem == null) ? 0 : orderItem.hashCode());
261
		result = prime * result + Float.floatToIntBits(totalAmount);
22009 ashik.ali 262
		return result;
263
	}
27579 tejbeer 264
 
22009 ashik.ali 265
	@Override
266
	public boolean equals(Object obj) {
267
		if (this == obj)
268
			return true;
269
		if (obj == null)
270
			return false;
271
		if (getClass() != obj.getClass())
272
			return false;
273
		FofoOrder other = (FofoOrder) obj;
26817 amit.gupta 274
		if (billingTimestamp == null) {
275
			if (other.billingTimestamp != null)
276
				return false;
277
		} else if (!billingTimestamp.equals(other.billingTimestamp))
278
			return false;
279
		if (cancelledTimestamp == null) {
280
			if (other.cancelledTimestamp != null)
281
				return false;
282
		} else if (!cancelledTimestamp.equals(other.cancelledTimestamp))
283
			return false;
284
		if (Float.floatToIntBits(cashback) != Float.floatToIntBits(other.cashback))
285
			return false;
286
		if (createTimestamp == null) {
287
			if (other.createTimestamp != null)
288
				return false;
289
		} else if (!createTimestamp.equals(other.createTimestamp))
290
			return false;
291
		if (customerAddressId != other.customerAddressId)
292
			return false;
293
		if (customerGstNumber == null) {
294
			if (other.customerGstNumber != null)
295
				return false;
296
		} else if (!customerGstNumber.equals(other.customerGstNumber))
297
			return false;
298
		if (customerId != other.customerId)
299
			return false;
300
		if (dateOfBirth == null) {
301
			if (other.dateOfBirth != null)
302
				return false;
303
		} else if (!dateOfBirth.equals(other.dateOfBirth))
304
			return false;
305
		if (fofoId != other.fofoId)
306
			return false;
22009 ashik.ali 307
		if (id != other.id)
308
			return false;
26817 amit.gupta 309
		if (invoiceNumber == null) {
310
			if (other.invoiceNumber != null)
311
				return false;
312
		} else if (!invoiceNumber.equals(other.invoiceNumber))
313
			return false;
314
		if (orderItem == null) {
315
			if (other.orderItem != null)
316
				return false;
317
		} else if (!orderItem.equals(other.orderItem))
318
			return false;
319
		if (Float.floatToIntBits(totalAmount) != Float.floatToIntBits(other.totalAmount))
320
			return false;
22009 ashik.ali 321
		return true;
322
	}
27586 tejbeer 323
 
22009 ashik.ali 324
	@Override
21602 ashik.ali 325
	public String toString() {
21710 ashik.ali 326
		return "FofoOrder [id=" + id + ", fofoId=" + fofoId + ", customerId=" + customerId + ", customerAddressId="
23369 ashik.ali 327
				+ customerAddressId + ", customerGstNumber=" + customerGstNumber + ", totalAmount=" + totalAmount
328
				+ ", invoiceNumber=" + invoiceNumber + ", cashback=" + cashback + ", createTimestamp=" + createTimestamp
26817 amit.gupta 329
				+ ", cancelledTimestamp=" + cancelledTimestamp + ", billingTimestamp=" + billingTimestamp
330
				+ ", orderItem=" + orderItem + ", dateOfBirth=" + dateOfBirth + "]";
21602 ashik.ali 331
	}
27586 tejbeer 332
 
21596 ashik.ali 333
}