@SuppressWarnings("unchecked")
public static void main(String[] args) {
System.out.println(44);
List<CallRecordVo> list1 = createTestList();
Collections.sort(list1, new Comparator<CallRecordVo>() {
@SuppressWarnings({ "unused", "rawtypes" })
@Override
public int compare(CallRecordVo o1, CallRecordVo o2) {
int flag = 0;
int i = new Integer(o1.getVillageId()).compareTo(o2.getVillageId());
if(i == 0){
Matcher matcher = Pattern.compile(
"\\d+|[甲乙己丙丁]+|[一二三四五六七八九十]").matcher(
o1.getDoorInfo());
List listo1 = new ArrayList();
while (matcher.find()) {
// System.out.println(matcher.group());
listo1.add(NumHelper.toLittleNum(matcher.group()));
}
Matcher matcher2 = Pattern.compile(
"\\d+|[甲乙己丙丁]+|[一二三四五六七八九十]").matcher(
o2.getDoorInfo());
List listo2 = new ArrayList();
while (matcher2.find()) {
// System.out.println(matcher.group());
listo2.add(NumHelper.toLittleNum(matcher2.group()));
}
if(listo1.size()>=1 && listo2.size() >=1){
int j = new Integer((int) listo1.get(0)).compareTo(new Integer( (int) listo2.get(0)));
if(j==0){
if(listo1.size()>=2 && listo2.size() >=2){
int k = new Integer((int) listo1.get(1)).compareTo(new Integer((int) listo2.get(1)));
if(k == 0){
if(listo1.size() >= 3 && listo2.size() >= 3 ){
int m = new Integer((int) listo1.get(2)).compareTo(new Integer((int) listo2.get(2)));
return m;
}
}
return k;
}
}
return j;
}
}
return i;
}
});
for (CallRecordVo param : list1) {
System.out.println(param.toString());
}
}
/**
* 构造地区排序得字段
* @return
*/
private static List<CallRecordVo> createTestList() {
List<CallRecordVo> list = new ArrayList<CallRecordVo>();
CallRecordVo callVo = new CallRecordVo();
callVo.setServerStationName("22");
callVo.setVillageId(13);
callVo.setVillageName("万源里社区");
callVo.setDoorInfo("44号楼一单元4号");
list.add(callVo);
CallRecordVo callVo1 = new CallRecordVo();
callVo1.setServerStationName("22");
callVo1.setVillageId(13);
callVo1.setVillageName("万源里社区");
callVo1.setDoorInfo("32楼36单元5号");
list.add(callVo1);
CallRecordVo callVo2 = new CallRecordVo();
callVo2.setServerStationName("22");
callVo2.setVillageId(13);
callVo2.setVillageName("万源里社区");
callVo2.setDoorInfo("46楼56单元4号");
list.add(callVo2);
CallRecordVo callVo3 = new CallRecordVo();
callVo3.setServerStationName("22");
callVo3.setVillageId(12);
callVo3.setVillageName("梅源社区");
callVo3.setDoorInfo("梅源里9号楼2单元4号");
list.add(callVo3);
CallRecordVo callVo5 = new CallRecordVo();
callVo5.setServerStationName("22");
callVo5.setVillageId(12);
callVo5.setVillageName("梅源社区");
callVo5.setDoorInfo("梅源里9号楼1单元48号");
list.add(callVo5);
CallRecordVo callVo6 = new CallRecordVo();
callVo6.setServerStationName("22");
callVo6.setVillageId(12);
callVo6.setVillageName("梅源社区");
callVo6.setDoorInfo("梅源里9号楼2单元44号");
list.add(callVo6);
CallRecordVo callVo4 = new CallRecordVo();
callVo4.setServerStationName("22");
callVo4.setVillageId(12);
callVo4.setVillageName("梅源社区");
callVo4.setDoorInfo("四栋五单元十四号");
list.add(callVo4);
return list;
}