NC 报销单根据日期和单据号排序
List<JKBXVO> resultList = new ArrayList<JKBXVO>();
if(djdl == null && resultList != null){//按日期、单据号进行排序
Collections.sort(resultList, new Comparator<JKBXVO>(){
@Override
public int compare(JKBXVO bxvo1, JKBXVO bxvo2) {
JKBXHeaderVO head1 = bxvo1.getParentVO();
JKBXHeaderVO head2 = bxvo2.getParentVO();
if(head1.getDjrq() != null && head2.getDjrq() != null){
if(head1.getDjrq().compareTo(head2.getDjrq()) > 0){
return -1;
}else if(head1.getDjrq().compareTo(head2.getDjrq()) < 0){
return 1;
}else{
if(head1.getDjbh() != null && head2.getDjbh() != null){
if(head1.getDjbh().compareTo(head2.getDjbh()) > 0){
return -1;
}else if(head1.getDjbh().compareTo(head2.getDjbh()) < 0){
return 1;
}
}
}
}
return 0;
}
});
}
return resultList;
组织VO比较器:
package nc.vo.org.util;
import java.util.Comparator;
import org.apache.commons.lang.StringUtils;
import nc.vo.org.OrgVO;
/**
* 组织VO比较器
* @author hanyw1
* @since uap6.3
*/
public class OrgVOComparator implements Comparator<OrgVO> {
@Override
public int compare(OrgVO o1, OrgVO o2) {
if(o1 == null) return -1;
if(o2 == null) return 1;
String code1 = o1.getCode();
String code2 = o2.getCode();
String org1Str = StringUtils.stripToEmpty(code1);
String org2Str = StringUtils.stripToEmpty(code2);
return org1Str.compareTo(org2Str);
}
}