demand: 航线开票记录查询、导出、定制导出性能优化
committer: heyu
This commit is contained in:
parent
c9f50691ca
commit
d5404feec8
@ -99,47 +99,7 @@ public class EmisSettleInvoiceChRecordController extends BaseController
|
|||||||
@Log(title = "渠道开票记录表", businessType = BusinessType.EXPORT)
|
@Log(title = "渠道开票记录表", businessType = BusinessType.EXPORT)
|
||||||
@PostMapping("/export")
|
@PostMapping("/export")
|
||||||
public void export(HttpServletResponse response, EmisSettleInvoiceChRecord emisSettleInvoiceChRecord) {
|
public void export(HttpServletResponse response, EmisSettleInvoiceChRecord emisSettleInvoiceChRecord) {
|
||||||
List<EmisSettleInvoiceChRecord> list = emisSettleInvoiceChRecordService
|
emisSettleInvoiceChRecordService.export(response, emisSettleInvoiceChRecord);
|
||||||
.selectEmisSettleInvoiceChRecordList(emisSettleInvoiceChRecord);
|
|
||||||
List<EmisSettleInvoiceChRecordExportVO> exportList = new ArrayList<>();
|
|
||||||
for (EmisSettleInvoiceChRecord record : list) {
|
|
||||||
EmisSettleInvoiceChRecordExportVO vo = new EmisSettleInvoiceChRecordExportVO();
|
|
||||||
// 开票日期
|
|
||||||
if (record.getCreateTime() != null) {
|
|
||||||
vo.setInvoiceDate(new SimpleDateFormat("M月d日").format(record.getCreateTime()));
|
|
||||||
}
|
|
||||||
// 公司抬头
|
|
||||||
vo.setCompanyTitle(InvoiceExportHelper.cleanCompanyTitle(record.getCompanyName()));
|
|
||||||
// 发票号
|
|
||||||
vo.setInvoiceNo(record.getInvoiceNo());
|
|
||||||
// 时间
|
|
||||||
vo.setSendMonth(record.getSendMonth());
|
|
||||||
// 开票金额
|
|
||||||
vo.setOpenMoney(record.getOpenMoney().stripTrailingZeros().toPlainString());
|
|
||||||
// 开票公司
|
|
||||||
vo.setInvoiceCompany(InvoiceExportHelper.mapInvoiceCompany(record.getSalerCompanyName()));
|
|
||||||
// 备注
|
|
||||||
vo.setRemark(InvoiceExportHelper.processRemark(record));
|
|
||||||
vo.setCustomRemark(InvoiceExportHelper.processCustomRemark(record));
|
|
||||||
// 付款日期
|
|
||||||
vo.setPayDate(InvoiceExportHelper.processPayDate(record.getExportPayDays()));
|
|
||||||
// 业务员
|
|
||||||
vo.setSalesmen(record.getSalesmen());
|
|
||||||
// 快递公司
|
|
||||||
vo.setExpressCompany(record.getSalesmen());
|
|
||||||
// 面单单号
|
|
||||||
vo.setBillCode("1".equals(record.getSettleType()) ? record.getBillCode() : "");
|
|
||||||
// 结算类型
|
|
||||||
vo.setSettleType(record.getSettleType());
|
|
||||||
// 申请备注
|
|
||||||
vo.setApplyRemark(record.getApplyRemark());
|
|
||||||
exportList.add(vo);
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
InvoicePoiExportUtil.export(response, exportList);
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -13,6 +13,8 @@ import java.util.List;
|
|||||||
import com.xdadan.erp.emis.domain.EmisSettleInvoiceChRecord;
|
import com.xdadan.erp.emis.domain.EmisSettleInvoiceChRecord;
|
||||||
import com.xdadan.erp.emis.domain.exception.EmisBizError;
|
import com.xdadan.erp.emis.domain.exception.EmisBizError;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ClassName EmisSettleInvoiceChRecordService
|
* @ClassName EmisSettleInvoiceChRecordService
|
||||||
* @Description 渠道开票记录表
|
* @Description 渠道开票记录表
|
||||||
@ -92,4 +94,13 @@ public interface IEmisSettleInvoiceChRecordService
|
|||||||
public void autoDoQueryOpenBillStatus();
|
public void autoDoQueryOpenBillStatus();
|
||||||
|
|
||||||
public void doQueryAndUpdateChOpenBillStatus(String reqNo);
|
public void doQueryAndUpdateChOpenBillStatus(String reqNo);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 渠道开票定制导出
|
||||||
|
*
|
||||||
|
* @param response
|
||||||
|
* @param emisSettleInvoiceChRecord
|
||||||
|
*/
|
||||||
|
void export(HttpServletResponse response, EmisSettleInvoiceChRecord emisSettleInvoiceChRecord);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,21 +2,26 @@ package com.xdadan.erp.emis.service.excelCellStrategy;
|
|||||||
|
|
||||||
import com.xdadan.erp.emis.domain.EmisSettleInvoiceChRecordExportVO;
|
import com.xdadan.erp.emis.domain.EmisSettleInvoiceChRecordExportVO;
|
||||||
import org.apache.poi.ss.usermodel.*;
|
import org.apache.poi.ss.usermodel.*;
|
||||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
import org.apache.poi.xssf.streaming.SXSSFWorkbook;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class InvoicePoiExportUtil {
|
public class InvoicePoiExportUtil {
|
||||||
|
private static SXSSFWorkbook wb;
|
||||||
|
private static Sheet sheet;
|
||||||
|
private static CellStyle style;
|
||||||
|
private static int rowIndex = 1;
|
||||||
|
private static OutputStream outputStream;
|
||||||
|
|
||||||
public static void export(HttpServletResponse response, List<EmisSettleInvoiceChRecordExportVO> data)
|
public static void createExcelWriter(OutputStream os) throws Exception {
|
||||||
throws Exception {
|
outputStream = os;
|
||||||
Workbook wb = new XSSFWorkbook();
|
// 创建工作簿
|
||||||
Sheet sheet = wb.createSheet("渠道开票记录表");
|
wb = new SXSSFWorkbook(100); // 使用SXSSFWorkbook,每100行刷新一次
|
||||||
|
sheet = wb.createSheet("渠道开票记录表");
|
||||||
|
|
||||||
// 设置行高、字体、边框
|
// 设置行高、字体、边框
|
||||||
CellStyle style = wb.createCellStyle();
|
style = wb.createCellStyle();
|
||||||
Font font = wb.createFont();
|
Font font = wb.createFont();
|
||||||
font.setFontName("宋体");
|
font.setFontName("宋体");
|
||||||
font.setFontHeightInPoints((short) 10);
|
font.setFontHeightInPoints((short) 10);
|
||||||
@ -27,7 +32,8 @@ public class InvoicePoiExportUtil {
|
|||||||
style.setBorderRight(BorderStyle.THIN);
|
style.setBorderRight(BorderStyle.THIN);
|
||||||
|
|
||||||
// 表头
|
// 表头
|
||||||
String[] headers = { "开票日期", "公司抬头", "发票号", "时间", "开票金额", "开票公司", "备注", "定制备注", "付款日期", "业务员", "快递公司", "面单单号" };
|
String[] headers = { "开票日期", "公司抬头", "发票号", "时间", "开票金额", "开票公司", "备注", "定制备注", "付款日期", "业务员", "快递公司",
|
||||||
|
"面单单号" };
|
||||||
Row headRow = sheet.createRow(0);
|
Row headRow = sheet.createRow(0);
|
||||||
headRow.setHeightInPoints(30);
|
headRow.setHeightInPoints(30);
|
||||||
for (int i = 0; i < headers.length; i++) {
|
for (int i = 0; i < headers.length; i++) {
|
||||||
@ -41,11 +47,15 @@ public class InvoicePoiExportUtil {
|
|||||||
for (int i = 0; i < columnWidths.length; i++) {
|
for (int i = 0; i < columnWidths.length; i++) {
|
||||||
sheet.setColumnWidth(i, (int) (columnWidths[i] * 256));
|
sheet.setColumnWidth(i, (int) (columnWidths[i] * 256));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void writeBatch(List<EmisSettleInvoiceChRecordExportVO> data) throws Exception {
|
||||||
|
if (data == null || data.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// 数据
|
|
||||||
int rowIdx = 1;
|
|
||||||
for (EmisSettleInvoiceChRecordExportVO vo : data) {
|
for (EmisSettleInvoiceChRecordExportVO vo : data) {
|
||||||
Row row = sheet.createRow(rowIdx++);
|
Row row = sheet.createRow(rowIndex++);
|
||||||
row.setHeightInPoints(30);
|
row.setHeightInPoints(30);
|
||||||
int col = 0;
|
int col = 0;
|
||||||
row.createCell(col++).setCellValue(vo.getInvoiceDate());
|
row.createCell(col++).setCellValue(vo.getInvoiceDate());
|
||||||
@ -61,17 +71,22 @@ public class InvoicePoiExportUtil {
|
|||||||
row.createCell(col++).setCellValue(vo.getExpressCompany());
|
row.createCell(col++).setCellValue(vo.getExpressCompany());
|
||||||
row.createCell(col++).setCellValue(vo.getBillCode());
|
row.createCell(col++).setCellValue(vo.getBillCode());
|
||||||
|
|
||||||
for (int i = 0; i < headers.length; i++) {
|
for (int i = 0; i < 12; i++) {
|
||||||
row.getCell(i).setCellStyle(style);
|
row.getCell(i).setCellStyle(style);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 输出
|
|
||||||
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
|
||||||
response.setHeader("Content-Disposition", "attachment;filename=invoice_export.xlsx");
|
|
||||||
OutputStream os = response.getOutputStream();
|
|
||||||
wb.write(os);
|
|
||||||
os.flush();
|
|
||||||
wb.close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void finish() throws Exception {
|
||||||
|
if (wb != null) {
|
||||||
|
wb.write(outputStream);
|
||||||
|
wb.close();
|
||||||
|
wb = null;
|
||||||
|
sheet = null;
|
||||||
|
style = null;
|
||||||
|
rowIndex = 1;
|
||||||
|
outputStream = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -10,35 +10,41 @@
|
|||||||
|
|
||||||
package com.xdadan.erp.emis.service.impl;
|
package com.xdadan.erp.emis.service.impl;
|
||||||
|
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.concurrent.*;
|
||||||
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSONArray;
|
import com.alibaba.fastjson.JSONArray;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.github.pagehelper.PageHelper;
|
||||||
import com.xdadan.erp.common.utils.DateUtils;
|
import com.xdadan.erp.common.utils.DateUtils;
|
||||||
import com.xdadan.erp.common.utils.SecurityUtils;
|
import com.xdadan.erp.common.utils.SecurityUtils;
|
||||||
import com.xdadan.erp.common.utils.StringUtils;
|
import com.xdadan.erp.common.utils.StringUtils;
|
||||||
import com.xdadan.erp.emis.domain.EmisBaseInvoiceChInfo;
|
import com.xdadan.erp.emis.domain.*;
|
||||||
import com.xdadan.erp.emis.domain.EmisSettleBill;
|
|
||||||
import com.xdadan.erp.emis.domain.EmisSettleInvoiceRecord;
|
|
||||||
import com.xdadan.erp.emis.domain.enumtype.EmisBizErrorType;
|
import com.xdadan.erp.emis.domain.enumtype.EmisBizErrorType;
|
||||||
import com.xdadan.erp.emis.domain.exception.EmisBizError;
|
import com.xdadan.erp.emis.domain.exception.EmisBizError;
|
||||||
import com.xdadan.erp.emis.mapper.EmisBaseInvoiceChInfoMapper;
|
import com.xdadan.erp.emis.mapper.EmisBaseInvoiceChInfoMapper;
|
||||||
import com.xdadan.erp.emis.mapper.EmisSettleInvoiceRecordMapper;
|
import com.xdadan.erp.emis.mapper.EmisSettleInvoiceRecordMapper;
|
||||||
import com.xdadan.erp.emis.service.EmisBaseService;
|
import com.xdadan.erp.emis.service.EmisBaseService;
|
||||||
import com.xdadan.erp.emis.service.IEmisSettleBillService;
|
import com.xdadan.erp.emis.service.IEmisSettleBillService;
|
||||||
|
import com.xdadan.erp.emis.service.excelCellStrategy.InvoiceExportHelper;
|
||||||
|
import com.xdadan.erp.emis.service.excelCellStrategy.InvoicePoiExportUtil;
|
||||||
import com.xdadan.erp.emis.service.openbill.hx.HXOrderGoods;
|
import com.xdadan.erp.emis.service.openbill.hx.HXOrderGoods;
|
||||||
import com.xdadan.erp.emis.service.openbill.hx.HXOrderInfo;
|
import com.xdadan.erp.emis.service.openbill.hx.HXOrderInfo;
|
||||||
import com.xdadan.erp.emis.service.openbill.hx.HXSdk;
|
import com.xdadan.erp.emis.service.openbill.hx.HXSdk;
|
||||||
import com.xdadan.erp.emis.utils.WaybillHelper;
|
import com.xdadan.erp.emis.utils.WaybillHelper;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import com.xdadan.erp.emis.domain.EmisSettleInvoiceChRecord;
|
|
||||||
import com.xdadan.erp.emis.mapper.EmisSettleInvoiceChRecordMapper;
|
import com.xdadan.erp.emis.mapper.EmisSettleInvoiceChRecordMapper;
|
||||||
import com.xdadan.erp.emis.service.IEmisSettleInvoiceChRecordService;
|
import com.xdadan.erp.emis.service.IEmisSettleInvoiceChRecordService;
|
||||||
import org.springframework.util.CollectionUtils;
|
import org.springframework.util.CollectionUtils;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 渠道开票记录表Service业务层处理
|
* 渠道开票记录表Service业务层处理
|
||||||
*
|
*
|
||||||
@ -46,6 +52,7 @@ import org.springframework.util.CollectionUtils;
|
|||||||
* @date 2024-07-24 23:39:08
|
* @date 2024-07-24 23:39:08
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
|
@Slf4j
|
||||||
public class EmisSettleInvoiceChRecordServiceImpl extends EmisBaseService implements IEmisSettleInvoiceChRecordService
|
public class EmisSettleInvoiceChRecordServiceImpl extends EmisBaseService implements IEmisSettleInvoiceChRecordService
|
||||||
{
|
{
|
||||||
@Autowired
|
@Autowired
|
||||||
@ -60,6 +67,27 @@ public class EmisSettleInvoiceChRecordServiceImpl extends EmisBaseService implem
|
|||||||
@Autowired
|
@Autowired
|
||||||
private IEmisSettleBillService emisSettleBillService;
|
private IEmisSettleBillService emisSettleBillService;
|
||||||
|
|
||||||
|
// 创建线程池
|
||||||
|
private static final int AVAILABLE_PROCESSORS = Runtime.getRuntime().availableProcessors();
|
||||||
|
private static final ThreadPoolExecutor executor = new ThreadPoolExecutor(
|
||||||
|
AVAILABLE_PROCESSORS, // 核心线程数 - 使用CPU核心数
|
||||||
|
AVAILABLE_PROCESSORS * 2, // 最大线程数 - CPU核心数的2倍
|
||||||
|
60L, // 空闲线程存活时间
|
||||||
|
TimeUnit.SECONDS, // 时间单位
|
||||||
|
new LinkedBlockingQueue<>(1000), // 工作队列
|
||||||
|
new ThreadFactory() {
|
||||||
|
private final AtomicInteger threadNumber = new AtomicInteger(1);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Thread newThread(Runnable r) {
|
||||||
|
Thread t = new Thread(r, "export-thread-" + threadNumber.getAndIncrement());
|
||||||
|
t.setDaemon(true);
|
||||||
|
return t;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
new ThreadPoolExecutor.CallerRunsPolicy() // Rejection policy
|
||||||
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询渠道开票记录表
|
* 查询渠道开票记录表
|
||||||
*
|
*
|
||||||
@ -82,7 +110,111 @@ public class EmisSettleInvoiceChRecordServiceImpl extends EmisBaseService implem
|
|||||||
@Override
|
@Override
|
||||||
public List<EmisSettleInvoiceChRecord> selectEmisSettleInvoiceChRecordList(EmisSettleInvoiceChRecord emisSettleInvoiceChRecord)
|
public List<EmisSettleInvoiceChRecord> selectEmisSettleInvoiceChRecordList(EmisSettleInvoiceChRecord emisSettleInvoiceChRecord)
|
||||||
{
|
{
|
||||||
return emisSettleInvoiceChRecordMapper.selectEmisSettleInvoiceChRecordList(emisSettleInvoiceChRecord);
|
long startTime = System.currentTimeMillis();
|
||||||
|
List<EmisSettleInvoiceChRecord> emisSettleInvoiceChRecords = emisSettleInvoiceChRecordMapper.selectEmisSettleInvoiceChRecordList(emisSettleInvoiceChRecord);
|
||||||
|
long endTime = System.currentTimeMillis();
|
||||||
|
log.info("查询渠道开票记录列表完成, 耗时: {}ms", (endTime - startTime));
|
||||||
|
return emisSettleInvoiceChRecords;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void export(HttpServletResponse response, EmisSettleInvoiceChRecord emisSettleInvoiceChRecord) {
|
||||||
|
long startTime = System.currentTimeMillis();
|
||||||
|
log.info("Starting invoice record export, query parameters: {}", emisSettleInvoiceChRecord);
|
||||||
|
|
||||||
|
try {
|
||||||
|
response.setContentType("application/vnd.ms-excel");
|
||||||
|
response.setCharacterEncoding("utf-8");
|
||||||
|
String fileName = "invoice_records_" + new SimpleDateFormat("yyyyMMdd").format(new Date());
|
||||||
|
response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xlsx");
|
||||||
|
|
||||||
|
InvoicePoiExportUtil.createExcelWriter(response.getOutputStream());
|
||||||
|
|
||||||
|
int pageSize = 1000;
|
||||||
|
int pageNum = 1;
|
||||||
|
boolean hasMore = true;
|
||||||
|
|
||||||
|
List<Future<List<EmisSettleInvoiceChRecordExportVO>>> futures = new ArrayList<>();
|
||||||
|
int totalRecords = 0;
|
||||||
|
|
||||||
|
while (hasMore) {
|
||||||
|
final int currentPage = pageNum;
|
||||||
|
Future<List<EmisSettleInvoiceChRecordExportVO>> future = executor.submit(() -> {
|
||||||
|
PageHelper.startPage(currentPage, pageSize);
|
||||||
|
List<EmisSettleInvoiceChRecord> list = this.selectEmisSettleInvoiceChRecordList(
|
||||||
|
emisSettleInvoiceChRecord);
|
||||||
|
|
||||||
|
if (list == null || list.isEmpty()) {
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
List<EmisSettleInvoiceChRecordExportVO> exportList = new ArrayList<>();
|
||||||
|
for (EmisSettleInvoiceChRecord record : list) {
|
||||||
|
EmisSettleInvoiceChRecordExportVO vo = new EmisSettleInvoiceChRecordExportVO();
|
||||||
|
// 开票日期
|
||||||
|
if (record.getCreateTime() != null) {
|
||||||
|
vo.setInvoiceDate(new SimpleDateFormat("M月d日").format(record.getCreateTime()));
|
||||||
|
}
|
||||||
|
// 公司抬头
|
||||||
|
vo.setCompanyTitle(InvoiceExportHelper.cleanCompanyTitle(record.getCompanyName()));
|
||||||
|
// 发票号
|
||||||
|
vo.setInvoiceNo(record.getInvoiceNo());
|
||||||
|
// 时间
|
||||||
|
vo.setSendMonth(record.getSendMonth());
|
||||||
|
// 开票金额
|
||||||
|
vo.setOpenMoney(record.getOpenMoney().stripTrailingZeros().toPlainString());
|
||||||
|
// 开票公司
|
||||||
|
vo.setInvoiceCompany(InvoiceExportHelper.mapInvoiceCompany(record.getSalerCompanyName()));
|
||||||
|
// 备注
|
||||||
|
vo.setRemark(InvoiceExportHelper.processRemark(record));
|
||||||
|
// 定制备注
|
||||||
|
vo.setCustomRemark(InvoiceExportHelper.processCustomRemark(record));
|
||||||
|
// 付款日期
|
||||||
|
vo.setPayDate(InvoiceExportHelper.processPayDate(record.getExportPayDays()));
|
||||||
|
// 业务员
|
||||||
|
vo.setSalesmen(record.getSalesmen());
|
||||||
|
// 快递公司
|
||||||
|
vo.setExpressCompany(record.getSalesmen());
|
||||||
|
// 面单单号
|
||||||
|
vo.setBillCode("1".equals(record.getSettleType()) ? record.getBillCode() : "");
|
||||||
|
// 结算类型
|
||||||
|
vo.setSettleType(record.getSettleType());
|
||||||
|
// 申请备注
|
||||||
|
vo.setApplyRemark(record.getApplyRemark());
|
||||||
|
exportList.add(vo);
|
||||||
|
}
|
||||||
|
|
||||||
|
return exportList;
|
||||||
|
});
|
||||||
|
|
||||||
|
futures.add(future);
|
||||||
|
pageNum++;
|
||||||
|
|
||||||
|
if (future.get().isEmpty()) {
|
||||||
|
hasMore = false;
|
||||||
|
} else {
|
||||||
|
totalRecords += future.get().size();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Future<List<EmisSettleInvoiceChRecordExportVO>> future : futures) {
|
||||||
|
List<EmisSettleInvoiceChRecordExportVO> exportList = future.get();
|
||||||
|
if (!exportList.isEmpty()) {
|
||||||
|
InvoicePoiExportUtil.writeBatch(exportList);
|
||||||
|
exportList.clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
InvoicePoiExportUtil.finish();
|
||||||
|
|
||||||
|
long totalTime = System.currentTimeMillis() - startTime;
|
||||||
|
log.info("Export completed, total time: {}ms, average time per record: {}ms",
|
||||||
|
totalTime, totalRecords > 0 ? totalTime / totalRecords : 0);
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("Failed to export Excel", e);
|
||||||
|
throw new RuntimeException("Failed to export Excel", e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -23,6 +23,19 @@
|
|||||||
|
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
|
<resultMap type="BaseEntity" id="EmisBaseResultAll">
|
||||||
|
|
||||||
|
<result property="remark" column="remark" />
|
||||||
|
<result property="tenantId" column="tenant_id" />
|
||||||
|
<result property="delFlag" column="del_flag" />
|
||||||
|
<result property="createBy" column="create_by" />
|
||||||
|
<result property="createTime" column="create_time" />
|
||||||
|
<result property="updateBy" column="update_by" />
|
||||||
|
<result property="updateTime" column="update_time" />
|
||||||
|
<result property="createSite" column="create_site" />
|
||||||
|
<result property="updateSite" column="update_site" />
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
<!-- 查询区域名称 -->
|
<!-- 查询区域名称 -->
|
||||||
<select id="selectAreaNameById" parameterType="Long" resultType="string">
|
<select id="selectAreaNameById" parameterType="Long" resultType="string">
|
||||||
select a.name from emis_country_area a where a.id = #{id} limit 1
|
select a.name from emis_country_area a where a.id = #{id} limit 1
|
||||||
|
|||||||
@ -56,218 +56,267 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
|
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
|
<resultMap type="EmisSettleInvoiceChRecord" id="EmisSettleInvoiceChRecordListResult" extends="com.xdadan.erp.emis.mapper.EmisBaseMapper.EmisBaseResultAll">
|
||||||
|
<result property="id" column="id" />
|
||||||
|
<result property="reqNo" column="req_no" />
|
||||||
|
<result property="applySeqNo" column="apply_seq_no" />
|
||||||
|
<result property="blEcinv" column="bl_ecinv" />
|
||||||
|
<result property="invoiceType" column="invoice_type" />
|
||||||
|
<result property="realInvoiceType" column="real_invoice_type" />
|
||||||
|
<result property="companyName" column="company_name" />
|
||||||
|
<result property="companyTaxNo" column="company_tax_no" />
|
||||||
|
<result property="companyTel" column="company_tel" />
|
||||||
|
<result property="companyAddress" column="company_address" />
|
||||||
|
<result property="bankName" column="bank_name" />
|
||||||
|
<result property="bankAccNo" column="bank_acc_no" />
|
||||||
|
<result property="contact" column="contact" />
|
||||||
|
<result property="phone" column="phone" />
|
||||||
|
<result property="taxRate" column="tax_rate" />
|
||||||
|
<result property="openMoney" column="open_money" />
|
||||||
|
<result property="email" column="email" />
|
||||||
|
<result property="salerCompanyName" column="saler_company_name" />
|
||||||
|
<result property="salerCompanyTaxNo" column="saler_company_tax_no" />
|
||||||
|
<result property="salerCompanyTel" column="saler_company_tel" />
|
||||||
|
<result property="salerCompanyAddress" column="saler_company_address" />
|
||||||
|
<result property="salerBankName" column="saler_bank_name" />
|
||||||
|
<result property="salerBankAccNo" column="saler_bank_acc_no" />
|
||||||
|
<result property="salerContact" column="saler_contact" />
|
||||||
|
<result property="salerPhone" column="saler_phone" />
|
||||||
|
<result property="salerChecker" column="saler_checker" />
|
||||||
|
<result property="salerPayee" column="saler_payee" />
|
||||||
|
<result property="invoiceNo" column="invoice_no" />
|
||||||
|
<result property="filePath" column="file_path" />
|
||||||
|
<result property="qrPath" column="qr_path" />
|
||||||
|
<result property="opManCode" column="op_man_code" />
|
||||||
|
<result property="opDate" column="op_date" />
|
||||||
|
<result property="opSiteCode" column="op_site_code" />
|
||||||
|
<result property="openChId" column="open_ch_id" />
|
||||||
|
<result property="openChStatus" column="open_ch_status" />
|
||||||
|
<result property="openChStatusDesc" column="open_ch_status_desc" />
|
||||||
|
<result property="openComCode" column="open_com_code" />
|
||||||
|
<result property="extData" column="ext_data" />
|
||||||
|
<result property="sendMonth" column="send_month" />
|
||||||
|
<result property="settleType" column="settle_type" />
|
||||||
|
<result property="openBillRemark" column="open_bill_remark" />
|
||||||
|
<result property="payDays" column="pay_days" />
|
||||||
|
|
||||||
|
<result property="billMonth" column="bill_month" />
|
||||||
|
<result property="billCode" column="bill_code" />
|
||||||
|
<result property="salesmen" column="salesmen" />
|
||||||
|
<result property="applyManName" column="apply_man_name" />
|
||||||
|
<result property="applyRemark" column="apply_remark" />
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
<sql id="selectEmisSettleInvoiceChRecordVo">
|
<sql id="selectEmisSettleInvoiceChRecordVo">
|
||||||
select id, req_no, apply_seq_no, bl_ecinv, invoice_type, real_invoice_type, company_name, company_tax_no, company_tel, company_address, bank_name, bank_acc_no, contact, phone, tax_rate, open_money, email, saler_company_name, saler_company_tax_no, saler_company_tel, saler_company_address, saler_bank_name, saler_bank_acc_no, saler_contact, saler_phone, saler_checker, saler_payee, invoice_no, file_path, qr_path, op_man_code, op_date, op_site_code, open_ch_id, open_ch_status, open_ch_status_desc, open_com_code, ext_data, remark, del_flag, create_by, create_time, update_by, update_time, create_site, update_site from emis_settle_invoice_ch_record
|
select id, req_no, apply_seq_no, bl_ecinv, invoice_type, real_invoice_type, company_name, company_tax_no, company_tel, company_address, bank_name, bank_acc_no, contact, phone, tax_rate, open_money, email, saler_company_name, saler_company_tax_no, saler_company_tel, saler_company_address, saler_bank_name, saler_bank_acc_no, saler_contact, saler_phone, saler_checker, saler_payee, invoice_no, file_path, qr_path, op_man_code, op_date, op_site_code, open_ch_id, open_ch_status, open_ch_status_desc, open_com_code, ext_data, remark, del_flag, create_by, create_time, update_by, update_time, create_site, update_site from emis_settle_invoice_ch_record
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
<select id="selectEmisSettleInvoiceChRecordList" parameterType="EmisSettleInvoiceChRecord" resultMap="EmisSettleInvoiceChRecordResult">
|
<select id="selectEmisSettleInvoiceChRecordList" parameterType="EmisSettleInvoiceChRecord" resultMap="EmisSettleInvoiceChRecordListResult">
|
||||||
SELECT
|
SELECT
|
||||||
a.id, a.req_no, a.apply_seq_no, a.bl_ecinv, a.invoice_type, a.real_invoice_type, a.company_name, a.company_tax_no, a.company_tel,
|
a.*,
|
||||||
a.company_address, a.bank_name, a.bank_acc_no, a.contact, a.phone, a.tax_rate, a.open_money, a.email, a.saler_company_name, a.saler_company_tax_no,
|
bi.bill_month,
|
||||||
a.saler_company_tel, a.saler_company_address, a.saler_bank_name, a.saler_bank_acc_no, a.saler_contact, a.saler_phone, a.saler_checker, a.saler_payee,
|
bi.bill_code,
|
||||||
a.invoice_no, a.file_path, a.qr_path, a.op_man_code, a.op_date, a.op_site_code, a.open_ch_id, a.open_ch_status, a.open_ch_status_desc, a.open_com_code,
|
si.salesmen,
|
||||||
a.ext_data, a.remark, a.del_flag, a.create_by, a.create_time, a.update_by, a.update_time, a.create_site, a.update_site,
|
si.apply_man_name,
|
||||||
(SELECT GROUP_CONCAT(DISTINCT CONCAT(SUBSTRING(DATE_FORMAT(w.send_date, '%Y'), 3, 2), DATE_FORMAT(w.send_date, '%m')))
|
si.apply_remark,
|
||||||
FROM emis_waybill w
|
smi.send_month,
|
||||||
INNER JOIN emis_settle_invoice_rel ir ON w.bill_code = ir.bill_no
|
bri.settle_type,
|
||||||
WHERE ir.apply_seq_no = a.apply_seq_no) as send_month,
|
bri.open_bill_remark,
|
||||||
(SELECT b.settle_type
|
pdi.pay_days
|
||||||
FROM emis_settle_bill b
|
|
||||||
INNER JOIN emis_settle_invoice_bill_rel r ON b.settle_bill_no = r.settle_bill_no
|
|
||||||
WHERE r.apply_seq_no = a.apply_seq_no
|
|
||||||
LIMIT 1) as settle_type,
|
|
||||||
CASE
|
|
||||||
WHEN (SELECT b.settle_type
|
|
||||||
FROM emis_settle_bill b
|
|
||||||
INNER JOIN emis_settle_invoice_bill_rel r ON b.settle_bill_no = r.settle_bill_no
|
|
||||||
WHERE r.apply_seq_no = a.apply_seq_no
|
|
||||||
LIMIT 1) = '2'
|
|
||||||
THEN (
|
|
||||||
SELECT GROUP_CONCAT(DISTINCT
|
|
||||||
CONCAT(
|
|
||||||
CONCAT(SUBSTRING(DATE_FORMAT(w.send_date, '%Y'), 3, 2), DATE_FORMAT(w.send_date, '%m ')),
|
|
||||||
b.cust_name
|
|
||||||
) SEPARATOR '-'
|
|
||||||
)
|
|
||||||
FROM emis_waybill w
|
|
||||||
INNER JOIN emis_settle_invoice_rel ir ON w.bill_code = ir.bill_no
|
|
||||||
INNER JOIN emis_settle_invoice_bill_rel r ON ir.apply_seq_no = r.apply_seq_no
|
|
||||||
INNER JOIN emis_settle_bill b ON r.settle_bill_no = b.settle_bill_no
|
|
||||||
WHERE ir.apply_seq_no = a.apply_seq_no
|
|
||||||
)
|
|
||||||
ELSE (
|
|
||||||
SELECT GROUP_CONCAT(DISTINCT
|
|
||||||
CONCAT(
|
|
||||||
DATE_FORMAT(w.send_date, '%m%d '),
|
|
||||||
w.send_company
|
|
||||||
) SEPARATOR '-'
|
|
||||||
)
|
|
||||||
FROM emis_waybill w
|
|
||||||
INNER JOIN emis_settle_invoice_rel ir ON w.bill_code = ir.bill_no
|
|
||||||
WHERE ir.apply_seq_no = a.apply_seq_no
|
|
||||||
)
|
|
||||||
END as open_bill_remark,
|
|
||||||
(SELECT GROUP_CONCAT(DISTINCT
|
|
||||||
CONCAT(
|
|
||||||
DATE_FORMAT(pr.trade_date, '%m/%d'),
|
|
||||||
' 已付(',
|
|
||||||
CASE pr.pay_type
|
|
||||||
WHEN '1' THEN '企业微信收款'
|
|
||||||
WHEN '2' THEN '工行汇款3890'
|
|
||||||
WHEN '3' THEN '微信支付'
|
|
||||||
WHEN '4' THEN '支付宝'
|
|
||||||
WHEN '5' THEN '其他'
|
|
||||||
WHEN '6' THEN '招行付款'
|
|
||||||
ELSE pr.pay_type
|
|
||||||
END,
|
|
||||||
')'
|
|
||||||
)
|
|
||||||
)
|
|
||||||
FROM emis_settle_pay_record pr
|
|
||||||
INNER JOIN emis_settle_pay_bill_rel pbr ON pr.pay_id = pbr.pay_id
|
|
||||||
INNER JOIN emis_settle_invoice_bill_rel ibr ON ibr.settle_bill_no = pbr.settle_bill_no
|
|
||||||
WHERE ibr.apply_seq_no = a.apply_seq_no) as pay_days
|
|
||||||
FROM emis_settle_invoice_ch_record a
|
FROM emis_settle_invoice_ch_record a
|
||||||
<where>
|
LEFT JOIN (
|
||||||
del_flag='0'
|
SELECT
|
||||||
<if test="id != null "> and id = #{id}</if>
|
bd.id,
|
||||||
<if test="reqNo != null and reqNo != ''"> and req_no = #{reqNo}</if>
|
GROUP_CONCAT(DISTINCT DATE_FORMAT(w.send_date, '%Y%m') ORDER BY w.send_date) as bill_month,
|
||||||
<if test="applySeqNo != null and applySeqNo != ''"> and apply_seq_no = #{applySeqNo}</if>
|
GROUP_CONCAT(DISTINCT w.bill_code ORDER BY w.bill_code) as bill_code
|
||||||
<if test="blEcinv != null and blEcinv != ''"> and bl_ecinv = #{blEcinv}</if>
|
FROM emis_settle_invoice_ch_record bd
|
||||||
<if test="invoiceType != null and invoiceType != ''"> and invoice_type = #{invoiceType}</if>
|
LEFT JOIN emis_settle_invoice_rel ir ON ir.apply_seq_no = bd.apply_seq_no AND ir.del_flag = '0'
|
||||||
<if test="realInvoiceType != null and realInvoiceType != ''"> and real_invoice_type = #{realInvoiceType}</if>
|
LEFT JOIN emis_waybill w ON w.bill_code = ir.bill_no AND w.del_flag = '0'
|
||||||
<if test="companyName != null and companyName != ''"> and company_name = #{companyName}</if>
|
WHERE bd.del_flag = '0'
|
||||||
<if test="companyTaxNo != null and companyTaxNo != ''"> and company_tax_no = #{companyTaxNo}</if>
|
GROUP BY bd.id
|
||||||
<if test="companyTel != null and companyTel != ''"> and company_tel = #{companyTel}</if>
|
) bi ON bi.id = a.id
|
||||||
<if test="companyAddress != null and companyAddress != ''"> and company_address = #{companyAddress}</if>
|
LEFT JOIN (
|
||||||
<if test="bankName != null and bankName != ''"> and bank_name = #{bankName}</if>
|
SELECT
|
||||||
<if test="bankAccNo != null and bankAccNo != ''"> and bank_acc_no = #{bankAccNo}</if>
|
bd.id,
|
||||||
<if test="contact != null and contact != ''"> and contact = #{contact}</if>
|
GROUP_CONCAT(DISTINCT esb.salesmen) as salesmen,
|
||||||
<if test="phone != null and phone != ''"> and phone = #{phone}</if>
|
MAX(user.emp_name) as apply_man_name,
|
||||||
<if test="taxRate != null and taxRate != ''"> and tax_rate = #{taxRate}</if>
|
MAX(record.remark) as apply_remark
|
||||||
<if test="openMoney != null "> and open_money = #{openMoney}</if>
|
FROM emis_settle_invoice_ch_record bd
|
||||||
<if test="email != null and email != ''"> and email = #{email}</if>
|
LEFT JOIN emis_settle_invoice_record record ON record.apply_seq_no = bd.apply_seq_no AND record.del_flag = '0'
|
||||||
<if test="salerCompanyName != null and salerCompanyName != ''"> and saler_company_name = #{salerCompanyName}</if>
|
LEFT JOIN sys_user user ON user.user_id = record.create_by AND user.del_flag = '0'
|
||||||
<if test="salerCompanyTaxNo != null and salerCompanyTaxNo != ''"> and saler_company_tax_no = #{salerCompanyTaxNo}</if>
|
LEFT JOIN emis_settle_invoice_bill_rel ibr ON ibr.apply_seq_no = bd.apply_seq_no AND ibr.del_flag = '0'
|
||||||
<if test="salerCompanyTel != null and salerCompanyTel != ''"> and saler_company_tel = #{salerCompanyTel}</if>
|
LEFT JOIN emis_settle_bill esb ON esb.settle_bill_no = ibr.settle_bill_no AND esb.del_flag = '0'
|
||||||
<if test="salerCompanyAddress != null and salerCompanyAddress != ''"> and saler_company_address = #{salerCompanyAddress}</if>
|
WHERE bd.del_flag = '0'
|
||||||
<if test="salerBankName != null and salerBankName != ''"> and saler_bank_name = #{salerBankName}</if>
|
GROUP BY bd.id
|
||||||
<if test="salerBankAccNo != null and salerBankAccNo != ''"> and saler_bank_acc_no = #{salerBankAccNo}</if>
|
) si ON si.id = a.id
|
||||||
<if test="salerContact != null and salerContact != ''"> and saler_contact = #{salerContact}</if>
|
LEFT JOIN (
|
||||||
<if test="salerPhone != null and salerPhone != ''"> and saler_phone = #{salerPhone}</if>
|
SELECT
|
||||||
<if test="invoiceNo != null and invoiceNo != ''"> and invoice_no = #{invoiceNo}</if>
|
bd.id,
|
||||||
<if test="filePath != null and filePath != ''"> and file_path like concat('%', #{filePath}, '%')</if>
|
GROUP_CONCAT(DISTINCT CONCAT(SUBSTRING(DATE_FORMAT(w.send_date, '%Y'), 3, 2), DATE_FORMAT(w.send_date, '%m'))) as send_month
|
||||||
<if test="qrPath != null and qrPath != ''"> and qr_path like concat('%', #{qrPath}, '%')</if>
|
FROM emis_settle_invoice_ch_record bd
|
||||||
<if test="opManCode != null and opManCode != ''"> and op_man_code = #{opManCode}</if>
|
LEFT JOIN emis_settle_invoice_rel ir ON ir.apply_seq_no = bd.apply_seq_no AND ir.del_flag = '0'
|
||||||
<if test="opDate != null "> and op_date = #{opDate}</if>
|
LEFT JOIN emis_waybill w ON w.bill_code = ir.bill_no AND w.del_flag = '0'
|
||||||
<if test="opSiteCode != null and opSiteCode != ''"> and op_site_code = #{opSiteCode}</if>
|
WHERE bd.del_flag = '0'
|
||||||
<if test="openChId != null and openChId != ''"> and open_ch_id = #{openChId}</if>
|
GROUP BY bd.id
|
||||||
<if test="openChStatus != null and openChStatus != ''"> and open_ch_status = #{openChStatus}</if>
|
) smi ON smi.id = a.id
|
||||||
<if test="openChStatusDesc != null and openChStatusDesc != ''"> and open_ch_status_desc like concat('%', #{openChStatusDesc}, '%')</if>
|
LEFT JOIN (
|
||||||
<if test="openComCode != null and openComCode != ''"> and open_com_code = #{openComCode}</if>
|
SELECT
|
||||||
<if test="extData != null and extData != ''"> and ext_data like concat('%', #{extData}, '%')</if>
|
bd.id,
|
||||||
<if test="remark != null and remark != ''"> and remark like concat('%', #{remark}, '%')</if>
|
GROUP_CONCAT(DISTINCT
|
||||||
<if test="delFlag != null and delFlag != ''"> and del_flag like concat('%', #{delFlag}, '%')</if>
|
CONCAT(
|
||||||
<if test="createBy != null and createBy != ''"> and create_by like concat('%', #{createBy}, '%')</if>
|
DATE_FORMAT(pr.trade_date, '%m/%d'),
|
||||||
<if test="createTime != null "> and create_time = #{createTime}</if>
|
' 已付(',
|
||||||
<if test="updateBy != null and updateBy != ''"> and update_by like concat('%', #{updateBy}, '%')</if>
|
CASE pr.pay_type
|
||||||
<if test="updateTime != null "> and update_time = #{updateTime}</if>
|
WHEN '1' THEN '企业微信收款'
|
||||||
<if test="createSite != null and createSite != ''"> and create_site like concat('%', #{createSite}, '%')</if>
|
WHEN '2' THEN '工行汇款3890'
|
||||||
<if test="updateSite != null and updateSite != ''"> and update_site like concat('%', #{updateSite}, '%')</if>
|
WHEN '3' THEN '微信支付'
|
||||||
|
WHEN '4' THEN '支付宝'
|
||||||
|
WHEN '5' THEN '其他'
|
||||||
|
WHEN '6' THEN '招行付款'
|
||||||
|
ELSE pr.pay_type
|
||||||
|
END,
|
||||||
|
')'
|
||||||
|
)
|
||||||
|
) as pay_days
|
||||||
|
FROM emis_settle_invoice_ch_record bd
|
||||||
|
LEFT JOIN emis_settle_invoice_bill_rel ibr ON ibr.apply_seq_no = bd.apply_seq_no AND ibr.del_flag = '0'
|
||||||
|
LEFT JOIN emis_settle_pay_bill_rel pbr ON ibr.settle_bill_no = pbr.settle_bill_no
|
||||||
|
LEFT JOIN emis_settle_pay_record pr ON pr.pay_id = pbr.pay_id
|
||||||
|
WHERE bd.del_flag = '0'
|
||||||
|
GROUP BY bd.id
|
||||||
|
) pdi ON pdi.id = a.id
|
||||||
|
LEFT JOIN (
|
||||||
|
SELECT
|
||||||
|
bd.id,
|
||||||
|
b.settle_type,
|
||||||
|
CASE
|
||||||
|
WHEN b.settle_type = '2' THEN
|
||||||
|
GROUP_CONCAT(DISTINCT
|
||||||
|
CONCAT(
|
||||||
|
CONCAT(SUBSTRING(DATE_FORMAT(w.send_date, '%Y'), 3, 2), DATE_FORMAT(w.send_date, '%m ')),
|
||||||
|
b.cust_name
|
||||||
|
) SEPARATOR '-'
|
||||||
|
)
|
||||||
|
ELSE
|
||||||
|
GROUP_CONCAT(DISTINCT
|
||||||
|
CONCAT(
|
||||||
|
DATE_FORMAT(w.send_date, '%m%d '),
|
||||||
|
w.send_company
|
||||||
|
) SEPARATOR '-'
|
||||||
|
)
|
||||||
|
END as open_bill_remark
|
||||||
|
FROM emis_settle_invoice_ch_record bd
|
||||||
|
LEFT JOIN emis_settle_invoice_rel ir ON ir.apply_seq_no = bd.apply_seq_no AND ir.del_flag = '0'
|
||||||
|
LEFT JOIN emis_waybill w ON w.bill_code = ir.bill_no AND w.del_flag = '0'
|
||||||
|
LEFT JOIN emis_settle_invoice_bill_rel ibr ON ibr.apply_seq_no = bd.apply_seq_no AND ibr.del_flag = '0'
|
||||||
|
LEFT JOIN emis_settle_bill b ON b.settle_bill_no = ibr.settle_bill_no AND b.del_flag = '0'
|
||||||
|
WHERE bd.del_flag = '0'
|
||||||
|
GROUP BY bd.id, b.settle_type
|
||||||
|
) bri ON bri.id = a.id
|
||||||
|
WHERE a.del_flag = '0'
|
||||||
|
<if test="id != null">AND a.id = #{id}</if>
|
||||||
|
<if test="reqNo != null and reqNo != ''">AND a.req_no = #{reqNo}</if>
|
||||||
|
<if test="applySeqNo != null and applySeqNo != ''">AND a.apply_seq_no = #{applySeqNo}</if>
|
||||||
|
<if test="blEcinv != null and blEcinv != ''">AND a.bl_ecinv = #{blEcinv}</if>
|
||||||
|
<if test="invoiceType != null and invoiceType != ''">AND a.invoice_type = #{invoiceType}</if>
|
||||||
|
<if test="realInvoiceType != null and realInvoiceType != ''"> and a.real_invoice_type = #{realInvoiceType}</if>
|
||||||
|
<if test="companyName != null and companyName != ''">AND a.company_name = #{companyName}</if>
|
||||||
|
<if test="companyTaxNo != null and companyTaxNo != ''"> and a.company_tax_no = #{companyTaxNo}</if>
|
||||||
|
<if test="companyTel != null and companyTel != ''"> and a.company_tel = #{companyTel}</if>
|
||||||
|
<if test="companyAddress != null and companyAddress != ''"> and a.company_address = #{companyAddress}</if>
|
||||||
|
<if test="bankName != null and bankName != ''"> and a.bank_name = #{bankName}</if>
|
||||||
|
<if test="bankAccNo != null and bankAccNo != ''"> and a.bank_acc_no = #{bankAccNo}</if>
|
||||||
|
<if test="contact != null and contact != ''"> and a.contact = #{contact}</if>
|
||||||
|
<if test="phone != null and phone != ''"> and a.phone = #{phone}</if>
|
||||||
|
<if test="taxRate != null and taxRate != ''"> and a.tax_rate = #{taxRate}</if>
|
||||||
|
<if test="openMoney != null "> and a.open_money = #{openMoney}</if>
|
||||||
|
<if test="email != null and email != ''"> and a.email = #{email}</if>
|
||||||
|
<if test="salerCompanyName != null and salerCompanyName != ''"> and a.saler_company_name = #{salerCompanyName}</if>
|
||||||
|
<if test="salerCompanyTaxNo != null and salerCompanyTaxNo != ''"> and a.saler_company_tax_no = #{salerCompanyTaxNo}</if>
|
||||||
|
<if test="salerCompanyTel != null and salerCompanyTel != ''"> and a.saler_company_tel = #{salerCompanyTel}</if>
|
||||||
|
<if test="salerCompanyAddress != null and salerCompanyAddress != ''"> and a.saler_company_address = #{salerCompanyAddress}</if>
|
||||||
|
<if test="salerBankName != null and salerBankName != ''"> and a.saler_bank_name = #{salerBankName}</if>
|
||||||
|
<if test="salerBankAccNo != null and salerBankAccNo != ''"> and a.saler_bank_acc_no = #{salerBankAccNo}</if>
|
||||||
|
<if test="salerContact != null and salerContact != ''"> and a.saler_contact = #{salerContact}</if>
|
||||||
|
<if test="salerPhone != null and salerPhone != ''"> and a.saler_phone = #{salerPhone}</if>
|
||||||
|
<if test="invoiceNo != null and invoiceNo != ''"> and a.invoice_no = #{invoiceNo}</if>
|
||||||
|
<if test="filePath != null and filePath != ''"> and a.file_path like concat('%', #{filePath}, '%')</if>
|
||||||
|
<if test="qrPath != null and qrPath != ''"> and a.qr_path like concat('%', #{qrPath}, '%')</if>
|
||||||
|
<if test="opManCode != null and opManCode != ''"> and a.op_man_code = #{opManCode}</if>
|
||||||
|
<if test="opDate != null "> and a.op_date = #{opDate}</if>
|
||||||
|
<if test="opSiteCode != null and opSiteCode != ''"> and a.op_site_code = #{opSiteCode}</if>
|
||||||
|
<if test="openChId != null and openChId != ''"> and a.open_ch_id = #{openChId}</if>
|
||||||
|
<if test="openChStatus != null and openChStatus != ''"> and a.open_ch_status = #{openChStatus}</if>
|
||||||
|
<if test="openChStatusDesc != null and openChStatusDesc != ''"> and a.open_ch_status_desc like concat('%', #{openChStatusDesc}, '%')</if>
|
||||||
|
<if test="openComCode != null and openComCode != ''"> and a.open_com_code = #{openComCode}</if>
|
||||||
|
<if test="extData != null and extData != ''"> and a.ext_data like concat('%', #{extData}, '%')</if>
|
||||||
|
<if test="remark != null and remark != ''"> and a.remark like concat('%', #{remark}, '%')</if>
|
||||||
|
<if test="delFlag != null and delFlag != ''"> and a.del_flag like concat('%', #{delFlag}, '%')</if>
|
||||||
|
<if test="createBy != null and createBy != ''"> and a.create_by like concat('%', #{createBy}, '%')</if>
|
||||||
|
<if test="createTime != null "> and a.create_time = #{createTime}</if>
|
||||||
|
<if test="updateBy != null and updateBy != ''"> and a.update_by like concat('%', #{updateBy}, '%')</if>
|
||||||
|
<if test="updateTime != null "> and a.update_time = #{updateTime}</if>
|
||||||
|
<if test="createSite != null and createSite != ''"> and a.create_site like concat('%', #{createSite}, '%')</if>
|
||||||
|
<if test="updateSite != null and updateSite != ''"> and a.update_site like concat('%', #{updateSite}, '%')</if>
|
||||||
|
|
||||||
<if test="params.beginCreateTime != null and params.beginCreateTime != ''">
|
<if test="params.beginCreateTime != null and params.beginCreateTime != ''">
|
||||||
and create_time <![CDATA[ >= ]]> #{params.beginCreateTime}
|
AND a.create_time >= STR_TO_DATE(#{params.beginCreateTime}, '%Y-%m-%d')
|
||||||
</if>
|
</if>
|
||||||
<if test="params.endCreateTime != null and params.endCreateTime != ''">
|
<if test="params.endCreateTime != null and params.endCreateTime != ''">
|
||||||
and create_time <![CDATA[ <= ]]> #{params.endCreateTime}
|
AND a.create_time <![CDATA[ <= ]]> DATE_ADD(STR_TO_DATE(#{params.endCreateTime}, '%Y-%m-%d'), INTERVAL 1 DAY)
|
||||||
</if>
|
</if>
|
||||||
|
|
||||||
|
<if test="params.billCode != null and params.billCode != ''">
|
||||||
|
AND EXISTS (
|
||||||
|
SELECT 1
|
||||||
|
FROM emis_settle_bill x2
|
||||||
|
INNER JOIN emis_settle_invoice_bill_rel x3 ON x2.settle_bill_no = x3.settle_bill_no
|
||||||
|
INNER JOIN emis_settle_sub_bill x4 ON x2.settle_bill_no = x4.settle_bill_no
|
||||||
|
WHERE x2.del_flag = '0'
|
||||||
|
AND x3.del_flag = '0'
|
||||||
|
AND x4.del_flag = '0'
|
||||||
|
AND a.apply_seq_no = x3.apply_seq_no
|
||||||
|
AND FIND_IN_SET(x4.bill_code, #{params.billCode})
|
||||||
|
)
|
||||||
|
</if>
|
||||||
|
|
||||||
<if test="params.billCode != null and params.billCode != ''">
|
<if test="params.settleBillNo != null and params.settleBillNo != ''">
|
||||||
and EXISTS(
|
AND EXISTS (
|
||||||
select 1 from emis_settle_bill x2,emis_settle_invoice_bill_rel x3,emis_settle_sub_bill x4
|
SELECT 1
|
||||||
where x2.del_flag = '0' and x3.del_flag = '0' and x4.del_flag='0'
|
FROM emis_settle_invoice_bill_rel x3
|
||||||
and a.apply_seq_no=x3.apply_seq_no
|
WHERE x3.del_flag = '0'
|
||||||
and x2.settle_bill_no=x3.settle_bill_no
|
AND a.apply_seq_no = x3.apply_seq_no
|
||||||
and x4.settle_bill_no=x2.settle_bill_no
|
AND FIND_IN_SET(x3.settle_bill_no, #{params.settleBillNo})
|
||||||
and FIND_IN_SET(x4.`bill_code`,#{params.billCode})
|
)
|
||||||
)
|
</if>
|
||||||
<!--
|
|
||||||
AND apply_seq_no IN (
|
|
||||||
SELECT x1.apply_seq_no FROM
|
|
||||||
emis_settle_invoice_record x1,
|
|
||||||
emis_settle_bill x2
|
|
||||||
WHERE
|
|
||||||
x1.del_flag = '0'
|
|
||||||
AND x2.del_flag = '0'
|
|
||||||
AND FIND_IN_SET( x2.settle_bill_no, x1.settle_bill_no )
|
|
||||||
AND exists (
|
|
||||||
select 1 from emis_settle_sub_bill b
|
|
||||||
where x2.settle_bill_no=b.settle_bill_no
|
|
||||||
and ( FIND_IN_SET(b.`bill_code`,#{params.billCode}) or b.bill_code like concat('%', #{params.billCode}, '%') )
|
|
||||||
)
|
|
||||||
)
|
|
||||||
-->
|
|
||||||
</if>
|
|
||||||
|
|
||||||
<if test="params.settleBillNo != null and params.settleBillNo != ''">
|
<if test="params.privSiteCode != null and params.privSiteCode != '88888'">
|
||||||
<!--
|
AND EXISTS (
|
||||||
AND apply_seq_no IN (
|
SELECT 1
|
||||||
SELECT x1.apply_seq_no FROM emis_settle_invoice_record x1,emis_settle_bill x2
|
FROM emis_settle_bill x2
|
||||||
WHERE x1.del_flag = '0' AND x2.del_flag = '0'
|
INNER JOIN emis_settle_invoice_bill_rel x3 ON x2.settle_bill_no = x3.settle_bill_no
|
||||||
AND FIND_IN_SET( x2.settle_bill_no, x1.settle_bill_no )
|
WHERE x2.del_flag = '0'
|
||||||
AND x2.settle_bill_no=#{params.settleBillNo}
|
AND x3.del_flag = '0'
|
||||||
)
|
AND a.apply_seq_no = x3.apply_seq_no
|
||||||
-->
|
AND (
|
||||||
and EXISTS(
|
x2.salesmen = #{params.privEmpName}
|
||||||
select 1 from emis_settle_invoice_bill_rel x3
|
OR x2.payee = #{params.privEmpName}
|
||||||
where x3.del_flag = '0'
|
OR EXISTS (
|
||||||
and a.apply_seq_no=x3.apply_seq_no
|
SELECT 1
|
||||||
AND FIND_IN_SET(x3.settle_bill_no, #{settleBillNo})
|
FROM emis_salesmen_rel esr
|
||||||
)
|
WHERE esr.del_flag = '0'
|
||||||
</if>
|
AND esr.bl_open = '1'
|
||||||
|
AND esr.sales_ass = #{params.privEmpName}
|
||||||
|
AND x2.salesmen = esr.salesmen
|
||||||
<if test="params.privSiteCode != null and params.privSiteCode != '88888'">
|
AND CURRENT_TIMESTAMP BETWEEN esr.start_date AND esr.end_date
|
||||||
and EXISTS(
|
)
|
||||||
select 1 from emis_settle_bill x2,emis_settle_invoice_bill_rel x3
|
)
|
||||||
where x2.del_flag = '0' and x3.del_flag = '0'
|
)
|
||||||
and a.apply_seq_no=x3.apply_seq_no and x2.settle_bill_no=x3.settle_bill_no
|
</if>
|
||||||
AND (
|
group by a.id
|
||||||
x2.salesmen = #{params.privEmpName}
|
ORDER BY a.create_time DESC
|
||||||
OR x2.payee = #{params.privEmpName}
|
|
||||||
OR x2.salesmen IN (
|
|
||||||
SELECT salesmen
|
|
||||||
FROM emis_salesmen_rel esr
|
|
||||||
where esr.del_flag='0' and esr.bl_open='1'
|
|
||||||
and now() <![CDATA[ >= ]]> esr.start_date and now() <![CDATA[ <= ]]> esr.end_date
|
|
||||||
and esr.sales_ass = #{params.privEmpName}
|
|
||||||
)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
<!--
|
|
||||||
AND apply_seq_no IN (
|
|
||||||
SELECT x1.apply_seq_no FROM
|
|
||||||
emis_settle_invoice_record x1,
|
|
||||||
emis_settle_bill x2
|
|
||||||
WHERE x1.del_flag = '0' AND x2.del_flag = '0'
|
|
||||||
AND FIND_IN_SET( x2.settle_bill_no, x1.settle_bill_no )
|
|
||||||
AND exists (
|
|
||||||
select 1 from emis_settle_sub_bill b
|
|
||||||
where x2.settle_bill_no=b.settle_bill_no
|
|
||||||
and ( b.salesmen=#{params.privEmpName} or b.payee=#{params.privEmpName}
|
|
||||||
or b.salesmen in(select salesmen from emis_salesmen_rel esr where esr.del_flag='0' and esr.bl_open='1' and now() <![CDATA[ >= ]]> esr.start_date and now() <![CDATA[ <= ]]> esr.end_date and esr.sales_ass=#{params.privEmpName})
|
|
||||||
)
|
|
||||||
)
|
|
||||||
) -->
|
|
||||||
</if>
|
|
||||||
|
|
||||||
</where>
|
|
||||||
order by create_time desc
|
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
|
||||||
<select id="checkHasSendToHx" parameterType="EmisSettleInvoiceChRecord" resultType="int">
|
<select id="checkHasSendToHx" parameterType="EmisSettleInvoiceChRecord" resultType="int">
|
||||||
select count(1) from emis_settle_invoice_ch_record
|
select count(1) from emis_settle_invoice_ch_record
|
||||||
where del_flag='0'
|
where del_flag='0'
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user