Subversion Repositories SmartDukaan

Rev

Rev 33991 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
33991 ranu 1
package com.spice.profitmandi.dao.model;
2
 
3
import javax.persistence.*;
4
import java.time.LocalDateTime;
5
import java.util.Objects;
6
 
7
 
8
@Entity
9
@NamedNativeQueries({
10
        @NamedNativeQuery(name = "CatalogsReport.SoldCatalogsReport",
11
                query = " SELECT o.customer_name, fs.warehouse_id, o.warehouse_id billing_warehouse,i.model_number,i.catalog_item_id,t.selling_price, sum(li.quantity) quantity,cc.status,o.billing_timestamp from transaction.order o" +
12
                        " JOIN transaction.lineitem li on li.order_id=o.id" +
13
                        " JOIN fofo.fofo_store fs on fs.id=o.customer_id" +
14
                        " JOIN catalog.item i on i.id=li.item_id" +
15
                        " JOIN catalog.tag_listing t on t.item_id=i.id" +
16
                        " JOIN catalog.catagoriesd_catalog cc on (cc.catalog_id=i.catalog_item_id and (cc.start_date <= o.billing_timestamp AND  (cc.end_date IS NULL or cc.end_date > o.billing_timestamp)))" +
17
                        " WHERE (o.billing_timestamp >= :startDate AND o.billing_timestamp < :endDate and o.refund_timestamp is null) and li.brand not in ('Smartdukaan', 'Dummy', 'FOC', 'Live Demo')" +
18
                        " GROUP BY o.customer_id , i.catalog_item_id",
34098 ranu 19
                resultSetMapping = "SoldCatalogReport"),
33991 ranu 20
 
21
})
22
 
23
@SqlResultSetMappings({
24
 
34098 ranu 25
        @SqlResultSetMapping(name = "SoldCatalogReport",
33991 ranu 26
                classes = {@ConstructorResult(targetClass = SoldCatalogsReportModel.class,
27
                        columns = {
28
                                @ColumnResult(name = "customer_name", type = String.class),
29
                                @ColumnResult(name = "warehouse_id", type = Integer.class),
30
                                @ColumnResult(name = "billing_warehouse ", type = Integer.class),
31
                                @ColumnResult(name = "model_number ", type = String.class),
32
                                @ColumnResult(name = "catalog_item_id ", type = Integer.class),
33
                                @ColumnResult(name = "selling_price ", type = Float.class),
34
                                @ColumnResult(name = "quantity ", type = Double.class),
35
                                @ColumnResult(name = "status ", type = String.class),
36
                                @ColumnResult(name = "billing_timestamp ", type = LocalDateTime.class)
37
                        }
38
                )}
39
        )
40
 
41
})
42
 
43
public class SoldCatalogsReportModel {
44
    String customerName;
45
    int partnerWarehouseId;
46
    int billingWarehouseId;
47
    String modelNumber;
48
    int catalogItemId;
49
    Float sellingPrice;
50
    Double soldQuantity;
51
    String status;
52
    LocalDateTime billingDate;
53
    // Synthetic primary key to satisfy JPA's requirement
54
    @Id
55
    @GeneratedValue(strategy = GenerationType.IDENTITY)
56
    private Long id; // This will not be used in the query but satisfies JPA.
57
 
58
    public SoldCatalogsReportModel(String customerName, int partnerWarehouseId, int billingWarehouseId, String modelNumber, int catalogItemId, Float sellingPrice, Double soldQuantity, String status, LocalDateTime billingDate) {
59
        this.customerName = customerName;
60
        this.partnerWarehouseId = partnerWarehouseId;
61
        this.billingWarehouseId = billingWarehouseId;
62
        this.modelNumber = modelNumber;
63
        this.catalogItemId = catalogItemId;
64
        this.sellingPrice = sellingPrice;
65
        this.soldQuantity = soldQuantity;
66
        this.status = status;
67
        this.billingDate = billingDate;
68
    }
69
 
70
    public String getCustomerName() {
71
        return customerName;
72
    }
73
 
74
    public void setCustomerName(String customerName) {
75
        this.customerName = customerName;
76
    }
77
 
78
    public int getPartnerWarehouseId() {
79
        return partnerWarehouseId;
80
    }
81
 
82
    public void setPartnerWarehouseId(int partnerWarehouseId) {
83
        this.partnerWarehouseId = partnerWarehouseId;
84
    }
85
 
86
    public int getBillingWarehouseId() {
87
        return billingWarehouseId;
88
    }
89
 
90
    public void setBillingWarehouseId(int billingWarehouseId) {
91
        this.billingWarehouseId = billingWarehouseId;
92
    }
93
 
94
    public String getModelNumber() {
95
        return modelNumber;
96
    }
97
 
98
    public void setModelNumber(String modelNumber) {
99
        this.modelNumber = modelNumber;
100
    }
101
 
102
    public int getCatalogItemId() {
103
        return catalogItemId;
104
    }
105
 
106
    public void setCatalogItemId(int catalogItemId) {
107
        this.catalogItemId = catalogItemId;
108
    }
109
 
110
    public Float getSellingPrice() {
111
        return sellingPrice;
112
    }
113
 
114
    public void setSellingPrice(Float sellingPrice) {
115
        this.sellingPrice = sellingPrice;
116
    }
117
 
118
    public Double getSoldQuantity() {
119
        return soldQuantity;
120
    }
121
 
122
    public void setSoldQuantity(Double soldQuantity) {
123
        this.soldQuantity = soldQuantity;
124
    }
125
 
126
    public String getStatus() {
127
        return status;
128
    }
129
 
130
    public void setStatus(String status) {
131
        this.status = status;
132
    }
133
 
134
    public LocalDateTime getBillingDate() {
135
        return billingDate;
136
    }
137
 
138
    public void setBillingDate(LocalDateTime billingDate) {
139
        this.billingDate = billingDate;
140
    }
141
 
142
    @Override
143
    public String toString() {
144
        return "SoldCatalogsReportModel{" +
145
                "customerName='" + customerName + '\'' +
146
                ", partnerWarehouseId=" + partnerWarehouseId +
147
                ", billingWarehouseId=" + billingWarehouseId +
148
                ", modelNumber='" + modelNumber + '\'' +
149
                ", catalogItemId=" + catalogItemId +
150
                ", sellingPrice=" + sellingPrice +
151
                ", soldQuantity=" + soldQuantity +
152
                ", status='" + status + '\'' +
153
                ", billingDate=" + billingDate +
154
                '}';
155
    }
156
 
157
    @Override
158
    public boolean equals(Object o) {
159
        if (this == o) return true;
160
        if (o == null || getClass() != o.getClass()) return false;
161
        SoldCatalogsReportModel that = (SoldCatalogsReportModel) o;
162
        return partnerWarehouseId == that.partnerWarehouseId && billingWarehouseId == that.billingWarehouseId && catalogItemId == that.catalogItemId && Objects.equals(customerName, that.customerName) && Objects.equals(modelNumber, that.modelNumber) && Objects.equals(sellingPrice, that.sellingPrice) && Objects.equals(soldQuantity, that.soldQuantity) && Objects.equals(status, that.status) && Objects.equals(billingDate, that.billingDate);
163
    }
164
 
165
    @Override
166
    public int hashCode() {
167
        return Objects.hash(customerName, partnerWarehouseId, billingWarehouseId, modelNumber, catalogItemId, sellingPrice, soldQuantity, status, billingDate);
168
    }
169
}