汇总单号信息,给秘书发邮件

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;

public class Lists {
    public static void main(String[] args) {
        List list = new ArrayList();
        list.add(new Student("00220581", "SSE201601"));
        list.add(new Student("00220582", "SSE201602"));
        list.add(new Student("00220583", "SSE201603"));
        list.add(new Student("00220581", "SSE201604"));
        list.add(new Student("00220581", "SSE201605"));
        list.add(new Student("00220582", "SSE201606"));
        list.add(new Student("00220582", "SSE201607"));
        list.add(new Student("00220583", "SSE201608"));
        groupSecretrySendMail(list);
    }

    public static void groupSecretrySendMail(List list) {
        Map mailList = new HashMap();
        Map mailParam = new HashMap();
        Iterator it = list.iterator();
        Student s = null;
        while (it.hasNext()) {
            s = (Student) it.next();
            StringBuffer listContent = (StringBuffer)mailList.get(s.getUu_code());
            if(null == listContent){
                listContent = new StringBuffer();
            }
            listContent = listContent.append(s.getFe_expenseno()).append(",");
            mailList.put(s.getUu_code(),listContent);
            s = null;
        }
        
        Set set  = mailList.keySet();
        Iterator iterator = set.iterator();
        while(iterator.hasNext()){
            String key = (String)iterator.next();
            System.out.println(key);
            System.out.print(mailList.get(key));
            System.out.println();
        }
    }
}

class Student {
    private String uu_code;
    private String fe_expenseno;

    public Student(String uu_code, String fe_expenseno) {
        super();
        this.uu_code = uu_code;
        this.fe_expenseno = fe_expenseno;
    }

    public String getUu_code() {
        return uu_code;
    }

    public void setUu_code(String uu_code) {
        this.uu_code = uu_code;
    }

    public String getFe_expenseno() {
        return fe_expenseno;
    }

    public void setFe_expenseno(String fe_expenseno) {
        this.fe_expenseno = fe_expenseno;
    }

}

 

posted @ 2016-08-11 13:01  chenxiangxiang  阅读(364)  评论(0编辑  收藏  举报