|
|
|
@ -29,10 +29,7 @@ import weaver.workflow.workflow.WorkflowConfigComInfo;
|
|
|
|
|
|
|
|
|
|
import java.io.*;
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.util.zip.ZipEntry;
|
|
|
|
|
import java.util.zip.ZipOutputStream;
|
|
|
|
|
|
|
|
|
@ -55,8 +52,8 @@ public class ExportFjUtil {
|
|
|
|
|
try {
|
|
|
|
|
List<List> filePaths = new ArrayList();
|
|
|
|
|
bb.writeLog("zipDoc outPath: " + outPath + ".zip");
|
|
|
|
|
FileOutputStream fileOutputStream = new FileOutputStream(outPath + ".zip");
|
|
|
|
|
ZipOutputStream zipOutputStream = new ZipOutputStream(fileOutputStream);
|
|
|
|
|
FileOutputStream fileOutputStream = null;
|
|
|
|
|
// ZipOutputStream zipOutputStream = new ZipOutputStream(fileOutputStream);
|
|
|
|
|
BufferedInputStream br = null;
|
|
|
|
|
//文件的名称
|
|
|
|
|
//循环下载文件,并将之放到ZipOutputStream中
|
|
|
|
@ -64,24 +61,60 @@ public class ExportFjUtil {
|
|
|
|
|
bb.writeLog("zipDoc sql: select imagefilename,imagefileid from docimagefile where docid in (" + docIds + ")");
|
|
|
|
|
while (rs.next()) {
|
|
|
|
|
List filePath = new ArrayList();
|
|
|
|
|
filePath.add("附件/" + zipFileNames[0] + "/" +rs.getString(3));
|
|
|
|
|
filePath.add(rs.getString(1));
|
|
|
|
|
filePath.add("附件/" + zipFileNames[0] + "/" +rs.getString(1));
|
|
|
|
|
filePath.add(rs.getString(3));
|
|
|
|
|
filePaths.add(filePath);
|
|
|
|
|
zipOutputStream.putNextEntry(new ZipEntry(rs.getString(1)));
|
|
|
|
|
br = new BufferedInputStream(ImageFileManager.getInputStreamById(rs.getInt(2)));
|
|
|
|
|
byte[] buffer = new byte[1024];
|
|
|
|
|
int r = 0;
|
|
|
|
|
while ((r = br.read(buffer)) != -1) {
|
|
|
|
|
zipOutputStream.write(buffer, 0, r);
|
|
|
|
|
// zipOutputStream.putNextEntry(new ZipEntry(rs.getString(1)));
|
|
|
|
|
// br = new BufferedInputStream(ImageFileManager.getInputStreamById(rs.getInt(2)));
|
|
|
|
|
// byte[] buffer = new byte[1024];
|
|
|
|
|
// int r = 0;
|
|
|
|
|
// while ((r = br.read(buffer)) != -1) {
|
|
|
|
|
// zipOutputStream.write(buffer, 0, r);
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// 获取文件名和文件ID
|
|
|
|
|
String fileName = rs.getString(1);
|
|
|
|
|
int fileId = rs.getInt(2);
|
|
|
|
|
// 构造输出文件的完整路径
|
|
|
|
|
String outFilePath = outPath + "/" + fileName;
|
|
|
|
|
// 创建一个输出流,指向你要写入的文件
|
|
|
|
|
fileOutputStream = new FileOutputStream(outFilePath);
|
|
|
|
|
br = null;
|
|
|
|
|
try {
|
|
|
|
|
// 获取文件的输入流
|
|
|
|
|
br = new BufferedInputStream(ImageFileManager.getInputStreamById(fileId));
|
|
|
|
|
// 创建一个缓冲区来读取和写入数据
|
|
|
|
|
byte[] buffer = new byte[1024];
|
|
|
|
|
int bytesRead;
|
|
|
|
|
// 读取输入流并写入输出流
|
|
|
|
|
while ((bytesRead = br.read(buffer)) != -1) {
|
|
|
|
|
fileOutputStream.write(buffer, 0, bytesRead);
|
|
|
|
|
}
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
} finally {
|
|
|
|
|
// 关闭流
|
|
|
|
|
try {
|
|
|
|
|
if (br != null) {
|
|
|
|
|
br.close();
|
|
|
|
|
}
|
|
|
|
|
fileOutputStream.close();
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
zipOutputStream.flush();
|
|
|
|
|
zipOutputStream.close();
|
|
|
|
|
br.close();
|
|
|
|
|
// zipOutputStream.flush();
|
|
|
|
|
// zipOutputStream.close();
|
|
|
|
|
// br.close();
|
|
|
|
|
|
|
|
|
|
//回写附件导出路径 差旅报销导出20240320144153\附件\CS001.zip
|
|
|
|
|
String syncSql = "update " + tableName + " set " + tableField + " = ? where " + whereField + " = ? ";
|
|
|
|
|
bb.writeLog("syncSql: " + syncSql);
|
|
|
|
|
bb.writeLog("filePaths: " + filePaths);
|
|
|
|
|
rs.executeBatchSql(syncSql, filePaths);
|
|
|
|
|
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
@ -133,11 +166,20 @@ public class ExportFjUtil {
|
|
|
|
|
|
|
|
|
|
RecordSet rs = new RecordSet();
|
|
|
|
|
String tableName = "";
|
|
|
|
|
List<String> sheetNames = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
if ("TravelBorrow".equals(type)) {//差旅借款
|
|
|
|
|
//封装Sheet页名
|
|
|
|
|
sheetNames.add("借款单");
|
|
|
|
|
sheetNames.add("借款关联申请");
|
|
|
|
|
sheetNames.add("付款明细");
|
|
|
|
|
sheetNames.add("审批信息");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tableName = "uf_LC_cljkd";
|
|
|
|
|
// String acqDataSql = "select a.*, b.*, c. * ,d.* " +
|
|
|
|
|
String acqDataSql = "select " +
|
|
|
|
|
" a.id as a_id, \n" +
|
|
|
|
|
" a.yslcid as a_yslcid , a.id as a_id, \n" +
|
|
|
|
|
"a.requestid as a_requestid, \n" +
|
|
|
|
|
"a.djmc as a_djmc, \n" +
|
|
|
|
|
"a.djbh as a_djbh, \n" +
|
|
|
|
@ -224,6 +266,7 @@ public class ExportFjUtil {
|
|
|
|
|
|
|
|
|
|
//主表
|
|
|
|
|
TravelBorrow travelBorrow = new TravelBorrow();
|
|
|
|
|
travelBorrow.setId(Util.null2String(rs.getString("a_yslcid")));
|
|
|
|
|
travelBorrow.setDjmc(Util.null2String(rs.getString("a_djmc")));
|
|
|
|
|
travelBorrow.setDjbh(Util.null2String(rs.getString("a_djbh")));
|
|
|
|
|
travelBorrow.setJkdwbh(Util.null2String(rs.getString("a_jkdwbh")));
|
|
|
|
@ -270,6 +313,7 @@ public class ExportFjUtil {
|
|
|
|
|
data2List.add(travelBorrowDt2);
|
|
|
|
|
//明细表3
|
|
|
|
|
TravelBorrowDt3 travelBorrowDt3 = new TravelBorrowDt3();
|
|
|
|
|
travelBorrowDt3.setDetailId(Util.null2String(rs.getString("d_id")));
|
|
|
|
|
travelBorrowDt3.setJkdnm(Util.null2String(rs.getString("d_jkdnm")));
|
|
|
|
|
travelBorrowDt3.setSpjd(Util.null2String(rs.getString("d_spjd")));
|
|
|
|
|
travelBorrowDt3.setSpr(Util.null2String(rs.getString("d_spr")));
|
|
|
|
@ -277,14 +321,41 @@ public class ExportFjUtil {
|
|
|
|
|
travelBorrowDt3.setSpsj(Util.null2String(rs.getString("d_spsj")));
|
|
|
|
|
data3List.add(travelBorrowDt3);
|
|
|
|
|
}
|
|
|
|
|
datasList.add(dataList);
|
|
|
|
|
datasList.add(data1List);
|
|
|
|
|
datasList.add(data2List);
|
|
|
|
|
datasList.add(data3List);
|
|
|
|
|
// 使用LinkedHashSet来保持插入顺序,并自动去重
|
|
|
|
|
Set<TravelReimbur> myEntitiesWithoutDuplicates = new LinkedHashSet<>(dataList);
|
|
|
|
|
|
|
|
|
|
// 如果需要将Set转换回List,可以使用以下方式
|
|
|
|
|
List<TravelReimbur> myEntitiesListWithoutDuplicates = new ArrayList<>(myEntitiesWithoutDuplicates);
|
|
|
|
|
datasList.add(myEntitiesListWithoutDuplicates);
|
|
|
|
|
|
|
|
|
|
// 使用LinkedHashSet来保持插入顺序,并自动去重
|
|
|
|
|
Set<TravelReimbur> myEntitiesWithoutDuplicates1 = new LinkedHashSet<>(data1List);
|
|
|
|
|
|
|
|
|
|
// 如果需要将Set转换回List,可以使用以下方式
|
|
|
|
|
List<TravelReimbur> myEntitiesListWithoutDuplicates1 = new ArrayList<>(myEntitiesWithoutDuplicates1);
|
|
|
|
|
datasList.add(myEntitiesListWithoutDuplicates1);
|
|
|
|
|
|
|
|
|
|
// 使用LinkedHashSet来保持插入顺序,并自动去重
|
|
|
|
|
Set<TravelReimbur> myEntitiesWithoutDuplicates2 = new LinkedHashSet<>(data2List);
|
|
|
|
|
|
|
|
|
|
// 如果需要将Set转换回List,可以使用以下方式
|
|
|
|
|
List<TravelReimbur> myEntitiesListWithoutDuplicates2 = new ArrayList<>(myEntitiesWithoutDuplicates2);
|
|
|
|
|
datasList.add(myEntitiesListWithoutDuplicates2);
|
|
|
|
|
|
|
|
|
|
// 使用LinkedHashSet来保持插入顺序,并自动去重
|
|
|
|
|
Set<TravelReimbur> myEntitiesWithoutDuplicates3 = new LinkedHashSet<>(data3List);
|
|
|
|
|
|
|
|
|
|
// 如果需要将Set转换回List,可以使用以下方式
|
|
|
|
|
List<TravelReimbur> myEntitiesListWithoutDuplicates3 = new ArrayList<>(myEntitiesWithoutDuplicates3);
|
|
|
|
|
datasList.add(myEntitiesListWithoutDuplicates3);
|
|
|
|
|
|
|
|
|
|
exportDatas.put(type, datasList);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ("Invoice".equals(type)) {//发票
|
|
|
|
|
//封装Sheet页名
|
|
|
|
|
sheetNames.add("发票信息");
|
|
|
|
|
|
|
|
|
|
tableName = "uf_LC_fpxx";
|
|
|
|
|
String acqDataSql = "select a.* from " + tableName + " a where a.id in (" + dataIds + ")";
|
|
|
|
|
bb.writeLog("Invoice acqDataSql: " + acqDataSql);
|
|
|
|
@ -337,12 +408,21 @@ public class ExportFjUtil {
|
|
|
|
|
invoice.setZyrbh(Util.null2String(rs.getString("zyrbh")));
|
|
|
|
|
|
|
|
|
|
dataList.add(invoice);
|
|
|
|
|
|
|
|
|
|
datasList.add(dataList);
|
|
|
|
|
}
|
|
|
|
|
datasList.add(dataList);
|
|
|
|
|
exportDatas.put(type, datasList);
|
|
|
|
|
}
|
|
|
|
|
if ("TravelReimbur".equals(type)) {//差旅报销
|
|
|
|
|
//封装Sheet页名
|
|
|
|
|
sheetNames.add("差旅报销单");
|
|
|
|
|
sheetNames.add("差旅行程明细");
|
|
|
|
|
sheetNames.add("费用分摊");
|
|
|
|
|
sheetNames.add("关联申请单");
|
|
|
|
|
sheetNames.add("借款核销");
|
|
|
|
|
sheetNames.add("付款明细");
|
|
|
|
|
sheetNames.add("审批信息");
|
|
|
|
|
sheetNames.add("发票文件");
|
|
|
|
|
|
|
|
|
|
tableName = "uf_OA_clbxd";
|
|
|
|
|
// String acqDataSql = "select a.*, b.*, c. * ,d.*, e.*, f.*, g.*, h.* from " + tableName + " a " +
|
|
|
|
|
String acqDataSql = "select " +
|
|
|
|
@ -647,21 +727,79 @@ public class ExportFjUtil {
|
|
|
|
|
travelReimburDt7.setWjcclj(Util.null2String(rs.getString("h_wjcclj")));
|
|
|
|
|
data7List.add(travelReimburDt7);
|
|
|
|
|
}
|
|
|
|
|
datasList.add(dataList);
|
|
|
|
|
datasList.add(data1List);
|
|
|
|
|
datasList.add(data2List);
|
|
|
|
|
datasList.add(data3List);
|
|
|
|
|
datasList.add(data4List);
|
|
|
|
|
datasList.add(data5List);
|
|
|
|
|
datasList.add(data6List);
|
|
|
|
|
datasList.add(data7List);
|
|
|
|
|
// 使用LinkedHashSet来保持插入顺序,并自动去重
|
|
|
|
|
Set<TravelReimbur> myEntitiesWithoutDuplicates = new LinkedHashSet<>(dataList);
|
|
|
|
|
|
|
|
|
|
// 如果需要将Set转换回List,可以使用以下方式
|
|
|
|
|
List<TravelReimbur> myEntitiesListWithoutDuplicates = new ArrayList<>(myEntitiesWithoutDuplicates);
|
|
|
|
|
datasList.add(myEntitiesListWithoutDuplicates);
|
|
|
|
|
|
|
|
|
|
// 使用LinkedHashSet来保持插入顺序,并自动去重
|
|
|
|
|
Set<TravelReimbur> myEntitiesWithoutDuplicates1 = new LinkedHashSet<>(data1List);
|
|
|
|
|
|
|
|
|
|
// 如果需要将Set转换回List,可以使用以下方式
|
|
|
|
|
List<TravelReimbur> myEntitiesListWithoutDuplicates1 = new ArrayList<>(myEntitiesWithoutDuplicates1);
|
|
|
|
|
datasList.add(myEntitiesListWithoutDuplicates1);
|
|
|
|
|
|
|
|
|
|
// 使用LinkedHashSet来保持插入顺序,并自动去重
|
|
|
|
|
Set<TravelReimbur> myEntitiesWithoutDuplicates2 = new LinkedHashSet<>(data2List);
|
|
|
|
|
|
|
|
|
|
// 如果需要将Set转换回List,可以使用以下方式
|
|
|
|
|
List<TravelReimbur> myEntitiesListWithoutDuplicates2 = new ArrayList<>(myEntitiesWithoutDuplicates2);
|
|
|
|
|
datasList.add(myEntitiesListWithoutDuplicates2);
|
|
|
|
|
|
|
|
|
|
// 使用LinkedHashSet来保持插入顺序,并自动去重
|
|
|
|
|
Set<TravelReimbur> myEntitiesWithoutDuplicates3 = new LinkedHashSet<>(data3List);
|
|
|
|
|
|
|
|
|
|
// 如果需要将Set转换回List,可以使用以下方式
|
|
|
|
|
List<TravelReimbur> myEntitiesListWithoutDuplicates3 = new ArrayList<>(myEntitiesWithoutDuplicates3);
|
|
|
|
|
datasList.add(myEntitiesListWithoutDuplicates3);
|
|
|
|
|
|
|
|
|
|
// 使用LinkedHashSet来保持插入顺序,并自动去重
|
|
|
|
|
Set<TravelReimbur> myEntitiesWithoutDuplicates4 = new LinkedHashSet<>(data4List);
|
|
|
|
|
|
|
|
|
|
// 如果需要将Set转换回List,可以使用以下方式
|
|
|
|
|
List<TravelReimbur> myEntitiesListWithoutDuplicates4 = new ArrayList<>(myEntitiesWithoutDuplicates4);
|
|
|
|
|
datasList.add(myEntitiesListWithoutDuplicates4);
|
|
|
|
|
|
|
|
|
|
// 使用LinkedHashSet来保持插入顺序,并自动去重
|
|
|
|
|
Set<TravelReimbur> myEntitiesWithoutDuplicates5 = new LinkedHashSet<>(data5List);
|
|
|
|
|
|
|
|
|
|
// 如果需要将Set转换回List,可以使用以下方式
|
|
|
|
|
List<TravelReimbur> myEntitiesListWithoutDuplicates5 = new ArrayList<>(myEntitiesWithoutDuplicates5);
|
|
|
|
|
datasList.add(myEntitiesListWithoutDuplicates5);
|
|
|
|
|
|
|
|
|
|
// 使用LinkedHashSet来保持插入顺序,并自动去重
|
|
|
|
|
Set<TravelReimbur> myEntitiesWithoutDuplicates6 = new LinkedHashSet<>(data6List);
|
|
|
|
|
|
|
|
|
|
// 如果需要将Set转换回List,可以使用以下方式
|
|
|
|
|
List<TravelReimbur> myEntitiesListWithoutDuplicates6 = new ArrayList<>(myEntitiesWithoutDuplicates6);
|
|
|
|
|
datasList.add(myEntitiesListWithoutDuplicates6);
|
|
|
|
|
|
|
|
|
|
// 使用LinkedHashSet来保持插入顺序,并自动去重
|
|
|
|
|
Set<TravelReimbur> myEntitiesWithoutDuplicates7 = new LinkedHashSet<>(data7List);
|
|
|
|
|
|
|
|
|
|
// 如果需要将Set转换回List,可以使用以下方式
|
|
|
|
|
List<TravelReimbur> myEntitiesListWithoutDuplicates7 = new ArrayList<>(myEntitiesWithoutDuplicates7);
|
|
|
|
|
datasList.add(myEntitiesListWithoutDuplicates7);
|
|
|
|
|
|
|
|
|
|
// datasList.add(data1List);
|
|
|
|
|
// datasList.add(data2List);
|
|
|
|
|
// datasList.add(data3List);
|
|
|
|
|
// datasList.add(data4List);
|
|
|
|
|
// datasList.add(data5List);
|
|
|
|
|
// datasList.add(data6List);
|
|
|
|
|
// datasList.add(data7List);
|
|
|
|
|
exportDatas.put(type, datasList);
|
|
|
|
|
}
|
|
|
|
|
bb.writeLog("exportDatas: " + JSONObject.toJSONString(exportDatas));
|
|
|
|
|
|
|
|
|
|
// SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
|
|
|
|
|
// String fileName="/opt/weaver/ecology/filesystem/ebusecexport/"+ "差旅借款单" + sdf.format(new Date()) + ".xlsx";
|
|
|
|
|
exportExcelFile(outPath, fileName, exportDatas);
|
|
|
|
|
bb.writeLog("exportExcelFile start ");
|
|
|
|
|
bb.writeLog("outPath: " + outPath);
|
|
|
|
|
bb.writeLog("fileName: " + fileName);
|
|
|
|
|
exportExcelFile(outPath, fileName, exportDatas, sheetNames);
|
|
|
|
|
result = true;
|
|
|
|
|
}catch (Exception e) {
|
|
|
|
|
bb.writeLog("WorkflowExcelDataCmd Exception: " + e);
|
|
|
|
@ -672,18 +810,23 @@ public class ExportFjUtil {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void exportExcelFile(String outPath, String fileName, Map<String, List<List<?>> > exportDatas) {
|
|
|
|
|
|
|
|
|
|
public void exportExcelFile(String outPath, String fileName, Map<String, List<List<?>> > exportDatas, List<String> sheetNames) {
|
|
|
|
|
bb.writeLog("sheetNames: " + sheetNames);
|
|
|
|
|
ExcelWriter excelWriter = EasyExcel.write(outPath + fileName + ".xlsx").build();
|
|
|
|
|
|
|
|
|
|
int i = 0;
|
|
|
|
|
for (String key : exportDatas.keySet()) {
|
|
|
|
|
WriteSheet writeSheet = new WriteSheet();
|
|
|
|
|
List<List<?>> tempList = exportDatas.get(key);
|
|
|
|
|
int i = 0;
|
|
|
|
|
int j = 0;
|
|
|
|
|
for (List<?> tl: tempList) {
|
|
|
|
|
bb.writeLog("i: " + i);
|
|
|
|
|
bb.writeLog("--sheetName: " + sheetNames.get(i));
|
|
|
|
|
String sheetName = Util.null2String(sheetNames.get(i));
|
|
|
|
|
//这里 需要指定写用哪个class去写
|
|
|
|
|
writeSheet = EasyExcel.writerSheet(i, "第" + i + "个sheet页").head(tl.get(0).getClass()).build();
|
|
|
|
|
writeSheet = EasyExcel.writerSheet(j, sheetName).head(tl.get(0).getClass()).build();
|
|
|
|
|
excelWriter.write(tl, writeSheet);
|
|
|
|
|
j++;
|
|
|
|
|
i++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|