|
|
@ -128,243 +128,246 @@ public class InventoryService extends ServiceImpl<InventoryMapper, Inventory> { |
|
|
|
prodStock.setProSid(inventory.getMateriel_id()); |
|
|
|
prodStock.setCusterName(data.get(0).get("custerName").toString()); |
|
|
|
prodStock.setCusterSid(records1.get(0).getSid()); |
|
|
|
prodStock.setLocationId("0"); |
|
|
|
prodStock.setLocationNumber("0"); |
|
|
|
prodStockList.add(prodStock); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
prodStockMap.put("list", prodStockList); |
|
|
|
String s = JSON.toJSONString(prodStockMap); |
|
|
|
HttpRequest.post("http://jianguan.yyundong.com/warehouseapi/stock/importStock").body(s).execute(); |
|
|
|
//导出报表
|
|
|
|
ThreadUtil.execute(() -> { |
|
|
|
try { |
|
|
|
exportExcel(map); |
|
|
|
}catch (Exception e){ |
|
|
|
e.printStackTrace(); |
|
|
|
} |
|
|
|
}); |
|
|
|
HttpResponse execute = HttpRequest.post("http://jianguan.yyundong.com/warehouseapi/stock/importStock").body(s).execute(); |
|
|
|
System.out.println(execute); |
|
|
|
//导出报表 暂时在此项目中不需要导出Excel报表
|
|
|
|
// ThreadUtil.execute(() -> {
|
|
|
|
// try {
|
|
|
|
// exportExcel(map);
|
|
|
|
// }catch (Exception e){
|
|
|
|
// e.printStackTrace();
|
|
|
|
// }
|
|
|
|
// });
|
|
|
|
return rb.success().setMsg("添加成功"); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 添加到数据库数据时生成的表格 |
|
|
|
* @param mapList 导出数据 |
|
|
|
* @throws Exception |
|
|
|
*/ |
|
|
|
public void exportExcel(Map<String, List<com.yxt.supervise.gf.shanhai.resp.Inventory>> mapList) throws Exception { |
|
|
|
SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd"); |
|
|
|
Date date = new Date(); |
|
|
|
XSSFWorkbook wb = new XSSFWorkbook(); |
|
|
|
List<Map<String, Object>> listMap1 = new ArrayList<>();//存储汇总数据
|
|
|
|
mapList.forEach((k,v) -> { |
|
|
|
HashMap<String, Object> mapCount = new HashMap<>(); |
|
|
|
Integer sumCount = v.stream().mapToInt(it -> Integer.parseInt(it.getNum())).sum(); |
|
|
|
Double priceCount = v.stream().mapToDouble(it -> Integer.parseInt(it.getNum()) * it.getPrice()).sum(); |
|
|
|
mapCount.put("name",k); |
|
|
|
mapCount.put("sumCount",sumCount); |
|
|
|
mapCount.put("priceCount",priceCount); |
|
|
|
listMap1.add(mapCount); |
|
|
|
}); |
|
|
|
//汇总工作簿
|
|
|
|
String[] collectHead = {"序号","仓库名称","物料数量","货值"}; |
|
|
|
Sheet stuSheeth = wb.createSheet("汇总"); |
|
|
|
Row headRowh = stuSheeth.createRow(0); //第一行为头
|
|
|
|
Font head1h = wb.createFont(); |
|
|
|
head1h.setFontHeightInPoints((short) 25); |
|
|
|
CellStyle cellStyleh = wb.createCellStyle(); |
|
|
|
cellStyleh.setFont(head1h); |
|
|
|
cellStyleh.setAlignment(HorizontalAlignment.CENTER); //设置水平对齐方式
|
|
|
|
cellStyleh.setVerticalAlignment(VerticalAlignment.CENTER); //设置垂直对齐方式
|
|
|
|
CellRangeAddress callRangeAddressh = new CellRangeAddress(0,0,0,collectHead.length-1); |
|
|
|
Cell cell1h = headRowh.createCell(0); |
|
|
|
cell1h.setCellStyle(cellStyleh); |
|
|
|
cell1h.setCellValue("库存汇总"); |
|
|
|
stuSheeth.addMergedRegion(callRangeAddressh); |
|
|
|
//设置表头字体大小
|
|
|
|
Font font1h = wb.createFont(); |
|
|
|
font1h.setFontHeightInPoints((short) 16); |
|
|
|
//获取表头行
|
|
|
|
Row titleRowh = stuSheeth.createRow(1); |
|
|
|
CellStyle styleh = wb.createCellStyle(); |
|
|
|
Font fonth = wb.createFont(); |
|
|
|
fonth.setFontHeightInPoints((short) 16); |
|
|
|
styleh.setVerticalAlignment(VerticalAlignment.CENTER); |
|
|
|
styleh.setAlignment(HorizontalAlignment.CENTER); |
|
|
|
styleh.setShrinkToFit(true); //自动伸缩
|
|
|
|
styleh.setFont(fonth); |
|
|
|
Cell cell = null; |
|
|
|
//把已经写好的标题行写入excel文件中
|
|
|
|
for (int i = 0; i < collectHead.length; i++) { |
|
|
|
cell = titleRowh.createCell(i); |
|
|
|
cell.setCellValue(collectHead[i]); |
|
|
|
cell.setCellStyle(styleh); |
|
|
|
} |
|
|
|
//把从数据库中取得的数据一一写入excel文件中
|
|
|
|
Row rowh = null; |
|
|
|
Cell cell2h = null; |
|
|
|
CellStyle dataStyleh = wb.createCellStyle(); |
|
|
|
dataStyleh.setVerticalAlignment(VerticalAlignment.CENTER); //设置垂直对齐方式
|
|
|
|
dataStyleh.setAlignment(HorizontalAlignment.CENTER); //设置水平对齐方式
|
|
|
|
Integer numSum = 0; |
|
|
|
Double countSum = 0.0; |
|
|
|
for (int i = 0; i < listMap1.size(); i++) { |
|
|
|
//创建list.size()行数据
|
|
|
|
rowh = stuSheeth.createRow(i + 2); |
|
|
|
//把值一一写进单元格里
|
|
|
|
//设置第一列为自动递增的序号
|
|
|
|
cell2h = rowh.createCell(0); |
|
|
|
cell2h.setCellValue(i + 1); |
|
|
|
cell2h.setCellStyle(dataStyleh); |
|
|
|
cell2h = rowh.createCell(1); |
|
|
|
cell2h.setCellValue(listMap1.get(i).get("name").toString()); |
|
|
|
cell2h.setCellStyle(dataStyleh); |
|
|
|
cell2h = rowh.createCell(2); |
|
|
|
cell2h.setCellValue(listMap1.get(i).get("sumCount").toString()); |
|
|
|
numSum+=Integer.parseInt(listMap1.get(i).get("sumCount").toString()); |
|
|
|
cell2h.setCellStyle(dataStyleh); |
|
|
|
cell2h = rowh.createCell(3); |
|
|
|
DecimalFormat df = new DecimalFormat("#0.00"); |
|
|
|
cell2h.setCellValue(df.format(listMap1.get(i).get("priceCount"))); |
|
|
|
countSum+=Double.parseDouble(df.format(listMap1.get(i).get("priceCount"))); |
|
|
|
cell2h.setCellStyle(dataStyleh); |
|
|
|
} |
|
|
|
fonth.setFontHeightInPoints((short) 14); |
|
|
|
Row row1h = stuSheeth.createRow(listMap1.size()+2); |
|
|
|
CellStyle style11h = wb.createCellStyle(); |
|
|
|
style11h.setVerticalAlignment(VerticalAlignment.CENTER); //设置垂直对齐方式
|
|
|
|
style11h.setAlignment(HorizontalAlignment.CENTER); |
|
|
|
style11h.setFont(fonth); |
|
|
|
Cell cell11h = row1h.createCell(0); |
|
|
|
cell11h.setCellStyle(style11h); |
|
|
|
cell11h.setCellValue("合计"); |
|
|
|
cell11h = row1h.createCell(2); |
|
|
|
cell11h.setCellStyle(style11h); |
|
|
|
cell11h.setCellValue(numSum); |
|
|
|
cell11h = row1h.createCell(3); |
|
|
|
cell11h.setCellStyle(style11h); |
|
|
|
cell11h.setCellValue(countSum); |
|
|
|
//设置单元格宽度自适应,在此基础上把宽度调至1.5倍
|
|
|
|
for (int i = 0; i < collectHead.length; i++) { |
|
|
|
stuSheeth.autoSizeColumn(i, true); |
|
|
|
stuSheeth.setColumnWidth(i, stuSheeth.getColumnWidth(i) * 15 / 10); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
for (Map.Entry<String, List<com.yxt.supervise.gf.shanhai.resp.Inventory>> stringListEntry : mapList.entrySet()) { |
|
|
|
//标题行抽出字段
|
|
|
|
String[] head = {"序号","仓库名称","物料组","物料编码","物料名称","物料品牌","物料单价","库存数量","货值"}; |
|
|
|
//设置sheet名称,并创建新的sheet对象
|
|
|
|
Sheet stuSheet = wb.createSheet(stringListEntry.getKey()); |
|
|
|
//合并单元格
|
|
|
|
Row headRow = stuSheet.createRow(0); //第一行为头
|
|
|
|
Font head1 = wb.createFont(); |
|
|
|
head1.setFontHeightInPoints((short) 25); |
|
|
|
CellStyle cellStyle = wb.createCellStyle(); |
|
|
|
cellStyle.setFont(head1); |
|
|
|
cellStyle.setAlignment(HorizontalAlignment.CENTER); //设置水平对齐方式
|
|
|
|
cellStyle.setVerticalAlignment(VerticalAlignment.CENTER); //设置垂直对齐方式
|
|
|
|
CellRangeAddress callRangeAddress = new CellRangeAddress(0,0,0,head.length-1); |
|
|
|
Cell cell1 = headRow.createCell(0); |
|
|
|
cell1.setCellStyle(cellStyle); |
|
|
|
cell1.setCellValue(stringListEntry.getKey() + "("+ sdf1.format(date) +")"); |
|
|
|
stuSheet.addMergedRegion(callRangeAddress); |
|
|
|
//设置表头字体大小
|
|
|
|
Font font1 = wb.createFont(); |
|
|
|
font1.setFontHeightInPoints((short) 16); |
|
|
|
//获取表头行
|
|
|
|
Row titleRow = stuSheet.createRow(1); |
|
|
|
//创建单元格,设置style居中,字体,单元格大小等
|
|
|
|
CellStyle style = wb.createCellStyle(); |
|
|
|
style.setVerticalAlignment(VerticalAlignment.CENTER); //设置垂直对齐方式
|
|
|
|
style.setAlignment(HorizontalAlignment.CENTER); |
|
|
|
style.setShrinkToFit(true); //自动伸缩
|
|
|
|
style.setFont(font1); |
|
|
|
Cell cellh = null; |
|
|
|
//把已经写好的标题行写入excel文件中
|
|
|
|
for (int i = 0; i < head.length; i++) { |
|
|
|
cellh = titleRow.createCell(i); |
|
|
|
cellh.setCellValue(head[i]); |
|
|
|
cellh.setCellStyle(style); |
|
|
|
} |
|
|
|
//把从数据库中取得的数据一一写入excel文件中
|
|
|
|
Row row = null; |
|
|
|
Cell cell2 = null; |
|
|
|
Double count = 0.0; |
|
|
|
Integer numCount = 0; |
|
|
|
CellStyle dataStyle = wb.createCellStyle(); |
|
|
|
dataStyle.setVerticalAlignment(VerticalAlignment.CENTER); //设置垂直对齐方式
|
|
|
|
dataStyle.setAlignment(HorizontalAlignment.CENTER); //设置水平对齐方式
|
|
|
|
for (int i = 0; i < stringListEntry.getValue().size(); i++) { |
|
|
|
//创建list.size()行数据
|
|
|
|
row = stuSheet.createRow(i + 2); |
|
|
|
//把值一一写进单元格里
|
|
|
|
//设置第一列为自动递增的序号
|
|
|
|
cell2 = row.createCell(0); |
|
|
|
cell2.setCellValue(i + 1); |
|
|
|
cell2.setCellStyle(dataStyle); |
|
|
|
cell2 = row.createCell(1); |
|
|
|
cell2.setCellValue(stringListEntry.getValue().get(i).getStorehouse_name()); |
|
|
|
numCount+=Integer.parseInt(stringListEntry.getValue().get(i).getNum()); |
|
|
|
cell2.setCellStyle(dataStyle); |
|
|
|
cell2 = row.createCell(2); |
|
|
|
cell2.setCellValue(stringListEntry.getValue().get(i).getMateriel_group_text()); |
|
|
|
cell2.setCellStyle(dataStyle); |
|
|
|
cell2 = row.createCell(3); |
|
|
|
cell2.setCellValue(stringListEntry.getValue().get(i).getMateriel_no()); |
|
|
|
cell2.setCellStyle(dataStyle); |
|
|
|
cell2 = row.createCell(4); |
|
|
|
cell2.setCellValue(stringListEntry.getValue().get(i).getMateriel_name()); |
|
|
|
cell2.setCellStyle(dataStyle); |
|
|
|
cell2 = row.createCell(5); |
|
|
|
cell2.setCellValue(stringListEntry.getValue().get(i).getBrand_name()); |
|
|
|
cell2.setCellStyle(dataStyle); |
|
|
|
Double price = stringListEntry.getValue().get(i).getPrice(); |
|
|
|
if (price == null){ |
|
|
|
price = 0.0; |
|
|
|
} |
|
|
|
cell2 = row.createCell(6); |
|
|
|
cell2.setCellValue(price); |
|
|
|
cell2.setCellStyle(dataStyle); |
|
|
|
cell2 = row.createCell(7); |
|
|
|
cell2.setCellValue(stringListEntry.getValue().get(i).getNum()); |
|
|
|
cell2.setCellStyle(dataStyle); |
|
|
|
Double i1 = Integer.parseInt(stringListEntry.getValue().get(i).getNum()) * price; |
|
|
|
cell2 = row.createCell(8); |
|
|
|
cell2.setCellValue(i1); |
|
|
|
cell2.setCellStyle(dataStyle); |
|
|
|
count+=i1; |
|
|
|
} |
|
|
|
Font font = wb.createFont(); |
|
|
|
font.setFontHeightInPoints((short) 14); |
|
|
|
Row row1 = stuSheet.createRow(stringListEntry.getValue().size()+2); |
|
|
|
CellStyle style11 = wb.createCellStyle(); |
|
|
|
style11.setVerticalAlignment(VerticalAlignment.CENTER); //设置垂直对齐方式
|
|
|
|
style11.setAlignment(HorizontalAlignment.CENTER); |
|
|
|
style11.setFont(font); |
|
|
|
Cell cell11 = row1.createCell(0); |
|
|
|
cell11.setCellStyle(style11); |
|
|
|
cell11.setCellValue("合计"); |
|
|
|
cell11 = row1.createCell(8); |
|
|
|
cell11.setCellStyle(style11); |
|
|
|
cell11.setCellValue(count); |
|
|
|
//设置单元格宽度自适应,在此基础上把宽度调至1.5倍
|
|
|
|
for (int i = 0; i < head.length; i++) { |
|
|
|
stuSheet.autoSizeColumn(i, true); |
|
|
|
stuSheet.setColumnWidth(i, stuSheet.getColumnWidth(i) * 15 / 10); |
|
|
|
} |
|
|
|
} |
|
|
|
File file = new File(filePath); |
|
|
|
if (!file.exists()) { |
|
|
|
file.mkdirs(); |
|
|
|
} |
|
|
|
//设置文件名
|
|
|
|
String fileName = "山海仓库库存" + sdf1.format(new Date()) + ".xlsx"; |
|
|
|
String savePath = filePath + File.separator + fileName; |
|
|
|
//下载
|
|
|
|
OutputStream fileOut = new FileOutputStream(savePath); |
|
|
|
wb.write(fileOut); |
|
|
|
fileOut.close(); |
|
|
|
} |
|
|
|
// /**
|
|
|
|
// * 添加到数据库数据时生成的表格
|
|
|
|
// * @param mapList 导出数据
|
|
|
|
// * @throws Exception
|
|
|
|
// */
|
|
|
|
// public void exportExcel(Map<String, List<com.yxt.supervise.gf.shanhai.resp.Inventory>> mapList) throws Exception {
|
|
|
|
// SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
|
// Date date = new Date();
|
|
|
|
// XSSFWorkbook wb = new XSSFWorkbook();
|
|
|
|
// List<Map<String, Object>> listMap1 = new ArrayList<>();//存储汇总数据
|
|
|
|
// mapList.forEach((k,v) -> {
|
|
|
|
// HashMap<String, Object> mapCount = new HashMap<>();
|
|
|
|
// Integer sumCount = v.stream().mapToInt(it -> Integer.parseInt(it.getNum())).sum();
|
|
|
|
// Double priceCount = v.stream().mapToDouble(it -> Integer.parseInt(it.getNum()) * it.getPrice()).sum();
|
|
|
|
// mapCount.put("name",k);
|
|
|
|
// mapCount.put("sumCount",sumCount);
|
|
|
|
// mapCount.put("priceCount",priceCount);
|
|
|
|
// listMap1.add(mapCount);
|
|
|
|
// });
|
|
|
|
// //汇总工作簿
|
|
|
|
// String[] collectHead = {"序号","仓库名称","物料数量","货值"};
|
|
|
|
// Sheet stuSheeth = wb.createSheet("汇总");
|
|
|
|
// Row headRowh = stuSheeth.createRow(0); //第一行为头
|
|
|
|
// Font head1h = wb.createFont();
|
|
|
|
// head1h.setFontHeightInPoints((short) 25);
|
|
|
|
// CellStyle cellStyleh = wb.createCellStyle();
|
|
|
|
// cellStyleh.setFont(head1h);
|
|
|
|
// cellStyleh.setAlignment(HorizontalAlignment.CENTER); //设置水平对齐方式
|
|
|
|
// cellStyleh.setVerticalAlignment(VerticalAlignment.CENTER); //设置垂直对齐方式
|
|
|
|
// CellRangeAddress callRangeAddressh = new CellRangeAddress(0,0,0,collectHead.length-1);
|
|
|
|
// Cell cell1h = headRowh.createCell(0);
|
|
|
|
// cell1h.setCellStyle(cellStyleh);
|
|
|
|
// cell1h.setCellValue("库存汇总");
|
|
|
|
// stuSheeth.addMergedRegion(callRangeAddressh);
|
|
|
|
// //设置表头字体大小
|
|
|
|
// Font font1h = wb.createFont();
|
|
|
|
// font1h.setFontHeightInPoints((short) 16);
|
|
|
|
// //获取表头行
|
|
|
|
// Row titleRowh = stuSheeth.createRow(1);
|
|
|
|
// CellStyle styleh = wb.createCellStyle();
|
|
|
|
// Font fonth = wb.createFont();
|
|
|
|
// fonth.setFontHeightInPoints((short) 16);
|
|
|
|
// styleh.setVerticalAlignment(VerticalAlignment.CENTER);
|
|
|
|
// styleh.setAlignment(HorizontalAlignment.CENTER);
|
|
|
|
// styleh.setShrinkToFit(true); //自动伸缩
|
|
|
|
// styleh.setFont(fonth);
|
|
|
|
// Cell cell = null;
|
|
|
|
// //把已经写好的标题行写入excel文件中
|
|
|
|
// for (int i = 0; i < collectHead.length; i++) {
|
|
|
|
// cell = titleRowh.createCell(i);
|
|
|
|
// cell.setCellValue(collectHead[i]);
|
|
|
|
// cell.setCellStyle(styleh);
|
|
|
|
// }
|
|
|
|
// //把从数据库中取得的数据一一写入excel文件中
|
|
|
|
// Row rowh = null;
|
|
|
|
// Cell cell2h = null;
|
|
|
|
// CellStyle dataStyleh = wb.createCellStyle();
|
|
|
|
// dataStyleh.setVerticalAlignment(VerticalAlignment.CENTER); //设置垂直对齐方式
|
|
|
|
// dataStyleh.setAlignment(HorizontalAlignment.CENTER); //设置水平对齐方式
|
|
|
|
// Integer numSum = 0;
|
|
|
|
// Double countSum = 0.0;
|
|
|
|
// for (int i = 0; i < listMap1.size(); i++) {
|
|
|
|
// //创建list.size()行数据
|
|
|
|
// rowh = stuSheeth.createRow(i + 2);
|
|
|
|
// //把值一一写进单元格里
|
|
|
|
// //设置第一列为自动递增的序号
|
|
|
|
// cell2h = rowh.createCell(0);
|
|
|
|
// cell2h.setCellValue(i + 1);
|
|
|
|
// cell2h.setCellStyle(dataStyleh);
|
|
|
|
// cell2h = rowh.createCell(1);
|
|
|
|
// cell2h.setCellValue(listMap1.get(i).get("name").toString());
|
|
|
|
// cell2h.setCellStyle(dataStyleh);
|
|
|
|
// cell2h = rowh.createCell(2);
|
|
|
|
// cell2h.setCellValue(listMap1.get(i).get("sumCount").toString());
|
|
|
|
// numSum+=Integer.parseInt(listMap1.get(i).get("sumCount").toString());
|
|
|
|
// cell2h.setCellStyle(dataStyleh);
|
|
|
|
// cell2h = rowh.createCell(3);
|
|
|
|
// DecimalFormat df = new DecimalFormat("#0.00");
|
|
|
|
// cell2h.setCellValue(df.format(listMap1.get(i).get("priceCount")));
|
|
|
|
// countSum+=Double.parseDouble(df.format(listMap1.get(i).get("priceCount")));
|
|
|
|
// cell2h.setCellStyle(dataStyleh);
|
|
|
|
// }
|
|
|
|
// fonth.setFontHeightInPoints((short) 14);
|
|
|
|
// Row row1h = stuSheeth.createRow(listMap1.size()+2);
|
|
|
|
// CellStyle style11h = wb.createCellStyle();
|
|
|
|
// style11h.setVerticalAlignment(VerticalAlignment.CENTER); //设置垂直对齐方式
|
|
|
|
// style11h.setAlignment(HorizontalAlignment.CENTER);
|
|
|
|
// style11h.setFont(fonth);
|
|
|
|
// Cell cell11h = row1h.createCell(0);
|
|
|
|
// cell11h.setCellStyle(style11h);
|
|
|
|
// cell11h.setCellValue("合计");
|
|
|
|
// cell11h = row1h.createCell(2);
|
|
|
|
// cell11h.setCellStyle(style11h);
|
|
|
|
// cell11h.setCellValue(numSum);
|
|
|
|
// cell11h = row1h.createCell(3);
|
|
|
|
// cell11h.setCellStyle(style11h);
|
|
|
|
// cell11h.setCellValue(countSum);
|
|
|
|
// //设置单元格宽度自适应,在此基础上把宽度调至1.5倍
|
|
|
|
// for (int i = 0; i < collectHead.length; i++) {
|
|
|
|
// stuSheeth.autoSizeColumn(i, true);
|
|
|
|
// stuSheeth.setColumnWidth(i, stuSheeth.getColumnWidth(i) * 15 / 10);
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// for (Map.Entry<String, List<com.yxt.supervise.gf.shanhai.resp.Inventory>> stringListEntry : mapList.entrySet()) {
|
|
|
|
// //标题行抽出字段
|
|
|
|
// String[] head = {"序号","仓库名称","物料组","物料编码","物料名称","物料品牌","物料单价","库存数量","货值"};
|
|
|
|
// //设置sheet名称,并创建新的sheet对象
|
|
|
|
// Sheet stuSheet = wb.createSheet(stringListEntry.getKey());
|
|
|
|
// //合并单元格
|
|
|
|
// Row headRow = stuSheet.createRow(0); //第一行为头
|
|
|
|
// Font head1 = wb.createFont();
|
|
|
|
// head1.setFontHeightInPoints((short) 25);
|
|
|
|
// CellStyle cellStyle = wb.createCellStyle();
|
|
|
|
// cellStyle.setFont(head1);
|
|
|
|
// cellStyle.setAlignment(HorizontalAlignment.CENTER); //设置水平对齐方式
|
|
|
|
// cellStyle.setVerticalAlignment(VerticalAlignment.CENTER); //设置垂直对齐方式
|
|
|
|
// CellRangeAddress callRangeAddress = new CellRangeAddress(0,0,0,head.length-1);
|
|
|
|
// Cell cell1 = headRow.createCell(0);
|
|
|
|
// cell1.setCellStyle(cellStyle);
|
|
|
|
// cell1.setCellValue(stringListEntry.getKey() + "("+ sdf1.format(date) +")");
|
|
|
|
// stuSheet.addMergedRegion(callRangeAddress);
|
|
|
|
// //设置表头字体大小
|
|
|
|
// Font font1 = wb.createFont();
|
|
|
|
// font1.setFontHeightInPoints((short) 16);
|
|
|
|
// //获取表头行
|
|
|
|
// Row titleRow = stuSheet.createRow(1);
|
|
|
|
// //创建单元格,设置style居中,字体,单元格大小等
|
|
|
|
// CellStyle style = wb.createCellStyle();
|
|
|
|
// style.setVerticalAlignment(VerticalAlignment.CENTER); //设置垂直对齐方式
|
|
|
|
// style.setAlignment(HorizontalAlignment.CENTER);
|
|
|
|
// style.setShrinkToFit(true); //自动伸缩
|
|
|
|
// style.setFont(font1);
|
|
|
|
// Cell cellh = null;
|
|
|
|
// //把已经写好的标题行写入excel文件中
|
|
|
|
// for (int i = 0; i < head.length; i++) {
|
|
|
|
// cellh = titleRow.createCell(i);
|
|
|
|
// cellh.setCellValue(head[i]);
|
|
|
|
// cellh.setCellStyle(style);
|
|
|
|
// }
|
|
|
|
// //把从数据库中取得的数据一一写入excel文件中
|
|
|
|
// Row row = null;
|
|
|
|
// Cell cell2 = null;
|
|
|
|
// Double count = 0.0;
|
|
|
|
// Integer numCount = 0;
|
|
|
|
// CellStyle dataStyle = wb.createCellStyle();
|
|
|
|
// dataStyle.setVerticalAlignment(VerticalAlignment.CENTER); //设置垂直对齐方式
|
|
|
|
// dataStyle.setAlignment(HorizontalAlignment.CENTER); //设置水平对齐方式
|
|
|
|
// for (int i = 0; i < stringListEntry.getValue().size(); i++) {
|
|
|
|
// //创建list.size()行数据
|
|
|
|
// row = stuSheet.createRow(i + 2);
|
|
|
|
// //把值一一写进单元格里
|
|
|
|
// //设置第一列为自动递增的序号
|
|
|
|
// cell2 = row.createCell(0);
|
|
|
|
// cell2.setCellValue(i + 1);
|
|
|
|
// cell2.setCellStyle(dataStyle);
|
|
|
|
// cell2 = row.createCell(1);
|
|
|
|
// cell2.setCellValue(stringListEntry.getValue().get(i).getStorehouse_name());
|
|
|
|
// numCount+=Integer.parseInt(stringListEntry.getValue().get(i).getNum());
|
|
|
|
// cell2.setCellStyle(dataStyle);
|
|
|
|
// cell2 = row.createCell(2);
|
|
|
|
// cell2.setCellValue(stringListEntry.getValue().get(i).getMateriel_group_text());
|
|
|
|
// cell2.setCellStyle(dataStyle);
|
|
|
|
// cell2 = row.createCell(3);
|
|
|
|
// cell2.setCellValue(stringListEntry.getValue().get(i).getMateriel_no());
|
|
|
|
// cell2.setCellStyle(dataStyle);
|
|
|
|
// cell2 = row.createCell(4);
|
|
|
|
// cell2.setCellValue(stringListEntry.getValue().get(i).getMateriel_name());
|
|
|
|
// cell2.setCellStyle(dataStyle);
|
|
|
|
// cell2 = row.createCell(5);
|
|
|
|
// cell2.setCellValue(stringListEntry.getValue().get(i).getBrand_name());
|
|
|
|
// cell2.setCellStyle(dataStyle);
|
|
|
|
// Double price = stringListEntry.getValue().get(i).getPrice();
|
|
|
|
// if (price == null){
|
|
|
|
// price = 0.0;
|
|
|
|
// }
|
|
|
|
// cell2 = row.createCell(6);
|
|
|
|
// cell2.setCellValue(price);
|
|
|
|
// cell2.setCellStyle(dataStyle);
|
|
|
|
// cell2 = row.createCell(7);
|
|
|
|
// cell2.setCellValue(stringListEntry.getValue().get(i).getNum());
|
|
|
|
// cell2.setCellStyle(dataStyle);
|
|
|
|
// Double i1 = Integer.parseInt(stringListEntry.getValue().get(i).getNum()) * price;
|
|
|
|
// cell2 = row.createCell(8);
|
|
|
|
// cell2.setCellValue(i1);
|
|
|
|
// cell2.setCellStyle(dataStyle);
|
|
|
|
// count+=i1;
|
|
|
|
// }
|
|
|
|
// Font font = wb.createFont();
|
|
|
|
// font.setFontHeightInPoints((short) 14);
|
|
|
|
// Row row1 = stuSheet.createRow(stringListEntry.getValue().size()+2);
|
|
|
|
// CellStyle style11 = wb.createCellStyle();
|
|
|
|
// style11.setVerticalAlignment(VerticalAlignment.CENTER); //设置垂直对齐方式
|
|
|
|
// style11.setAlignment(HorizontalAlignment.CENTER);
|
|
|
|
// style11.setFont(font);
|
|
|
|
// Cell cell11 = row1.createCell(0);
|
|
|
|
// cell11.setCellStyle(style11);
|
|
|
|
// cell11.setCellValue("合计");
|
|
|
|
// cell11 = row1.createCell(8);
|
|
|
|
// cell11.setCellStyle(style11);
|
|
|
|
// cell11.setCellValue(count);
|
|
|
|
// //设置单元格宽度自适应,在此基础上把宽度调至1.5倍
|
|
|
|
// for (int i = 0; i < head.length; i++) {
|
|
|
|
// stuSheet.autoSizeColumn(i, true);
|
|
|
|
// stuSheet.setColumnWidth(i, stuSheet.getColumnWidth(i) * 15 / 10);
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// File file = new File(filePath);
|
|
|
|
// if (!file.exists()) {
|
|
|
|
// file.mkdirs();
|
|
|
|
// }
|
|
|
|
// //设置文件名
|
|
|
|
// String fileName = "山海仓库库存" + sdf1.format(new Date()) + ".xlsx";
|
|
|
|
// String savePath = filePath + File.separator + fileName;
|
|
|
|
// //下载
|
|
|
|
// OutputStream fileOut = new FileOutputStream(savePath);
|
|
|
|
// wb.write(fileOut);
|
|
|
|
// fileOut.close();
|
|
|
|
// }
|
|
|
|
|
|
|
|
public PagerVo<InventoryVo> listPage(PagerQuery<InventoryQuery> pq){ |
|
|
|
InventoryQuery params = pq.getParams(); |
|
|
|