| Line 3... |
Line 3... |
| 3 |
import java.time.LocalDateTime;
|
3 |
import java.time.LocalDateTime;
|
| 4 |
|
4 |
|
| 5 |
import javax.persistence.Column;
|
5 |
import javax.persistence.Column;
|
| 6 |
import javax.persistence.Entity;
|
6 |
import javax.persistence.Entity;
|
| 7 |
import javax.persistence.Id;
|
7 |
import javax.persistence.Id;
|
| - |
|
8 |
import javax.persistence.NamedQueries;
|
| - |
|
9 |
import javax.persistence.NamedQuery;
|
| 8 |
import javax.persistence.Table;
|
10 |
import javax.persistence.Table;
|
| 9 |
|
11 |
|
| 10 |
@Entity
|
12 |
@Entity
|
| 11 |
@Table(name = "fofo.activated_imei", schema = "fofo")
|
13 |
@Table(name = "fofo.activated_imei", schema = "fofo")
|
| - |
|
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 |
})
|
| 12 |
public class ActivatedImei {
|
56 |
public class ActivatedImei {
|
| 13 |
@Id
|
57 |
@Id
|
| 14 |
@Column(name = "serial_number", unique = true)
|
58 |
@Column(name = "serial_number", unique = true)
|
| 15 |
private String serialNumber;
|
59 |
private String serialNumber;
|
| 16 |
|
60 |
|
| 17 |
@Column(name = "activation_timestamp")
|
61 |
@Column(name = "activation_timestamp")
|
| 18 |
private LocalDateTime activationTimestamp;
|
62 |
private LocalDateTime activationTimestamp;
|
| 19 |
|
63 |
|
| 20 |
@Column(name = "create_timestamp")
|
64 |
@Column(name = "create_timestamp")
|
| 21 |
private LocalDateTime createTimestamp;
|
65 |
private LocalDateTime createTimestamp;
|
| 22 |
|
66 |
|
| 23 |
public ActivatedImei() {
|
67 |
public ActivatedImei() {
|
| 24 |
super();
|
68 |
super();
|
| 25 |
}
|
69 |
}
|
| 26 |
|
70 |
|
| 27 |
public ActivatedImei(String serialNumber, LocalDateTime activationTimestamp) {
|
71 |
public ActivatedImei(String serialNumber, LocalDateTime activationTimestamp) {
|
| 28 |
this.activationTimestamp = activationTimestamp;
|
72 |
this.activationTimestamp = activationTimestamp;
|
| 29 |
this.serialNumber = serialNumber;
|
73 |
this.serialNumber = serialNumber;
|
| 30 |
}
|
74 |
}
|
| 31 |
|
75 |
|
| Line 48... |
Line 92... |
| 48 |
}
|
92 |
}
|
| 49 |
|
93 |
|
| 50 |
public void setActivationTimestamp(LocalDateTime activationTimestamp) {
|
94 |
public void setActivationTimestamp(LocalDateTime activationTimestamp) {
|
| 51 |
this.activationTimestamp = activationTimestamp;
|
95 |
this.activationTimestamp = activationTimestamp;
|
| 52 |
}
|
96 |
}
|
| 53 |
|
- |
|
| 54 |
|
- |
|
| 55 |
|
97 |
|
| 56 |
public LocalDateTime getCreateTimestamp() {
|
98 |
public LocalDateTime getCreateTimestamp() {
|
| 57 |
return createTimestamp;
|
99 |
return createTimestamp;
|
| 58 |
}
|
100 |
}
|
| 59 |
|
101 |
|
| Line 95... |
Line 137... |
| 95 |
return false;
|
137 |
return false;
|
| 96 |
} else if (!serialNumber.equals(other.serialNumber))
|
138 |
} else if (!serialNumber.equals(other.serialNumber))
|
| 97 |
return false;
|
139 |
return false;
|
| 98 |
return true;
|
140 |
return true;
|
| 99 |
}
|
141 |
}
|
| 100 |
|
- |
|
| 101 |
|
- |
|
| 102 |
|
142 |
|
| 103 |
}
|
143 |
}
|