| 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
|
| 36255 |
vikas |
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), "
|
| 36255 |
vikas |
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) "
|
| 36259 |
amit |
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 "
|
|
|
52 |
+ " where (ai.createTimestamp is null or ai.createTimestamp < :daysBeforeToday) and li.brand = :brand and ai.activationTimestamp is null and fs.internal = false and o.billingTimestamp > '2021-01-01'"
|
|
|
53 |
+ " and limei.serialNumber not in (select fli.serialNumber from FofoLineItem fli where fli.serialNumber is not null)"),
|
| 29452 |
manish |
54 |
|
| 36259 |
amit |
55 |
@NamedQuery(name = "ActivatedImei.selectImeiActivationByBrandTertiary", query = "select new com.spice.profitmandi.dao.model.ImeiActivationTimestampModel(fli.serialNumber, ai.activationTimestamp) "
|
|
|
56 |
+ " from FofoOrder fo join FofoOrderItem foi on fo.id=foi.orderId join FofoLineItem fli on fli.fofoOrderItemId=foi.id "
|
|
|
57 |
+ " 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 "
|
|
|
58 |
+ " where (ai.createTimestamp is null or ai.createTimestamp < :daysBeforeToday) and ci.brand = :brand and ai.activationTimestamp is null and fo.cancelledTimestamp is null and fs.internal = false and fo.createTimestamp > '2021-01-01'"),
|
|
|
59 |
|
| 31170 |
amit.gupta |
60 |
@NamedQuery(name = "ActivatedImei.selectImeiSoldNotActivatedByBrand", query = "select new com.spice.profitmandi.dao.model.ImeiActivationTimestampModel(fli.serialNumber, ai.activationTimestamp) "
|
| 36259 |
amit |
61 |
+ " from FofoOrder fo join FofoOrderItem foi on fo.id=foi.orderId join FofoLineItem fli on fli.fofoOrderItemId=foi.id "
|
| 31170 |
amit.gupta |
62 |
+ " 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 "
|
| 36259 |
amit |
63 |
+ " where ai.createTimestamp is null and ci.brand = :brand and ai.activationTimestamp is null and fo.cancelledTimestamp is null and fs.internal = false and fo.createTimestamp > '2021-01-01'"),
|
| 31170 |
amit.gupta |
64 |
|
| 30449 |
amit.gupta |
65 |
@NamedQuery(name = "ActivatedImei.selectActivatedImeisByOrders", query = "select new com.spice.profitmandi.dao.model.ImeiActivationTimestampModel(o.id, o.lineItem.unitPrice, limei.serialNumber, ai.activationTimestamp) "
|
|
|
66 |
+ " 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 "
|
|
|
67 |
+ " where o.id in :orderIds and ai.activationTimestamp is not null"),
|
|
|
68 |
|
| 30505 |
amit.gupta |
69 |
@NamedQuery(name = "ActivatedImei.selectActivatedGrnPendingAmount", query = "select cast(sum(o.lineItem.unitPrice) as float )"
|
| 30479 |
amit.gupta |
70 |
+ " 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 |
71 |
+ " 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 |
72 |
|
| 35536 |
amit |
73 |
@NamedQuery(name = "ActivatedImei.selectActivatedGrnPendingAmountByFofoIds", query = "select o.retailerId, cast(sum(o.lineItem.unitPrice) as float )"
|
|
|
74 |
+ " 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 "
|
|
|
75 |
+ " 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"),
|
|
|
76 |
|
| 34641 |
ranu |
77 |
@NamedQuery(name = "ActivatedImei.getMonthlyUnbilledTertiaryPrice", query = "select new com.spice.profitmandi.dao.model.PartnerWiseActivatedNotBilledTotal(ii.fofoId, sum((tl.mop)), DATE_FORMAT(ai.activationTimestamp, '%Y-%m')) "
|
|
|
78 |
+" from InventoryItem ii" +
|
|
|
79 |
" join Item i on i.id=ii.itemId" +
|
|
|
80 |
" join TagListing tl on tl.itemId=i.id" +
|
|
|
81 |
" join ActivatedImei ai on ai.serialNumber=ii.serialNumber" +
|
|
|
82 |
" WHERE ii.goodQuantity=1 and ai.activationTimestamp is not null and ai.activationTimestamp >= :startDate " +
|
|
|
83 |
" and ii.fofoId= :fofoId group by DATE_FORMAT(ai.activationTimestamp, '%Y-%m')"),
|
| 28825 |
tejbeer |
84 |
})
|
| 26299 |
amit.gupta |
85 |
public class ActivatedImei {
|
| 26309 |
amit.gupta |
86 |
@Id
|
|
|
87 |
@Column(name = "serial_number", unique = true)
|
|
|
88 |
private String serialNumber;
|
| 28825 |
tejbeer |
89 |
|
| 26309 |
amit.gupta |
90 |
@Column(name = "activation_timestamp")
|
|
|
91 |
private LocalDateTime activationTimestamp;
|
| 26299 |
amit.gupta |
92 |
|
| 26309 |
amit.gupta |
93 |
@Column(name = "create_timestamp")
|
|
|
94 |
private LocalDateTime createTimestamp;
|
| 28825 |
tejbeer |
95 |
|
| 30896 |
amit.gupta |
96 |
@Column
|
| 30904 |
amit.gupta |
97 |
private boolean checked = false;
|
| 30896 |
amit.gupta |
98 |
|
| 33952 |
aman.kumar |
99 |
@Column(name = "auth_id")
|
|
|
100 |
private int authId;
|
|
|
101 |
|
| 26299 |
amit.gupta |
102 |
public ActivatedImei() {
|
|
|
103 |
super();
|
|
|
104 |
}
|
| 28825 |
tejbeer |
105 |
|
| 26299 |
amit.gupta |
106 |
public ActivatedImei(String serialNumber, LocalDateTime activationTimestamp) {
|
|
|
107 |
this.activationTimestamp = activationTimestamp;
|
|
|
108 |
this.serialNumber = serialNumber;
|
|
|
109 |
}
|
|
|
110 |
|
|
|
111 |
public String getSerialNumber() {
|
|
|
112 |
return serialNumber;
|
|
|
113 |
}
|
|
|
114 |
|
|
|
115 |
public void setSerialNumber(String serialNumber) {
|
|
|
116 |
this.serialNumber = serialNumber;
|
|
|
117 |
}
|
|
|
118 |
|
|
|
119 |
public LocalDateTime getActivationTimestamp() {
|
|
|
120 |
return activationTimestamp;
|
|
|
121 |
}
|
|
|
122 |
|
|
|
123 |
public void setActivationTimestamp(LocalDateTime activationTimestamp) {
|
|
|
124 |
this.activationTimestamp = activationTimestamp;
|
|
|
125 |
}
|
|
|
126 |
|
| 26309 |
amit.gupta |
127 |
public LocalDateTime getCreateTimestamp() {
|
|
|
128 |
return createTimestamp;
|
|
|
129 |
}
|
|
|
130 |
|
|
|
131 |
public void setCreateTimestamp(LocalDateTime createTimestamp) {
|
|
|
132 |
this.createTimestamp = createTimestamp;
|
|
|
133 |
}
|
|
|
134 |
|
| 33952 |
aman.kumar |
135 |
public int getAuthId() {
|
|
|
136 |
return authId;
|
|
|
137 |
}
|
|
|
138 |
|
|
|
139 |
public void setAuthId(int authId) {
|
|
|
140 |
this.authId = authId;
|
|
|
141 |
}
|
|
|
142 |
|
| 26299 |
amit.gupta |
143 |
@Override
|
| 30896 |
amit.gupta |
144 |
public String toString() {
|
|
|
145 |
return "ActivatedImei{" +
|
|
|
146 |
"serialNumber='" + serialNumber + '\'' +
|
|
|
147 |
", activationTimestamp=" + activationTimestamp +
|
|
|
148 |
", createTimestamp=" + createTimestamp +
|
|
|
149 |
", checked=" + checked +
|
| 33952 |
aman.kumar |
150 |
", authId=" + authId +
|
| 30896 |
amit.gupta |
151 |
'}';
|
| 26299 |
amit.gupta |
152 |
}
|
|
|
153 |
|
|
|
154 |
@Override
|
| 30896 |
amit.gupta |
155 |
public boolean equals(Object o) {
|
|
|
156 |
if (this == o) return true;
|
|
|
157 |
if (o == null || getClass() != o.getClass()) return false;
|
|
|
158 |
ActivatedImei that = (ActivatedImei) o;
|
|
|
159 |
return checked == that.checked && Objects.equals(serialNumber, that.serialNumber) && Objects.equals(activationTimestamp, that.activationTimestamp) && Objects.equals(createTimestamp, that.createTimestamp);
|
| 26299 |
amit.gupta |
160 |
}
|
|
|
161 |
|
| 30896 |
amit.gupta |
162 |
@Override
|
|
|
163 |
public int hashCode() {
|
|
|
164 |
return Objects.hash(serialNumber, activationTimestamp, createTimestamp, checked);
|
|
|
165 |
}
|
|
|
166 |
|
|
|
167 |
public boolean isChecked() {
|
|
|
168 |
return checked;
|
|
|
169 |
}
|
|
|
170 |
|
|
|
171 |
public void setChecked(boolean checked) {
|
|
|
172 |
this.checked = checked;
|
|
|
173 |
}
|
|
|
174 |
|
| 26299 |
amit.gupta |
175 |
}
|