Subversion Repositories SmartDukaan

Rev

Rev 35426 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
33772 amit.gupta 1
package com.spice.profitmandi.dao.entity.catalog;
2
 
3
import javax.persistence.*;
4
import java.time.LocalDateTime;
5
import java.util.Objects;
6
 
35343 ranu 7
 
8
@NamedQueries({
9
        @NamedQuery(name = "Catalog.findOtherORNullCategoryAndInStock", query = "select i.catalogItemId "
10
                + " from WarehouseInventoryItem wi "
11
                + " join Item i on i.id = wi.itemId"
12
                + " left join CategorisedCatalog cc on cc.catalogId = i.catalogItemId and cc.endDate is null "
35356 ranu 13
                + " where ((cc.status is null OR cc.status = 'OTHER' OR cc.status = 'SLOWMOVING')) and i.categoryId in (10006,10009,10010) and i.brand= :brand group by i.catalogItemId having sum(wi.currentQuantity) > 0"),
35343 ranu 14
 
15
        @NamedQuery(name = "Catalog.findOtherORNullCategoryAndPartnerInStock", query = "select i.catalogItemId "
16
                + " from CurrentInventorySnapshot cis "
17
                + " join Item i on i.id = cis.itemId"
18
                + " left join CategorisedCatalog cc on cc.catalogId = i.catalogItemId and cc.endDate is null "
35356 ranu 19
                + " where  ((cc.status is null OR cc.status = 'OTHER' OR cc.status = 'SLOWMOVING')) and i.categoryId in (10006,10009,10010) and i.brand= :brand and cis.fofoId = :fofoId group by i.catalogItemId having sum(cis.availability) > 0"),
35357 ranu 20
 
35365 ranu 21
        @NamedQuery(name = "Catalog.findAllWithEOLWithOutStock", query = "select i.catalogItemId "
35359 ranu 22
                + " from Item i "
23
                + " left join  WarehouseInventoryItem wi on i.id = wi.itemId"
35357 ranu 24
                + " left join CategorisedCatalog cc on cc.catalogId = i.catalogItemId and cc.endDate is null "
35426 ranu 25
                + " where ((cc.status is null OR cc.status = 'OTHER' OR cc.status = 'SLOWMOVING')) and i.categoryId in (10006,10009,10010) group by i.catalogItemId having (sum(wi.currentQuantity) = 0 OR sum(wi.currentQuantity) IS NULL)"),
35357 ranu 26
 
35487 ranu 27
        @NamedQuery(name = "Catalog.selectAllStatusAndBrandWise", query = "select c.id" +
28
                " from Catalog c " +
29
                " join CategorisedCatalog cc on c.id = cc.catalogId and cc.endDate is null" +
30
                " where cc.status in  (:statuses) and c.brand in :brands"),
35426 ranu 31
 
35487 ranu 32
 
35426 ranu 33
        @NamedQuery(
34
                name = "Catalog.findAllWithNoGoodStock",
35
                query = "select i.catalogItemId "
36
                        + " from Item i "
37
                        + " left join WarehouseInventoryItem wi on i.id = wi.itemId "
38
                        + " left join CategorisedCatalog cc on cc.catalogId = i.catalogItemId and cc.endDate is null "
39
                        + " where (cc.status is null OR cc.status = 'OTHER' OR cc.status = 'SLOWMOVING') "
40
                        + " and i.categoryId in (10006, 10009, 10010) "
41
                        + " group by i.catalogItemId "
42
                        + " having "
43
                        + "   sum(case when (wi.lastScanType is null OR wi.lastScanType NOT IN (:scanTypes)) "
44
                        + "            then wi.currentQuantity else 0 end) = 0 "
45
                        + "   OR sum(wi.currentQuantity) IS NULL"
46
        )
47
 
35343 ranu 48
})
49
 
33772 amit.gupta 50
@Entity
51
@Table(name = "catalog.catalog")
52
public class Catalog {
53
    @Id
54
    @GeneratedValue(strategy = GenerationType.IDENTITY)
55
    @Column(name = "id", columnDefinition = "int(11)")
56
    private int id;
57
 
58
    @Column(name="brand_id")
59
    private int brandId;
60
 
61
    @Column
62
    private String brand;
63
 
64
    @Column(name="model_number")
65
    private String modelNumber;
66
 
67
    @Column(name="model_name")
68
    private String modelName;
69
 
33888 ranu 70
    @Column(name = "category_id")
71
    private int categoryId;
72
 
33772 amit.gupta 73
    @Column(name="created_by")
74
    private String createdBy;
75
 
76
    @Column
77
    private LocalDateTime created;
78
 
79
    public int getId() {
80
        return id;
81
    }
82
 
83
    public void setId(int id) {
84
        this.id = id;
85
    }
86
 
87
    public int getBrandId() {
88
        return brandId;
89
    }
90
 
91
    public void setBrandId(int brandId) {
92
        this.brandId = brandId;
93
    }
94
 
95
    public String getBrand() {
96
        return brand;
97
    }
98
 
99
    public void setBrand(String brand) {
100
        this.brand = brand;
101
    }
102
 
103
    public String getModelNumber() {
104
        return modelNumber;
105
    }
106
 
107
    public void setModelNumber(String modelNumber) {
108
        this.modelNumber = modelNumber;
109
    }
110
 
111
    public String getModelName() {
112
        return modelName;
113
    }
114
 
115
    public void setModelName(String modelName) {
116
        this.modelName = modelName;
117
    }
118
 
119
    public String getCreatedBy() {
120
        return createdBy;
121
    }
122
 
123
    public void setCreatedBy(String createdBy) {
124
        this.createdBy = createdBy;
125
    }
126
 
127
    public LocalDateTime getCreated() {
128
        return created;
129
    }
130
 
131
    public void setCreated(LocalDateTime created) {
132
        this.created = created;
133
    }
134
 
33888 ranu 135
    public int getCategoryId() {
136
        return categoryId;
137
    }
138
 
139
    public void setCategoryId(int categoryId) {
140
        this.categoryId = categoryId;
141
    }
142
 
33772 amit.gupta 143
    @Override
144
    public boolean equals(Object o) {
145
        if (this == o) return true;
146
        if (o == null || getClass() != o.getClass()) return false;
147
        Catalog catalog = (Catalog) o;
33888 ranu 148
        return id == catalog.id && brandId == catalog.brandId && categoryId == catalog.categoryId && Objects.equals(brand, catalog.brand) && Objects.equals(modelNumber, catalog.modelNumber) && Objects.equals(modelName, catalog.modelName) && Objects.equals(createdBy, catalog.createdBy) && Objects.equals(created, catalog.created);
33772 amit.gupta 149
    }
150
 
151
    @Override
33888 ranu 152
    public int hashCode() {
153
        return Objects.hash(id, brandId, brand, modelNumber, modelName, categoryId, createdBy, created);
154
    }
155
 
33916 amit.gupta 156
    public String getDescription() {
157
        StringBuilder itemString = new StringBuilder();
158
        if (this.getBrand() != null && !this.getBrand().isEmpty()) {
159
            itemString.append(this.getBrand().trim());
160
        }
161
        itemString.append(" ");
162
        if (this.getModelName() != null && !this.getModelName().isEmpty()) {
163
            itemString.append(this.getModelName().trim());
164
        }
165
        if (this.getModelNumber() != null && !this.getModelNumber().isEmpty()) {
166
            itemString.append(" ");
167
            itemString.append(this.getModelNumber().trim());
168
        }
169
 
170
        return itemString.toString().replaceAll("\\s+", " ").trim();
171
    }
172
 
35188 amit 173
    public String getDescriptionNoBrand() {
174
        StringBuilder itemString = new StringBuilder();
175
        itemString.append(" ");
176
        if (this.getModelName() != null && !this.getModelName().isEmpty()) {
177
            itemString.append(this.getModelName().trim());
178
        }
179
        if (this.getModelNumber() != null && !this.getModelNumber().isEmpty()) {
180
            itemString.append(" ");
181
            itemString.append(this.getModelNumber().trim());
182
        }
183
 
184
        return itemString.toString().replaceAll("\\s+", " ").trim();
185
    }
186
 
33888 ranu 187
    @Override
33772 amit.gupta 188
    public String toString() {
189
        return "Catalog{" +
190
                "id=" + id +
191
                ", brandId=" + brandId +
192
                ", brand='" + brand + '\'' +
193
                ", modelNumber='" + modelNumber + '\'' +
194
                ", modelName='" + modelName + '\'' +
33888 ranu 195
                ", categoryId=" + categoryId +
33772 amit.gupta 196
                ", createdBy='" + createdBy + '\'' +
197
                ", created=" + created +
198
                '}';
199
    }
200
 
201
}
202