Subversion Repositories SmartDukaan

Rev

Rev 27592 | Rev 27599 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
22653 ashik.ali 1
package com.spice.profitmandi.dao.entity.fofo;
22418 ashik.ali 2
 
3
import java.io.Serializable;
24349 amit.gupta 4
import java.time.LocalDate;
22418 ashik.ali 5
 
6
import javax.persistence.Column;
7
import javax.persistence.Entity;
23786 amit.gupta 8
import javax.persistence.EnumType;
9
import javax.persistence.Enumerated;
22418 ashik.ali 10
import javax.persistence.Id;
27556 tejbeer 11
import javax.persistence.NamedQueries;
12
import javax.persistence.NamedQuery;
22418 ashik.ali 13
import javax.persistence.Table;
23786 amit.gupta 14
import javax.persistence.Transient;
22418 ashik.ali 15
 
23786 amit.gupta 16
import com.spice.profitmandi.common.enumuration.CounterSize;
17
import com.spice.profitmandi.dao.entity.user.Address;
18
 
22418 ashik.ali 19
/**
20
 * This class basically contains store code details
21
 * 
22
 * @author ashikali
23
 *
24
 */
25
@Entity
27556 tejbeer 26
@Table(name = "fofo.fofo_store", schema = "fofo")
27
 
28
@NamedQueries({
29
 
27594 tejbeer 30
		@NamedQuery(name = "FofoStore.selectGroupByBrandWarehousePartnerSale", query = "select new com.spice.profitmandi.dao.model.BrandWisePartnerSaleModel(foi.brand, "
31
				+ "sum(case when concat(year(foi.createTimestamp), month(foi.createTimestamp))= :lms then CAST(foi.quantity*foi.mop  AS int) else 0 end),"
32
				+ "sum(case when concat(year(foi.createTimestamp), month(foi.createTimestamp))= :lms then foi.quantity  else 0 end),"
33
				+ "sum(case when concat(year(foi.createTimestamp), month(foi.createTimestamp))= :mtd  then CAST(foi.quantity*foi.mop  AS int) else 0 end),"
34
				+ "sum(case when concat(year(foi.createTimestamp), month(foi.createTimestamp))= :mtd  then foi.quantity 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 between  :lmtdStartDate and :lmtdEndDate then foi.quantity else 0 end))"
37
				+ " 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 "
38
				+ "and foi.createTimestamp >= :lmtdStartDate and i.categoryId = :categoryId" + " group by foi.brand"),
39
 
27592 tejbeer 40
		@NamedQuery(name = "FofoStore.selectGroupByWarehouseBrandWisePartnerSale", query = "select new com.spice.profitmandi.dao.model.WarehouseWiseBrandSaleModel("
41
				+ "(case when a.city in ('Noida', 'Ghaziabad')  and foi.brand = 'Vivo' then 7573 else fs.warehouseId end) AS col_0_0_,"
27574 tejbeer 42
				+ "sum(case when concat(year(foi.createTimestamp), month(foi.createTimestamp))= :lms then CAST(foi.quantity*foi.mop  AS int) else 0 end),"
43
				+ "sum(case when concat(year(foi.createTimestamp), month(foi.createTimestamp))= :lms then foi.quantity  else 0 end),"
44
				+ "sum(case when concat(year(foi.createTimestamp), month(foi.createTimestamp))= :mtd  then CAST(foi.quantity*foi.mop  AS int) else 0 end),"
45
				+ "sum(case when concat(year(foi.createTimestamp), month(foi.createTimestamp))= :mtd  then foi.quantity else 0 end), "
46
				+ "sum(case when foi.createTimestamp between  :lmtdStartDate and :lmtdEndDate  then CAST(foi.quantity*foi.mop  AS int) else 0 end), "
47
				+ "sum(case when foi.createTimestamp between  :lmtdStartDate and :lmtdEndDate then foi.quantity else 0 end))"
27592 tejbeer 48
				+ " 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"
49
				+ " join com.spice.profitmandi.dao.entity.user.User u on u.id = fs.id join Address a on a.id = u.addressId"
50
				+ " where fo.cancelledTimestamp is null and fs.active = true"
51
				+ " and foi.createTimestamp >= :lmtdStartDate and foi.brand = :brand and i.categoryId = :categoryId"
52
				+ " group by col_0_0_"),
27556 tejbeer 53
 
27594 tejbeer 54
		@NamedQuery(name = "FofoStore.selectWarehouseBrandItemSale", query = "select new com.spice.profitmandi.dao.model.WarehouseBrandWiseItemSaleModel(fs.warehouseId, i.brand, i.modelName, i.modelNumber,i.color,"
27574 tejbeer 55
				+ "sum(case when concat(year(foi.createTimestamp), month(foi.createTimestamp))= :lms then CAST(foi.quantity*foi.mop  AS int) else 0 end),"
56
				+ "sum(case when concat(year(foi.createTimestamp), month(foi.createTimestamp))= :lms then foi.quantity  else 0 end),"
57
				+ "sum(case when concat(year(foi.createTimestamp), month(foi.createTimestamp))= :mtd  then CAST(foi.quantity*foi.mop  AS int) else 0 end),"
58
				+ "sum(case when concat(year(foi.createTimestamp), month(foi.createTimestamp))= :mtd  then foi.quantity else 0 end), "
59
				+ "sum(case when foi.createTimestamp between  :lmtdStartDate and :lmtdEndDate  then CAST(foi.quantity*foi.mop  AS int) else 0 end), "
60
				+ "sum(case when foi.createTimestamp between  :lmtdStartDate and :lmtdEndDate then foi.quantity else 0 end))"
27594 tejbeer 61
				+ " 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"
62
				+ " and  foi.createTimestamp >= :lmtdStartDate and fs.warehouseId in :warehouseId and i.brand = :brand and i.categoryId = :categoryId group by i.id"),
63
 
64
		@NamedQuery(name = "FofoStore.selectGroupByBrandAccesoriesWarehousePartnerSale", query = "select new com.spice.profitmandi.dao.model.BrandWisePartnerSaleModel(foi.brand, "
65
				+ "sum(case when concat(year(foi.createTimestamp), month(foi.createTimestamp))= :lms then CAST(foi.quantity*foi.mop  AS int) else 0 end),"
66
				+ "sum(case when concat(year(foi.createTimestamp), month(foi.createTimestamp))= :lms then foi.quantity  else 0 end),"
67
				+ "sum(case when concat(year(foi.createTimestamp), month(foi.createTimestamp))= :mtd  then CAST(foi.quantity*foi.mop  AS int) else 0 end),"
68
				+ "sum(case when concat(year(foi.createTimestamp), month(foi.createTimestamp))= :mtd  then foi.quantity else 0 end), "
69
				+ "sum(case when foi.createTimestamp between  :lmtdStartDate and :lmtdEndDate  then CAST(foi.quantity*foi.mop  AS int) else 0 end), "
70
				+ "sum(case when foi.createTimestamp between  :lmtdStartDate and :lmtdEndDate then foi.quantity else 0 end))"
27592 tejbeer 71
				+ " 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 "
27594 tejbeer 72
				+ "and foi.createTimestamp >= :lmtdStartDate and i.categoryId != :categoryId" + " group by foi.brand"),
27556 tejbeer 73
 
27594 tejbeer 74
		@NamedQuery(name = "FofoStore.selectGroupByWarehouseAccesoriesBrandWisePartnerSale", query = "select new com.spice.profitmandi.dao.model.WarehouseWiseBrandSaleModel(fs.warehouseId,"
75
				+ "sum(case when concat(year(foi.createTimestamp), month(foi.createTimestamp))= :lms then CAST(foi.quantity*foi.mop  AS int) else 0 end),"
76
				+ "sum(case when concat(year(foi.createTimestamp), month(foi.createTimestamp))= :lms then foi.quantity  else 0 end),"
77
				+ "sum(case when concat(year(foi.createTimestamp), month(foi.createTimestamp))= :mtd  then CAST(foi.quantity*foi.mop  AS int) else 0 end),"
78
				+ "sum(case when concat(year(foi.createTimestamp), month(foi.createTimestamp))= :mtd  then foi.quantity else 0 end), "
79
				+ "sum(case when foi.createTimestamp between  :lmtdStartDate and :lmtdEndDate  then CAST(foi.quantity*foi.mop  AS int) else 0 end), "
80
				+ "sum(case when foi.createTimestamp between  :lmtdStartDate and :lmtdEndDate then foi.quantity else 0 end))"
81
				+ " 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"
82
				+ " and foi.createTimestamp >= :lmtdStartDate and foi.brand = :brand and i.categoryId != :categoryId"
83
				+ " group by fs.warehouseId"),
27592 tejbeer 84
 
27594 tejbeer 85
		@NamedQuery(name = "FofoStore.selectWarehouseAccesoriesBrandItemSale", query = "select new com.spice.profitmandi.dao.model.WarehouseBrandWiseItemSaleModel(fs.warehouseId, i.brand, i.modelName, i.modelNumber,i.color,"
27591 tejbeer 86
				+ "sum(case when concat(year(foi.createTimestamp), month(foi.createTimestamp))= :lms then CAST(foi.quantity*foi.mop  AS int) else 0 end),"
87
				+ "sum(case when concat(year(foi.createTimestamp), month(foi.createTimestamp))= :lms then foi.quantity  else 0 end),"
88
				+ "sum(case when concat(year(foi.createTimestamp), month(foi.createTimestamp))= :mtd  then CAST(foi.quantity*foi.mop  AS int) else 0 end),"
89
				+ "sum(case when concat(year(foi.createTimestamp), month(foi.createTimestamp))= :mtd  then foi.quantity else 0 end), "
90
				+ "sum(case when foi.createTimestamp between  :lmtdStartDate and :lmtdEndDate  then CAST(foi.quantity*foi.mop  AS int) else 0 end), "
91
				+ "sum(case when foi.createTimestamp between  :lmtdStartDate and :lmtdEndDate then foi.quantity else 0 end))"
27556 tejbeer 92
				+ " 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"
27594 tejbeer 93
				+ " and  foi.createTimestamp >= :lmtdStartDate and fs.warehouseId in :warehouseId and i.brand = :brand and i.categoryId != :categoryId group by i.id"),
27556 tejbeer 94
 
95
})
96
public class FofoStore implements Serializable {
97
 
22418 ashik.ali 98
	private static final long serialVersionUID = 1L;
27556 tejbeer 99
 
22418 ashik.ali 100
	public FofoStore() {
101
	}
27556 tejbeer 102
 
22418 ashik.ali 103
	@Id
27556 tejbeer 104
	@Column(name = "id", unique = true, updatable = false)
22418 ashik.ali 105
	private int id;
27556 tejbeer 106
 
107
	@Column(name = "code", unique = true)
22418 ashik.ali 108
	private String code;
27556 tejbeer 109
 
23847 ashik.ali 110
	@Column(name = "latitude")
111
	private String latitude;
27556 tejbeer 112
 
23847 ashik.ali 113
	@Column(name = "longitude")
114
	private String longitude;
27556 tejbeer 115
 
116
	@Column(name = "counter_size")
23786 amit.gupta 117
	@Enumerated(EnumType.STRING)
118
	private CounterSize counterSize = CounterSize.TEN_LAC;
27556 tejbeer 119
 
120
	@Column(name = "warehouse_id")
25069 amit.gupta 121
	private int warehouseId;
27556 tejbeer 122
 
25069 amit.gupta 123
	public int getWarehouseId() {
124
		return warehouseId;
125
	}
27556 tejbeer 126
 
25069 amit.gupta 127
	public void setWarehouseId(int warehouseId) {
128
		this.warehouseId = warehouseId;
129
	}
130
 
27556 tejbeer 131
	@Column(name = "minimum_investment")
23884 amit.gupta 132
	private float minimumInvestment;
27556 tejbeer 133
 
134
	@Column(name = "grace_date")
24349 amit.gupta 135
	private LocalDate graceDate;
27556 tejbeer 136
 
137
	@Column(name = "investment_ok")
25276 amit.gupta 138
	private boolean investmentOk;
27556 tejbeer 139
 
25276 amit.gupta 140
	public boolean isInvestmentOk() {
141
		return investmentOk;
142
	}
27556 tejbeer 143
 
25276 amit.gupta 144
	public void setInvestmentOk(boolean investmentOk) {
145
		this.investmentOk = investmentOk;
146
	}
147
 
27556 tejbeer 148
	@Column(name = "grace_count")
24349 amit.gupta 149
	private int graceCount;
24843 govind 150
 
151
	@Column
27556 tejbeer 152
	private boolean active = true;
25276 amit.gupta 153
 
24349 amit.gupta 154
	public int getGraceCount() {
155
		return graceCount;
156
	}
27556 tejbeer 157
 
24843 govind 158
	public boolean isActive() {
159
		return active;
160
	}
27556 tejbeer 161
 
24843 govind 162
	public void setActive(boolean active) {
163
		this.active = active;
164
	}
27556 tejbeer 165
 
24349 amit.gupta 166
	public void setGraceCount(int graceCount) {
167
		this.graceCount = graceCount;
168
	}
27556 tejbeer 169
 
24349 amit.gupta 170
	public LocalDate getGraceDate() {
171
		return graceDate;
172
	}
27556 tejbeer 173
 
24349 amit.gupta 174
	public void setGraceDate(LocalDate graceDate) {
175
		this.graceDate = graceDate;
176
	}
27556 tejbeer 177
 
23884 amit.gupta 178
	public float getMinimumInvestment() {
179
		return minimumInvestment;
180
	}
27556 tejbeer 181
 
23884 amit.gupta 182
	public void setMinimumInvestment(float minimumInvestment) {
183
		this.minimumInvestment = minimumInvestment;
184
	}
185
 
23786 amit.gupta 186
	@Transient
187
	private Address userAddress;
27556 tejbeer 188
 
189
	/*
190
	 * public int getCreditCycle() { return creditCycle; } public void
191
	 * setCreditCycle(int creditCycle) { this.creditCycle = creditCycle; }
192
	 */
23786 amit.gupta 193
	public CounterSize getCounterSize() {
23716 amit.gupta 194
		return counterSize;
195
	}
27556 tejbeer 196
 
23786 amit.gupta 197
	public void setCounterSize(CounterSize counterSize) {
23716 amit.gupta 198
		this.counterSize = counterSize;
199
	}
27556 tejbeer 200
 
22418 ashik.ali 201
	public int getId() {
202
		return id;
203
	}
27556 tejbeer 204
 
22418 ashik.ali 205
	public void setId(int id) {
206
		this.id = id;
207
	}
27556 tejbeer 208
 
209
	public String getCode() {
22418 ashik.ali 210
		return code;
211
	}
27556 tejbeer 212
 
213
	public void setCode(String code) {
22418 ashik.ali 214
		this.code = code;
215
	}
27556 tejbeer 216
 
217
	public String getLatitude() {
23847 ashik.ali 218
		return latitude;
219
	}
27556 tejbeer 220
 
221
	public void setLatitude(String latitude) {
23847 ashik.ali 222
		this.latitude = latitude;
223
	}
27556 tejbeer 224
 
225
	public String getLongitude() {
23847 ashik.ali 226
		return longitude;
227
	}
27556 tejbeer 228
 
229
	public void setLongitude(String longitude) {
23847 ashik.ali 230
		this.longitude = longitude;
231
	}
27556 tejbeer 232
 
23786 amit.gupta 233
	public Address getUserAddress() {
234
		return userAddress;
235
	}
27556 tejbeer 236
 
23786 amit.gupta 237
	public void setUserAddress(Address userAddress) {
238
		this.userAddress = userAddress;
239
	}
27556 tejbeer 240
 
22418 ashik.ali 241
	@Override
242
	public int hashCode() {
243
		final int prime = 31;
244
		int result = 1;
25276 amit.gupta 245
		result = prime * result + (active ? 1231 : 1237);
24349 amit.gupta 246
		result = prime * result + ((code == null) ? 0 : code.hashCode());
247
		result = prime * result + ((counterSize == null) ? 0 : counterSize.hashCode());
248
		result = prime * result + graceCount;
249
		result = prime * result + ((graceDate == null) ? 0 : graceDate.hashCode());
22418 ashik.ali 250
		result = prime * result + id;
25276 amit.gupta 251
		result = prime * result + (investmentOk ? 1231 : 1237);
24349 amit.gupta 252
		result = prime * result + ((latitude == null) ? 0 : latitude.hashCode());
253
		result = prime * result + ((longitude == null) ? 0 : longitude.hashCode());
254
		result = prime * result + Float.floatToIntBits(minimumInvestment);
255
		result = prime * result + ((userAddress == null) ? 0 : userAddress.hashCode());
25276 amit.gupta 256
		result = prime * result + warehouseId;
22418 ashik.ali 257
		return result;
258
	}
27556 tejbeer 259
 
22418 ashik.ali 260
	@Override
261
	public boolean equals(Object obj) {
262
		if (this == obj)
263
			return true;
264
		if (obj == null)
265
			return false;
266
		if (getClass() != obj.getClass())
267
			return false;
268
		FofoStore other = (FofoStore) obj;
25276 amit.gupta 269
		if (active != other.active)
270
			return false;
24349 amit.gupta 271
		if (code == null) {
272
			if (other.code != null)
273
				return false;
274
		} else if (!code.equals(other.code))
275
			return false;
276
		if (counterSize != other.counterSize)
277
			return false;
278
		if (graceCount != other.graceCount)
279
			return false;
280
		if (graceDate == null) {
281
			if (other.graceDate != null)
282
				return false;
283
		} else if (!graceDate.equals(other.graceDate))
284
			return false;
22418 ashik.ali 285
		if (id != other.id)
286
			return false;
25276 amit.gupta 287
		if (investmentOk != other.investmentOk)
288
			return false;
24349 amit.gupta 289
		if (latitude == null) {
290
			if (other.latitude != null)
291
				return false;
292
		} else if (!latitude.equals(other.latitude))
293
			return false;
294
		if (longitude == null) {
295
			if (other.longitude != null)
296
				return false;
297
		} else if (!longitude.equals(other.longitude))
298
			return false;
299
		if (Float.floatToIntBits(minimumInvestment) != Float.floatToIntBits(other.minimumInvestment))
300
			return false;
301
		if (userAddress == null) {
302
			if (other.userAddress != null)
303
				return false;
304
		} else if (!userAddress.equals(other.userAddress))
305
			return false;
25276 amit.gupta 306
		if (warehouseId != other.warehouseId)
307
			return false;
22418 ashik.ali 308
		return true;
309
	}
27556 tejbeer 310
 
22418 ashik.ali 311
	@Override
312
	public String toString() {
23884 amit.gupta 313
		return "FofoStore [id=" + id + ", code=" + code + ", latitude=" + latitude + ", longitude=" + longitude
25069 amit.gupta 314
				+ ", counterSize=" + counterSize + ", warehouseId=" + warehouseId + ", minimumInvestment="
25276 amit.gupta 315
				+ minimumInvestment + ", graceDate=" + graceDate + ", investmentOk=" + investmentOk + ", graceCount="
316
				+ graceCount + ", active=" + active + ", userAddress=" + userAddress + "]";
22418 ashik.ali 317
	}
27556 tejbeer 318
 
22418 ashik.ali 319
}