bug修改
parent
a41d653cf0
commit
ee802328be
|
|
@ -47,8 +47,8 @@ public class InvoiceLogService extends BaseService {
|
||||||
String selectsql = "select t.*, r.supermarket_id, s.name supermarket_name, \n" +
|
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.weight end weight, \n" +
|
||||||
" case when t.type = 3 then p.total_price end total_price, \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.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.settlement_user_name end settlement_user_name, \n" +
|
||||||
" case when t.type = 3 then p.customer_name end customer_name \n";
|
" case when t.type = 3 then p.customer_name end customer_name \n";
|
||||||
String fromsql = "from invoice_log t \n" +
|
String fromsql = "from invoice_log t \n" +
|
||||||
" left join invoice_receive r on r.id = t.invoice_receive_id \n" +
|
" left join invoice_receive r on r.id = t.invoice_receive_id \n" +
|
||||||
|
|
|
||||||
|
|
@ -216,7 +216,7 @@ public class OrderEndService extends BaseService {
|
||||||
"_" + DateTimeUtil.sdf.get().format(o.getDate("date")) +
|
"_" + DateTimeUtil.sdf.get().format(o.getDate("date")) +
|
||||||
"_" + o.getSupermarketId() +
|
"_" + o.getSupermarketId() +
|
||||||
"_" + o.getSaleType() +
|
"_" + o.getSaleType() +
|
||||||
"_" + o.getInvoiceType() +
|
// "_" + o.getInvoiceType() +
|
||||||
"_" + o.getProductId() +
|
"_" + o.getProductId() +
|
||||||
"_" + o.getOrderclusterId());
|
"_" + o.getOrderclusterId());
|
||||||
return o;
|
return o;
|
||||||
|
|
|
||||||
|
|
@ -541,7 +541,7 @@ public class OrderTempService extends BaseService {
|
||||||
"CUSTOMER_ID,\n" +
|
"CUSTOMER_ID,\n" +
|
||||||
"SUPERMARKET_ID,\n" +
|
"SUPERMARKET_ID,\n" +
|
||||||
"PRODUCT_ID,\n" +
|
"PRODUCT_ID,\n" +
|
||||||
"INVOICE_TYPE,\n" +
|
// "INVOICE_TYPE,\n" +
|
||||||
"SALE_TYPE,\n" +
|
"SALE_TYPE,\n" +
|
||||||
"ORDERCLUSTER_ID,\n" +
|
"ORDERCLUSTER_ID,\n" +
|
||||||
"DATE_FORMAT( CREATE_TIME, '%Y-%m-%d' )";
|
"DATE_FORMAT( CREATE_TIME, '%Y-%m-%d' )";
|
||||||
|
|
|
||||||
|
|
@ -477,7 +477,7 @@ group by date
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 最后 30 条销售记录
|
* 最后 30 天销售记录
|
||||||
*
|
*
|
||||||
* @param supermarket_id
|
* @param supermarket_id
|
||||||
* @return
|
* @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" +
|
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" +
|
" from order_temp t\n" +
|
||||||
" left join supermarket s on s.id = t.supermarket_id\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.supermarket_id = ? \n" +
|
||||||
" AND t.CREATE_TIME >= CURDATE() - INTERVAL 30 DAY\n" +
|
" AND t.CREATE_TIME >= CURDATE() - INTERVAL 30 DAY\n" +
|
||||||
" AND t.CREATE_TIME < CURDATE()" +
|
" AND t.CREATE_TIME < CURDATE()" +
|
||||||
|
|
@ -506,7 +506,7 @@ group by date
|
||||||
" ) a on a.id = t.id\n" +
|
" ) a on a.id = t.id\n" +
|
||||||
" where a.id is not null\n" +
|
" where a.id is not null\n" +
|
||||||
" ) c on c.customer_id = t.customer_id\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() - INTERVAL 30 DAY\n" +
|
||||||
" AND t.CREATE_TIME < CURDATE()" +
|
" AND t.CREATE_TIME < CURDATE()" +
|
||||||
" order by t.create_time desc \n" +
|
" order by t.create_time desc \n" +
|
||||||
|
|
|
||||||
|
|
@ -30,4 +30,21 @@ public class InvoiceUseController extends Controller {
|
||||||
render(new ExcelRender(tm + "_票据使用记录_" + System.currentTimeMillis() + ".xlsx", wb));
|
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));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@ import org.apache.poi.ss.usermodel.*;
|
||||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class InvoiceUseService {
|
public class InvoiceUseService {
|
||||||
private static Log log = Log.getLog(InvoiceUseService.class);
|
private static Log log = Log.getLog(InvoiceUseService.class);
|
||||||
|
|
@ -390,4 +391,162 @@ public class InvoiceUseService {
|
||||||
|
|
||||||
return wb;
|
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<Object> 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<Record> 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<Record> 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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -265,7 +265,8 @@ public class InvoiceLogSyncService extends BaseSyncService {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (invoiceLog.getInvoiceType() == 1) {
|
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) {
|
} else if (invoiceLog.getInvoiceType() == 2) {
|
||||||
return cancelType2(invoiceLog, invalid_memo, sysuser);
|
return cancelType2(invoiceLog, invalid_memo, sysuser);
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -282,7 +283,7 @@ public class InvoiceLogSyncService extends BaseSyncService {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (invoiceLog.getInvoiceType() == 1) {
|
if (invoiceLog.getInvoiceType() == 1) {
|
||||||
return cancelType1(invoiceLog, invalid_memo, sysuser);
|
return cancelType2(invoiceLog, invalid_memo, sysuser);
|
||||||
} else if (invoiceLog.getInvoiceType() == 2) {
|
} else if (invoiceLog.getInvoiceType() == 2) {
|
||||||
return cancelType2(invoiceLog, invalid_memo, sysuser);
|
return cancelType2(invoiceLog, invalid_memo, sysuser);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue