| 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 |
|
| 29475 |
amit.gupta |
27 |
@NamedQuery(name = "ActivatedImei.selectActivatedModelGroupByWarehouse", query = "select new com.spice.profitmandi.dao.model.WarehouseWiseActivatedModel(o.warehouseId, "
|
| 28825 |
tejbeer |
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"
|
| 29474 |
amit.gupta |
36 |
+ " group by o.warehouseId"),
|
| 28825 |
tejbeer |
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 |
|
| 29452 |
manish |
55 |
@NamedQuery(name = "ActivatedImei.selectVivoImeiAndActivationTimeStamp", query = "select new com.spice.profitmandi.dao.model.VivoImeiAndActivationTimeStampModel(ii.serialNumber, ai.activationTimestamp) "
|
|
|
56 |
+ " from InventoryItem ii left join ActivatedImei ai on ii.serialNumber = ai.serialNumber join Item i on i.id = ii.itemId "
|
|
|
57 |
+ " where ii.lastScanType in('PURCHASE','SALE','SALE_RET','PURCHASE_RET') and i.brand = 'Vivo' and ai.activationTimestamp is null"),
|
|
|
58 |
|
| 28825 |
tejbeer |
59 |
})
|
| 26299 |
amit.gupta |
60 |
public class ActivatedImei {
|
| 26309 |
amit.gupta |
61 |
@Id
|
|
|
62 |
@Column(name = "serial_number", unique = true)
|
|
|
63 |
private String serialNumber;
|
| 28825 |
tejbeer |
64 |
|
| 26309 |
amit.gupta |
65 |
@Column(name = "activation_timestamp")
|
|
|
66 |
private LocalDateTime activationTimestamp;
|
| 26299 |
amit.gupta |
67 |
|
| 26309 |
amit.gupta |
68 |
@Column(name = "create_timestamp")
|
|
|
69 |
private LocalDateTime createTimestamp;
|
| 28825 |
tejbeer |
70 |
|
| 26299 |
amit.gupta |
71 |
public ActivatedImei() {
|
|
|
72 |
super();
|
|
|
73 |
}
|
| 28825 |
tejbeer |
74 |
|
| 26299 |
amit.gupta |
75 |
public ActivatedImei(String serialNumber, LocalDateTime activationTimestamp) {
|
|
|
76 |
this.activationTimestamp = activationTimestamp;
|
|
|
77 |
this.serialNumber = serialNumber;
|
|
|
78 |
}
|
|
|
79 |
|
|
|
80 |
@Override
|
|
|
81 |
public String toString() {
|
| 26309 |
amit.gupta |
82 |
return "ActivatedImei [serialNumber=" + serialNumber + ", activationTimestamp=" + activationTimestamp
|
|
|
83 |
+ ", createTimestamp=" + createTimestamp + "]";
|
| 26299 |
amit.gupta |
84 |
}
|
|
|
85 |
|
|
|
86 |
public String getSerialNumber() {
|
|
|
87 |
return serialNumber;
|
|
|
88 |
}
|
|
|
89 |
|
|
|
90 |
public void setSerialNumber(String serialNumber) {
|
|
|
91 |
this.serialNumber = serialNumber;
|
|
|
92 |
}
|
|
|
93 |
|
|
|
94 |
public LocalDateTime getActivationTimestamp() {
|
|
|
95 |
return activationTimestamp;
|
|
|
96 |
}
|
|
|
97 |
|
|
|
98 |
public void setActivationTimestamp(LocalDateTime activationTimestamp) {
|
|
|
99 |
this.activationTimestamp = activationTimestamp;
|
|
|
100 |
}
|
|
|
101 |
|
| 26309 |
amit.gupta |
102 |
public LocalDateTime getCreateTimestamp() {
|
|
|
103 |
return createTimestamp;
|
|
|
104 |
}
|
|
|
105 |
|
|
|
106 |
public void setCreateTimestamp(LocalDateTime createTimestamp) {
|
|
|
107 |
this.createTimestamp = createTimestamp;
|
|
|
108 |
}
|
|
|
109 |
|
| 26299 |
amit.gupta |
110 |
@Override
|
|
|
111 |
public int hashCode() {
|
|
|
112 |
final int prime = 31;
|
|
|
113 |
int result = 1;
|
| 26309 |
amit.gupta |
114 |
result = prime * result + ((activationTimestamp == null) ? 0 : activationTimestamp.hashCode());
|
|
|
115 |
result = prime * result + ((createTimestamp == null) ? 0 : createTimestamp.hashCode());
|
| 26299 |
amit.gupta |
116 |
result = prime * result + ((serialNumber == null) ? 0 : serialNumber.hashCode());
|
|
|
117 |
return result;
|
|
|
118 |
}
|
|
|
119 |
|
|
|
120 |
@Override
|
|
|
121 |
public boolean equals(Object obj) {
|
|
|
122 |
if (this == obj)
|
|
|
123 |
return true;
|
|
|
124 |
if (obj == null)
|
|
|
125 |
return false;
|
|
|
126 |
if (getClass() != obj.getClass())
|
|
|
127 |
return false;
|
|
|
128 |
ActivatedImei other = (ActivatedImei) obj;
|
| 26309 |
amit.gupta |
129 |
if (activationTimestamp == null) {
|
|
|
130 |
if (other.activationTimestamp != null)
|
|
|
131 |
return false;
|
|
|
132 |
} else if (!activationTimestamp.equals(other.activationTimestamp))
|
|
|
133 |
return false;
|
|
|
134 |
if (createTimestamp == null) {
|
|
|
135 |
if (other.createTimestamp != null)
|
|
|
136 |
return false;
|
|
|
137 |
} else if (!createTimestamp.equals(other.createTimestamp))
|
|
|
138 |
return false;
|
| 26299 |
amit.gupta |
139 |
if (serialNumber == null) {
|
|
|
140 |
if (other.serialNumber != null)
|
|
|
141 |
return false;
|
|
|
142 |
} else if (!serialNumber.equals(other.serialNumber))
|
|
|
143 |
return false;
|
|
|
144 |
return true;
|
|
|
145 |
}
|
|
|
146 |
|
|
|
147 |
}
|