| 34055 |
ranu |
1 |
package com.spice.profitmandi.dao.model;
|
|
|
2 |
|
|
|
3 |
import javax.persistence.*;
|
|
|
4 |
import java.util.Objects;
|
|
|
5 |
|
|
|
6 |
|
|
|
7 |
@Entity
|
|
|
8 |
@NamedNativeQueries({
|
|
|
9 |
@NamedNativeQuery(name = "Aging.15DaysOurStock",
|
|
|
10 |
query = "select" +
|
|
|
11 |
" SUM(CASE WHEN cc.status = 'EOL' THEN tl.selling_price ELSE 0 END) AS EOL," +
|
|
|
12 |
" SUM(CASE WHEN cc.status = 'SLOWMOVING' THEN tl.selling_price ELSE 0 END) AS Slowmoving," +
|
|
|
13 |
" SUM(CASE WHEN cc.status = 'FASTMOVING' THEN tl.selling_price ELSE 0 END) AS Fastmoving," +
|
|
|
14 |
" SUM(CASE WHEN cc.status = 'HID' THEN tl.selling_price ELSE 0 END) AS HID," +
|
|
|
15 |
" SUM(CASE WHEN cc.status IS NULL THEN tl.selling_price ELSE 0 END) AS Other," +
|
|
|
16 |
" SUM(tl.selling_price) AS Total" +
|
|
|
17 |
" from warehouse.inventoryItem ii" +
|
|
|
18 |
" join warehouse.scanNew s on s.inventoryItemId = ii.id" +
|
|
|
19 |
" join catalog.item i on i.id = ii.itemId" +
|
|
|
20 |
" join catalog.tag_listing tl on tl.item_id = i.id" +
|
| 34074 |
ranu |
21 |
" left join catalog.catagoriesd_catalog cc on cc.catalog_id = i.catalog_item_id and cc.end_date is null" +
|
| 34055 |
ranu |
22 |
" join (warehouse.inventoryItem ii2 join warehouse.purchase p on p.id = ii2.purchaseId" +
|
|
|
23 |
" join warehouse.purchaseorder po on po.id = p.purchaseOrder_id" +
|
| 34068 |
ranu |
24 |
" join warehouse.invoice inv on (p.invoice_id = inv.id and po.supplierId = inv.supplierId and" +
|
| 34055 |
ranu |
25 |
" po.warehouseId = ii2.physicalWarehouseId)" +
|
|
|
26 |
" join warehouse.supplier su on su.id = inv.supplierId and su.internal = 0)" +
|
|
|
27 |
" on (ii.serialNumber = ii2.serialNumber and ii2.lastScanType != 'PURCHASE_RETURN')" +
|
|
|
28 |
"" +
|
|
|
29 |
"where s.type = 'PURCHASE'" +
|
|
|
30 |
" and (DATEDIFF(now(), inv.invoiceDate) > 15 )" +
|
|
|
31 |
" and ii.lastScanType not in ('DOA_IN', 'DOA_OUT', 'SALE_RET_UNUSABLE')" +
|
|
|
32 |
" and ii.currentQuantity = 1" +
|
|
|
33 |
" and i.category = 10006" +
|
|
|
34 |
" and ii.created > '2018-01-01'",
|
|
|
35 |
resultSetMapping = "Our15DaysAging"),
|
|
|
36 |
|
|
|
37 |
})
|
|
|
38 |
|
|
|
39 |
@SqlResultSetMappings({
|
|
|
40 |
|
|
|
41 |
@SqlResultSetMapping(name = "Our15DaysAging",
|
|
|
42 |
classes = {@ConstructorResult(targetClass = Our15DaysOldAgingStock.class,
|
|
|
43 |
columns = {
|
|
|
44 |
@ColumnResult(name = "EOL", type = Long.class),
|
|
|
45 |
@ColumnResult(name = "Slowmoving", type = Long.class),
|
|
|
46 |
@ColumnResult(name = "Fastmoving ", type = Long.class),
|
|
|
47 |
@ColumnResult(name = "HID", type = Long.class),
|
|
|
48 |
@ColumnResult(name = "Other", type = Long.class),
|
|
|
49 |
@ColumnResult(name = "Total", type = Long.class),
|
|
|
50 |
}
|
|
|
51 |
)}
|
|
|
52 |
)
|
|
|
53 |
|
|
|
54 |
})
|
|
|
55 |
|
|
|
56 |
public class Our15DaysOldAgingStock {
|
|
|
57 |
long eolAgingStock;
|
|
|
58 |
long runningAgingStock;
|
|
|
59 |
long fastmovingAgingStock;
|
|
|
60 |
long hidAgingStock;
|
|
|
61 |
long otherAgingStock;
|
|
|
62 |
long total;
|
|
|
63 |
|
|
|
64 |
// Synthetic primary key to satisfy JPA's requirement
|
|
|
65 |
@Id
|
|
|
66 |
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
|
|
67 |
private Long id; // This will not be used in the query but satisfies JPA.
|
|
|
68 |
|
|
|
69 |
public Our15DaysOldAgingStock(long eolAgingStock, long runningAgingStock, long fastmovingAgingStock, long hidAgingStock, long otherAgingStock, long total) {
|
|
|
70 |
this.eolAgingStock = eolAgingStock;
|
|
|
71 |
this.runningAgingStock = runningAgingStock;
|
|
|
72 |
this.fastmovingAgingStock = fastmovingAgingStock;
|
|
|
73 |
this.hidAgingStock = hidAgingStock;
|
|
|
74 |
this.otherAgingStock = otherAgingStock;
|
|
|
75 |
this.total = total;
|
|
|
76 |
}
|
|
|
77 |
|
|
|
78 |
public long getEolAgingStock() {
|
|
|
79 |
return eolAgingStock;
|
|
|
80 |
}
|
|
|
81 |
|
|
|
82 |
public void setEolAgingStock(long eolAgingStock) {
|
|
|
83 |
this.eolAgingStock = eolAgingStock;
|
|
|
84 |
}
|
|
|
85 |
|
|
|
86 |
public long getRunningAgingStock() {
|
|
|
87 |
return runningAgingStock;
|
|
|
88 |
}
|
|
|
89 |
|
|
|
90 |
public void setRunningAgingStock(long runningAgingStock) {
|
|
|
91 |
this.runningAgingStock = runningAgingStock;
|
|
|
92 |
}
|
|
|
93 |
|
|
|
94 |
public long getFastmovingAgingStock() {
|
|
|
95 |
return fastmovingAgingStock;
|
|
|
96 |
}
|
|
|
97 |
|
|
|
98 |
public void setFastmovingAgingStock(long fastmovingAgingStock) {
|
|
|
99 |
this.fastmovingAgingStock = fastmovingAgingStock;
|
|
|
100 |
}
|
|
|
101 |
|
|
|
102 |
public long getHidAgingStock() {
|
|
|
103 |
return hidAgingStock;
|
|
|
104 |
}
|
|
|
105 |
|
|
|
106 |
public void setHidAgingStock(long hidAgingStock) {
|
|
|
107 |
this.hidAgingStock = hidAgingStock;
|
|
|
108 |
}
|
|
|
109 |
|
|
|
110 |
public long getOtherAgingStock() {
|
|
|
111 |
return otherAgingStock;
|
|
|
112 |
}
|
|
|
113 |
|
|
|
114 |
public void setOtherAgingStock(long otherAgingStock) {
|
|
|
115 |
this.otherAgingStock = otherAgingStock;
|
|
|
116 |
}
|
|
|
117 |
|
|
|
118 |
public long getTotal() {
|
|
|
119 |
return total;
|
|
|
120 |
}
|
|
|
121 |
|
|
|
122 |
public void setTotal(long total) {
|
|
|
123 |
this.total = total;
|
|
|
124 |
}
|
|
|
125 |
|
|
|
126 |
@Override
|
|
|
127 |
public boolean equals(Object o) {
|
|
|
128 |
if (this == o) return true;
|
|
|
129 |
if (o == null || getClass() != o.getClass()) return false;
|
|
|
130 |
Our15DaysOldAgingStock that = (Our15DaysOldAgingStock) o;
|
|
|
131 |
return eolAgingStock == that.eolAgingStock && runningAgingStock == that.runningAgingStock && fastmovingAgingStock == that.fastmovingAgingStock && hidAgingStock == that.hidAgingStock && otherAgingStock == that.otherAgingStock && total == that.total;
|
|
|
132 |
}
|
|
|
133 |
|
|
|
134 |
@Override
|
|
|
135 |
public int hashCode() {
|
|
|
136 |
return Objects.hash(eolAgingStock, runningAgingStock, fastmovingAgingStock, hidAgingStock, otherAgingStock, total);
|
|
|
137 |
}
|
|
|
138 |
}
|
|
|
139 |
|