add:新增生成excel任务调度

This commit is contained in:
2024-05-20 16:34:10 +08:00
parent e1de520be0
commit b9854b2c66
2 changed files with 127 additions and 3 deletions

View File

@@ -104,11 +104,11 @@ public class AutoSaveIvtExcel {
Date date = new Date();
SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd");
String nowStr = format.format(date) + "-";
String path = properties.getPath().getPath() + type + File.separator + nowStr + "库存报表.xls";
String path = properties.getPath().getPath() + type + File.separator + nowStr + "0库存报表.xls";
FileOutputStream fileOut = new FileOutputStream(path);
LocalStorage localStorage = new LocalStorage(
nowStr + "库存报表.xls",
nowStr + "库存报表",
nowStr + "0库存报表.xls",
nowStr + "0库存报表",
"xls",
path,
type,

View File

@@ -0,0 +1,124 @@
package org.nl.wms.sch.manage;
import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import lombok.RequiredArgsConstructor;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.nl.modules.common.config.FileProperties;
import org.nl.modules.common.utils.FileUtil;
import org.nl.modules.tools.domain.LocalStorage;
import org.nl.modules.tools.repository.LocalStorageRepository;
import org.nl.modules.wql.WQL;
import org.redisson.api.RLock;
import org.redisson.api.RedissonClient;
import org.springframework.stereotype.Component;
import java.io.File;
import java.io.FileOutputStream;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.concurrent.TimeUnit;
@Slf4j
@Component
@RequiredArgsConstructor
public class AutoSaveIvtExcelTwo {
private final RedissonClient redissonClient;
private final FileProperties properties;
private final LocalStorageRepository localStorageRepository;
@SneakyThrows
public void run() {
RLock lock = redissonClient.getLock(this.getClass().getName());
boolean tryLock = lock.tryLock(0, TimeUnit.SECONDS);
try {
if (tryLock) {
HSSFWorkbook workbook = new HSSFWorkbook();
HSSFSheet sheet = workbook.createSheet("TestSheet");
HSSFRow row = sheet.createRow(0);
//设置第一列
row.createCell(0).setCellValue("仓库");
row.createCell(1).setCellValue("库区");
row.createCell(2).setCellValue("木箱码");
row.createCell(3).setCellValue("物料名称");
row.createCell(4).setCellValue("子卷号");
row.createCell(5).setCellValue("客户名称");
row.createCell(6).setCellValue("销售订单");
row.createCell(7).setCellValue("业务员");
row.createCell(8).setCellValue("入库时间");
row.createCell(9).setCellValue("单箱装卷数");
row.createCell(10).setCellValue("库龄");
row.createCell(11).setCellValue("产品规格(幅宽)");
row.createCell(12).setCellValue("净重");
row.createCell(13).setCellValue("长度");
row.createCell(14).setCellValue("物料标准厚度");
row.createCell(15).setCellValue("管件类型");
row.createCell(16).setCellValue("管件描述");
//查询库存明细
JSONObject map = new JSONObject();
map.put("flag", "22");
JSONArray resultJSONArray = WQL.getWO("QST_STRUCTIVT001").addParamMap(map).process().getResultJSONArray(0);
for (int i = 0; i < resultJSONArray.size(); i++) {
HSSFRow row_dtl = sheet.createRow(i+1);
JSONObject dtl = resultJSONArray.getJSONObject(i);
row_dtl.createCell(0).setCellValue(dtl.getString("stor_name"));
row_dtl.createCell(1).setCellValue(dtl.getString("sect_name"));
row_dtl.createCell(2).setCellValue(dtl.getString("package_box_sn"));
row_dtl.createCell(3).setCellValue(dtl.getString("material_name"));
row_dtl.createCell(4).setCellValue(dtl.getString("pcsn"));
row_dtl.createCell(5).setCellValue(dtl.getString("customer_description"));
row_dtl.createCell(6).setCellValue(dtl.getString("sale_order_name"));
row_dtl.createCell(7).setCellValue(dtl.getString("sales_owner"));
row_dtl.createCell(8).setCellValue(dtl.getString("instorage_time"));
row_dtl.createCell(9).setCellValue(dtl.getString("quanlity_in_box"));
row_dtl.createCell(10).setCellValue(dtl.getString("sid_day"));
row_dtl.createCell(11).setCellValue(String.format("%.0f", dtl.getDoubleValue("width")));
row_dtl.createCell(12).setCellValue(dtl.getString("net_weight"));
row_dtl.createCell(13).setCellValue(dtl.getString("length"));
row_dtl.createCell(14).setCellValue(dtl.getString("thickness_request"));
row_dtl.createCell(15).setCellValue(dtl.getString("paper_type"));
row_dtl.createCell(16).setCellValue(dtl.getString("paper_name"));
}
String type = FileUtil.getFileType("xls");
Date date = new Date();
SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd");
String nowStr = format.format(date) + "-";
String path = properties.getPath().getPath() + type + File.separator + nowStr + "8库存报表.xls";
FileOutputStream fileOut = new FileOutputStream(path);
LocalStorage localStorage = new LocalStorage(
nowStr + "8库存报表.xls",
nowStr + "8库存报表",
"xls",
path,
type,
"");
localStorageRepository.save(localStorage);
workbook.write(fileOut);
fileOut.close();
} else {
System.out.println("AutoQueryBillInfo" + DateUtil.now() + "被锁住!!!!");
}
} finally {
if (tryLock) {
lock.unlock();
}
}
}
}