Subversion Repositories SmartDukaan

Rev

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