bug修改

dev
wany 2025-03-17 16:10:24 +08:00
parent e2569f8f8e
commit 16a70f68c7
4 changed files with 337 additions and 2 deletions

View File

@ -121,8 +121,8 @@ public class InvoiceLogService extends BaseService {
" tr.first_weight, tr.second_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.create_time end order_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 order_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.truck_license end truck_license, \n" +
" case when t.type = 3 then p.customer_texpayer_name end customer_texpayer_name, \n" +
" case when t.type = 3 then p.customer_texpayer_num end customer_texpayer_num, \n" +

View File

@ -550,4 +550,293 @@ public class OrderTempService extends BaseService {
return Db.find(sql,paraList.toArray());
}
public Workbook export1(String sn,
String truck_license,
Integer supermarket_id,
Integer supermarket_type,
Integer customer_id,
String customer_name,
String stm,
String etm,
Integer isprepaid,
Integer state,
Integer type,
String invoice_code,
Integer invoice_type,
String ticket_code,
Integer product_id,
Boolean invoice_code_is_null) {
String selectsql = "select t.* ,t.sn as old_sn,t.ticket_code as old_ticket_code,ot.ticket_code as new_ticket_code,ot.sn as new_sn" +
", p.in_time, p.out_time, p.in_which, p.out_which, p.in_mode, p.out_mode \n" +
", p.first_weight, p.second_weight, p.first_weigh_mode, p.second_weight_mode \n" +
", p.first_pic, p.first_weight_which, p.second_weight_which, p.second_pic \n" +
", p.arrive_time, p.type, p.memo transport_memo, s.name supermarket_name \n" +
", ot.trans_price in_trans_price, ot.weight in_weight \n";
String fromsql = "from order_temp t \n" +
" left join transport p on p.order_sn = t.sn \n" +
" left join supermarket s on s.id = t.supermarket_id \n" +
" left join order_transfer ot on ot.old_sn = t.sn \n" +
" where 1=1 ";
List<Object> paraList = new ArrayList<>();
if (supermarket_type != null && supermarket_type == 3) {
selectsql = "select t.*,t.ticket_code as new_ticket_code,t.sn as new_sn " +
", p.in_time, p.out_time, p.in_which, p.out_which, p.in_mode, p.out_mode \n" +
", p.first_weight, p.second_weight, p.first_weigh_mode, p.second_weight_mode \n" +
", p.first_pic, p.first_weight_which, p.second_weight_which, p.second_pic \n" +
", p.arrive_time, p.type, p.memo transport_memo, s.name supermarket_name \n" +
", s1.name customer_name \n" +
", t.trans_price in_trans_price, t.weight in_weight,ot.ticket_code as old_ticket_code \n";
fromsql = "from order_transfer t \n" +
" left join transport p on p.order_sn = t.sn \n" +
" left join supermarket s on s.id = t.sandfarm_id \n" +
" left join supermarket s1 on s1.id = t.supermarket_id \n" +
" left join order_temp ot on t.old_sn = ot.sn \n" +
" where 1=1 ";
supermarket_type = 1;
}
if (StrKit.notBlank(sn)) {
fromsql += " and t.sn like ? \n";
paraList.add("%" + sn.trim() + "%");
}
if (supermarket_id != null) {
fromsql += " and s.id = ? \n";
paraList.add(supermarket_id);
}
if (supermarket_type != null) {
fromsql += " and s.type = ? \n";
paraList.add(supermarket_type);
}
if (StrKit.notBlank(truck_license)) {
fromsql += " and t.truck_license like ? \n";
paraList.add("%" + truck_license.trim() + "%");
}
if (StrKit.notBlank(customer_name)) {
if (supermarket_type != null && supermarket_type == 1){
fromsql += " and s1.name like ? \n";
}else{
fromsql += " and t.customer_name like ? \n";
}
paraList.add("%" + customer_name.trim() + "%");
}
if (customer_id != null) {
fromsql += " and t.customer_id = ? \n";
paraList.add(customer_id);
}
if (StrKit.notBlank(stm)) {
fromsql += " and t.create_time >= ? \n";
paraList.add(stm);
}
if (StrKit.notBlank(etm)) {
fromsql += " and t.create_time <= ? \n";
paraList.add(etm);
}
if (isprepaid != null) {
fromsql += " and t.isprepaid = ? \n";
paraList.add(isprepaid);
}
if (product_id != null) {
fromsql += " and t.product_id = ? \n";
paraList.add(product_id);
}
if (invoice_code_is_null != null && invoice_code_is_null) {
fromsql += " and t.invoice_code is null \n";
} else {
if (StrKit.notBlank(invoice_code)) {
fromsql += " and t.invoice_code like ? \n";
paraList.add("%" + invoice_code.trim() + "%");
}
}
if (state != null) {
fromsql += " and t.state = ? \n";
paraList.add(state);
}
if (type != null && (type == 0 || type == 1)) {
fromsql += " and t.sale_type = ? \n";
paraList.add(type);
}
if (invoice_type != null) {
fromsql += " and t.invoice_type = ? \n";
paraList.add(invoice_type);
}
if (StrKit.notBlank(ticket_code)) {
fromsql += " and t.ticket_code like ? \n";
paraList.add("%" + ticket_code.trim() + "%");
}
String findSql = selectsql + fromsql;
findSql += " order by t.create_time desc";
List<Record> list = Db.find(findSql, paraList.toArray());
Workbook wb = new XSSFWorkbook();
Sheet sheet = wb.createSheet("运输日志");
int datalen = list.size();
int end_col = 15;
Row row = null;
if(supermarket_type == 0){
// 表头 start
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("单价");
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
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("sn"));
row.createCell(a++).setCellValue(DateTimeUtil.sdfhms.get().format(order.getDate("create_time")));
row.createCell(a++).setCellValue(order.getStr("supermarket_name"));
row.createCell(a++).setCellValue(order.getStr("customer_name"));
row.createCell(a++).setCellValue(DataUtil.getDefaultByRecord(order, "weight"));
row.createCell(a++).setCellValue(DataUtil.getDefaultByRecord(order, "unit_price"));
row.createCell(a++).setCellValue(DataUtil.getDefaultByRecord(order, "total_price"));
row.createCell(a++).setCellValue(order.getStr("truck_license"));
if(order.getInt("invoice_type") == null){
row.createCell(a++).setCellValue("");
}else{
row.createCell(a++).setCellValue(order.getInt("invoice_type") == 2 ? "专票" : "普票");
}
row.createCell(a++).setCellValue(order.getStr("invoice_number"));
row.createCell(a++).setCellValue(order.getStr("invoice_code"));
row.createCell(a++).setCellValue(order.getStr("ticket_code"));
switch (order.getInt("state")) {
case 1:
row.createCell(a++).setCellValue("新建");
break;
case 4:
row.createCell(a++).setCellValue("待付款");
break;
case 5:
row.createCell(a++).setCellValue("已出货");
break;
case 9:
row.createCell(a++).setCellValue("已取消");
break;
default:
row.createCell(a++).setCellValue("");
}
}
}else {
// 表头 start
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("取土场出场净重(吨)");
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
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("old_sn"));
row.createCell(a++).setCellValue(order.getStr("new_sn"));
row.createCell(a++).setCellValue(DateTimeUtil.sdfhms.get().format(order.getDate("create_time")));
row.createCell(a++).setCellValue(order.getStr("supermarket_name"));
row.createCell(a++).setCellValue(order.getStr("customer_name"));
row.createCell(a++).setCellValue(DataUtil.getDefaultByRecord(order, "weight"));
row.createCell(a++).setCellValue(DataUtil.getDefaultByRecord(order, "in_weight"));
row.createCell(a++).setCellValue(DataUtil.getDefaultByRecord(order, "in_trans_price"));
row.createCell(a++).setCellValue(order.getStr("truck_license"));
row.createCell(a++).setCellValue(order.getStr("old_ticket_code"));
row.createCell(a++).setCellValue(order.getStr("new_ticket_code"));
switch (order.getInt("state")) {
case 1:
row.createCell(a++).setCellValue("新建");
break;
case 4:
row.createCell(a++).setCellValue("待付款");
break;
case 5:
row.createCell(a++).setCellValue("已出货");
break;
case 9:
row.createCell(a++).setCellValue("已取消");
break;
default:
row.createCell(a++).setCellValue("");
}
}
}
// 通用单元格格式
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;
}
}

View File

@ -55,6 +55,29 @@ public class OrderTempController extends BaseController {
renderJson(Result.object(OrderTempService.me.find(pp, sn, truck_license, supermarket_id, supermarket_type, customer_id, customer_name, stm, etm, isprepaid, state, type, invoice_code, invoice_type, ticket_code, product_id, invoice_code_is_null)));
}
@Before(StartAndEndIntervalValidator.class)
public void export1() {
String stm = get("stm", now().minusDays(TM_TIME) + " 00:00:00");
String etm = get("etm",now() + " 23:59:59");
String truck_license = getUpperCaseVal("truck_license");
String customer_name = get("customer_name");
String sn = get("sn");
Integer state = getInt("state");
Integer type = getInt("type");
Integer product_id = getInt("product_id");
Integer supermarket_id = getInt("supermarket_id");
Integer supermarket_type = getInt("supermarket_type");
Integer isprepaid = getInt("isprepaid");
String invoice_code = get("invoice_code");
String ticket_code = get("ticket_code");
Integer invoice_type = getInt("invoice_type");
Integer customer_id = getInt("customer_id");
Boolean invoice_code_is_null = getBoolean("invoice_code_is_null");
Workbook wb = OrderTempService.me.export1(sn, truck_license, supermarket_id, supermarket_type, customer_id, customer_name, stm, etm, isprepaid, state, type, invoice_code, invoice_type, ticket_code, product_id, invoice_code_is_null);
render(new ExcelRender("运输日志_" + System.currentTimeMillis() + ".xlsx", wb));
}
@Before(StartAndEndIntervalValidator.class)
public void export() {
String stm = get("stm");

View File

@ -69,6 +69,29 @@ public class OrderTempController extends BaseController {
renderJson(Result.object(OrderTempService.me.find(pp, sn, truck_license, supermarket_id, supermarket_type, customer_id, customer_name, stm, etm, isprepaid, state, type, invoice_code, invoice_type, ticket_code, product_id, invoice_code_is_null)));
}
@Before(StartAndEndIntervalValidator.class)
public void export1() {
String stm = get("stm", now().minusDays(TM_TIME) + " 00:00:00");
String etm = get("etm",now() + " 23:59:59");
String truck_license = getUpperCaseVal("truck_license");
String customer_name = get("customer_name");
String sn = get("sn");
Integer state = getInt("state");
Integer type = getInt("type");
Integer product_id = getInt("product_id");
Integer supermarket_id = getInt("supermarket_id");
Integer supermarket_type = getInt("supermarket_type");
Integer isprepaid = getInt("isprepaid");
String invoice_code = get("invoice_code");
String ticket_code = get("ticket_code");
Integer invoice_type = getInt("invoice_type");
Integer customer_id = getInt("customer_id");
Boolean invoice_code_is_null = getBoolean("invoice_code_is_null");
Workbook wb = OrderTempService.me.export1(sn, truck_license, supermarket_id, supermarket_type, customer_id, customer_name, stm, etm, isprepaid, state, type, invoice_code, invoice_type, ticket_code, product_id, invoice_code_is_null);
render(new ExcelRender("运输日志_" + System.currentTimeMillis() + ".xlsx", wb));
}
@Before(StartAndEndIntervalValidator.class)
public void export() {
String stm = get("stm");