package nc.pub.sap.sort;

import java.util.Comparator;

import nc.pub.sap.constant.SapConstants;
import nc.vo.sap.syproconfig.SyProConfigBVO;
/**
 * @Description: VOÅÅÐò
 * 
 * @author Ð»ÎÄÈç ¡¾±Ì¹ðÔ°SAP×¨Ïî¡¿
 * @date 2018-4-13
 * @version with NC V6.3
 */
@SuppressWarnings("rawtypes")
public class SapVOSort implements Comparator {

	private int direction = -1;
	public SapVOSort(int direction){
		this.direction = direction;
	}
	
	@Override
	public int compare(Object vo1, Object vo2) {
		if(vo1 instanceof SyProConfigBVO){
			SyProConfigBVO bVO1 = (SyProConfigBVO)vo1;
			SyProConfigBVO bVO2 = (SyProConfigBVO)vo2;
			Integer exe_order1 = 1;
			Integer exe_order2 = 1;
			if(SapConstants.DIRECTION_SAP2NC==direction){
				exe_order1 = bVO1.getExe_order_sn();
				exe_order2 = bVO2.getExe_order_sn();
				exe_order1 = exe_order1==null?1:exe_order1;
				exe_order2 = exe_order2==null?1:exe_order2;
			}else if(SapConstants.DIRECTION_NC2SAP==direction){
				exe_order1 = bVO1.getExe_order_ns();
				exe_order2 = bVO2.getExe_order_ns();
				exe_order1 = exe_order1==null?1:exe_order1;
				exe_order2 = exe_order2==null?1:exe_order2;
			}
			return exe_order1.compareTo(exe_order2);
		}
		return 0;
	}

}
