You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
85 lines
4.0 KiB
Java
85 lines
4.0 KiB
Java
package com.engine.custom.archives.service;
|
|
|
|
import cn.hutool.core.util.ZipUtil;
|
|
import com.dcfs.fts.common.error.FtpException;
|
|
import com.engine.custom.archives.entity.PushArchivesBean;
|
|
import com.engine.custom.archives.util.ArchivesUtil;
|
|
import com.engine.custom.hg.util.HgUtils;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
import weaver.conn.RecordSet;
|
|
import weaver.general.Util;
|
|
|
|
import java.io.File;
|
|
import java.io.FileOutputStream;
|
|
import java.io.IOException;
|
|
import java.io.OutputStream;
|
|
import java.text.SimpleDateFormat;
|
|
import java.util.Date;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
|
|
public class SignReportPushArchivesService {
|
|
public static Logger log = LoggerFactory.getLogger("Archives");
|
|
private static String filePath;
|
|
private static String Url;
|
|
private static String templatePath; // 模板文件路径
|
|
private static final String zwdir = "正文";
|
|
private static final String fjdir = "附件";
|
|
private static final String cbddir = "承办单";
|
|
private static final String zlcdir = "承办单" + File.separator + "子流程";
|
|
private static final String lzxxdir = "流转信息";
|
|
private static final String fjFile = "附件";
|
|
private static final String fjWord = "附件";
|
|
private static final String zwWord = "正文";
|
|
private static final String lhgWord = "留痕稿";
|
|
private static final String lcfjWord = "流程附件";
|
|
private static final String qzyjfjWord = "签字意见附件";
|
|
private static final String wjcldWord = "文件处理单";
|
|
private static final String wjlzxxWord = "文件流转信息";
|
|
|
|
public void setProp(Map<String, String> param) {
|
|
filePath = Util.null2String(param.get("filePath"));
|
|
Url = Util.null2String(param.get("Url"));
|
|
templatePath = Util.null2String(param.get("templatePath"));
|
|
}
|
|
|
|
public void pushArchives(Map<String, String> param) {
|
|
Date date = ArchivesUtil.getDate();
|
|
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd");
|
|
String format = dateFormat.format(date);
|
|
SimpleDateFormat yyyyMMddHHmmss = new SimpleDateFormat("yyyy-MM-dd HH:mm");
|
|
// 获取当前时间的第一秒
|
|
String firstSecond = yyyyMMddHHmmss.format(ArchivesUtil.getFirstSecondOfDate(date));
|
|
// 获取当前时间的最后一秒
|
|
String lastSecond = yyyyMMddHHmmss.format(ArchivesUtil.getLastSecondOfDate(date));
|
|
RecordSet recordSet = new RecordSet();
|
|
List<PushArchivesBean> result = ArchivesUtil.getResultList(recordSet, firstSecond, lastSecond, 0);
|
|
log.error("推送发文的数量:{}", result.size());
|
|
File file = ArchivesUtil.crFile(filePath + "/togd_" + new SimpleDateFormat("yyyyMMdd000000").format(date));
|
|
log.error("textfile:{}", file.getAbsolutePath());
|
|
for (PushArchivesBean pushArchivesBean : result) {
|
|
int id = pushArchivesBean.getId();
|
|
int request = pushArchivesBean.getRequest();
|
|
log.error("推送的requestId:{}", request);
|
|
try {
|
|
// String context = generateFile(request);
|
|
ArchivesUtil.writeToTxt(file.getPath(), file.getName(), context, true);
|
|
File txtzip = new File(filePath + File.separator + "togd_" + new SimpleDateFormat("yyyyMMdd000000").format(date) + ".zip");
|
|
log.error("textZipFile:{}", txtzip.getAbsolutePath());
|
|
OutputStream outputStream = new FileOutputStream(txtzip);
|
|
File writename = new File(file.getPath() + "/" + file.getName() + ".txt");
|
|
com.engine.custom.hg.util.ZipUtil.filesToZip(writename, outputStream, writename.getName());
|
|
log.error("writename:{}", writename.getName());
|
|
String s = HgUtils.putFile(txtzip.getAbsolutePath(), txtzip.getName());
|
|
// updateRecord(request, s);
|
|
log.error("textZip:{}", s);
|
|
} catch (FtpException e) {
|
|
e.printStackTrace();
|
|
} catch (IOException e) {
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
}
|
|
}
|