| 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 |
|
| 31170 |
amit.gupta |
54 |
@NamedQuery(name = "ActivatedImei.selectImeiSoldNotActivatedByBrand", query = "select new com.spice.profitmandi.dao.model.ImeiActivationTimestampModel(fli.serialNumber, ai.activationTimestamp) "
|
|
|
55 |
+ " from FofoOrder fo join FofoOrderItem foi on fo.id=foi.orderId join FofoLineItem fli on fli.fofoOrderItemId=foi.id "
|
|
|
56 |
+ " join Item ci on ci.id=foi.itemId join FofoStore fs on fs.id=fo.fofoId left join ActivatedImei ai on fli.serialNumber = ai.serialNumber "
|
|
|
57 |
+ " where ai.createTimestamp is null and ci.brand = :brand and ai.activationTimestamp is null and fo.cancelledTimestamp is null and fs.internal = false and date(fo.createTimestamp) >'2021-01-01'"),
|
|
|
58 |
|
| 30449 |
amit.gupta |
59 |
@NamedQuery(name = "ActivatedImei.selectActivatedImeisByOrders", query = "select new com.spice.profitmandi.dao.model.ImeiActivationTimestampModel(o.id, o.lineItem.unitPrice, limei.serialNumber, ai.activationTimestamp) "
|
|
|
60 |
+ " 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 "
|
|
|
61 |
+ " where o.id in :orderIds and ai.activationTimestamp is not null"),
|
|
|
62 |
|
| 30505 |
amit.gupta |
63 |
@NamedQuery(name = "ActivatedImei.selectActivatedGrnPendingAmount", query = "select cast(sum(o.lineItem.unitPrice) as float )"
|
| 30479 |
amit.gupta |
64 |
+ " 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 |
65 |
+ " 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 |
66 |
|
| 28825 |
tejbeer |
67 |
})
|
| 26299 |
amit.gupta |
68 |
public class ActivatedImei {
|
| 26309 |
amit.gupta |
69 |
@Id
|
|
|
70 |
@Column(name = "serial_number", unique = true)
|
|
|
71 |
private String serialNumber;
|
| 28825 |
tejbeer |
72 |
|
| 26309 |
amit.gupta |
73 |
@Column(name = "activation_timestamp")
|
|
|
74 |
private LocalDateTime activationTimestamp;
|
| 26299 |
amit.gupta |
75 |
|
| 26309 |
amit.gupta |
76 |
@Column(name = "create_timestamp")
|
|
|
77 |
private LocalDateTime createTimestamp;
|
| 28825 |
tejbeer |
78 |
|
| 30896 |
amit.gupta |
79 |
@Column
|
| 30904 |
amit.gupta |
80 |
private boolean checked = false;
|
| 30896 |
amit.gupta |
81 |
|
| 26299 |
amit.gupta |
82 |
public ActivatedImei() {
|
|
|
83 |
super();
|
|
|
84 |
}
|
| 28825 |
tejbeer |
85 |
|
| 26299 |
amit.gupta |
86 |
public ActivatedImei(String serialNumber, LocalDateTime activationTimestamp) {
|
|
|
87 |
this.activationTimestamp = activationTimestamp;
|
|
|
88 |
this.serialNumber = serialNumber;
|
|
|
89 |
}
|
|
|
90 |
|
|
|
91 |
public String getSerialNumber() {
|
|
|
92 |
return serialNumber;
|
|
|
93 |
}
|
|
|
94 |
|
|
|
95 |
public void setSerialNumber(String serialNumber) {
|
|
|
96 |
this.serialNumber = serialNumber;
|
|
|
97 |
}
|
|
|
98 |
|
|
|
99 |
public LocalDateTime getActivationTimestamp() {
|
|
|
100 |
return activationTimestamp;
|
|
|
101 |
}
|
|
|
102 |
|
|
|
103 |
public void setActivationTimestamp(LocalDateTime activationTimestamp) {
|
|
|
104 |
this.activationTimestamp = activationTimestamp;
|
|
|
105 |
}
|
|
|
106 |
|
| 26309 |
amit.gupta |
107 |
public LocalDateTime getCreateTimestamp() {
|
|
|
108 |
return createTimestamp;
|
|
|
109 |
}
|
|
|
110 |
|
|
|
111 |
public void setCreateTimestamp(LocalDateTime createTimestamp) {
|
|
|
112 |
this.createTimestamp = createTimestamp;
|
|
|
113 |
}
|
|
|
114 |
|
| 26299 |
amit.gupta |
115 |
@Override
|
| 30896 |
amit.gupta |
116 |
public String toString() {
|
|
|
117 |
return "ActivatedImei{" +
|
|
|
118 |
"serialNumber='" + serialNumber + '\'' +
|
|
|
119 |
", activationTimestamp=" + activationTimestamp +
|
|
|
120 |
", createTimestamp=" + createTimestamp +
|
|
|
121 |
", checked=" + checked +
|
|
|
122 |
'}';
|
| 26299 |
amit.gupta |
123 |
}
|
|
|
124 |
|
|
|
125 |
@Override
|
| 30896 |
amit.gupta |
126 |
public boolean equals(Object o) {
|
|
|
127 |
if (this == o) return true;
|
|
|
128 |
if (o == null || getClass() != o.getClass()) return false;
|
|
|
129 |
ActivatedImei that = (ActivatedImei) o;
|
|
|
130 |
return checked == that.checked && Objects.equals(serialNumber, that.serialNumber) && Objects.equals(activationTimestamp, that.activationTimestamp) && Objects.equals(createTimestamp, that.createTimestamp);
|
| 26299 |
amit.gupta |
131 |
}
|
|
|
132 |
|
| 30896 |
amit.gupta |
133 |
@Override
|
|
|
134 |
public int hashCode() {
|
|
|
135 |
return Objects.hash(serialNumber, activationTimestamp, createTimestamp, checked);
|
|
|
136 |
}
|
|
|
137 |
|
|
|
138 |
public boolean isChecked() {
|
|
|
139 |
return checked;
|
|
|
140 |
}
|
|
|
141 |
|
|
|
142 |
public void setChecked(boolean checked) {
|
|
|
143 |
this.checked = checked;
|
|
|
144 |
}
|
|
|
145 |
|
| 26299 |
amit.gupta |
146 |
}
|