-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDepartment.java
More file actions
225 lines (185 loc) · 4.87 KB
/
Department.java
File metadata and controls
225 lines (185 loc) · 4.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
package btp.oneP;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
/**
*
* 营业部实体
* 系统版本: v1.0<br>
* 开发人员: @author baitp<br>
* 开发时间: 2017年09月03日<br>
*/
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.PriorityQueue;
public class Department implements Serializable,Comparable<Department>{
/**
*
*/
private static final long serialVersionUID = 6070094233812709878L;
/*
* 营业部类型:本家营业部:0;捆绑营业部:1;总部:2;
*/
public static int SELF = 0;
public static int BINDING = 1;
public static int HQ = 2;
public Department(){}
public Department(double leisureLevel,double defectProbability, int orgType) {
super();
this.leisureLevel = leisureLevel;
this.orgType = orgType;
this.defectProbability = defectProbability;
}
/*
*营业部编号
*/
private String orgCode;
/*
* 对应VideoQueuesAction.agentFBranchList里的相应营业部坐席队列
*/
private Map<Long, Agent> agentList;
/*
* 空闲坐席人数
*/
private int freeAgentNum;
/*
* 属于什么营业部:
* 分本家营业部:0;捆绑营业部:1;总部:2;
*/
private int orgType;
/*
* 饱满程度:空闲人数/总人数
*/
private double leisureLevel;
public double getLeisureLevel() {
return leisureLevel;
}
public void setLeisureLevel(double leisureLevel) {
this.leisureLevel = leisureLevel;
}
public String getOrgCode() {
return orgCode;
}
public void setOrgCode(String orgCode) {
this.orgCode = orgCode;
}
public Map<Long, Agent> getAgentList() {
return agentList;
}
public void setAgentList(LinkedHashMap<Long, Agent> agentList) {
this.agentList = agentList;
}
public int getFreeAgentNum() {
return freeAgentNum;
}
public void setFreeAgentNum(int freeAgentNum) {
this.freeAgentNum = freeAgentNum;
}
public int getOrgType() {
return orgType;
}
public void setOrgType(int orgType) {
this.orgType = orgType;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((orgCode == null) ? 0 : orgCode.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
Department other = (Department) obj;
if (orgCode == null) {
if (other.orgCode != null)
return false;
} else if (!orgCode.equals(other.orgCode))
return false;
return true;
}
@Override
public String toString() {
return "Department [orgType=" + orgType + ", leisureLevel=" + leisureLevel + ", defectProbability="
+ defectProbability + "]\n";
}
//营业部比较器:优先级:营业部类型>空闲程度>缺损率
private static Comparator<Department> comparatorForDepartment = new Comparator<Department>(){
@Override
public int compare(Department d1, Department d2) {
if(d1.getOrgType() > d2.getOrgType()){
return 1;
}else if(d1.getOrgType() < d2.getOrgType()){
return -1;
}else{
if(d1.getLeisureLevel() > d2.getLeisureLevel()){
return -1;
}else if(d1.getLeisureLevel() < d2.getLeisureLevel()){
return 1;
}else{
if(d1.getDefectProbability() > d2.getDefectProbability()){
return 1;
}else if(d1.getDefectProbability() < d2.getDefectProbability()){
return -1;
}else{
return 0;
}
}
}
}
};
private double defectProbability;
public double getDefectProbability() {
return defectProbability;
}
public void setDefectProbability(double defectProbability) {
this.defectProbability = defectProbability;
}
public static void main(String...args) {
List<Department> dl = new ArrayList<>();
Department self = new Department(0.98,0,1);
dl.add(self);
dl.add(new Department(1,0.88,1));
dl.add(new Department(1,0.98,2));
dl.add(new Department(1,1,1));
dl.add(new Department(1,0.76,1));
dl.add(new Department(1,0.23,1));
dl.add(new Department(1,0.55,1));
dl.add(new Department(1,0,1));
Collections.sort(dl, comparatorForDepartment);
System.out.println(dl);
System.out.println("-------------------------");
PriorityQueue<Department> pq = new PriorityQueue<>();
pq.addAll(dl);
System.out.println(pq.peek());
self.setOrgType(1);
System.out.println(pq.peek());
pq.remove();
pq.addAll(dl);
System.out.println(pq.peek());
}
@Override
public int compareTo(Department o) {
if(this.getOrgType() > o.getOrgType()){
return 1;
}else if(this.getOrgType() < o.getOrgType()){
return -1;
}else{
if(this.getFreeAgentNum() > o.getFreeAgentNum()){
return -1;
}else if(this.getFreeAgentNum() < o.getFreeAgentNum()){
return 1;
}else{
return 0;
}
}
}
}