From a7ac8157039970645bca541e90c691aecf18ba02 Mon Sep 17 00:00:00 2001 From: wuwenxiong <646448316@qq.com> Date: Tue, 14 Sep 2021 15:31:00 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=9F=E8=AE=A1=E6=94=AF=E6=8C=81=E5=A4=9A?= =?UTF-8?q?=E5=93=81=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../stat/customer/CustomerStatService.java | 130 ++++-- .../ssjygl/stat/sale/OrderStatService.java | 419 ++++++++++++------ .../ssjygl/stat/sale/OrderStatController.java | 48 +- .../stat/customer/CustomerStatController.java | 7 +- .../ssjygl/stat/sale/OrderStatController.java | 46 +- 5 files changed, 439 insertions(+), 211 deletions(-) diff --git a/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/stat/customer/CustomerStatService.java b/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/stat/customer/CustomerStatService.java index cdb5c59..098424b 100644 --- a/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/stat/customer/CustomerStatService.java +++ b/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/stat/customer/CustomerStatService.java @@ -25,21 +25,17 @@ public class CustomerStatService { * @param customer_id * @return */ - public List checkAccount(String tm, Integer customer_id) { + public List checkAccount(String tm, Integer customer_id, Boolean stat_product, Integer product_id) { String querytm = tm + " 23:59:59"; - String sql = null; + String sql; + String fromSql; + String tempSql; + String productSql = ""; + String customerSql= ""; + List paraList = new ArrayList<>(); - if (customer_id != null) { - List paraList = new ArrayList<>(); - paraList.add(querytm); - paraList.add(customer_id); - paraList.add(querytm); - paraList.add(customer_id); - paraList.add(querytm); - paraList.add(customer_id); - paraList.add(customer_id); - - sql = "select t.customer_id id,\n" + + if (stat_product) { + fromSql = "select t.customer_id id,\n" + " c.`name`,\n" + " t.surplus,\n" + " a.total_price,\n" + @@ -47,17 +43,61 @@ public class CustomerStatService { " a.total_cnt,\n" + " b.amount,\n" + " b.refund_amount,\n" + - " b.amount - ifnull(a.total_price,0) - b.refund_amount then_surplus\n" + - " from prepay_customer t\n" + - " left join customer c on c.id= t.customer_id\n" + - " left join(\n" + - " select t.customer_id, sum(t.total_price) total_price, sum(t.weight) total_weight, count(t.sn) total_cnt\n" + + " b.amount - ifnull(a.total_price,0) - b.refund_amount then_surplus,a.product_id,a.product_name\n"; + if (customer_id != null) { + customerSql= " and t.customer_id = ? \n"; + } + if (product_id != null && product_id > 0) { + productSql = " and t.product_id=? "; + } + tempSql = " select t.customer_id, sum(t.total_price) total_price, sum(t.weight) total_weight, count(t.sn) total_cnt,t.product_id,t.product_name\n" + " from order_temp t\n" + " where t.customer_id is not null\n" + " and t.create_time <= ? \n" + " and t.state = 5\n" + - " and t.customer_id = ? \n" + - " group by t.customer_id\n" + + customerSql + + productSql + + " group by t.customer_id,t.product_id,t.product_name\n"; + + + } else { + if (customer_id != null) { + customerSql= " and t.customer_id = ? \n"; + } + fromSql = "select t.customer_id id,\n" + + " c.`name`,\n" + + " t.surplus,\n" + + " a.total_price,\n" + + " a.total_weight,\n" + + " a.total_cnt,\n" + + " b.amount,\n" + + " b.refund_amount,\n" + + " b.amount - ifnull(a.total_price,0) - b.refund_amount then_surplus\n"; + tempSql = " select t.customer_id, sum(t.total_price) total_price, sum(t.weight) total_weight, count(t.sn) total_cnt\n" + + " from order_temp t\n" + + " where t.customer_id is not null\n" + + " and t.create_time <= ? \n" + + " and t.state = 5\n" + + customerSql + + " group by t.customer_id\n"; + } + if (customer_id != null) { + paraList.add(querytm); + paraList.add(customer_id); + if (stat_product&&product_id != null && product_id > 0) { + paraList.add(product_id); + } + paraList.add(querytm); + paraList.add(customer_id); + paraList.add(querytm); + paraList.add(customer_id); + paraList.add(customer_id); + + sql = fromSql + + " from prepay_customer t\n" + + " left join customer c on c.id= t.customer_id\n" + + " join(\n" + + tempSql+ " ) a on a.customer_id = t.customer_id\n" + " left join(\n" + " select a.customer_id, a.amount, ifnull(b.amount, 0) refund_amount\n" + @@ -88,24 +128,17 @@ public class CustomerStatService { return Db.find(sql, paraList.toArray()); } else { - sql = "select t.customer_id id,\n" + - " c.`name`,\n" + - " t.surplus,\n" + - " a.total_price,\n" + - " a.total_weight,\n" + - " a.total_cnt,\n" + - " b.amount,\n" + - " b.refund_amount,\n" + - " b.amount - ifnull(a.total_price,0) - b.refund_amount then_surplus\n" + + paraList.add(querytm); + if (stat_product&&product_id != null && product_id > 0) { + paraList.add(product_id); + } + paraList.add(querytm); + paraList.add(querytm); + sql = fromSql + " from prepay_customer t\n" + " left join customer c on c.id= t.customer_id\n" + - " left join(\n" + - " select t.customer_id, sum(t.total_price) total_price, sum(t.weight) total_weight, count(t.sn) total_cnt\n" + - " from order_temp t\n" + - " where t.customer_id is not null\n" + - " and t.create_time <= ? \n" + - " and t.state = 5\n" + - " group by t.customer_id\n" + + " join(\n" + + tempSql+ " ) a on a.customer_id = t.customer_id\n" + " left join(\n" + " select a.customer_id, a.amount, ifnull(b.amount, 0) refund_amount\n" + @@ -131,20 +164,25 @@ public class CustomerStatService { " ) b on b.customer_id= t.customer_id\n" + " order by t.customer_id"; - return Db.find(sql, querytm, querytm, querytm); + return Db.find(sql, paraList.toArray()); } } - public Workbook checkAccountExport(String tm, Integer customer_id) { - List list = checkAccount(tm, customer_id); + public Workbook checkAccountExport(String tm, Integer customer_id, Boolean stat_product, Integer product_id) { + List list = checkAccount(tm, customer_id,stat_product,product_id); - Workbook wb = new XSSFWorkbook(); - Sheet sheet = wb.createSheet(tm + " 客户对账统计"); + Workbook wb = new XSSFWorkbook(); + Sheet sheet = wb.createSheet(tm + " 客户对账统计"); // 表头 start Row row = sheet.createRow(0); - int a = 0; + int a = 0; + int end_col = 8; row.createCell(a++).setCellValue("序号"); + if (stat_product) { + row.createCell(a++).setCellValue("品类"); + end_col=9; + } row.createCell(a++).setCellValue("客户"); row.createCell(a++).setCellValue("余额"); row.createCell(a++).setCellValue("累计充值"); @@ -155,14 +193,16 @@ public class CustomerStatService { // 表头 end int datalen = list.size(); - int end_col = 8; for (int i = 0; i < datalen; i++) { Record record = list.get(i); row = sheet.createRow(i + 1); - a = 0; + a = 0; row.createCell(a++).setCellValue(i + 1); + if (stat_product) { + row.createCell(a++).setCellValue(record.getStr("product_name")); + } row.createCell(a++).setCellValue(record.getStr("name")); row.createCell(a++).setCellValue(DataUtil.getDefaultByRecord(record, "then_surplus")); row.createCell(a++).setCellValue(DataUtil.getDefaultByRecord(record, "amount")); @@ -172,7 +212,7 @@ public class CustomerStatService { row.createCell(a++).setCellValue(record.getStr("total_cnt")); } - ReportExcelStyle.setCommonCellStyle(wb, sheet, datalen, end_col); + ReportExcelStyle.setCommonCellStyle(wb, sheet, datalen-1, end_col); return wb; } diff --git a/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/stat/sale/OrderStatService.java b/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/stat/sale/OrderStatService.java index 8bbfcf9..253e37e 100644 --- a/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/stat/sale/OrderStatService.java +++ b/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/stat/sale/OrderStatService.java @@ -327,33 +327,55 @@ public class OrderStatService { * @param tm YYYY-MM * @return */ - public Record monthgrid(String tm, Integer supermarket_id, Integer customer_id) { - // 使用实际支付金额统计 - String sql = "select ifnull(max(t.customer_id), t.customer_name) customer_id, ifnull(t.customer_name, '民用') customer_name, t.supermarket_id, max(s.name) supermarket_name, count(*) cnt, sum(t.total_price) total \n" + - " from (\n" + - " select t.customer_id, t.customer_name, t.supermarket_id, t.paid, t.total_price, 3 type \n" + - " from order_temp t\n" + - " where t.state = ? \n" + - " and t.create_time like ?\n" + - " ) t\n" + - " left join supermarket s on s.id = t.supermarket_id\n" + - " where 1 = 1 \n"; - + public Record monthgrid(String tm, Integer supermarket_id, Integer customer_id, Boolean stat_product, Integer product_id) { + String sql; + String paramsSql = ""; List paraList = new ArrayList<>(); + paraList.add(OrderStateEnum.RECEIVED.getStateid()); paraList.add(tm + "%"); if (supermarket_id != null && supermarket_id > 0) { - sql += " and t.supermarket_id = ? \n"; + paramsSql += " and t.supermarket_id = ? \n"; paraList.add(supermarket_id); } if (customer_id != null && customer_id > 0) { - sql += " and t.customer_id = ? \n"; + paramsSql += " and t.customer_id = ? \n"; paraList.add(customer_id); } - sql += " group by t.customer_name, t.supermarket_id"; + // 使用实际支付金额统计 + if(stat_product){ + if(product_id != null && product_id > 0){ + paramsSql += " and t.product_id = ? \n"; + paraList.add(product_id); + } + sql ="select ifnull(max(t.customer_id), t.customer_name) customer_id, ifnull(t.customer_name, '民用') customer_name, t.supermarket_id, max(s.name) supermarket_name, count(*) cnt, sum(t.total_price) total,t.product_id, t.product_name \n"+ + " from (\n" + + " select t.customer_id, t.customer_name , t.supermarket_id, t.paid, t.total_price,t.product_id, t.product_name, 3 type \n" + + " from order_temp t\n" + + " where t.state = ? \n" + + " and t.create_time like ?\n" + + " ) t\n" + + " left join supermarket s on s.id = t.supermarket_id\n" + + " where 1 = 1 \n"+ + paramsSql + + " group by t.customer_name, t.supermarket_id, t.product_id, t.product_name"; + } else { + sql = "select ifnull(max(t.customer_id), t.customer_name) customer_id, ifnull(t.customer_name, '民用') customer_name, t.supermarket_id, max(s.name) supermarket_name, count(*) cnt, sum(t.total_price) total \n" + + " from (\n" + + " select t.customer_id, t.customer_name , t.supermarket_id, t.paid, t.total_price, 3 type \n" + + " from order_temp t\n" + + " where t.state = ? \n" + + " and t.create_time like ?\n" + + " ) t\n" + + " left join supermarket s on s.id = t.supermarket_id\n" + + " where 1 = 1 \n" + + paramsSql + + "group by t.customer_name, t.supermarket_id"; + } + List dblist = Db.find(sql, paraList.toArray()); Map spkeys = new HashMap<>(); // supermarket_id <-> supermarket_name @@ -385,7 +407,7 @@ public class OrderStatService { outobj.set("id", sql_customer_id); outobj.set("name", record.getStr("customer_name")); outobj.set("total", outobj.getDouble("total") + record.getDouble("total")); - + outobj.set("product_name", record.getStr("product_name")); outobj.set(supermarket_id_str, record.getDouble("total")); } @@ -422,8 +444,8 @@ public class OrderStatService { * @param tm * @return */ - public Workbook monthgridExport(String tm, Integer supermarket_id, Integer customer_id) { - Record grid = monthgrid(tm, supermarket_id, customer_id); + public Workbook monthgridExport(String tm, Integer supermarket_id, Integer customer_id, Boolean stat_product, Integer product_id) { + Record grid = monthgrid(tm, supermarket_id, customer_id, stat_product, product_id); Workbook wb = new XSSFWorkbook(); Sheet sheet = wb.createSheet("销售月汇总"); @@ -531,35 +553,66 @@ public class OrderStatService { * @param tm * @return */ - public List salestatCustomer(String tm, Integer invoice_type) { + public List salestatCustomer(String tm, Integer invoice_type, Boolean stat_product) { List dblist = null; if (invoice_type != null) { - dblist = Db.find("select max(t.customer_id) id, t.customer_name name, count(*) as orderCount, sum(t.total_price) as totalPrice, sum(t.weight) as weight, max(t.invoice_type) invoiceType\n" + - " from (\n" + - " select ifnull(t.customer_id, t.customer_name) customer_id, t.customer_name, t.paid, t.total_price, t.weight, t.invoice_type\n" + - " from order_temp t\n" + - " where t.state = ? \n" + - " and t.invoice_type = ? \n" + - " and t.create_time like ? \n" + - " ) t\n" + - " group by t.customer_name", - OrderStateEnum.RECEIVED.getStateid(), - invoice_type, - tm + "%" - ); + if(stat_product){ + dblist = Db.find("select max(t.customer_id) id, t.customer_name name, count(*) as orderCount, sum(t.total_price) as totalPrice, sum(t.weight) as weight, max(t.invoice_type) invoiceType,t.product_name\n" + + " from (\n" + + " select ifnull(t.customer_id, t.customer_name) customer_id, t.customer_name, t.paid, t.total_price, t.weight, t.invoice_type,t.product_id,t.product_name\n" + + " from order_temp t\n" + + " where t.state = ? \n" + + " and t.invoice_type = ? \n" + + " and t.create_time like ? \n" + + " ) t\n" + + " group by t.customer_name,t.product_id,t.product_name", + OrderStateEnum.RECEIVED.getStateid(), + invoice_type, + tm + "%"); + }else { + dblist = Db.find("select max(t.customer_id) id, t.customer_name name, count(*) as orderCount, sum(t.total_price) as totalPrice, sum(t.weight) as weight, max(t.invoice_type) invoiceType\n" + + " from (\n" + + " select ifnull(t.customer_id, t.customer_name) customer_id, t.customer_name, t.paid, t.total_price, t.weight, t.invoice_type\n" + + " from order_temp t\n" + + " where t.state = ? \n" + + " and t.invoice_type = ? \n" + + " and t.create_time like ? \n" + + " ) t\n" + + " group by t.customer_name", + OrderStateEnum.RECEIVED.getStateid(), + invoice_type, + tm + "%"); + } + + } else { - dblist = Db.find("select max(t.customer_id) id, t.customer_name name, count(*) as orderCount, sum(t.total_price) as totalPrice, sum(t.weight) as weight, max(t.invoice_type) invoiceType\n" + - " from (\n" + - " select ifnull(t.customer_id, t.customer_name) customer_id, t.customer_name, t.paid, t.total_price, t.weight, t.invoice_type\n" + - " from order_temp t\n" + - " where t.state = ? \n" + - " and t.create_time like ? \n" + - " ) t\n" + - " group by t.customer_name", - OrderStateEnum.RECEIVED.getStateid(), - tm + "%" - ); + if(stat_product){ + dblist = Db.find("select max(t.customer_id) id, t.customer_name name, count(*) as orderCount, sum(t.total_price) as totalPrice, sum(t.weight) as weight, max(t.invoice_type) invoiceType,t.product_name\n" + + " from (\n" + + " select ifnull(t.customer_id, t.customer_name) customer_id, t.customer_name, t.paid, t.total_price, t.weight, t.invoice_type,t.product_id,t.product_name\n" + + " from order_temp t\n" + + " where t.state = ? \n" + + " and t.create_time like ? \n" + + " ) t\n" + + " group by t.customer_name,t.product_id,t.product_name", + OrderStateEnum.RECEIVED.getStateid(), + tm + "%" + ); + }else { + dblist = Db.find("select max(t.customer_id) id, t.customer_name name, count(*) as orderCount, sum(t.total_price) as totalPrice, sum(t.weight) as weight, max(t.invoice_type) invoiceType\n" + + " from (\n" + + " select ifnull(t.customer_id, t.customer_name) customer_id, t.customer_name, t.paid, t.total_price, t.weight, t.invoice_type\n" + + " from order_temp t\n" + + " where t.state = ? \n" + + " and t.create_time like ? \n" + + " ) t\n" + + " group by t.customer_name", + OrderStateEnum.RECEIVED.getStateid(), + tm + "%" + ); + } + } Record total = new Record(); @@ -576,7 +629,7 @@ public class OrderStatService { } total.set("weight", Double.parseDouble(String.format("%.2f", total.getDouble("weight")))); - + total.set("product_name", ""); dblist.add(total); return dblist; @@ -684,8 +737,8 @@ public class OrderStatService { * @param tm * @return */ - public Workbook salestatCustomerExport(String tm, String title, String subtitle, Integer invoice_type) { - List list = salestatCustomer(tm, invoice_type); + public Workbook salestatCustomerExport(String tm, String title, String subtitle, Integer invoice_type, Boolean stat_product) { + List list = salestatCustomer(tm, invoice_type, stat_product); Workbook wb = new XSSFWorkbook(); Sheet sheet = wb.createSheet(title); @@ -741,7 +794,7 @@ public class OrderStatService { } - public Workbook daysalestatCustomerExport(String tm, Integer invoice_type) { + public Workbook daysalestatCustomerExport(String tm, Integer invoice_type, Boolean stat_product) { String title = "销售日统计"; @@ -755,10 +808,10 @@ public class OrderStatService { subtitle += title; - return salestatCustomerExport(tm, title, subtitle, invoice_type); + return salestatCustomerExport(tm, title, subtitle, invoice_type, stat_product); } - public Workbook monthsalestatCustomerExport(String tm, Integer invoice_type) { + public Workbook monthsalestatCustomerExport(String tm, Integer invoice_type, Boolean stat_product) { String title = "销售月统计"; // 副标题 start @@ -771,7 +824,7 @@ public class OrderStatService { subtitle += title; - return salestatCustomerExport(tm, title, subtitle, invoice_type); + return salestatCustomerExport(tm, title, subtitle, invoice_type, stat_product); } /** @@ -781,31 +834,51 @@ public class OrderStatService { * @param supermarket_id * @return */ - public List mdstat(String stm, String etm, Integer supermarket_id) { - String paramsSql = ""; - if (supermarket_id != null) { - paramsSql = "and t.supermarket_id = ? \n"; + public List mdstat(String stm, String etm, Integer supermarket_id, Boolean stat_product, Integer product_id) { + String sql; + List paramsArray = new ArrayList<>(); + paramsArray.add(OrderStateEnum.RECEIVED.getStateid()); + paramsArray.add(stm); + paramsArray.add(etm); + String productParams = ""; + + if (supermarket_id != null && supermarket_id > 0) { + productParams += " and t.supermarket_id = ?\n"; + paramsArray.add(supermarket_id); } + if(stat_product){ + if (product_id != null && product_id > 0) { + productParams += " and t.product_id = ?\n"; + paramsArray.add(product_id); + } - String sql = "select date_format(t.create_time, '%Y-%m-%d') as date, sum(t.weight) as weight, sum(t.total_price) as totalPrice\n" + - "from (\n" + - " select t.create_time, t.weight, t.paid, t.total_price\n" + - " from order_temp t\n" + - " where t.state = ? \n" + - paramsSql + - " and t.create_time >= ? \n" + - " and t.create_time <= ? \n" + - ") t\n" + - "group by date_format(t.create_time, '%Y-%m-%d')\n" + - "order by date_format(t.create_time, '%Y-%m-%d')"; - - List dblist; - if (supermarket_id != null) { - dblist = Db.find(sql, OrderStateEnum.RECEIVED.getStateid(), supermarket_id, stm, etm); + sql = "select date_format(t.create_time, '%Y-%m-%d') as date, count(t.sn) truckCnt, sum(t.weight) as weight, sum(t.total_price) as totalPrice,t.product_id,t.product_name\n" + + "from (\n" + + " select t.sn, t.create_time, t.weight, t.paid, t.total_price,t.product_id,t.product_name\n" + + " from order_temp t\n" + + " where t.state = ? \n" + + " and t.create_time >= ? \n" + + " and t.create_time <= ? \n" + + productParams + + ") t\n" + + "group by date_format(t.create_time, '%Y-%m-%d') ,t.product_id,t.product_name\n" + + "order by date_format(t.create_time, '%Y-%m-%d'),t.product_id,t.product_name"; } else { - dblist = Db.find(sql, OrderStateEnum.RECEIVED.getStateid(), stm, etm); + sql = "select date_format(t.create_time, '%Y-%m-%d') as date, count(t.sn) truckCnt, sum(t.weight) as weight, sum(t.total_price) as totalPrice\n" + + "from (\n" + + " select t.sn, t.create_time, t.weight, t.paid, t.total_price\n" + + " from order_temp t\n" + + " where t.state = ? \n" + + " and t.create_time >= ? \n" + + " and t.create_time <= ? \n" + + productParams + + ") t\n" + + "group by date_format(t.create_time, '%Y-%m-%d')\n" + + "order by date_format(t.create_time, '%Y-%m-%d')"; } + List dblist = Db.find(sql, paramsArray.toArray()); + Record total = new Record(); total.set("id", dblist.size() + 1); total.set("date", null); @@ -843,8 +916,8 @@ public class OrderStatService { * @param supermarket_id * @return */ - public Workbook mdstatExport(String stm, String etm, Integer supermarket_id) { - List list = mdstat(stm, etm, supermarket_id); + public Workbook mdstatExport(String stm, String etm, Integer supermarket_id, Boolean stat_product, Integer product_id) { + List list = mdstat(stm, etm, supermarket_id, stat_product, product_id); Workbook wb = new XSSFWorkbook(); Sheet sheet = wb.createSheet("销售月逐日统计"); @@ -1313,23 +1386,44 @@ public class OrderStatService { return wb; } - public List yearStatBySup(String year) { + public List yearStatBySup(String year, Boolean stat_product) { List list; if (StrKit.notBlank(year)) { - 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 like ? \n" + - " group by t.supermarket_id\n" + - ") a on s.id = a.id order by s.id", year + "%"); + if(stat_product){ + list = Db.find("select s.id, s.name, a.cnt, a.total_price, a.total_weight,a.product_id,a.product_name 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,t.product_id,t.product_name from order_temp t\n" + + " where t.state = 5\n" + + " and t.create_time like ? \n" + + " group by t.supermarket_id,t.product_id,t.product_name\n" + + ") a on s.id = a.id order by s.id", year + "%"); + }else { + 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 like ? \n" + + " group by t.supermarket_id\n" + + ") a on s.id = a.id order by s.id", year + "%"); + } + } else { - 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" + - " group by t.supermarket_id\n" + - ") a on s.id = a.id order by s.id"); + if(stat_product){ + list = Db.find("select s.id, s.name, a.cnt, a.total_price, a.total_weight,a.product_id,a.product_name 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,t.product_id,t.product_name from order_temp t\n" + + " where t.state = 5\n" + + " group by t.supermarket_id,t.product_id,t.product_name\n" + + ") a on s.id = a.id order by s.id"); + }else { + 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" + + " group by t.supermarket_id\n" + + ") a on s.id = a.id order by s.id"); + } + } Record hj = new Record(); @@ -1356,8 +1450,8 @@ public class OrderStatService { return list; } - public Workbook yearStatBySupExport(String year) { - List list = yearStatBySup(year); + public Workbook yearStatBySupExport(String year, Boolean stat_product) { + List list = yearStatBySup(year, stat_product); Workbook wb = new XSSFWorkbook(); Sheet sheet; @@ -1398,15 +1492,36 @@ public class OrderStatService { return wb; } - public List yearStatBySup(String stm, String etm) { - List 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); + public List yearStatBySup(String stm, String etm, Boolean stat_product, Integer product_id) { + List list; + String paramsSql = ""; + List paramsArray = new ArrayList<>(); + paramsArray.add(stm); + paramsArray.add(etm); + if (stat_product) { + if(product_id != null && product_id > 0){ + paramsSql+=" and t.product_id=? \n"; + paramsArray.add(product_id); + } + list = Db.find("select s.id, s.name, a.cnt, a.total_price, a.total_weight ,a.product_id,a.product_name 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,t.product_id,t.product_name from order_temp t\n" + + " where t.state = 5\n" + + " and t.create_time >= ? \n" + + " and t.create_time <= ? \n" + + paramsSql+ + " group by t.supermarket_id,t.product_id,t.product_name\n" + + ") a on s.id = a.id order by s.id", paramsArray.toArray()); + }else { + 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", paramsArray.toArray()); + } Record hj = new Record(); hj.set("id", 0); @@ -1432,8 +1547,8 @@ public class OrderStatService { return list; } - public Workbook yearStatBySupExport(String stm, String etm) { - List list = yearStatBySup(stm, etm); + public Workbook yearStatBySupExport(String stm, String etm, Boolean stat_product,Integer product_id) { + List list = yearStatBySup(stm, etm, stat_product, product_id); Workbook wb = new XSSFWorkbook(); Sheet sheet = wb.createSheet(stm.substring(0, 10) + " ~ " + etm.substring(0, 10) + "年销售汇总"); @@ -1467,25 +1582,48 @@ public class OrderStatService { return wb; } - public List yearStatByCustomer(String year) { + public List yearStatByCustomer(String year, Boolean stat_product) { List list; if (StrKit.notBlank(year)) { - 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 like ? \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", year + "%"); + if(stat_product){ + list = Db.find("select ifnull(c.name, '零散') name, a.*, p.surplus total_surplus ,a.product_id,a.product_name from (\n" + + " select ifnull(t.customer_id, -1) id, count(t.sn) cnt, sum(t.total_price) total_price, sum(weight) total_weight,t.product_id,t.product_name from order_temp t\n" + + " where t.state = 5\n" + + " and t.create_time like ? \n" + + " group by t.customer_id,t.product_id,t.product_name\n" + + " ) a\n" + + " left join customer c on c.id = a.id\n" + + " left join prepay_customer p on p.customer_id = a.id", year + "%"); + }else { + 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 like ? \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", year + "%"); + } + } else { - 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" + - " 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"); + if(stat_product){ + list = Db.find("select ifnull(c.name, '零散') name, a.*, p.surplus total_surplus,a.product_id,a.product_name from (\n" + + " select ifnull(t.customer_id, -1) id, count(t.sn) cnt, sum(t.total_price) total_price, sum(weight) total_weight,t.product_id,t.product_name from order_temp t\n" + + " where t.state = 5\n" + + " group by t.customer_id,t.product_id,t.product_name\n" + + " ) a\n" + + " left join customer c on c.id = a.id\n" + + " left join prepay_customer p on p.customer_id = a.id"); + }else { + 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" + + " 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"); + } + } Record hj = new Record(); @@ -1520,8 +1658,8 @@ public class OrderStatService { } - public Workbook yearStatByCustomerExport(String year) { - List list = yearStatByCustomer(year); + public Workbook yearStatByCustomerExport(String year, Boolean stat_product) { + List list = yearStatByCustomer(year, stat_product); Workbook wb = new XSSFWorkbook(); Sheet sheet; @@ -1580,17 +1718,38 @@ public class OrderStatService { } - public List yearStatByCustomer(String stm, String etm) { - List 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); - + public List yearStatByCustomer(String stm, String etm, Boolean stat_product, Integer product_id) { + List list; + String paramsSql = ""; + List paramsArray = new ArrayList<>(); + paramsArray.add(stm); + paramsArray.add(etm); + if(stat_product){ + if(product_id != null && product_id > 0){ + paramsSql +=" and t.product_id=? \n"; + paramsArray.add(product_id); + } + list = Db.find("select c.id id, ifnull(c.name, '零散') name, a.*, p.surplus total_surplus ,a.product_id,a.product_name from (\n" + + " select ifnull(t.customer_id, -1) id, count(t.sn) cnt, sum(t.total_price) total_price, sum(weight) total_weight,t.product_id,t.product_name from order_temp t\n" + + " where t.state = 5\n" + + " and t.create_time >= ? \n" + + " and t.create_time <= ? \n" + + paramsSql+ + " group by t.customer_id,t.product_id,t.product_name\n" + + " ) a\n" + + " left join customer c on c.id = a.id\n" + + " left join prepay_customer p on p.customer_id = a.id", paramsArray.toArray()); + }else { + list = Db.find("select c.id, 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", paramsArray.toArray()); + } Record hj = new Record(); hj.set("id", 0); @@ -1624,8 +1783,8 @@ public class OrderStatService { } - public Workbook yearStatByCustomerExport(String stm, String etm) { - List list = yearStatByCustomer(stm, etm); + public Workbook yearStatByCustomerExport(String stm, String etm, Boolean stat_product, Integer product_id) { + List list = yearStatByCustomer(stm, etm, stat_product, product_id); Workbook wb = new XSSFWorkbook(); Sheet sheet = wb.createSheet(stm.substring(0, 10) + " ~ " + stm.substring(0, 10) + "时段销售汇总"); diff --git a/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/stat/sale/OrderStatController.java b/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/stat/sale/OrderStatController.java index 7cc6380..61a02fe 100644 --- a/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/stat/sale/OrderStatController.java +++ b/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/stat/sale/OrderStatController.java @@ -69,11 +69,13 @@ public class OrderStatController extends BaseController { Integer customer_id = getInt("customer_id"); String tm = get("tm"); int export = getInt("export", 0); + Integer product_id = getInt("product_id"); + Boolean stat_product = getBoolean("stat_product",false); if (export == 0) { - renderJson(Result.object(OrderStatService.me.monthgrid(tm, supermarket_id, customer_id))); + renderJson(Result.object(OrderStatService.me.monthgrid(tm, supermarket_id, customer_id, stat_product, product_id))); } else { - Workbook wb = OrderStatService.me.monthgridExport(tm, supermarket_id, customer_id); + Workbook wb = OrderStatService.me.monthgridExport(tm, supermarket_id, customer_id, stat_product, product_id); render(new ExcelRender(tm + "_销售月汇总_" + System.currentTimeMillis() + ".xlsx", wb)); } } @@ -118,10 +120,11 @@ public class OrderStatController extends BaseController { String tm = get("tm"); Integer invoice_type = getInt("invoice_type"); int export = getInt("export", 0); + Boolean stat_product = getBoolean("stat_product",false); if (export == 0) { - renderJson(Result.object(OrderStatService.me.salestatCustomer(tm, invoice_type))); + renderJson(Result.object(OrderStatService.me.salestatCustomer(tm, invoice_type, stat_product))); } else { - Workbook wb = OrderStatService.me.daysalestatCustomerExport(tm, invoice_type); + Workbook wb = OrderStatService.me.daysalestatCustomerExport(tm, invoice_type, stat_product); render(new ExcelRender(tm + "_销售日统计_" + System.currentTimeMillis() + ".xlsx", wb)); } } @@ -134,11 +137,11 @@ public class OrderStatController extends BaseController { String tm = get("tm"); Integer invoice_type = getInt("invoice_type"); int export = getInt("export", 0); - + Boolean stat_product = getBoolean("stat_product",false); if (export == 0) { - renderJson(Result.object(OrderStatService.me.salestatCustomer(tm, invoice_type))); + renderJson(Result.object(OrderStatService.me.salestatCustomer(tm, invoice_type, stat_product))); } else { - Workbook wb = OrderStatService.me.monthsalestatCustomerExport(tm, invoice_type); + Workbook wb = OrderStatService.me.monthsalestatCustomerExport(tm, invoice_type, stat_product); render(new ExcelRender(tm + "_销售月统计_" + System.currentTimeMillis() + ".xlsx", wb)); } } @@ -152,11 +155,13 @@ public class OrderStatController extends BaseController { String etm = get("etm"); // 前端将 YYYY-MM-DD 后面补 " 23:59:59" Integer supermarket_id = getInt("supermarket_id"); int export = getInt("export", 0); + Boolean stat_product = getBoolean("stat_product",false); + Integer product_id = getInt("product_id"); if (export == 0) { - renderJson(Result.object(OrderStatService.me.mdstat(stm, etm, supermarket_id))); + renderJson(Result.object(OrderStatService.me.mdstat(stm, etm, supermarket_id, stat_product, product_id))); } else { - Workbook wb = OrderStatService.me.mdstatExport(stm, etm, supermarket_id); + Workbook wb = OrderStatService.me.mdstatExport(stm, etm, supermarket_id, stat_product, product_id); render(new ExcelRender(stm.substring(0, 10) + "至" + etm.substring(0, 10) + "_销售月逐日统计_" + System.currentTimeMillis() + ".xlsx", wb)); } @@ -288,10 +293,11 @@ public class OrderStatController extends BaseController { public void statYearCustomer() { String tm = get("tm"); int export = getInt("export", 0); // 是否导出为exce 0 不导出,1 导出 + Boolean stat_product = getBoolean("stat_product",false); if (export == 0) { - renderJson(Result.object(OrderStatService.me.yearStatByCustomer(tm))); + renderJson(Result.object(OrderStatService.me.yearStatByCustomer(tm, stat_product))); } else { - Workbook wb = OrderStatService.me.yearStatByCustomerExport(tm); + Workbook wb = OrderStatService.me.yearStatByCustomerExport(tm, stat_product); render(new ExcelRender("按客户统计总销售汇总表_" + System.currentTimeMillis() + ".xlsx", wb)); } } @@ -299,10 +305,12 @@ public class OrderStatController extends BaseController { public void statYearBySup() { String tm = get("tm"); int export = getInt("export", 0); // 是否导出为exce 0 不导出,1 导出 + Boolean stat_product = getBoolean("stat_product",false); + if (export == 0) { - renderJson(Result.object(OrderStatService.me.yearStatBySup(tm))); + renderJson(Result.object(OrderStatService.me.yearStatBySup(tm, stat_product))); } else { - Workbook wb = OrderStatService.me.yearStatBySupExport(tm); + Workbook wb = OrderStatService.me.yearStatBySupExport(tm, stat_product); render(new ExcelRender("按砂站总销售汇总表_" + System.currentTimeMillis() + ".xlsx", wb)); } } @@ -312,10 +320,13 @@ public class OrderStatController extends BaseController { String stm = get("stm"); String etm = get("etm"); int export = getInt("export", 0); // 是否导出为exce 0 不导出,1 导出 + Boolean stat_product = getBoolean("stat_product",false); + Integer product_id = getInt("product_id"); + if (export == 0) { - renderJson(Result.object(OrderStatService.me.yearStatByCustomer(stm, etm))); + renderJson(Result.object(OrderStatService.me.yearStatByCustomer(stm, etm, stat_product, product_id))); } else { - Workbook wb = OrderStatService.me.yearStatByCustomerExport(stm, etm); + Workbook wb = OrderStatService.me.yearStatByCustomerExport(stm, etm, stat_product, product_id); render(new ExcelRender("按客户统计总销售汇总表_" + System.currentTimeMillis() + ".xlsx", wb)); } } @@ -324,11 +335,14 @@ public class OrderStatController extends BaseController { public void statRangeAllSup() { String stm = get("stm"); String etm = get("etm"); + Boolean stat_product = getBoolean("stat_product",false); + Integer product_id = getInt("product_id"); int export = getInt("export", 0); // 是否导出为exce 0 不导出,1 导出 + if (export == 0) { - renderJson(Result.object(OrderStatService.me.yearStatBySup(stm, etm))); + renderJson(Result.object(OrderStatService.me.yearStatBySup(stm, etm, stat_product, product_id))); } else { - Workbook wb = OrderStatService.me.yearStatBySupExport(stm, etm); + Workbook wb = OrderStatService.me.yearStatBySupExport(stm, etm, stat_product, product_id); render(new ExcelRender("按砂站总销售汇总表_" + System.currentTimeMillis() + ".xlsx", wb)); } } diff --git a/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/stat/customer/CustomerStatController.java b/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/stat/customer/CustomerStatController.java index 2a9b795..f942ade 100644 --- a/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/stat/customer/CustomerStatController.java +++ b/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/stat/customer/CustomerStatController.java @@ -14,13 +14,14 @@ public class CustomerStatController extends Controller { public void checkAccount() { String tm = get("tm"); Integer customer_id = getInt("customer_id"); - + Integer product_id = getInt("product_id"); + Boolean stat_product = getBoolean("stat_product",false); int export = getInt("export", 0); // 是否导出为exce 0 不导出,1 导出 if (export == 0) { - renderJson(Result.object(CustomerStatService.me.checkAccount(tm, customer_id))); + renderJson(Result.object(CustomerStatService.me.checkAccount(tm, customer_id, stat_product, product_id))); } else { - Workbook wb = CustomerStatService.me.checkAccountExport(tm, customer_id); + Workbook wb = CustomerStatService.me.checkAccountExport(tm, customer_id, stat_product, product_id); render(new ExcelRender(tm + "_客户对账统计_" + System.currentTimeMillis() + ".xlsx", wb)); } diff --git a/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/stat/sale/OrderStatController.java b/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/stat/sale/OrderStatController.java index 2b4f651..2749ca2 100644 --- a/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/stat/sale/OrderStatController.java +++ b/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/stat/sale/OrderStatController.java @@ -84,6 +84,8 @@ public class OrderStatController extends BaseController { public void monthgrid() { Integer supermarket_id = getInt("supermarket_id"); Integer customer_id = getInt("customer_id"); + Integer product_id = getInt("product_id"); + Boolean stat_product = getBoolean("stat_product",false); Sysuser tokenuser = SysuserSyncService.me.getSysuserByToken(get("token")); @@ -99,9 +101,9 @@ public class OrderStatController extends BaseController { int export = getInt("export", 0); if (export == 0) { - renderJson(Result.object(OrderStatService.me.monthgrid(tm, supermarket_id, customer_id))); + renderJson(Result.object(OrderStatService.me.monthgrid(tm, supermarket_id, customer_id, stat_product, product_id))); } else { - Workbook wb = OrderStatService.me.monthgridExport(tm, supermarket_id, customer_id); + Workbook wb = OrderStatService.me.monthgridExport(tm, supermarket_id, customer_id, stat_product, product_id); render(new ExcelRender(tm + "_销售月汇总_" + System.currentTimeMillis() + ".xlsx", wb)); } } @@ -146,10 +148,12 @@ public class OrderStatController extends BaseController { String tm = get("tm"); Integer invoice_type = getInt("invoice_type"); int export = getInt("export", 0); + Boolean stat_product = getBoolean("stat_product",false); + if (export == 0) { - renderJson(Result.object(OrderStatService.me.salestatCustomer(tm, invoice_type))); + renderJson(Result.object(OrderStatService.me.salestatCustomer(tm, invoice_type, stat_product))); } else { - Workbook wb = OrderStatService.me.daysalestatCustomerExport(tm, invoice_type); + Workbook wb = OrderStatService.me.daysalestatCustomerExport(tm, invoice_type, stat_product); render(new ExcelRender(tm + "_销售日统计_" + System.currentTimeMillis() + ".xlsx", wb)); } } @@ -162,11 +166,12 @@ public class OrderStatController extends BaseController { String tm = get("tm"); Integer invoice_type = getInt("invoice_type"); int export = getInt("export", 0); + Boolean stat_product = getBoolean("stat_product",false); if (export == 0) { - renderJson(Result.object(OrderStatService.me.salestatCustomer(tm, invoice_type))); + renderJson(Result.object(OrderStatService.me.salestatCustomer(tm, invoice_type, stat_product))); } else { - Workbook wb = OrderStatService.me.monthsalestatCustomerExport(tm, invoice_type); + Workbook wb = OrderStatService.me.monthsalestatCustomerExport(tm, invoice_type, stat_product); render(new ExcelRender(tm + "_销售月统计_" + System.currentTimeMillis() + ".xlsx", wb)); } } @@ -179,12 +184,14 @@ public class OrderStatController extends BaseController { String stm = get("stm"); // 前端将 YYYY-MM-DD 后面补 " 00:00:00" String etm = get("etm"); // 前端将 YYYY-MM-DD 后面补 " 23:59:59" Integer supermarket_id = getInt("supermarket_id"); + Boolean stat_product = getBoolean("stat_product",false); + Integer product_id = getInt("product_id"); int export = getInt("export", 0); if (export == 0) { - renderJson(Result.object(OrderStatService.me.mdstat(stm, etm, supermarket_id))); + renderJson(Result.object(OrderStatService.me.mdstat(stm, etm, supermarket_id, stat_product,product_id))); } else { - Workbook wb = OrderStatService.me.mdstatExport(stm, etm, supermarket_id); + Workbook wb = OrderStatService.me.mdstatExport(stm, etm, supermarket_id, stat_product,product_id); render(new ExcelRender(stm.substring(0, 10) + "至" + etm.substring(0, 10) + "_销售月逐日统计_" + System.currentTimeMillis() + ".xlsx", wb)); } @@ -352,10 +359,12 @@ public class OrderStatController extends BaseController { public void statYearCustomer() { String tm = get("tm"); int export = getInt("export", 0); // 是否导出为exce 0 不导出,1 导出 + Boolean stat_product = getBoolean("stat_product",false); + if (export == 0) { - renderJson(Result.object(OrderStatService.me.yearStatByCustomer(tm))); + renderJson(Result.object(OrderStatService.me.yearStatByCustomer(tm, stat_product))); } else { - Workbook wb = OrderStatService.me.yearStatByCustomerExport(tm); + Workbook wb = OrderStatService.me.yearStatByCustomerExport(tm, stat_product); render(new ExcelRender("按客户统计总销售汇总表_" + System.currentTimeMillis() + ".xlsx", wb)); } } @@ -363,10 +372,11 @@ public class OrderStatController extends BaseController { public void statYearBySup() { String tm = get("tm"); int export = getInt("export", 0); // 是否导出为exce 0 不导出,1 导出 + Boolean stat_product = getBoolean("stat_product",false); if (export == 0) { - renderJson(Result.object(OrderStatService.me.yearStatBySup(tm))); + renderJson(Result.object(OrderStatService.me.yearStatBySup(tm, stat_product))); } else { - Workbook wb = OrderStatService.me.yearStatBySupExport(tm); + Workbook wb = OrderStatService.me.yearStatBySupExport(tm, stat_product); render(new ExcelRender("按砂站总销售汇总表_" + System.currentTimeMillis() + ".xlsx", wb)); } } @@ -375,11 +385,13 @@ public class OrderStatController extends BaseController { public void statRangeAllCustomer() { String stm = get("stm"); String etm = get("etm"); + Boolean stat_product = getBoolean("stat_product",false); + Integer product_id = getInt("product_id"); int export = getInt("export", 0); // 是否导出为exce 0 不导出,1 导出 if (export == 0) { - renderJson(Result.object(OrderStatService.me.yearStatByCustomer(stm, etm))); + renderJson(Result.object(OrderStatService.me.yearStatByCustomer(stm, etm, stat_product, product_id))); } else { - Workbook wb = OrderStatService.me.yearStatByCustomerExport(stm, etm); + Workbook wb = OrderStatService.me.yearStatByCustomerExport(stm, etm, stat_product,product_id); render(new ExcelRender("按客户统计总销售汇总表_" + System.currentTimeMillis() + ".xlsx", wb)); } } @@ -388,11 +400,13 @@ public class OrderStatController extends BaseController { public void statRangeAllSup() { String stm = get("stm"); String etm = get("etm"); + Boolean stat_product = getBoolean("stat_product",false); + Integer product_id = getInt("product_id"); int export = getInt("export", 0); // 是否导出为exce 0 不导出,1 导出 if (export == 0) { - renderJson(Result.object(OrderStatService.me.yearStatBySup(stm, etm))); + renderJson(Result.object(OrderStatService.me.yearStatBySup(stm, etm, stat_product,product_id))); } else { - Workbook wb = OrderStatService.me.yearStatBySupExport(stm, etm); + Workbook wb = OrderStatService.me.yearStatBySupExport(stm, etm, stat_product,product_id); render(new ExcelRender("按砂站总销售汇总表_" + System.currentTimeMillis() + ".xlsx", wb)); } }