Subversion Repositories SmartDukaan

Rev

Rev 27599 | Rev 27676 | 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
 
27670 tejbeer 54
		@NamedQuery(name = "FofoStore.selectWarehouseBrandItemSale", query = "select new com.spice.profitmandi.dao.model.WarehouseBrandWiseItemSaleModel(fs.warehouseId,i.id, 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
 
27670 tejbeer 85
		@NamedQuery(name = "FofoStore.selectWarehouseAccesoriesBrandItemSale", query = "select new com.spice.profitmandi.dao.model.WarehouseBrandWiseItemSaleModel(fs.warehouseId,i.id, 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
 
27599 tejbeer 95
		@NamedQuery(name = "FofoStore.selectPartnerPendingIndentItem", query = "select new com.spice.profitmandi.dao.model.PartnerPendingIndentItemModel(o.retailerName,"
96
				+ " li.quantity, li.totalPrice)"
97
				+ " from FofoStore fs join Order o on fs.id = o.retailerId join  LineItem li on li.orderId = o.id "
98
				+ " where li.itemId = :itemId and fs.warehouseId = :warehouseId and o.status = 3"),
99
 
27670 tejbeer 100
		@NamedQuery(name = "FofoStore.selectUnbilledActivateStockGroupByBrand", query = "select new com.spice.profitmandi.dao.model.BrandWiseUnbilledActivateStockModel(i.brand,"
101
				+ "  sum(case when concat(year(ai.activationTimestamp), month(ai.activationTimestamp)) = :almtd then CAST(tl.sellingPrice  AS int) else 0 end))"
102
				+ " from FofoStore fs join InventoryItem ii on fs.id = ii.fofoId join ActivatedImei ai on ai.serialNumber = ii.serialNumber join Item i on i.id = ii.itemId join TagListing tl on tl.itemId = i.id"
103
				+ " where fs.active = true and ii.goodQuantity >= 1 group by i.brand"),
104
 
105
		@NamedQuery(name = "FofoStore.selectUnbilledActivateStockGroupByWarehouse", query = "select new com.spice.profitmandi.dao.model.WarehouseWiseBrandUnbilledActivatedModel(fs.warehouseId,"
106
				+ "  sum(case when concat(year(ai.activationTimestamp), month(ai.activationTimestamp)) = :almtd then CAST(tl.sellingPrice  AS int) else 0 end))"
107
				+ " from FofoStore fs join InventoryItem ii on fs.id = ii.fofoId join ActivatedImei ai on ai.serialNumber = ii.serialNumber join Item i on i.id = ii.itemId join TagListing tl on tl.itemId = i.id"
108
				+ " where fs.active = true and ii.goodQuantity >= 1 and i.brand = :brand  group by fs.warehouseId"),
109
 
110
		@NamedQuery(name = "FofoStore.selectWarehouseBrandItemUnbilledActivateStock", query = "select new com.spice.profitmandi.dao.model.WarehouseBrandItemUnbilledActivatedModel(fs.warehouseId,i.id, i.brand, i.modelName, i.modelNumber,i.color,"
111
				+ "  sum(case when concat(year(ai.activationTimestamp), month(ai.activationTimestamp)) = :almtd then CAST(tl.sellingPrice  AS int) else 0 end))"
112
				+ " from FofoStore fs join InventoryItem ii on fs.id = ii.fofoId join ActivatedImei ai on ai.serialNumber = ii.serialNumber join Item i on i.id = ii.itemId join TagListing tl on tl.itemId = i.id"
113
				+ " where fs.active = true and ii.goodQuantity >= 1 and i.brand = :brand and fs.warehouseId in :warehouseId group by i.id"),
114
 
27556 tejbeer 115
})
27599 tejbeer 116
 
27556 tejbeer 117
public class FofoStore implements Serializable {
118
 
22418 ashik.ali 119
	private static final long serialVersionUID = 1L;
27556 tejbeer 120
 
22418 ashik.ali 121
	public FofoStore() {
122
	}
27556 tejbeer 123
 
22418 ashik.ali 124
	@Id
27556 tejbeer 125
	@Column(name = "id", unique = true, updatable = false)
22418 ashik.ali 126
	private int id;
27556 tejbeer 127
 
128
	@Column(name = "code", unique = true)
22418 ashik.ali 129
	private String code;
27556 tejbeer 130
 
23847 ashik.ali 131
	@Column(name = "latitude")
132
	private String latitude;
27556 tejbeer 133
 
23847 ashik.ali 134
	@Column(name = "longitude")
135
	private String longitude;
27556 tejbeer 136
 
137
	@Column(name = "counter_size")
23786 amit.gupta 138
	@Enumerated(EnumType.STRING)
139
	private CounterSize counterSize = CounterSize.TEN_LAC;
27556 tejbeer 140
 
141
	@Column(name = "warehouse_id")
25069 amit.gupta 142
	private int warehouseId;
27556 tejbeer 143
 
25069 amit.gupta 144
	public int getWarehouseId() {
145
		return warehouseId;
146
	}
27556 tejbeer 147
 
25069 amit.gupta 148
	public void setWarehouseId(int warehouseId) {
149
		this.warehouseId = warehouseId;
150
	}
151
 
27556 tejbeer 152
	@Column(name = "minimum_investment")
23884 amit.gupta 153
	private float minimumInvestment;
27556 tejbeer 154
 
155
	@Column(name = "grace_date")
24349 amit.gupta 156
	private LocalDate graceDate;
27556 tejbeer 157
 
158
	@Column(name = "investment_ok")
25276 amit.gupta 159
	private boolean investmentOk;
27556 tejbeer 160
 
25276 amit.gupta 161
	public boolean isInvestmentOk() {
162
		return investmentOk;
163
	}
27556 tejbeer 164
 
25276 amit.gupta 165
	public void setInvestmentOk(boolean investmentOk) {
166
		this.investmentOk = investmentOk;
167
	}
168
 
27556 tejbeer 169
	@Column(name = "grace_count")
24349 amit.gupta 170
	private int graceCount;
24843 govind 171
 
172
	@Column
27556 tejbeer 173
	private boolean active = true;
25276 amit.gupta 174
 
24349 amit.gupta 175
	public int getGraceCount() {
176
		return graceCount;
177
	}
27556 tejbeer 178
 
24843 govind 179
	public boolean isActive() {
180
		return active;
181
	}
27556 tejbeer 182
 
24843 govind 183
	public void setActive(boolean active) {
184
		this.active = active;
185
	}
27556 tejbeer 186
 
24349 amit.gupta 187
	public void setGraceCount(int graceCount) {
188
		this.graceCount = graceCount;
189
	}
27556 tejbeer 190
 
24349 amit.gupta 191
	public LocalDate getGraceDate() {
192
		return graceDate;
193
	}
27556 tejbeer 194
 
24349 amit.gupta 195
	public void setGraceDate(LocalDate graceDate) {
196
		this.graceDate = graceDate;
197
	}
27556 tejbeer 198
 
23884 amit.gupta 199
	public float getMinimumInvestment() {
200
		return minimumInvestment;
201
	}
27556 tejbeer 202
 
23884 amit.gupta 203
	public void setMinimumInvestment(float minimumInvestment) {
204
		this.minimumInvestment = minimumInvestment;
205
	}
206
 
23786 amit.gupta 207
	@Transient
208
	private Address userAddress;
27556 tejbeer 209
 
210
	/*
211
	 * public int getCreditCycle() { return creditCycle; } public void
212
	 * setCreditCycle(int creditCycle) { this.creditCycle = creditCycle; }
213
	 */
23786 amit.gupta 214
	public CounterSize getCounterSize() {
23716 amit.gupta 215
		return counterSize;
216
	}
27556 tejbeer 217
 
23786 amit.gupta 218
	public void setCounterSize(CounterSize counterSize) {
23716 amit.gupta 219
		this.counterSize = counterSize;
220
	}
27556 tejbeer 221
 
22418 ashik.ali 222
	public int getId() {
223
		return id;
224
	}
27556 tejbeer 225
 
22418 ashik.ali 226
	public void setId(int id) {
227
		this.id = id;
228
	}
27556 tejbeer 229
 
230
	public String getCode() {
22418 ashik.ali 231
		return code;
232
	}
27556 tejbeer 233
 
234
	public void setCode(String code) {
22418 ashik.ali 235
		this.code = code;
236
	}
27556 tejbeer 237
 
238
	public String getLatitude() {
23847 ashik.ali 239
		return latitude;
240
	}
27556 tejbeer 241
 
242
	public void setLatitude(String latitude) {
23847 ashik.ali 243
		this.latitude = latitude;
244
	}
27556 tejbeer 245
 
246
	public String getLongitude() {
23847 ashik.ali 247
		return longitude;
248
	}
27556 tejbeer 249
 
250
	public void setLongitude(String longitude) {
23847 ashik.ali 251
		this.longitude = longitude;
252
	}
27556 tejbeer 253
 
23786 amit.gupta 254
	public Address getUserAddress() {
255
		return userAddress;
256
	}
27556 tejbeer 257
 
23786 amit.gupta 258
	public void setUserAddress(Address userAddress) {
259
		this.userAddress = userAddress;
260
	}
27556 tejbeer 261
 
22418 ashik.ali 262
	@Override
263
	public int hashCode() {
264
		final int prime = 31;
265
		int result = 1;
25276 amit.gupta 266
		result = prime * result + (active ? 1231 : 1237);
24349 amit.gupta 267
		result = prime * result + ((code == null) ? 0 : code.hashCode());
268
		result = prime * result + ((counterSize == null) ? 0 : counterSize.hashCode());
269
		result = prime * result + graceCount;
270
		result = prime * result + ((graceDate == null) ? 0 : graceDate.hashCode());
22418 ashik.ali 271
		result = prime * result + id;
25276 amit.gupta 272
		result = prime * result + (investmentOk ? 1231 : 1237);
24349 amit.gupta 273
		result = prime * result + ((latitude == null) ? 0 : latitude.hashCode());
274
		result = prime * result + ((longitude == null) ? 0 : longitude.hashCode());
275
		result = prime * result + Float.floatToIntBits(minimumInvestment);
276
		result = prime * result + ((userAddress == null) ? 0 : userAddress.hashCode());
25276 amit.gupta 277
		result = prime * result + warehouseId;
22418 ashik.ali 278
		return result;
279
	}
27556 tejbeer 280
 
22418 ashik.ali 281
	@Override
282
	public boolean equals(Object obj) {
283
		if (this == obj)
284
			return true;
285
		if (obj == null)
286
			return false;
287
		if (getClass() != obj.getClass())
288
			return false;
289
		FofoStore other = (FofoStore) obj;
25276 amit.gupta 290
		if (active != other.active)
291
			return false;
24349 amit.gupta 292
		if (code == null) {
293
			if (other.code != null)
294
				return false;
295
		} else if (!code.equals(other.code))
296
			return false;
297
		if (counterSize != other.counterSize)
298
			return false;
299
		if (graceCount != other.graceCount)
300
			return false;
301
		if (graceDate == null) {
302
			if (other.graceDate != null)
303
				return false;
304
		} else if (!graceDate.equals(other.graceDate))
305
			return false;
22418 ashik.ali 306
		if (id != other.id)
307
			return false;
25276 amit.gupta 308
		if (investmentOk != other.investmentOk)
309
			return false;
24349 amit.gupta 310
		if (latitude == null) {
311
			if (other.latitude != null)
312
				return false;
313
		} else if (!latitude.equals(other.latitude))
314
			return false;
315
		if (longitude == null) {
316
			if (other.longitude != null)
317
				return false;
318
		} else if (!longitude.equals(other.longitude))
319
			return false;
320
		if (Float.floatToIntBits(minimumInvestment) != Float.floatToIntBits(other.minimumInvestment))
321
			return false;
322
		if (userAddress == null) {
323
			if (other.userAddress != null)
324
				return false;
325
		} else if (!userAddress.equals(other.userAddress))
326
			return false;
25276 amit.gupta 327
		if (warehouseId != other.warehouseId)
328
			return false;
22418 ashik.ali 329
		return true;
330
	}
27556 tejbeer 331
 
22418 ashik.ali 332
	@Override
333
	public String toString() {
23884 amit.gupta 334
		return "FofoStore [id=" + id + ", code=" + code + ", latitude=" + latitude + ", longitude=" + longitude
25069 amit.gupta 335
				+ ", counterSize=" + counterSize + ", warehouseId=" + warehouseId + ", minimumInvestment="
25276 amit.gupta 336
				+ minimumInvestment + ", graceDate=" + graceDate + ", investmentOk=" + investmentOk + ", graceCount="
337
				+ graceCount + ", active=" + active + ", userAddress=" + userAddress + "]";
22418 ashik.ali 338
	}
27556 tejbeer 339
 
22418 ashik.ali 340
}