Subversion Repositories SmartDukaan

Rev

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