Subversion Repositories SmartDukaan

Rev

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