Subversion Repositories SmartDukaan

Rev

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