Subversion Repositories SmartDukaan

Rev

Rev 31860 | Rev 34641 | 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;
30896 amit.gupta 5
import java.util.Objects;
26299 amit.gupta 6
 
7
@Entity
31860 tejbeer 8
@Table(name = "fofo.activated_imei")
28825 tejbeer 9
 
10
@NamedQueries({
11
 
12
		@NamedQuery(name = "ActivatedImei.selectActivatedModelGroupByBrand", query = "select new com.spice.profitmandi.dao.model.BrandWiseActivatedModel(li.brand, "
13
				+ "sum(case when concat(year(ai.activationTimestamp), month(ai.activationTimestamp))= :lms then 1 else 0 end),"
14
				+ "sum(case when concat(year(ai.activationTimestamp), month(ai.activationTimestamp))= :lms  then CAST(li.unitPrice  AS int) else 0 end),"
15
				+ "sum(case when concat(year(ai.activationTimestamp), month(ai.activationTimestamp))= :mtd then 1 else 0 end),"
16
				+ "sum(case when concat(year(ai.activationTimestamp), month(ai.activationTimestamp))= :mtd   then CAST(li.unitPrice AS int) else 0 end), "
17
				+ "sum(case when ai.activationTimestamp between  :lmtdStartDate and :lmtdEndDate then 1 else 0 end), "
18
				+ "sum(case when ai.activationTimestamp between  :lmtdStartDate and :lmtdEndDate then  CAST(li.unitPrice  AS int) else 0 end))"
19
				+ " 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 "
20
				+ "	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"),
21
 
29475 amit.gupta 22
		@NamedQuery(name = "ActivatedImei.selectActivatedModelGroupByWarehouse", query = "select new com.spice.profitmandi.dao.model.WarehouseWiseActivatedModel(o.warehouseId, "
28825 tejbeer 23
				+ "sum(case when concat(year(ai.activationTimestamp), month(ai.activationTimestamp))= :lms then 1 else 0 end),"
24
				+ "sum(case when concat(year(ai.activationTimestamp), month(ai.activationTimestamp))= :lms  then CAST(li.unitPrice  AS int) else 0 end),"
25
				+ "sum(case when concat(year(ai.activationTimestamp), month(ai.activationTimestamp))= :mtd then 1 else 0 end),"
26
				+ "sum(case when concat(year(ai.activationTimestamp), month(ai.activationTimestamp))= :mtd   then CAST(li.unitPrice AS int) else 0 end), "
27
				+ "sum(case when ai.activationTimestamp between  :lmtdStartDate and :lmtdEndDate then 1 else 0 end), "
28
				+ "sum(case when ai.activationTimestamp between  :lmtdStartDate and :lmtdEndDate then  CAST(li.unitPrice  AS int) else 0 end))"
29
				+ " 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 "
30
				+ " 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 31
				+ " group by o.warehouseId"),
28825 tejbeer 32
 
33
		@NamedQuery(name = "ActivatedImei.selectWarehouseBrandActivatedItem", query = "select new com.spice.profitmandi.dao.model.WarehouseBrandWiseItemActivatedModel(fs.warehouseId, li.itemId, li.brand,li.modelName,"
34
				+ " li.modelNumber, li.color,"
35
				+ "sum(case when concat(year(ai.activationTimestamp), month(ai.activationTimestamp))= :lms then 1 else 0 end),"
36
				+ "sum(case when concat(year(ai.activationTimestamp), month(ai.activationTimestamp))= :lms  then CAST(li.unitPrice  AS int) else 0 end),"
37
				+ "sum(case when concat(year(ai.activationTimestamp), month(ai.activationTimestamp))= :mtd then 1 else 0 end),"
38
				+ "sum(case when concat(year(ai.activationTimestamp), month(ai.activationTimestamp))= :mtd   then CAST(li.unitPrice AS int) else 0 end), "
39
				+ "sum(case when ai.activationTimestamp between  :lmtdStartDate and :lmtdEndDate then 1 else 0 end), "
40
				+ "sum(case when ai.activationTimestamp between  :lmtdStartDate and :lmtdEndDate then  CAST(li.unitPrice  AS int) else 0 end))"
41
				+ " 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 "
42
				+ " 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 "
43
				+ " group by li.itemId"),
44
 
45
		@NamedQuery(name = "ActivatedImei.selectActivatedUpdationDate", query = "select new com.spice.profitmandi.dao.model.ActivationImeiUpdationModel(fs.warehouseId,li.brand, "
46
				+ " Max(ai.createTimestamp))"
47
				+ " 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 "
48
				+ "	join FofoStore fs on fs.id = o.retailerId group by li.brand,fs.warehouseId"),
49
 
30344 amit.gupta 50
		@NamedQuery(name = "ActivatedImei.selectImeiActivationByBrand", query = "select new com.spice.profitmandi.dao.model.ImeiActivationTimestampModel(limei.serialNumber, ai.activationTimestamp) "
51
				+ " from Order o join LineItem  li on o.id=li.orderId join LineItemImei  limei on li.id=limei.lineItemId join FofoStore fs on fs.id=o.retailerId left join ActivatedImei ai on limei.serialNumber = ai.serialNumber "
30823 amit.gupta 52
				+ "	where (ai.createTimestamp is null or ai.createTimestamp < :daysBeforeToday) and li.brand = :brand and ai.activationTimestamp is null and fs.internal = false and date(o.billingTimestamp)>'2021-01-01'"),
29452 manish 53
 
31170 amit.gupta 54
		@NamedQuery(name = "ActivatedImei.selectImeiSoldNotActivatedByBrand", query = "select new com.spice.profitmandi.dao.model.ImeiActivationTimestampModel(fli.serialNumber, ai.activationTimestamp) "
55
				+ " from FofoOrder fo join FofoOrderItem  foi on fo.id=foi.orderId join FofoLineItem  fli on fli.fofoOrderItemId=foi.id "
56
				+ " join Item ci on ci.id=foi.itemId join FofoStore fs on fs.id=fo.fofoId left join ActivatedImei ai on fli.serialNumber = ai.serialNumber "
57
				+ "	where ai.createTimestamp is null and ci.brand = :brand and ai.activationTimestamp is null and fo.cancelledTimestamp is null and fs.internal = false and date(fo.createTimestamp) >'2021-01-01'"),
58
 
30449 amit.gupta 59
		@NamedQuery(name = "ActivatedImei.selectActivatedImeisByOrders", query = "select new com.spice.profitmandi.dao.model.ImeiActivationTimestampModel(o.id, o.lineItem.unitPrice, limei.serialNumber, ai.activationTimestamp) "
60
				+ " from Order o join LineItem  li on o.id=li.orderId join LineItemImei  limei on li.id=limei.lineItemId join FofoStore fs on fs.id=o.retailerId left join ActivatedImei ai on limei.serialNumber = ai.serialNumber "
61
				+ "	where o.id in :orderIds and ai.activationTimestamp is not null"),
62
 
30505 amit.gupta 63
		@NamedQuery(name = "ActivatedImei.selectActivatedGrnPendingAmount", query = "select cast(sum(o.lineItem.unitPrice) as float )"
30479 amit.gupta 64
				+ " from Order o join LineItemImei  limei on o.lineItem.id=limei.lineItemId join FofoStore fs on fs.id=o.retailerId left join ActivatedImei ai on limei.serialNumber = ai.serialNumber "
30484 amit.gupta 65
				+ "	where o.status in (12, 9) and ai.activationTimestamp is not null and o.partnerGrnTimestamp is null and o.retailerId=:fofoId group by o.retailerId"),
30479 amit.gupta 66
 
28825 tejbeer 67
})
26299 amit.gupta 68
public class ActivatedImei {
26309 amit.gupta 69
	@Id
70
	@Column(name = "serial_number", unique = true)
71
	private String serialNumber;
28825 tejbeer 72
 
26309 amit.gupta 73
	@Column(name = "activation_timestamp")
74
	private LocalDateTime activationTimestamp;
26299 amit.gupta 75
 
26309 amit.gupta 76
	@Column(name = "create_timestamp")
77
	private LocalDateTime createTimestamp;
28825 tejbeer 78
 
30896 amit.gupta 79
	@Column
30904 amit.gupta 80
	private boolean checked = false;
30896 amit.gupta 81
 
33952 aman.kumar 82
	@Column(name = "auth_id")
83
	private int authId;
84
 
26299 amit.gupta 85
	public ActivatedImei() {
86
		super();
87
	}
28825 tejbeer 88
 
26299 amit.gupta 89
	public ActivatedImei(String serialNumber, LocalDateTime activationTimestamp) {
90
		this.activationTimestamp = activationTimestamp;
91
		this.serialNumber = serialNumber;
92
	}
93
 
94
	public String getSerialNumber() {
95
		return serialNumber;
96
	}
97
 
98
	public void setSerialNumber(String serialNumber) {
99
		this.serialNumber = serialNumber;
100
	}
101
 
102
	public LocalDateTime getActivationTimestamp() {
103
		return activationTimestamp;
104
	}
105
 
106
	public void setActivationTimestamp(LocalDateTime activationTimestamp) {
107
		this.activationTimestamp = activationTimestamp;
108
	}
109
 
26309 amit.gupta 110
	public LocalDateTime getCreateTimestamp() {
111
		return createTimestamp;
112
	}
113
 
114
	public void setCreateTimestamp(LocalDateTime createTimestamp) {
115
		this.createTimestamp = createTimestamp;
116
	}
117
 
33952 aman.kumar 118
	public int getAuthId() {
119
		return authId;
120
	}
121
 
122
	public void setAuthId(int authId) {
123
		this.authId = authId;
124
	}
125
 
26299 amit.gupta 126
	@Override
30896 amit.gupta 127
	public String toString() {
128
		return "ActivatedImei{" +
129
				"serialNumber='" + serialNumber + '\'' +
130
				", activationTimestamp=" + activationTimestamp +
131
				", createTimestamp=" + createTimestamp +
132
				", checked=" + checked +
33952 aman.kumar 133
				", authId=" + authId +
30896 amit.gupta 134
				'}';
26299 amit.gupta 135
	}
136
 
137
	@Override
30896 amit.gupta 138
	public boolean equals(Object o) {
139
		if (this == o) return true;
140
		if (o == null || getClass() != o.getClass()) return false;
141
		ActivatedImei that = (ActivatedImei) o;
142
		return checked == that.checked && Objects.equals(serialNumber, that.serialNumber) && Objects.equals(activationTimestamp, that.activationTimestamp) && Objects.equals(createTimestamp, that.createTimestamp);
26299 amit.gupta 143
	}
144
 
30896 amit.gupta 145
	@Override
146
	public int hashCode() {
147
		return Objects.hash(serialNumber, activationTimestamp, createTimestamp, checked);
148
	}
149
 
150
	public boolean isChecked() {
151
		return checked;
152
	}
153
 
154
	public void setChecked(boolean checked) {
155
		this.checked = checked;
156
	}
157
 
26299 amit.gupta 158
}