package market.Mes.util;

import java.util.Collections;
import java.util.Comparator;
import java.util.List;

import market.Mes.Dev.vo.DevBladeGrp;
import market.Mes.Lengthwise.Performance.vo.MesCrSlittingD;

/**
 * @author syh
 */
public class MesUtil {

	
	/**
	 * 按照List<MesCrSlittingD>中的某个xh类型的属性进行排序 
	 * @param list
	 */
	public static void sortIntMethod(List list){  
	    Collections.sort(list, new Comparator(){  
	        @Override  
	        public int compare(Object o1, Object o2) {  
	        	MesCrSlittingD m1=(MesCrSlittingD)o1;  
	        	MesCrSlittingD m2=(MesCrSlittingD)o2;  
	            if(m1.getXh()>m2.getXh()){  
	                return 1;  
	            }else if(m1.getXh()==m2.getXh()){  
	                return 0;  
	            }else{  
	                return -1;  
	            }  
	        }             
	    });  
	}  
	/**
	 * 按照List<DevBladeGrp>中的某个xh类型的属性进行排序 
	 * @param list
	 */
	public static void sortIntMethod2(List list){  
	    Collections.sort(list, new Comparator(){  
	        @Override  
	        public int compare(Object o1, Object o2) {  
	        	DevBladeGrp m1=(DevBladeGrp)o1;  
	        	DevBladeGrp m2=(DevBladeGrp)o2;  
	            if(m1.getXh()>m2.getXh()){  
	                return 1;  
	            }else if(m1.getXh()==m2.getXh()){  
	                return 0;  
	            }else{  
	                return -1;  
	            }  
	        }             
	    });  
	}  
	
	/*
	public static void main(String[] args){
		MesCrSlittingD mm1=new MesCrSlittingD();
		mm1.setXh(7);
		mm1.setCoil_no("Y1830914F0107");
		MesCrSlittingD mm2=new MesCrSlittingD();
		mm2.setXh(10);
		mm2.setCoil_no("Y1830914F0110");
		MesCrSlittingD mm3=new MesCrSlittingD();
		mm3.setXh(2);
		mm3.setCoil_no("Y1830914F0102");
		MesCrSlittingD mm4=new MesCrSlittingD();
		mm4.setXh(4);
		mm4.setCoil_no("Y1830914F0104");
		List<MesCrSlittingD> list=new ArrayList<>();
		list.add(mm1);
		list.add(mm2);
		list.add(mm3);
		list.add(mm4);
		
	    System.out.println("/////////////排序之前///////////////");  
	    for(MesCrSlittingD st:list){  
	        System.out.println("st.xh="+st.getXh()+",st.coilno="+st.getCoil_no());  
	    }  
	    sortIntMethod(list);
	    System.out.println("/////////////排序之后///////////////");  
	    for(MesCrSlittingD st:list){  
	        System.out.println("st.xh="+st.getXh()+",st.coilno="+st.getCoil_no());  
	    } 
	}
	*/
}
