Subversion Repositories SmartDukaan

Rev

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

Rev Author Line No. Line
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;
5
 
6
@Entity
7
@Table(name = "fofo.activated_imei", schema = "fofo")
28825 tejbeer 8
 
9
@NamedQueries({
10
 
11
		@NamedQuery(name = "ActivatedImei.selectActivatedModelGroupByBrand", query = "select new com.spice.profitmandi.dao.model.BrandWiseActivatedModel(li.brand, "
12
				+ "sum(case when concat(year(ai.activationTimestamp), month(ai.activationTimestamp))= :lms then 1 else 0 end),"
13
				+ "sum(case when concat(year(ai.activationTimestamp), month(ai.activationTimestamp))= :lms  then CAST(li.unitPrice  AS int) else 0 end),"
14
				+ "sum(case when concat(year(ai.activationTimestamp), month(ai.activationTimestamp))= :mtd then 1 else 0 end),"
15
				+ "sum(case when concat(year(ai.activationTimestamp), month(ai.activationTimestamp))= :mtd   then CAST(li.unitPrice AS int) else 0 end), "
16
				+ "sum(case when ai.activationTimestamp between  :lmtdStartDate and :lmtdEndDate then 1 else 0 end), "
17
				+ "sum(case when ai.activationTimestamp between  :lmtdStartDate and :lmtdEndDate then  CAST(li.unitPrice  AS int) else 0 end))"
18
				+ " 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 "
19
				+ "	join FofoStore fs on fs.id = o.retailerId where (fs.fofoType = 'FRANCHISE' or fs.fofoType = 'THIRD_PARTY') and fs.id in :fofoIds group by li.brand"),
20
 
29475 amit.gupta 21
		@NamedQuery(name = "ActivatedImei.selectActivatedModelGroupByWarehouse", query = "select new com.spice.profitmandi.dao.model.WarehouseWiseActivatedModel(o.warehouseId, "
28825 tejbeer 22
				+ "sum(case when concat(year(ai.activationTimestamp), month(ai.activationTimestamp))= :lms then 1 else 0 end),"
23
				+ "sum(case when concat(year(ai.activationTimestamp), month(ai.activationTimestamp))= :lms  then CAST(li.unitPrice  AS int) else 0 end),"
24
				+ "sum(case when concat(year(ai.activationTimestamp), month(ai.activationTimestamp))= :mtd then 1 else 0 end),"
25
				+ "sum(case when concat(year(ai.activationTimestamp), month(ai.activationTimestamp))= :mtd   then CAST(li.unitPrice AS int) else 0 end), "
26
				+ "sum(case when ai.activationTimestamp between  :lmtdStartDate and :lmtdEndDate then 1 else 0 end), "
27
				+ "sum(case when ai.activationTimestamp between  :lmtdStartDate and :lmtdEndDate then  CAST(li.unitPrice  AS int) else 0 end))"
28
				+ " 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 "
29
				+ " join FofoStore fs on fs.id = o.retailerId where (fs.fofoType = 'FRANCHISE' or fs.fofoType = 'THIRD_PARTY') and li.brand = :brand and fs.id in :fofoIds"
29474 amit.gupta 30
				+ " group by o.warehouseId"),
28825 tejbeer 31
 
32
		@NamedQuery(name = "ActivatedImei.selectWarehouseBrandActivatedItem", query = "select new com.spice.profitmandi.dao.model.WarehouseBrandWiseItemActivatedModel(fs.warehouseId, li.itemId, li.brand,li.modelName,"
33
				+ " li.modelNumber, li.color,"
34
				+ "sum(case when concat(year(ai.activationTimestamp), month(ai.activationTimestamp))= :lms then 1 else 0 end),"
35
				+ "sum(case when concat(year(ai.activationTimestamp), month(ai.activationTimestamp))= :lms  then CAST(li.unitPrice  AS int) else 0 end),"
36
				+ "sum(case when concat(year(ai.activationTimestamp), month(ai.activationTimestamp))= :mtd then 1 else 0 end),"
37
				+ "sum(case when concat(year(ai.activationTimestamp), month(ai.activationTimestamp))= :mtd   then CAST(li.unitPrice AS int) else 0 end), "
38
				+ "sum(case when ai.activationTimestamp between  :lmtdStartDate and :lmtdEndDate then 1 else 0 end), "
39
				+ "sum(case when ai.activationTimestamp between  :lmtdStartDate and :lmtdEndDate then  CAST(li.unitPrice  AS int) else 0 end))"
40
				+ " 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 "
41
				+ " join FofoStore fs on fs.id = o.retailerId where (fs.fofoType = 'FRANCHISE' or fs.fofoType = 'THIRD_PARTY') and fs.warehouseId in :warehouseId and li.brand = :brand and fs.id in :fofoIds "
42
				+ " group by li.itemId"),
43
 
44
		@NamedQuery(name = "ActivatedImei.selectActivatedUpdationDate", query = "select new com.spice.profitmandi.dao.model.ActivationImeiUpdationModel(fs.warehouseId,li.brand, "
45
				+ " Max(ai.createTimestamp))"
46
				+ " 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 "
47
				+ "	join FofoStore fs on fs.id = o.retailerId group by li.brand,fs.warehouseId"),
48
 
30213 amit.gupta 49
		@NamedQuery(name = "ActivatedImei.selectImeiActivationByBrand", query = "select new com.spice.profitmandi.dao.model.ImeiActivationTimestampModel(ii.serialNumber, ai.activationTimestamp) "
29452 manish 50
				+ " from InventoryItem ii left join ActivatedImei ai on ii.serialNumber = ai.serialNumber join Item i on i.id = ii.itemId "
30213 amit.gupta 51
				+ "	where ii.lastScanType in('PURCHASE','SALE','SALE_RET','PURCHASE_RET') and i.brand = :brand and ai.activationTimestamp is null and ii.serialNumber is not null"),
29452 manish 52
 
28825 tejbeer 53
})
26299 amit.gupta 54
public class ActivatedImei {
26309 amit.gupta 55
	@Id
56
	@Column(name = "serial_number", unique = true)
57
	private String serialNumber;
28825 tejbeer 58
 
26309 amit.gupta 59
	@Column(name = "activation_timestamp")
60
	private LocalDateTime activationTimestamp;
26299 amit.gupta 61
 
26309 amit.gupta 62
	@Column(name = "create_timestamp")
63
	private LocalDateTime createTimestamp;
28825 tejbeer 64
 
26299 amit.gupta 65
	public ActivatedImei() {
66
		super();
67
	}
28825 tejbeer 68
 
26299 amit.gupta 69
	public ActivatedImei(String serialNumber, LocalDateTime activationTimestamp) {
70
		this.activationTimestamp = activationTimestamp;
71
		this.serialNumber = serialNumber;
72
	}
73
 
74
	@Override
75
	public String toString() {
26309 amit.gupta 76
		return "ActivatedImei [serialNumber=" + serialNumber + ", activationTimestamp=" + activationTimestamp
77
				+ ", createTimestamp=" + createTimestamp + "]";
26299 amit.gupta 78
	}
79
 
80
	public String getSerialNumber() {
81
		return serialNumber;
82
	}
83
 
84
	public void setSerialNumber(String serialNumber) {
85
		this.serialNumber = serialNumber;
86
	}
87
 
88
	public LocalDateTime getActivationTimestamp() {
89
		return activationTimestamp;
90
	}
91
 
92
	public void setActivationTimestamp(LocalDateTime activationTimestamp) {
93
		this.activationTimestamp = activationTimestamp;
94
	}
95
 
26309 amit.gupta 96
	public LocalDateTime getCreateTimestamp() {
97
		return createTimestamp;
98
	}
99
 
100
	public void setCreateTimestamp(LocalDateTime createTimestamp) {
101
		this.createTimestamp = createTimestamp;
102
	}
103
 
26299 amit.gupta 104
	@Override
105
	public int hashCode() {
106
		final int prime = 31;
107
		int result = 1;
26309 amit.gupta 108
		result = prime * result + ((activationTimestamp == null) ? 0 : activationTimestamp.hashCode());
109
		result = prime * result + ((createTimestamp == null) ? 0 : createTimestamp.hashCode());
26299 amit.gupta 110
		result = prime * result + ((serialNumber == null) ? 0 : serialNumber.hashCode());
111
		return result;
112
	}
113
 
114
	@Override
115
	public boolean equals(Object obj) {
116
		if (this == obj)
117
			return true;
118
		if (obj == null)
119
			return false;
120
		if (getClass() != obj.getClass())
121
			return false;
122
		ActivatedImei other = (ActivatedImei) obj;
26309 amit.gupta 123
		if (activationTimestamp == null) {
124
			if (other.activationTimestamp != null)
125
				return false;
126
		} else if (!activationTimestamp.equals(other.activationTimestamp))
127
			return false;
128
		if (createTimestamp == null) {
129
			if (other.createTimestamp != null)
130
				return false;
131
		} else if (!createTimestamp.equals(other.createTimestamp))
132
			return false;
26299 amit.gupta 133
		if (serialNumber == null) {
134
			if (other.serialNumber != null)
135
				return false;
136
		} else if (!serialNumber.equals(other.serialNumber))
137
			return false;
138
		return true;
139
	}
140
 
141
}