Subversion Repositories SmartDukaan

Rev

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