50,707
社区成员
发帖
与我相关
我的任务
分享
public static void main(String[] args) {
List<Sheet1> ls1=getSheet1();
List<Sheet2> ls2=getSheet2();
List<SheetAll> lsa=new ArrayList<SheetAll>();
SheetAll sa=null;
for (Sheet1 sheet1 : ls1) {
Double total=sheet1.getTotal();
for(Sheet2 sheet2 : ls2){
Double qty=sheet2.getQuantity();
Double times=total/qty;
if(sheet1.getModelNo()!=null && sheet1.getModelNo().equals(sheet2.getModel())){
for(int i=0;i<times;i++){
sa=new SheetAll();
sa.setContainerNo(sheet1.getContainerNo());
sa.setModelNo(sheet1.getModelNo());
sa.setLocation(sheet2.getLocation());
sa.setDate(sheet2.getDate());
if(total>qty){
sa.setQuantity(qty);
total=total-sheet2.getQuantity();
}else{
sa.setQuantity(total);
}
lsa.add(sa);
}
}
}
}
for (SheetAll sheetAll : lsa) {
System.out.println(sheetAll.getContainerNo()+"\t"+sheetAll.getModelNo()+"\t"+sheetAll.getLocation()+"\t"+sheetAll.getQuantity()+"\t"+sheetAll.getDate());
}
}
public static List<Sheet1> getSheet1(){
List<Sheet1> ls=new ArrayList<Sheet1>();
ls.add(new Sheet1("CN1", "MN1", 2000.0));
ls.add(new Sheet1("CN2", "MN2", 5000.0));
ls.add(new Sheet1("CN3", "MN3", 8000.0));
return ls;
}
public static List<Sheet2> getSheet2(){
List<Sheet2> ls=new ArrayList<Sheet2>();
ls.add(new Sheet2("MN1", "L1", 800.0,"2018-07-08"));
ls.add(new Sheet2("MN2", "l2", 1500.0,"2018-07-09"));
ls.add(new Sheet2("MN3", "l3", 1000.0,"2018-07-10"));
return ls;
}
private String ContainerNo;
private String ModelNo;
private Double total;
private String model;
private String location;
private Double quantity;
private String date;
private String ContainerNo;
private String ModelNo;
private String location;
private Double quantity;
private String date;