Subversion Repositories SmartDukaan

Rev

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