Subversion Repositories SmartDukaan

Rev

Rev 26309 | Rev 29452 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
26299 amit.gupta 1
package com.spice.profitmandi.dao.entity.fofo;
2
 
3
import java.time.LocalDateTime;
4
 
5
import javax.persistence.Column;
6
import javax.persistence.Entity;
7
import javax.persistence.Id;
28825 tejbeer 8
import javax.persistence.NamedQueries;
9
import javax.persistence.NamedQuery;
26299 amit.gupta 10
import javax.persistence.Table;
11
 
12
@Entity
13
@Table(name = "fofo.activated_imei", schema = "fofo")
28825 tejbeer 14
 
15
@NamedQueries({
16
 
17
		@NamedQuery(name = "ActivatedImei.selectActivatedModelGroupByBrand", query = "select new com.spice.profitmandi.dao.model.BrandWiseActivatedModel(li.brand, "
18
				+ "sum(case when concat(year(ai.activationTimestamp), month(ai.activationTimestamp))= :lms then 1 else 0 end),"
19
				+ "sum(case when concat(year(ai.activationTimestamp), month(ai.activationTimestamp))= :lms  then CAST(li.unitPrice  AS int) else 0 end),"
20
				+ "sum(case when concat(year(ai.activationTimestamp), month(ai.activationTimestamp))= :mtd then 1 else 0 end),"
21
				+ "sum(case when concat(year(ai.activationTimestamp), month(ai.activationTimestamp))= :mtd   then CAST(li.unitPrice AS int) else 0 end), "
22
				+ "sum(case when ai.activationTimestamp between  :lmtdStartDate and :lmtdEndDate then 1 else 0 end), "
23
				+ "sum(case when ai.activationTimestamp between  :lmtdStartDate and :lmtdEndDate then  CAST(li.unitPrice  AS int) else 0 end))"
24
				+ " from ActivatedImei ai join LineItemImeiView lim on ai.serialNumber = lim.serialNumber join LineItem li on li.id = lim.lineItemId join Order o on o.id = li.orderId "
25
				+ "	join FofoStore fs on fs.id = o.retailerId where (fs.fofoType = 'FRANCHISE' or fs.fofoType = 'THIRD_PARTY') and fs.id in :fofoIds group by li.brand"),
26
 
27
		@NamedQuery(name = "ActivatedImei.selectActivatedModelGroupByWarehouse", query = "select new com.spice.profitmandi.dao.model.WarehouseWiseActivatedModel(fs.warehouseId, "
28
				+ "sum(case when concat(year(ai.activationTimestamp), month(ai.activationTimestamp))= :lms then 1 else 0 end),"
29
				+ "sum(case when concat(year(ai.activationTimestamp), month(ai.activationTimestamp))= :lms  then CAST(li.unitPrice  AS int) else 0 end),"
30
				+ "sum(case when concat(year(ai.activationTimestamp), month(ai.activationTimestamp))= :mtd then 1 else 0 end),"
31
				+ "sum(case when concat(year(ai.activationTimestamp), month(ai.activationTimestamp))= :mtd   then CAST(li.unitPrice AS int) else 0 end), "
32
				+ "sum(case when ai.activationTimestamp between  :lmtdStartDate and :lmtdEndDate then 1 else 0 end), "
33
				+ "sum(case when ai.activationTimestamp between  :lmtdStartDate and :lmtdEndDate then  CAST(li.unitPrice  AS int) else 0 end))"
34
				+ " from ActivatedImei ai join LineItemImeiView lim on ai.serialNumber = lim.serialNumber join LineItem li on li.id = lim.lineItemId join Order o on o.id = li.orderId "
35
				+ " join FofoStore fs on fs.id = o.retailerId where (fs.fofoType = 'FRANCHISE' or fs.fofoType = 'THIRD_PARTY') and li.brand = :brand and fs.id in :fofoIds"
36
				+ " group by fs.warehouseId"),
37
 
38
		@NamedQuery(name = "ActivatedImei.selectWarehouseBrandActivatedItem", query = "select new com.spice.profitmandi.dao.model.WarehouseBrandWiseItemActivatedModel(fs.warehouseId, li.itemId, li.brand,li.modelName,"
39
				+ " li.modelNumber, li.color,"
40
				+ "sum(case when concat(year(ai.activationTimestamp), month(ai.activationTimestamp))= :lms then 1 else 0 end),"
41
				+ "sum(case when concat(year(ai.activationTimestamp), month(ai.activationTimestamp))= :lms  then CAST(li.unitPrice  AS int) else 0 end),"
42
				+ "sum(case when concat(year(ai.activationTimestamp), month(ai.activationTimestamp))= :mtd then 1 else 0 end),"
43
				+ "sum(case when concat(year(ai.activationTimestamp), month(ai.activationTimestamp))= :mtd   then CAST(li.unitPrice AS int) else 0 end), "
44
				+ "sum(case when ai.activationTimestamp between  :lmtdStartDate and :lmtdEndDate then 1 else 0 end), "
45
				+ "sum(case when ai.activationTimestamp between  :lmtdStartDate and :lmtdEndDate then  CAST(li.unitPrice  AS int) else 0 end))"
46
				+ " from ActivatedImei ai join LineItemImeiView lim on ai.serialNumber = lim.serialNumber join LineItem li on li.id = lim.lineItemId join Order o on o.id = li.orderId "
47
				+ " join FofoStore fs on fs.id = o.retailerId where (fs.fofoType = 'FRANCHISE' or fs.fofoType = 'THIRD_PARTY') and fs.warehouseId in :warehouseId and li.brand = :brand and fs.id in :fofoIds "
48
				+ " group by li.itemId"),
49
 
50
		@NamedQuery(name = "ActivatedImei.selectActivatedUpdationDate", query = "select new com.spice.profitmandi.dao.model.ActivationImeiUpdationModel(fs.warehouseId,li.brand, "
51
				+ " Max(ai.createTimestamp))"
52
				+ " from ActivatedImei ai join LineItemImeiView lim on ai.serialNumber = lim.serialNumber join LineItem li on li.id = lim.lineItemId join Order o on o.id = li.orderId "
53
				+ "	join FofoStore fs on fs.id = o.retailerId group by li.brand,fs.warehouseId"),
54
 
55
})
26299 amit.gupta 56
public class ActivatedImei {
26309 amit.gupta 57
	@Id
58
	@Column(name = "serial_number", unique = true)
59
	private String serialNumber;
28825 tejbeer 60
 
26309 amit.gupta 61
	@Column(name = "activation_timestamp")
62
	private LocalDateTime activationTimestamp;
26299 amit.gupta 63
 
26309 amit.gupta 64
	@Column(name = "create_timestamp")
65
	private LocalDateTime createTimestamp;
28825 tejbeer 66
 
26299 amit.gupta 67
	public ActivatedImei() {
68
		super();
69
	}
28825 tejbeer 70
 
26299 amit.gupta 71
	public ActivatedImei(String serialNumber, LocalDateTime activationTimestamp) {
72
		this.activationTimestamp = activationTimestamp;
73
		this.serialNumber = serialNumber;
74
	}
75
 
76
	@Override
77
	public String toString() {
26309 amit.gupta 78
		return "ActivatedImei [serialNumber=" + serialNumber + ", activationTimestamp=" + activationTimestamp
79
				+ ", createTimestamp=" + createTimestamp + "]";
26299 amit.gupta 80
	}
81
 
82
	public String getSerialNumber() {
83
		return serialNumber;
84
	}
85
 
86
	public void setSerialNumber(String serialNumber) {
87
		this.serialNumber = serialNumber;
88
	}
89
 
90
	public LocalDateTime getActivationTimestamp() {
91
		return activationTimestamp;
92
	}
93
 
94
	public void setActivationTimestamp(LocalDateTime activationTimestamp) {
95
		this.activationTimestamp = activationTimestamp;
96
	}
97
 
26309 amit.gupta 98
	public LocalDateTime getCreateTimestamp() {
99
		return createTimestamp;
100
	}
101
 
102
	public void setCreateTimestamp(LocalDateTime createTimestamp) {
103
		this.createTimestamp = createTimestamp;
104
	}
105
 
26299 amit.gupta 106
	@Override
107
	public int hashCode() {
108
		final int prime = 31;
109
		int result = 1;
26309 amit.gupta 110
		result = prime * result + ((activationTimestamp == null) ? 0 : activationTimestamp.hashCode());
111
		result = prime * result + ((createTimestamp == null) ? 0 : createTimestamp.hashCode());
26299 amit.gupta 112
		result = prime * result + ((serialNumber == null) ? 0 : serialNumber.hashCode());
113
		return result;
114
	}
115
 
116
	@Override
117
	public boolean equals(Object obj) {
118
		if (this == obj)
119
			return true;
120
		if (obj == null)
121
			return false;
122
		if (getClass() != obj.getClass())
123
			return false;
124
		ActivatedImei other = (ActivatedImei) obj;
26309 amit.gupta 125
		if (activationTimestamp == null) {
126
			if (other.activationTimestamp != null)
127
				return false;
128
		} else if (!activationTimestamp.equals(other.activationTimestamp))
129
			return false;
130
		if (createTimestamp == null) {
131
			if (other.createTimestamp != null)
132
				return false;
133
		} else if (!createTimestamp.equals(other.createTimestamp))
134
			return false;
26299 amit.gupta 135
		if (serialNumber == null) {
136
			if (other.serialNumber != null)
137
				return false;
138
		} else if (!serialNumber.equals(other.serialNumber))
139
			return false;
140
		return true;
141
	}
142
 
143
}