Subversion Repositories SmartDukaan

Rev

Rev 28020 | Rev 28474 | 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
 
27579 tejbeer 87
})
88
public class FofoOrder implements Serializable {
89
 
21596 ashik.ali 90
	private static final long serialVersionUID = 1L;
91
 
92
	@Id
93
	@Column(name = "id")
94
	@GeneratedValue(strategy = GenerationType.IDENTITY)
95
	private int id;
27579 tejbeer 96
 
21596 ashik.ali 97
	@Column(name = "fofo_id")
98
	private int fofoId;
27579 tejbeer 99
 
21596 ashik.ali 100
	@Column(name = "customer_id")
101
	private int customerId;
27579 tejbeer 102
 
21710 ashik.ali 103
	@Column(name = "customer_address_id")
104
	private int customerAddressId;
27579 tejbeer 105
 
23369 ashik.ali 106
	@Column(name = "customer_gst_number")
107
	private String customerGstNumber;
27579 tejbeer 108
 
21596 ashik.ali 109
	@Column(name = "total_amount")
110
	private float totalAmount;
27579 tejbeer 111
 
21609 ashik.ali 112
	@Column(name = "invoice_number", length = 50)
21596 ashik.ali 113
	private String invoiceNumber;
27579 tejbeer 114
 
22859 ashik.ali 115
	@Column(name = "cashback")
116
	private float cashback;
27579 tejbeer 117
 
22009 ashik.ali 118
	@Convert(converter = LocalDateTimeAttributeConverter.class)
21596 ashik.ali 119
	@Column(name = "create_timestamp")
27579 tejbeer 120
	private LocalDateTime createTimestamp = LocalDateTime.now();
121
 
24264 amit.gupta 122
	@Convert(converter = LocalDateTimeAttributeConverter.class)
123
	@Column(name = "cancelled_timestamp")
27579 tejbeer 124
	private LocalDateTime cancelledTimestamp;
125
 
126
	// @Convert(converter = LocalDateTimeAttributeConverter.class)
127
	// @Column(name = "billing_timestamp")
25083 amit.gupta 128
	@Transient
27579 tejbeer 129
	private LocalDateTime billingTimestamp;
130
 
26817 amit.gupta 131
	@Transient
25083 amit.gupta 132
	private FofoOrderItem orderItem;
27579 tejbeer 133
 
25726 amit.gupta 134
	@Transient
135
	private LocalDate dateOfBirth;
27579 tejbeer 136
 
25726 amit.gupta 137
	public LocalDate getDateOfBirth() {
138
		return dateOfBirth;
139
	}
27579 tejbeer 140
 
25726 amit.gupta 141
	public void setDateOfBirth(LocalDate dateOfBirth) {
142
		this.dateOfBirth = dateOfBirth;
143
	}
27579 tejbeer 144
 
25083 amit.gupta 145
	public FofoOrderItem getOrderItem() {
146
		return orderItem;
147
	}
27579 tejbeer 148
 
25083 amit.gupta 149
	public void setOrderItem(FofoOrderItem orderItem) {
150
		this.orderItem = orderItem;
151
	}
27579 tejbeer 152
 
24264 amit.gupta 153
	public LocalDateTime getCancelledTimestamp() {
154
		return cancelledTimestamp;
155
	}
27579 tejbeer 156
 
24264 amit.gupta 157
	public void setCancelledTimestamp(LocalDateTime cancelledTimestamp) {
158
		this.cancelledTimestamp = cancelledTimestamp;
159
	}
27579 tejbeer 160
 
21984 kshitij.so 161
	public int getId() {
162
		return id;
163
	}
27579 tejbeer 164
 
21984 kshitij.so 165
	public void setId(int id) {
166
		this.id = id;
167
	}
27579 tejbeer 168
 
21984 kshitij.so 169
	public int getFofoId() {
170
		return fofoId;
171
	}
27579 tejbeer 172
 
21984 kshitij.so 173
	public void setFofoId(int fofoId) {
174
		this.fofoId = fofoId;
175
	}
27579 tejbeer 176
 
21984 kshitij.so 177
	public int getCustomerId() {
178
		return customerId;
179
	}
27579 tejbeer 180
 
21984 kshitij.so 181
	public void setCustomerId(int customerId) {
182
		this.customerId = customerId;
183
	}
27579 tejbeer 184
 
21984 kshitij.so 185
	public int getCustomerAddressId() {
186
		return customerAddressId;
187
	}
27579 tejbeer 188
 
21984 kshitij.so 189
	public void setCustomerAddressId(int customerAddressId) {
190
		this.customerAddressId = customerAddressId;
191
	}
27579 tejbeer 192
 
23369 ashik.ali 193
	public String getCustomerGstNumber() {
194
		return customerGstNumber;
195
	}
27579 tejbeer 196
 
23369 ashik.ali 197
	public void setCustomerGstNumber(String customerGstNumber) {
198
		this.customerGstNumber = customerGstNumber;
199
	}
27579 tejbeer 200
 
21984 kshitij.so 201
	public float getTotalAmount() {
202
		return totalAmount;
203
	}
27579 tejbeer 204
 
21984 kshitij.so 205
	public void setTotalAmount(float totalAmount) {
206
		this.totalAmount = totalAmount;
207
	}
27579 tejbeer 208
 
21984 kshitij.so 209
	public String getInvoiceNumber() {
210
		return invoiceNumber;
211
	}
27579 tejbeer 212
 
21984 kshitij.so 213
	public void setInvoiceNumber(String invoiceNumber) {
214
		this.invoiceNumber = invoiceNumber;
215
	}
27579 tejbeer 216
 
22859 ashik.ali 217
	public float getCashback() {
218
		return cashback;
219
	}
27579 tejbeer 220
 
22859 ashik.ali 221
	public void setCashback(float cashback) {
222
		this.cashback = cashback;
223
	}
27579 tejbeer 224
 
21984 kshitij.so 225
	public LocalDateTime getCreateTimestamp() {
226
		return createTimestamp;
227
	}
27579 tejbeer 228
 
21984 kshitij.so 229
	public void setCreateTimestamp(LocalDateTime createTimestamp) {
230
		this.createTimestamp = createTimestamp;
231
	}
27579 tejbeer 232
 
233
	public String getFormattedDate() {
234
		DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd-MM-yyyy HH:mm");
22243 ashik.ali 235
		return this.createTimestamp.format(formatter);
27579 tejbeer 236
	}
237
 
21924 ashik.ali 238
	@Override
22009 ashik.ali 239
	public int hashCode() {
240
		final int prime = 31;
241
		int result = 1;
26817 amit.gupta 242
		result = prime * result + ((billingTimestamp == null) ? 0 : billingTimestamp.hashCode());
243
		result = prime * result + ((cancelledTimestamp == null) ? 0 : cancelledTimestamp.hashCode());
244
		result = prime * result + Float.floatToIntBits(cashback);
245
		result = prime * result + ((createTimestamp == null) ? 0 : createTimestamp.hashCode());
246
		result = prime * result + customerAddressId;
247
		result = prime * result + ((customerGstNumber == null) ? 0 : customerGstNumber.hashCode());
248
		result = prime * result + customerId;
249
		result = prime * result + ((dateOfBirth == null) ? 0 : dateOfBirth.hashCode());
250
		result = prime * result + fofoId;
22009 ashik.ali 251
		result = prime * result + id;
26817 amit.gupta 252
		result = prime * result + ((invoiceNumber == null) ? 0 : invoiceNumber.hashCode());
253
		result = prime * result + ((orderItem == null) ? 0 : orderItem.hashCode());
254
		result = prime * result + Float.floatToIntBits(totalAmount);
22009 ashik.ali 255
		return result;
256
	}
27579 tejbeer 257
 
22009 ashik.ali 258
	@Override
259
	public boolean equals(Object obj) {
260
		if (this == obj)
261
			return true;
262
		if (obj == null)
263
			return false;
264
		if (getClass() != obj.getClass())
265
			return false;
266
		FofoOrder other = (FofoOrder) obj;
26817 amit.gupta 267
		if (billingTimestamp == null) {
268
			if (other.billingTimestamp != null)
269
				return false;
270
		} else if (!billingTimestamp.equals(other.billingTimestamp))
271
			return false;
272
		if (cancelledTimestamp == null) {
273
			if (other.cancelledTimestamp != null)
274
				return false;
275
		} else if (!cancelledTimestamp.equals(other.cancelledTimestamp))
276
			return false;
277
		if (Float.floatToIntBits(cashback) != Float.floatToIntBits(other.cashback))
278
			return false;
279
		if (createTimestamp == null) {
280
			if (other.createTimestamp != null)
281
				return false;
282
		} else if (!createTimestamp.equals(other.createTimestamp))
283
			return false;
284
		if (customerAddressId != other.customerAddressId)
285
			return false;
286
		if (customerGstNumber == null) {
287
			if (other.customerGstNumber != null)
288
				return false;
289
		} else if (!customerGstNumber.equals(other.customerGstNumber))
290
			return false;
291
		if (customerId != other.customerId)
292
			return false;
293
		if (dateOfBirth == null) {
294
			if (other.dateOfBirth != null)
295
				return false;
296
		} else if (!dateOfBirth.equals(other.dateOfBirth))
297
			return false;
298
		if (fofoId != other.fofoId)
299
			return false;
22009 ashik.ali 300
		if (id != other.id)
301
			return false;
26817 amit.gupta 302
		if (invoiceNumber == null) {
303
			if (other.invoiceNumber != null)
304
				return false;
305
		} else if (!invoiceNumber.equals(other.invoiceNumber))
306
			return false;
307
		if (orderItem == null) {
308
			if (other.orderItem != null)
309
				return false;
310
		} else if (!orderItem.equals(other.orderItem))
311
			return false;
312
		if (Float.floatToIntBits(totalAmount) != Float.floatToIntBits(other.totalAmount))
313
			return false;
22009 ashik.ali 314
		return true;
315
	}
27586 tejbeer 316
 
22009 ashik.ali 317
	@Override
21602 ashik.ali 318
	public String toString() {
21710 ashik.ali 319
		return "FofoOrder [id=" + id + ", fofoId=" + fofoId + ", customerId=" + customerId + ", customerAddressId="
23369 ashik.ali 320
				+ customerAddressId + ", customerGstNumber=" + customerGstNumber + ", totalAmount=" + totalAmount
321
				+ ", invoiceNumber=" + invoiceNumber + ", cashback=" + cashback + ", createTimestamp=" + createTimestamp
26817 amit.gupta 322
				+ ", cancelledTimestamp=" + cancelledTimestamp + ", billingTimestamp=" + billingTimestamp
323
				+ ", orderItem=" + orderItem + ", dateOfBirth=" + dateOfBirth + "]";
21602 ashik.ali 324
	}
27586 tejbeer 325
 
21596 ashik.ali 326
}