TASK:mixi;

This commit is contained in:
shahaibo
2024-09-14 21:30:42 +08:00
parent b080b47644
commit cf0b45ae7f

View File

@@ -76,9 +76,9 @@ public class MiTuExportScheduledTask {
public void executeWeeklyHeavyStockReport() { public void executeWeeklyHeavyStockReport() {
// customerPurchaseReport(); // customerPurchaseReport();
// NewJoinVIPReport(); // NewJoinVIPReport();
// weeklySellThrReport(); weeklySellThrReport();
// WeeklyHeavyStockReport(); WeeklyHeavyStockReport();
// QuarterlyProductGroupingReport(); QuarterlyProductGroupingReport();
// customerTypeAnalysis(); // customerTypeAnalysis();
// getBestSell30Days(); // getBestSell30Days();
// getData(); // getData();
@@ -655,8 +655,10 @@ public class MiTuExportScheduledTask {
} }
// 处理最后一个PLU_CODE的数据 // 处理最后一个PLU_CODE的数据
if (startRow < rowNum) { if (startRow < rowNum) {
mergeCells(sheet, startRow, rowNum - 1); String currentPluCode = transactionSummaryList.get(transactionSummaryList.size() - 1).getPLU_CODE();
linkImageToCell(workbook, sheet, startRow, rowNum - 1, headers.length - 1, imagePath, channelSftp); imagePath = getImagePath(currentPluCode);
mergeCells(sheet, startRow, rowNum);
linkImageToCell(workbook, sheet, startRow, rowNum, headers.length - 1, imagePath, channelSftp);
} }
} }
@@ -719,7 +721,6 @@ public class MiTuExportScheduledTask {
int rowNum = 1; int rowNum = 1;
int startRow = rowNum; int startRow = rowNum;
String previousPluCode = "";
String imagePath = ""; String imagePath = "";
// 创建并配置SFTP连接 // 创建并配置SFTP连接
@@ -737,16 +738,21 @@ public class MiTuExportScheduledTask {
channelSftp = (ChannelSftp) session.openChannel("sftp"); channelSftp = (ChannelSftp) session.openChannel("sftp");
channelSftp.connect(); channelSftp.connect();
if (weeklyHeavyStockList.size() > 0) {
String previousPluCode = weeklyHeavyStockList.get(0).getPLU_CODE();
for (WeeklyHeavyStock weeklyHeavyStock : weeklyHeavyStockList) { for (WeeklyHeavyStock weeklyHeavyStock : weeklyHeavyStockList) {
String currentPluCode = weeklyHeavyStock.getPLU_CODE(); String currentPluCode = weeklyHeavyStock.getPLU_CODE();
// 当 PLU_CODE 改变时处理图片和单元格合并
if (!currentPluCode.equals(previousPluCode)) { if (!currentPluCode.equals(previousPluCode)) {
imagePath = getImagePath(currentPluCode); imagePath = getImagePath(previousPluCode);
// 合并单元格并插入图片
if (startRow < rowNum - 1) { if (startRow < rowNum - 1) {
mergeCells(sheet, startRow, rowNum - 1); mergeCells(sheet, startRow, rowNum - 1);
if (imagePath != null && !imagePath.isEmpty()) {
linkImageToCell(workbook, sheet, startRow, rowNum - 1, headers.length - 1, imagePath, channelSftp); linkImageToCell(workbook, sheet, startRow, rowNum - 1, headers.length - 1, imagePath, channelSftp);
} }
}
startRow = rowNum; startRow = rowNum;
previousPluCode = currentPluCode; previousPluCode = currentPluCode;
} }
@@ -777,13 +783,15 @@ public class MiTuExportScheduledTask {
rowNum++; rowNum++;
} }
if (startRow < rowNum - 1) { if (startRow < rowNum) {
mergeCells(sheet, startRow, rowNum - 1); String currentPluCode = weeklyHeavyStockList.get(weeklyHeavyStockList.size() - 1).getPLU_CODE();
imagePath = getImagePath(currentPluCode);
mergeCells(sheet, startRow, rowNum);
if (imagePath != null && !imagePath.isEmpty()) { if (imagePath != null && !imagePath.isEmpty()) {
linkImageToCell(workbook, sheet, startRow, rowNum - 1, headers.length - 1, imagePath, channelSftp); linkImageToCell(workbook, sheet, startRow, rowNum, headers.length - 1, imagePath, channelSftp);
}
} }
} }
} catch (Exception e) { } catch (Exception e) {
log.info(imagePath); log.info(imagePath);
throw new RuntimeException("Error while processing the report", e); throw new RuntimeException("Error while processing the report", e);
@@ -898,7 +906,6 @@ public class MiTuExportScheduledTask {
int rowNum = 3; // 数据从第四行开始 int rowNum = 3; // 数据从第四行开始
int startRow = rowNum; int startRow = rowNum;
String previousPluCode = "";
String imagePath = ""; String imagePath = "";
// 创建并配置SFTP连接 // 创建并配置SFTP连接
@@ -916,15 +923,16 @@ public class MiTuExportScheduledTask {
channelSftp = (ChannelSftp) session.openChannel("sftp"); channelSftp = (ChannelSftp) session.openChannel("sftp");
channelSftp.connect(); channelSftp.connect();
if (weeklyHeavyStockList.size() > 0) {
String previousPluCode = weeklyHeavyStockList.get(0).getPLU_CODE();
for (WeeklyHeavyStock weeklyHeavyStock : weeklyHeavyStockList) { for (WeeklyHeavyStock weeklyHeavyStock : weeklyHeavyStockList) {
if (!weeklyHeavyStock.getPLU_CODE().equals(previousPluCode)) { String currentPluCode = weeklyHeavyStock.getPLU_CODE();
imagePath = getImagePath(weeklyHeavyStock.getPLU_CODE()); if (!currentPluCode.equals(previousPluCode)) {
imagePath = getImagePath(previousPluCode);
// 新的PLU_CODE合并之前的单元格并插入图片 // 新的PLU_CODE合并之前的单元格并插入图片
if (startRow < rowNum - 1) { if (startRow < rowNum - 1) {
mergeCells(sheet, startRow, rowNum - 1); mergeCells(sheet, startRow, rowNum - 1);
if (imagePath != null && !imagePath.isEmpty()) { linkImageToCell(workbook, sheet, startRow, rowNum - 1, 0, imagePath, channelSftp);
linkImageToCell(workbook, sheet, startRow, rowNum - 1, 0, imagePath, channelSftp); // 插入图片到合并单元格
}
} }
startRow = rowNum; startRow = rowNum;
previousPluCode = weeklyHeavyStock.getPLU_CODE(); previousPluCode = weeklyHeavyStock.getPLU_CODE();
@@ -978,13 +986,14 @@ public class MiTuExportScheduledTask {
} }
// 确保处理最后一个Plu Code // 确保处理最后一个Plu Code
if (startRow < rowNum - 1 || previousPluCode != null) { if (startRow < rowNum) {
mergeCells(sheet, startRow, rowNum - 1); String currentPluCode = weeklyHeavyStockList.get(weeklyHeavyStockList.size() - 1).getPLU_CODE();
if (imagePath != null && !imagePath.isEmpty()) { imagePath = getImagePath(currentPluCode);
linkImageToCell(workbook, sheet, startRow, rowNum - 1, 0, imagePath, channelSftp); // 插入图片到合并单元格 mergeCells(sheet, startRow, rowNum);
} linkImageToCell(workbook, sheet, startRow, rowNum, 0, imagePath, channelSftp);
} }
}
} catch (Exception e) { } catch (Exception e) {
throw new RuntimeException("Error while processing the report", e); throw new RuntimeException("Error while processing the report", e);
} finally { } finally {