Subversion Repositories SmartDukaan

Rev

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