Subversion Repositories SmartDukaan

Rev

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