Subversion Repositories SmartDukaan

Rev

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