|
@@ -3,6 +3,7 @@ package com.jpsoft.printing.modules;
|
|
|
import com.github.pagehelper.Page;
|
|
|
import com.jpsoft.printing.config.OSSConfig;
|
|
|
import com.jpsoft.printing.modules.base.dto.NameValueDTO;
|
|
|
+import com.jpsoft.printing.modules.base.entity.Account;
|
|
|
import com.jpsoft.printing.modules.base.entity.Customer;
|
|
|
import com.jpsoft.printing.modules.base.service.AccountService;
|
|
|
import com.jpsoft.printing.modules.base.service.CustomerService;
|
|
@@ -48,9 +49,11 @@ public class ReportController {
|
|
|
public MessageResult transactionRanking(String startDay, String endDay, Integer limit){
|
|
|
MessageResult msgResult = new MessageResult<>();
|
|
|
|
|
|
- List<NameValueDTO> list = accountService.findTransactionRanking(startDay, endDay, limit);
|
|
|
- for(NameValueDTO dto : list){
|
|
|
- Customer customer = customerService.get(dto.getName());
|
|
|
+ List<Account> list = accountService.findTransactionList(0, startDay, endDay, "total_amount ASC", limit);
|
|
|
+ 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())) {
|
|
@@ -58,10 +61,10 @@ public class ReportController {
|
|
|
} else {
|
|
|
allName = customer.getName();
|
|
|
}
|
|
|
- dto.setName(allName);
|
|
|
+ account.setCustomerName(allName);
|
|
|
}
|
|
|
else {
|
|
|
- dto.setName(null);
|
|
|
+ account.setCustomerName(null);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -76,9 +79,11 @@ public class ReportController {
|
|
|
public MessageResult transactionRankingXls(String startDay, String endDay, Integer limit, String title) throws Exception {
|
|
|
MessageResult msgResult = new MessageResult<>();
|
|
|
|
|
|
- List<NameValueDTO> list = accountService.findTransactionRanking(startDay, endDay, limit);
|
|
|
- for(NameValueDTO dto : list){
|
|
|
- Customer customer = customerService.get(dto.getName());
|
|
|
+ List<Account> list = accountService.findTransactionList(0, startDay, endDay, "total_amount ASC", limit);
|
|
|
+ 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())) {
|
|
@@ -86,10 +91,10 @@ public class ReportController {
|
|
|
} else {
|
|
|
allName = customer.getName();
|
|
|
}
|
|
|
- dto.setName(allName);
|
|
|
+ account.setCustomerName(allName);
|
|
|
}
|
|
|
else {
|
|
|
- dto.setName(null);
|
|
|
+ account.setCustomerName(null);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -104,12 +109,12 @@ public class ReportController {
|
|
|
int rowNum = 2;
|
|
|
|
|
|
for(int i=0; i<list.size(); i++) {
|
|
|
- NameValueDTO dto = list.get(i);
|
|
|
+ Account account = list.get(i);
|
|
|
|
|
|
Row row = sheet.createRow(rowNum);
|
|
|
row.createCell(0).setCellValue(i+1);
|
|
|
- row.createCell(1).setCellValue(dto.getName());
|
|
|
- row.createCell(2).setCellValue(dto.getValue().toString());
|
|
|
+ row.createCell(1).setCellValue(account.getCustomerName());
|
|
|
+ row.createCell(2).setCellValue(account.getTotalAmount().toString());
|
|
|
|
|
|
rowNum++;
|
|
|
}
|
|
@@ -119,7 +124,7 @@ public class ReportController {
|
|
|
ByteArrayOutputStream output = new ByteArrayOutputStream();
|
|
|
wb.write(output);
|
|
|
String fileName = title + "(" + sdf.format(new Date()) + ").xls";
|
|
|
- String name = "D:\\" + fileName;
|
|
|
+ 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);
|
|
@@ -128,7 +133,38 @@ public class ReportController {
|
|
|
output.close();
|
|
|
|
|
|
msgResult.setResult(true);
|
|
|
- msgResult.setData(name);
|
|
|
+ msgResult.setMessage("报表生成完成。");
|
|
|
+ msgResult.setData("/printing-portal/xls/" + fileName);
|
|
|
+
|
|
|
+ return msgResult;
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value="交易报表-老板")
|
|
|
+ @RequestMapping(value = "transactionReportBoss",method = RequestMethod.POST)
|
|
|
+ public MessageResult transactionReportBoss(String startDay, String endDay){
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ msgResult.setResult(true);
|
|
|
+ msgResult.setData(list);
|
|
|
|
|
|
return msgResult;
|
|
|
}
|