EXcelテーブルへのデータのエクスポート
26950 ワード
データのエクスポート
@PostMapping("/commodityInventoryExportExcel")
@ApiOperation(" ( )")
public void commodityInventoryExportExcel(@RequestParam Integer id, HttpServletResponse response){
ExcelData data = new ExcelData();
data.setName(" ");
List<String> titles = new ArrayList<>();
titles.add(" ");
titles.add(" ");
titles.add(" ");
titles.add(" ");
titles.add(" ");
titles.add(" ");
titles.add(" ");
titles.add(" ");
titles.add(" ");
titles.add(" ");
titles.add(" ");
titles.add(" ");
titles.add(" ");
titles.add(" ");
titles.add(" ");
titles.add(" ");
titles.add(" ");
data.setTitles(titles);
List<CommodityInventoryDetail> commodityInventoryDetailList = commodityInventoryDetailService.getListByCommodityInventoryId(id);
List<List<Object>> rows = new ArrayList<>();
for (int i = 0; i < commodityInventoryDetailList.size(); i++) {
List<Object> row = new ArrayList<>();
row.add(i+1);
row.add(commodityInventoryDetailList.get(i).getCategoriesName());//
row.add(commodityInventoryDetailList.get(i).getCommodityName());//
WarehouseManagement warehouseManagement = warehouseManagementService.findWarehouseByStorageDetailId(commodityInventoryDetailList.get(i).getWarehouseId());
if (warehouseManagement!=null) {
row.add(warehouseManagement.getWarehouseManagement().getWarehouseManagement().getName());//
row.add(warehouseManagement.getWarehouseManagement().getName());//
row.add(warehouseManagement.getName());//
}
row.add(commodityInventoryDetailList.get(i).getUnit());//
row.add(commodityInventoryDetailList.get(i).getOriginalNum());//
row.add(commodityInventoryDetailList.get(i).getInventoryNum());//
row.add(commodityInventoryDetailList.get(i).getLost()==0?"":commodityInventoryDetailList.get(i).getLost());//
row.add(commodityInventoryDetailList.get(i).getOverFlow()==0?"":commodityInventoryDetailList.get(i).getOverFlow());//
row.add(commodityInventoryDetailList.get(i).getCostPrice());//
//
if (commodityInventoryDetailList.get(i).getLost()!=0) {
commodityInventoryDetailList.get(i).setSum((commodityInventoryDetailList.get(i).getLost())*commodityInventoryDetailList.get(i).getCostPrice());
} else if (commodityInventoryDetailList.get(i).getOverFlow()!=0){
commodityInventoryDetailList.get(i).setSum((commodityInventoryDetailList.get(i).getOverFlow())*commodityInventoryDetailList.get(i).getCostPrice());
}
row.add(commodityInventoryDetailList.get(i).getSum());//
row.add(commodityInventoryDetailList.get(i).getRemark());//
row.add(commodityInventoryDetailList.get(i).getUpdateBy());//
row.add(commodityInventoryDetailList.get(i).getUpdateTime());//
if(commodityInventoryDetailList.get(i).getStatus()==0){//
row.add("");
}else {
row.add(" ");
}
rows.add(i,row);
}
data.setRows(rows);
try {
ExcelUtils.exportExcel(data, response);
} catch (Exception e) {
e.printStackTrace();
}
}