| 26299 |
amit.gupta |
1 |
package com.spice.profitmandi.dao.entity.fofo;
|
|
|
2 |
|
| 30213 |
amit.gupta |
3 |
import javax.persistence.*;
|
| 26299 |
amit.gupta |
4 |
import java.time.LocalDateTime;
|
| 30896 |
amit.gupta |
5 |
import java.util.Objects;
|
| 26299 |
amit.gupta |
6 |
|
|
|
7 |
@Entity
|
|
|
8 |
@Table(name = "fofo.activated_imei", schema = "fofo")
|
| 28825 |
tejbeer |
9 |
|
|
|
10 |
@NamedQueries({
|
|
|
11 |
|
|
|
12 |
@NamedQuery(name = "ActivatedImei.selectActivatedModelGroupByBrand", query = "select new com.spice.profitmandi.dao.model.BrandWiseActivatedModel(li.brand, "
|
|
|
13 |
+ "sum(case when concat(year(ai.activationTimestamp), month(ai.activationTimestamp))= :lms then 1 else 0 end),"
|
|
|
14 |
+ "sum(case when concat(year(ai.activationTimestamp), month(ai.activationTimestamp))= :lms then CAST(li.unitPrice AS int) else 0 end),"
|
|
|
15 |
+ "sum(case when concat(year(ai.activationTimestamp), month(ai.activationTimestamp))= :mtd then 1 else 0 end),"
|
|
|
16 |
+ "sum(case when concat(year(ai.activationTimestamp), month(ai.activationTimestamp))= :mtd then CAST(li.unitPrice AS int) else 0 end), "
|
|
|
17 |
+ "sum(case when ai.activationTimestamp between :lmtdStartDate and :lmtdEndDate then 1 else 0 end), "
|
|
|
18 |
+ "sum(case when ai.activationTimestamp between :lmtdStartDate and :lmtdEndDate then CAST(li.unitPrice AS int) else 0 end))"
|
|
|
19 |
+ " 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 "
|
|
|
20 |
+ " 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"),
|
|
|
21 |
|
| 29475 |
amit.gupta |
22 |
@NamedQuery(name = "ActivatedImei.selectActivatedModelGroupByWarehouse", query = "select new com.spice.profitmandi.dao.model.WarehouseWiseActivatedModel(o.warehouseId, "
|
| 28825 |
tejbeer |
23 |
+ "sum(case when concat(year(ai.activationTimestamp), month(ai.activationTimestamp))= :lms then 1 else 0 end),"
|
|
|
24 |
+ "sum(case when concat(year(ai.activationTimestamp), month(ai.activationTimestamp))= :lms then CAST(li.unitPrice AS int) else 0 end),"
|
|
|
25 |
+ "sum(case when concat(year(ai.activationTimestamp), month(ai.activationTimestamp))= :mtd then 1 else 0 end),"
|
|
|
26 |
+ "sum(case when concat(year(ai.activationTimestamp), month(ai.activationTimestamp))= :mtd then CAST(li.unitPrice AS int) else 0 end), "
|
|
|
27 |
+ "sum(case when ai.activationTimestamp between :lmtdStartDate and :lmtdEndDate then 1 else 0 end), "
|
|
|
28 |
+ "sum(case when ai.activationTimestamp between :lmtdStartDate and :lmtdEndDate then CAST(li.unitPrice AS int) else 0 end))"
|
|
|
29 |
+ " 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 "
|
|
|
30 |
+ " 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 |
31 |
+ " group by o.warehouseId"),
|
| 28825 |
tejbeer |
32 |
|
|
|
33 |
@NamedQuery(name = "ActivatedImei.selectWarehouseBrandActivatedItem", query = "select new com.spice.profitmandi.dao.model.WarehouseBrandWiseItemActivatedModel(fs.warehouseId, li.itemId, li.brand,li.modelName,"
|
|
|
34 |
+ " li.modelNumber, li.color,"
|
|
|
35 |
+ "sum(case when concat(year(ai.activationTimestamp), month(ai.activationTimestamp))= :lms then 1 else 0 end),"
|
|
|
36 |
+ "sum(case when concat(year(ai.activationTimestamp), month(ai.activationTimestamp))= :lms then CAST(li.unitPrice AS int) else 0 end),"
|
|
|
37 |
+ "sum(case when concat(year(ai.activationTimestamp), month(ai.activationTimestamp))= :mtd then 1 else 0 end),"
|
|
|
38 |
+ "sum(case when concat(year(ai.activationTimestamp), month(ai.activationTimestamp))= :mtd then CAST(li.unitPrice AS int) else 0 end), "
|
|
|
39 |
+ "sum(case when ai.activationTimestamp between :lmtdStartDate and :lmtdEndDate then 1 else 0 end), "
|
|
|
40 |
+ "sum(case when ai.activationTimestamp between :lmtdStartDate and :lmtdEndDate then CAST(li.unitPrice AS int) else 0 end))"
|
|
|
41 |
+ " 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 "
|
|
|
42 |
+ " 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 "
|
|
|
43 |
+ " group by li.itemId"),
|
|
|
44 |
|
|
|
45 |
@NamedQuery(name = "ActivatedImei.selectActivatedUpdationDate", query = "select new com.spice.profitmandi.dao.model.ActivationImeiUpdationModel(fs.warehouseId,li.brand, "
|
|
|
46 |
+ " Max(ai.createTimestamp))"
|
|
|
47 |
+ " 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 "
|
|
|
48 |
+ " join FofoStore fs on fs.id = o.retailerId group by li.brand,fs.warehouseId"),
|
|
|
49 |
|
| 30344 |
amit.gupta |
50 |
@NamedQuery(name = "ActivatedImei.selectImeiActivationByBrand", query = "select new com.spice.profitmandi.dao.model.ImeiActivationTimestampModel(limei.serialNumber, ai.activationTimestamp) "
|
|
|
51 |
+ " from Order o join LineItem li on o.id=li.orderId join LineItemImei limei on li.id=limei.lineItemId join FofoStore fs on fs.id=o.retailerId left join ActivatedImei ai on limei.serialNumber = ai.serialNumber "
|
| 30823 |
amit.gupta |
52 |
+ " where (ai.createTimestamp is null or ai.createTimestamp < :daysBeforeToday) and li.brand = :brand and ai.activationTimestamp is null and fs.internal = false and date(o.billingTimestamp)>'2021-01-01'"),
|
| 29452 |
manish |
53 |
|
| 30449 |
amit.gupta |
54 |
@NamedQuery(name = "ActivatedImei.selectActivatedImeisByOrders", query = "select new com.spice.profitmandi.dao.model.ImeiActivationTimestampModel(o.id, o.lineItem.unitPrice, limei.serialNumber, ai.activationTimestamp) "
|
|
|
55 |
+ " from Order o join LineItem li on o.id=li.orderId join LineItemImei limei on li.id=limei.lineItemId join FofoStore fs on fs.id=o.retailerId left join ActivatedImei ai on limei.serialNumber = ai.serialNumber "
|
|
|
56 |
+ " where o.id in :orderIds and ai.activationTimestamp is not null"),
|
|
|
57 |
|
| 30505 |
amit.gupta |
58 |
@NamedQuery(name = "ActivatedImei.selectActivatedGrnPendingAmount", query = "select cast(sum(o.lineItem.unitPrice) as float )"
|
| 30479 |
amit.gupta |
59 |
+ " from Order o join LineItemImei limei on o.lineItem.id=limei.lineItemId join FofoStore fs on fs.id=o.retailerId left join ActivatedImei ai on limei.serialNumber = ai.serialNumber "
|
| 30484 |
amit.gupta |
60 |
+ " where o.status in (12, 9) and ai.activationTimestamp is not null and o.partnerGrnTimestamp is null and o.retailerId=:fofoId group by o.retailerId"),
|
| 30479 |
amit.gupta |
61 |
|
| 28825 |
tejbeer |
62 |
})
|
| 26299 |
amit.gupta |
63 |
public class ActivatedImei {
|
| 26309 |
amit.gupta |
64 |
@Id
|
|
|
65 |
@Column(name = "serial_number", unique = true)
|
|
|
66 |
private String serialNumber;
|
| 28825 |
tejbeer |
67 |
|
| 26309 |
amit.gupta |
68 |
@Column(name = "activation_timestamp")
|
|
|
69 |
private LocalDateTime activationTimestamp;
|
| 26299 |
amit.gupta |
70 |
|
| 26309 |
amit.gupta |
71 |
@Column(name = "create_timestamp")
|
|
|
72 |
private LocalDateTime createTimestamp;
|
| 28825 |
tejbeer |
73 |
|
| 30896 |
amit.gupta |
74 |
@Column
|
| 30904 |
amit.gupta |
75 |
private boolean checked = false;
|
| 30896 |
amit.gupta |
76 |
|
| 26299 |
amit.gupta |
77 |
public ActivatedImei() {
|
|
|
78 |
super();
|
|
|
79 |
}
|
| 28825 |
tejbeer |
80 |
|
| 26299 |
amit.gupta |
81 |
public ActivatedImei(String serialNumber, LocalDateTime activationTimestamp) {
|
|
|
82 |
this.activationTimestamp = activationTimestamp;
|
|
|
83 |
this.serialNumber = serialNumber;
|
|
|
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
|
| 30896 |
amit.gupta |
111 |
public String toString() {
|
|
|
112 |
return "ActivatedImei{" +
|
|
|
113 |
"serialNumber='" + serialNumber + '\'' +
|
|
|
114 |
", activationTimestamp=" + activationTimestamp +
|
|
|
115 |
", createTimestamp=" + createTimestamp +
|
|
|
116 |
", checked=" + checked +
|
|
|
117 |
'}';
|
| 26299 |
amit.gupta |
118 |
}
|
|
|
119 |
|
|
|
120 |
@Override
|
| 30896 |
amit.gupta |
121 |
public boolean equals(Object o) {
|
|
|
122 |
if (this == o) return true;
|
|
|
123 |
if (o == null || getClass() != o.getClass()) return false;
|
|
|
124 |
ActivatedImei that = (ActivatedImei) o;
|
|
|
125 |
return checked == that.checked && Objects.equals(serialNumber, that.serialNumber) && Objects.equals(activationTimestamp, that.activationTimestamp) && Objects.equals(createTimestamp, that.createTimestamp);
|
| 26299 |
amit.gupta |
126 |
}
|
|
|
127 |
|
| 30896 |
amit.gupta |
128 |
@Override
|
|
|
129 |
public int hashCode() {
|
|
|
130 |
return Objects.hash(serialNumber, activationTimestamp, createTimestamp, checked);
|
|
|
131 |
}
|
|
|
132 |
|
|
|
133 |
public boolean isChecked() {
|
|
|
134 |
return checked;
|
|
|
135 |
}
|
|
|
136 |
|
|
|
137 |
public void setChecked(boolean checked) {
|
|
|
138 |
this.checked = checked;
|
|
|
139 |
}
|
|
|
140 |
|
| 26299 |
amit.gupta |
141 |
}
|