NC 报销单根据日期和单据号排序
List<JKBXVO> resultList = new ArrayList<JKBXVO>();if(djdl == null && resultList != null){//按日期、单据号进行排序Collections.sort(resultList, new Comparator<JKBXVO>(){@Overridepublic 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 .util;import parator;import mons.lang.StringUtils;import .OrgVO;/*** 组织VO比较器* @author hanyw1* @since uap6.3*/public class OrgVOComparator implements Comparator<OrgVO> {@Overridepublic 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 pareTo(org2Str);}}