Subversion Repositories SmartDukaan

Rev

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