Subversion Repositories SmartDukaan

Rev

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