From ee802328be77d49d1b1e4e62005bef718c9e28f2 Mon Sep 17 00:00:00 2001 From: wany <13995595726@qq.com> Date: Mon, 17 Mar 2025 14:10:28 +0800 Subject: [PATCH] =?UTF-8?q?bug=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ssjygl/invoice/log/InvoiceLogService.java | 4 +- .../order/orderend/OrderEndService.java | 2 +- .../order/ordertemp/OrderTempService.java | 2 +- .../cowr/ssjygl/overall/OverallService.java | 6 +- .../stat/invoice/InvoiceUseController.java | 17 ++ .../stat/invoice/InvoiceUseService.java | 159 ++++++++++++++++++ .../invoice/log/InvoiceLogSyncService.java | 5 +- 7 files changed, 186 insertions(+), 9 deletions(-) diff --git a/ssjygl-xsct-common/src/main/java/com/cowr/ssjygl/invoice/log/InvoiceLogService.java b/ssjygl-xsct-common/src/main/java/com/cowr/ssjygl/invoice/log/InvoiceLogService.java index 701248d..2d6fe02 100644 --- a/ssjygl-xsct-common/src/main/java/com/cowr/ssjygl/invoice/log/InvoiceLogService.java +++ b/ssjygl-xsct-common/src/main/java/com/cowr/ssjygl/invoice/log/InvoiceLogService.java @@ -47,8 +47,8 @@ public class InvoiceLogService extends BaseService { String selectsql = "select t.*, r.supermarket_id, s.name supermarket_name, \n" + " case when t.type = 3 then p.weight end weight, \n" + " case when t.type = 3 then p.total_price end total_price, \n" + - " case when t.type = 3 then p.create_time end create_time, \n" + - " case when t.type = 3 then p.settlement_user_name end settlement_user_name, \n" + +// " case when t.type = 3 then p.create_time end create_time, \n" + +// " case when t.type = 3 then p.settlement_user_name end settlement_user_name, \n" + " case when t.type = 3 then p.customer_name end customer_name \n"; String fromsql = "from invoice_log t \n" + " left join invoice_receive r on r.id = t.invoice_receive_id \n" + diff --git a/ssjygl-xsct-common/src/main/java/com/cowr/ssjygl/order/orderend/OrderEndService.java b/ssjygl-xsct-common/src/main/java/com/cowr/ssjygl/order/orderend/OrderEndService.java index bcde899..2c74539 100644 --- a/ssjygl-xsct-common/src/main/java/com/cowr/ssjygl/order/orderend/OrderEndService.java +++ b/ssjygl-xsct-common/src/main/java/com/cowr/ssjygl/order/orderend/OrderEndService.java @@ -216,7 +216,7 @@ public class OrderEndService extends BaseService { "_" + DateTimeUtil.sdf.get().format(o.getDate("date")) + "_" + o.getSupermarketId() + "_" + o.getSaleType() + - "_" + o.getInvoiceType() + +// "_" + o.getInvoiceType() + "_" + o.getProductId() + "_" + o.getOrderclusterId()); return o; diff --git a/ssjygl-xsct-common/src/main/java/com/cowr/ssjygl/order/ordertemp/OrderTempService.java b/ssjygl-xsct-common/src/main/java/com/cowr/ssjygl/order/ordertemp/OrderTempService.java index 69211b7..94337b6 100644 --- a/ssjygl-xsct-common/src/main/java/com/cowr/ssjygl/order/ordertemp/OrderTempService.java +++ b/ssjygl-xsct-common/src/main/java/com/cowr/ssjygl/order/ordertemp/OrderTempService.java @@ -541,7 +541,7 @@ public class OrderTempService extends BaseService { "CUSTOMER_ID,\n" + "SUPERMARKET_ID,\n" + "PRODUCT_ID,\n" + - "INVOICE_TYPE,\n" + +// "INVOICE_TYPE,\n" + "SALE_TYPE,\n" + "ORDERCLUSTER_ID,\n" + "DATE_FORMAT( CREATE_TIME, '%Y-%m-%d' )"; diff --git a/ssjygl-xsct-common/src/main/java/com/cowr/ssjygl/overall/OverallService.java b/ssjygl-xsct-common/src/main/java/com/cowr/ssjygl/overall/OverallService.java index 0118c8e..f77e785 100644 --- a/ssjygl-xsct-common/src/main/java/com/cowr/ssjygl/overall/OverallService.java +++ b/ssjygl-xsct-common/src/main/java/com/cowr/ssjygl/overall/OverallService.java @@ -477,7 +477,7 @@ group by date } /** - * 最后 30 条销售记录 + * 最后 30 天销售记录 * * @param supermarket_id * @return @@ -487,7 +487,7 @@ group by date return Db.find("select t.sn, t.customer_id, t.customer_name, t.truck_license, t.weight, t.total_price, t.create_time, t.supermarket_id, s.name supermarket_name \n" + " from order_temp t\n" + " left join supermarket s on s.id = t.supermarket_id\n" + - " where t.state = 5 \n" + + " where t.state = 5 and t.sale_type != 2 \n" + " and t.supermarket_id = ? \n" + " AND t.CREATE_TIME >= CURDATE() - INTERVAL 30 DAY\n" + " AND t.CREATE_TIME < CURDATE()" + @@ -506,7 +506,7 @@ group by date " ) a on a.id = t.id\n" + " where a.id is not null\n" + " ) c on c.customer_id = t.customer_id\n" + - " where t.state = 5 \n" + + " where t.state = 5 and t.sale_type != 2 \n" + " AND t.CREATE_TIME >= CURDATE() - INTERVAL 30 DAY\n" + " AND t.CREATE_TIME < CURDATE()" + " order by t.create_time desc \n" + diff --git a/ssjygl-xsct-common/src/main/java/com/cowr/ssjygl/stat/invoice/InvoiceUseController.java b/ssjygl-xsct-common/src/main/java/com/cowr/ssjygl/stat/invoice/InvoiceUseController.java index 1ed806f..07758e8 100644 --- a/ssjygl-xsct-common/src/main/java/com/cowr/ssjygl/stat/invoice/InvoiceUseController.java +++ b/ssjygl-xsct-common/src/main/java/com/cowr/ssjygl/stat/invoice/InvoiceUseController.java @@ -30,4 +30,21 @@ public class InvoiceUseController extends Controller { render(new ExcelRender(tm + "_票据使用记录_" + System.currentTimeMillis() + ".xlsx", wb)); } } + + + @Before(DayValidator.class) + public void statuse1() { + String tm = get("tm"); + Integer invoice_type = getInt("invoice_type"); + String invoice_number = get("invoice_number"); + String invoice_code = get("invoice_code"); + Integer invoice_state = getInt("invoice_state"); + int export = getInt("export", 0); + if (export == 0) { + renderJson(Result.success(InvoiceUseService.me.statuse1(tm, invoice_type, invoice_number, invoice_code, invoice_state))); + }else{ + Workbook wb = InvoiceUseService.me.statuseExport1(tm, invoice_type, invoice_number, invoice_code, invoice_state); + render(new ExcelRender(tm + "_票据使用记录_" + System.currentTimeMillis() + ".xlsx", wb)); + } + } } diff --git a/ssjygl-xsct-common/src/main/java/com/cowr/ssjygl/stat/invoice/InvoiceUseService.java b/ssjygl-xsct-common/src/main/java/com/cowr/ssjygl/stat/invoice/InvoiceUseService.java index a7098d0..753775f 100644 --- a/ssjygl-xsct-common/src/main/java/com/cowr/ssjygl/stat/invoice/InvoiceUseService.java +++ b/ssjygl-xsct-common/src/main/java/com/cowr/ssjygl/stat/invoice/InvoiceUseService.java @@ -10,6 +10,7 @@ import org.apache.poi.ss.usermodel.*; import org.apache.poi.xssf.usermodel.XSSFWorkbook; import java.util.*; +import java.util.stream.Collectors; public class InvoiceUseService { private static Log log = Log.getLog(InvoiceUseService.class); @@ -390,4 +391,162 @@ public class InvoiceUseService { return wb; } + + public Record statuse1(String tm, Integer invoice_type, String invoice_number, String invoice_code, Integer invoice_state) { + String logsql = "select \n" + + " t.invoice_number, t.`code` invoice_code, t.state invoice_state, t.invoice_type\n" + + " , o.weight, o.total_price\n" + + " from invoice_log t\n" + + " left join order_temp o on o.sn = t.order_sn \n" + + " where o.sale_type != 2 \n"; + + List paramlog = new ArrayList<>(); + + logsql += " and t.create_time >= ? and t.create_time < date_add(?, interval 1 day)\n"; + + paramlog.add(tm); + paramlog.add(tm); + + if (StrKit.notBlank(invoice_number)) { + logsql += " and t.invoice_number like ? \n"; + + paramlog.add("%" + invoice_number.trim() + "%"); + } + + if (StrKit.notBlank(invoice_code)) { + logsql += " and t.code like ? \n"; + + paramlog.add("%" + invoice_code.trim() + "%"); + } + + if (invoice_state != null) { + logsql += " and t.state = ? \n"; + paramlog.add(invoice_state); + } + + if (invoice_type != null) { + logsql += " and t.invoice_type = ? \n"; + paramlog.add(invoice_type); + } + List list = new ArrayList<>(); + + String sql = "select t.invoice_number, t.invoice_code, t.invoice_state, t.invoice_type,sum(t.weight) as weight,sum(t.total_price) as total_price from (" + + logsql +" order by t.create_time ) t group by t.invoice_number, t.invoice_code, t.invoice_state, t.invoice_type"; + list = Db.find(sql, paramlog.toArray()); + + Record out = new Record(); + out.set("list", list); + out.set("cnt", list.size()); + out.set("total_weight", 0.0); + out.set("total_price", 0.0); + out.set("invoice_type_1_cnt", 0); + out.set("invoice_type_2_cnt", 0); + + for (Record record : list) { + record.set("rowkey", StrKit.getRandomUUID()); // 加一个唯一 key 给前端用 + + if (record.get("weight") != null) { + out.set("total_weight", out.getBigDecimal("total_weight").add(record.getBigDecimal("weight"))); + } + if (record.get("total_price") != null) { + out.set("total_price", out.getBigDecimal("total_price").add(record.getBigDecimal("total_price"))); + } + + if (record.getInt("invoice_type") == 1) { + out.set("invoice_type_1_cnt", out.getInt("invoice_type_1_cnt") + 1); + } else if (record.getInt("invoice_type") == 2) { + out.set("invoice_type_2_cnt", out.getInt("invoice_type_2_cnt") + 1); + } else { + log.debug("错误数据: %s", record.toJson()); + } + } + + return out; + + } + + public Workbook statuseExport1( + String tm, + Integer invoice_type, + String invoice_number, + String invoice_code, + Integer invoice_state + ) { + Record ret = statuse1(tm, invoice_type, invoice_number, invoice_code, invoice_state); + + List list = ret.get("list"); + + Workbook wb = new XSSFWorkbook(); + Sheet sheet = wb.createSheet("票据使用记录"); + + // 表头 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("发票状态"); + row.createCell(a++).setCellValue("总价(元)"); + row.createCell(a++).setCellValue("数量(吨)"); + + // 表头 end + + int end_col = 20; + 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(i + 1); + row.createCell(a++).setCellValue(order.getStr("invoice_number")); + row.createCell(a++).setCellValue(order.getStr("invoice_code")); + row.createCell(a++).setCellValue(order.getInt("invoice_type") == 2 ? "专票" : "普票"); + if (order.get("invoice_state") != null) { + switch (order.getInt("invoice_state")) { + case 5: + row.createCell(a++).setCellValue("已使用"); + break; + case 9: + row.createCell(a++).setCellValue("已作废"); + break; + default: + row.createCell(a++).setCellValue(""); + } + } else { + row.createCell(a++).setCellValue(""); + } + row.createCell(a++).setCellValue(DataUtil.getDefaultByRecord(order, "total_price")); + row.createCell(a++).setCellValue(DataUtil.getDefaultByRecord(order, "weight")); + } + + // 通用单元格格式 + Font font = wb.createFont(); + CellStyle cellStyle = wb.createCellStyle(); + font.setFontHeight((short) (10 * 20)); + font.setFontName("宋体"); + cellStyle.setAlignment(HorizontalAlignment.CENTER);//水平居中 + cellStyle.setVerticalAlignment(VerticalAlignment.CENTER);//垂直居中 + cellStyle.setFont(font); + + // 设置通用单元格格式 + for (int r = 0; r < datalen + 1; r++) { + row = sheet.getRow(r); + if (row == null) { + row = sheet.createRow(r); + } + + for (int c = 0; c < end_col + 1; c++) { + Cell cell = row.getCell(c); + + if (cell == null) { + cell = row.createCell(c); + } + cell.setCellStyle(cellStyle); + } + } + + return wb; + } } diff --git a/ssjygl-xsct-service/src/main/java/com/cowr/service/ssjygl/invoice/log/InvoiceLogSyncService.java b/ssjygl-xsct-service/src/main/java/com/cowr/service/ssjygl/invoice/log/InvoiceLogSyncService.java index f24a5dd..a62c7d6 100644 --- a/ssjygl-xsct-service/src/main/java/com/cowr/service/ssjygl/invoice/log/InvoiceLogSyncService.java +++ b/ssjygl-xsct-service/src/main/java/com/cowr/service/ssjygl/invoice/log/InvoiceLogSyncService.java @@ -265,7 +265,8 @@ public class InvoiceLogSyncService extends BaseSyncService { } if (invoiceLog.getInvoiceType() == 1) { - return cancelType1(invoiceLog, invalid_memo, sysuser); +// return cancelType1(invoiceLog, invalid_memo, sysuser); + return cancelType2(invoiceLog, invalid_memo, sysuser); } else if (invoiceLog.getInvoiceType() == 2) { return cancelType2(invoiceLog, invalid_memo, sysuser); } else { @@ -282,7 +283,7 @@ public class InvoiceLogSyncService extends BaseSyncService { } if (invoiceLog.getInvoiceType() == 1) { - return cancelType1(invoiceLog, invalid_memo, sysuser); + return cancelType2(invoiceLog, invalid_memo, sysuser); } else if (invoiceLog.getInvoiceType() == 2) { return cancelType2(invoiceLog, invalid_memo, sysuser); } else {