|
@@ -168,4 +168,72 @@ public class ReportController {
|
|
|
|
|
|
return msgResult;
|
|
|
}
|
|
|
+
|
|
|
+ @ApiOperation(value="导出交易报表-老板")
|
|
|
+ @RequestMapping(value = "transactionReportBossXls",method = RequestMethod.POST)
|
|
|
+ public MessageResult transactionReportBossXls(String startDay, String endDay, String title) throws Exception {
|
|
|
+ MessageResult msgResult = new MessageResult<>();
|
|
|
+
|
|
|
+ List<Account> list = accountService.findTransactionList(0, startDay, endDay, "b.name_ ASC", null);
|
|
|
+ for(Account account : list){
|
|
|
+ account.setTotalAmount(account.getTotalAmount().negate());
|
|
|
+
|
|
|
+ Customer customer = customerService.get(account.getCustomerId());
|
|
|
+ if(customer != null) {
|
|
|
+ String allName = "";
|
|
|
+ if (StringUtils.isNotEmpty(customer.getCompany())) {
|
|
|
+ allName = customer.getName() + "(" + customer.getCompany() + ")";
|
|
|
+ } else {
|
|
|
+ allName = customer.getName();
|
|
|
+ }
|
|
|
+ account.setCustomerName(allName);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ account.setCustomerName(null);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ String xlsPath = "static/transactionReportBoss.xls";
|
|
|
+ ClassPathResource resource = new ClassPathResource(xlsPath);
|
|
|
+ Workbook wb = WorkbookFactory.create(resource.getInputStream());
|
|
|
+
|
|
|
+ //写入数据
|
|
|
+ Sheet sheet = wb.getSheetAt(0);
|
|
|
+ Row rowTitle = sheet.getRow(0);
|
|
|
+ rowTitle.getCell(0).setCellValue(title);
|
|
|
+ int rowNum = 2;
|
|
|
+
|
|
|
+ for(int i=0; i<list.size(); i++) {
|
|
|
+ Account account = list.get(i);
|
|
|
+
|
|
|
+ Row row = sheet.createRow(rowNum);
|
|
|
+ row.createCell(0).setCellValue(i+1);
|
|
|
+ row.createCell(1).setCellValue(account.getCustomerName());
|
|
|
+ row.createCell(2).setCellValue(account.getActualAmount().toString());
|
|
|
+ row.createCell(3).setCellValue(account.getClothAmount().toString());
|
|
|
+ row.createCell(4).setCellValue(account.getRollAmount().toString());
|
|
|
+ row.createCell(5).setCellValue(account.getTotalAmount().toString());
|
|
|
+
|
|
|
+ rowNum++;
|
|
|
+ }
|
|
|
+
|
|
|
+ //保存到服务器,返回文件名
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
|
|
|
+ ByteArrayOutputStream output = new ByteArrayOutputStream();
|
|
|
+ wb.write(output);
|
|
|
+ String fileName = title + "(" + sdf.format(new Date()) + ").xls";
|
|
|
+ String name = "D:\\JpSoft\\Tomcat 8.5\\webapps\\printing-portal\\xls\\" + fileName;
|
|
|
+ File file = new File(name);
|
|
|
+ FileOutputStream file1 = new FileOutputStream(file);
|
|
|
+ wb.write(file1);
|
|
|
+ file1.close();
|
|
|
+ wb.close();
|
|
|
+ output.close();
|
|
|
+
|
|
|
+ msgResult.setResult(true);
|
|
|
+ msgResult.setMessage("报表生成完成。");
|
|
|
+ msgResult.setData("/printing-portal/xls/" + fileName);
|
|
|
+
|
|
|
+ return msgResult;
|
|
|
+ }
|
|
|
}
|