| 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
|
| 35458 |
amit |
8 |
@Table(name = "fofo.activated_imei")
|
| 28825 |
tejbeer |
9 |
|
|
|
10 |
@NamedQueries({
|
|
|
11 |
|
|
|
12 |
@NamedQuery(name = "ActivatedImei.selectActivatedModelGroupByBrand", query = "select new com.spice.profitmandi.dao.model.BrandWiseActivatedModel(li.brand, "
|
| 35464 |
amit |
13 |
+ "sum(case when ai.activationTimestamp >= :lmsStartDate and ai.activationTimestamp < :mtdStartDate then 1 else 0 end),"
|
|
|
14 |
+ "sum(case when ai.activationTimestamp >= :lmsStartDate and ai.activationTimestamp < :mtdStartDate then CAST(li.unitPrice AS int) else 0 end),"
|
|
|
15 |
+ "sum(case when ai.activationTimestamp >= :mtdStartDate then 1 else 0 end),"
|
|
|
16 |
+ "sum(case when ai.activationTimestamp >= :mtdStartDate then CAST(li.unitPrice AS int) else 0 end), "
|
|
|
17 |
+ "sum(case when ai.activationTimestamp >= :lmtdStartDate and ai.activationTimestamp < :lmtdEndDate then 1 else 0 end), "
|
| 35595 |
amit |
18 |
+ "sum(case when ai.activationTimestamp >= :lmtdStartDate and ai.activationTimestamp < :lmtdEndDate then CAST(li.unitPrice AS int) else 0 end))"
|
| 28825 |
tejbeer |
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 "
|
| 35464 |
amit |
20 |
+ " join FofoStore fs on fs.id = o.retailerId where ai.activationTimestamp >= :lmsStartDate and (fs.fofoType = 'FRANCHISE' or fs.fofoType = 'THIRD_PARTY') and fs.id in :fofoIds group by li.brand"),
|
| 28825 |
tejbeer |
21 |
|
| 29475 |
amit.gupta |
22 |
@NamedQuery(name = "ActivatedImei.selectActivatedModelGroupByWarehouse", query = "select new com.spice.profitmandi.dao.model.WarehouseWiseActivatedModel(o.warehouseId, "
|
| 35464 |
amit |
23 |
+ "sum(case when ai.activationTimestamp >= :lmsStartDate and ai.activationTimestamp < :mtdStartDate then 1 else 0 end),"
|
|
|
24 |
+ "sum(case when ai.activationTimestamp >= :lmsStartDate and ai.activationTimestamp < :mtdStartDate then CAST(li.unitPrice AS int) else 0 end),"
|
|
|
25 |
+ "sum(case when ai.activationTimestamp >= :mtdStartDate then 1 else 0 end),"
|
|
|
26 |
+ "sum(case when ai.activationTimestamp >= :mtdStartDate then CAST(li.unitPrice AS int) else 0 end), "
|
|
|
27 |
+ "sum(case when ai.activationTimestamp >= :lmtdStartDate and ai.activationTimestamp < :lmtdEndDate then 1 else 0 end), "
|
|
|
28 |
+ "sum(case when ai.activationTimestamp >= :lmtdStartDate and ai.activationTimestamp < :lmtdEndDate then CAST(li.unitPrice AS int) else 0 end))"
|
| 28825 |
tejbeer |
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 "
|
| 35464 |
amit |
30 |
+ " join FofoStore fs on fs.id = o.retailerId where ai.activationTimestamp >= :lmsStartDate and (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,"
|
| 35464 |
amit |
35 |
+ "sum(case when ai.activationTimestamp >= :lmsStartDate and ai.activationTimestamp < :mtdStartDate then 1 else 0 end),"
|
|
|
36 |
+ "sum(case when ai.activationTimestamp >= :lmsStartDate and ai.activationTimestamp < :mtdStartDate then CAST(li.unitPrice AS int) else 0 end),"
|
|
|
37 |
+ "sum(case when ai.activationTimestamp >= :mtdStartDate then 1 else 0 end),"
|
|
|
38 |
+ "sum(case when ai.activationTimestamp >= :mtdStartDate then CAST(li.unitPrice AS int) else 0 end), "
|
|
|
39 |
+ "sum(case when ai.activationTimestamp >= :lmtdStartDate and ai.activationTimestamp < :lmtdEndDate then 1 else 0 end), "
|
|
|
40 |
+ "sum(case when ai.activationTimestamp >= :lmtdStartDate and ai.activationTimestamp < :lmtdEndDate then CAST(li.unitPrice AS int) else 0 end))"
|
| 28825 |
tejbeer |
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 "
|
| 35464 |
amit |
42 |
+ " join FofoStore fs on fs.id = o.retailerId where ai.activationTimestamp >= :lmsStartDate and (fs.fofoType = 'FRANCHISE' or fs.fofoType = 'THIRD_PARTY') and fs.warehouseId in :warehouseId and li.brand = :brand and fs.id in :fofoIds "
|
| 28825 |
tejbeer |
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))"
|
| 35466 |
amit |
47 |
+ " from ActivatedImei ai join LineItemImei 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 where ai.createTimestamp >= :startDate group by li.brand,fs.warehouseId"),
|
| 28825 |
tejbeer |
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 |
|
| 35536 |
amit |
67 |
@NamedQuery(name = "ActivatedImei.selectActivatedGrnPendingAmountByFofoIds", query = "select o.retailerId, cast(sum(o.lineItem.unitPrice) as float )"
|
|
|
68 |
+ " 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 "
|
|
|
69 |
+ " where o.status in (12, 9) and ai.activationTimestamp is not null and o.partnerGrnTimestamp is null and o.retailerId in :fofoIds group by o.retailerId"),
|
|
|
70 |
|
| 34641 |
ranu |
71 |
@NamedQuery(name = "ActivatedImei.getMonthlyUnbilledTertiaryPrice", query = "select new com.spice.profitmandi.dao.model.PartnerWiseActivatedNotBilledTotal(ii.fofoId, sum((tl.mop)), DATE_FORMAT(ai.activationTimestamp, '%Y-%m')) "
|
|
|
72 |
+" from InventoryItem ii" +
|
|
|
73 |
" join Item i on i.id=ii.itemId" +
|
|
|
74 |
" join TagListing tl on tl.itemId=i.id" +
|
|
|
75 |
" join ActivatedImei ai on ai.serialNumber=ii.serialNumber" +
|
|
|
76 |
" WHERE ii.goodQuantity=1 and ai.activationTimestamp is not null and ai.activationTimestamp >= :startDate " +
|
|
|
77 |
" and ii.fofoId= :fofoId group by DATE_FORMAT(ai.activationTimestamp, '%Y-%m')"),
|
| 28825 |
tejbeer |
78 |
})
|
| 26299 |
amit.gupta |
79 |
public class ActivatedImei {
|
| 26309 |
amit.gupta |
80 |
@Id
|
|
|
81 |
@Column(name = "serial_number", unique = true)
|
|
|
82 |
private String serialNumber;
|
| 28825 |
tejbeer |
83 |
|
| 26309 |
amit.gupta |
84 |
@Column(name = "activation_timestamp")
|
|
|
85 |
private LocalDateTime activationTimestamp;
|
| 26299 |
amit.gupta |
86 |
|
| 26309 |
amit.gupta |
87 |
@Column(name = "create_timestamp")
|
|
|
88 |
private LocalDateTime createTimestamp;
|
| 28825 |
tejbeer |
89 |
|
| 30896 |
amit.gupta |
90 |
@Column
|
| 30904 |
amit.gupta |
91 |
private boolean checked = false;
|
| 30896 |
amit.gupta |
92 |
|
| 33952 |
aman.kumar |
93 |
@Column(name = "auth_id")
|
|
|
94 |
private int authId;
|
|
|
95 |
|
| 26299 |
amit.gupta |
96 |
public ActivatedImei() {
|
|
|
97 |
super();
|
|
|
98 |
}
|
| 28825 |
tejbeer |
99 |
|
| 26299 |
amit.gupta |
100 |
public ActivatedImei(String serialNumber, LocalDateTime activationTimestamp) {
|
|
|
101 |
this.activationTimestamp = activationTimestamp;
|
|
|
102 |
this.serialNumber = serialNumber;
|
|
|
103 |
}
|
|
|
104 |
|
|
|
105 |
public String getSerialNumber() {
|
|
|
106 |
return serialNumber;
|
|
|
107 |
}
|
|
|
108 |
|
|
|
109 |
public void setSerialNumber(String serialNumber) {
|
|
|
110 |
this.serialNumber = serialNumber;
|
|
|
111 |
}
|
|
|
112 |
|
|
|
113 |
public LocalDateTime getActivationTimestamp() {
|
|
|
114 |
return activationTimestamp;
|
|
|
115 |
}
|
|
|
116 |
|
|
|
117 |
public void setActivationTimestamp(LocalDateTime activationTimestamp) {
|
|
|
118 |
this.activationTimestamp = activationTimestamp;
|
|
|
119 |
}
|
|
|
120 |
|
| 26309 |
amit.gupta |
121 |
public LocalDateTime getCreateTimestamp() {
|
|
|
122 |
return createTimestamp;
|
|
|
123 |
}
|
|
|
124 |
|
|
|
125 |
public void setCreateTimestamp(LocalDateTime createTimestamp) {
|
|
|
126 |
this.createTimestamp = createTimestamp;
|
|
|
127 |
}
|
|
|
128 |
|
| 33952 |
aman.kumar |
129 |
public int getAuthId() {
|
|
|
130 |
return authId;
|
|
|
131 |
}
|
|
|
132 |
|
|
|
133 |
public void setAuthId(int authId) {
|
|
|
134 |
this.authId = authId;
|
|
|
135 |
}
|
|
|
136 |
|
| 26299 |
amit.gupta |
137 |
@Override
|
| 30896 |
amit.gupta |
138 |
public String toString() {
|
|
|
139 |
return "ActivatedImei{" +
|
|
|
140 |
"serialNumber='" + serialNumber + '\'' +
|
|
|
141 |
", activationTimestamp=" + activationTimestamp +
|
|
|
142 |
", createTimestamp=" + createTimestamp +
|
|
|
143 |
", checked=" + checked +
|
| 33952 |
aman.kumar |
144 |
", authId=" + authId +
|
| 30896 |
amit.gupta |
145 |
'}';
|
| 26299 |
amit.gupta |
146 |
}
|
|
|
147 |
|
|
|
148 |
@Override
|
| 30896 |
amit.gupta |
149 |
public boolean equals(Object o) {
|
|
|
150 |
if (this == o) return true;
|
|
|
151 |
if (o == null || getClass() != o.getClass()) return false;
|
|
|
152 |
ActivatedImei that = (ActivatedImei) o;
|
|
|
153 |
return checked == that.checked && Objects.equals(serialNumber, that.serialNumber) && Objects.equals(activationTimestamp, that.activationTimestamp) && Objects.equals(createTimestamp, that.createTimestamp);
|
| 26299 |
amit.gupta |
154 |
}
|
|
|
155 |
|
| 30896 |
amit.gupta |
156 |
@Override
|
|
|
157 |
public int hashCode() {
|
|
|
158 |
return Objects.hash(serialNumber, activationTimestamp, createTimestamp, checked);
|
|
|
159 |
}
|
|
|
160 |
|
|
|
161 |
public boolean isChecked() {
|
|
|
162 |
return checked;
|
|
|
163 |
}
|
|
|
164 |
|
|
|
165 |
public void setChecked(boolean checked) {
|
|
|
166 |
this.checked = checked;
|
|
|
167 |
}
|
|
|
168 |
|
| 26299 |
amit.gupta |
169 |
}
|