dev
parent
33dba4ef79
commit
c7c18bd88e
|
|
@ -1516,9 +1516,78 @@ public class OrderStatService {
|
||||||
row = sheet.createRow(i + 1);
|
row = sheet.createRow(i + 1);
|
||||||
a = 0;
|
a = 0;
|
||||||
row.createCell(a++).setCellValue(order.getStr("name"));
|
row.createCell(a++).setCellValue(order.getStr("name"));
|
||||||
if(order.get("cnt") != null){
|
if (order.get("cnt") != null) {
|
||||||
row.createCell(a++).setCellValue(order.getInt("cnt"));
|
row.createCell(a++).setCellValue(order.getInt("cnt"));
|
||||||
}else{
|
} else {
|
||||||
|
row.createCell(a++).setCellValue("");
|
||||||
|
}
|
||||||
|
row.createCell(a++).setCellValue(DataUtil.getDefaultByRecord(order, "total_weight"));
|
||||||
|
row.createCell(a++).setCellValue(DataUtil.getDefaultByRecord(order, "total_price"));
|
||||||
|
}
|
||||||
|
|
||||||
|
ReportExcelStyle.setCommonCellStyle(wb, sheet, datalen, end_col);
|
||||||
|
|
||||||
|
return wb;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Record> yearStatBySup(String stm, String etm) {
|
||||||
|
List<Record> list = Db.find("select s.id, s.name, a.cnt, a.total_price, a.total_weight from supermarket s\n" +
|
||||||
|
"left join (\n" +
|
||||||
|
" select t.supermarket_id id, count(t.sn) cnt, sum(t.total_price) total_price, sum(weight) total_weight from order_temp t\n" +
|
||||||
|
" where t.state = 5\n" +
|
||||||
|
" and t.create_time >= ? \n" +
|
||||||
|
" and t.create_time <= ? \n" +
|
||||||
|
" group by t.supermarket_id\n" +
|
||||||
|
") a on s.id = a.id order by s.id", stm, etm);
|
||||||
|
|
||||||
|
Record hj = new Record();
|
||||||
|
hj.set("id", 0);
|
||||||
|
hj.set("name", "合计");
|
||||||
|
hj.set("cnt", 0);
|
||||||
|
hj.set("total_price", new BigDecimal(0));
|
||||||
|
hj.set("total_weight", new BigDecimal(0));
|
||||||
|
|
||||||
|
for (Record record : list) {
|
||||||
|
if (record.get("cnt") != null) {
|
||||||
|
hj.set("cnt", hj.getInt("cnt") + record.getInt("cnt"));
|
||||||
|
}
|
||||||
|
if (record.get("total_price") != null) {
|
||||||
|
hj.set("total_price", hj.getBigDecimal("total_price").add(record.getBigDecimal("total_price")));
|
||||||
|
}
|
||||||
|
if (record.get("total_weight") != null) {
|
||||||
|
hj.set("total_weight", hj.getBigDecimal("total_weight").add(record.getBigDecimal("total_weight")));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
list.add(hj);
|
||||||
|
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Workbook yearStatBySupExport(String stm, String etm) {
|
||||||
|
List<Record> list = yearStatBySup(stm, etm);
|
||||||
|
Workbook wb = new XSSFWorkbook();
|
||||||
|
Sheet sheet = wb.createSheet(stm.substring(0, 10) + " ~ " + etm.substring(0, 10) + "年销售汇总");
|
||||||
|
|
||||||
|
// 表头 start
|
||||||
|
Row row = sheet.createRow(0);
|
||||||
|
int a = 0;
|
||||||
|
row.createCell(a++).setCellValue("名称");
|
||||||
|
row.createCell(a++).setCellValue("订单量");
|
||||||
|
row.createCell(a++).setCellValue("总销售吨数");
|
||||||
|
row.createCell(a++).setCellValue("总销售额");
|
||||||
|
|
||||||
|
int end_col = 4;
|
||||||
|
int datalen = list.size();
|
||||||
|
for (int i = 0; i < datalen; i++) {
|
||||||
|
Record order = list.get(i);
|
||||||
|
|
||||||
|
row = sheet.createRow(i + 1);
|
||||||
|
a = 0;
|
||||||
|
row.createCell(a++).setCellValue(order.getStr("name"));
|
||||||
|
if (order.get("cnt") != null) {
|
||||||
|
row.createCell(a++).setCellValue(order.getInt("cnt"));
|
||||||
|
} else {
|
||||||
row.createCell(a++).setCellValue("");
|
row.createCell(a++).setCellValue("");
|
||||||
}
|
}
|
||||||
row.createCell(a++).setCellValue(DataUtil.getDefaultByRecord(order, "total_weight"));
|
row.createCell(a++).setCellValue(DataUtil.getDefaultByRecord(order, "total_weight"));
|
||||||
|
|
@ -1595,6 +1664,103 @@ public class OrderStatService {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 表头 start
|
||||||
|
Row row = sheet.createRow(0);
|
||||||
|
int a = 0;
|
||||||
|
row.createCell(a++).setCellValue("名称");
|
||||||
|
row.createCell(a++).setCellValue("订单量");
|
||||||
|
row.createCell(a++).setCellValue("总销售吨数");
|
||||||
|
row.createCell(a++).setCellValue("总销售额");
|
||||||
|
row.createCell(a++).setCellValue("客户总余额");
|
||||||
|
|
||||||
|
int end_col = 5;
|
||||||
|
int datalen = list.size();
|
||||||
|
Record hj = null;
|
||||||
|
|
||||||
|
for (int i = 0; i < datalen; i++) {
|
||||||
|
Record order = list.get(i);
|
||||||
|
|
||||||
|
row = sheet.createRow(i + 1);
|
||||||
|
a = 0;
|
||||||
|
|
||||||
|
if (order.getInt("id") == 0) {
|
||||||
|
hj = order;
|
||||||
|
}
|
||||||
|
|
||||||
|
row.createCell(a++).setCellValue(order.getStr("name"));
|
||||||
|
row.createCell(a++).setCellValue(order.getInt("cnt"));
|
||||||
|
row.createCell(a++).setCellValue(DataUtil.getDefaultByRecord(order, "total_weight"));
|
||||||
|
row.createCell(a++).setCellValue(DataUtil.getDefaultByRecord(order, "total_price"));
|
||||||
|
row.createCell(a++).setCellValue(DataUtil.getDefaultByRecord(order, "total_surplus"));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hj != null) {
|
||||||
|
row = sheet.createRow(datalen + 1);
|
||||||
|
a = 0;
|
||||||
|
|
||||||
|
row.createCell(a++).setCellValue("账户总余额");
|
||||||
|
row.createCell(a++).setCellValue("");
|
||||||
|
row.createCell(a++).setCellValue("");
|
||||||
|
row.createCell(a++).setCellValue(DataUtil.getDefaultByRecord(hj, "total_account_surplus"));
|
||||||
|
row.createCell(a++).setCellValue("");
|
||||||
|
}
|
||||||
|
|
||||||
|
sheet.addMergedRegion(new CellRangeAddress(datalen + 1, datalen + 1, 3, 4));// 下标从0开始 起始行号,终止行号, 起始列号,终止列号
|
||||||
|
ReportExcelStyle.setCommonCellStyle(wb, sheet, datalen + 1, end_col);
|
||||||
|
|
||||||
|
return wb;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public List<Record> yearStatByCustomer(String stm, String etm) {
|
||||||
|
List<Record> list = Db.find("select ifnull(c.name, '零散') name, a.*, p.surplus total_surplus from (\n" +
|
||||||
|
" select ifnull(t.customer_id, -1) id, count(t.sn) cnt, sum(t.total_price) total_price, sum(weight) total_weight from order_temp t\n" +
|
||||||
|
" where t.state = 5\n" +
|
||||||
|
" and t.create_time >= ? \n" +
|
||||||
|
" and t.create_time <= ? \n" +
|
||||||
|
" group by t.customer_id\n" +
|
||||||
|
" ) a\n" +
|
||||||
|
" left join customer c on c.id = a.id\n" +
|
||||||
|
" left join prepay_customer p on p.customer_id = a.id", stm, etm);
|
||||||
|
|
||||||
|
|
||||||
|
Record hj = new Record();
|
||||||
|
hj.set("id", 0);
|
||||||
|
hj.set("name", "合计");
|
||||||
|
hj.set("cnt", 0);
|
||||||
|
hj.set("total_price", new BigDecimal(0));
|
||||||
|
hj.set("total_weight", new BigDecimal(0));
|
||||||
|
hj.set("total_weight", new BigDecimal(0));
|
||||||
|
hj.set("total_surplus", new BigDecimal(0));
|
||||||
|
|
||||||
|
for (Record record : list) {
|
||||||
|
if (record.get("cnt") != null) {
|
||||||
|
hj.set("cnt", hj.getInt("cnt") + record.getInt("cnt"));
|
||||||
|
}
|
||||||
|
if (record.get("total_price") != null) {
|
||||||
|
hj.set("total_price", hj.getBigDecimal("total_price").add(record.getBigDecimal("total_price")));
|
||||||
|
}
|
||||||
|
if (record.get("total_weight") != null) {
|
||||||
|
hj.set("total_weight", hj.getBigDecimal("total_weight").add(record.getBigDecimal("total_weight")));
|
||||||
|
}
|
||||||
|
if (record.get("total_surplus") != null) {
|
||||||
|
hj.set("total_surplus", hj.getBigDecimal("total_surplus").add(record.getBigDecimal("total_surplus")));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
hj.set("total_account_surplus", hj.getBigDecimal("total_surplus").add(hj.getBigDecimal("total_price")));
|
||||||
|
|
||||||
|
list.add(hj);
|
||||||
|
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public Workbook yearStatByCustomerExport(String stm, String etm) {
|
||||||
|
List<Record> list = yearStatByCustomer(stm, etm);
|
||||||
|
Workbook wb = new XSSFWorkbook();
|
||||||
|
Sheet sheet = wb.createSheet(stm.substring(0, 10) + " ~ " + stm.substring(0, 10) + "时段销售汇总");
|
||||||
|
|
||||||
// 表头 start
|
// 表头 start
|
||||||
Row row = sheet.createRow(0);
|
Row row = sheet.createRow(0);
|
||||||
int a = 0;
|
int a = 0;
|
||||||
|
|
|
||||||
|
|
@ -302,4 +302,30 @@ public class OrderStatController extends BaseController {
|
||||||
render(new ExcelRender("按砂站总销售汇总表_" + System.currentTimeMillis() + ".xlsx", wb));
|
render(new ExcelRender("按砂站总销售汇总表_" + System.currentTimeMillis() + ".xlsx", wb));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Before(StartAndEndIntervalValidator.class)
|
||||||
|
public void statRangeAllCustomer() {
|
||||||
|
String stm = get("stm");
|
||||||
|
String etm = get("etm");
|
||||||
|
int export = getInt("export", 0); // 是否导出为exce 0 不导出,1 导出
|
||||||
|
if (export == 0) {
|
||||||
|
renderJson(Result.object(OrderStatService.me.yearStatByCustomer(stm, etm)));
|
||||||
|
} else {
|
||||||
|
Workbook wb = OrderStatService.me.yearStatByCustomerExport(stm, etm);
|
||||||
|
render(new ExcelRender("按客户统计总销售汇总表_" + System.currentTimeMillis() + ".xlsx", wb));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Before(StartAndEndIntervalValidator.class)
|
||||||
|
public void statRangeAllSup() {
|
||||||
|
String stm = get("stm");
|
||||||
|
String etm = get("etm");
|
||||||
|
int export = getInt("export", 0); // 是否导出为exce 0 不导出,1 导出
|
||||||
|
if (export == 0) {
|
||||||
|
renderJson(Result.object(OrderStatService.me.yearStatBySup(stm, etm)));
|
||||||
|
} else {
|
||||||
|
Workbook wb = OrderStatService.me.yearStatBySupExport(stm, etm);
|
||||||
|
render(new ExcelRender("按砂站总销售汇总表_" + System.currentTimeMillis() + ".xlsx", wb));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -363,4 +363,30 @@ public class OrderStatController extends BaseController {
|
||||||
render(new ExcelRender("按砂站总销售汇总表_" + System.currentTimeMillis() + ".xlsx", wb));
|
render(new ExcelRender("按砂站总销售汇总表_" + System.currentTimeMillis() + ".xlsx", wb));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Before(StartAndEndIntervalValidator.class)
|
||||||
|
public void statRangeAllCustomer() {
|
||||||
|
String stm = get("stm");
|
||||||
|
String etm = get("etm");
|
||||||
|
int export = getInt("export", 0); // 是否导出为exce 0 不导出,1 导出
|
||||||
|
if (export == 0) {
|
||||||
|
renderJson(Result.object(OrderStatService.me.yearStatByCustomer(stm, etm)));
|
||||||
|
} else {
|
||||||
|
Workbook wb = OrderStatService.me.yearStatByCustomerExport(stm, etm);
|
||||||
|
render(new ExcelRender("按客户统计总销售汇总表_" + System.currentTimeMillis() + ".xlsx", wb));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Before(StartAndEndIntervalValidator.class)
|
||||||
|
public void statRangeAllSup() {
|
||||||
|
String stm = get("stm");
|
||||||
|
String etm = get("etm");
|
||||||
|
int export = getInt("export", 0); // 是否导出为exce 0 不导出,1 导出
|
||||||
|
if (export == 0) {
|
||||||
|
renderJson(Result.object(OrderStatService.me.yearStatBySup(stm, etm)));
|
||||||
|
} else {
|
||||||
|
Workbook wb = OrderStatService.me.yearStatBySupExport(stm, etm);
|
||||||
|
render(new ExcelRender("按砂站总销售汇总表_" + System.currentTimeMillis() + ".xlsx", wb));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue