no message
parent
1ae2a15ce1
commit
4e99ee60b2
@ -0,0 +1,44 @@
|
||||
package com.cloudstore.eccom;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.weaver.base.msgcenter.channel.IMessageReceive;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import weaver.general.BaseBean;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class MessageReceiveTest implements IMessageReceive {
|
||||
public static Logger log = LoggerFactory.getLogger("Archives");
|
||||
private BaseBean bean=new BaseBean();
|
||||
@Override
|
||||
public void onMessage(String s) {
|
||||
log.error("onMessage:{}",s);
|
||||
bean.writeLog("onMessage:{}",s);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
log.error("onStartExecute");
|
||||
bean.writeLog("onStartExecute");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnd() {
|
||||
log.error("onEndExecute");
|
||||
bean.writeLog("onEndExecute");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setProp(Map<String, String> map) {
|
||||
log.error("setProp:{}",map);
|
||||
bean.writeLog("setProp:{}"+map);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setList(List<IMessageReceive> list) {
|
||||
log.error("setList:{}", JSONObject.toJSONString(list));
|
||||
bean.writeLog("setList:{}"+ JSONObject.toJSONString(list));
|
||||
}
|
||||
}
|
@ -0,0 +1,63 @@
|
||||
package com.engine.custom.archives.corn;
|
||||
|
||||
import com.engine.custom.archives.service.ReceivingPushArchivesService;
|
||||
import com.engine.custom.archives.service.SendingPushArchivesService;
|
||||
import com.engine.custom.archives.service.SignReportPushArchivesService;
|
||||
import com.engine.custom.archives.util.ArchivesUtil;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import weaver.interfaces.schedule.BaseCronJob;
|
||||
|
||||
import java.io.File;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
/***
|
||||
* 推送档案系统定时任务
|
||||
* @author rengp
|
||||
* @date 2024/4/7
|
||||
*/
|
||||
|
||||
public class PushArchivesCornMultiThread extends BaseCronJob {
|
||||
public String filePath = "/opt/weaver/archivesFile";
|
||||
public String Url = "http://14.1.206.240:18080/fcscloud/composite/upload";
|
||||
public String templatePath = "/opt/weaver/archivesFile/template/";
|
||||
public String reqid = "";
|
||||
public static Logger log = LoggerFactory.getLogger("Archives");
|
||||
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
log.info("PushArchivesCorn====Begin========");
|
||||
Date date = ArchivesUtil.getDate();
|
||||
String dateStr = new SimpleDateFormat("yyyyMMdd").format(date);
|
||||
HashMap<String, String> param = new HashMap<>();
|
||||
param.put("filePath",filePath+ File.separator+dateStr);
|
||||
param.put("Url",Url);
|
||||
// param.put("requestid",reqid);
|
||||
param.put("templatePath",templatePath);
|
||||
ExecutorService executor = Executors.newFixedThreadPool(3);
|
||||
executor.submit(new Thread(() -> {
|
||||
ReceivingPushArchivesService receivingservice = new ReceivingPushArchivesService();
|
||||
receivingservice.setProp(param);
|
||||
receivingservice.pushArchives(param);
|
||||
}));
|
||||
|
||||
executor.submit(new Thread(() -> {
|
||||
ReceivingPushArchivesService receivingservice = new ReceivingPushArchivesService();
|
||||
receivingservice.setProp(param);
|
||||
receivingservice.pushArchives(param);
|
||||
}));
|
||||
|
||||
|
||||
executor.submit(new Thread(() -> {
|
||||
SignReportPushArchivesService signReportservice =new SignReportPushArchivesService();
|
||||
signReportservice.setProp(param);
|
||||
signReportservice.pushArchives(param);
|
||||
}));
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,720 @@
|
||||
package com.engine.custom.archives.service.firstBranch;
|
||||
|
||||
|
||||
import cn.hutool.core.util.ZipUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
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.archives.util.KeyWord;
|
||||
import com.engine.custom.hg.util.HgUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.file.ImageFileManager;
|
||||
import weaver.general.StringUtil;
|
||||
import weaver.general.Util;
|
||||
import weaver.hrm.User;
|
||||
import weaver.hrm.company.DepartmentComInfo;
|
||||
import weaver.soa.workflow.request.RequestInfo;
|
||||
import weaver.soa.workflow.request.RequestService;
|
||||
import weaver.workflow.workflow.WorkflowBillComInfo;
|
||||
import weaver.workflow.workflow.WorkflowComInfo;
|
||||
|
||||
import java.io.*;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
|
||||
|
||||
public class FirstBranchReceivingPushArchivesService implements KeyWord {
|
||||
private static String filePath;
|
||||
private static String Url;
|
||||
private static String templatePath; // 模板文件路径
|
||||
private int endTime= 7;
|
||||
|
||||
public static Logger log = LoggerFactory.getLogger("Archives");
|
||||
|
||||
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"));
|
||||
endTime = Util.getIntValue(param.get("endTime"),7);
|
||||
}
|
||||
|
||||
|
||||
public void pushArchives(Map<String, String> param) {
|
||||
log.info("FirstBranchReceivingPushArchivesService ====Begin========{}", param);
|
||||
try {
|
||||
ZipUtil zipUtil = new ZipUtil();
|
||||
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(getFirstSecondOfDate(date));
|
||||
// 获取当前时间的最后一秒
|
||||
String lastSecond = yyyyMMddHHmmss.format(getLastSecondOfDate(date));
|
||||
|
||||
|
||||
RecordSet recordSet = new RecordSet();
|
||||
List<PushArchivesBean> result = ArchivesUtil.getResultList(recordSet, firstSecond, lastSecond, 4);
|
||||
log.error("推送分行收文的数量:{}", result.size());
|
||||
File file = ArchivesUtil.crFile(filePath + "/togd_" + new SimpleDateFormat("yyyyMMdd000000").format(date));
|
||||
log.error("textfile:{}", file.getAbsolutePath());
|
||||
for (PushArchivesBean pushArchivesBean : result) {
|
||||
if (ArchivesUtil.isAfterSevenAM(endTime)){
|
||||
log.info("超过执行时间:{}点暂停计划任务",endTime);
|
||||
break;
|
||||
}
|
||||
int requestid = pushArchivesBean.getRequest();
|
||||
try {
|
||||
log.error("requestid:{}", requestid);
|
||||
//1.生成文件及推送的txt
|
||||
String context = extracted(requestid);
|
||||
log.error("context:{}", context);
|
||||
//1.生成文件及推送的txt
|
||||
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(requestid, s);
|
||||
updateRecord(requestid,"esbtxtml",s);
|
||||
updateRecord(requestid,"zt","0");
|
||||
log.error("textZip:{}", s);
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
log.error("推送档案requestid:{}异常,异常原因为:{}",requestid,e.getMessage());
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.info("PushArchivesCorn====Exception========{}", e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void updateRecord(int requestids, String s) {
|
||||
String sql = "update uf_pushArchivesLog set esbtxtml = ? where request in ( " + requestids + " )";
|
||||
RecordSet recordSet = new RecordSet();
|
||||
recordSet.executeUpdate(sql, s);
|
||||
}
|
||||
|
||||
private String extracted(int requestid) throws FtpException, IOException {
|
||||
String newRequestid = "togd"+requestid;
|
||||
RequestService requestService = new RequestService();
|
||||
RequestInfo requestInfo = requestService.getRequest(Util.getIntValue(requestid), 100);
|
||||
String workflowid = requestInfo.getWorkflowid();
|
||||
Map<String, String> requesData = getRequestByid(requestid);
|
||||
log.info("requesData:{}", requesData);
|
||||
String fj = Util.null2String(requesData.get("fj"));
|
||||
String zwkbj = Util.null2String(requesData.get("zwkbj"));
|
||||
String lczw = Util.null2String(requesData.get("lczw"));
|
||||
String gwly = Util.null2String(requesData.get("gwly"));
|
||||
//增加签字意见中的附件到附件文件夹中
|
||||
Map<String, String> signFiles = ArchivesUtil.getSignFiles(requestid,false);
|
||||
List<String> docids = new ArrayList<>();
|
||||
// docids.addAll(Arrays.asList(fj.split(",")));
|
||||
// docids.addAll(Arrays.asList(zwkbj.split(",")));
|
||||
Map<String, String> fjMap = ArchivesUtil.getFileIdByDocId(fj);
|
||||
|
||||
// Map<String, String> zwkbjMap = ArchivesUtil.getFileIdByDocId(zwkbj);
|
||||
// Map<String, String> lczwMap = ArchivesUtil.getFileIdByDocId(lczw);
|
||||
Map<String, String> lczwMap = new HashMap<>();
|
||||
//判断公文来源
|
||||
if ("0".equals(gwly)){
|
||||
lczwMap = ArchivesUtil.getFileIdByDocId(lczw);
|
||||
}else {
|
||||
lczwMap = ArchivesUtil.getFileIdByDocId(zwkbj);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
List<String> zwFileName = new ArrayList<>();
|
||||
List<String> fjFileName = new ArrayList<>();
|
||||
final int[] i = {1};
|
||||
//附件
|
||||
fjMap.forEach((docid, imageid) -> {
|
||||
ImageFileManager imageFileManager = new ImageFileManager();
|
||||
imageFileManager.getImageFileInfoById(Util.getIntValue(imageid));
|
||||
InputStream inputStream = imageFileManager.getInputStream();
|
||||
//中文路径/中文文件名
|
||||
String imageFileName = filePath + File.separator + newRequestid + File.separator + FJDIR + File.separator + LCFJWORD + i[0] +"-" + imageFileManager.getImageFileName();
|
||||
fjFileName.add(LCFJWORD+ i[0] +"-" + imageFileManager.getImageFileName());
|
||||
log.info("生成附件路径:{}", imageFileName);
|
||||
imageFileName = ArchivesUtil.codeUtf8(imageFileName);
|
||||
try {
|
||||
File file = ArchivesUtil.saveInputStreamToFile(inputStream, imageFileName);
|
||||
String jsonStr = ArchivesUtil.callApi(Url, file);
|
||||
log.error("永中接口返回数据:{}", jsonStr);
|
||||
JSONObject result = JSONObject.parseObject(jsonStr);
|
||||
String errorcode = result.getString("errorcode");
|
||||
if ("0".equals(errorcode)) {
|
||||
JSONObject data = result.getJSONObject("data");
|
||||
String destFileName = data.getString("destFileName");
|
||||
String viewUrl = data.getString("viewUrl");
|
||||
ArchivesUtil.downloadFile(viewUrl, filePath + File.separator + newRequestid + File.separator + FJDIR + File.separator + LCFJWORD+ i[0] + "-" + imageFileManager.getImageFileName() + ".pdf");
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}finally {
|
||||
if(inputStream!=null) {
|
||||
try {
|
||||
inputStream.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
i[0]++;
|
||||
});
|
||||
i[0] = 1;
|
||||
//签字意见附件
|
||||
signFiles.forEach((docid, imageid) -> {
|
||||
ImageFileManager imageFileManager = new ImageFileManager();
|
||||
imageFileManager.getImageFileInfoById(Util.getIntValue(imageid));
|
||||
InputStream inputStream = imageFileManager.getInputStream();
|
||||
//中文路径/中文文件名
|
||||
String imageFileName = filePath + File.separator + newRequestid + File.separator + FJDIR + File.separator + QZYJFJWORD + i[0] + "-" +imageFileManager.getImageFileName();
|
||||
fjFileName.add(QZYJFJWORD + i[0] + "-" +imageFileManager.getImageFileName());
|
||||
log.info("生成签字意见附件路径:{}", imageFileName);
|
||||
imageFileName = ArchivesUtil.codeUtf8(imageFileName);
|
||||
try {
|
||||
File file = ArchivesUtil.saveInputStreamToFile(inputStream, imageFileName);
|
||||
String jsonStr = ArchivesUtil.callApi(Url, file);
|
||||
log.error("永中接口返回数据:{}", jsonStr);
|
||||
JSONObject result = JSONObject.parseObject(jsonStr);
|
||||
String errorcode = result.getString("errorcode");
|
||||
if ("0".equals(errorcode)) {
|
||||
JSONObject data = result.getJSONObject("data");
|
||||
String destFileName = data.getString("destFileName");
|
||||
String viewUrl = data.getString("viewUrl");
|
||||
ArchivesUtil.downloadFile(viewUrl, filePath + File.separator + newRequestid + File.separator + FJDIR + File.separator + QZYJFJWORD + i[0] + "-" + imageFileManager.getImageFileName() + ".pdf");
|
||||
}
|
||||
i[0]++;
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}finally {
|
||||
if(inputStream!=null) {
|
||||
try {
|
||||
inputStream.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
i[0] = 1;
|
||||
Map<String, String> coReqFile = getCoReqFile(requestid, workflowid);
|
||||
//协办要求
|
||||
coReqFile.forEach((docid, imageid) -> {
|
||||
ImageFileManager imageFileManager = new ImageFileManager();
|
||||
imageFileManager.getImageFileInfoById(Util.getIntValue(imageid));
|
||||
InputStream inputStream = imageFileManager.getInputStream();
|
||||
zwFileName.add(XBBMFJWORD+ i[0] +"-"+ imageFileManager.getImageFileName());
|
||||
//中文路径/中文文件名
|
||||
String imageFileName = filePath + File.separator + newRequestid + File.separator + FJDIR + File.separator + XBBMFJWORD + i[0] +"-"+ imageFileManager.getImageFileName();
|
||||
log.info("生成协办部门路径:{}", imageFileName);
|
||||
imageFileName = ArchivesUtil.codeUtf8(imageFileName);
|
||||
try {
|
||||
File file = ArchivesUtil.saveInputStreamToFile(inputStream, imageFileName);
|
||||
String jsonStr = ArchivesUtil.callApi(Url, file);
|
||||
log.error("永中接口返回:{}", jsonStr);
|
||||
JSONObject result = JSONObject.parseObject(jsonStr);
|
||||
String errorcode = result.getString("errorcode");
|
||||
if ("0".equals(errorcode)) {
|
||||
JSONObject data = result.getJSONObject("data");
|
||||
String destFileName = data.getString("destFileName");
|
||||
String viewUrl = data.getString("viewUrl");
|
||||
ArchivesUtil.downloadFile(viewUrl, filePath + File.separator + newRequestid + File.separator + FJDIR + File.separator+XBBMFJWORD+ i[0] +"-" + imageFileManager.getImageFileName() + ".pdf");
|
||||
}
|
||||
i[0]++;
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}finally {
|
||||
if(inputStream!=null) {
|
||||
try {
|
||||
inputStream.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// i[0] = 1;
|
||||
// //正文
|
||||
// zwkbjMap.forEach((docid, imageid) -> {
|
||||
// ImageFileManager imageFileManager = new ImageFileManager();
|
||||
// imageFileManager.getImageFileInfoById(Util.getIntValue(imageid));
|
||||
// InputStream inputStream = imageFileManager.getInputStream();
|
||||
// zwFileName.add(imageFileManager.getImageFileName());
|
||||
// //中文路径/中文文件名
|
||||
// String imageFileName = filePath + File.separator + newRequestid + File.separator + zwdir + File.separator + imageFileManager.getImageFileName();
|
||||
// log.info("生成正文路径:{}", imageFileName);
|
||||
// imageFileName = ArchivesUtil.codeUtf8(imageFileName);
|
||||
// try {
|
||||
// File file = ArchivesUtil.saveInputStreamToFile(inputStream, imageFileName);
|
||||
// String jsonStr = ArchivesUtil.callApi(Url, file);
|
||||
// log.error("永中接口返回:{}", jsonStr);
|
||||
// JSONObject result = JSONObject.parseObject(jsonStr);
|
||||
// String errorcode = result.getString("errorcode");
|
||||
// if ("0".equals(errorcode)) {
|
||||
// JSONObject data = result.getJSONObject("data");
|
||||
// String destFileName = data.getString("destFileName");
|
||||
// String viewUrl = data.getString("viewUrl");
|
||||
// ArchivesUtil.downloadFile(viewUrl, filePath + File.separator + newRequestid + File.separator + zwdir + File.separator + imageFileManager.getImageFileName() + ".pdf");
|
||||
// }
|
||||
//
|
||||
// } catch (IOException e) {
|
||||
// e.printStackTrace();
|
||||
// }finally {
|
||||
// if(inputStream!=null) {
|
||||
// try {
|
||||
// inputStream.close();
|
||||
// } catch (IOException e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
|
||||
i[0] = 1;
|
||||
//正文
|
||||
lczwMap.forEach((docid, imageid) -> {
|
||||
ImageFileManager imageFileManager = new ImageFileManager();
|
||||
imageFileManager.getImageFileInfoById(Util.getIntValue(imageid));
|
||||
InputStream inputStream = imageFileManager.getInputStream();
|
||||
zwFileName.add(imageFileManager.getImageFileName());
|
||||
//中文路径/中文文件名
|
||||
String imageFileName = filePath + File.separator + newRequestid + File.separator + ZWDIR + File.separator + (imageFileManager.getImageFileName().replaceAll("/","-"));
|
||||
log.info("生成正文路径:{}", imageFileName);
|
||||
imageFileName = ArchivesUtil.codeUtf8(imageFileName);
|
||||
try {
|
||||
File file = ArchivesUtil.saveInputStreamToFile(inputStream, imageFileName);
|
||||
String jsonStr = ArchivesUtil.callApi(Url, file);
|
||||
log.error("永中接口返回:{}", jsonStr);
|
||||
JSONObject result = JSONObject.parseObject(jsonStr);
|
||||
String errorcode = result.getString("errorcode");
|
||||
if ("0".equals(errorcode)) {
|
||||
JSONObject data = result.getJSONObject("data");
|
||||
String destFileName = data.getString("destFileName");
|
||||
String viewUrl = data.getString("viewUrl");
|
||||
ArchivesUtil.downloadFile(viewUrl, filePath + File.separator + newRequestid + File.separator + ZWDIR + File.separator + (imageFileManager.getImageFileName().replaceAll("/","-")) + ".pdf");
|
||||
}
|
||||
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}finally {
|
||||
if(inputStream!=null) {
|
||||
try {
|
||||
inputStream.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
//开始承办单 先获取主流程的承办单
|
||||
List<String> requestDocid = ArchivesUtil.generaRequestFormPdf(requestid,0);
|
||||
// 1.去掉生成子流程承办单
|
||||
// List<String> subRequestDocid = generaSubRequestFormPdf(requestid);
|
||||
Map<String, String> reqDocMap = ArchivesUtil.getFileIdByDocId(String.join(",", requestDocid));
|
||||
// 2.去掉生成子流程承办单
|
||||
// Map<String, String> subReqDocMap = getFileIdByDocId(String.join(",", subRequestDocid));
|
||||
log.error("reqDocMap:{}", JSONObject.toJSONString(reqDocMap));
|
||||
//log.error("subReqDocMap:{}", JSONObject.toJSONString(subReqDocMap));
|
||||
docids.addAll(requestDocid);
|
||||
// 3.去掉生成子流程承办单
|
||||
// docids.addAll(subRequestDocid);
|
||||
//承办单
|
||||
reqDocMap.forEach((docid, imageid) -> {
|
||||
ImageFileManager imageFileManager = new ImageFileManager();
|
||||
imageFileManager.getImageFileInfoById(Util.getIntValue(imageid));
|
||||
InputStream inputStream = imageFileManager.getInputStream();
|
||||
//中文路径/中文文件名
|
||||
// String imageFileName = filePath + File.separator + requestid + File.separator + cbddir + File.separator + fjFile + i[0] + "_" + imageFileManager.getImageFileName();
|
||||
String imageFileName = filePath + File.separator + newRequestid + File.separator + CBDDIR + File.separator + WJCLDWORD+".pdf";
|
||||
|
||||
log.info("主流程承办单路径:{}", imageFileName);
|
||||
imageFileName = ArchivesUtil.codeUtf8(imageFileName);
|
||||
try {
|
||||
File file = ArchivesUtil.saveInputStreamToFile(inputStream, imageFileName);
|
||||
String jsonStr = ArchivesUtil.callApi(Url, file);
|
||||
log.error("永中接口返回:{}", jsonStr);
|
||||
JSONObject result = JSONObject.parseObject(jsonStr);
|
||||
String errorcode = result.getString("errorcode");
|
||||
if ("0".equals(errorcode)) {
|
||||
JSONObject data = result.getJSONObject("data");
|
||||
String destFileName = data.getString("destFileName");
|
||||
String viewUrl = data.getString("viewUrl");
|
||||
ArchivesUtil.downloadFile(viewUrl, filePath + File.separator + newRequestid + File.separator + CBDDIR + File.separator + WJCLDWORD + ".pdf" + ".pdf");
|
||||
}
|
||||
i[0]++;
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}finally {
|
||||
if(inputStream!=null) {
|
||||
try {
|
||||
inputStream.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
//正文
|
||||
|
||||
i[0] = 1;
|
||||
// 4.去掉生成子流程承办单
|
||||
// subReqDocMap.forEach((docid, imageid) -> {
|
||||
// ImageFileManager imageFileManager = new ImageFileManager();
|
||||
// imageFileManager.getImageFileInfoById(Util.getIntValue(imageid));
|
||||
// InputStream inputStream = imageFileManager.getInputStream();
|
||||
// //中文路径/中文文件名
|
||||
// String imageFileName = filePath + File.separator + requestid + File.separator + zlcdir + File.separator + fjFile + i[0] + "_" + (imageFileManager.getImageFileName().contains("-")?imageFileManager.getImageFileName().split("\\-")[1]:imageFileManager.getImageFileName());
|
||||
// imageFileName = codeUtf8(imageFileName);
|
||||
// log.info("子流程承办单路径:{}", imageFileName);
|
||||
// try {
|
||||
// File file = saveInputStreamToFile(inputStream, imageFileName);
|
||||
// String jsonStr = callApi(Url, file);
|
||||
// log.error("永中接口返回:{}", jsonStr);
|
||||
// JSONObject result = JSONObject.parseObject(jsonStr);
|
||||
// String errorcode = result.getString("errorcode");
|
||||
// if ("0".equals(errorcode)) {
|
||||
// JSONObject data = result.getJSONObject("data");
|
||||
// String destFileName = data.getString("destFileName");
|
||||
// String viewUrl = data.getString("viewUrl");
|
||||
// downloadFile(viewUrl, filePath + File.separator + requestid + File.separator + zlcdir + File.separator + fjFile + i[0] + "_" + (imageFileManager.getImageFileName().contains("-")?imageFileManager.getImageFileName().split("\\-")[1]:imageFileManager.getImageFileName() )+ ".pdf");
|
||||
// }
|
||||
// i[0]++;
|
||||
// } catch (IOException e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// });
|
||||
log.error(JSONObject.toJSONString(requestDocid));
|
||||
// log.error(JSONObject.toJSONString(subRequestDocid));
|
||||
for (String docid : docids) {
|
||||
log.error("删除了" + docid);
|
||||
ArchivesUtil.deleteDocByid(docid);
|
||||
}
|
||||
//--------------------------------------------------------------------
|
||||
|
||||
|
||||
String logFile = ArchivesUtil.getSignLog(requestid, CBDDIR+File.separator+LZXXDIR, requestInfo.getCreatorid() + requestInfo.getDescription(),templatePath,filePath,false,workflowid);
|
||||
String s = ArchivesUtil.callApi(Url, new File(logFile));
|
||||
log.error(s);
|
||||
JSONObject result = JSONObject.parseObject(s);
|
||||
String errorcode = result.getString("errorcode");
|
||||
if ("0".equals(errorcode)) {
|
||||
JSONObject data = result.getJSONObject("data");
|
||||
String destFileName = data.getString("destFileName");
|
||||
String viewUrl = data.getString("viewUrl");
|
||||
ArchivesUtil.downloadFile(viewUrl, logFile + ".pdf");
|
||||
}
|
||||
String zipName = filePath + File.separator + newRequestid + ".zip";
|
||||
ZipUtil.zip(filePath + File.separator + newRequestid, zipName);
|
||||
log.error("zipName:{}", zipName);
|
||||
String ftpFilePath = HgUtils.putFile(zipName, newRequestid + ".zip");
|
||||
ArchivesUtil.deleteDirectory(filePath + File.separator + newRequestid);
|
||||
updateRecord(requestid,"esbwjml",ftpFilePath);
|
||||
log.error("ftpFilePath:{}", ftpFilePath);
|
||||
// String ftpFilePathNew = HgUtils.putFile(zipName, "test" + File.separator + newRequestid + ".zip");
|
||||
// log.error("ftpFilePathNew:{}", ftpFilePathNew);
|
||||
String context = getContext(requestid, requesData, newRequestid + ".zip", zwFileName, fjFileName);
|
||||
// insertRecord(requestid, context, ftpFilePath);
|
||||
log.error("context:{}", context);
|
||||
updateRecord(requestid,"content",context);
|
||||
return context;
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void insertRecord(int requestid, String context, String ftpFilePath) {
|
||||
String sql = "insert into uf_pushArchivesLog (request ,content,esbwjml) VALUES (?,?,?)";
|
||||
RecordSet recordSet = new RecordSet();
|
||||
recordSet.executeUpdate(sql, requestid, context, ftpFilePath);
|
||||
}
|
||||
|
||||
|
||||
// 获取指定日期的第一秒
|
||||
public static Date getFirstSecondOfDate(Date date) {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(date);
|
||||
calendar.set(Calendar.HOUR_OF_DAY, 0);
|
||||
calendar.set(Calendar.MINUTE, 0);
|
||||
calendar.set(Calendar.SECOND, 0);
|
||||
calendar.set(Calendar.MILLISECOND, 0);
|
||||
return calendar.getTime();
|
||||
}
|
||||
|
||||
// 获取指定日期的最后一秒
|
||||
public static Date getLastSecondOfDate(Date date) {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(date);
|
||||
calendar.set(Calendar.HOUR_OF_DAY, 23);
|
||||
calendar.set(Calendar.MINUTE, 59);
|
||||
calendar.set(Calendar.SECOND, 59);
|
||||
calendar.set(Calendar.MILLISECOND, 999);
|
||||
return calendar.getTime();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/***
|
||||
* 封装数据
|
||||
* @param requestid
|
||||
* @return
|
||||
*/
|
||||
public Map<String, String> getRequestByid(int requestid) {
|
||||
HashMap<String, String> record = new HashMap<>();
|
||||
String sql = "select * from formtable_main_55 where requestid = ?";
|
||||
String reqsql = "select REQUESTNAME from WORKFLOW_REQUESTBASE where REQUESTID = ?";
|
||||
RecordSet rs = new RecordSet();
|
||||
rs.executeQuery(sql, requestid);
|
||||
if (rs.next()) {
|
||||
String fj = Util.null2String(rs.getString("fj"));
|
||||
String zwkbj = Util.null2String(rs.getString("zwkbj")); // 正文可编辑字段
|
||||
record.put("fj", fj);
|
||||
record.put("zwkbj", zwkbj);
|
||||
record.put("zwyyglgwmk", Util.null2String(rs.getString("zwyyglgwmk")));
|
||||
record.put("lwh", Util.null2String(rs.getString("lwh")));
|
||||
record.put("mj", Util.null2String(rs.getString("mj")));
|
||||
record.put("lwrq", Util.null2String(rs.getString("lwrq")));
|
||||
record.put("swrq", Util.null2String(rs.getString("swrq")));
|
||||
record.put("blqx", Util.null2String(rs.getString("blqx")));
|
||||
record.put("sfdb", Util.null2String(rs.getString("sfdb")));
|
||||
record.put("wjlx", Util.null2String(rs.getString("wjlx")));
|
||||
record.put("fssj", Util.null2String(rs.getString("fssj")));
|
||||
record.put("gdh", Util.null2String(rs.getString("gdh")));
|
||||
record.put("swh", Util.null2String(rs.getString("swh")));
|
||||
record.put("ngbm", Util.null2String(rs.getString("ngbm")));
|
||||
record.put("ngr", Util.null2String(rs.getString("ngr")));
|
||||
record.put("ngrq", Util.null2String(rs.getString("ngrq")));
|
||||
record.put("swlx", Util.null2String(rs.getString("swlx")));
|
||||
record.put("jghwt", Util.null2String(rs.getString("jghwt")));
|
||||
record.put("lwdwmc", Util.null2String(rs.getString("lwdwmc")));
|
||||
record.put("bgqx", Util.null2String(rs.getString("bgqx")));
|
||||
record.put("ys", Util.null2String(rs.getString("ys")));
|
||||
record.put("wz", Util.null2String(rs.getString("wz")));
|
||||
record.put("lb", Util.null2String(rs.getString("lb")));
|
||||
record.put("bz", Util.null2String(rs.getString("bz")));
|
||||
record.put("yffbm", Util.null2String(rs.getString("yffbm")));
|
||||
record.put("ffbmb", Util.null2String(rs.getString("ffbmb")));
|
||||
record.put("yffbm", Util.null2String(rs.getString("yffbm")));
|
||||
record.put("lczw", Util.null2String(rs.getString("lczw")));
|
||||
record.put("gwly", Util.null2String(rs.getString("gwly")));
|
||||
record.put("lwdwsx", Util.null2String(rs.getString("lwdwsx")));
|
||||
record.put("fb", Util.null2String(rs.getString("fb")));
|
||||
record.put("xjdw", Util.null2String(rs.getString("xjdw")));
|
||||
record.put("ejzx", Util.null2String(rs.getString("ejzx")));
|
||||
record.put("yjbm", Util.null2String(rs.getString("yjbm")));
|
||||
record.put("yjfxxldbm", Util.null2String(rs.getString("yjfxxldbm")));
|
||||
}
|
||||
rs.executeQuery(reqsql, requestid);
|
||||
if (rs.next()) {
|
||||
record.put("REQUESTNAME", Util.null2String(rs.getString("REQUESTNAME")));
|
||||
}
|
||||
return record;
|
||||
}
|
||||
|
||||
|
||||
private String getContext(int requestid, Map<String, String> requesData, String zipName, List<String> zwFileName, List<String> fjFileName) {
|
||||
StringBuilder context = new StringBuilder();
|
||||
try {
|
||||
|
||||
String swrq = Util.null2String(requesData.get("swrq"));
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||
LocalDate date = LocalDate.parse(swrq, formatter);
|
||||
int year = date.getYear();
|
||||
context.append(year).append("|");
|
||||
String jghwt = Util.null2String(requesData.get("jghwt"));
|
||||
context.append(jghwt).append("|");
|
||||
// String swh = Util.null2String(requesData.get("swh"));
|
||||
String swh = Util.null2String(requesData.get("lwh"));
|
||||
context.append(swh).append("|");
|
||||
String requestname = Util.null2String(requesData.get("REQUESTNAME"));
|
||||
context.append(requestname).append("|");
|
||||
String lwdwmc = Util.null2String(requesData.get("lwdwsx")); //5 责任者 -> 来文单位
|
||||
context.append(lwdwmc).append("|");
|
||||
String bgqx = Util.null2String(requesData.get("bgqx")); //6 保管期限 -> 保管期限
|
||||
context.append(bgqx).append("|");
|
||||
String lwrq = Util.null2String(requesData.get("lwrq")); //7 日期 -> 原发文日期
|
||||
context.append(lwrq).append("|");
|
||||
String ys = Util.null2String(requesData.get("ys")); //8 页数 -> 页数
|
||||
context.append(ys).append("|");
|
||||
String wz = Util.null2String(requesData.get("wz")); //9 文种 -> 文种
|
||||
context.append(wz).append("|");
|
||||
String ngbm = Util.null2String(requesData.get("ngbm"));
|
||||
String fb = Util.null2String(requesData.get("fb"));
|
||||
String[] deptData = ArchivesUtil.getDeptNameAndCode(ngbm);
|
||||
String[] subData = getSubCom(fb);
|
||||
context.append(subData[0]).append("|"); //10 行编号 -> 拟稿部门
|
||||
|
||||
context.append(subData[1]).append("|"); //11 行名称
|
||||
context.append("").append("|"); // 12 保管期限编号
|
||||
context.append("").append("|"); // 13 保管期限及编号
|
||||
context.append("").append("|"); // 14 是否开放
|
||||
context.append("").append("|"); // 15 互见号
|
||||
String lb = Util.null2String(requesData.get("lb"));
|
||||
context.append(lb).append("|"); //16 类别 -> 类别
|
||||
//TODO
|
||||
String xgbm = Util.null2String(getAssociatedDepts(requesData));
|
||||
context.append(xgbm).append("|"); //17 相关部门 -> 流经部门
|
||||
// String lwh = Util.null2String(requesData.get("lwh"));// 18 收文号 -> 来文文号
|
||||
String lwh = Util.null2String(requesData.get("swh"));// 18 收文号 -> 来文文号
|
||||
context.append(lwh).append("|");
|
||||
String fs = "";
|
||||
context.append(fs).append("|"); // 19 份数 -> 份数
|
||||
String bz = Util.null2String(requesData.get("bz"));
|
||||
context.append(bz).append("|"); // 20 备注 -> 备注
|
||||
String yywh = Util.null2String(requesData.get("yywh"));
|
||||
context.append(yywh).append("|"); // 21 引用文号 -> 引用文号
|
||||
String wjlx = Util.null2String(requesData.get("wjlx"));
|
||||
context.append(wjlx).append("|"); // 22 文件类型 -> 空
|
||||
String fwlx = Util.null2String(requesData.get("fwlx"));
|
||||
context.append(fwlx).append("|"); // 23 文件类型 -> 空
|
||||
String f = Util.null2String(requesData.get("f"));
|
||||
context.append(f).append("|"); // 24 发 -> 空
|
||||
String ngr = Util.null2String(requesData.get("ngr"));
|
||||
context.append(new User(Util.getIntValue(ngr)).getLoginid()).append("|"); // 25 拟稿人 -> 拟稿人
|
||||
context.append(deptData[1]).append("|"); // 26 拟稿部门 -> 拟稿部门名称
|
||||
context.append("收文").append("|"); // 27 公文类型 -> "收文"
|
||||
//TODO
|
||||
context.append(ArchivesUtil.getAssociatedPersons(requestid,false)).append("|"); // 28 相关人员 -> 参与人员
|
||||
context.append("智慧OA").append("|"); // 29 数据来源 -> 数据来源
|
||||
context.append(year).append("|"); // 30 形成年度 -> 年份
|
||||
context.append(String.join("&&", zwFileName)).append("|"); // 31 正文名称
|
||||
context.append(String.join("&&", fjFileName)).append("|"); // 32 附件名称
|
||||
context.append("togd"+requestid).append("|"); // 33 主键
|
||||
context.append("").append("|"); // 34 关联主键
|
||||
context.append("").append("|"); // 35 被关联主键
|
||||
context.append(zipName);// 36 压缩包名称
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
log.error("getContextError:{}", e.getMessage());
|
||||
}
|
||||
|
||||
return context.toString();
|
||||
}
|
||||
|
||||
private String getAssociatedDepts(Map<String, String> requesData) {
|
||||
HashSet<String> records = new HashSet<>();
|
||||
records.addAll(Arrays.asList(Util.null2String(requesData.get("ngbm")).split(",")));
|
||||
records.addAll(Arrays.asList(Util.null2String(requesData.get("ffbm")).split(",")));
|
||||
records.addAll(Arrays.asList(Util.null2String(requesData.get("yffbm")).split(",")));
|
||||
records.addAll(Arrays.asList(Util.null2String(requesData.get("ffbmb")).split(",")));
|
||||
records.addAll(Arrays.asList(Util.null2String(requesData.get("xjdw")).split(",")));
|
||||
records.addAll(Arrays.asList(Util.null2String(requesData.get("ejzx")).split(",")));
|
||||
records.addAll(Arrays.asList(Util.null2String(requesData.get("yjbm")).split(",")));
|
||||
records.addAll(Arrays.asList(Util.null2String(requesData.get("yjfxxldbm")).split(",")));
|
||||
ArrayList<String> deptName = new ArrayList<>();
|
||||
DepartmentComInfo departmentComInfo = new DepartmentComInfo();
|
||||
for (String record : records) {
|
||||
try {
|
||||
if (StringUtil.isEmpty(record)){
|
||||
continue;
|
||||
}
|
||||
String departmentName = departmentComInfo.getDepartmentName(record);
|
||||
deptName.add(departmentName);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
return String.join("&&", deptName);
|
||||
}
|
||||
|
||||
private Map<String, String> getCoReqFile(int requestid , String workflowid){
|
||||
try {
|
||||
RecordSet rs = new RecordSet();
|
||||
rs.executeQuery("select * from uf_ArchivesSet where mainwfid = ?",workflowid);
|
||||
boolean isCo = false;
|
||||
String cowfid = "";
|
||||
String cofield = "";
|
||||
String cofieldid = "";
|
||||
if (rs.next()){
|
||||
cowfid = Util.null2String(rs.getString("cowfid"));
|
||||
if (!StringUtils.isBlank(cowfid)){
|
||||
isCo = true;
|
||||
cofield = Util.null2String(rs.getString("cofield"));
|
||||
cofieldid = Util.null2String(rs.getString("cofieldid"));
|
||||
}
|
||||
}
|
||||
log.info("isCo:{};cowfid:{};cofield:{};cofieldid:{}",isCo,cowfid,cofield,cofieldid);
|
||||
|
||||
|
||||
if(isCo){
|
||||
ArrayList<String> CoSubRequest = new ArrayList<>();
|
||||
Map<String, String> subRequest = ArchivesUtil.getSubRequest(Util.null2String(requestid) , 6);
|
||||
log.info("subRequest:{}",subRequest);
|
||||
for (Map.Entry<String, String> subRequestEntry : subRequest.entrySet()) {
|
||||
String subWFid = subRequestEntry.getValue();
|
||||
if (cowfid.equals(subWFid)){
|
||||
CoSubRequest.add(subRequestEntry.getKey());
|
||||
}
|
||||
}
|
||||
log.info("CoSubRequest.size:{}",CoSubRequest.size());
|
||||
if (CoSubRequest.size() == 0){
|
||||
return new HashMap<>();
|
||||
}
|
||||
WorkflowComInfo wf = new WorkflowComInfo();
|
||||
WorkflowBillComInfo wcInfo = new WorkflowBillComInfo();
|
||||
String formId = wf.getFormId(cowfid);
|
||||
String tablename = wcInfo.getTablename(formId);
|
||||
String cosql = "select "+cofield+" from " + tablename + " where " +
|
||||
" requestid in ( " + String.join(",",CoSubRequest) + " ) " +
|
||||
" order by requestid asc ";
|
||||
log.info("cosql:{}",cosql);
|
||||
|
||||
rs.executeQuery(cosql);
|
||||
log.info("rs.getExceptionMsg():{}",rs.getExceptionMsg());
|
||||
String fieldValue = "";
|
||||
String[] cofieldsplit = cofield.split(",");
|
||||
String coFile = cofieldsplit[2]; //协办部门
|
||||
ArrayList<String> docids = new ArrayList<>();
|
||||
while (rs.next()){
|
||||
String coFileValue = rs.getString(coFile);
|
||||
docids.addAll(Arrays.asList(coFileValue.split(",")));
|
||||
}
|
||||
log.info("fieldValue:{}",fieldValue);
|
||||
return ArchivesUtil.getFileIdByDocId(String.join(",",docids));
|
||||
}
|
||||
return new HashMap<>();
|
||||
}catch (Exception e){
|
||||
log.error("getCoReqFile:[}",e.getMessage());
|
||||
return new HashMap<>();
|
||||
}
|
||||
}
|
||||
|
||||
private void updateRecord(int requestid, String field , String fieldvalue) {
|
||||
String sql = "update uf_pushArchivesLog set "+field+" = ? where request = ?";
|
||||
RecordSet recordSet = new RecordSet();
|
||||
recordSet.executeUpdate(sql, fieldvalue, requestid);
|
||||
}
|
||||
|
||||
|
||||
public static String[] getSubCom(String ngbm) {
|
||||
RecordSet rs = new RecordSet();
|
||||
rs.executeQuery("select sub.id subid , SUBCOMPANYNAME from HRMSUBCOMPANY sub where sub.id = ? ",ngbm);
|
||||
rs.next();
|
||||
String subcompanyname = rs.getString("SUBCOMPANYNAME");
|
||||
String subid = rs.getString("subid");
|
||||
if ("总行".equals(subcompanyname)){
|
||||
subcompanyname = "总行机关";
|
||||
}
|
||||
rs.executeQuery("select DAPYBH from HRMSUBCOMPANYDEFINED where SUBCOMID = ?",subid);
|
||||
rs.next();
|
||||
String DAPYBH = rs.getString("DAPYBH");
|
||||
return new String[]{DAPYBH,subcompanyname};
|
||||
}
|
||||
}
|
@ -0,0 +1,571 @@
|
||||
package com.engine.custom.archives.service.firstBranch;
|
||||
|
||||
import cn.hutool.core.util.ZipUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
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.archives.util.KeyWord;
|
||||
import com.engine.custom.hg.util.HgUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.file.ImageFileManager;
|
||||
import weaver.general.StringUtil;
|
||||
import weaver.general.Util;
|
||||
import weaver.hrm.User;
|
||||
import weaver.hrm.company.DepartmentComInfo;
|
||||
import weaver.soa.workflow.request.RequestInfo;
|
||||
import weaver.soa.workflow.request.RequestService;
|
||||
|
||||
import java.io.*;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
|
||||
/***
|
||||
* @Des: 一级分行发文推送档案系统服务
|
||||
*/
|
||||
public class FirstBranchSendingPushArchivesService implements KeyWord {
|
||||
public static Logger log = LoggerFactory.getLogger("Archives");
|
||||
private static String filePath;
|
||||
private static String Url;
|
||||
private static String templatePath; // 模板文件路径
|
||||
private int endTime= 7;
|
||||
|
||||
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"));
|
||||
endTime = Util.getIntValue(param.get("endTime"),7);
|
||||
}
|
||||
|
||||
public void pushArchives(Map<String, String> param) {
|
||||
log.info("PushArchivesCorn====Begin========{}", 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, 3);
|
||||
log.error("推送分行发文的数量:{}", result.size());
|
||||
File file = ArchivesUtil.crFile(filePath + "/togd_" + new SimpleDateFormat("yyyyMMdd000000").format(date));
|
||||
log.error("textfile:{}", file.getAbsolutePath());
|
||||
for (PushArchivesBean pushArchivesBean : result) {
|
||||
if (ArchivesUtil.isAfterSevenAM(endTime)){
|
||||
log.info("超过执行时间:{}点暂停计划任务",endTime);
|
||||
break;
|
||||
}
|
||||
// int id = pushArchivesBean.getId();
|
||||
int request = pushArchivesBean.getRequest();
|
||||
log.error("推送的requestId:{}", request);
|
||||
try {
|
||||
String context = generateFile(request);
|
||||
if ("-1".equals(context)){
|
||||
continue;
|
||||
}
|
||||
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,"esbtxtml",s);
|
||||
updateRecord(request,"zt","0");
|
||||
log.error("textZip:{}", s);
|
||||
} catch (FtpException e) {
|
||||
e.printStackTrace();
|
||||
log.error("推送档案requestid:{}异常,异常原因为:{}",request,e.getMessage());
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
log.error("推送档案requestid:{}异常,异常原因为:{}",request,e.getMessage());
|
||||
} catch (Exception e){
|
||||
e.printStackTrace();
|
||||
log.error("推送档案requestid:{}异常,异常原因为:{}",request,e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
private String generateFile(int requestid) throws FtpException, IOException {
|
||||
Map<String, String> requesData = getRequestByid(requestid);
|
||||
String newRequestid = "togd"+requestid;
|
||||
log.info("requesData:{}", requesData);
|
||||
String bh = requesData.get("bh");
|
||||
if (StringUtil.isEmpty(bh)){
|
||||
return "-1";
|
||||
}
|
||||
String fj = Util.null2String(requesData.get("fj"));
|
||||
String dwd = Util.null2String(requesData.get("dwd"));
|
||||
String zw = Util.null2String(requesData.get("zw"));
|
||||
String qgqhj = Util.null2String(requesData.get("qgqhj"));
|
||||
String thhlh = Util.null2String(requesData.get("thhlh"));
|
||||
|
||||
|
||||
//增加签字意见中的附件到附件文件夹中
|
||||
Map<String, String> signFiles = ArchivesUtil.getSignFiles(requestid,false);
|
||||
List<String> docids = new ArrayList<>();
|
||||
// docids.addAll(Arrays.asList(fj.split(",")));
|
||||
// docids.addAll(Arrays.asList(zwkbj.split(",")));
|
||||
Map<String, String> fjMap = ArchivesUtil.getFileIdByDocId(fj);
|
||||
Map<String, String> dwdMap = ArchivesUtil.getFileIdByDocId(dwd);
|
||||
Map<String, String> zwMap = ArchivesUtil.getFileIdByDocId(zw);
|
||||
Map<String, String> qgqhjMap = ArchivesUtil.getFileIdByDocId(qgqhj);
|
||||
Map<String, String> thhlhMap = ArchivesUtil.getFileIdByDocId(thhlh);
|
||||
List<String> zwFileName = new ArrayList<>();
|
||||
List<String> fjFileName = new ArrayList<>();
|
||||
final int[] i = {1};
|
||||
//附件
|
||||
fjMap.forEach((docid, imageid) -> {
|
||||
ImageFileManager imageFileManager = new ImageFileManager();
|
||||
imageFileManager.getImageFileInfoById(Util.getIntValue(imageid));
|
||||
InputStream inputStream = imageFileManager.getInputStream();
|
||||
//中文路径/中文文件名
|
||||
String imageFileName = filePath + File.separator + newRequestid + File.separator + FJDIR + File.separator + LCFJWORD + "-" +imageFileManager.getImageFileName();
|
||||
fjFileName.add(LCFJWORD + "-" +imageFileManager.getImageFileName());
|
||||
log.info("生成附件路径:{}", imageFileName);
|
||||
imageFileName = ArchivesUtil.codeUtf8(imageFileName);
|
||||
try {
|
||||
File file = ArchivesUtil.saveInputStreamToFile(inputStream, imageFileName);
|
||||
String jsonStr = ArchivesUtil.callApi(Url, file);
|
||||
log.error("永中接口返回数据:{}", jsonStr);
|
||||
JSONObject result = JSONObject.parseObject(jsonStr);
|
||||
String errorcode = result.getString("errorcode");
|
||||
if ("0".equals(errorcode)) {
|
||||
JSONObject data = result.getJSONObject("data");
|
||||
String destFileName = data.getString("destFileName");
|
||||
String viewUrl = data.getString("viewUrl");
|
||||
ArchivesUtil.downloadFile(viewUrl, filePath + File.separator + newRequestid + File.separator + FJDIR + File.separator + LCFJWORD + "-" + imageFileManager.getImageFileName() + ".pdf");
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}finally {
|
||||
if(inputStream!=null) {
|
||||
try {
|
||||
inputStream.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
//签字意见附件
|
||||
signFiles.forEach((docid, imageid) -> {
|
||||
ImageFileManager imageFileManager = new ImageFileManager();
|
||||
imageFileManager.getImageFileInfoById(Util.getIntValue(imageid));
|
||||
InputStream inputStream = imageFileManager.getInputStream();
|
||||
//中文路径/中文文件名
|
||||
String imageFileName = filePath + File.separator + newRequestid + File.separator + FJDIR + File.separator + QZYJFJWORD+ "-" +imageFileManager.getImageFileName();
|
||||
fjFileName.add(QZYJFJWORD+ "-" +imageFileManager.getImageFileName());
|
||||
log.info("生成签字意见附件路径:{}", imageFileName);
|
||||
imageFileName = ArchivesUtil.codeUtf8(imageFileName);
|
||||
try {
|
||||
File file = ArchivesUtil.saveInputStreamToFile(inputStream, imageFileName);
|
||||
String jsonStr = ArchivesUtil.callApi(Url, file);
|
||||
log.error("永中接口返回数据:{}", jsonStr);
|
||||
JSONObject result = JSONObject.parseObject(jsonStr);
|
||||
String errorcode = result.getString("errorcode");
|
||||
if ("0".equals(errorcode)) {
|
||||
JSONObject data = result.getJSONObject("data");
|
||||
String destFileName = data.getString("destFileName");
|
||||
String viewUrl = data.getString("viewUrl");
|
||||
ArchivesUtil.downloadFile(viewUrl, filePath + File.separator + newRequestid + File.separator + FJDIR + File.separator + QZYJFJWORD+ "-" + imageFileManager.getImageFileName() + ".pdf");
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}finally {
|
||||
if(inputStream!=null) {
|
||||
try {
|
||||
inputStream.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
//多文档
|
||||
// dwdMap.forEach((docid, imageid) -> {
|
||||
// ImageFileManager imageFileManager = new ImageFileManager();
|
||||
// imageFileManager.getImageFileInfoById(Util.getIntValue(imageid));
|
||||
// InputStream inputStream = imageFileManager.getInputStream();
|
||||
// zwFileName.add(imageFileManager.getImageFileName());
|
||||
// //中文路径/中文文件名
|
||||
// String imageFileName = filePath + File.separator + requestid + File.separator + zwdir + File.separator + fjWord + i[0] + "_" + zwWord + "_" + imageFileManager.getImageFileName();
|
||||
// log.info("生成多文档路径:{}", imageFileName);
|
||||
// imageFileName = ArchivesUtil.codeUtf8(imageFileName);
|
||||
// try {
|
||||
// File file = ArchivesUtil.saveInputStreamToFile(inputStream, imageFileName);
|
||||
// String jsonStr = ArchivesUtil.callApi(Url, file);
|
||||
// log.error("永中接口返回:{}", jsonStr);
|
||||
// JSONObject result = JSONObject.parseObject(jsonStr);
|
||||
// String errorcode = result.getString("errorcode");
|
||||
// if ("0".equals(errorcode)) {
|
||||
// JSONObject data = result.getJSONObject("data");
|
||||
// String destFileName = data.getString("destFileName");
|
||||
// String viewUrl = data.getString("viewUrl");
|
||||
// ArchivesUtil.downloadFile(viewUrl, filePath + File.separator + requestid + File.separator + zwdir + File.separator + fjWord + i[0] + "_" + zwWord + "_" + imageFileManager.getImageFileName() + ".pdf");
|
||||
// }
|
||||
// } catch (IOException e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// i[0]++;
|
||||
// });
|
||||
//正文
|
||||
zwMap.forEach((docid, imageid) -> {
|
||||
ImageFileManager imageFileManager = new ImageFileManager();
|
||||
imageFileManager.getImageFileInfoById(Util.getIntValue(imageid));
|
||||
InputStream inputStream = imageFileManager.getInputStream();
|
||||
|
||||
String newFile = FJWORD + i[0] + "_" + ZWWORD + "-" + (imageFileManager.getImageFileName().replaceAll("/","-"));
|
||||
//中文路径/中文文件名
|
||||
String imageFileName = filePath + File.separator + newRequestid + File.separator + ZWDIR + File.separator + newFile;
|
||||
zwFileName.add(newFile);
|
||||
log.info("生成正文路径:{}", imageFileName);
|
||||
imageFileName = ArchivesUtil.codeUtf8(imageFileName);
|
||||
try {
|
||||
File file = ArchivesUtil.saveInputStreamToFile(inputStream, imageFileName);
|
||||
String jsonStr = ArchivesUtil.callApi(Url, file);
|
||||
log.error("永中接口返回:{}", jsonStr);
|
||||
JSONObject result = JSONObject.parseObject(jsonStr);
|
||||
String errorcode = result.getString("errorcode");
|
||||
if ("0".equals(errorcode)) {
|
||||
JSONObject data = result.getJSONObject("data");
|
||||
String destFileName = data.getString("destFileName");
|
||||
String viewUrl = data.getString("viewUrl");
|
||||
ArchivesUtil.downloadFile(viewUrl, filePath + File.separator + newRequestid + File.separator + ZWDIR + File.separator + newFile + ".pdf");
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}finally {
|
||||
if(inputStream!=null) {
|
||||
try {
|
||||
inputStream.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
i[0]++;
|
||||
});
|
||||
//清稿前痕迹
|
||||
qgqhjMap.forEach((docid, imageid) -> {
|
||||
ImageFileManager imageFileManager = new ImageFileManager();
|
||||
imageFileManager.getImageFileInfoById(Util.getIntValue(imageid));
|
||||
InputStream inputStream = imageFileManager.getInputStream();
|
||||
|
||||
String newFile = FJWORD + i[0] + "_" + LHGWORD + "-" + (imageFileManager.getImageFileName().replaceAll("/","-"));
|
||||
zwFileName.add(newFile);
|
||||
//中文路径/中文文件名
|
||||
String imageFileName = filePath + File.separator + newRequestid + File.separator + ZWDIR + File.separator + newFile;
|
||||
log.info("生成清稿前痕迹路径:{}", imageFileName);
|
||||
imageFileName = ArchivesUtil.codeUtf8(imageFileName);
|
||||
try {
|
||||
File file = ArchivesUtil.saveInputStreamToFile(inputStream, imageFileName);
|
||||
String jsonStr = ArchivesUtil.callApi(Url, file);
|
||||
log.error("永中接口返回:{}", jsonStr);
|
||||
JSONObject result = JSONObject.parseObject(jsonStr);
|
||||
String errorcode = result.getString("errorcode");
|
||||
if ("0".equals(errorcode)) {
|
||||
JSONObject data = result.getJSONObject("data");
|
||||
String destFileName = data.getString("destFileName");
|
||||
String viewUrl = data.getString("viewUrl");
|
||||
ArchivesUtil.downloadFile(viewUrl, filePath + File.separator + newRequestid + File.separator + ZWDIR + File.separator + newFile + ".pdf");
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}finally {
|
||||
if(inputStream!=null) {
|
||||
try {
|
||||
inputStream.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
i[0]++;
|
||||
});
|
||||
//套红后留痕
|
||||
// thhlhMap.forEach((docid, imageid) -> {
|
||||
// ImageFileManager imageFileManager = new ImageFileManager();
|
||||
// imageFileManager.getImageFileInfoById(Util.getIntValue(imageid));
|
||||
// InputStream inputStream = imageFileManager.getInputStream();
|
||||
// zwFileName.add(imageFileManager.getImageFileName());
|
||||
// //中文路径/中文文件名
|
||||
// String imageFileName = filePath + File.separator + requestid + File.separator + zwdir + File.separator + fjWord + i[0] + "_" + lhgWord + "_" + imageFileManager.getImageFileName();
|
||||
// log.info("生成套红后留痕路径:{}", imageFileName);
|
||||
// imageFileName = ArchivesUtil.codeUtf8(imageFileName);
|
||||
// try {
|
||||
// File file = ArchivesUtil.saveInputStreamToFile(inputStream, imageFileName);
|
||||
// String jsonStr = ArchivesUtil.callApi(Url, file);
|
||||
// log.error("永中接口返回:{}", jsonStr);
|
||||
// JSONObject result = JSONObject.parseObject(jsonStr);
|
||||
// String errorcode = result.getString("errorcode");
|
||||
// if ("0".equals(errorcode)) {
|
||||
// JSONObject data = result.getJSONObject("data");
|
||||
// String destFileName = data.getString("destFileName");
|
||||
// String viewUrl = data.getString("viewUrl");
|
||||
// ArchivesUtil.downloadFile(viewUrl, filePath + File.separator + requestid + File.separator + zwdir + File.separator + fjWord + i[0] + "_" + lhgWord + "_" + imageFileManager.getImageFileName() + ".pdf");
|
||||
// }
|
||||
// } catch (IOException e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// i[0]++;
|
||||
// });
|
||||
|
||||
//开始承办单 先获取主流程的承办单
|
||||
List<String> requestDocid = ArchivesUtil.generaRequestFormPdf(requestid, 0);
|
||||
// 1.去掉生成子流程承办单
|
||||
// List<String> subRequestDocid = generaSubRequestFormPdf(requestid);
|
||||
Map<String, String> reqDocMap = ArchivesUtil.getFileIdByDocId(String.join(",", requestDocid));
|
||||
// 2.去掉生成子流程承办单
|
||||
// Map<String, String> subReqDocMap = getFileIdByDocId(String.join(",", subRequestDocid));
|
||||
log.error("reqDocMap:{}", JSONObject.toJSONString(reqDocMap));
|
||||
//log.error("subReqDocMap:{}", JSONObject.toJSONString(subReqDocMap));
|
||||
docids.addAll(requestDocid);
|
||||
// 3.去掉生成子流程承办单
|
||||
// docids.addAll(subRequestDocid);
|
||||
i[0] = 1;
|
||||
//主流程承办单
|
||||
reqDocMap.forEach((docid, imageid) -> {
|
||||
ImageFileManager imageFileManager = new ImageFileManager();
|
||||
imageFileManager.getImageFileInfoById(Util.getIntValue(imageid));
|
||||
InputStream inputStream = imageFileManager.getInputStream();
|
||||
//中文路径/中文文件名
|
||||
// String imageFileName = filePath + File.separator + requestid + File.separator + cbddir + File.separator + fjFile + i[0] + "_" + imageFileManager.getImageFileName();
|
||||
// String imageFileName = filePath + File.separator + newRequestid + File.separator + cbddir + File.separator + fjFile + i[0] + "_" + wjcldWord+".pdf";
|
||||
String imageFileName = filePath + File.separator + newRequestid + File.separator + CBDDIR + File.separator + WJCLDWORD+".pdf";
|
||||
log.info("主流程承办单路径:{}", imageFileName);
|
||||
imageFileName = ArchivesUtil.codeUtf8(imageFileName);
|
||||
try {
|
||||
File file = ArchivesUtil.saveInputStreamToFile(inputStream, imageFileName);
|
||||
String jsonStr = ArchivesUtil.callApi(Url, file);
|
||||
log.error("永中接口返回:{}", jsonStr);
|
||||
JSONObject result = JSONObject.parseObject(jsonStr);
|
||||
String errorcode = result.getString("errorcode");
|
||||
if ("0".equals(errorcode)) {
|
||||
JSONObject data = result.getJSONObject("data");
|
||||
String destFileName = data.getString("destFileName");
|
||||
String viewUrl = data.getString("viewUrl");
|
||||
ArchivesUtil.downloadFile(viewUrl, filePath + File.separator + newRequestid + File.separator + CBDDIR + File.separator + WJCLDWORD + ".pdf" + ".pdf");
|
||||
}
|
||||
i[0]++;
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}finally {
|
||||
if(inputStream!=null) {
|
||||
try {
|
||||
inputStream.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
//正文
|
||||
|
||||
|
||||
log.error(JSONObject.toJSONString(requestDocid));
|
||||
for (String docid : docids) {
|
||||
log.error("删除了" + docid);
|
||||
ArchivesUtil.deleteDocByid(docid);
|
||||
}
|
||||
//--------------------------------------------------------------------
|
||||
RequestService requestService = new RequestService();
|
||||
RequestInfo requestInfo = requestService.getRequest(Util.getIntValue(requestid), 100);
|
||||
String workflowid = requestInfo.getWorkflowid();
|
||||
String logFile = ArchivesUtil.getSignLog(requestid, CBDDIR + File.separator + LZXXDIR, requestInfo.getCreatorid() + requestInfo.getDescription(), templatePath, filePath,false,workflowid);
|
||||
String s = ArchivesUtil.callApi(Url, new File(logFile));
|
||||
log.error(s);
|
||||
JSONObject result = JSONObject.parseObject(s);
|
||||
String errorcode = result.getString("errorcode");
|
||||
if ("0".equals(errorcode)) {
|
||||
JSONObject data = result.getJSONObject("data");
|
||||
String destFileName = data.getString("destFileName");
|
||||
String viewUrl = data.getString("viewUrl");
|
||||
ArchivesUtil.downloadFile(viewUrl, logFile + ".pdf");
|
||||
}
|
||||
String zipName = filePath + File.separator + newRequestid + ".zip";
|
||||
ZipUtil.zip(filePath + File.separator + newRequestid, zipName);
|
||||
log.error("zipName:{}", zipName);
|
||||
String ftpFilePath = HgUtils.putFile(zipName, newRequestid + ".zip");
|
||||
log.error("ftpFilePath:{}", ftpFilePath);
|
||||
updateRecord(requestid,"esbwjml",ftpFilePath);
|
||||
ArchivesUtil.deleteDirectory(filePath + File.separator + newRequestid);
|
||||
// String ftpFilePathNew = HgUtils.putFile(zipName, "test" + File.separator + requestid + ".zip");
|
||||
// log.error("ftpFilePathNew:{}", ftpFilePathNew);
|
||||
String context = getContext(requestid, requesData, newRequestid + ".zip", zwFileName, fjFileName);
|
||||
// insertRecord(requestid, context, ftpFilePath);
|
||||
updateRecord(requestid,"content",context);
|
||||
log.error("context:{}", context);
|
||||
return context;
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
* 封装数据
|
||||
* @param requestid
|
||||
* @return
|
||||
*/
|
||||
public Map<String, String> getRequestByid(int requestid) {
|
||||
HashMap<String, String> record = new HashMap<>();
|
||||
String sql = "select * from formtable_main_49 where requestid = ?";
|
||||
String reqsql = "select REQUESTNAME from WORKFLOW_REQUESTBASE where REQUESTID = ?";
|
||||
RecordSet rs = new RecordSet();
|
||||
rs.executeQuery(sql, requestid);
|
||||
if (rs.next()) {
|
||||
record.put("fj", Util.null2String(rs.getString("fj")));
|
||||
record.put("dwd", Util.null2String(rs.getString("dwd")));
|
||||
record.put("zw", Util.null2String(rs.getString("zw")));
|
||||
record.put("ngrq", Util.null2String(rs.getString("ngrq")));
|
||||
record.put("jghwt", Util.null2String(rs.getString("jghwt")));
|
||||
record.put("bh", Util.null2String(rs.getString("bh")));
|
||||
record.put("ngbm", Util.null2String(rs.getString("ngbm")));
|
||||
record.put("bgqx", Util.null2String(rs.getString("bgqx")));
|
||||
record.put("cwrq", Util.null2String(rs.getString("cwrq")));
|
||||
record.put("ys", Util.null2String(rs.getString("ys")));
|
||||
record.put("wz", Util.null2String(rs.getString("wz")));
|
||||
record.put("ngbm", Util.null2String(rs.getString("ngbm")));
|
||||
record.put("lb", Util.null2String(rs.getString("lb")));
|
||||
record.put("bz", Util.null2String(rs.getString("bz")));
|
||||
record.put("yywh", Util.null2String(rs.getString("yywh")));
|
||||
record.put("wjlx", Util.null2String(rs.getString("wjlx")));
|
||||
record.put("fwlx", Util.null2String(rs.getString("fwlx")));
|
||||
record.put("f", Util.null2String(rs.getString("f")));
|
||||
record.put("ngr", Util.null2String(rs.getString("ngr")));
|
||||
record.put("qgqhj", Util.null2String(rs.getString("qgqhj")));
|
||||
record.put("thhlh", Util.null2String(rs.getString("thhlh")));
|
||||
|
||||
}
|
||||
rs.executeQuery(reqsql, requestid);
|
||||
if (rs.next()) {
|
||||
record.put("REQUESTNAME", Util.null2String(rs.getString("REQUESTNAME")));
|
||||
}
|
||||
return record;
|
||||
}
|
||||
|
||||
private String getContext(int requestid, Map<String, String> requesData, String zipName, List<String> zwFileName, List<String> fjFileName) {
|
||||
StringBuilder context = new StringBuilder();
|
||||
try {
|
||||
DepartmentComInfo departmentComInfo = new DepartmentComInfo();
|
||||
String ngrq = Util.null2String(requesData.get("ngrq")); //拟稿日期
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||
LocalDate date = LocalDate.parse(ngrq, formatter);
|
||||
int year = date.getYear();
|
||||
context.append(year).append("|"); //1.年度 -> 拟稿日期
|
||||
String jghwt = Util.null2String(requesData.get("jghwt"));//2.机构或问题 -> 机构或问题
|
||||
context.append(jghwt).append("|");
|
||||
String bh = Util.null2String(requesData.get("bh"));// 3.文号 -> 编号
|
||||
context.append(bh).append("|");
|
||||
String requestname = Util.null2String(requesData.get("REQUESTNAME")); // 4.文件题名 -> 流程名称
|
||||
context.append(requestname).append("|");
|
||||
String ngbmName = Util.null2String(departmentComInfo.getDepartmentmark(requesData.get("ngbm"))); //5 责任者 -> 拟稿部门
|
||||
context.append(ngbmName).append("|");
|
||||
String bgqx = Util.null2String(requesData.get("bgqx")); //6 保管期限 -> 保管期限
|
||||
context.append(bgqx).append("|");
|
||||
String cwrq = Util.null2String(requesData.get("cwrq")); //7 日期 -> 成文日期
|
||||
context.append(cwrq).append("|");
|
||||
String ys = Util.null2String(requesData.get("ys")); //8 页数 -> 页数
|
||||
context.append(ys).append("|");
|
||||
String wz = Util.null2String(requesData.get("wz")); //9 文种 -> 文种
|
||||
context.append(wz).append("|");
|
||||
String ngbm = Util.null2String(requesData.get("ngbm"));
|
||||
String[] deptData = ArchivesUtil.getDeptNameAndCode(ngbm);
|
||||
String[] subData = ArchivesUtil.getSubCom(ngbm);
|
||||
context.append(subData[0]).append("|"); //10 行编号 -> 拟稿部门
|
||||
|
||||
context.append(subData[1]).append("|"); //11 行名称
|
||||
context.append("").append("|"); // 12 保管期限编号
|
||||
context.append("").append("|"); // 13 保管期限及编号
|
||||
context.append("").append("|"); // 14 是否开放
|
||||
context.append("").append("|"); // 15 互见号
|
||||
String lb = Util.null2String(requesData.get("lb"));
|
||||
context.append(lb).append("|"); //16 类别 -> 类别
|
||||
//TODO
|
||||
String xgbm = Util.null2String(getAssociatedDepts(requesData));
|
||||
context.append(xgbm).append("|"); //17 相关部门 -> 流经部门
|
||||
// String lwh = Util.null2String(requesData.get("lwh"));
|
||||
context.append("").append("|");// 18 收文号 -> 空
|
||||
String fs = "";
|
||||
context.append(fs).append("|"); // 19 份数 -> 份数
|
||||
String bz = Util.null2String(requesData.get("bz"));
|
||||
context.append("").append("|"); // 20 备注 -> 备注
|
||||
String yywh = Util.null2String(requesData.get("yywh"));
|
||||
context.append("").append("|"); // 21 引用文号 -> 引用文号
|
||||
String wjlx = Util.null2String(requesData.get("wjlx"));
|
||||
context.append("").append("|"); // 22 文件类型 -> 空
|
||||
String fwlx = Util.null2String(requesData.get("fwlx"));
|
||||
context.append("分行发文").append("|"); // 23 发文类型 -> 空
|
||||
String f = Util.null2String(requesData.get("f"));
|
||||
context.append(f).append("|"); // 24 发 -> 空
|
||||
String ngr = Util.null2String(requesData.get("ngr"));
|
||||
context.append(new User(Util.getIntValue(ngr)).getLoginid()).append("|"); // 25 拟稿人 -> 拟稿人
|
||||
context.append(ngbmName).append("|"); // 26 拟稿部门 -> 拟稿部门名称
|
||||
context.append("发文").append("|"); // 27 公文类型 -> "收文"
|
||||
//TODO
|
||||
context.append(ArchivesUtil.getAssociatedPersons(requestid,false)).append("|"); // 28 相关人员 -> 参与人员
|
||||
context.append("智慧OA").append("|"); // 29 数据来源 -> 数据来源
|
||||
context.append(year).append("|"); // 30 形成年度 -> 年份
|
||||
context.append(String.join("&&", zwFileName)).append("|"); // 31 正文名称
|
||||
context.append(String.join("&&", fjFileName)).append("|"); // 32 附件名称
|
||||
context.append("togd"+requestid).append("|"); // 33 主键
|
||||
context.append("").append("|"); // 34 关联主键
|
||||
context.append("").append("|"); // 35 被关联主键
|
||||
context.append(zipName);// 36 压缩包名称
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
log.error("getContextError:{}", e.getMessage());
|
||||
}
|
||||
|
||||
return context.toString();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private String getAssociatedDepts(Map<String, String> requesData) {
|
||||
HashSet<String> records = new HashSet<>();
|
||||
records.addAll(Arrays.asList(Util.null2String(requesData.get("hqbm")).split(","))); // 会签部门
|
||||
records.addAll(Arrays.asList(Util.null2String(requesData.get("ngbm")).split(","))); // 拟稿部门
|
||||
records.addAll(Arrays.asList(Util.null2String(requesData.get("bmyb")).split(","))); // 部门阅办
|
||||
records.addAll(Arrays.asList(Util.null2String(requesData.get("cs")).split(","))); // 抄送
|
||||
records.addAll(Arrays.asList(Util.null2String(requesData.get("nbfs")).split(","))); // 本行发送
|
||||
records.addAll(Arrays.asList(Util.null2String(requesData.get("zs")).split(","))); // 主送
|
||||
records.addAll(Arrays.asList(Util.null2String(requesData.get("dqbm")).split(","))); // 当前部门
|
||||
records.addAll(Arrays.asList(Util.null2String(requesData.get("cb")).split(","))); // 抄报
|
||||
records.addAll(Arrays.asList(Util.null2String(requesData.get("bmhqzj")).split(","))); // 部门会签(追加)
|
||||
records.addAll(Arrays.asList(Util.null2String(requesData.get("bmybzj")).split(","))); // 部门阅办(追加)
|
||||
ArrayList<String> deptName = new ArrayList<>();
|
||||
DepartmentComInfo departmentComInfo = new DepartmentComInfo();
|
||||
for (String record : records) {
|
||||
try {
|
||||
if (StringUtil.isEmpty(record)){
|
||||
continue;
|
||||
}
|
||||
String departmentName = departmentComInfo.getDepartmentmark(record);
|
||||
deptName.add(departmentName);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
return String.join("&&", deptName);
|
||||
}
|
||||
|
||||
private void updateRecord(int requestid, String field , String fieldvalue) {
|
||||
String sql = "update uf_pushArchivesLog set "+field+" = ? where request = ?";
|
||||
RecordSet recordSet = new RecordSet();
|
||||
recordSet.executeUpdate(sql, fieldvalue, requestid);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,541 @@
|
||||
package com.engine.custom.archives.service.firstBranch;
|
||||
|
||||
import cn.hutool.core.util.ZipUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
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.archives.util.KeyWord;
|
||||
import com.engine.custom.hg.util.HgUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.file.ImageFileManager;
|
||||
import weaver.general.StringUtil;
|
||||
import weaver.general.Util;
|
||||
import weaver.hrm.User;
|
||||
import weaver.hrm.company.DepartmentComInfo;
|
||||
import weaver.soa.workflow.request.RequestInfo;
|
||||
import weaver.soa.workflow.request.RequestService;
|
||||
|
||||
import java.io.*;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
|
||||
public class FirstBranchSignReportPushArchivesService implements KeyWord {
|
||||
public static Logger log = LoggerFactory.getLogger("Archives");
|
||||
private static String filePath;
|
||||
private static String Url;
|
||||
private static String templatePath; // 模板文件路径
|
||||
|
||||
private int endTime= 7;
|
||||
|
||||
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"));
|
||||
endTime = Util.getIntValue(param.get("endTime"),7);
|
||||
}
|
||||
|
||||
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();
|
||||
//签报 type = 2
|
||||
List<PushArchivesBean> result = ArchivesUtil.getResultList(recordSet, firstSecond, lastSecond, 5);
|
||||
log.error("推送发文的数量:{}", result.size());
|
||||
File file = ArchivesUtil.crFile(filePath + "/togd_" + new SimpleDateFormat("yyyyMMdd000000").format(date));
|
||||
log.error("textfile:{}", file.getAbsolutePath());
|
||||
for (PushArchivesBean pushArchivesBean : result) {
|
||||
if (ArchivesUtil.isAfterSevenAM(endTime)){
|
||||
log.info("超过执行时间:{}点暂停计划任务",endTime);
|
||||
break;
|
||||
}
|
||||
int id = pushArchivesBean.getId();
|
||||
int request = pushArchivesBean.getRequest();
|
||||
log.error("推送的requestId:{}", request);
|
||||
try {
|
||||
String context = generateFile(request);
|
||||
if ("-1".equals(context)){
|
||||
continue;
|
||||
}
|
||||
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);
|
||||
updateRecord(request,"esbtxtml",s);
|
||||
updateRecord(request,"zt","0");
|
||||
log.error("textZip:{}", s);
|
||||
} catch (FtpException e) {
|
||||
log.error("推送档案requestid:{}异常,异常原因为:{}",request,e.getMessage());
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
log.error("推送档案requestid:{}异常,异常原因为:{}",request,e.getMessage());
|
||||
e.printStackTrace();
|
||||
} catch (Exception e) {
|
||||
log.error("推送档案requestid:{}异常,异常原因为:{}",request,e.getMessage());
|
||||
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
private String generateFile(int requestid) throws FtpException, IOException {
|
||||
Map<String, String> requesData = getRequestByid(requestid);
|
||||
String newRequestid = "togd"+requestid;
|
||||
log.info("requesData:{}", requesData);
|
||||
String bhnew = requesData.get("bhnew");
|
||||
log.info("流程id:{}:文号为空不推送", requestid);
|
||||
if (StringUtil.isEmpty(bhnew)){
|
||||
return "-1";
|
||||
}
|
||||
String fj = Util.null2String(requesData.get("fj"));
|
||||
String dwd = Util.null2String(requesData.get("dwd"));
|
||||
String zw = Util.null2String(requesData.get("zw"));
|
||||
String qgqhj = Util.null2String(requesData.get("qgqhj"));
|
||||
//可能有多个,获取id最大的一个
|
||||
qgqhj = Util.null2String(ArchivesUtil.findMaxValue(qgqhj));
|
||||
|
||||
//增加签字意见中的附件到附件文件夹中
|
||||
Map<String, String> signFiles = ArchivesUtil.getSignFiles(requestid,true);
|
||||
List<String> docids = new ArrayList<>();
|
||||
// docids.addAll(Arrays.asList(fj.split(",")));
|
||||
// docids.addAll(Arrays.asList(zwkbj.split(",")));
|
||||
Map<String, String> fjMap = ArchivesUtil.getFileIdByDocId(fj);
|
||||
Map<String, String> zwMap = ArchivesUtil.getFileIdByDocId(zw);
|
||||
Map<String, String> qgqhjMap = ArchivesUtil.getFileIdByDocId(qgqhj);
|
||||
List<String> zwFileName = new ArrayList<>();
|
||||
List<String> fjFileName = new ArrayList<>();
|
||||
final int[] i = {1};
|
||||
//附件
|
||||
fjMap.forEach((docid, imageid) -> {
|
||||
ImageFileManager imageFileManager = new ImageFileManager();
|
||||
imageFileManager.getImageFileInfoById(Util.getIntValue(imageid));
|
||||
InputStream inputStream = imageFileManager.getInputStream();
|
||||
//中文路径/中文文件名
|
||||
String imageFileName = filePath + File.separator + newRequestid + File.separator + FJDIR + File.separator + LCFJWORD + "-" +imageFileManager.getImageFileName();
|
||||
fjFileName.add(imageFileManager.getImageFileName());
|
||||
log.info("生成附件路径:{}", imageFileName);
|
||||
imageFileName = ArchivesUtil.codeUtf8(imageFileName);
|
||||
try {
|
||||
File file = ArchivesUtil.saveInputStreamToFile(inputStream, imageFileName);
|
||||
String jsonStr = ArchivesUtil.callApi(Url, file);
|
||||
log.error("永中接口返回数据:{}", jsonStr);
|
||||
JSONObject result = JSONObject.parseObject(jsonStr);
|
||||
String errorcode = result.getString("errorcode");
|
||||
if ("0".equals(errorcode)) {
|
||||
JSONObject data = result.getJSONObject("data");
|
||||
String destFileName = data.getString("destFileName");
|
||||
String viewUrl = data.getString("viewUrl");
|
||||
ArchivesUtil.downloadFile(viewUrl, filePath + File.separator + newRequestid + File.separator + FJDIR + File.separator + LCFJWORD + "-" + imageFileManager.getImageFileName() + ".pdf");
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if(inputStream!=null) {
|
||||
try {
|
||||
inputStream.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
//签字意见附件
|
||||
signFiles.forEach((docid, imageid) -> {
|
||||
ImageFileManager imageFileManager = new ImageFileManager();
|
||||
imageFileManager.getImageFileInfoById(Util.getIntValue(imageid));
|
||||
InputStream inputStream = imageFileManager.getInputStream();
|
||||
//中文路径/中文文件名
|
||||
String imageFileName = filePath + File.separator + newRequestid + File.separator + FJDIR + File.separator + QZYJFJWORD+ "-" +imageFileManager.getImageFileName();
|
||||
fjFileName.add(imageFileManager.getImageFileName());
|
||||
log.info("生成签字意见附件路径:{}", imageFileName);
|
||||
imageFileName = ArchivesUtil.codeUtf8(imageFileName);
|
||||
try {
|
||||
File file = ArchivesUtil.saveInputStreamToFile(inputStream, imageFileName);
|
||||
String jsonStr = ArchivesUtil.callApi(Url, file);
|
||||
log.error("永中接口返回数据:{}", jsonStr);
|
||||
JSONObject result = JSONObject.parseObject(jsonStr);
|
||||
String errorcode = result.getString("errorcode");
|
||||
if ("0".equals(errorcode)) {
|
||||
JSONObject data = result.getJSONObject("data");
|
||||
String destFileName = data.getString("destFileName");
|
||||
String viewUrl = data.getString("viewUrl");
|
||||
ArchivesUtil.downloadFile(viewUrl, filePath + File.separator + newRequestid + File.separator + FJDIR + File.separator + QZYJFJWORD+ "-" + imageFileManager.getImageFileName() + ".pdf");
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if(inputStream!=null) {
|
||||
try {
|
||||
inputStream.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
//正文
|
||||
zwMap.forEach((docid, imageid) -> {
|
||||
ImageFileManager imageFileManager = new ImageFileManager();
|
||||
imageFileManager.getImageFileInfoById(Util.getIntValue(imageid));
|
||||
InputStream inputStream = imageFileManager.getInputStream();
|
||||
|
||||
String newFile = FJWORD + i[0] + "_" + ZWWORD + "-" + (imageFileManager.getImageFileName().replaceAll("/","-"));
|
||||
//中文路径/中文文件名
|
||||
String imageFileName = filePath + File.separator + newRequestid + File.separator + ZWDIR + File.separator + newFile;
|
||||
zwFileName.add(newFile);
|
||||
log.info("生成正文路径:{}", imageFileName);
|
||||
imageFileName = ArchivesUtil.codeUtf8(imageFileName);
|
||||
try {
|
||||
File file = ArchivesUtil.saveInputStreamToFile(inputStream, imageFileName);
|
||||
String jsonStr = ArchivesUtil.callApi(Url, file);
|
||||
log.error("永中接口返回:{}", jsonStr);
|
||||
JSONObject result = JSONObject.parseObject(jsonStr);
|
||||
String errorcode = result.getString("errorcode");
|
||||
if ("0".equals(errorcode)) {
|
||||
JSONObject data = result.getJSONObject("data");
|
||||
String destFileName = data.getString("destFileName");
|
||||
String viewUrl = data.getString("viewUrl");
|
||||
ArchivesUtil.downloadFile(viewUrl, filePath + File.separator + newRequestid + File.separator + ZWDIR + File.separator + newFile + ".pdf");
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if(inputStream!=null) {
|
||||
try {
|
||||
inputStream.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
i[0]++;
|
||||
});
|
||||
//清稿前痕迹
|
||||
qgqhjMap.forEach((docid, imageid) -> {
|
||||
ImageFileManager imageFileManager = new ImageFileManager();
|
||||
imageFileManager.getImageFileInfoById(Util.getIntValue(imageid));
|
||||
InputStream inputStream = imageFileManager.getInputStream();
|
||||
|
||||
String newFile = FJWORD + i[0] + "_" + LHGWORD + "-" + (imageFileManager.getImageFileName().replaceAll("/","-"));
|
||||
zwFileName.add(newFile);
|
||||
//中文路径/中文文件名
|
||||
String imageFileName = filePath + File.separator + newRequestid + File.separator + ZWDIR + File.separator + newFile;
|
||||
log.info("生成清稿前痕迹路径:{}", imageFileName);
|
||||
imageFileName = ArchivesUtil.codeUtf8(imageFileName);
|
||||
try {
|
||||
File file = ArchivesUtil.saveInputStreamToFile(inputStream, imageFileName);
|
||||
String jsonStr = ArchivesUtil.callApi(Url, file);
|
||||
log.error("永中接口返回:{}", jsonStr);
|
||||
JSONObject result = JSONObject.parseObject(jsonStr);
|
||||
String errorcode = result.getString("errorcode");
|
||||
if ("0".equals(errorcode)) {
|
||||
JSONObject data = result.getJSONObject("data");
|
||||
String destFileName = data.getString("destFileName");
|
||||
String viewUrl = data.getString("viewUrl");
|
||||
ArchivesUtil.downloadFile(viewUrl, filePath + File.separator + newRequestid + File.separator + ZWDIR + File.separator + newFile + ".pdf");
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if(inputStream!=null) {
|
||||
try {
|
||||
inputStream.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
i[0]++;
|
||||
});
|
||||
//套红后留痕
|
||||
// thhlhMap.forEach((docid, imageid) -> {
|
||||
// ImageFileManager imageFileManager = new ImageFileManager();
|
||||
// imageFileManager.getImageFileInfoById(Util.getIntValue(imageid));
|
||||
// InputStream inputStream = imageFileManager.getInputStream();
|
||||
// zwFileName.add(imageFileManager.getImageFileName());
|
||||
// //中文路径/中文文件名
|
||||
// String imageFileName = filePath + File.separator + requestid + File.separator + zwdir + File.separator + fjWord + i[0] + "_" + lhgWord + "_" + imageFileManager.getImageFileName();
|
||||
// log.info("生成套红后留痕路径:{}", imageFileName);
|
||||
// imageFileName = ArchivesUtil.codeUtf8(imageFileName);
|
||||
// try {
|
||||
// File file = ArchivesUtil.saveInputStreamToFile(inputStream, imageFileName);
|
||||
// String jsonStr = ArchivesUtil.callApi(Url, file);
|
||||
// log.error("永中接口返回:{}", jsonStr);
|
||||
// JSONObject result = JSONObject.parseObject(jsonStr);
|
||||
// String errorcode = result.getString("errorcode");
|
||||
// if ("0".equals(errorcode)) {
|
||||
// JSONObject data = result.getJSONObject("data");
|
||||
// String destFileName = data.getString("destFileName");
|
||||
// String viewUrl = data.getString("viewUrl");
|
||||
// ArchivesUtil.downloadFile(viewUrl, filePath + File.separator + requestid + File.separator + zwdir + File.separator + fjWord + i[0] + "_" + lhgWord + "_" + imageFileManager.getImageFileName() + ".pdf");
|
||||
// }
|
||||
// } catch (IOException e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// i[0]++;
|
||||
// });
|
||||
|
||||
//开始承办单 先获取主流程的承办单
|
||||
List<String> requestDocid = ArchivesUtil.generaRequestFormPdf(requestid, 0);
|
||||
// 1.去掉生成子流程承办单
|
||||
// List<String> subRequestDocid = generaSubRequestFormPdf(requestid);
|
||||
Map<String, String> reqDocMap = ArchivesUtil.getFileIdByDocId(String.join(",", requestDocid));
|
||||
// 2.去掉生成子流程承办单
|
||||
// Map<String, String> subReqDocMap = getFileIdByDocId(String.join(",", subRequestDocid));
|
||||
log.error("reqDocMap:{}", JSONObject.toJSONString(reqDocMap));
|
||||
//log.error("subReqDocMap:{}", JSONObject.toJSONString(subReqDocMap));
|
||||
docids.addAll(requestDocid);
|
||||
// 3.去掉生成子流程承办单
|
||||
// docids.addAll(subRequestDocid);
|
||||
i[0] = 1;
|
||||
//主流程承办单
|
||||
reqDocMap.forEach((docid, imageid) -> {
|
||||
ImageFileManager imageFileManager = new ImageFileManager();
|
||||
imageFileManager.getImageFileInfoById(Util.getIntValue(imageid));
|
||||
InputStream inputStream = imageFileManager.getInputStream();
|
||||
//中文路径/中文文件名
|
||||
// String imageFileName = filePath + File.separator + requestid + File.separator + cbddir + File.separator + fjFile + i[0] + "_" + imageFileManager.getImageFileName();
|
||||
// String imageFileName = filePath + File.separator + newRequestid + File.separator + cbddir + File.separator + fjFile + i[0] + "_" + wjcldWord+".pdf";
|
||||
String imageFileName = filePath + File.separator + newRequestid + File.separator + CBDDIR + File.separator + WJCLDWORD+".pdf";
|
||||
log.info("主流程承办单路径:{}", imageFileName);
|
||||
imageFileName = ArchivesUtil.codeUtf8(imageFileName);
|
||||
try {
|
||||
File file = ArchivesUtil.saveInputStreamToFile(inputStream, imageFileName);
|
||||
String jsonStr = ArchivesUtil.callApi(Url, file);
|
||||
log.error("永中接口返回:{}", jsonStr);
|
||||
JSONObject result = JSONObject.parseObject(jsonStr);
|
||||
String errorcode = result.getString("errorcode");
|
||||
if ("0".equals(errorcode)) {
|
||||
JSONObject data = result.getJSONObject("data");
|
||||
String destFileName = data.getString("destFileName");
|
||||
String viewUrl = data.getString("viewUrl");
|
||||
// ArchivesUtil.downloadFile(viewUrl, filePath + File.separator + newRequestid + File.separator + cbddir + File.separator + fjFile + i[0] + "_" + wjcldWord + ".pdf" + ".pdf");
|
||||
ArchivesUtil.downloadFile(viewUrl, filePath + File.separator + newRequestid + File.separator + CBDDIR + File.separator + WJCLDWORD + ".pdf" + ".pdf");
|
||||
}
|
||||
i[0]++;
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}finally {
|
||||
if(inputStream!=null) {
|
||||
try {
|
||||
inputStream.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
//正文
|
||||
|
||||
|
||||
log.error(JSONObject.toJSONString(requestDocid));
|
||||
for (String docid : docids) {
|
||||
log.error("删除了" + docid);
|
||||
ArchivesUtil.deleteDocByid(docid);
|
||||
}
|
||||
//--------------------------------------------------------------------
|
||||
RequestService requestService = new RequestService();
|
||||
RequestInfo requestInfo = requestService.getRequest(Util.getIntValue(requestid), 100);
|
||||
String workflowid = requestInfo.getWorkflowid();
|
||||
String logFile = ArchivesUtil.getSignLog(requestid, CBDDIR + File.separator + LZXXDIR, requestInfo.getCreatorid() + requestInfo.getDescription(), templatePath, filePath,false,workflowid);
|
||||
String s = ArchivesUtil.callApi(Url, new File(logFile));
|
||||
log.error(s);
|
||||
JSONObject result = JSONObject.parseObject(s);
|
||||
String errorcode = result.getString("errorcode");
|
||||
if ("0".equals(errorcode)) {
|
||||
JSONObject data = result.getJSONObject("data");
|
||||
String destFileName = data.getString("destFileName");
|
||||
String viewUrl = data.getString("viewUrl");
|
||||
ArchivesUtil.downloadFile(viewUrl, logFile + ".pdf");
|
||||
}
|
||||
String zipName = filePath + File.separator + newRequestid + ".zip";
|
||||
ZipUtil.zip(filePath + File.separator + newRequestid, zipName);
|
||||
log.error("zipName:{}", zipName);
|
||||
String ftpFilePath = HgUtils.putFile(zipName, newRequestid + ".zip");
|
||||
log.error("ftpFilePath:{}", ftpFilePath);
|
||||
updateRecord(requestid,"esbwjml",ftpFilePath);
|
||||
ArchivesUtil.deleteDirectory(filePath + File.separator + newRequestid);
|
||||
|
||||
// String ftpFilePathNew = HgUtils.putFile(zipName, "test" + File.separator + requestid + ".zip");
|
||||
// log.error("ftpFilePathNew:{}", ftpFilePathNew);
|
||||
String context = getContext(requestid, requesData, newRequestid + ".zip", zwFileName, fjFileName);
|
||||
// insertRecord(requestid, context, ftpFilePath);
|
||||
updateRecord(requestid,"content",context);
|
||||
log.error("context:{}", context);
|
||||
return context;
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
* 封装数据
|
||||
* @param requestid
|
||||
* @return
|
||||
*/
|
||||
public Map<String, String> getRequestByid(int requestid) {
|
||||
HashMap<String, String> record = new HashMap<>();
|
||||
String sql = "select * from formtable_main_69 where requestid = ?";
|
||||
String reqsql = "select REQUESTNAME from WORKFLOW_REQUESTBASE where REQUESTID = ?";
|
||||
RecordSet rs = new RecordSet();
|
||||
rs.executeQuery(sql, requestid);
|
||||
if (rs.next()) {
|
||||
record.put("bh", Util.null2String(rs.getString("bh")));
|
||||
record.put("bhnew", Util.null2String(rs.getString("bhnew")));
|
||||
record.put("ngbm", Util.null2String(rs.getString("ngbm")));
|
||||
record.put("ngr", Util.null2String(rs.getString("ngr")));
|
||||
record.put("ngrq", Util.null2String(rs.getString("ngrq")));
|
||||
record.put("lxfs", Util.null2String(rs.getString("lxfs")));
|
||||
record.put("bt", Util.null2String(rs.getString("bt")));
|
||||
record.put("zw", Util.null2String(rs.getString("zw")));
|
||||
record.put("fj", Util.null2String(rs.getString("fj")));
|
||||
record.put("hqbm", Util.null2String(rs.getString("hqbm")));
|
||||
record.put("hqbmzhwy", Util.null2String(rs.getString("hqbmzhwy")));
|
||||
record.put("hqdqbm", Util.null2String(rs.getString("hqdqbm")));
|
||||
record.put("ffbm", Util.null2String(rs.getString("ffbm")));
|
||||
record.put("hqbmzjhqbmzj", Util.null2String(rs.getString("hqbmzj")));
|
||||
record.put("dwd", Util.null2String(rs.getString("dwd")));
|
||||
record.put("bmffzj", Util.null2String(rs.getString("bmffzj")));
|
||||
record.put("dqnf", Util.null2String(rs.getString("dqnf")));
|
||||
record.put("qgqhj", Util.null2String(rs.getString("qgqhj")));
|
||||
}
|
||||
rs.executeQuery(reqsql, requestid);
|
||||
if (rs.next()) {
|
||||
record.put("REQUESTNAME", Util.null2String(rs.getString("REQUESTNAME")));
|
||||
}
|
||||
return record;
|
||||
}
|
||||
|
||||
|
||||
private String getContext(int requestid, Map<String, String> requesData, String zipName, List<String> zwFileName, List<String> fjFileName) {
|
||||
StringBuilder context = new StringBuilder();
|
||||
try {
|
||||
DepartmentComInfo departmentComInfo = new DepartmentComInfo();
|
||||
String ngrq = Util.null2String(requesData.get("ngrq")); //拟稿日期
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||
LocalDate date = LocalDate.parse(ngrq, formatter);
|
||||
int year = date.getYear();
|
||||
context.append(year).append("|"); //1.年度 -> 拟稿日期
|
||||
String jghwt = Util.null2String(requesData.get("jghwt"));//2.机构或问题 -> 机构或问题
|
||||
context.append(jghwt).append("|");
|
||||
String bh = Util.null2String(requesData.get("bhnew"));// 3.文号 -> 编号
|
||||
context.append(bh).append("|");
|
||||
String requestname = Util.null2String(requesData.get("REQUESTNAME")); // 4.文件题名 -> 流程名称
|
||||
context.append(requestname).append("|");
|
||||
String ngbmName = Util.null2String(departmentComInfo.getDepartmentname(requesData.get("ngbm"))); //5 责任者 -> 拟稿部门
|
||||
context.append(ngbmName).append("|");
|
||||
String bgqx = Util.null2String(requesData.get("bgqx")); //6 保管期限 -> 保管期限
|
||||
context.append(bgqx).append("|");
|
||||
// String cwrq = Util.null2String(requesData.get("cwrq")); //7 日期 -> 成文日期
|
||||
context.append(ngrq).append("|");
|
||||
String ys = Util.null2String(requesData.get("ys")); //8 页数 -> 页数
|
||||
context.append(ys).append("|");
|
||||
String wz = Util.null2String(requesData.get("wz")); //9 文种 -> 文种
|
||||
context.append(wz).append("|");
|
||||
String ngbm = Util.null2String(requesData.get("ngbm"));
|
||||
String[] deptData = ArchivesUtil.getDeptNameAndCode(ngbm);
|
||||
String[] subData = ArchivesUtil.getSubCom(ngbm);
|
||||
context.append(subData[0]).append("|"); //10 行编号 -> 拟稿部门
|
||||
|
||||
context.append(subData[1]).append("|"); //11 行名称
|
||||
context.append("").append("|"); // 12 保管期限编号
|
||||
context.append("").append("|"); // 13 保管期限及编号
|
||||
context.append("").append("|"); // 14 是否开放
|
||||
context.append("").append("|"); // 15 互见号
|
||||
String lb = Util.null2String(requesData.get("lb"));
|
||||
context.append(lb).append("|"); //16 类别 -> 类别
|
||||
//TODO
|
||||
String xgbm = Util.null2String(getAssociatedDepts(requesData));
|
||||
context.append(xgbm).append("|"); //17 相关部门 -> 流经部门
|
||||
// String lwh = Util.null2String(requesData.get("lwh"));
|
||||
context.append("").append("|");// 18 收文号 -> 空
|
||||
String fs = "";
|
||||
context.append(fs).append("|"); // 19 份数 -> 份数
|
||||
String bz = Util.null2String(requesData.get("bz"));
|
||||
context.append("").append("|"); // 20 备注 -> 备注
|
||||
String yywh = Util.null2String(requesData.get("yywh"));
|
||||
context.append("").append("|"); // 21 引用文号 -> 引用文号
|
||||
String wjlx = Util.null2String(requesData.get("wjlx"));
|
||||
context.append("").append("|"); // 22 文件类型 -> 空
|
||||
String fwlx = Util.null2String(requesData.get("fwlx"));
|
||||
context.append("分行签报").append("|"); // 23 发文类型 -> 空
|
||||
String f = Util.null2String(requesData.get("f"));
|
||||
context.append(f).append("|"); // 24 发 -> 空
|
||||
String ngr = Util.null2String(requesData.get("ngr"));
|
||||
context.append(new User(Util.getIntValue(ngr)).getLoginid()).append("|"); // 25 拟稿人 -> 拟稿人
|
||||
context.append(ngbmName).append("|"); // 26 拟稿部门 -> 拟稿部门名称
|
||||
context.append("签报").append("|"); // 27 公文类型 -> "收文"
|
||||
//TODO
|
||||
context.append(ArchivesUtil.getAssociatedPersons(requestid,false)).append("|"); // 28 相关人员 -> 参与人员
|
||||
context.append("智慧OA").append("|"); // 29 数据来源 -> 数据来源
|
||||
context.append(year).append("|"); // 30 形成年度 -> 年份
|
||||
context.append(String.join("&&", zwFileName)).append("|"); // 31 正文名称
|
||||
context.append(String.join("&&", fjFileName)).append("|"); // 32 附件名称
|
||||
context.append("togd"+requestid).append("|"); // 33 主键
|
||||
context.append("").append("|"); // 34 关联主键
|
||||
context.append("").append("|"); // 35 被关联主键
|
||||
context.append(zipName);// 36 压缩包名称
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
log.error("getContextError:{}", e.getMessage());
|
||||
}
|
||||
|
||||
return context.toString();
|
||||
}
|
||||
private String getAssociatedDepts(Map<String, String> requesData) {
|
||||
HashSet<String> records = new HashSet<>();
|
||||
records.addAll(Arrays.asList(Util.null2String(requesData.get("ngbm")).split(","))); // 会签部门
|
||||
records.addAll(Arrays.asList(Util.null2String(requesData.get("hqbm")).split(","))); // 拟稿部门
|
||||
records.addAll(Arrays.asList(Util.null2String(requesData.get("ffbm")).split(","))); // 部门阅办
|
||||
records.addAll(Arrays.asList(Util.null2String(requesData.get("hqbmzj")).split(","))); // 抄送
|
||||
// records.addAll(Arrays.asList(Util.null2String(requesData.get("bmffzj")).split(","))); // 本行发送
|
||||
|
||||
ArrayList<String> deptName = new ArrayList<>();
|
||||
DepartmentComInfo departmentComInfo = new DepartmentComInfo();
|
||||
for (String record : records) {
|
||||
try {
|
||||
if (StringUtil.isEmpty(record)){
|
||||
continue;
|
||||
}
|
||||
String departmentName = departmentComInfo.getDepartmentName(record);
|
||||
deptName.add(departmentName);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
return String.join("&&", deptName);
|
||||
}
|
||||
|
||||
private void updateRecord(int requestid, String s) {
|
||||
String sql = "update uf_pushArchivesLog set esbtxtml = ? where request = ?";
|
||||
RecordSet recordSet = new RecordSet();
|
||||
recordSet.executeUpdate(sql, s, requestid);
|
||||
}
|
||||
private void updateRecord(int requestid, String field , String fieldvalue) {
|
||||
String sql = "update uf_pushArchivesLog set "+field+" = ? where request = ?";
|
||||
RecordSet recordSet = new RecordSet();
|
||||
recordSet.executeUpdate(sql, fieldvalue, requestid);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//secondBranch
|
@ -0,0 +1,722 @@
|
||||
package com.engine.custom.archives.service.secondBranch;
|
||||
|
||||
|
||||
import cn.hutool.core.util.ZipUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
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.archives.util.KeyWord;
|
||||
import com.engine.custom.hg.util.HgUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.file.ImageFileManager;
|
||||
import weaver.general.StringUtil;
|
||||
import weaver.general.Util;
|
||||
import weaver.hrm.User;
|
||||
import weaver.hrm.company.DepartmentComInfo;
|
||||
import weaver.soa.workflow.request.RequestInfo;
|
||||
import weaver.soa.workflow.request.RequestService;
|
||||
import weaver.workflow.workflow.WorkflowBillComInfo;
|
||||
import weaver.workflow.workflow.WorkflowComInfo;
|
||||
|
||||
import java.io.*;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
|
||||
|
||||
public class SecondBranchReceivingPushArchivesService implements KeyWord {
|
||||
private static String filePath;
|
||||
private static String Url;
|
||||
private static String templatePath; // 模板文件路径
|
||||
private int endTime= 7;
|
||||
|
||||
public static Logger log = LoggerFactory.getLogger("Archives");
|
||||
|
||||
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"));
|
||||
endTime = Util.getIntValue(param.get("endTime"),7);
|
||||
}
|
||||
|
||||
|
||||
public void pushArchives(Map<String, String> param) {
|
||||
log.info("FirstBranchReceivingPushArchivesService ====Begin========{}", param);
|
||||
try {
|
||||
ZipUtil zipUtil = new ZipUtil();
|
||||
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(getFirstSecondOfDate(date));
|
||||
// 获取当前时间的最后一秒
|
||||
String lastSecond = yyyyMMddHHmmss.format(getLastSecondOfDate(date));
|
||||
|
||||
|
||||
RecordSet recordSet = new RecordSet();
|
||||
List<PushArchivesBean> result = ArchivesUtil.getResultList(recordSet, firstSecond, lastSecond, 7);
|
||||
log.error("推送分行收文的数量:{}", result.size());
|
||||
File file = ArchivesUtil.crFile(filePath + "/togd_" + new SimpleDateFormat("yyyyMMdd000000").format(date));
|
||||
log.error("textfile:{}", file.getAbsolutePath());
|
||||
for (PushArchivesBean pushArchivesBean : result) {
|
||||
if (ArchivesUtil.isAfterSevenAM(endTime)){
|
||||
log.info("超过执行时间:{}点暂停计划任务",endTime);
|
||||
break;
|
||||
}
|
||||
int requestid = pushArchivesBean.getRequest();
|
||||
try {
|
||||
log.error("requestid:{}", requestid);
|
||||
//1.生成文件及推送的txt
|
||||
String context = extracted(requestid);
|
||||
log.error("context:{}", context);
|
||||
//1.生成文件及推送的txt
|
||||
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(requestid, s);
|
||||
updateRecord(requestid,"esbtxtml",s);
|
||||
updateRecord(requestid,"zt","0");
|
||||
log.error("textZip:{}", s);
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
log.error("推送档案requestid:{}异常,异常原因为:{}",requestid,e.getMessage());
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.info("PushArchivesCorn====Exception========{}", e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void updateRecord(int requestids, String s) {
|
||||
String sql = "update uf_pushArchivesLog set esbtxtml = ? where request in ( " + requestids + " )";
|
||||
RecordSet recordSet = new RecordSet();
|
||||
recordSet.executeUpdate(sql, s);
|
||||
}
|
||||
|
||||
private String extracted(int requestid) throws FtpException, IOException {
|
||||
String newRequestid = "togd"+requestid;
|
||||
RequestService requestService = new RequestService();
|
||||
RequestInfo requestInfo = requestService.getRequest(Util.getIntValue(requestid), 100);
|
||||
String workflowid = requestInfo.getWorkflowid();
|
||||
Map<String, String> requesData = getRequestByid(requestid);
|
||||
log.info("requesData:{}", requesData);
|
||||
String fj = Util.null2String(requesData.get("fj"));
|
||||
String zwkbj = Util.null2String(requesData.get("zwkbj"));
|
||||
String lczw = Util.null2String(requesData.get("lczw"));
|
||||
String gwly = Util.null2String(requesData.get("gwly"));
|
||||
//增加签字意见中的附件到附件文件夹中
|
||||
Map<String, String> signFiles = ArchivesUtil.getSignFiles(requestid,false);
|
||||
List<String> docids = new ArrayList<>();
|
||||
// docids.addAll(Arrays.asList(fj.split(",")));
|
||||
// docids.addAll(Arrays.asList(zwkbj.split(",")));
|
||||
Map<String, String> fjMap = ArchivesUtil.getFileIdByDocId(fj);
|
||||
|
||||
// Map<String, String> zwkbjMap = ArchivesUtil.getFileIdByDocId(zwkbj);
|
||||
// Map<String, String> lczwMap = ArchivesUtil.getFileIdByDocId(lczw);
|
||||
Map<String, String> lczwMap = new HashMap<>();
|
||||
//判断公文来源
|
||||
if ("0".equals(gwly)){
|
||||
lczwMap = ArchivesUtil.getFileIdByDocId(lczw);
|
||||
}else {
|
||||
lczwMap = ArchivesUtil.getFileIdByDocId(zwkbj);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
List<String> zwFileName = new ArrayList<>();
|
||||
List<String> fjFileName = new ArrayList<>();
|
||||
final int[] i = {1};
|
||||
//附件
|
||||
fjMap.forEach((docid, imageid) -> {
|
||||
ImageFileManager imageFileManager = new ImageFileManager();
|
||||
imageFileManager.getImageFileInfoById(Util.getIntValue(imageid));
|
||||
InputStream inputStream = imageFileManager.getInputStream();
|
||||
//中文路径/中文文件名
|
||||
String imageFileName = filePath + File.separator + newRequestid + File.separator + FJDIR + File.separator + LCFJWORD + i[0] +"-" + imageFileManager.getImageFileName();
|
||||
fjFileName.add(LCFJWORD+ i[0] +"-" + imageFileManager.getImageFileName());
|
||||
log.info("生成附件路径:{}", imageFileName);
|
||||
imageFileName = ArchivesUtil.codeUtf8(imageFileName);
|
||||
try {
|
||||
File file = ArchivesUtil.saveInputStreamToFile(inputStream, imageFileName);
|
||||
String jsonStr = ArchivesUtil.callApi(Url, file);
|
||||
log.error("永中接口返回数据:{}", jsonStr);
|
||||
JSONObject result = JSONObject.parseObject(jsonStr);
|
||||
String errorcode = result.getString("errorcode");
|
||||
if ("0".equals(errorcode)) {
|
||||
JSONObject data = result.getJSONObject("data");
|
||||
String destFileName = data.getString("destFileName");
|
||||
String viewUrl = data.getString("viewUrl");
|
||||
ArchivesUtil.downloadFile(viewUrl, filePath + File.separator + newRequestid + File.separator + FJDIR + File.separator + LCFJWORD+ i[0] + "-" + imageFileManager.getImageFileName() + ".pdf");
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}finally {
|
||||
if(inputStream!=null) {
|
||||
try {
|
||||
inputStream.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
i[0]++;
|
||||
});
|
||||
i[0] = 1;
|
||||
//签字意见附件
|
||||
signFiles.forEach((docid, imageid) -> {
|
||||
ImageFileManager imageFileManager = new ImageFileManager();
|
||||
imageFileManager.getImageFileInfoById(Util.getIntValue(imageid));
|
||||
InputStream inputStream = imageFileManager.getInputStream();
|
||||
//中文路径/中文文件名
|
||||
String imageFileName = filePath + File.separator + newRequestid + File.separator + FJDIR + File.separator + QZYJFJWORD + i[0] + "-" +imageFileManager.getImageFileName();
|
||||
fjFileName.add(QZYJFJWORD + i[0] + "-" +imageFileManager.getImageFileName());
|
||||
log.info("生成签字意见附件路径:{}", imageFileName);
|
||||
imageFileName = ArchivesUtil.codeUtf8(imageFileName);
|
||||
try {
|
||||
File file = ArchivesUtil.saveInputStreamToFile(inputStream, imageFileName);
|
||||
String jsonStr = ArchivesUtil.callApi(Url, file);
|
||||
log.error("永中接口返回数据:{}", jsonStr);
|
||||
JSONObject result = JSONObject.parseObject(jsonStr);
|
||||
String errorcode = result.getString("errorcode");
|
||||
if ("0".equals(errorcode)) {
|
||||
JSONObject data = result.getJSONObject("data");
|
||||
String destFileName = data.getString("destFileName");
|
||||
String viewUrl = data.getString("viewUrl");
|
||||
ArchivesUtil.downloadFile(viewUrl, filePath + File.separator + newRequestid + File.separator + FJDIR + File.separator + QZYJFJWORD + i[0] + "-" + imageFileManager.getImageFileName() + ".pdf");
|
||||
}
|
||||
i[0]++;
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}finally {
|
||||
if(inputStream!=null) {
|
||||
try {
|
||||
inputStream.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
i[0] = 1;
|
||||
Map<String, String> coReqFile = getCoReqFile(requestid, workflowid);
|
||||
//协办要求
|
||||
coReqFile.forEach((docid, imageid) -> {
|
||||
ImageFileManager imageFileManager = new ImageFileManager();
|
||||
imageFileManager.getImageFileInfoById(Util.getIntValue(imageid));
|
||||
InputStream inputStream = imageFileManager.getInputStream();
|
||||
zwFileName.add(XBBMFJWORD+ i[0] +"-"+ imageFileManager.getImageFileName());
|
||||
//中文路径/中文文件名
|
||||
String imageFileName = filePath + File.separator + newRequestid + File.separator + FJDIR + File.separator + XBBMFJWORD + i[0] +"-"+ imageFileManager.getImageFileName();
|
||||
log.info("生成协办部门路径:{}", imageFileName);
|
||||
imageFileName = ArchivesUtil.codeUtf8(imageFileName);
|
||||
try {
|
||||
File file = ArchivesUtil.saveInputStreamToFile(inputStream, imageFileName);
|
||||
String jsonStr = ArchivesUtil.callApi(Url, file);
|
||||
log.error("永中接口返回:{}", jsonStr);
|
||||
JSONObject result = JSONObject.parseObject(jsonStr);
|
||||
String errorcode = result.getString("errorcode");
|
||||
if ("0".equals(errorcode)) {
|
||||
JSONObject data = result.getJSONObject("data");
|
||||
String destFileName = data.getString("destFileName");
|
||||
String viewUrl = data.getString("viewUrl");
|
||||
ArchivesUtil.downloadFile(viewUrl, filePath + File.separator + newRequestid + File.separator + FJDIR + File.separator+XBBMFJWORD+ i[0] +"-" + imageFileManager.getImageFileName() + ".pdf");
|
||||
}
|
||||
i[0]++;
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}finally {
|
||||
if(inputStream!=null) {
|
||||
try {
|
||||
inputStream.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// i[0] = 1;
|
||||
// //正文
|
||||
// zwkbjMap.forEach((docid, imageid) -> {
|
||||
// ImageFileManager imageFileManager = new ImageFileManager();
|
||||
// imageFileManager.getImageFileInfoById(Util.getIntValue(imageid));
|
||||
// InputStream inputStream = imageFileManager.getInputStream();
|
||||
// zwFileName.add(imageFileManager.getImageFileName());
|
||||
// //中文路径/中文文件名
|
||||
// String imageFileName = filePath + File.separator + newRequestid + File.separator + zwdir + File.separator + imageFileManager.getImageFileName();
|
||||
// log.info("生成正文路径:{}", imageFileName);
|
||||
// imageFileName = ArchivesUtil.codeUtf8(imageFileName);
|
||||
// try {
|
||||
// File file = ArchivesUtil.saveInputStreamToFile(inputStream, imageFileName);
|
||||
// String jsonStr = ArchivesUtil.callApi(Url, file);
|
||||
// log.error("永中接口返回:{}", jsonStr);
|
||||
// JSONObject result = JSONObject.parseObject(jsonStr);
|
||||
// String errorcode = result.getString("errorcode");
|
||||
// if ("0".equals(errorcode)) {
|
||||
// JSONObject data = result.getJSONObject("data");
|
||||
// String destFileName = data.getString("destFileName");
|
||||
// String viewUrl = data.getString("viewUrl");
|
||||
// ArchivesUtil.downloadFile(viewUrl, filePath + File.separator + newRequestid + File.separator + zwdir + File.separator + imageFileManager.getImageFileName() + ".pdf");
|
||||
// }
|
||||
//
|
||||
// } catch (IOException e) {
|
||||
// e.printStackTrace();
|
||||
// }finally {
|
||||
// if(inputStream!=null) {
|
||||
// try {
|
||||
// inputStream.close();
|
||||
// } catch (IOException e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
|
||||
i[0] = 1;
|
||||
//正文
|
||||
lczwMap.forEach((docid, imageid) -> {
|
||||
ImageFileManager imageFileManager = new ImageFileManager();
|
||||
imageFileManager.getImageFileInfoById(Util.getIntValue(imageid));
|
||||
InputStream inputStream = imageFileManager.getInputStream();
|
||||
zwFileName.add(imageFileManager.getImageFileName());
|
||||
//中文路径/中文文件名
|
||||
String imageFileName = filePath + File.separator + newRequestid + File.separator + ZWDIR + File.separator + (imageFileManager.getImageFileName().replaceAll("/","-"));
|
||||
log.info("生成正文路径:{}", imageFileName);
|
||||
imageFileName = ArchivesUtil.codeUtf8(imageFileName);
|
||||
try {
|
||||
File file = ArchivesUtil.saveInputStreamToFile(inputStream, imageFileName);
|
||||
String jsonStr = ArchivesUtil.callApi(Url, file);
|
||||
log.error("永中接口返回:{}", jsonStr);
|
||||
JSONObject result = JSONObject.parseObject(jsonStr);
|
||||
String errorcode = result.getString("errorcode");
|
||||
if ("0".equals(errorcode)) {
|
||||
JSONObject data = result.getJSONObject("data");
|
||||
String destFileName = data.getString("destFileName");
|
||||
String viewUrl = data.getString("viewUrl");
|
||||
ArchivesUtil.downloadFile(viewUrl, filePath + File.separator + newRequestid + File.separator + ZWDIR + File.separator + (imageFileManager.getImageFileName().replaceAll("/","-")) + ".pdf");
|
||||
}
|
||||
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}finally {
|
||||
if(inputStream!=null) {
|
||||
try {
|
||||
inputStream.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
//开始承办单 先获取主流程的承办单
|
||||
List<String> requestDocid = ArchivesUtil.generaRequestFormPdf(requestid,0);
|
||||
// 1.去掉生成子流程承办单
|
||||
// List<String> subRequestDocid = generaSubRequestFormPdf(requestid);
|
||||
Map<String, String> reqDocMap = ArchivesUtil.getFileIdByDocId(String.join(",", requestDocid));
|
||||
// 2.去掉生成子流程承办单
|
||||
// Map<String, String> subReqDocMap = getFileIdByDocId(String.join(",", subRequestDocid));
|
||||
log.error("reqDocMap:{}", JSONObject.toJSONString(reqDocMap));
|
||||
//log.error("subReqDocMap:{}", JSONObject.toJSONString(subReqDocMap));
|
||||
docids.addAll(requestDocid);
|
||||
// 3.去掉生成子流程承办单
|
||||
// docids.addAll(subRequestDocid);
|
||||
//承办单
|
||||
reqDocMap.forEach((docid, imageid) -> {
|
||||
ImageFileManager imageFileManager = new ImageFileManager();
|
||||
imageFileManager.getImageFileInfoById(Util.getIntValue(imageid));
|
||||
InputStream inputStream = imageFileManager.getInputStream();
|
||||
//中文路径/中文文件名
|
||||
// String imageFileName = filePath + File.separator + requestid + File.separator + cbddir + File.separator + fjFile + i[0] + "_" + imageFileManager.getImageFileName();
|
||||
String imageFileName = filePath + File.separator + newRequestid + File.separator + CBDDIR + File.separator + WJCLDWORD+".pdf";
|
||||
|
||||
log.info("主流程承办单路径:{}", imageFileName);
|
||||
imageFileName = ArchivesUtil.codeUtf8(imageFileName);
|
||||
try {
|
||||
File file = ArchivesUtil.saveInputStreamToFile(inputStream, imageFileName);
|
||||
String jsonStr = ArchivesUtil.callApi(Url, file);
|
||||
log.error("永中接口返回:{}", jsonStr);
|
||||
JSONObject result = JSONObject.parseObject(jsonStr);
|
||||
String errorcode = result.getString("errorcode");
|
||||
if ("0".equals(errorcode)) {
|
||||
JSONObject data = result.getJSONObject("data");
|
||||
String destFileName = data.getString("destFileName");
|
||||
String viewUrl = data.getString("viewUrl");
|
||||
ArchivesUtil.downloadFile(viewUrl, filePath + File.separator + newRequestid + File.separator + CBDDIR + File.separator + WJCLDWORD + ".pdf" + ".pdf");
|
||||
}
|
||||
i[0]++;
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}finally {
|
||||
if(inputStream!=null) {
|
||||
try {
|
||||
inputStream.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
//正文
|
||||
|
||||
i[0] = 1;
|
||||
// 4.去掉生成子流程承办单
|
||||
// subReqDocMap.forEach((docid, imageid) -> {
|
||||
// ImageFileManager imageFileManager = new ImageFileManager();
|
||||
// imageFileManager.getImageFileInfoById(Util.getIntValue(imageid));
|
||||
// InputStream inputStream = imageFileManager.getInputStream();
|
||||
// //中文路径/中文文件名
|
||||
// String imageFileName = filePath + File.separator + requestid + File.separator + zlcdir + File.separator + fjFile + i[0] + "_" + (imageFileManager.getImageFileName().contains("-")?imageFileManager.getImageFileName().split("\\-")[1]:imageFileManager.getImageFileName());
|
||||
// imageFileName = codeUtf8(imageFileName);
|
||||
// log.info("子流程承办单路径:{}", imageFileName);
|
||||
// try {
|
||||
// File file = saveInputStreamToFile(inputStream, imageFileName);
|
||||
// String jsonStr = callApi(Url, file);
|
||||
// log.error("永中接口返回:{}", jsonStr);
|
||||
// JSONObject result = JSONObject.parseObject(jsonStr);
|
||||
// String errorcode = result.getString("errorcode");
|
||||
// if ("0".equals(errorcode)) {
|
||||
// JSONObject data = result.getJSONObject("data");
|
||||
// String destFileName = data.getString("destFileName");
|
||||
// String viewUrl = data.getString("viewUrl");
|
||||
// downloadFile(viewUrl, filePath + File.separator + requestid + File.separator + zlcdir + File.separator + fjFile + i[0] + "_" + (imageFileManager.getImageFileName().contains("-")?imageFileManager.getImageFileName().split("\\-")[1]:imageFileManager.getImageFileName() )+ ".pdf");
|
||||
// }
|
||||
// i[0]++;
|
||||
// } catch (IOException e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// });
|
||||
log.error(JSONObject.toJSONString(requestDocid));
|
||||
// log.error(JSONObject.toJSONString(subRequestDocid));
|
||||
for (String docid : docids) {
|
||||
log.error("删除了" + docid);
|
||||
ArchivesUtil.deleteDocByid(docid);
|
||||
}
|
||||
//--------------------------------------------------------------------
|
||||
|
||||
|
||||
String logFile = ArchivesUtil.getSignLog(requestid, CBDDIR+File.separator+LZXXDIR, requestInfo.getCreatorid() + requestInfo.getDescription(),templatePath,filePath,false,workflowid);
|
||||
String s = ArchivesUtil.callApi(Url, new File(logFile));
|
||||
log.error(s);
|
||||
JSONObject result = JSONObject.parseObject(s);
|
||||
String errorcode = result.getString("errorcode");
|
||||
if ("0".equals(errorcode)) {
|
||||
JSONObject data = result.getJSONObject("data");
|
||||
String destFileName = data.getString("destFileName");
|
||||
String viewUrl = data.getString("viewUrl");
|
||||
ArchivesUtil.downloadFile(viewUrl, logFile + ".pdf");
|
||||
}
|
||||
String zipName = filePath + File.separator + newRequestid + ".zip";
|
||||
ZipUtil.zip(filePath + File.separator + newRequestid, zipName);
|
||||
log.error("zipName:{}", zipName);
|
||||
String ftpFilePath = HgUtils.putFile(zipName, newRequestid + ".zip");
|
||||
ArchivesUtil.deleteDirectory(filePath + File.separator + newRequestid);
|
||||
updateRecord(requestid,"esbwjml",ftpFilePath);
|
||||
log.error("ftpFilePath:{}", ftpFilePath);
|
||||
// String ftpFilePathNew = HgUtils.putFile(zipName, "test" + File.separator + newRequestid + ".zip");
|
||||
// log.error("ftpFilePathNew:{}", ftpFilePathNew);
|
||||
String context = getContext(requestid, requesData, newRequestid + ".zip", zwFileName, fjFileName);
|
||||
// insertRecord(requestid, context, ftpFilePath);
|
||||
log.error("context:{}", context);
|
||||
updateRecord(requestid,"content",context);
|
||||
return context;
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void insertRecord(int requestid, String context, String ftpFilePath) {
|
||||
String sql = "insert into uf_pushArchivesLog (request ,content,esbwjml) VALUES (?,?,?)";
|
||||
RecordSet recordSet = new RecordSet();
|
||||
recordSet.executeUpdate(sql, requestid, context, ftpFilePath);
|
||||
}
|
||||
|
||||
|
||||
// 获取指定日期的第一秒
|
||||
public static Date getFirstSecondOfDate(Date date) {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(date);
|
||||
calendar.set(Calendar.HOUR_OF_DAY, 0);
|
||||
calendar.set(Calendar.MINUTE, 0);
|
||||
calendar.set(Calendar.SECOND, 0);
|
||||
calendar.set(Calendar.MILLISECOND, 0);
|
||||
return calendar.getTime();
|
||||
}
|
||||
|
||||
// 获取指定日期的最后一秒
|
||||
public static Date getLastSecondOfDate(Date date) {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(date);
|
||||
calendar.set(Calendar.HOUR_OF_DAY, 23);
|
||||
calendar.set(Calendar.MINUTE, 59);
|
||||
calendar.set(Calendar.SECOND, 59);
|
||||
calendar.set(Calendar.MILLISECOND, 999);
|
||||
return calendar.getTime();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/***
|
||||
* 封装数据
|
||||
* @param requestid
|
||||
* @return
|
||||
*/
|
||||
public Map<String, String> getRequestByid(int requestid) {
|
||||
HashMap<String, String> record = new HashMap<>();
|
||||
String sql = "select * from formtable_main_137 where requestid = ?";
|
||||
String reqsql = "select REQUESTNAME from WORKFLOW_REQUESTBASE where REQUESTID = ?";
|
||||
RecordSet rs = new RecordSet();
|
||||
rs.executeQuery(sql, requestid);
|
||||
if (rs.next()) {
|
||||
String fj = Util.null2String(rs.getString("fj"));
|
||||
String zwkbj = Util.null2String(rs.getString("zwkbj")); // 正文可编辑字段
|
||||
record.put("fj", fj);
|
||||
record.put("zwkbj", zwkbj);
|
||||
record.put("zwyyglgwmk", Util.null2String(rs.getString("zwyyglgwmk")));
|
||||
record.put("lwh", Util.null2String(rs.getString("lwh")));
|
||||
record.put("mj", Util.null2String(rs.getString("mj")));
|
||||
record.put("lwrq", Util.null2String(rs.getString("lwrq")));
|
||||
record.put("swrq", Util.null2String(rs.getString("swrq")));
|
||||
record.put("blqx", Util.null2String(rs.getString("blqx")));
|
||||
record.put("sfdb", Util.null2String(rs.getString("sfdb")));
|
||||
record.put("wjlx", Util.null2String(rs.getString("wjlx")));
|
||||
record.put("fssj", Util.null2String(rs.getString("fssj")));
|
||||
record.put("gdh", Util.null2String(rs.getString("gdh")));
|
||||
record.put("swh", Util.null2String(rs.getString("swh")));
|
||||
record.put("ngbm", Util.null2String(rs.getString("ngbm")));
|
||||
record.put("ngr", Util.null2String(rs.getString("ngr")));
|
||||
record.put("ngrq", Util.null2String(rs.getString("ngrq")));
|
||||
record.put("swlx", Util.null2String(rs.getString("swlx")));
|
||||
record.put("jghwt", Util.null2String(rs.getString("jghwt")));
|
||||
record.put("lwdwmc", Util.null2String(rs.getString("lwdwmc")));
|
||||
record.put("bgqx", Util.null2String(rs.getString("bgqx")));
|
||||
record.put("ys", Util.null2String(rs.getString("ys")));
|
||||
record.put("wz", Util.null2String(rs.getString("wz")));
|
||||
record.put("lb", Util.null2String(rs.getString("lb")));
|
||||
record.put("bz", Util.null2String(rs.getString("bz")));
|
||||
record.put("yffbm", Util.null2String(rs.getString("yffbm")));
|
||||
record.put("ffbmb", Util.null2String(rs.getString("ffbmb")));
|
||||
record.put("yffbm", Util.null2String(rs.getString("yffbm")));
|
||||
record.put("lczw", Util.null2String(rs.getString("lczw")));
|
||||
record.put("gwly", Util.null2String(rs.getString("gwly")));
|
||||
record.put("lwdwsx", Util.null2String(rs.getString("lwdwsx")));
|
||||
record.put("fb", Util.null2String(rs.getString("fb")));
|
||||
record.put("xjdw", Util.null2String(rs.getString("xjdw")));
|
||||
record.put("ejzx", Util.null2String(rs.getString("ejzx")));
|
||||
record.put("yjbm", Util.null2String(rs.getString("yjbm")));
|
||||
record.put("yjfxxldbm", Util.null2String(rs.getString("yjfxxldbm")));
|
||||
}
|
||||
rs.executeQuery(reqsql, requestid);
|
||||
if (rs.next()) {
|
||||
record.put("REQUESTNAME", Util.null2String(rs.getString("REQUESTNAME")));
|
||||
}
|
||||
return record;
|
||||
}
|
||||
|
||||
|
||||
private String getContext(int requestid, Map<String, String> requesData, String zipName, List<String> zwFileName, List<String> fjFileName) {
|
||||
StringBuilder context = new StringBuilder();
|
||||
try {
|
||||
|
||||
String swrq = Util.null2String(requesData.get("swrq"));
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||
LocalDate date = LocalDate.parse(swrq, formatter);
|
||||
int year = date.getYear();
|
||||
context.append(year).append("|");
|
||||
String jghwt = Util.null2String(requesData.get("jghwt"));
|
||||
context.append(jghwt).append("|");
|
||||
// String swh = Util.null2String(requesData.get("swh"));
|
||||
String swh = Util.null2String(requesData.get("lwh"));
|
||||
context.append(swh).append("|");
|
||||
String requestname = Util.null2String(requesData.get("REQUESTNAME"));
|
||||
context.append(requestname).append("|");
|
||||
String lwdwmc = Util.null2String(requesData.get("lwdwsx")); //5 责任者 -> 来文单位
|
||||
context.append(lwdwmc).append("|");
|
||||
String bgqx = Util.null2String(requesData.get("bgqx")); //6 保管期限 -> 保管期限
|
||||
context.append(bgqx).append("|");
|
||||
String lwrq = Util.null2String(requesData.get("lwrq")); //7 日期 -> 原发文日期
|
||||
context.append(lwrq).append("|");
|
||||
String ys = Util.null2String(requesData.get("ys")); //8 页数 -> 页数
|
||||
context.append(ys).append("|");
|
||||
String wz = Util.null2String(requesData.get("wz")); //9 文种 -> 文种
|
||||
context.append(wz).append("|");
|
||||
String ngbm = Util.null2String(requesData.get("ngbm"));
|
||||
String fb = Util.null2String(requesData.get("fb"));
|
||||
String yjbm = Util.null2String(requesData.get("yjbm"));
|
||||
String[] deptData = ArchivesUtil.getDeptNameAndCode(ngbm);
|
||||
String[] yjbmdeptData = ArchivesUtil.getDeptNameAndCode(yjbm);
|
||||
String[] subData = getSubCom(fb);
|
||||
context.append(yjbmdeptData[0]).append("|"); //10 行编号 -> 拟稿部门
|
||||
|
||||
context.append(yjbmdeptData[1]).append("|"); //11 行名称
|
||||
context.append("").append("|"); // 12 保管期限编号
|
||||
context.append("").append("|"); // 13 保管期限及编号
|
||||
context.append("").append("|"); // 14 是否开放
|
||||
context.append("").append("|"); // 15 互见号
|
||||
String lb = Util.null2String(requesData.get("lb"));
|
||||
context.append(lb).append("|"); //16 类别 -> 类别
|
||||
//TODO
|
||||
String xgbm = Util.null2String(getAssociatedDepts(requesData));
|
||||
context.append(xgbm).append("|"); //17 相关部门 -> 流经部门
|
||||
// String lwh = Util.null2String(requesData.get("lwh"));// 18 收文号 -> 来文文号
|
||||
String lwh = Util.null2String(requesData.get("swh"));// 18 收文号 -> 来文文号
|
||||
context.append(lwh).append("|");
|
||||
String fs = "";
|
||||
context.append(fs).append("|"); // 19 份数 -> 份数
|
||||
String bz = Util.null2String(requesData.get("bz"));
|
||||
context.append(bz).append("|"); // 20 备注 -> 备注
|
||||
String yywh = Util.null2String(requesData.get("yywh"));
|
||||
context.append(yywh).append("|"); // 21 引用文号 -> 引用文号
|
||||
String wjlx = Util.null2String(requesData.get("wjlx"));
|
||||
context.append(wjlx).append("|"); // 22 文件类型 -> 空
|
||||
String fwlx = Util.null2String(requesData.get("fwlx"));
|
||||
context.append(fwlx).append("|"); // 23 文件类型 -> 空
|
||||
String f = Util.null2String(requesData.get("f"));
|
||||
context.append(f).append("|"); // 24 发 -> 空
|
||||
String ngr = Util.null2String(requesData.get("ngr"));
|
||||
context.append(new User(Util.getIntValue(ngr)).getLoginid()).append("|"); // 25 拟稿人 -> 拟稿人
|
||||
context.append(deptData[1]).append("|"); // 26 拟稿部门 -> 拟稿部门名称
|
||||
context.append("收文").append("|"); // 27 公文类型 -> "收文"
|
||||
//TODO
|
||||
context.append(ArchivesUtil.getAssociatedPersons(requestid,false)).append("|"); // 28 相关人员 -> 参与人员
|
||||
context.append("智慧OA").append("|"); // 29 数据来源 -> 数据来源
|
||||
context.append(year).append("|"); // 30 形成年度 -> 年份
|
||||
context.append(String.join("&&", zwFileName)).append("|"); // 31 正文名称
|
||||
context.append(String.join("&&", fjFileName)).append("|"); // 32 附件名称
|
||||
context.append("togd"+requestid).append("|"); // 33 主键
|
||||
context.append("").append("|"); // 34 关联主键
|
||||
context.append("").append("|"); // 35 被关联主键
|
||||
context.append(zipName);// 36 压缩包名称
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
log.error("getContextError:{}", e.getMessage());
|
||||
}
|
||||
|
||||
return context.toString();
|
||||
}
|
||||
|
||||
private String getAssociatedDepts(Map<String, String> requesData) {
|
||||
HashSet<String> records = new HashSet<>();
|
||||
records.addAll(Arrays.asList(Util.null2String(requesData.get("ngbm")).split(",")));
|
||||
records.addAll(Arrays.asList(Util.null2String(requesData.get("ffbm")).split(",")));
|
||||
records.addAll(Arrays.asList(Util.null2String(requesData.get("yffbm")).split(",")));
|
||||
records.addAll(Arrays.asList(Util.null2String(requesData.get("ffbmb")).split(",")));
|
||||
records.addAll(Arrays.asList(Util.null2String(requesData.get("xjdw")).split(",")));
|
||||
records.addAll(Arrays.asList(Util.null2String(requesData.get("ejzx")).split(",")));
|
||||
records.addAll(Arrays.asList(Util.null2String(requesData.get("yjbm")).split(",")));
|
||||
records.addAll(Arrays.asList(Util.null2String(requesData.get("yjfxxldbm")).split(",")));
|
||||
ArrayList<String> deptName = new ArrayList<>();
|
||||
DepartmentComInfo departmentComInfo = new DepartmentComInfo();
|
||||
for (String record : records) {
|
||||
try {
|
||||
if (StringUtil.isEmpty(record)){
|
||||
continue;
|
||||
}
|
||||
String departmentName = departmentComInfo.getDepartmentName(record);
|
||||
deptName.add(departmentName);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
return String.join("&&", deptName);
|
||||
}
|
||||
|
||||
private Map<String, String> getCoReqFile(int requestid , String workflowid){
|
||||
try {
|
||||
RecordSet rs = new RecordSet();
|
||||
rs.executeQuery("select * from uf_ArchivesSet where mainwfid = ?",workflowid);
|
||||
boolean isCo = false;
|
||||
String cowfid = "";
|
||||
String cofield = "";
|
||||
String cofieldid = "";
|
||||
if (rs.next()){
|
||||
cowfid = Util.null2String(rs.getString("cowfid"));
|
||||
if (!StringUtils.isBlank(cowfid)){
|
||||
isCo = true;
|
||||
cofield = Util.null2String(rs.getString("cofield"));
|
||||
cofieldid = Util.null2String(rs.getString("cofieldid"));
|
||||
}
|
||||
}
|
||||
log.info("isCo:{};cowfid:{};cofield:{};cofieldid:{}",isCo,cowfid,cofield,cofieldid);
|
||||
|
||||
|
||||
if(isCo){
|
||||
ArrayList<String> CoSubRequest = new ArrayList<>();
|
||||
Map<String, String> subRequest = ArchivesUtil.getSubRequest(Util.null2String(requestid) , 6);
|
||||
log.info("subRequest:{}",subRequest);
|
||||
for (Map.Entry<String, String> subRequestEntry : subRequest.entrySet()) {
|
||||
String subWFid = subRequestEntry.getValue();
|
||||
if (cowfid.equals(subWFid)){
|
||||
CoSubRequest.add(subRequestEntry.getKey());
|
||||
}
|
||||
}
|
||||
log.info("CoSubRequest.size:{}",CoSubRequest.size());
|
||||
if (CoSubRequest.size() == 0){
|
||||
return new HashMap<>();
|
||||
}
|
||||
WorkflowComInfo wf = new WorkflowComInfo();
|
||||
WorkflowBillComInfo wcInfo = new WorkflowBillComInfo();
|
||||
String formId = wf.getFormId(cowfid);
|
||||
String tablename = wcInfo.getTablename(formId);
|
||||
String cosql = "select "+cofield+" from " + tablename + " where " +
|
||||
" requestid in ( " + String.join(",",CoSubRequest) + " ) " +
|
||||
" order by requestid asc ";
|
||||
log.info("cosql:{}",cosql);
|
||||
|
||||
rs.executeQuery(cosql);
|
||||
log.info("rs.getExceptionMsg():{}",rs.getExceptionMsg());
|
||||
String fieldValue = "";
|
||||
String[] cofieldsplit = cofield.split(",");
|
||||
String coFile = cofieldsplit[2]; //协办部门
|
||||
ArrayList<String> docids = new ArrayList<>();
|
||||
while (rs.next()){
|
||||
String coFileValue = rs.getString(coFile);
|
||||
docids.addAll(Arrays.asList(coFileValue.split(",")));
|
||||
}
|
||||
log.info("fieldValue:{}",fieldValue);
|
||||
return ArchivesUtil.getFileIdByDocId(String.join(",",docids));
|
||||
}
|
||||
return new HashMap<>();
|
||||
}catch (Exception e){
|
||||
log.error("getCoReqFile:[}",e.getMessage());
|
||||
return new HashMap<>();
|
||||
}
|
||||
}
|
||||
|
||||
private void updateRecord(int requestid, String field , String fieldvalue) {
|
||||
String sql = "update uf_pushArchivesLog set "+field+" = ? where request = ?";
|
||||
RecordSet recordSet = new RecordSet();
|
||||
recordSet.executeUpdate(sql, fieldvalue, requestid);
|
||||
}
|
||||
|
||||
|
||||
public static String[] getSubCom(String ngbm) {
|
||||
RecordSet rs = new RecordSet();
|
||||
rs.executeQuery("select sub.id subid , SUBCOMPANYNAME from HRMSUBCOMPANY sub where sub.id = ? ",ngbm);
|
||||
rs.next();
|
||||
String subcompanyname = rs.getString("SUBCOMPANYNAME");
|
||||
String subid = rs.getString("subid");
|
||||
if ("总行".equals(subcompanyname)){
|
||||
subcompanyname = "总行机关";
|
||||
}
|
||||
rs.executeQuery("select DAPYBH from HRMSUBCOMPANYDEFINED where SUBCOMID = ?",subid);
|
||||
rs.next();
|
||||
String DAPYBH = rs.getString("DAPYBH");
|
||||
return new String[]{DAPYBH,subcompanyname};
|
||||
}
|
||||
}
|
@ -0,0 +1,575 @@
|
||||
package com.engine.custom.archives.service.secondBranch;
|
||||
|
||||
import cn.hutool.core.util.ZipUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
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.archives.util.KeyWord;
|
||||
import com.engine.custom.hg.util.HgUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.file.ImageFileManager;
|
||||
import weaver.general.StringUtil;
|
||||
import weaver.general.Util;
|
||||
import weaver.hrm.User;
|
||||
import weaver.hrm.company.DepartmentComInfo;
|
||||
import weaver.soa.workflow.request.RequestInfo;
|
||||
import weaver.soa.workflow.request.RequestService;
|
||||
|
||||
import java.io.*;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
|
||||
/***
|
||||
* @Des: 一级分行发文推送档案系统服务
|
||||
*/
|
||||
public class SecondBranchSendingPushArchivesService implements KeyWord {
|
||||
public static Logger log = LoggerFactory.getLogger("Archives");
|
||||
private static String filePath;
|
||||
private static String Url;
|
||||
private static String templatePath; // 模板文件路径
|
||||
private int endTime= 7;
|
||||
|
||||
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"));
|
||||
endTime = Util.getIntValue(param.get("endTime"),7);
|
||||
}
|
||||
|
||||
public void pushArchives(Map<String, String> param) {
|
||||
log.info("PushArchivesCorn====Begin========{}", 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, 6);
|
||||
log.error("推送分行发文的数量:{}", result.size());
|
||||
File file = ArchivesUtil.crFile(filePath + "/togd_" + new SimpleDateFormat("yyyyMMdd000000").format(date));
|
||||
log.error("textfile:{}", file.getAbsolutePath());
|
||||
for (PushArchivesBean pushArchivesBean : result) {
|
||||
if (ArchivesUtil.isAfterSevenAM(endTime)){
|
||||
log.info("超过执行时间:{}点暂停计划任务",endTime);
|
||||
break;
|
||||
}
|
||||
// int id = pushArchivesBean.getId();
|
||||
int request = pushArchivesBean.getRequest();
|
||||
log.error("推送的requestId:{}", request);
|
||||
try {
|
||||
String context = generateFile(request);
|
||||
if ("-1".equals(context)){
|
||||
continue;
|
||||
}
|
||||
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,"esbtxtml",s);
|
||||
updateRecord(request,"zt","0");
|
||||
log.error("textZip:{}", s);
|
||||
} catch (FtpException e) {
|
||||
e.printStackTrace();
|
||||
log.error("推送档案requestid:{}异常,异常原因为:{}",request,e.getMessage());
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
log.error("推送档案requestid:{}异常,异常原因为:{}",request,e.getMessage());
|
||||
} catch (Exception e){
|
||||
e.printStackTrace();
|
||||
log.error("推送档案requestid:{}异常,异常原因为:{}",request,e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
private String generateFile(int requestid) throws FtpException, IOException {
|
||||
Map<String, String> requesData = getRequestByid(requestid);
|
||||
String newRequestid = "togd"+requestid;
|
||||
log.info("requesData:{}", requesData);
|
||||
String bh = requesData.get("bh");
|
||||
if (StringUtil.isEmpty(bh)){
|
||||
return "-1";
|
||||
}
|
||||
String fj = Util.null2String(requesData.get("fj"));
|
||||
String dwd = Util.null2String(requesData.get("dwd"));
|
||||
String zw = Util.null2String(requesData.get("zw"));
|
||||
String qgqhj = Util.null2String(requesData.get("qgqhj"));
|
||||
String thhlh = Util.null2String(requesData.get("thhlh"));
|
||||
|
||||
|
||||
//增加签字意见中的附件到附件文件夹中
|
||||
Map<String, String> signFiles = ArchivesUtil.getSignFiles(requestid,false);
|
||||
List<String> docids = new ArrayList<>();
|
||||
// docids.addAll(Arrays.asList(fj.split(",")));
|
||||
// docids.addAll(Arrays.asList(zwkbj.split(",")));
|
||||
Map<String, String> fjMap = ArchivesUtil.getFileIdByDocId(fj);
|
||||
Map<String, String> dwdMap = ArchivesUtil.getFileIdByDocId(dwd);
|
||||
Map<String, String> zwMap = ArchivesUtil.getFileIdByDocId(zw);
|
||||
Map<String, String> qgqhjMap = ArchivesUtil.getFileIdByDocId(qgqhj);
|
||||
Map<String, String> thhlhMap = ArchivesUtil.getFileIdByDocId(thhlh);
|
||||
List<String> zwFileName = new ArrayList<>();
|
||||
List<String> fjFileName = new ArrayList<>();
|
||||
final int[] i = {1};
|
||||
//附件
|
||||
fjMap.forEach((docid, imageid) -> {
|
||||
ImageFileManager imageFileManager = new ImageFileManager();
|
||||
imageFileManager.getImageFileInfoById(Util.getIntValue(imageid));
|
||||
InputStream inputStream = imageFileManager.getInputStream();
|
||||
//中文路径/中文文件名
|
||||
String imageFileName = filePath + File.separator + newRequestid + File.separator + FJDIR + File.separator + LCFJWORD + "-" +imageFileManager.getImageFileName();
|
||||
fjFileName.add(LCFJWORD + "-" +imageFileManager.getImageFileName());
|
||||
log.info("生成附件路径:{}", imageFileName);
|
||||
imageFileName = ArchivesUtil.codeUtf8(imageFileName);
|
||||
try {
|
||||
File file = ArchivesUtil.saveInputStreamToFile(inputStream, imageFileName);
|
||||
String jsonStr = ArchivesUtil.callApi(Url, file);
|
||||
log.error("永中接口返回数据:{}", jsonStr);
|
||||
JSONObject result = JSONObject.parseObject(jsonStr);
|
||||
String errorcode = result.getString("errorcode");
|
||||
if ("0".equals(errorcode)) {
|
||||
JSONObject data = result.getJSONObject("data");
|
||||
String destFileName = data.getString("destFileName");
|
||||
String viewUrl = data.getString("viewUrl");
|
||||
ArchivesUtil.downloadFile(viewUrl, filePath + File.separator + newRequestid + File.separator + FJDIR + File.separator + LCFJWORD + "-" + imageFileManager.getImageFileName() + ".pdf");
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}finally {
|
||||
if(inputStream!=null) {
|
||||
try {
|
||||
inputStream.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
//签字意见附件
|
||||
signFiles.forEach((docid, imageid) -> {
|
||||
ImageFileManager imageFileManager = new ImageFileManager();
|
||||
imageFileManager.getImageFileInfoById(Util.getIntValue(imageid));
|
||||
InputStream inputStream = imageFileManager.getInputStream();
|
||||
//中文路径/中文文件名
|
||||
String imageFileName = filePath + File.separator + newRequestid + File.separator + FJDIR + File.separator + QZYJFJWORD+ "-" +imageFileManager.getImageFileName();
|
||||
fjFileName.add(QZYJFJWORD+ "-" +imageFileManager.getImageFileName());
|
||||
log.info("生成签字意见附件路径:{}", imageFileName);
|
||||
imageFileName = ArchivesUtil.codeUtf8(imageFileName);
|
||||
try {
|
||||
File file = ArchivesUtil.saveInputStreamToFile(inputStream, imageFileName);
|
||||
String jsonStr = ArchivesUtil.callApi(Url, file);
|
||||
log.error("永中接口返回数据:{}", jsonStr);
|
||||
JSONObject result = JSONObject.parseObject(jsonStr);
|
||||
String errorcode = result.getString("errorcode");
|
||||
if ("0".equals(errorcode)) {
|
||||
JSONObject data = result.getJSONObject("data");
|
||||
String destFileName = data.getString("destFileName");
|
||||
String viewUrl = data.getString("viewUrl");
|
||||
ArchivesUtil.downloadFile(viewUrl, filePath + File.separator + newRequestid + File.separator + FJDIR + File.separator + QZYJFJWORD+ "-" + imageFileManager.getImageFileName() + ".pdf");
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}finally {
|
||||
if(inputStream!=null) {
|
||||
try {
|
||||
inputStream.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
//多文档
|
||||
// dwdMap.forEach((docid, imageid) -> {
|
||||
// ImageFileManager imageFileManager = new ImageFileManager();
|
||||
// imageFileManager.getImageFileInfoById(Util.getIntValue(imageid));
|
||||
// InputStream inputStream = imageFileManager.getInputStream();
|
||||
// zwFileName.add(imageFileManager.getImageFileName());
|
||||
// //中文路径/中文文件名
|
||||
// String imageFileName = filePath + File.separator + requestid + File.separator + zwdir + File.separator + fjWord + i[0] + "_" + zwWord + "_" + imageFileManager.getImageFileName();
|
||||
// log.info("生成多文档路径:{}", imageFileName);
|
||||
// imageFileName = ArchivesUtil.codeUtf8(imageFileName);
|
||||
// try {
|
||||
// File file = ArchivesUtil.saveInputStreamToFile(inputStream, imageFileName);
|
||||
// String jsonStr = ArchivesUtil.callApi(Url, file);
|
||||
// log.error("永中接口返回:{}", jsonStr);
|
||||
// JSONObject result = JSONObject.parseObject(jsonStr);
|
||||
// String errorcode = result.getString("errorcode");
|
||||
// if ("0".equals(errorcode)) {
|
||||
// JSONObject data = result.getJSONObject("data");
|
||||
// String destFileName = data.getString("destFileName");
|
||||
// String viewUrl = data.getString("viewUrl");
|
||||
// ArchivesUtil.downloadFile(viewUrl, filePath + File.separator + requestid + File.separator + zwdir + File.separator + fjWord + i[0] + "_" + zwWord + "_" + imageFileManager.getImageFileName() + ".pdf");
|
||||
// }
|
||||
// } catch (IOException e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// i[0]++;
|
||||
// });
|
||||
//正文
|
||||
zwMap.forEach((docid, imageid) -> {
|
||||
ImageFileManager imageFileManager = new ImageFileManager();
|
||||
imageFileManager.getImageFileInfoById(Util.getIntValue(imageid));
|
||||
InputStream inputStream = imageFileManager.getInputStream();
|
||||
|
||||
String newFile = FJWORD + i[0] + "_" + ZWWORD + "-" + (imageFileManager.getImageFileName().replaceAll("/","-"));
|
||||
//中文路径/中文文件名
|
||||
String imageFileName = filePath + File.separator + newRequestid + File.separator + ZWDIR + File.separator + newFile;
|
||||
zwFileName.add(newFile);
|
||||
log.info("生成正文路径:{}", imageFileName);
|
||||
imageFileName = ArchivesUtil.codeUtf8(imageFileName);
|
||||
try {
|
||||
File file = ArchivesUtil.saveInputStreamToFile(inputStream, imageFileName);
|
||||
String jsonStr = ArchivesUtil.callApi(Url, file);
|
||||
log.error("永中接口返回:{}", jsonStr);
|
||||
JSONObject result = JSONObject.parseObject(jsonStr);
|
||||
String errorcode = result.getString("errorcode");
|
||||
if ("0".equals(errorcode)) {
|
||||
JSONObject data = result.getJSONObject("data");
|
||||
String destFileName = data.getString("destFileName");
|
||||
String viewUrl = data.getString("viewUrl");
|
||||
ArchivesUtil.downloadFile(viewUrl, filePath + File.separator + newRequestid + File.separator + ZWDIR + File.separator + newFile + ".pdf");
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}finally {
|
||||
if(inputStream!=null) {
|
||||
try {
|
||||
inputStream.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
i[0]++;
|
||||
});
|
||||
//清稿前痕迹
|
||||
qgqhjMap.forEach((docid, imageid) -> {
|
||||
ImageFileManager imageFileManager = new ImageFileManager();
|
||||
imageFileManager.getImageFileInfoById(Util.getIntValue(imageid));
|
||||
InputStream inputStream = imageFileManager.getInputStream();
|
||||
|
||||
String newFile = FJWORD + i[0] + "_" + LHGWORD + "-" + (imageFileManager.getImageFileName().replaceAll("/","-"));
|
||||
zwFileName.add(newFile);
|
||||
//中文路径/中文文件名
|
||||
String imageFileName = filePath + File.separator + newRequestid + File.separator + ZWDIR + File.separator + newFile;
|
||||
log.info("生成清稿前痕迹路径:{}", imageFileName);
|
||||
imageFileName = ArchivesUtil.codeUtf8(imageFileName);
|
||||
try {
|
||||
File file = ArchivesUtil.saveInputStreamToFile(inputStream, imageFileName);
|
||||
String jsonStr = ArchivesUtil.callApi(Url, file);
|
||||
log.error("永中接口返回:{}", jsonStr);
|
||||
JSONObject result = JSONObject.parseObject(jsonStr);
|
||||
String errorcode = result.getString("errorcode");
|
||||
if ("0".equals(errorcode)) {
|
||||
JSONObject data = result.getJSONObject("data");
|
||||
String destFileName = data.getString("destFileName");
|
||||
String viewUrl = data.getString("viewUrl");
|
||||
ArchivesUtil.downloadFile(viewUrl, filePath + File.separator + newRequestid + File.separator + ZWDIR + File.separator + newFile + ".pdf");
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}finally {
|
||||
if(inputStream!=null) {
|
||||
try {
|
||||
inputStream.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
i[0]++;
|
||||
});
|
||||
//套红后留痕
|
||||
// thhlhMap.forEach((docid, imageid) -> {
|
||||
// ImageFileManager imageFileManager = new ImageFileManager();
|
||||
// imageFileManager.getImageFileInfoById(Util.getIntValue(imageid));
|
||||
// InputStream inputStream = imageFileManager.getInputStream();
|
||||
// zwFileName.add(imageFileManager.getImageFileName());
|
||||
// //中文路径/中文文件名
|
||||
// String imageFileName = filePath + File.separator + requestid + File.separator + zwdir + File.separator + fjWord + i[0] + "_" + lhgWord + "_" + imageFileManager.getImageFileName();
|
||||
// log.info("生成套红后留痕路径:{}", imageFileName);
|
||||
// imageFileName = ArchivesUtil.codeUtf8(imageFileName);
|
||||
// try {
|
||||
// File file = ArchivesUtil.saveInputStreamToFile(inputStream, imageFileName);
|
||||
// String jsonStr = ArchivesUtil.callApi(Url, file);
|
||||
// log.error("永中接口返回:{}", jsonStr);
|
||||
// JSONObject result = JSONObject.parseObject(jsonStr);
|
||||
// String errorcode = result.getString("errorcode");
|
||||
// if ("0".equals(errorcode)) {
|
||||
// JSONObject data = result.getJSONObject("data");
|
||||
// String destFileName = data.getString("destFileName");
|
||||
// String viewUrl = data.getString("viewUrl");
|
||||
// ArchivesUtil.downloadFile(viewUrl, filePath + File.separator + requestid + File.separator + zwdir + File.separator + fjWord + i[0] + "_" + lhgWord + "_" + imageFileManager.getImageFileName() + ".pdf");
|
||||
// }
|
||||
// } catch (IOException e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// i[0]++;
|
||||
// });
|
||||
|
||||
//开始承办单 先获取主流程的承办单
|
||||
List<String> requestDocid = ArchivesUtil.generaRequestFormPdf(requestid, 0);
|
||||
// 1.去掉生成子流程承办单
|
||||
// List<String> subRequestDocid = generaSubRequestFormPdf(requestid);
|
||||
Map<String, String> reqDocMap = ArchivesUtil.getFileIdByDocId(String.join(",", requestDocid));
|
||||
// 2.去掉生成子流程承办单
|
||||
// Map<String, String> subReqDocMap = getFileIdByDocId(String.join(",", subRequestDocid));
|
||||
log.error("reqDocMap:{}", JSONObject.toJSONString(reqDocMap));
|
||||
//log.error("subReqDocMap:{}", JSONObject.toJSONString(subReqDocMap));
|
||||
docids.addAll(requestDocid);
|
||||
// 3.去掉生成子流程承办单
|
||||
// docids.addAll(subRequestDocid);
|
||||
i[0] = 1;
|
||||
//主流程承办单
|
||||
reqDocMap.forEach((docid, imageid) -> {
|
||||
ImageFileManager imageFileManager = new ImageFileManager();
|
||||
imageFileManager.getImageFileInfoById(Util.getIntValue(imageid));
|
||||
InputStream inputStream = imageFileManager.getInputStream();
|
||||
//中文路径/中文文件名
|
||||
// String imageFileName = filePath + File.separator + requestid + File.separator + cbddir + File.separator + fjFile + i[0] + "_" + imageFileManager.getImageFileName();
|
||||
// String imageFileName = filePath + File.separator + newRequestid + File.separator + cbddir + File.separator + fjFile + i[0] + "_" + wjcldWord+".pdf";
|
||||
String imageFileName = filePath + File.separator + newRequestid + File.separator + CBDDIR + File.separator + WJCLDWORD+".pdf";
|
||||
log.info("主流程承办单路径:{}", imageFileName);
|
||||
imageFileName = ArchivesUtil.codeUtf8(imageFileName);
|
||||
try {
|
||||
File file = ArchivesUtil.saveInputStreamToFile(inputStream, imageFileName);
|
||||
String jsonStr = ArchivesUtil.callApi(Url, file);
|
||||
log.error("永中接口返回:{}", jsonStr);
|
||||
JSONObject result = JSONObject.parseObject(jsonStr);
|
||||
String errorcode = result.getString("errorcode");
|
||||
if ("0".equals(errorcode)) {
|
||||
JSONObject data = result.getJSONObject("data");
|
||||
String destFileName = data.getString("destFileName");
|
||||
String viewUrl = data.getString("viewUrl");
|
||||
ArchivesUtil.downloadFile(viewUrl, filePath + File.separator + newRequestid + File.separator + CBDDIR + File.separator + WJCLDWORD + ".pdf" + ".pdf");
|
||||
}
|
||||
i[0]++;
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}finally {
|
||||
if(inputStream!=null) {
|
||||
try {
|
||||
inputStream.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
//正文
|
||||
|
||||
|
||||
log.error(JSONObject.toJSONString(requestDocid));
|
||||
for (String docid : docids) {
|
||||
log.error("删除了" + docid);
|
||||
ArchivesUtil.deleteDocByid(docid);
|
||||
}
|
||||
//--------------------------------------------------------------------
|
||||
RequestService requestService = new RequestService();
|
||||
RequestInfo requestInfo = requestService.getRequest(Util.getIntValue(requestid), 100);
|
||||
String workflowid = requestInfo.getWorkflowid();
|
||||
String logFile = ArchivesUtil.getSignLog(requestid, CBDDIR + File.separator + LZXXDIR, requestInfo.getCreatorid() + requestInfo.getDescription(), templatePath, filePath,false,workflowid);
|
||||
String s = ArchivesUtil.callApi(Url, new File(logFile));
|
||||
log.error(s);
|
||||
JSONObject result = JSONObject.parseObject(s);
|
||||
String errorcode = result.getString("errorcode");
|
||||
if ("0".equals(errorcode)) {
|
||||
JSONObject data = result.getJSONObject("data");
|
||||
String destFileName = data.getString("destFileName");
|
||||
String viewUrl = data.getString("viewUrl");
|
||||
ArchivesUtil.downloadFile(viewUrl, logFile + ".pdf");
|
||||
}
|
||||
String zipName = filePath + File.separator + newRequestid + ".zip";
|
||||
ZipUtil.zip(filePath + File.separator + newRequestid, zipName);
|
||||
log.error("zipName:{}", zipName);
|
||||
String ftpFilePath = HgUtils.putFile(zipName, newRequestid + ".zip");
|
||||
log.error("ftpFilePath:{}", ftpFilePath);
|
||||
updateRecord(requestid,"esbwjml",ftpFilePath);
|
||||
ArchivesUtil.deleteDirectory(filePath + File.separator + newRequestid);
|
||||
// String ftpFilePathNew = HgUtils.putFile(zipName, "test" + File.separator + requestid + ".zip");
|
||||
// log.error("ftpFilePathNew:{}", ftpFilePathNew);
|
||||
String context = getContext(requestid, requesData, newRequestid + ".zip", zwFileName, fjFileName);
|
||||
// insertRecord(requestid, context, ftpFilePath);
|
||||
updateRecord(requestid,"content",context);
|
||||
log.error("context:{}", context);
|
||||
return context;
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
* 封装数据
|
||||
* @param requestid
|
||||
* @return
|
||||
*/
|
||||
public Map<String, String> getRequestByid(int requestid) {
|
||||
HashMap<String, String> record = new HashMap<>();
|
||||
String sql = "select * from formtable_main_170 where requestid = ?";
|
||||
String reqsql = "select REQUESTNAME from WORKFLOW_REQUESTBASE where REQUESTID = ?";
|
||||
RecordSet rs = new RecordSet();
|
||||
rs.executeQuery(sql, requestid);
|
||||
if (rs.next()) {
|
||||
record.put("fj", Util.null2String(rs.getString("fj")));
|
||||
record.put("dwd", Util.null2String(rs.getString("dwd")));
|
||||
record.put("zw", Util.null2String(rs.getString("zw")));
|
||||
record.put("ngrq", Util.null2String(rs.getString("ngrq")));
|
||||
record.put("jghwt", Util.null2String(rs.getString("jghwt")));
|
||||
record.put("bh", Util.null2String(rs.getString("bh")));
|
||||
record.put("ngbm", Util.null2String(rs.getString("ngbm")));
|
||||
record.put("bgqx", Util.null2String(rs.getString("bgqx")));
|
||||
record.put("cwrq", Util.null2String(rs.getString("cwrq")));
|
||||
record.put("ys", Util.null2String(rs.getString("ys")));
|
||||
record.put("wz", Util.null2String(rs.getString("wz")));
|
||||
record.put("ngbm", Util.null2String(rs.getString("ngbm")));
|
||||
record.put("lb", Util.null2String(rs.getString("lb")));
|
||||
record.put("bz", Util.null2String(rs.getString("bz")));
|
||||
record.put("yywh", Util.null2String(rs.getString("yywh")));
|
||||
record.put("wjlx", Util.null2String(rs.getString("wjlx")));
|
||||
record.put("fwlx", Util.null2String(rs.getString("fwlx")));
|
||||
record.put("f", Util.null2String(rs.getString("f")));
|
||||
record.put("ngr", Util.null2String(rs.getString("ngr")));
|
||||
record.put("qgqhj", Util.null2String(rs.getString("qgqhj")));
|
||||
record.put("thhlh", Util.null2String(rs.getString("thhlh")));
|
||||
record.put("yjbm", Util.null2String(rs.getString("yjbm")));
|
||||
|
||||
}
|
||||
rs.executeQuery(reqsql, requestid);
|
||||
if (rs.next()) {
|
||||
record.put("REQUESTNAME", Util.null2String(rs.getString("REQUESTNAME")));
|
||||
}
|
||||
return record;
|
||||
}
|
||||
|
||||
private String getContext(int requestid, Map<String, String> requesData, String zipName, List<String> zwFileName, List<String> fjFileName) {
|
||||
StringBuilder context = new StringBuilder();
|
||||
try {
|
||||
DepartmentComInfo departmentComInfo = new DepartmentComInfo();
|
||||
String ngrq = Util.null2String(requesData.get("ngrq")); //拟稿日期
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||
LocalDate date = LocalDate.parse(ngrq, formatter);
|
||||
int year = date.getYear();
|
||||
context.append(year).append("|"); //1.年度 -> 拟稿日期
|
||||
String jghwt = Util.null2String(requesData.get("jghwt"));//2.机构或问题 -> 机构或问题
|
||||
context.append(jghwt).append("|");
|
||||
String bh = Util.null2String(requesData.get("bh"));// 3.文号 -> 编号
|
||||
context.append(bh).append("|");
|
||||
String requestname = Util.null2String(requesData.get("REQUESTNAME")); // 4.文件题名 -> 流程名称
|
||||
context.append(requestname).append("|");
|
||||
String ngbmName = Util.null2String(departmentComInfo.getDepartmentmark(requesData.get("ngbm"))); //5 责任者 -> 拟稿部门
|
||||
context.append(ngbmName).append("|");
|
||||
String bgqx = Util.null2String(requesData.get("bgqx")); //6 保管期限 -> 保管期限
|
||||
context.append(bgqx).append("|");
|
||||
String cwrq = Util.null2String(requesData.get("cwrq")); //7 日期 -> 成文日期
|
||||
context.append(cwrq).append("|");
|
||||
String ys = Util.null2String(requesData.get("ys")); //8 页数 -> 页数
|
||||
context.append(ys).append("|");
|
||||
String wz = Util.null2String(requesData.get("wz")); //9 文种 -> 文种
|
||||
context.append(wz).append("|");
|
||||
String ngbm = Util.null2String(requesData.get("ngbm"));
|
||||
String yjbm = Util.null2String(requesData.get("yjbm"));
|
||||
|
||||
String[] deptData = ArchivesUtil.getDeptNameAndCode(ngbm);
|
||||
String[] yjbmdeptData = ArchivesUtil.getDeptNameAndCode(yjbm);
|
||||
String[] subData = ArchivesUtil.getSubCom(ngbm);
|
||||
context.append(yjbmdeptData[0]).append("|"); //10 行编号 -> 拟稿部门
|
||||
|
||||
context.append(yjbmdeptData[1]).append("|"); //11 行名称
|
||||
context.append("").append("|"); // 12 保管期限编号
|
||||
context.append("").append("|"); // 13 保管期限及编号
|
||||
context.append("").append("|"); // 14 是否开放
|
||||
context.append("").append("|"); // 15 互见号
|
||||
String lb = Util.null2String(requesData.get("lb"));
|
||||
context.append(lb).append("|"); //16 类别 -> 类别
|
||||
//TODO
|
||||
String xgbm = Util.null2String(getAssociatedDepts(requesData));
|
||||
context.append(xgbm).append("|"); //17 相关部门 -> 流经部门
|
||||
// String lwh = Util.null2String(requesData.get("lwh"));
|
||||
context.append("").append("|");// 18 收文号 -> 空
|
||||
String fs = "";
|
||||
context.append(fs).append("|"); // 19 份数 -> 份数
|
||||
String bz = Util.null2String(requesData.get("bz"));
|
||||
context.append("").append("|"); // 20 备注 -> 备注
|
||||
String yywh = Util.null2String(requesData.get("yywh"));
|
||||
context.append("").append("|"); // 21 引用文号 -> 引用文号
|
||||
String wjlx = Util.null2String(requesData.get("wjlx"));
|
||||
context.append("").append("|"); // 22 文件类型 -> 空
|
||||
String fwlx = Util.null2String(requesData.get("fwlx"));
|
||||
context.append("分行发文").append("|"); // 23 发文类型 -> 空
|
||||
String f = Util.null2String(requesData.get("f"));
|
||||
context.append(f).append("|"); // 24 发 -> 空
|
||||
String ngr = Util.null2String(requesData.get("ngr"));
|
||||
context.append(new User(Util.getIntValue(ngr)).getLoginid()).append("|"); // 25 拟稿人 -> 拟稿人
|
||||
context.append(ngbmName).append("|"); // 26 拟稿部门 -> 拟稿部门名称
|
||||
context.append("发文").append("|"); // 27 公文类型 -> "收文"
|
||||
//TODO
|
||||
context.append(ArchivesUtil.getAssociatedPersons(requestid,false)).append("|"); // 28 相关人员 -> 参与人员
|
||||
context.append("智慧OA").append("|"); // 29 数据来源 -> 数据来源
|
||||
context.append(year).append("|"); // 30 形成年度 -> 年份
|
||||
context.append(String.join("&&", zwFileName)).append("|"); // 31 正文名称
|
||||
context.append(String.join("&&", fjFileName)).append("|"); // 32 附件名称
|
||||
context.append("togd"+requestid).append("|"); // 33 主键
|
||||
context.append("").append("|"); // 34 关联主键
|
||||
context.append("").append("|"); // 35 被关联主键
|
||||
context.append(zipName);// 36 压缩包名称
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
log.error("getContextError:{}", e.getMessage());
|
||||
}
|
||||
|
||||
return context.toString();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private String getAssociatedDepts(Map<String, String> requesData) {
|
||||
HashSet<String> records = new HashSet<>();
|
||||
records.addAll(Arrays.asList(Util.null2String(requesData.get("hqbm")).split(","))); // 会签部门
|
||||
records.addAll(Arrays.asList(Util.null2String(requesData.get("ngbm")).split(","))); // 拟稿部门
|
||||
records.addAll(Arrays.asList(Util.null2String(requesData.get("bmyb")).split(","))); // 部门阅办
|
||||
records.addAll(Arrays.asList(Util.null2String(requesData.get("cs")).split(","))); // 抄送
|
||||
records.addAll(Arrays.asList(Util.null2String(requesData.get("nbfs")).split(","))); // 本行发送
|
||||
records.addAll(Arrays.asList(Util.null2String(requesData.get("zs")).split(","))); // 主送
|
||||
records.addAll(Arrays.asList(Util.null2String(requesData.get("dqbm")).split(","))); // 当前部门
|
||||
records.addAll(Arrays.asList(Util.null2String(requesData.get("cb")).split(","))); // 抄报
|
||||
records.addAll(Arrays.asList(Util.null2String(requesData.get("bmhqzj")).split(","))); // 部门会签(追加)
|
||||
records.addAll(Arrays.asList(Util.null2String(requesData.get("bmybzj")).split(","))); // 部门阅办(追加)
|
||||
ArrayList<String> deptName = new ArrayList<>();
|
||||
DepartmentComInfo departmentComInfo = new DepartmentComInfo();
|
||||
for (String record : records) {
|
||||
try {
|
||||
if (StringUtil.isEmpty(record)){
|
||||
continue;
|
||||
}
|
||||
String departmentName = departmentComInfo.getDepartmentmark(record);
|
||||
deptName.add(departmentName);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
return String.join("&&", deptName);
|
||||
}
|
||||
|
||||
private void updateRecord(int requestid, String field , String fieldvalue) {
|
||||
String sql = "update uf_pushArchivesLog set "+field+" = ? where request = ?";
|
||||
RecordSet recordSet = new RecordSet();
|
||||
recordSet.executeUpdate(sql, fieldvalue, requestid);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
package com.engine.custom.archives.util;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public interface KeyWord {
|
||||
public static final String ZWDIR = "正文";
|
||||
public static final String FJDIR = "附件";
|
||||
public static final String CBDDIR = "承办单";
|
||||
public static final String ZLCDIR = "承办单" + File.separator + "子流程";
|
||||
public static final String LZXXDIR = "流转信息";
|
||||
public static final String FJFILE = "附件";
|
||||
public static final String FJWORD = "附件";
|
||||
public static final String ZWWORD = "正文";
|
||||
public static final String LHGWORD = "留痕稿";
|
||||
public static final String LCFJWORD = "流程附件";
|
||||
public static final String QZYJFJWORD = "签字意见附件";
|
||||
public static final String WJCLDWORD = "文件处理单";
|
||||
public static final String WJLZXXWORD = "文件流转信息";
|
||||
public static final String XBBMFJWORD = "协办部门附件";
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,120 @@
|
||||
package com.engine.custom.msg;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
import com.cloudstore.dev.api.bean.MessageBean;
|
||||
import com.weaver.base.msgcenter.channel.IMessageReceive;
|
||||
import com.weaver.general.Util;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.general.BaseBean;
|
||||
import weaver.general.StringUtil;
|
||||
import weaver.hrm.HrmUserVarify;
|
||||
import weaver.hrm.User;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class MessageReceiveTest implements IMessageReceive {
|
||||
public static Logger log = LoggerFactory.getLogger("Archives");
|
||||
private BaseBean bean=new BaseBean();
|
||||
@Override
|
||||
public void onMessage(String s) {
|
||||
log.error("onMessage:{}",s);
|
||||
bean.writeLog("onMessage:{}",s);
|
||||
List<MessageBean> localList = JSONArray.parseArray(s, MessageBean.class);
|
||||
for (MessageBean messageBean : localList) {
|
||||
String customContext = getCustomContext(messageBean);
|
||||
log.error("customContext:{}",customContext);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
log.error("onStartExecute");
|
||||
bean.writeLog("onStartExecute");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnd() {
|
||||
log.error("onEndExecute");
|
||||
bean.writeLog("onEndExecute");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setProp(Map<String, String> map) {
|
||||
log.error("setProp:{}",map);
|
||||
bean.writeLog("setProp:{}"+map);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setList(List<IMessageReceive> list) {
|
||||
log.error("setList:{}", JSONObject.toJSONString(list));
|
||||
bean.writeLog("setList:{}"+ JSONObject.toJSONString(list));
|
||||
}
|
||||
|
||||
private String getCustomContext(MessageBean messageBean) {
|
||||
log.error("onMessage:{}",messageBean);
|
||||
String customContext = "";
|
||||
if (messageBean == null ){
|
||||
bean.writeLog("messageBean==null,异常");
|
||||
return customContext;
|
||||
}
|
||||
String messageGroupTypeName = Util.null2String(messageBean.getMessageGroupTypeName());
|
||||
if (messageGroupTypeName.contains("流程")){
|
||||
RecordSet rs = new RecordSet();
|
||||
String targetId = messageBean.getTargetId();
|
||||
if (StringUtil.isEmpty(targetId)||targetId.contains("|")){
|
||||
return Util.null2String(messageBean.getContext());
|
||||
}
|
||||
rs.executeQuery("select * from WORKFLOW_REQUESTBASE where REQUESTID = ?",targetId);
|
||||
if (rs.next()){
|
||||
int creater = Util.getIntValue(rs.getString("creater"));
|
||||
User user = new User(creater);
|
||||
String createdate = Util.null2String(rs.getString("createdate"));
|
||||
String createtime = Util.null2String(rs.getString("createtime"));
|
||||
customContext = messageGroupTypeName + "-" + (StringUtil.isEmpty(messageBean.getContext()) ? messageBean.getTitle() : messageBean.getContext() ) + ",创建人:" + user.getLastname()
|
||||
+",创建时间:"+createdate + " " + createtime + " ,请您登录到办公网进行处理。";
|
||||
}
|
||||
}else if(messageGroupTypeName.contains("邮件") || messageGroupTypeName.contains("信件")){
|
||||
// String date = messageBean.getDate();
|
||||
// String time = messageBean.getTime();
|
||||
customContext = messageGroupTypeName + "-" + (StringUtil.isEmpty(messageBean.getContext()) ? messageBean.getTitle() : messageBean.getContext() ) + " ,请您登录到办公网进行处理。";
|
||||
}else {
|
||||
customContext = Util.null2String(messageBean.getContext());
|
||||
}
|
||||
return customContext;
|
||||
}
|
||||
|
||||
|
||||
public static String getStringValue(JSONObject jsonObject, String key) {
|
||||
return jsonObject.containsKey(key) ? jsonObject.getString(key) : null;
|
||||
}
|
||||
|
||||
public static Integer getIntegerValue(JSONObject jsonObject, String key) {
|
||||
return jsonObject.containsKey(key) ? jsonObject.getInteger(key) : null;
|
||||
}
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
// 示例 JSON 字符串
|
||||
String jsonString = "{\"name\":\"John\", \"age\":30}";
|
||||
|
||||
// 将 JSON 字符串解析为 JSONObject
|
||||
JSONObject jsonObject = JSONObject.parseObject(jsonString);
|
||||
|
||||
// 检查 key 是否存在并获取值
|
||||
String name = getStringValue(jsonObject, "name");
|
||||
String age = getStringValue(jsonObject, "age");
|
||||
String address = getStringValue(jsonObject, "address"); // key 不存在
|
||||
|
||||
// 输出结果
|
||||
System.out.println("Name: " + name); // 输出: Name: John
|
||||
System.out.println("Age: " + age); // 输出: Age: 30
|
||||
System.out.println("Address: " + address); // 输出: Address: null
|
||||
}
|
||||
|
||||
}
|
@ -1,66 +0,0 @@
|
||||
<%@ page import="java.io.FileInputStream" %>
|
||||
<%@ page import="java.net.URLEncoder" %>
|
||||
<%@ page import="com.api.login.util.LoginUtil" %>
|
||||
<%@ page import="weaver.conn.RecordSet" %>
|
||||
<%@ page import="com.icbc.api.internal.apache.http.impl.cookie.S" %>
|
||||
<%@ page import="weaver.hrm.HrmUserVarify" %>
|
||||
<%@ page import="weaver.hrm.User" %>
|
||||
<%@ page import="com.alibaba.fastjson.JSONArray" %>
|
||||
<%@ page import="com.alibaba.fastjson.JSONObject" %>
|
||||
<%@ page import="java.time.LocalDate" %>
|
||||
<%@ page import="java.time.format.DateTimeFormatter" %>
|
||||
<%@ page import="weaver.general.Util" %>
|
||||
<%@ page import="weaver.general.StringUtil" %>
|
||||
<%@ page import="java.time.DayOfWeek" %>
|
||||
<%@ page import="weaver.file.Prop" %>
|
||||
<%@ page import="java.io.IOException" %>
|
||||
<%@ page import="java.util.*" %>
|
||||
<%@ page language="java" contentType="text/html; charset=UTF-8" %>
|
||||
|
||||
|
||||
<%
|
||||
List<String> weekends = getAllWeekendsOfYear(LocalDate.now().getYear());
|
||||
for (String weekend : weekends) {
|
||||
out.print(weekend+"<br>");
|
||||
}
|
||||
out.print(weekends.size());
|
||||
|
||||
%>
|
||||
<%!
|
||||
private static List<String> getAllWeekendsOfYear(int year) {
|
||||
//将本年的周六周日加到list中
|
||||
List<String> weekendDates = new ArrayList<>();
|
||||
LocalDate date = LocalDate.of(year, 1, 1);
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||
while (date.getYear() == year) {
|
||||
if (date.getDayOfWeek() == DayOfWeek.SATURDAY || date.getDayOfWeek() == DayOfWeek.SUNDAY) {
|
||||
weekendDates.add(date.format(formatter));
|
||||
}
|
||||
date = date.plusDays(1);
|
||||
}
|
||||
//查询库里的节假日设置
|
||||
RecordSet recordSet = new RecordSet();
|
||||
// String groupid = Util.null2String(Prop.getPropValue("year_report_set", "groupid"),"24") ;
|
||||
String groupid = "24" ;
|
||||
recordSet.executeQuery("select changeType ,holidayDate from KQ_HolidaySet where groupid = ?",groupid);
|
||||
//去掉调配工作日,加上公众假日和调配休息日
|
||||
List<String> WorkDates = new ArrayList<>();
|
||||
List<String> holidayDates = new ArrayList<>();
|
||||
while (recordSet.next()){
|
||||
String changeType = recordSet.getString("changeType");
|
||||
String holidayDate = recordSet.getString("holidayDate");
|
||||
if ("2".equals(changeType)){
|
||||
WorkDates.add(holidayDate);
|
||||
}else if("1".equals(changeType) || "3".equals(changeType)){
|
||||
holidayDates.add(holidayDate);
|
||||
}
|
||||
}
|
||||
weekendDates.removeAll(WorkDates);
|
||||
HashSet<String> set = new HashSet<>();
|
||||
set.addAll(weekendDates);
|
||||
set.addAll(holidayDates);
|
||||
return new ArrayList<>(set);
|
||||
}
|
||||
|
||||
|
||||
%>
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,84 @@
|
||||
<%@ page import="java.text.SimpleDateFormat" %>
|
||||
<%@ page import="weaver.hrm.HrmUserVarify" %>
|
||||
<%@ page import="weaver.hrm.User" %>
|
||||
<%@ page import="weaver.conn.RecordSet" %>
|
||||
<%@ page import="java.util.*" %>
|
||||
<%@ page import="weaver.general.Util" %>
|
||||
<%@ page import="weaver.workflow.workflow.WorkflowComInfo" %>
|
||||
<%@ page import="weaver.workflow.workflow.WorkflowBillComInfo" %>
|
||||
<%@ page import="weaver.conn.BatchRecordSet" %>
|
||||
<%@ page language="java" contentType="text/html; charset=UTF-8" %>
|
||||
|
||||
|
||||
<%
|
||||
// out.print(Prop.getPropValue("qwe","host"));
|
||||
User user = HrmUserVarify.getUser(request, response);
|
||||
if (user == null){
|
||||
out.print("暂无权限");
|
||||
}
|
||||
if (!(1 == (user.getUID()))){
|
||||
out.print("暂无权限");
|
||||
return;
|
||||
}
|
||||
out.print("开始执行");
|
||||
out.print("<br/>");
|
||||
long startTime = System.currentTimeMillis();
|
||||
RecordSet recordSet = new RecordSet();
|
||||
String sql = "select MAINWFID , endnodeid , type from uf_ArchivesSet";
|
||||
recordSet.executeQuery(sql);
|
||||
ArrayList<HashMap<String, String>> wfids = new ArrayList<>();
|
||||
while (recordSet.next()){
|
||||
HashMap<String, String> map = new HashMap<>();
|
||||
String wfid = Util.null2String(recordSet.getString("MAINWFID"));
|
||||
String endnodeid = Util.null2String(recordSet.getString("endnodeid"));
|
||||
String type = Util.null2String(recordSet.getString("type"));
|
||||
map.put("wfid",wfid);
|
||||
map.put("endnodeid",endnodeid);
|
||||
map.put("type",type);
|
||||
|
||||
wfids.add(map);
|
||||
}
|
||||
WorkflowComInfo wf = new WorkflowComInfo();
|
||||
WorkflowBillComInfo wcInfo = new WorkflowBillComInfo();
|
||||
ArrayList<String> insertParam = new ArrayList<>();
|
||||
String sep = Util.getSeparator()+"";
|
||||
BatchRecordSet brs = new BatchRecordSet();
|
||||
String timestamp = generateTimestamp();
|
||||
String insertSql = "insert into uf_pushArchivesLog (request,ddsj,type) values (?,?,?)";
|
||||
for (HashMap<String, String> map : wfids) {
|
||||
String wfid = map.get("wfid");
|
||||
String endnodeid = map.get("endnodeid");
|
||||
endnodeid = endnodeid.length() > 0 ? endnodeid : "-1";
|
||||
String type = map.get("type");
|
||||
String formId = wf.getFormId(wfid);
|
||||
String tablename = wcInfo.getTablename(formId);
|
||||
String wfsql = "select base.requestid reqid from "+ tablename +" business left join " +
|
||||
" WORKFLOW_REQUESTBASE base on business.requestid = base.requestid " +
|
||||
" left join uf_pushArchivesLog log on business.requestid = log.request " +
|
||||
" where ( base.currentnodeid in ( "+ endnodeid +" ) or currentnodetype = 3 ) " +
|
||||
" and log.id is null";
|
||||
recordSet.executeQuery( wfsql);
|
||||
out.println("查询sql:"+wfsql);
|
||||
out.print("<br/>");
|
||||
while (recordSet.next()){
|
||||
String reqid = recordSet.getString("reqid");
|
||||
String insertStr = reqid + sep + timestamp + sep + type;
|
||||
out.print(insertStr);
|
||||
out.print("<br/>");
|
||||
insertParam.add(insertStr);
|
||||
}
|
||||
}
|
||||
brs.executeSqlBatchNew(insertSql,insertParam);
|
||||
long endTime = System.currentTimeMillis();
|
||||
long executionTime = endTime - startTime;
|
||||
out.print("执行完成 ->"+ "程序执行时间: " + executionTime + " 毫秒");
|
||||
|
||||
%>
|
||||
<%!
|
||||
public static String generateTimestamp() {
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
Date currentDate = new Date();
|
||||
return dateFormat.format(currentDate);
|
||||
}
|
||||
|
||||
%>
|
@ -0,0 +1,84 @@
|
||||
<%@ page import="java.text.SimpleDateFormat" %>
|
||||
<%@ page import="weaver.hrm.HrmUserVarify" %>
|
||||
<%@ page import="weaver.hrm.User" %>
|
||||
<%@ page import="weaver.conn.RecordSet" %>
|
||||
<%@ page import="java.util.*" %>
|
||||
<%@ page import="weaver.general.Util" %>
|
||||
<%@ page import="weaver.workflow.workflow.WorkflowComInfo" %>
|
||||
<%@ page import="weaver.workflow.workflow.WorkflowBillComInfo" %>
|
||||
<%@ page import="weaver.conn.BatchRecordSet" %>
|
||||
<%@ page language="java" contentType="text/html; charset=UTF-8" %>
|
||||
|
||||
|
||||
<%
|
||||
// out.print(Prop.getPropValue("qwe","host"));
|
||||
User user = HrmUserVarify.getUser(request, response);
|
||||
if (user == null){
|
||||
out.print("暂无权限");
|
||||
}
|
||||
if (!(1 == (user.getUID()))){
|
||||
out.print("暂无权限");
|
||||
return;
|
||||
}
|
||||
out.print("开始执行");
|
||||
out.print("<br/>");
|
||||
long startTime = System.currentTimeMillis();
|
||||
RecordSet recordSet = new RecordSet();
|
||||
String sql = "select MAINWFID , endnodeid , type from uf_ArchivesSet";
|
||||
recordSet.executeQuery(sql);
|
||||
ArrayList<HashMap<String, String>> wfids = new ArrayList<>();
|
||||
while (recordSet.next()){
|
||||
HashMap<String, String> map = new HashMap<>();
|
||||
String wfid = Util.null2String(recordSet.getString("MAINWFID"));
|
||||
String endnodeid = Util.null2String(recordSet.getString("endnodeid"));
|
||||
String type = Util.null2String(recordSet.getString("type"));
|
||||
map.put("wfid",wfid);
|
||||
map.put("endnodeid",endnodeid);
|
||||
map.put("type",type);
|
||||
|
||||
wfids.add(map);
|
||||
}
|
||||
WorkflowComInfo wf = new WorkflowComInfo();
|
||||
WorkflowBillComInfo wcInfo = new WorkflowBillComInfo();
|
||||
ArrayList<String> insertParam = new ArrayList<>();
|
||||
String sep = Util.getSeparator()+"";
|
||||
BatchRecordSet brs = new BatchRecordSet();
|
||||
String timestamp = generateTimestamp();
|
||||
String insertSql = "insert into uf_pushArchivesLog (request,ddsj,type) values (?,?,?)";
|
||||
for (HashMap<String, String> map : wfids) {
|
||||
String wfid = map.get("wfid");
|
||||
String endnodeid = map.get("endnodeid");
|
||||
endnodeid = endnodeid.length() > 0 ? endnodeid : "-1";
|
||||
String type = map.get("type");
|
||||
String formId = wf.getFormId(wfid);
|
||||
String tablename = wcInfo.getTablename(formId);
|
||||
String wfsql = "select base.requestid reqid from "+ tablename +" business left join " +
|
||||
" WORKFLOW_REQUESTBASE base on business.requestid = base.requestid " +
|
||||
" left join uf_pushArchivesLog log on business.requestid = log.request " +
|
||||
" where ( base.currentnodeid in ( "+ endnodeid +" ) or currentnodetype = 3 ) and createdate >= '2023-01-01' and createdate <= '2023-12-31'" +
|
||||
" and log.id is null ";
|
||||
recordSet.executeQuery( wfsql);
|
||||
out.println("查询sql:"+wfsql);
|
||||
out.print("<br/>");
|
||||
while (recordSet.next()){
|
||||
String reqid = recordSet.getString("reqid");
|
||||
String insertStr = reqid + sep + timestamp + sep + type;
|
||||
out.print(insertStr);
|
||||
out.print("<br/>");
|
||||
insertParam.add(insertStr);
|
||||
}
|
||||
}
|
||||
brs.executeSqlBatchNew(insertSql,insertParam);
|
||||
long endTime = System.currentTimeMillis();
|
||||
long executionTime = endTime - startTime;
|
||||
out.print("执行完成 ->"+ "程序执行时间: " + executionTime + " 毫秒");
|
||||
|
||||
%>
|
||||
<%!
|
||||
public static String generateTimestamp() {
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
Date currentDate = new Date();
|
||||
return dateFormat.format(currentDate);
|
||||
}
|
||||
|
||||
%>
|
@ -0,0 +1,84 @@
|
||||
<%@ page import="java.text.SimpleDateFormat" %>
|
||||
<%@ page import="weaver.hrm.HrmUserVarify" %>
|
||||
<%@ page import="weaver.hrm.User" %>
|
||||
<%@ page import="weaver.conn.RecordSet" %>
|
||||
<%@ page import="java.util.*" %>
|
||||
<%@ page import="weaver.general.Util" %>
|
||||
<%@ page import="weaver.workflow.workflow.WorkflowComInfo" %>
|
||||
<%@ page import="weaver.workflow.workflow.WorkflowBillComInfo" %>
|
||||
<%@ page import="weaver.conn.BatchRecordSet" %>
|
||||
<%@ page language="java" contentType="text/html; charset=UTF-8" %>
|
||||
|
||||
|
||||
<%
|
||||
// out.print(Prop.getPropValue("qwe","host"));
|
||||
User user = HrmUserVarify.getUser(request, response);
|
||||
if (user == null){
|
||||
out.print("暂无权限");
|
||||
}
|
||||
if (!(1 == (user.getUID()))){
|
||||
out.print("暂无权限");
|
||||
return;
|
||||
}
|
||||
out.print("开始执行");
|
||||
out.print("<br/>");
|
||||
long startTime = System.currentTimeMillis();
|
||||
RecordSet recordSet = new RecordSet();
|
||||
String sql = "select MAINWFID , endnodeid , type from uf_ArchivesSet";
|
||||
recordSet.executeQuery(sql);
|
||||
ArrayList<HashMap<String, String>> wfids = new ArrayList<>();
|
||||
while (recordSet.next()){
|
||||
HashMap<String, String> map = new HashMap<>();
|
||||
String wfid = Util.null2String(recordSet.getString("MAINWFID"));
|
||||
String endnodeid = Util.null2String(recordSet.getString("endnodeid"));
|
||||
String type = Util.null2String(recordSet.getString("type"));
|
||||
map.put("wfid",wfid);
|
||||
map.put("endnodeid",endnodeid);
|
||||
map.put("type",type);
|
||||
|
||||
wfids.add(map);
|
||||
}
|
||||
WorkflowComInfo wf = new WorkflowComInfo();
|
||||
WorkflowBillComInfo wcInfo = new WorkflowBillComInfo();
|
||||
ArrayList<String> insertParam = new ArrayList<>();
|
||||
String sep = Util.getSeparator()+"";
|
||||
BatchRecordSet brs = new BatchRecordSet();
|
||||
String timestamp = generateTimestamp();
|
||||
String insertSql = "insert into uf_pushArchivesLog (request,ddsj,type) values (?,?,?)";
|
||||
for (HashMap<String, String> map : wfids) {
|
||||
String wfid = map.get("wfid");
|
||||
String endnodeid = map.get("endnodeid");
|
||||
endnodeid = endnodeid.length() > 0 ? endnodeid : "-1";
|
||||
String type = map.get("type");
|
||||
String formId = wf.getFormId(wfid);
|
||||
String tablename = wcInfo.getTablename(formId);
|
||||
String wfsql = "select base.requestid reqid from "+ tablename +" business left join " +
|
||||
" WORKFLOW_REQUESTBASE base on business.requestid = base.requestid " +
|
||||
" left join uf_pushArchivesLog log on business.requestid = log.request " +
|
||||
" where ( base.currentnodeid in ( "+ endnodeid +" ) or currentnodetype = 3 ) and createdate >= '2023-12-01' and createdate <= '2023-12-31'" +
|
||||
" and log.id is null ";
|
||||
recordSet.executeQuery( wfsql);
|
||||
out.println("查询sql:"+wfsql);
|
||||
out.print("<br/>");
|
||||
while (recordSet.next()){
|
||||
String reqid = recordSet.getString("reqid");
|
||||
String insertStr = reqid + sep + timestamp + sep + type;
|
||||
out.print(insertStr);
|
||||
out.print("<br/>");
|
||||
insertParam.add(insertStr);
|
||||
}
|
||||
}
|
||||
brs.executeSqlBatchNew(insertSql,insertParam);
|
||||
long endTime = System.currentTimeMillis();
|
||||
long executionTime = endTime - startTime;
|
||||
out.print("执行完成 ->"+ "程序执行时间: " + executionTime + " 毫秒");
|
||||
|
||||
%>
|
||||
<%!
|
||||
public static String generateTimestamp() {
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
Date currentDate = new Date();
|
||||
return dateFormat.format(currentDate);
|
||||
}
|
||||
|
||||
%>
|
Binary file not shown.
@ -1,60 +0,0 @@
|
||||
<%@ page import="weaver.conn.RecordSetDataSource" %>
|
||||
<%@ page import="weaver.conn.RecordSet" %>
|
||||
<%@ page import="com.engine.custom.corn.util.ReportUtil" %>
|
||||
<%@ page language="java" contentType="text/html; charset=UTF-8" %>
|
||||
|
||||
<%
|
||||
out.print("<br/>最爱用APP更新开始执行");
|
||||
execute();
|
||||
out.print("<br/>最爱用APP更新结束");
|
||||
|
||||
%>
|
||||
<%!
|
||||
|
||||
|
||||
public void execute() {
|
||||
|
||||
RecordSet rs = new RecordSet();
|
||||
updateAppAndNum(rs);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
private int updateAppAndNum(RecordSet rs) {
|
||||
rs.executeUpdate("UPDATE uf_personreport " +
|
||||
"SET " +
|
||||
" (zaydyy, ljsycs) = ( " +
|
||||
" SELECT MaxField, MaxValue " +
|
||||
" FROM ( " +
|
||||
" SELECT id , " +
|
||||
" GREATEST( " +
|
||||
" NVL(gsznzydjs, 0), " +
|
||||
" NVL(itptdjs, 0), " +
|
||||
" NVL(ygzs, 0), " +
|
||||
" NVL(sktx, 0), " +
|
||||
" NVL(sxsp, 0) " +
|
||||
" ) AS MaxValue, " +
|
||||
" CASE GREATEST( " +
|
||||
" NVL(gsznzydjs, 0), " +
|
||||
" NVL(itptdjs, 0), " +
|
||||
" NVL(ygzs, 0), " +
|
||||
" NVL(sktx, 0), " +
|
||||
" NVL(sxsp, 0) " +
|
||||
" ) " +
|
||||
" WHEN NVL(gsznzydjs, 0) THEN '公司智能作业' " +
|
||||
" WHEN NVL(itptdjs, 0) THEN 'IT项目审批' " +
|
||||
" WHEN NVL(ygzs, 0) THEN '云工作室' " +
|
||||
" WHEN NVL(sktx, 0) THEN '数看天行' " +
|
||||
" WHEN NVL(sxsp, 0) THEN '授信审批' " +
|
||||
" END AS MaxField " +
|
||||
" FROM uf_personreport " +
|
||||
" ) " +
|
||||
" WHERE uf_personreport.id = id " +
|
||||
" ) " +
|
||||
"WHERE gsznzydjs is not null or itptdjs is not null or ygzs is not null or sktx is not null or sxsp is not null");
|
||||
return rs.getUpdateCount();
|
||||
}
|
||||
|
||||
|
||||
%>
|
@ -1,119 +0,0 @@
|
||||
<%@ page import="weaver.conn.RecordSetDataSource" %>
|
||||
<%@ page import="weaver.conn.RecordSet" %>
|
||||
<%@ page import="com.engine.custom.corn.util.ReportUtil" %>
|
||||
<%@ page language="java" contentType="text/html; charset=UTF-8" %>
|
||||
|
||||
<%
|
||||
out.print("<br/>关键词更新开始执行");
|
||||
String execute = execute();
|
||||
out.print(execute);
|
||||
out.print("<br/>关键词更新结束");
|
||||
|
||||
%>
|
||||
<%!
|
||||
public String execute() {
|
||||
RecordSetDataSource em7rs = new RecordSetDataSource("em7");
|
||||
RecordSetDataSource emprs = new RecordSetDataSource("emp_msg");
|
||||
RecordSet rs = new RecordSet();
|
||||
RecordSet rs2 = new RecordSet();
|
||||
RecordSet rs3 = new RecordSet();
|
||||
String roleMember = ReportUtil.getRoleMember(rs);
|
||||
String out = "";
|
||||
int i = updateRoleGjc(rs, roleMember);
|
||||
out = out + "<br/>updateRoleGjc==>" + i;
|
||||
int i1 = updateGjcOfficialWf(rs, 650);
|
||||
out = out + "<br/>updateGjcOfficialWf==>" + i1;
|
||||
int i2 = updateGjcAffairsWf(rs, 650);
|
||||
out = out + "<br/>updateGjcAffairsWf==>" + i2;
|
||||
int i3 = updateGjcBusinessWf(rs, 650);
|
||||
out = out + "<br/>updateGjcBusinessWf==>" + i3;
|
||||
int i4 = updateGjcShareDoc(rs, 650);
|
||||
out = out + "<br/>updateGjcShareDoc==>" + i4;
|
||||
int i5 = updateGjcMeeting(rs, 650);
|
||||
out = out + "<br/>updateGjcMeeting==>" + i5;
|
||||
int i6 = updateGjcLogin(rs, 650);
|
||||
out = out + "<br/>updateGjcLogin==>" + i6;
|
||||
int i7 = updateGjcMsg(rs, 650);
|
||||
out = out + "<br/>updateGjcMsg==>" + i7;
|
||||
int i8 = updateGjcNull(rs);
|
||||
out = out + "<br/>updateGjcNull==>" + i8;
|
||||
return out;
|
||||
|
||||
}
|
||||
|
||||
private int updateRoleGjc(RecordSet rs, String roleMember) {
|
||||
rs.executeUpdate(" update uf_personreport set gjc = '统筹全局' where ry in ( " + roleMember + ")");
|
||||
return rs.getUpdateCount();
|
||||
}
|
||||
|
||||
//更新公文办理数前10%的人
|
||||
private int updateGjcOfficialWf(RecordSet rs, int rownum) {
|
||||
rs.executeUpdate(" update uf_personreport set gjc = '人形公文处理机' where id in( " +
|
||||
" select rk.id from ( " +
|
||||
" select ROW_NUMBER() OVER (ORDER BY qnljclgw DESC) AS rank , * from uf_personreport where qnljclgw is not null and qnljclgw != 0 and gjc is null" +
|
||||
" ) rk where rk.rank < " + rownum + ")");
|
||||
return rs.getUpdateCount();
|
||||
}
|
||||
|
||||
//更新事务审批数前10%的人
|
||||
private int updateGjcAffairsWf(RecordSet rs, int rownum) {
|
||||
rs.executeUpdate(" update uf_personreport set gjc = '宝藏事务挖掘机' where id in( " +
|
||||
" select rk.id from ( " +
|
||||
" select ROW_NUMBER() OVER (ORDER BY grswsps DESC) AS rank , * from uf_personreport where grswsps is not null and grswsps != 0 and gjc is null" +
|
||||
" ) rk where rk.rank < " + rownum + ")");
|
||||
return rs.getUpdateCount();
|
||||
}
|
||||
|
||||
//更新商旅使用数前10%的人
|
||||
private int updateGjcBusinessWf(RecordSet rs, int rownum) {
|
||||
rs.executeUpdate(" update uf_personreport set gjc = '走南闯北 遥遥领先' where id in( " +
|
||||
" select rk.id from ( " +
|
||||
" select ROW_NUMBER() OVER (ORDER BY ljsyslcs DESC) AS rank , * from uf_personreport where ljsyslcs is not null and ljsyslcs != 0 and gjc is null" +
|
||||
" ) rk where rk.rank < " + rownum+ ")");
|
||||
return rs.getUpdateCount();
|
||||
}
|
||||
|
||||
|
||||
//更新分享文档数前10%的人
|
||||
private int updateGjcShareDoc(RecordSet rs, int rownum) {
|
||||
rs.executeUpdate(" update uf_personreport set gjc = '知识分享之光' where id in( " +
|
||||
" select rk.id from ( " +
|
||||
" select ROW_NUMBER() OVER (ORDER BY grwdgx DESC) AS rank , * from uf_personreport where grwdgx is not null and grwdgx != 0 and gjc is null" +
|
||||
" ) rk where rk.rank < " + rownum + ")");
|
||||
return rs.getUpdateCount();
|
||||
}
|
||||
|
||||
//更新创建会议数前10%的人
|
||||
private int updateGjcMeeting(RecordSet rs, int rownum) {
|
||||
rs.executeUpdate(" update uf_personreport set gjc = '会议守护者' where id in( " +
|
||||
" select rk.id from ( " +
|
||||
" select ROW_NUMBER() OVER (ORDER BY grhycycs DESC) AS rank , * from uf_personreport where grhycycs is not null and grhycycs != 0 and gjc is null" +
|
||||
" ) rk where rk.rank < " + rownum + ")");
|
||||
return rs.getUpdateCount();
|
||||
}
|
||||
|
||||
//更新登录次数前10%的人
|
||||
private int updateGjcLogin(RecordSet rs, int rownum) {
|
||||
rs.executeUpdate(" update uf_personreport set gjc = '智慧OA最亲密的朋友' where id in( " +
|
||||
" select rk.id from ( " +
|
||||
" select ROW_NUMBER() OVER (ORDER BY ljdloacs DESC) AS rank , * from uf_personreport where ljdloacs is not null and ljdloacs != 0 and gjc is null" +
|
||||
" ) rk where rk.rank < " + rownum + ")");
|
||||
return rs.getUpdateCount();
|
||||
}
|
||||
|
||||
//更新聊天次数前10%的人
|
||||
private int updateGjcMsg(RecordSet rs, int rownum) {
|
||||
rs.executeUpdate(" update uf_personreport set gjc = '社交天花板' where id in( " +
|
||||
" select rk.id from ( " +
|
||||
" select ROW_NUMBER() OVER (ORDER BY grcylts DESC) AS rank , * from uf_personreport where grcylts is not null and grcylts != 0 and gjc is null" +
|
||||
" ) rk where rk.rank < " + rownum + ")");
|
||||
return rs.getUpdateCount();
|
||||
}
|
||||
|
||||
//无关键词的人
|
||||
private int updateGjcNull(RecordSet rs) {
|
||||
rs.executeUpdate(" update uf_personreport set gjc = '智慧OA探索家' where gjc = '' or gjc is null");
|
||||
return rs.getUpdateCount();
|
||||
}
|
||||
|
||||
%>
|
File diff suppressed because it is too large
Load Diff
@ -1,52 +0,0 @@
|
||||
<%@ page import="org.apache.poi.xwpf.usermodel.XWPFDocument" %>
|
||||
<%@ page import="cn.afterturn.easypoi.word.WordExportUtil" %>
|
||||
<%@ page import="java.nio.charset.StandardCharsets" %>
|
||||
<%@ page import="java.io.*" %>
|
||||
<%@ page import="weaver.hrm.User" %>
|
||||
<%@ page import="com.engine.workflow.cmd.requestForm.StatusDataCmd" %>
|
||||
<%@ page import="com.engine.core.interceptor.CommandContext" %>
|
||||
<%@ page import="com.api.workflow.service.RequestAuthenticationService" %>
|
||||
<%@ page import="java.util.*" %>
|
||||
<%@ page import="weaver.conn.RecordSet" %>
|
||||
<%@ page import="weaver.general.Util" %>
|
||||
<%@ page import="com.alibaba.fastjson.JSON" %>
|
||||
<%@ page import="weaver.workflow.monitor.Monitor" %>
|
||||
<%@ page import="weaver.workflow.workflow.WorkflowConfigComInfo" %>
|
||||
<%@ page import="weaver.hrm.resource.ResourceComInfo" %>
|
||||
<%@ page import="weaver.crm.Maint.CustomerInfoComInfo" %>
|
||||
<%@ page import="com.engine.workflow.biz.RobotNode.RobotNodeServiceBiz" %>
|
||||
<%@ page import="weaver.general.TimeUtil" %>
|
||||
<%@ page import="com.api.workflow.util.ServiceUtil" %>
|
||||
<%@ page import="com.engine.workflow.biz.RobotNode.RobotNodeBiz" %>
|
||||
<%@ page import="com.alibaba.fastjson.JSONObject" %>
|
||||
<%@ page import="java.nio.charset.Charset" %>
|
||||
<%@ page import="weaver.rtx.ChangeCharset" %>
|
||||
<%@ page import="weaver.soa.workflow.request.RequestService" %>
|
||||
<%@ page import="weaver.soa.workflow.request.RequestInfo" %>
|
||||
<%@ page import="weaver.interfaces.workflow.action.WorkflowToDoc" %>
|
||||
<%@ page import="weaver.workflow.request.RequestManager" %>
|
||||
<%@ page import="com.engine.custom.archives.action.WorkflowToDocCus" %>
|
||||
<%@ page import="okhttp3.*" %>
|
||||
<%@ page import="weaver.docs.docs.DocRecycleManager" %>
|
||||
|
||||
|
||||
<%
|
||||
response.setCharacterEncoding("utf-8");
|
||||
String requestid = "607615";
|
||||
RequestService requestService = new RequestService();
|
||||
RequestInfo requestInfo = requestService.getRequest(Util.getIntValue(requestid), 100);
|
||||
out.print(JSONObject.toJSONString(requestInfo));
|
||||
%>
|
||||
|
||||
<%!
|
||||
|
||||
public static void deleteDocByid(String docid){
|
||||
DocRecycleManager docRecycleManager=new DocRecycleManager();
|
||||
User user = new User(1);
|
||||
docRecycleManager.moveDocToRecycle(user.getUID(), user.getLogintype(), Util.getIntValue(docid), "127.0.0.1");
|
||||
docRecycleManager.deleteDocFromRecycle(user.getUID(), user.getLogintype(), weaver.general.Util.getIntValue(docid), "127.0.0.1");
|
||||
}
|
||||
|
||||
%>
|
||||
|
||||
|
File diff suppressed because one or more lines are too long
Binary file not shown.
Binary file not shown.
@ -0,0 +1,21 @@
|
||||
|
||||
<%@ page import="weaver.conn.RecordSetDataSource" %>
|
||||
<%@ page import="java.time.LocalDateTime" %>
|
||||
<%@ page import="java.time.format.DateTimeFormatter" %>
|
||||
<%@ page import="com.engine.custom.corn.util.ReportUtil" %>
|
||||
<%@ page import="weaver.conn.RecordSet" %>
|
||||
<%@ page import="org.slf4j.Logger" %>
|
||||
<%@ page import="org.slf4j.LoggerFactory" %>
|
||||
<%@ page language="java" contentType="text/html; charset=UTF-8" %>
|
||||
|
||||
|
||||
<%
|
||||
|
||||
out.print("11111111");
|
||||
Logger log = LoggerFactory.getLogger("Archives");
|
||||
log.error("111111111111111");
|
||||
out.print("2222222222");
|
||||
%>
|
||||
<%!
|
||||
|
||||
%>
|
@ -0,0 +1,69 @@
|
||||
|
||||
|
||||
<%@ page import="java.text.SimpleDateFormat" %>
|
||||
|
||||
<%@ page import="java.util.*" %>
|
||||
<%@ page import="org.slf4j.Logger" %>
|
||||
<%@ page import="org.slf4j.LoggerFactory" %>
|
||||
<%@ page import="com.engine.custom.audit.service.PushAuditService" %>
|
||||
<%@ page import="com.engine.custom.hg.entity.HGBean" %>
|
||||
<%@ page import="weaver.conn.RecordSet" %>
|
||||
<%@ page import="weaver.general.Util" %>
|
||||
<%@ page import="com.alibaba.fastjson.JSONObject" %>
|
||||
<%@ page language="java" contentType="text/html; charset=UTF-8" %>
|
||||
|
||||
|
||||
<%
|
||||
// String getrqBydatesql = "select * from uf_tosjLog where ddsj > ? and ddsj < ? ";
|
||||
// out.print("获取推送审计系统数据start");
|
||||
// RecordSet recordSet = new RecordSet();
|
||||
// recordSet.executeQuery(getrqBydatesql , "2024-04-23 00:00" ,"2024-04-23 24:00");
|
||||
// // out.print("getrqBydatesql=="+getrqBydatesql + startTime + endTime);
|
||||
// ArrayList<HGBean> hgBeans = new ArrayList<>();
|
||||
// while (recordSet.next()){
|
||||
// HGBean hgBean = new HGBean();
|
||||
// hgBean.setId(Util.getIntValue(recordSet.getString("id")));
|
||||
// hgBean.setRequestId(Util.getIntValue(recordSet.getString("request")));
|
||||
// hgBean.setContent(Util.null2String(recordSet.getString("content")));
|
||||
// hgBean.setZt(Util.getIntValue(recordSet.getString("zt")));
|
||||
// hgBean.setDdsj(Util.null2String(recordSet.getString("ddsj")));
|
||||
// hgBean.setTssj(Util.null2String(recordSet.getString("tssj")));
|
||||
// hgBean.setZwid(Util.null2String(recordSet.getString("zwid")));
|
||||
// hgBean.setFjid(Util.null2String(recordSet.getString("fjid")));
|
||||
// String ml = Util.null2String(recordSet.getString("ml"));
|
||||
// hgBean.setMl(Arrays.asList(ml.split(",")));
|
||||
// String fjml = Util.null2String(recordSet.getString("fjml"));
|
||||
// hgBean.setMl(Arrays.asList(fjml.split(",")));
|
||||
// hgBeans.add(hgBean);
|
||||
// out.print("isEnd="+isEnd(hgBean.getRequestId()+""));
|
||||
// }
|
||||
// out.print("数据条数="+hgBeans.size());
|
||||
// out.print(JSONObject.toJSONString(hgBeans));
|
||||
String sql = "select CURRENTNODETYPE,CURRENTNODEID from WORKFLOW_REQUESTBASE where requestid = ?";
|
||||
RecordSet recordSet = new RecordSet();
|
||||
recordSet.executeQuery(sql,"331361");
|
||||
String CURRENTNODETYPE = "";
|
||||
String CURRENTNODEID = "";
|
||||
out.print(recordSet.getCounts());
|
||||
if(recordSet.next()){
|
||||
CURRENTNODETYPE = recordSet.getString("CURRENTNODETYPE");
|
||||
CURRENTNODEID = recordSet.getString("CURRENTNODEID");
|
||||
}
|
||||
out.print(CURRENTNODETYPE);
|
||||
|
||||
%>
|
||||
<%!
|
||||
public static String isEnd(String requestid ){
|
||||
String sql = "select CURRENTNODETYPE,CURRENTNODEID from WORKFLOW_REQUESTBASE where requestid = ?";
|
||||
RecordSet recordSet = new RecordSet();
|
||||
recordSet.execute(sql,requestid);
|
||||
String CURRENTNODETYPE = "";
|
||||
String CURRENTNODEID = "";
|
||||
if(recordSet.next()){
|
||||
CURRENTNODETYPE = recordSet.getString("CURRENTNODETYPE");
|
||||
CURRENTNODEID = recordSet.getString("CURRENTNODEID");
|
||||
}
|
||||
return CURRENTNODETYPE;
|
||||
};
|
||||
|
||||
%>
|
Binary file not shown.
@ -0,0 +1,16 @@
|
||||
<%@ page import="weaver.conn.RecordSet" %>
|
||||
<%@ page import="weaver.general.Util" %>
|
||||
<%@ page import="java.util.*" %>
|
||||
<%@ page import="com.alibaba.fastjson.JSONObject" %>
|
||||
<%@ page import="weaver.workflow.workflow.WorkflowBillComInfo" %>
|
||||
<%@ page language="java" contentType="text/html; charset=UTF-8" %>
|
||||
|
||||
|
||||
<%
|
||||
WorkflowBillComInfo wcInfo = new WorkflowBillComInfo();
|
||||
String createpage = wcInfo.getCreatepage("319334");
|
||||
out.print(createpage);
|
||||
%>
|
||||
<%!
|
||||
|
||||
%>
|
@ -0,0 +1,28 @@
|
||||
package weaver.interfaces.workflow.action.javacode;
|
||||
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.interfaces.workflow.action.Action;
|
||||
import weaver.general.BaseBean;
|
||||
import weaver.soa.workflow.request.RequestInfo;
|
||||
/**
|
||||
* Online custom action interface
|
||||
*/
|
||||
public class Action20240511020255 extends BaseBean implements Action{
|
||||
/**
|
||||
* After selecting aciton after the process path node, this method will be executed after the node is submitted.
|
||||
*/
|
||||
public String execute(RequestInfo request) {
|
||||
|
||||
RecordSet recordSet = new RecordSet();
|
||||
recordSet.executeUpdate("DELETE FROM uf_pushArchivesLog " +
|
||||
"WHERE id NOT IN ( " +
|
||||
" SELECT MIN(id) " +
|
||||
" FROM uf_pushArchivesLog where type = 0 or type = 1 " +
|
||||
" GROUP BY REQUEST " +
|
||||
");");
|
||||
|
||||
|
||||
|
||||
return Action.SUCCESS;
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,712 @@
|
||||
<%@ page import="weaver.conn.RecordSet" %>
|
||||
<%@ page import="weaver.general.BaseBean" %>
|
||||
<%@ page import="com.alibaba.fastjson.JSONObject" %>
|
||||
<%@ page import="com.alibaba.fastjson.JSONArray" %>
|
||||
<%@ page import="weaver.general.Util" %>
|
||||
<%@ page import="cn.hutool.core.util.ZipUtil" %>
|
||||
<%@ page import="com.engine.custom.archives.util.ArchivesUtil" %>
|
||||
<%@ page import="java.text.SimpleDateFormat" %>
|
||||
<%@ page import="com.engine.custom.archives.entity.PushArchivesBean" %>
|
||||
<%@ page import="com.engine.custom.hg.util.HgUtils" %>
|
||||
<%@ page import="com.dcfs.fts.common.error.FtpException" %>
|
||||
<%@ page import="weaver.soa.workflow.request.RequestService" %>
|
||||
<%@ page import="weaver.soa.workflow.request.RequestInfo" %>
|
||||
<%@ page import="weaver.file.ImageFileManager" %>
|
||||
<%@ page import="java.io.*" %>
|
||||
<%@ page import="java.util.*" %>
|
||||
<%@ page import="java.time.format.DateTimeFormatter" %>
|
||||
<%@ page import="java.time.LocalDate" %>
|
||||
<%@ page import="weaver.hrm.User" %>
|
||||
<%@ page import="weaver.hrm.company.DepartmentComInfo" %>
|
||||
<%@ page import="weaver.general.StringUtil" %>
|
||||
<%@ page import="org.apache.commons.lang.StringUtils" %>
|
||||
<%@ page import="weaver.workflow.workflow.WorkflowComInfo" %>
|
||||
<%@ page import="weaver.workflow.workflow.WorkflowBillComInfo" %>
|
||||
<%@ page import="org.slf4j.Logger" %>
|
||||
<%@ page import="org.slf4j.LoggerFactory" %>
|
||||
<%@ page import="com.engine.custom.archives.service.ReceivingPushArchivesService" %>
|
||||
<%@ page import="java.net.URLEncoder" %>
|
||||
<%@ page import="java.nio.charset.StandardCharsets" %>
|
||||
<%@ page import="okhttp3.*" %>
|
||||
<%@ page import="com.engine.common.util.ParamUtil" %>
|
||||
<%@ page language="java" contentType="text/html; charset=UTF-8" %>
|
||||
|
||||
<%
|
||||
|
||||
Map<String, Object> paramMap = ParamUtil.request2Map(request);
|
||||
String requestid = Util.null2String(paramMap.get("requestid"));
|
||||
Logger log = LoggerFactory.getLogger("Archives");
|
||||
log.info("PushArchivesCorn====Begin========");
|
||||
Date date = ArchivesUtil.getDate();
|
||||
String dateStr = new SimpleDateFormat("yyyyMMdd").format(date);
|
||||
ArrayList<PushArchivesBean> pushArchivesBeans = new ArrayList<>();
|
||||
PushArchivesBean pushArchivesBean = new PushArchivesBean();
|
||||
pushArchivesBean.setRequest(Util.getIntValue(requestid));
|
||||
pushArchivesBeans.add(pushArchivesBean);
|
||||
pushArchives(pushArchivesBeans,dateStr);
|
||||
%>
|
||||
|
||||
|
||||
<%!
|
||||
|
||||
private static String filePath = "/opt/oadata/archivesFile";;
|
||||
private static String Url = "http://14.1.213.5:18080/fcscloud/composite/upload" ;
|
||||
private static String templatePath = "/opt/weaver/archivesFile/template/"; // 模板文件路径
|
||||
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 lcfjWord = "流程附件";
|
||||
private static final String qzyjfjWord = "签字意见附件";
|
||||
private static final String xbbmfjWord = "协办部门附件";
|
||||
private static final String wjcldWord = "文件处理单";
|
||||
private static final String wjlzxxWord = "文件流转信息";
|
||||
|
||||
public static Logger log = LoggerFactory.getLogger("Archives");
|
||||
|
||||
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(List<PushArchivesBean> result, String dateStr) {
|
||||
|
||||
try {
|
||||
filePath = filePath + File.separator + dateStr ;
|
||||
ZipUtil zipUtil = new ZipUtil();
|
||||
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(getFirstSecondOfDate(date));
|
||||
// 获取当前时间的最后一秒
|
||||
String lastSecond = yyyyMMddHHmmss.format(getLastSecondOfDate(date));
|
||||
|
||||
|
||||
RecordSet recordSet = new RecordSet();
|
||||
// List<PushArchivesBean> result = ArchivesUtil.getResultList(recordSet, firstSecond, lastSecond, 1);
|
||||
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 requestid = pushArchivesBean.getRequest();
|
||||
try {
|
||||
log.error("requestid:{}", requestid);
|
||||
//1.生成文件及推送的txt
|
||||
String context = extracted(requestid);
|
||||
log.error("context:{}", context);
|
||||
//1.生成文件及推送的txt
|
||||
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(requestid, s);
|
||||
updateRecord(requestid,"esbtxtml",s);
|
||||
updateRecord(requestid,"zt","0");
|
||||
log.error("textZip:{}", s);
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
log.error("推送档案requestid:{}异常,异常原因为:{}",requestid,e.getMessage());
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.info("PushArchivesCorn====Exception========{}", e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void updateRecord(int requestids, String s) {
|
||||
String sql = "update uf_pushArchivesLog set esbtxtml = ? where request in ( " + requestids + " )";
|
||||
RecordSet recordSet = new RecordSet();
|
||||
recordSet.executeUpdate(sql, s);
|
||||
}
|
||||
|
||||
private String extracted(int requestid) throws FtpException, IOException {
|
||||
String newRequestid = "togd"+requestid;
|
||||
RequestService requestService = new RequestService();
|
||||
RequestInfo requestInfo = requestService.getRequest(Util.getIntValue(requestid), 100);
|
||||
String workflowid = requestInfo.getWorkflowid();
|
||||
Map<String, String> requesData = getRequestByid(requestid);
|
||||
log.info("requesData:{}", requesData);
|
||||
String fj = Util.null2String(requesData.get("fj"));
|
||||
String zwkbj = Util.null2String(requesData.get("zwkbj"));
|
||||
String lczw = Util.null2String(requesData.get("lczw"));
|
||||
String gwly = Util.null2String(requesData.get("gwly"));
|
||||
//增加签字意见中的附件到附件文件夹中
|
||||
Map<String, String> signFiles = ArchivesUtil.getSignFiles(requestid,true);
|
||||
List<String> docids = new ArrayList<>();
|
||||
// docids.addAll(Arrays.asList(fj.split(",")));
|
||||
// docids.addAll(Arrays.asList(zwkbj.split(",")));
|
||||
Map<String, String> fjMap = ArchivesUtil.getFileIdByDocId(fj);
|
||||
|
||||
// Map<String, String> zwkbjMap = ArchivesUtil.getFileIdByDocId(zwkbj);
|
||||
// Map<String, String> lczwMap = ArchivesUtil.getFileIdByDocId(lczw);
|
||||
Map<String, String> lczwMap = new HashMap<>();
|
||||
//判断公文来源
|
||||
if ("0".equals(gwly)){
|
||||
lczwMap = ArchivesUtil.getFileIdByDocId(lczw);
|
||||
}else {
|
||||
lczwMap = ArchivesUtil.getFileIdByDocId(zwkbj);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
List<String> zwFileName = new ArrayList<>();
|
||||
List<String> fjFileName = new ArrayList<>();
|
||||
final int[] i = {1};
|
||||
//附件
|
||||
fjMap.forEach((docid, imageid) -> {
|
||||
ImageFileManager imageFileManager = new ImageFileManager();
|
||||
imageFileManager.getImageFileInfoById(Util.getIntValue(imageid));
|
||||
InputStream inputStream = imageFileManager.getInputStream();
|
||||
//中文路径/中文文件名
|
||||
String imageFileName = filePath + File.separator + newRequestid + File.separator + fjdir + File.separator + lcfjWord+ i[0] +"-" + imageFileManager.getImageFileName();
|
||||
fjFileName.add(lcfjWord+ i[0] +"-" + imageFileManager.getImageFileName());
|
||||
log.info("生成附件路径:{}", imageFileName);
|
||||
imageFileName = ArchivesUtil.codeUtf8(imageFileName);
|
||||
try {
|
||||
File file = ArchivesUtil.saveInputStreamToFile(inputStream, imageFileName);
|
||||
String jsonStr = ArchivesUtil.callApi(Url, file);
|
||||
log.error("永中接口返回数据:{}", jsonStr);
|
||||
JSONObject result = JSONObject.parseObject(jsonStr);
|
||||
String errorcode = result.getString("errorcode");
|
||||
if ("0".equals(errorcode)) {
|
||||
JSONObject data = result.getJSONObject("data");
|
||||
String destFileName = data.getString("destFileName");
|
||||
String viewUrl = data.getString("viewUrl");
|
||||
ArchivesUtil.downloadFile(viewUrl, filePath + File.separator + newRequestid + File.separator + fjdir + File.separator + lcfjWord+ i[0] + "-" + imageFileManager.getImageFileName() + ".pdf");
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}finally {
|
||||
if(inputStream!=null) {
|
||||
try {
|
||||
inputStream.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
i[0]++;
|
||||
});
|
||||
i[0] = 1;
|
||||
//签字意见附件
|
||||
signFiles.forEach((docid, imageid) -> {
|
||||
ImageFileManager imageFileManager = new ImageFileManager();
|
||||
imageFileManager.getImageFileInfoById(Util.getIntValue(imageid));
|
||||
InputStream inputStream = imageFileManager.getInputStream();
|
||||
//中文路径/中文文件名
|
||||
String imageFileName = filePath + File.separator + newRequestid + File.separator + fjdir + File.separator + qzyjfjWord + i[0] + "-" +imageFileManager.getImageFileName();
|
||||
fjFileName.add(qzyjfjWord + i[0] + "-" +imageFileManager.getImageFileName());
|
||||
log.info("生成签字意见附件路径:{}", imageFileName);
|
||||
imageFileName = ArchivesUtil.codeUtf8(imageFileName);
|
||||
try {
|
||||
File file = ArchivesUtil.saveInputStreamToFile(inputStream, imageFileName);
|
||||
String jsonStr = ArchivesUtil.callApi(Url, file);
|
||||
log.error("永中接口返回数据:{}", jsonStr);
|
||||
JSONObject result = JSONObject.parseObject(jsonStr);
|
||||
String errorcode = result.getString("errorcode");
|
||||
if ("0".equals(errorcode)) {
|
||||
JSONObject data = result.getJSONObject("data");
|
||||
String destFileName = data.getString("destFileName");
|
||||
String viewUrl = data.getString("viewUrl");
|
||||
ArchivesUtil.downloadFile(viewUrl, filePath + File.separator + newRequestid + File.separator + fjdir + File.separator + qzyjfjWord + i[0] + "-" + imageFileManager.getImageFileName() + ".pdf");
|
||||
}
|
||||
i[0]++;
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}finally {
|
||||
if(inputStream!=null) {
|
||||
try {
|
||||
inputStream.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
i[0] = 1;
|
||||
Map<String, String> coReqFile = getCoReqFile(requestid, workflowid);
|
||||
//协办要求
|
||||
coReqFile.forEach((docid, imageid) -> {
|
||||
ImageFileManager imageFileManager = new ImageFileManager();
|
||||
imageFileManager.getImageFileInfoById(Util.getIntValue(imageid));
|
||||
InputStream inputStream = imageFileManager.getInputStream();
|
||||
zwFileName.add(xbbmfjWord+ i[0] +"-"+ imageFileManager.getImageFileName());
|
||||
//中文路径/中文文件名
|
||||
String imageFileName = filePath + File.separator + newRequestid + File.separator + fjdir + File.separator +xbbmfjWord+ i[0] +"-"+ imageFileManager.getImageFileName();
|
||||
log.info("生成协办部门路径:{}", imageFileName);
|
||||
imageFileName = ArchivesUtil.codeUtf8(imageFileName);
|
||||
try {
|
||||
File file = ArchivesUtil.saveInputStreamToFile(inputStream, imageFileName);
|
||||
String jsonStr = ArchivesUtil.callApi(Url, file);
|
||||
log.error("永中接口返回:{}", jsonStr);
|
||||
JSONObject result = JSONObject.parseObject(jsonStr);
|
||||
String errorcode = result.getString("errorcode");
|
||||
if ("0".equals(errorcode)) {
|
||||
JSONObject data = result.getJSONObject("data");
|
||||
String destFileName = data.getString("destFileName");
|
||||
String viewUrl = data.getString("viewUrl");
|
||||
ArchivesUtil.downloadFile(viewUrl, filePath + File.separator + newRequestid + File.separator + fjdir + File.separator+xbbmfjWord+ i[0] +"-" + imageFileManager.getImageFileName() + ".pdf");
|
||||
}
|
||||
i[0]++;
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}finally {
|
||||
if(inputStream!=null) {
|
||||
try {
|
||||
inputStream.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// i[0] = 1;
|
||||
// //正文
|
||||
// zwkbjMap.forEach((docid, imageid) -> {
|
||||
// ImageFileManager imageFileManager = new ImageFileManager();
|
||||
// imageFileManager.getImageFileInfoById(Util.getIntValue(imageid));
|
||||
// InputStream inputStream = imageFileManager.getInputStream();
|
||||
// zwFileName.add(imageFileManager.getImageFileName());
|
||||
// //中文路径/中文文件名
|
||||
// String imageFileName = filePath + File.separator + newRequestid + File.separator + zwdir + File.separator + imageFileManager.getImageFileName();
|
||||
// log.info("生成正文路径:{}", imageFileName);
|
||||
// imageFileName = ArchivesUtil.codeUtf8(imageFileName);
|
||||
// try {
|
||||
// File file = ArchivesUtil.saveInputStreamToFile(inputStream, imageFileName);
|
||||
// String jsonStr = ArchivesUtil.callApi(Url, file);
|
||||
// log.error("永中接口返回:{}", jsonStr);
|
||||
// JSONObject result = JSONObject.parseObject(jsonStr);
|
||||
// String errorcode = result.getString("errorcode");
|
||||
// if ("0".equals(errorcode)) {
|
||||
// JSONObject data = result.getJSONObject("data");
|
||||
// String destFileName = data.getString("destFileName");
|
||||
// String viewUrl = data.getString("viewUrl");
|
||||
// ArchivesUtil.downloadFile(viewUrl, filePath + File.separator + newRequestid + File.separator + zwdir + File.separator + imageFileManager.getImageFileName() + ".pdf");
|
||||
// }
|
||||
//
|
||||
// } catch (IOException e) {
|
||||
// e.printStackTrace();
|
||||
// }finally {
|
||||
// if(inputStream!=null) {
|
||||
// try {
|
||||
// inputStream.close();
|
||||
// } catch (IOException e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
|
||||
i[0] = 1;
|
||||
//正文
|
||||
lczwMap.forEach((docid, imageid) -> {
|
||||
ImageFileManager imageFileManager = new ImageFileManager();
|
||||
imageFileManager.getImageFileInfoById(Util.getIntValue(imageid));
|
||||
InputStream inputStream = imageFileManager.getInputStream();
|
||||
zwFileName.add(imageFileManager.getImageFileName());
|
||||
//中文路径/中文文件名
|
||||
String imageFileName = filePath + File.separator + newRequestid + File.separator + zwdir + File.separator + imageFileManager.getImageFileName();
|
||||
log.info("生成正文路径:{}", imageFileName);
|
||||
imageFileName = ArchivesUtil.codeUtf8(imageFileName);
|
||||
try {
|
||||
File file = ArchivesUtil.saveInputStreamToFile(inputStream, imageFileName);
|
||||
String jsonStr = ArchivesUtil.callApi(Url, file);
|
||||
log.error("永中接口返回:{}", jsonStr);
|
||||
JSONObject result = JSONObject.parseObject(jsonStr);
|
||||
String errorcode = result.getString("errorcode");
|
||||
if ("0".equals(errorcode)) {
|
||||
JSONObject data = result.getJSONObject("data");
|
||||
String destFileName = data.getString("destFileName");
|
||||
String viewUrl = data.getString("viewUrl");
|
||||
ArchivesUtil.downloadFile(viewUrl, filePath + File.separator + newRequestid + File.separator + zwdir + File.separator + imageFileManager.getImageFileName() + ".pdf");
|
||||
}
|
||||
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}finally {
|
||||
if(inputStream!=null) {
|
||||
try {
|
||||
inputStream.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
//开始承办单 先获取主流程的承办单
|
||||
List<String> requestDocid = ArchivesUtil.generaRequestFormPdf(requestid,1);
|
||||
// 1.去掉生成子流程承办单
|
||||
// List<String> subRequestDocid = generaSubRequestFormPdf(requestid);
|
||||
Map<String, String> reqDocMap = ArchivesUtil.getFileIdByDocId(String.join(",", requestDocid));
|
||||
// 2.去掉生成子流程承办单
|
||||
// Map<String, String> subReqDocMap = getFileIdByDocId(String.join(",", subRequestDocid));
|
||||
log.error("reqDocMap:{}", JSONObject.toJSONString(reqDocMap));
|
||||
//log.error("subReqDocMap:{}", JSONObject.toJSONString(subReqDocMap));
|
||||
docids.addAll(requestDocid);
|
||||
// 3.去掉生成子流程承办单
|
||||
// docids.addAll(subRequestDocid);
|
||||
//承办单
|
||||
reqDocMap.forEach((docid, imageid) -> {
|
||||
ImageFileManager imageFileManager = new ImageFileManager();
|
||||
imageFileManager.getImageFileInfoById(Util.getIntValue(imageid));
|
||||
InputStream inputStream = imageFileManager.getInputStream();
|
||||
//中文路径/中文文件名
|
||||
// String imageFileName = filePath + File.separator + requestid + File.separator + cbddir + File.separator + fjFile + i[0] + "_" + imageFileManager.getImageFileName();
|
||||
String imageFileName = filePath + File.separator + newRequestid + File.separator + cbddir + File.separator + wjcldWord+".pdf";
|
||||
|
||||
log.info("主流程承办单路径:{}", imageFileName);
|
||||
imageFileName = ArchivesUtil.codeUtf8(imageFileName);
|
||||
try {
|
||||
File file = ArchivesUtil.saveInputStreamToFile(inputStream, imageFileName);
|
||||
String jsonStr = ArchivesUtil.callApi(Url, file);
|
||||
log.error("永中接口返回:{}", jsonStr);
|
||||
JSONObject result = JSONObject.parseObject(jsonStr);
|
||||
String errorcode = result.getString("errorcode");
|
||||
if ("0".equals(errorcode)) {
|
||||
JSONObject data = result.getJSONObject("data");
|
||||
String destFileName = data.getString("destFileName");
|
||||
String viewUrl = data.getString("viewUrl");
|
||||
ArchivesUtil.downloadFile(viewUrl, filePath + File.separator + newRequestid + File.separator + cbddir + File.separator + wjcldWord + ".pdf" + ".pdf");
|
||||
}
|
||||
i[0]++;
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}finally {
|
||||
if(inputStream!=null) {
|
||||
try {
|
||||
inputStream.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
//正文
|
||||
|
||||
i[0] = 1;
|
||||
// 4.去掉生成子流程承办单
|
||||
// subReqDocMap.forEach((docid, imageid) -> {
|
||||
// ImageFileManager imageFileManager = new ImageFileManager();
|
||||
// imageFileManager.getImageFileInfoById(Util.getIntValue(imageid));
|
||||
// InputStream inputStream = imageFileManager.getInputStream();
|
||||
// //中文路径/中文文件名
|
||||
// String imageFileName = filePath + File.separator + requestid + File.separator + zlcdir + File.separator + fjFile + i[0] + "_" + (imageFileManager.getImageFileName().contains("-")?imageFileManager.getImageFileName().split("\\-")[1]:imageFileManager.getImageFileName());
|
||||
// imageFileName = codeUtf8(imageFileName);
|
||||
// log.info("子流程承办单路径:{}", imageFileName);
|
||||
// try {
|
||||
// File file = saveInputStreamToFile(inputStream, imageFileName);
|
||||
// String jsonStr = callApi(Url, file);
|
||||
// log.error("永中接口返回:{}", jsonStr);
|
||||
// JSONObject result = JSONObject.parseObject(jsonStr);
|
||||
// String errorcode = result.getString("errorcode");
|
||||
// if ("0".equals(errorcode)) {
|
||||
// JSONObject data = result.getJSONObject("data");
|
||||
// String destFileName = data.getString("destFileName");
|
||||
// String viewUrl = data.getString("viewUrl");
|
||||
// downloadFile(viewUrl, filePath + File.separator + requestid + File.separator + zlcdir + File.separator + fjFile + i[0] + "_" + (imageFileManager.getImageFileName().contains("-")?imageFileManager.getImageFileName().split("\\-")[1]:imageFileManager.getImageFileName() )+ ".pdf");
|
||||
// }
|
||||
// i[0]++;
|
||||
// } catch (IOException e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// });
|
||||
log.error(JSONObject.toJSONString(requestDocid));
|
||||
// log.error(JSONObject.toJSONString(subRequestDocid));
|
||||
for (String docid : docids) {
|
||||
log.error("删除了" + docid);
|
||||
ArchivesUtil.deleteDocByid(docid);
|
||||
}
|
||||
//--------------------------------------------------------------------
|
||||
|
||||
|
||||
String logFile = ArchivesUtil.getSignLog(requestid, cbddir+File.separator+lzxxdir, requestInfo.getCreatorid() + requestInfo.getDescription(),templatePath,filePath,true,workflowid);
|
||||
String s = ArchivesUtil.callApi(Url, new File(logFile));
|
||||
log.error(s);
|
||||
JSONObject result = JSONObject.parseObject(s);
|
||||
String errorcode = result.getString("errorcode");
|
||||
if ("0".equals(errorcode)) {
|
||||
JSONObject data = result.getJSONObject("data");
|
||||
String destFileName = data.getString("destFileName");
|
||||
String viewUrl = data.getString("viewUrl");
|
||||
ArchivesUtil.downloadFile(viewUrl, logFile + ".pdf");
|
||||
}
|
||||
String zipName = filePath + File.separator + newRequestid + ".zip";
|
||||
ZipUtil.zip(filePath + File.separator + newRequestid, zipName);
|
||||
log.error("zipName:{}", zipName);
|
||||
String ftpFilePath = HgUtils.putFile(zipName, newRequestid + ".zip");
|
||||
updateRecord(requestid,"esbwjml",ftpFilePath);
|
||||
log.error("ftpFilePath:{}", ftpFilePath);
|
||||
// String ftpFilePathNew = HgUtils.putFile(zipName, "test" + File.separator + newRequestid + ".zip");
|
||||
// log.error("ftpFilePathNew:{}", ftpFilePathNew);
|
||||
String context = getContext(requestid, requesData, newRequestid + ".zip", zwFileName, fjFileName);
|
||||
// insertRecord(requestid, context, ftpFilePath);
|
||||
log.error("context:{}", context);
|
||||
updateRecord(requestid,"content",context);
|
||||
return context;
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void insertRecord(int requestid, String context, String ftpFilePath) {
|
||||
String sql = "insert into uf_pushArchivesLog (request ,content,esbwjml) VALUES (?,?,?)";
|
||||
RecordSet recordSet = new RecordSet();
|
||||
recordSet.executeUpdate(sql, requestid, context, ftpFilePath);
|
||||
}
|
||||
|
||||
|
||||
// 获取指定日期的第一秒
|
||||
public static Date getFirstSecondOfDate(Date date) {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(date);
|
||||
calendar.set(Calendar.HOUR_OF_DAY, 0);
|
||||
calendar.set(Calendar.MINUTE, 0);
|
||||
calendar.set(Calendar.SECOND, 0);
|
||||
calendar.set(Calendar.MILLISECOND, 0);
|
||||
return calendar.getTime();
|
||||
}
|
||||
|
||||
// 获取指定日期的最后一秒
|
||||
public static Date getLastSecondOfDate(Date date) {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(date);
|
||||
calendar.set(Calendar.HOUR_OF_DAY, 23);
|
||||
calendar.set(Calendar.MINUTE, 59);
|
||||
calendar.set(Calendar.SECOND, 59);
|
||||
calendar.set(Calendar.MILLISECOND, 999);
|
||||
return calendar.getTime();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/***
|
||||
* 封装数据
|
||||
* @param requestid
|
||||
* @return
|
||||
*/
|
||||
public Map<String, String> getRequestByid(int requestid) {
|
||||
HashMap<String, String> record = new HashMap<>();
|
||||
String sql = "select * from formtable_main_30 where requestid = ?";
|
||||
String reqsql = "select REQUESTNAME from WORKFLOW_REQUESTBASE where REQUESTID = ?";
|
||||
RecordSet rs = new RecordSet();
|
||||
rs.executeQuery(sql, requestid);
|
||||
if (rs.next()) {
|
||||
String fj = Util.null2String(rs.getString("fj"));
|
||||
String zwkbj = Util.null2String(rs.getString("zwkbj")); // 正文可编辑字段
|
||||
record.put("fj", fj);
|
||||
record.put("zwkbj", zwkbj);
|
||||
record.put("zwyyglgwmk", Util.null2String(rs.getString("zwyyglgwmk")));
|
||||
record.put("lwh", Util.null2String(rs.getString("lwh")));
|
||||
record.put("mj", Util.null2String(rs.getString("mj")));
|
||||
record.put("lwrq", Util.null2String(rs.getString("lwrq")));
|
||||
record.put("swrq", Util.null2String(rs.getString("swrq")));
|
||||
record.put("blqx", Util.null2String(rs.getString("blqx")));
|
||||
record.put("sfdb", Util.null2String(rs.getString("sfdb")));
|
||||
record.put("wjlx", Util.null2String(rs.getString("wjlx")));
|
||||
record.put("fssj", Util.null2String(rs.getString("fssj")));
|
||||
record.put("gdh", Util.null2String(rs.getString("gdh")));
|
||||
record.put("swh", Util.null2String(rs.getString("swh")));
|
||||
record.put("ngbm", Util.null2String(rs.getString("ngbm")));
|
||||
record.put("ngr", Util.null2String(rs.getString("ngr")));
|
||||
record.put("ngrq", Util.null2String(rs.getString("ngrq")));
|
||||
record.put("swlx", Util.null2String(rs.getString("swlx")));
|
||||
record.put("jghwt", Util.null2String(rs.getString("jghwt")));
|
||||
record.put("lwdwmc", Util.null2String(rs.getString("lwdwmc")));
|
||||
record.put("bgqx", Util.null2String(rs.getString("bgqx")));
|
||||
record.put("ys", Util.null2String(rs.getString("ys")));
|
||||
record.put("wz", Util.null2String(rs.getString("wz")));
|
||||
record.put("lb", Util.null2String(rs.getString("lb")));
|
||||
record.put("bz", Util.null2String(rs.getString("bz")));
|
||||
record.put("yffbm", Util.null2String(rs.getString("yffbm")));
|
||||
record.put("ffbmb", Util.null2String(rs.getString("ffbmb")));
|
||||
record.put("yffbm", Util.null2String(rs.getString("yffbm")));
|
||||
record.put("lczw", Util.null2String(rs.getString("lczw")));
|
||||
record.put("gwly", Util.null2String(rs.getString("gwly")));
|
||||
record.put("lwdwsx", Util.null2String(rs.getString("lwdwsx")));
|
||||
}
|
||||
rs.executeQuery(reqsql, requestid);
|
||||
if (rs.next()) {
|
||||
record.put("REQUESTNAME", Util.null2String(rs.getString("REQUESTNAME")));
|
||||
}
|
||||
return record;
|
||||
}
|
||||
|
||||
|
||||
private String getContext(int requestid, Map<String, String> requesData, String zipName, List<String> zwFileName, List<String> fjFileName) {
|
||||
StringBuilder context = new StringBuilder();
|
||||
try {
|
||||
|
||||
String swrq = Util.null2String(requesData.get("swrq"));
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||
LocalDate date = LocalDate.parse(swrq, formatter);
|
||||
int year = date.getYear();
|
||||
context.append(year).append("|");
|
||||
String jghwt = Util.null2String(requesData.get("jghwt"));
|
||||
context.append(jghwt).append("|");
|
||||
// String swh = Util.null2String(requesData.get("swh"));
|
||||
String swh = Util.null2String(requesData.get("lwh"));
|
||||
context.append(swh).append("|");
|
||||
String requestname = Util.null2String(requesData.get("REQUESTNAME"));
|
||||
context.append(requestname).append("|");
|
||||
String lwdwmc = Util.null2String(requesData.get("lwdwsx")); //5 责任者 -> 来文单位
|
||||
context.append(lwdwmc).append("|");
|
||||
String bgqx = Util.null2String(requesData.get("bgqx")); //6 保管期限 -> 保管期限
|
||||
context.append(bgqx).append("|");
|
||||
String lwrq = Util.null2String(requesData.get("lwrq")); //7 日期 -> 原发文日期
|
||||
context.append(lwrq).append("|");
|
||||
String ys = Util.null2String(requesData.get("ys")); //8 页数 -> 页数
|
||||
context.append(ys).append("|");
|
||||
String wz = Util.null2String(requesData.get("wz")); //9 文种 -> 文种
|
||||
context.append(wz).append("|");
|
||||
String ngbm = Util.null2String(requesData.get("ngbm"));
|
||||
String[] deptData = ArchivesUtil.getDeptNameAndCode(ngbm);
|
||||
String[] subData = ArchivesUtil.getSubCom(ngbm);
|
||||
context.append("D10001").append("|"); //10 行编号 -> 拟稿部门
|
||||
|
||||
context.append("总行机关").append("|"); //11 行名称
|
||||
context.append("").append("|"); // 12 保管期限编号
|
||||
context.append("").append("|"); // 13 保管期限及编号
|
||||
context.append("").append("|"); // 14 是否开放
|
||||
context.append("").append("|"); // 15 互见号
|
||||
String lb = Util.null2String(requesData.get("lb"));
|
||||
context.append(lb).append("|"); //16 类别 -> 类别
|
||||
//TODO
|
||||
String xgbm = Util.null2String(getAssociatedDepts(requesData));
|
||||
context.append(xgbm).append("|"); //17 相关部门 -> 流经部门
|
||||
// String lwh = Util.null2String(requesData.get("lwh"));// 18 收文号 -> 来文文号
|
||||
String lwh = Util.null2String(requesData.get("swh"));// 18 收文号 -> 来文文号
|
||||
context.append(lwh).append("|");
|
||||
String fs = "";
|
||||
context.append(fs).append("|"); // 19 份数 -> 份数
|
||||
String bz = Util.null2String(requesData.get("bz"));
|
||||
context.append(bz).append("|"); // 20 备注 -> 备注
|
||||
String yywh = Util.null2String(requesData.get("yywh"));
|
||||
context.append(yywh).append("|"); // 21 引用文号 -> 引用文号
|
||||
String wjlx = Util.null2String(requesData.get("wjlx"));
|
||||
context.append(wjlx).append("|"); // 22 文件类型 -> 空
|
||||
String fwlx = Util.null2String(requesData.get("fwlx"));
|
||||
context.append(fwlx).append("|"); // 23 文件类型 -> 空
|
||||
String f = Util.null2String(requesData.get("f"));
|
||||
context.append(f).append("|"); // 24 发 -> 空
|
||||
String ngr = Util.null2String(requesData.get("ngr"));
|
||||
context.append(new User(Util.getIntValue(ngr)).getLoginid()).append("|"); // 25 拟稿人 -> 拟稿人
|
||||
context.append(deptData[1]).append("|"); // 26 拟稿部门 -> 拟稿部门名称
|
||||
context.append("收文").append("|"); // 27 公文类型 -> "收文"
|
||||
//TODO
|
||||
context.append(ArchivesUtil.getAssociatedPersons(requestid,true)).append("|"); // 28 相关人员 -> 参与人员
|
||||
context.append("智慧OA").append("|"); // 29 数据来源 -> 数据来源
|
||||
context.append(year).append("|"); // 30 形成年度 -> 年份
|
||||
context.append(String.join("&&", zwFileName)).append("|"); // 31 正文名称
|
||||
context.append(String.join("&&", fjFileName)).append("|"); // 32 附件名称
|
||||
context.append("togd"+requestid).append("|"); // 33 主键
|
||||
context.append("").append("|"); // 34 关联主键
|
||||
context.append("").append("|"); // 35 被关联主键
|
||||
context.append(zipName);// 36 压缩包名称
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
log.error("getContextError:{}", e.getMessage());
|
||||
}
|
||||
|
||||
return context.toString();
|
||||
}
|
||||
|
||||
private String getAssociatedDepts(Map<String, String> requesData) {
|
||||
HashSet<String> records = new HashSet<>();
|
||||
records.addAll(Arrays.asList(Util.null2String(requesData.get("ngbm")).split(",")));
|
||||
records.addAll(Arrays.asList(Util.null2String(requesData.get("ffbm")).split(",")));
|
||||
records.addAll(Arrays.asList(Util.null2String(requesData.get("yffbm")).split(",")));
|
||||
records.addAll(Arrays.asList(Util.null2String(requesData.get("ffbmb")).split(",")));
|
||||
records.addAll(Arrays.asList(Util.null2String(requesData.get("zfbm")).split(",")));
|
||||
ArrayList<String> deptName = new ArrayList<>();
|
||||
DepartmentComInfo departmentComInfo = new DepartmentComInfo();
|
||||
for (String record : records) {
|
||||
try {
|
||||
if (StringUtil.isEmpty(record)){
|
||||
continue;
|
||||
}
|
||||
String departmentName = departmentComInfo.getDepartmentName(record);
|
||||
deptName.add(departmentName);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
return String.join("&&", deptName);
|
||||
}
|
||||
|
||||
private Map<String, String> getCoReqFile(int requestid , String workflowid){
|
||||
RecordSet rs = new RecordSet();
|
||||
rs.executeQuery("select * from uf_ArchivesSet where mainwfid = ?",workflowid);
|
||||
boolean isCo = false;
|
||||
String cowfid = "";
|
||||
String cofield = "";
|
||||
String cofieldid = "";
|
||||
if (rs.next()){
|
||||
cowfid = Util.null2String(rs.getString("cowfid"));
|
||||
if (!StringUtils.isBlank(cowfid)){
|
||||
isCo = true;
|
||||
cofield = Util.null2String(rs.getString("cofield"));
|
||||
cofieldid = Util.null2String(rs.getString("cofieldid"));
|
||||
}
|
||||
}
|
||||
log.info("isCo:{};cowfid:{};cofield:{};cofieldid:{}",isCo,cowfid,cofield,cofieldid);
|
||||
|
||||
|
||||
if(isCo){
|
||||
ArrayList<String> CoSubRequest = new ArrayList<>();
|
||||
Map<String, String> subRequest = ArchivesUtil.getSubRequest(Util.null2String(requestid) , 6);
|
||||
log.info("subRequest:{}",subRequest);
|
||||
for (Map.Entry<String, String> subRequestEntry : subRequest.entrySet()) {
|
||||
String subWFid = subRequestEntry.getValue();
|
||||
if (cowfid.equals(subWFid)){
|
||||
CoSubRequest.add(subRequestEntry.getKey());
|
||||
}
|
||||
}
|
||||
log.info("CoSubRequest.size:{}",CoSubRequest.size());
|
||||
WorkflowComInfo wf = new WorkflowComInfo();
|
||||
WorkflowBillComInfo wcInfo = new WorkflowBillComInfo();
|
||||
String formId = wf.getFormId(cowfid);
|
||||
String tablename = wcInfo.getTablename(formId);
|
||||
String cosql = "select "+cofield+" from " + tablename + " where " +
|
||||
" requestid in ( " + String.join(",",CoSubRequest) + " ) " +
|
||||
" order by requestid asc ";
|
||||
log.info("cosql:{}",cosql);
|
||||
|
||||
rs.executeQuery(cosql);
|
||||
log.info("rs.getExceptionMsg():{}",rs.getExceptionMsg());
|
||||
String fieldValue = "";
|
||||
String[] cofieldsplit = cofield.split(",");
|
||||
String coFile = cofieldsplit[2]; //协办部门
|
||||
ArrayList<String> docids = new ArrayList<>();
|
||||
while (rs.next()){
|
||||
String coFileValue = rs.getString(coFile);
|
||||
docids.addAll(Arrays.asList(coFileValue.split(",")));
|
||||
}
|
||||
log.info("fieldValue:{}",fieldValue);
|
||||
return ArchivesUtil.getFileIdByDocId(String.join(",",docids));
|
||||
}
|
||||
return new HashMap<>();
|
||||
}
|
||||
|
||||
private void updateRecord(int requestid, String field , String fieldvalue) {
|
||||
String sql = "update uf_pushArchivesLog set "+field+" = ? where request = ?";
|
||||
RecordSet recordSet = new RecordSet();
|
||||
recordSet.executeUpdate(sql, fieldvalue, requestid);
|
||||
}
|
||||
%>
|
||||
|
@ -0,0 +1,618 @@
|
||||
<%@ page import="weaver.conn.RecordSet" %>
|
||||
<%@ page import="weaver.general.BaseBean" %>
|
||||
<%@ page import="weaver.general.Util" %>
|
||||
<%@ page import="com.alibaba.fastjson.JSONObject" %>
|
||||
<%@ page import="com.alibaba.fastjson.JSONArray" %>
|
||||
<%@ page import="java.util.regex.Pattern" %>
|
||||
<%@ page import="java.util.regex.Matcher" %>
|
||||
<%@ page import="java.io.*" %>
|
||||
<%@ page import="weaver.docs.webservices.DocInfo" %>
|
||||
<%@ page import="weaver.docs.webservices.DocAttachment" %>
|
||||
<%@ page import="org.apache.axis.encoding.Base64" %>
|
||||
<%@ page import="weaver.docs.webservices.DocServiceImpl" %>
|
||||
<%@ page import="weaver.hrm.User" %>
|
||||
<%@ page import="java.text.SimpleDateFormat" %>
|
||||
<%@ page import="java.util.*" %>
|
||||
<%@ page import="org.apache.commons.lang.StringUtils" %>
|
||||
<%@ page language="java" contentType="text/html; charset=UTF-8"%>
|
||||
<%@ page import="org.apache.http.impl.client.CloseableHttpClient" %>
|
||||
<%@ page import="org.apache.http.impl.client.HttpClients" %>
|
||||
<%@ page import="org.apache.http.client.methods.HttpPost" %>
|
||||
<%@ page import="com.alibaba.fastjson.JSON" %>
|
||||
<%@ page import="org.apache.http.entity.StringEntity" %>
|
||||
<%@ page import="org.apache.http.client.methods.CloseableHttpResponse" %>
|
||||
<%@ page import="org.apache.http.HttpStatus" %>
|
||||
<%@ page import="org.apache.http.HttpEntity" %>
|
||||
<%@ page import="org.apache.http.util.EntityUtils" %>
|
||||
<%@ page import="org.apache.http.client.ClientProtocolException" %>
|
||||
<%@ page import="weaver.hrm.HrmUserVarify" %>
|
||||
<%@ page import="java.net.URL" %>
|
||||
<%@ page import="java.net.HttpURLConnection" %>
|
||||
<%@ page import="org.apache.http.HttpException" %>
|
||||
<%@ page import="org.apache.http.client.HttpClient" %>
|
||||
<%@ page import="org.apache.commons.httpclient.methods.PostMethod" %>
|
||||
<%@ page import="org.apache.commons.httpclient.params.HttpMethodParams" %>
|
||||
<%@ page import="org.slf4j.Logger" %>
|
||||
<%@ page import="org.slf4j.LoggerFactory" %>
|
||||
<%@ page import="com.engine.custom.archives.util.ArchivesUtil" %>
|
||||
<%@ page import="com.engine.custom.archives.entity.PushArchivesBean" %>
|
||||
<%@ page import="com.engine.custom.hg.util.HgUtils" %>
|
||||
<%@ page import="com.dcfs.fts.common.error.FtpException" %>
|
||||
<%@ page import="weaver.file.ImageFileManager" %>
|
||||
<%@ page import="weaver.soa.workflow.request.RequestService" %>
|
||||
<%@ page import="weaver.soa.workflow.request.RequestInfo" %>
|
||||
<%@ page import="cn.hutool.core.util.ZipUtil" %>
|
||||
<%@ page import="weaver.hrm.company.DepartmentComInfo" %>
|
||||
<%@ page import="java.time.format.DateTimeFormatter" %>
|
||||
<%@ page import="java.time.LocalDate" %>
|
||||
<%@ page import="weaver.general.StringUtil" %>
|
||||
<%@ page import="java.net.URLEncoder" %>
|
||||
<%@ page import="java.nio.charset.StandardCharsets" %>
|
||||
<%@ page import="okhttp3.*" %>
|
||||
<%@ page import="com.engine.common.util.ParamUtil" %>
|
||||
|
||||
<%
|
||||
Map<String, Object> paramMap = ParamUtil.request2Map(request);
|
||||
String requestid = Util.null2String(paramMap.get("requestid"));
|
||||
Logger log = LoggerFactory.getLogger("Archives");
|
||||
log.info("PushArchivesCorn====Begin========");
|
||||
Date date = ArchivesUtil.getDate();
|
||||
String dateStr = new SimpleDateFormat("yyyyMMdd").format(date);
|
||||
ArrayList<PushArchivesBean> pushArchivesBeans = new ArrayList<>();
|
||||
PushArchivesBean pushArchivesBean = new PushArchivesBean();
|
||||
pushArchivesBean.setRequest(Util.getIntValue(requestid));
|
||||
pushArchivesBeans.add(pushArchivesBean);
|
||||
pushArchives(pushArchivesBeans,dateStr);
|
||||
|
||||
%>
|
||||
|
||||
<%!
|
||||
public static Logger log = LoggerFactory.getLogger("Archives");
|
||||
private static String filePath = "/opt/oadata/archivesFile";;
|
||||
private static String Url = "http://14.1.213.5:18080/fcscloud/composite/upload" ;
|
||||
private static String templatePath = "/opt/weaver/archivesFile/template/"; // 模板文件路径
|
||||
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(List<PushArchivesBean> result, String dateStr) {
|
||||
// log.info("PushArchivesCorn====Begin========{}", param);
|
||||
filePath = filePath + File.separator + dateStr ;
|
||||
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);
|
||||
if ("-1".equals(context)){
|
||||
continue;
|
||||
}
|
||||
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,"esbtxtml",s);
|
||||
updateRecord(request,"zt","0");
|
||||
log.error("textZip:{}", s);
|
||||
} catch (FtpException e) {
|
||||
e.printStackTrace();
|
||||
log.error("推送档案requestid:{}异常,异常原因为:{}",request,e.getMessage());
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
log.error("推送档案requestid:{}异常,异常原因为:{}",request,e.getMessage());
|
||||
} catch (Exception e){
|
||||
e.printStackTrace();
|
||||
log.error("推送档案requestid:{}异常,异常原因为:{}",request,e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
private String generateFile(int requestid) throws FtpException, IOException {
|
||||
Map<String, String> requesData = getRequestByid(requestid);
|
||||
String newRequestid = "togd"+requestid;
|
||||
log.info("requesData:{}", requesData);
|
||||
String bh = requesData.get("bh");
|
||||
if (StringUtil.isEmpty(bh)){
|
||||
return "-1";
|
||||
}
|
||||
String fj = Util.null2String(requesData.get("fj"));
|
||||
String dwd = Util.null2String(requesData.get("dwd"));
|
||||
String zw = Util.null2String(requesData.get("zw"));
|
||||
String qgqhj = Util.null2String(requesData.get("qgqhj"));
|
||||
String thhlh = Util.null2String(requesData.get("thhlh"));
|
||||
|
||||
|
||||
//增加签字意见中的附件到附件文件夹中
|
||||
Map<String, String> signFiles = ArchivesUtil.getSignFiles(requestid,false);
|
||||
List<String> docids = new ArrayList<>();
|
||||
// docids.addAll(Arrays.asList(fj.split(",")));
|
||||
// docids.addAll(Arrays.asList(zwkbj.split(",")));
|
||||
Map<String, String> fjMap = ArchivesUtil.getFileIdByDocId(fj);
|
||||
Map<String, String> dwdMap = ArchivesUtil.getFileIdByDocId(dwd);
|
||||
Map<String, String> zwMap = ArchivesUtil.getFileIdByDocId(zw);
|
||||
Map<String, String> qgqhjMap = ArchivesUtil.getFileIdByDocId(qgqhj);
|
||||
Map<String, String> thhlhMap = ArchivesUtil.getFileIdByDocId(thhlh);
|
||||
List<String> zwFileName = new ArrayList<>();
|
||||
List<String> fjFileName = new ArrayList<>();
|
||||
final int[] i = {1};
|
||||
//附件
|
||||
fjMap.forEach((docid, imageid) -> {
|
||||
ImageFileManager imageFileManager = new ImageFileManager();
|
||||
imageFileManager.getImageFileInfoById(Util.getIntValue(imageid));
|
||||
InputStream inputStream = imageFileManager.getInputStream();
|
||||
//中文路径/中文文件名
|
||||
String imageFileName = filePath + File.separator + newRequestid + File.separator + fjdir + File.separator + lcfjWord + "-" +imageFileManager.getImageFileName();
|
||||
fjFileName.add(lcfjWord + "-" +imageFileManager.getImageFileName());
|
||||
log.info("生成附件路径:{}", imageFileName);
|
||||
imageFileName = ArchivesUtil.codeUtf8(imageFileName);
|
||||
try {
|
||||
File file = ArchivesUtil.saveInputStreamToFile(inputStream, imageFileName);
|
||||
String jsonStr = ArchivesUtil.callApi(Url, file);
|
||||
log.error("永中接口返回数据:{}", jsonStr);
|
||||
JSONObject result = JSONObject.parseObject(jsonStr);
|
||||
String errorcode = result.getString("errorcode");
|
||||
if ("0".equals(errorcode)) {
|
||||
JSONObject data = result.getJSONObject("data");
|
||||
String destFileName = data.getString("destFileName");
|
||||
String viewUrl = data.getString("viewUrl");
|
||||
ArchivesUtil.downloadFile(viewUrl, filePath + File.separator + newRequestid + File.separator + fjdir + File.separator + lcfjWord + "-" + imageFileManager.getImageFileName() + ".pdf");
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}finally {
|
||||
if(inputStream!=null) {
|
||||
try {
|
||||
inputStream.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
//签字意见附件
|
||||
signFiles.forEach((docid, imageid) -> {
|
||||
ImageFileManager imageFileManager = new ImageFileManager();
|
||||
imageFileManager.getImageFileInfoById(Util.getIntValue(imageid));
|
||||
InputStream inputStream = imageFileManager.getInputStream();
|
||||
//中文路径/中文文件名
|
||||
String imageFileName = filePath + File.separator + newRequestid + File.separator + fjdir + File.separator + qzyjfjWord+ "-" +imageFileManager.getImageFileName();
|
||||
fjFileName.add(qzyjfjWord+ "-" +imageFileManager.getImageFileName());
|
||||
log.info("生成签字意见附件路径:{}", imageFileName);
|
||||
imageFileName = ArchivesUtil.codeUtf8(imageFileName);
|
||||
try {
|
||||
File file = ArchivesUtil.saveInputStreamToFile(inputStream, imageFileName);
|
||||
String jsonStr = ArchivesUtil.callApi(Url, file);
|
||||
log.error("永中接口返回数据:{}", jsonStr);
|
||||
JSONObject result = JSONObject.parseObject(jsonStr);
|
||||
String errorcode = result.getString("errorcode");
|
||||
if ("0".equals(errorcode)) {
|
||||
JSONObject data = result.getJSONObject("data");
|
||||
String destFileName = data.getString("destFileName");
|
||||
String viewUrl = data.getString("viewUrl");
|
||||
ArchivesUtil.downloadFile(viewUrl, filePath + File.separator + newRequestid + File.separator + fjdir + File.separator + qzyjfjWord+ "-" + imageFileManager.getImageFileName() + ".pdf");
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}finally {
|
||||
if(inputStream!=null) {
|
||||
try {
|
||||
inputStream.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
//多文档
|
||||
// dwdMap.forEach((docid, imageid) -> {
|
||||
// ImageFileManager imageFileManager = new ImageFileManager();
|
||||
// imageFileManager.getImageFileInfoById(Util.getIntValue(imageid));
|
||||
// InputStream inputStream = imageFileManager.getInputStream();
|
||||
// zwFileName.add(imageFileManager.getImageFileName());
|
||||
// //中文路径/中文文件名
|
||||
// String imageFileName = filePath + File.separator + requestid + File.separator + zwdir + File.separator + fjWord + i[0] + "_" + zwWord + "_" + imageFileManager.getImageFileName();
|
||||
// log.info("生成多文档路径:{}", imageFileName);
|
||||
// imageFileName = ArchivesUtil.codeUtf8(imageFileName);
|
||||
// try {
|
||||
// File file = ArchivesUtil.saveInputStreamToFile(inputStream, imageFileName);
|
||||
// String jsonStr = ArchivesUtil.callApi(Url, file);
|
||||
// log.error("永中接口返回:{}", jsonStr);
|
||||
// JSONObject result = JSONObject.parseObject(jsonStr);
|
||||
// String errorcode = result.getString("errorcode");
|
||||
// if ("0".equals(errorcode)) {
|
||||
// JSONObject data = result.getJSONObject("data");
|
||||
// String destFileName = data.getString("destFileName");
|
||||
// String viewUrl = data.getString("viewUrl");
|
||||
// ArchivesUtil.downloadFile(viewUrl, filePath + File.separator + requestid + File.separator + zwdir + File.separator + fjWord + i[0] + "_" + zwWord + "_" + imageFileManager.getImageFileName() + ".pdf");
|
||||
// }
|
||||
// } catch (IOException e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// i[0]++;
|
||||
// });
|
||||
//正文
|
||||
zwMap.forEach((docid, imageid) -> {
|
||||
ImageFileManager imageFileManager = new ImageFileManager();
|
||||
imageFileManager.getImageFileInfoById(Util.getIntValue(imageid));
|
||||
InputStream inputStream = imageFileManager.getInputStream();
|
||||
|
||||
String newFile = fjWord + i[0] + "_" + zwWord + "-" + imageFileManager.getImageFileName();
|
||||
//中文路径/中文文件名
|
||||
String imageFileName = filePath + File.separator + newRequestid + File.separator + zwdir + File.separator + newFile;
|
||||
zwFileName.add(newFile);
|
||||
log.info("生成正文路径:{}", imageFileName);
|
||||
imageFileName = ArchivesUtil.codeUtf8(imageFileName);
|
||||
try {
|
||||
File file = ArchivesUtil.saveInputStreamToFile(inputStream, imageFileName);
|
||||
String jsonStr = ArchivesUtil.callApi(Url, file);
|
||||
log.error("永中接口返回:{}", jsonStr);
|
||||
JSONObject result = JSONObject.parseObject(jsonStr);
|
||||
String errorcode = result.getString("errorcode");
|
||||
if ("0".equals(errorcode)) {
|
||||
JSONObject data = result.getJSONObject("data");
|
||||
String destFileName = data.getString("destFileName");
|
||||
String viewUrl = data.getString("viewUrl");
|
||||
ArchivesUtil.downloadFile(viewUrl, filePath + File.separator + newRequestid + File.separator + zwdir + File.separator + newFile + ".pdf");
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}finally {
|
||||
if(inputStream!=null) {
|
||||
try {
|
||||
inputStream.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
i[0]++;
|
||||
});
|
||||
//清稿前痕迹
|
||||
qgqhjMap.forEach((docid, imageid) -> {
|
||||
ImageFileManager imageFileManager = new ImageFileManager();
|
||||
imageFileManager.getImageFileInfoById(Util.getIntValue(imageid));
|
||||
InputStream inputStream = imageFileManager.getInputStream();
|
||||
|
||||
String newFile = fjWord + i[0] + "_" + lhgWord + "-" + imageFileManager.getImageFileName();
|
||||
zwFileName.add(newFile);
|
||||
//中文路径/中文文件名
|
||||
String imageFileName = filePath + File.separator + newRequestid + File.separator + zwdir + File.separator + newFile;
|
||||
log.info("生成清稿前痕迹路径:{}", imageFileName);
|
||||
imageFileName = ArchivesUtil.codeUtf8(imageFileName);
|
||||
try {
|
||||
File file = ArchivesUtil.saveInputStreamToFile(inputStream, imageFileName);
|
||||
String jsonStr = ArchivesUtil.callApi(Url, file);
|
||||
log.error("永中接口返回:{}", jsonStr);
|
||||
JSONObject result = JSONObject.parseObject(jsonStr);
|
||||
String errorcode = result.getString("errorcode");
|
||||
if ("0".equals(errorcode)) {
|
||||
JSONObject data = result.getJSONObject("data");
|
||||
String destFileName = data.getString("destFileName");
|
||||
String viewUrl = data.getString("viewUrl");
|
||||
ArchivesUtil.downloadFile(viewUrl, filePath + File.separator + newRequestid + File.separator + zwdir + File.separator + newFile + ".pdf");
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}finally {
|
||||
if(inputStream!=null) {
|
||||
try {
|
||||
inputStream.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
i[0]++;
|
||||
});
|
||||
//套红后留痕
|
||||
// thhlhMap.forEach((docid, imageid) -> {
|
||||
// ImageFileManager imageFileManager = new ImageFileManager();
|
||||
// imageFileManager.getImageFileInfoById(Util.getIntValue(imageid));
|
||||
// InputStream inputStream = imageFileManager.getInputStream();
|
||||
// zwFileName.add(imageFileManager.getImageFileName());
|
||||
// //中文路径/中文文件名
|
||||
// String imageFileName = filePath + File.separator + requestid + File.separator + zwdir + File.separator + fjWord + i[0] + "_" + lhgWord + "_" + imageFileManager.getImageFileName();
|
||||
// log.info("生成套红后留痕路径:{}", imageFileName);
|
||||
// imageFileName = ArchivesUtil.codeUtf8(imageFileName);
|
||||
// try {
|
||||
// File file = ArchivesUtil.saveInputStreamToFile(inputStream, imageFileName);
|
||||
// String jsonStr = ArchivesUtil.callApi(Url, file);
|
||||
// log.error("永中接口返回:{}", jsonStr);
|
||||
// JSONObject result = JSONObject.parseObject(jsonStr);
|
||||
// String errorcode = result.getString("errorcode");
|
||||
// if ("0".equals(errorcode)) {
|
||||
// JSONObject data = result.getJSONObject("data");
|
||||
// String destFileName = data.getString("destFileName");
|
||||
// String viewUrl = data.getString("viewUrl");
|
||||
// ArchivesUtil.downloadFile(viewUrl, filePath + File.separator + requestid + File.separator + zwdir + File.separator + fjWord + i[0] + "_" + lhgWord + "_" + imageFileManager.getImageFileName() + ".pdf");
|
||||
// }
|
||||
// } catch (IOException e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// i[0]++;
|
||||
// });
|
||||
|
||||
//开始承办单 先获取主流程的承办单
|
||||
List<String> requestDocid = ArchivesUtil.generaRequestFormPdf(requestid, 0);
|
||||
// 1.去掉生成子流程承办单
|
||||
// List<String> subRequestDocid = generaSubRequestFormPdf(requestid);
|
||||
Map<String, String> reqDocMap = ArchivesUtil.getFileIdByDocId(String.join(",", requestDocid));
|
||||
// 2.去掉生成子流程承办单
|
||||
// Map<String, String> subReqDocMap = getFileIdByDocId(String.join(",", subRequestDocid));
|
||||
log.error("reqDocMap:{}", JSONObject.toJSONString(reqDocMap));
|
||||
//log.error("subReqDocMap:{}", JSONObject.toJSONString(subReqDocMap));
|
||||
docids.addAll(requestDocid);
|
||||
// 3.去掉生成子流程承办单
|
||||
// docids.addAll(subRequestDocid);
|
||||
i[0] = 1;
|
||||
//主流程承办单
|
||||
reqDocMap.forEach((docid, imageid) -> {
|
||||
ImageFileManager imageFileManager = new ImageFileManager();
|
||||
imageFileManager.getImageFileInfoById(Util.getIntValue(imageid));
|
||||
InputStream inputStream = imageFileManager.getInputStream();
|
||||
//中文路径/中文文件名
|
||||
// String imageFileName = filePath + File.separator + requestid + File.separator + cbddir + File.separator + fjFile + i[0] + "_" + imageFileManager.getImageFileName();
|
||||
// String imageFileName = filePath + File.separator + newRequestid + File.separator + cbddir + File.separator + fjFile + i[0] + "_" + wjcldWord+".pdf";
|
||||
String imageFileName = filePath + File.separator + newRequestid + File.separator + cbddir + File.separator + wjcldWord+".pdf";
|
||||
log.info("主流程承办单路径:{}", imageFileName);
|
||||
imageFileName = ArchivesUtil.codeUtf8(imageFileName);
|
||||
try {
|
||||
File file = ArchivesUtil.saveInputStreamToFile(inputStream, imageFileName);
|
||||
String jsonStr = ArchivesUtil.callApi(Url, file);
|
||||
log.error("永中接口返回:{}", jsonStr);
|
||||
JSONObject result = JSONObject.parseObject(jsonStr);
|
||||
String errorcode = result.getString("errorcode");
|
||||
if ("0".equals(errorcode)) {
|
||||
JSONObject data = result.getJSONObject("data");
|
||||
String destFileName = data.getString("destFileName");
|
||||
String viewUrl = data.getString("viewUrl");
|
||||
ArchivesUtil.downloadFile(viewUrl, filePath + File.separator + newRequestid + File.separator + cbddir + File.separator + wjcldWord + ".pdf" + ".pdf");
|
||||
}
|
||||
i[0]++;
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}finally {
|
||||
if(inputStream!=null) {
|
||||
try {
|
||||
inputStream.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
//正文
|
||||
|
||||
|
||||
log.error(JSONObject.toJSONString(requestDocid));
|
||||
for (String docid : docids) {
|
||||
log.error("删除了" + docid);
|
||||
ArchivesUtil.deleteDocByid(docid);
|
||||
}
|
||||
//--------------------------------------------------------------------
|
||||
RequestService requestService = new RequestService();
|
||||
RequestInfo requestInfo = requestService.getRequest(Util.getIntValue(requestid), 100);
|
||||
String workflowid = requestInfo.getWorkflowid();
|
||||
String logFile = ArchivesUtil.getSignLog(requestid, cbddir + File.separator + lzxxdir, requestInfo.getCreatorid() + requestInfo.getDescription(), templatePath, filePath,false,workflowid);
|
||||
String s = ArchivesUtil.callApi(Url, new File(logFile));
|
||||
log.error(s);
|
||||
JSONObject result = JSONObject.parseObject(s);
|
||||
String errorcode = result.getString("errorcode");
|
||||
if ("0".equals(errorcode)) {
|
||||
JSONObject data = result.getJSONObject("data");
|
||||
String destFileName = data.getString("destFileName");
|
||||
String viewUrl = data.getString("viewUrl");
|
||||
ArchivesUtil.downloadFile(viewUrl, logFile + ".pdf");
|
||||
}
|
||||
String zipName = filePath + File.separator + newRequestid + ".zip";
|
||||
ZipUtil.zip(filePath + File.separator + newRequestid, zipName);
|
||||
log.error("zipName:{}", zipName);
|
||||
String ftpFilePath = HgUtils.putFile(zipName, newRequestid + ".zip");
|
||||
log.error("ftpFilePath:{}", ftpFilePath);
|
||||
updateRecord(requestid,"esbwjml",ftpFilePath);
|
||||
// String ftpFilePathNew = HgUtils.putFile(zipName, "test" + File.separator + requestid + ".zip");
|
||||
// log.error("ftpFilePathNew:{}", ftpFilePathNew);
|
||||
String context = getContext(requestid, requesData, newRequestid + ".zip", zwFileName, fjFileName);
|
||||
// insertRecord(requestid, context, ftpFilePath);
|
||||
updateRecord(requestid,"content",context);
|
||||
log.error("context:{}", context);
|
||||
return context;
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
* 封装数据
|
||||
* @param requestid
|
||||
* @return
|
||||
*/
|
||||
public Map<String, String> getRequestByid(int requestid) {
|
||||
HashMap<String, String> record = new HashMap<>();
|
||||
String sql = "select * from formtable_main_11 where requestid = ?";
|
||||
String reqsql = "select REQUESTNAME from WORKFLOW_REQUESTBASE where REQUESTID = ?";
|
||||
RecordSet rs = new RecordSet();
|
||||
rs.executeQuery(sql, requestid);
|
||||
if (rs.next()) {
|
||||
record.put("fj", Util.null2String(rs.getString("fj")));
|
||||
record.put("dwd", Util.null2String(rs.getString("dwd")));
|
||||
record.put("zw", Util.null2String(rs.getString("zw")));
|
||||
record.put("ngrq", Util.null2String(rs.getString("ngrq")));
|
||||
record.put("jghwt", Util.null2String(rs.getString("jghwt")));
|
||||
record.put("bh", Util.null2String(rs.getString("bh")));
|
||||
record.put("ngbm", Util.null2String(rs.getString("ngbm")));
|
||||
record.put("bgqx", Util.null2String(rs.getString("bgqx")));
|
||||
record.put("cwrq", Util.null2String(rs.getString("cwrq")));
|
||||
record.put("ys", Util.null2String(rs.getString("ys")));
|
||||
record.put("wz", Util.null2String(rs.getString("wz")));
|
||||
record.put("ngbm", Util.null2String(rs.getString("ngbm")));
|
||||
record.put("lb", Util.null2String(rs.getString("lb")));
|
||||
record.put("bz", Util.null2String(rs.getString("bz")));
|
||||
record.put("yywh", Util.null2String(rs.getString("yywh")));
|
||||
record.put("wjlx", Util.null2String(rs.getString("wjlx")));
|
||||
record.put("fwlx", Util.null2String(rs.getString("fwlx")));
|
||||
record.put("f", Util.null2String(rs.getString("f")));
|
||||
record.put("ngr", Util.null2String(rs.getString("ngr")));
|
||||
record.put("qgqhj", Util.null2String(rs.getString("qgqhj")));
|
||||
record.put("thhlh", Util.null2String(rs.getString("thhlh")));
|
||||
|
||||
}
|
||||
rs.executeQuery(reqsql, requestid);
|
||||
if (rs.next()) {
|
||||
record.put("REQUESTNAME", Util.null2String(rs.getString("REQUESTNAME")));
|
||||
}
|
||||
return record;
|
||||
}
|
||||
|
||||
private String getContext(int requestid, Map<String, String> requesData, String zipName, List<String> zwFileName, List<String> fjFileName) {
|
||||
StringBuilder context = new StringBuilder();
|
||||
try {
|
||||
DepartmentComInfo departmentComInfo = new DepartmentComInfo();
|
||||
String ngrq = Util.null2String(requesData.get("ngrq")); //拟稿日期
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||
LocalDate date = LocalDate.parse(ngrq, formatter);
|
||||
int year = date.getYear();
|
||||
context.append(year).append("|"); //1.年度 -> 拟稿日期
|
||||
String jghwt = Util.null2String(requesData.get("jghwt"));//2.机构或问题 -> 机构或问题
|
||||
context.append(jghwt).append("|");
|
||||
String bh = Util.null2String(requesData.get("bh"));// 3.文号 -> 编号
|
||||
context.append(bh).append("|");
|
||||
String requestname = Util.null2String(requesData.get("REQUESTNAME")); // 4.文件题名 -> 流程名称
|
||||
context.append(requestname).append("|");
|
||||
String ngbmName = Util.null2String(departmentComInfo.getDepartmentname(requesData.get("ngbm"))); //5 责任者 -> 拟稿部门
|
||||
context.append(ngbmName).append("|");
|
||||
String bgqx = Util.null2String(requesData.get("bgqx")); //6 保管期限 -> 保管期限
|
||||
context.append(bgqx).append("|");
|
||||
String cwrq = Util.null2String(requesData.get("cwrq")); //7 日期 -> 成文日期
|
||||
context.append(cwrq).append("|");
|
||||
String ys = Util.null2String(requesData.get("ys")); //8 页数 -> 页数
|
||||
context.append(ys).append("|");
|
||||
String wz = Util.null2String(requesData.get("wz")); //9 文种 -> 文种
|
||||
context.append(wz).append("|");
|
||||
String ngbm = Util.null2String(requesData.get("ngbm"));
|
||||
String[] deptData = ArchivesUtil.getDeptNameAndCode(ngbm);
|
||||
String[] subData = ArchivesUtil.getSubCom(ngbm);
|
||||
context.append("D10001").append("|"); //10 行编号 -> 拟稿部门
|
||||
|
||||
context.append("总行机关").append("|"); //11 行名称
|
||||
context.append("").append("|"); // 12 保管期限编号
|
||||
context.append("").append("|"); // 13 保管期限及编号
|
||||
context.append("").append("|"); // 14 是否开放
|
||||
context.append("").append("|"); // 15 互见号
|
||||
String lb = Util.null2String(requesData.get("lb"));
|
||||
context.append(lb).append("|"); //16 类别 -> 类别
|
||||
//TODO
|
||||
String xgbm = Util.null2String(getAssociatedDepts(requesData));
|
||||
context.append(xgbm).append("|"); //17 相关部门 -> 流经部门
|
||||
// String lwh = Util.null2String(requesData.get("lwh"));
|
||||
context.append("").append("|");// 18 收文号 -> 空
|
||||
String fs = "";
|
||||
context.append(fs).append("|"); // 19 份数 -> 份数
|
||||
String bz = Util.null2String(requesData.get("bz"));
|
||||
context.append("").append("|"); // 20 备注 -> 备注
|
||||
String yywh = Util.null2String(requesData.get("yywh"));
|
||||
context.append("").append("|"); // 21 引用文号 -> 引用文号
|
||||
String wjlx = Util.null2String(requesData.get("wjlx"));
|
||||
context.append("").append("|"); // 22 文件类型 -> 空
|
||||
String fwlx = Util.null2String(requesData.get("fwlx"));
|
||||
context.append("总行发文").append("|"); // 23 发文类型 -> 空
|
||||
String f = Util.null2String(requesData.get("f"));
|
||||
context.append(f).append("|"); // 24 发 -> 空
|
||||
String ngr = Util.null2String(requesData.get("ngr"));
|
||||
context.append(new User(Util.getIntValue(ngr)).getLoginid()).append("|"); // 25 拟稿人 -> 拟稿人
|
||||
context.append(ngbmName).append("|"); // 26 拟稿部门 -> 拟稿部门名称
|
||||
context.append("发文").append("|"); // 27 公文类型 -> "收文"
|
||||
//TODO
|
||||
context.append(ArchivesUtil.getAssociatedPersons(requestid,false)).append("|"); // 28 相关人员 -> 参与人员
|
||||
context.append("智慧OA").append("|"); // 29 数据来源 -> 数据来源
|
||||
context.append(year).append("|"); // 30 形成年度 -> 年份
|
||||
context.append(String.join("&&", zwFileName)).append("|"); // 31 正文名称
|
||||
context.append(String.join("&&", fjFileName)).append("|"); // 32 附件名称
|
||||
context.append("togd"+requestid).append("|"); // 33 主键
|
||||
context.append("").append("|"); // 34 关联主键
|
||||
context.append("").append("|"); // 35 被关联主键
|
||||
context.append(zipName);// 36 压缩包名称
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
log.error("getContextError:{}", e.getMessage());
|
||||
}
|
||||
|
||||
return context.toString();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private String getAssociatedDepts(Map<String, String> requesData) {
|
||||
HashSet<String> records = new HashSet<>();
|
||||
records.addAll(Arrays.asList(Util.null2String(requesData.get("hqbm")).split(","))); // 会签部门
|
||||
records.addAll(Arrays.asList(Util.null2String(requesData.get("ngbm")).split(","))); // 拟稿部门
|
||||
records.addAll(Arrays.asList(Util.null2String(requesData.get("bmyb")).split(","))); // 部门阅办
|
||||
records.addAll(Arrays.asList(Util.null2String(requesData.get("cs")).split(","))); // 抄送
|
||||
records.addAll(Arrays.asList(Util.null2String(requesData.get("nbfs")).split(","))); // 本行发送
|
||||
records.addAll(Arrays.asList(Util.null2String(requesData.get("zs")).split(","))); // 主送
|
||||
records.addAll(Arrays.asList(Util.null2String(requesData.get("dqbm")).split(","))); // 当前部门
|
||||
records.addAll(Arrays.asList(Util.null2String(requesData.get("cb")).split(","))); // 抄报
|
||||
records.addAll(Arrays.asList(Util.null2String(requesData.get("bmhqzj")).split(","))); // 部门会签(追加)
|
||||
records.addAll(Arrays.asList(Util.null2String(requesData.get("bmybzj")).split(","))); // 部门阅办(追加)
|
||||
ArrayList<String> deptName = new ArrayList<>();
|
||||
DepartmentComInfo departmentComInfo = new DepartmentComInfo();
|
||||
for (String record : records) {
|
||||
try {
|
||||
if (StringUtil.isEmpty(record)){
|
||||
continue;
|
||||
}
|
||||
String departmentName = departmentComInfo.getDepartmentName(record);
|
||||
deptName.add(departmentName);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
return String.join("&&", deptName);
|
||||
}
|
||||
|
||||
private void updateRecord(int requestid, String field , String fieldvalue) {
|
||||
String sql = "update uf_pushArchivesLog set "+field+" = ? where request = ?";
|
||||
RecordSet recordSet = new RecordSet();
|
||||
recordSet.executeUpdate(sql, fieldvalue, requestid);
|
||||
}
|
||||
|
||||
|
||||
|
||||
%>
|
@ -0,0 +1,588 @@
|
||||
<%@ page import="weaver.conn.RecordSet" %>
|
||||
<%@ page import="weaver.general.BaseBean" %>
|
||||
<%@ page import="weaver.general.Util" %>
|
||||
<%@ page import="com.alibaba.fastjson.JSONObject" %>
|
||||
<%@ page import="com.alibaba.fastjson.JSONArray" %>
|
||||
<%@ page import="java.util.regex.Pattern" %>
|
||||
<%@ page import="java.util.regex.Matcher" %>
|
||||
<%@ page import="java.io.*" %>
|
||||
<%@ page import="weaver.docs.webservices.DocInfo" %>
|
||||
<%@ page import="weaver.docs.webservices.DocAttachment" %>
|
||||
<%@ page import="org.apache.axis.encoding.Base64" %>
|
||||
<%@ page import="weaver.docs.webservices.DocServiceImpl" %>
|
||||
<%@ page import="weaver.hrm.User" %>
|
||||
<%@ page import="java.text.SimpleDateFormat" %>
|
||||
<%@ page import="java.util.*" %>
|
||||
<%@ page import="org.apache.commons.lang.StringUtils" %>
|
||||
<%@ page language="java" contentType="text/html; charset=UTF-8"%>
|
||||
<%@ page import="org.apache.http.impl.client.CloseableHttpClient" %>
|
||||
<%@ page import="org.apache.http.impl.client.HttpClients" %>
|
||||
<%@ page import="org.apache.http.client.methods.HttpPost" %>
|
||||
<%@ page import="com.alibaba.fastjson.JSON" %>
|
||||
<%@ page import="org.apache.http.entity.StringEntity" %>
|
||||
<%@ page import="org.apache.http.client.methods.CloseableHttpResponse" %>
|
||||
<%@ page import="org.apache.http.HttpStatus" %>
|
||||
<%@ page import="org.apache.http.HttpEntity" %>
|
||||
<%@ page import="org.apache.http.util.EntityUtils" %>
|
||||
<%@ page import="org.apache.http.client.ClientProtocolException" %>
|
||||
<%@ page import="weaver.hrm.HrmUserVarify" %>
|
||||
<%@ page import="java.net.URL" %>
|
||||
<%@ page import="java.net.HttpURLConnection" %>
|
||||
<%@ page import="org.apache.http.HttpException" %>
|
||||
<%@ page import="org.apache.http.client.HttpClient" %>
|
||||
<%@ page import="org.apache.commons.httpclient.methods.PostMethod" %>
|
||||
<%@ page import="org.apache.commons.httpclient.params.HttpMethodParams" %>
|
||||
<%@ page import="org.slf4j.Logger" %>
|
||||
<%@ page import="org.slf4j.LoggerFactory" %>
|
||||
<%@ page import="com.engine.custom.archives.util.ArchivesUtil" %>
|
||||
<%@ page import="com.engine.custom.archives.entity.PushArchivesBean" %>
|
||||
<%@ page import="com.engine.custom.hg.util.HgUtils" %>
|
||||
<%@ page import="com.dcfs.fts.common.error.FtpException" %>
|
||||
<%@ page import="weaver.file.ImageFileManager" %>
|
||||
<%@ page import="weaver.soa.workflow.request.RequestService" %>
|
||||
<%@ page import="weaver.soa.workflow.request.RequestInfo" %>
|
||||
<%@ page import="cn.hutool.core.util.ZipUtil" %>
|
||||
<%@ page import="weaver.hrm.company.DepartmentComInfo" %>
|
||||
<%@ page import="java.time.format.DateTimeFormatter" %>
|
||||
<%@ page import="java.time.LocalDate" %>
|
||||
<%@ page import="weaver.general.StringUtil" %>
|
||||
<%@ page import="java.net.URLEncoder" %>
|
||||
<%@ page import="java.nio.charset.StandardCharsets" %>
|
||||
<%@ page import="okhttp3.*" %>
|
||||
<%@ page import="com.engine.common.util.ParamUtil" %>
|
||||
|
||||
<%
|
||||
Map<String, Object> paramMap = ParamUtil.request2Map(request);
|
||||
String requestid = Util.null2String(paramMap.get("requestid"));
|
||||
Logger log = LoggerFactory.getLogger("Archives");
|
||||
log.info("PushArchivesCorn====Begin========");
|
||||
Date date = ArchivesUtil.getDate();
|
||||
String dateStr = new SimpleDateFormat("yyyyMMdd").format(date);
|
||||
ArrayList<PushArchivesBean> pushArchivesBeans = new ArrayList<>();
|
||||
PushArchivesBean pushArchivesBean = new PushArchivesBean();
|
||||
pushArchivesBean.setRequest(Util.getIntValue(requestid));
|
||||
pushArchivesBeans.add(pushArchivesBean);
|
||||
pushArchives(pushArchivesBeans,dateStr);
|
||||
|
||||
|
||||
%>
|
||||
|
||||
<%!
|
||||
public static Logger log = LoggerFactory.getLogger("Archives");
|
||||
private static String filePath = "/opt/oadata/archivesFile";
|
||||
// private static String Url = "http://14.1.213.5:18080/fcscloud/composite/upload" ;
|
||||
public String Url = "http://14.1.206.240:18080/fcscloud/composite/upload";
|
||||
private static String templatePath = "/opt/weaver/archivesFile/template/"; // 模板文件路径
|
||||
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(List<PushArchivesBean> result, String dateStr) {
|
||||
filePath = filePath + File.separator + dateStr ;
|
||||
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();
|
||||
//签报 type = 2
|
||||
// List<PushArchivesBean> result = ArchivesUtil.getResultList(recordSet, firstSecond, lastSecond, 2);
|
||||
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);
|
||||
if ("-1".equals(context)){
|
||||
continue;
|
||||
}
|
||||
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);
|
||||
updateRecord(request,"esbtxtml",s);
|
||||
updateRecord(request,"zt","0");
|
||||
log.error("textZip:{}", s);
|
||||
} catch (FtpException e) {
|
||||
log.error("推送档案requestid:{}异常,异常原因为:{}",request,e.getMessage());
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
log.error("推送档案requestid:{}异常,异常原因为:{}",request,e.getMessage());
|
||||
e.printStackTrace();
|
||||
} catch (Exception e) {
|
||||
log.error("推送档案requestid:{}异常,异常原因为:{}",request,e.getMessage());
|
||||
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
private String generateFile(int requestid) throws FtpException, IOException {
|
||||
Map<String, String> requesData = getRequestByid(requestid);
|
||||
String newRequestid = "togd"+requestid;
|
||||
log.info("requesData:{}", requesData);
|
||||
String bhnew = requesData.get("bhnew");
|
||||
log.info("流程id:{}:文号为空不推送", requestid);
|
||||
if (StringUtil.isEmpty(bhnew)){
|
||||
return "-1";
|
||||
}
|
||||
String fj = Util.null2String(requesData.get("fj"));
|
||||
String dwd = Util.null2String(requesData.get("dwd"));
|
||||
String zw = Util.null2String(requesData.get("zw"));
|
||||
String qgqhj = Util.null2String(requesData.get("qgqhj"));
|
||||
//可能有多个,获取id最大的一个
|
||||
qgqhj = Util.null2String(ArchivesUtil.findMaxValue(qgqhj));
|
||||
|
||||
//增加签字意见中的附件到附件文件夹中
|
||||
Map<String, String> signFiles = ArchivesUtil.getSignFiles(requestid,true);
|
||||
List<String> docids = new ArrayList<>();
|
||||
// docids.addAll(Arrays.asList(fj.split(",")));
|
||||
// docids.addAll(Arrays.asList(zwkbj.split(",")));
|
||||
Map<String, String> fjMap = ArchivesUtil.getFileIdByDocId(fj);
|
||||
Map<String, String> zwMap = ArchivesUtil.getFileIdByDocId(zw);
|
||||
Map<String, String> qgqhjMap = ArchivesUtil.getFileIdByDocId(qgqhj);
|
||||
List<String> zwFileName = new ArrayList<>();
|
||||
List<String> fjFileName = new ArrayList<>();
|
||||
final int[] i = {1};
|
||||
//附件
|
||||
fjMap.forEach((docid, imageid) -> {
|
||||
ImageFileManager imageFileManager = new ImageFileManager();
|
||||
imageFileManager.getImageFileInfoById(Util.getIntValue(imageid));
|
||||
InputStream inputStream = imageFileManager.getInputStream();
|
||||
//中文路径/中文文件名
|
||||
String imageFileName = filePath + File.separator + newRequestid + File.separator + fjdir + File.separator + lcfjWord + "-" +imageFileManager.getImageFileName();
|
||||
fjFileName.add(imageFileManager.getImageFileName());
|
||||
log.info("生成附件路径:{}", imageFileName);
|
||||
imageFileName = ArchivesUtil.codeUtf8(imageFileName);
|
||||
try {
|
||||
File file = ArchivesUtil.saveInputStreamToFile(inputStream, imageFileName);
|
||||
String jsonStr = ArchivesUtil.callApi(Url, file);
|
||||
log.error("永中接口返回数据:{}", jsonStr);
|
||||
JSONObject result = JSONObject.parseObject(jsonStr);
|
||||
String errorcode = result.getString("errorcode");
|
||||
if ("0".equals(errorcode)) {
|
||||
JSONObject data = result.getJSONObject("data");
|
||||
String destFileName = data.getString("destFileName");
|
||||
String viewUrl = data.getString("viewUrl");
|
||||
ArchivesUtil.downloadFile(viewUrl, filePath + File.separator + newRequestid + File.separator + fjdir + File.separator + lcfjWord + "-" + imageFileManager.getImageFileName() + ".pdf");
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if(inputStream!=null) {
|
||||
try {
|
||||
inputStream.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
//签字意见附件
|
||||
signFiles.forEach((docid, imageid) -> {
|
||||
ImageFileManager imageFileManager = new ImageFileManager();
|
||||
imageFileManager.getImageFileInfoById(Util.getIntValue(imageid));
|
||||
InputStream inputStream = imageFileManager.getInputStream();
|
||||
//中文路径/中文文件名
|
||||
String imageFileName = filePath + File.separator + newRequestid + File.separator + fjdir + File.separator + qzyjfjWord+ "-" +imageFileManager.getImageFileName();
|
||||
fjFileName.add(imageFileManager.getImageFileName());
|
||||
log.info("生成签字意见附件路径:{}", imageFileName);
|
||||
imageFileName = ArchivesUtil.codeUtf8(imageFileName);
|
||||
try {
|
||||
File file = ArchivesUtil.saveInputStreamToFile(inputStream, imageFileName);
|
||||
String jsonStr = ArchivesUtil.callApi(Url, file);
|
||||
log.error("永中接口返回数据:{}", jsonStr);
|
||||
JSONObject result = JSONObject.parseObject(jsonStr);
|
||||
String errorcode = result.getString("errorcode");
|
||||
if ("0".equals(errorcode)) {
|
||||
JSONObject data = result.getJSONObject("data");
|
||||
String destFileName = data.getString("destFileName");
|
||||
String viewUrl = data.getString("viewUrl");
|
||||
ArchivesUtil.downloadFile(viewUrl, filePath + File.separator + newRequestid + File.separator + fjdir + File.separator + qzyjfjWord+ "-" + imageFileManager.getImageFileName() + ".pdf");
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if(inputStream!=null) {
|
||||
try {
|
||||
inputStream.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
//正文
|
||||
zwMap.forEach((docid, imageid) -> {
|
||||
ImageFileManager imageFileManager = new ImageFileManager();
|
||||
imageFileManager.getImageFileInfoById(Util.getIntValue(imageid));
|
||||
InputStream inputStream = imageFileManager.getInputStream();
|
||||
|
||||
String newFile = fjWord + i[0] + "_" + zwWord + "-" + imageFileManager.getImageFileName();
|
||||
//中文路径/中文文件名
|
||||
String imageFileName = filePath + File.separator + newRequestid + File.separator + zwdir + File.separator + newFile;
|
||||
zwFileName.add(newFile);
|
||||
log.info("生成正文路径:{}", imageFileName);
|
||||
imageFileName = ArchivesUtil.codeUtf8(imageFileName);
|
||||
try {
|
||||
File file = ArchivesUtil.saveInputStreamToFile(inputStream, imageFileName);
|
||||
String jsonStr = ArchivesUtil.callApi(Url, file);
|
||||
log.error("永中接口返回:{}", jsonStr);
|
||||
JSONObject result = JSONObject.parseObject(jsonStr);
|
||||
String errorcode = result.getString("errorcode");
|
||||
if ("0".equals(errorcode)) {
|
||||
JSONObject data = result.getJSONObject("data");
|
||||
String destFileName = data.getString("destFileName");
|
||||
String viewUrl = data.getString("viewUrl");
|
||||
ArchivesUtil.downloadFile(viewUrl, filePath + File.separator + newRequestid + File.separator + zwdir + File.separator + newFile + ".pdf");
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if(inputStream!=null) {
|
||||
try {
|
||||
inputStream.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
i[0]++;
|
||||
});
|
||||
//清稿前痕迹
|
||||
qgqhjMap.forEach((docid, imageid) -> {
|
||||
ImageFileManager imageFileManager = new ImageFileManager();
|
||||
imageFileManager.getImageFileInfoById(Util.getIntValue(imageid));
|
||||
InputStream inputStream = imageFileManager.getInputStream();
|
||||
|
||||
String newFile = fjWord + i[0] + "_" + lhgWord + "-" + imageFileManager.getImageFileName();
|
||||
zwFileName.add(newFile);
|
||||
//中文路径/中文文件名
|
||||
String imageFileName = filePath + File.separator + newRequestid + File.separator + zwdir + File.separator + newFile;
|
||||
log.info("生成清稿前痕迹路径:{}", imageFileName);
|
||||
imageFileName = ArchivesUtil.codeUtf8(imageFileName);
|
||||
try {
|
||||
File file = ArchivesUtil.saveInputStreamToFile(inputStream, imageFileName);
|
||||
String jsonStr = ArchivesUtil.callApi(Url, file);
|
||||
log.error("永中接口返回:{}", jsonStr);
|
||||
JSONObject result = JSONObject.parseObject(jsonStr);
|
||||
String errorcode = result.getString("errorcode");
|
||||
if ("0".equals(errorcode)) {
|
||||
JSONObject data = result.getJSONObject("data");
|
||||
String destFileName = data.getString("destFileName");
|
||||
String viewUrl = data.getString("viewUrl");
|
||||
ArchivesUtil.downloadFile(viewUrl, filePath + File.separator + newRequestid + File.separator + zwdir + File.separator + newFile + ".pdf");
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if(inputStream!=null) {
|
||||
try {
|
||||
inputStream.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
i[0]++;
|
||||
});
|
||||
//套红后留痕
|
||||
// thhlhMap.forEach((docid, imageid) -> {
|
||||
// ImageFileManager imageFileManager = new ImageFileManager();
|
||||
// imageFileManager.getImageFileInfoById(Util.getIntValue(imageid));
|
||||
// InputStream inputStream = imageFileManager.getInputStream();
|
||||
// zwFileName.add(imageFileManager.getImageFileName());
|
||||
// //中文路径/中文文件名
|
||||
// String imageFileName = filePath + File.separator + requestid + File.separator + zwdir + File.separator + fjWord + i[0] + "_" + lhgWord + "_" + imageFileManager.getImageFileName();
|
||||
// log.info("生成套红后留痕路径:{}", imageFileName);
|
||||
// imageFileName = ArchivesUtil.codeUtf8(imageFileName);
|
||||
// try {
|
||||
// File file = ArchivesUtil.saveInputStreamToFile(inputStream, imageFileName);
|
||||
// String jsonStr = ArchivesUtil.callApi(Url, file);
|
||||
// log.error("永中接口返回:{}", jsonStr);
|
||||
// JSONObject result = JSONObject.parseObject(jsonStr);
|
||||
// String errorcode = result.getString("errorcode");
|
||||
// if ("0".equals(errorcode)) {
|
||||
// JSONObject data = result.getJSONObject("data");
|
||||
// String destFileName = data.getString("destFileName");
|
||||
// String viewUrl = data.getString("viewUrl");
|
||||
// ArchivesUtil.downloadFile(viewUrl, filePath + File.separator + requestid + File.separator + zwdir + File.separator + fjWord + i[0] + "_" + lhgWord + "_" + imageFileManager.getImageFileName() + ".pdf");
|
||||
// }
|
||||
// } catch (IOException e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// i[0]++;
|
||||
// });
|
||||
|
||||
//开始承办单 先获取主流程的承办单
|
||||
List<String> requestDocid = ArchivesUtil.generaRequestFormPdf(requestid, 1);
|
||||
// 1.去掉生成子流程承办单
|
||||
// List<String> subRequestDocid = generaSubRequestFormPdf(requestid);
|
||||
Map<String, String> reqDocMap = ArchivesUtil.getFileIdByDocId(String.join(",", requestDocid));
|
||||
// 2.去掉生成子流程承办单
|
||||
// Map<String, String> subReqDocMap = getFileIdByDocId(String.join(",", subRequestDocid));
|
||||
log.error("reqDocMap:{}", JSONObject.toJSONString(reqDocMap));
|
||||
//log.error("subReqDocMap:{}", JSONObject.toJSONString(subReqDocMap));
|
||||
docids.addAll(requestDocid);
|
||||
// 3.去掉生成子流程承办单
|
||||
// docids.addAll(subRequestDocid);
|
||||
i[0] = 1;
|
||||
//主流程承办单
|
||||
reqDocMap.forEach((docid, imageid) -> {
|
||||
ImageFileManager imageFileManager = new ImageFileManager();
|
||||
imageFileManager.getImageFileInfoById(Util.getIntValue(imageid));
|
||||
InputStream inputStream = imageFileManager.getInputStream();
|
||||
//中文路径/中文文件名
|
||||
// String imageFileName = filePath + File.separator + requestid + File.separator + cbddir + File.separator + fjFile + i[0] + "_" + imageFileManager.getImageFileName();
|
||||
// String imageFileName = filePath + File.separator + newRequestid + File.separator + cbddir + File.separator + fjFile + i[0] + "_" + wjcldWord+".pdf";
|
||||
String imageFileName = filePath + File.separator + newRequestid + File.separator + cbddir + File.separator + wjcldWord+".pdf";
|
||||
log.info("主流程承办单路径:{}", imageFileName);
|
||||
imageFileName = ArchivesUtil.codeUtf8(imageFileName);
|
||||
try {
|
||||
File file = ArchivesUtil.saveInputStreamToFile(inputStream, imageFileName);
|
||||
String jsonStr = ArchivesUtil.callApi(Url, file);
|
||||
log.error("永中接口返回:{}", jsonStr);
|
||||
JSONObject result = JSONObject.parseObject(jsonStr);
|
||||
String errorcode = result.getString("errorcode");
|
||||
if ("0".equals(errorcode)) {
|
||||
JSONObject data = result.getJSONObject("data");
|
||||
String destFileName = data.getString("destFileName");
|
||||
String viewUrl = data.getString("viewUrl");
|
||||
// ArchivesUtil.downloadFile(viewUrl, filePath + File.separator + newRequestid + File.separator + cbddir + File.separator + fjFile + i[0] + "_" + wjcldWord + ".pdf" + ".pdf");
|
||||
ArchivesUtil.downloadFile(viewUrl, filePath + File.separator + newRequestid + File.separator + cbddir + File.separator + wjcldWord + ".pdf" + ".pdf");
|
||||
}
|
||||
i[0]++;
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}finally {
|
||||
if(inputStream!=null) {
|
||||
try {
|
||||
inputStream.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
//正文
|
||||
|
||||
|
||||
log.error(JSONObject.toJSONString(requestDocid));
|
||||
for (String docid : docids) {
|
||||
log.error("删除了" + docid);
|
||||
ArchivesUtil.deleteDocByid(docid);
|
||||
}
|
||||
//--------------------------------------------------------------------
|
||||
RequestService requestService = new RequestService();
|
||||
RequestInfo requestInfo = requestService.getRequest(Util.getIntValue(requestid), 100);
|
||||
String workflowid = requestInfo.getWorkflowid();
|
||||
String logFile = ArchivesUtil.getSignLog(requestid, cbddir + File.separator + lzxxdir, requestInfo.getCreatorid() + requestInfo.getDescription(), templatePath, filePath,true,workflowid);
|
||||
String s = ArchivesUtil.callApi(Url, new File(logFile));
|
||||
log.error(s);
|
||||
JSONObject result = JSONObject.parseObject(s);
|
||||
String errorcode = result.getString("errorcode");
|
||||
if ("0".equals(errorcode)) {
|
||||
JSONObject data = result.getJSONObject("data");
|
||||
String destFileName = data.getString("destFileName");
|
||||
String viewUrl = data.getString("viewUrl");
|
||||
ArchivesUtil.downloadFile(viewUrl, logFile + ".pdf");
|
||||
}
|
||||
String zipName = filePath + File.separator + newRequestid + ".zip";
|
||||
ZipUtil.zip(filePath + File.separator + newRequestid, zipName);
|
||||
log.error("zipName:{}", zipName);
|
||||
String ftpFilePath = HgUtils.putFile(zipName, newRequestid + ".zip");
|
||||
log.error("ftpFilePath:{}", ftpFilePath);
|
||||
updateRecord(requestid,"esbwjml",ftpFilePath);
|
||||
// String ftpFilePathNew = HgUtils.putFile(zipName, "test" + File.separator + requestid + ".zip");
|
||||
// log.error("ftpFilePathNew:{}", ftpFilePathNew);
|
||||
String context = getContext(requestid, requesData, newRequestid + ".zip", zwFileName, fjFileName);
|
||||
// insertRecord(requestid, context, ftpFilePath);
|
||||
updateRecord(requestid,"content",context);
|
||||
log.error("context:{}", context);
|
||||
return context;
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
* 封装数据
|
||||
* @param requestid
|
||||
* @return
|
||||
*/
|
||||
public Map<String, String> getRequestByid(int requestid) {
|
||||
HashMap<String, String> record = new HashMap<>();
|
||||
String sql = "select * from formtable_main_20 where requestid = ?";
|
||||
String reqsql = "select REQUESTNAME from WORKFLOW_REQUESTBASE where REQUESTID = ?";
|
||||
RecordSet rs = new RecordSet();
|
||||
rs.executeQuery(sql, requestid);
|
||||
if (rs.next()) {
|
||||
record.put("bh", Util.null2String(rs.getString("bh")));
|
||||
record.put("bhnew", Util.null2String(rs.getString("bhnew")));
|
||||
record.put("ngbm", Util.null2String(rs.getString("ngbm")));
|
||||
record.put("ngr", Util.null2String(rs.getString("ngr")));
|
||||
record.put("ngrq", Util.null2String(rs.getString("ngrq")));
|
||||
record.put("lxfs", Util.null2String(rs.getString("lxfs")));
|
||||
record.put("bt", Util.null2String(rs.getString("bt")));
|
||||
record.put("zw", Util.null2String(rs.getString("zw")));
|
||||
record.put("fj", Util.null2String(rs.getString("fj")));
|
||||
record.put("hqbm", Util.null2String(rs.getString("hqbm")));
|
||||
record.put("hqbmzhwy", Util.null2String(rs.getString("hqbmzhwy")));
|
||||
record.put("hqdqbm", Util.null2String(rs.getString("hqdqbm")));
|
||||
record.put("ffbm", Util.null2String(rs.getString("ffbm")));
|
||||
record.put("hqbmzjhqbmzj", Util.null2String(rs.getString("hqbmzj")));
|
||||
record.put("dwd", Util.null2String(rs.getString("dwd")));
|
||||
record.put("bmffzj", Util.null2String(rs.getString("bmffzj")));
|
||||
record.put("dqnf", Util.null2String(rs.getString("dqnf")));
|
||||
record.put("qgqhj", Util.null2String(rs.getString("qgqhj")));
|
||||
}
|
||||
rs.executeQuery(reqsql, requestid);
|
||||
if (rs.next()) {
|
||||
record.put("REQUESTNAME", Util.null2String(rs.getString("REQUESTNAME")));
|
||||
}
|
||||
return record;
|
||||
}
|
||||
|
||||
|
||||
private String getContext(int requestid, Map<String, String> requesData, String zipName, List<String> zwFileName, List<String> fjFileName) {
|
||||
StringBuilder context = new StringBuilder();
|
||||
try {
|
||||
DepartmentComInfo departmentComInfo = new DepartmentComInfo();
|
||||
String ngrq = Util.null2String(requesData.get("ngrq")); //拟稿日期
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||
LocalDate date = LocalDate.parse(ngrq, formatter);
|
||||
int year = date.getYear();
|
||||
context.append(year).append("|"); //1.年度 -> 拟稿日期
|
||||
String jghwt = Util.null2String(requesData.get("jghwt"));//2.机构或问题 -> 机构或问题
|
||||
context.append(jghwt).append("|");
|
||||
String bh = Util.null2String(requesData.get("bhnew"));// 3.文号 -> 编号
|
||||
context.append(bh).append("|");
|
||||
String requestname = Util.null2String(requesData.get("REQUESTNAME")); // 4.文件题名 -> 流程名称
|
||||
context.append(requestname).append("|");
|
||||
String ngbmName = Util.null2String(departmentComInfo.getDepartmentname(requesData.get("ngbm"))); //5 责任者 -> 拟稿部门
|
||||
context.append(ngbmName).append("|");
|
||||
String bgqx = Util.null2String(requesData.get("bgqx")); //6 保管期限 -> 保管期限
|
||||
context.append(bgqx).append("|");
|
||||
// String cwrq = Util.null2String(requesData.get("cwrq")); //7 日期 -> 成文日期
|
||||
context.append(ngrq).append("|");
|
||||
String ys = Util.null2String(requesData.get("ys")); //8 页数 -> 页数
|
||||
context.append(ys).append("|");
|
||||
String wz = Util.null2String(requesData.get("wz")); //9 文种 -> 文种
|
||||
context.append(wz).append("|");
|
||||
String ngbm = Util.null2String(requesData.get("ngbm"));
|
||||
String[] deptData = ArchivesUtil.getDeptNameAndCode(ngbm);
|
||||
String[] subData = ArchivesUtil.getSubCom(ngbm);
|
||||
context.append("D10001").append("|"); //10 行编号 -> 拟稿部门
|
||||
|
||||
context.append("总行机关").append("|"); //11 行名称
|
||||
context.append("").append("|"); // 12 保管期限编号
|
||||
context.append("").append("|"); // 13 保管期限及编号
|
||||
context.append("").append("|"); // 14 是否开放
|
||||
context.append("").append("|"); // 15 互见号
|
||||
String lb = Util.null2String(requesData.get("lb"));
|
||||
context.append(lb).append("|"); //16 类别 -> 类别
|
||||
//TODO
|
||||
String xgbm = Util.null2String(getAssociatedDepts(requesData));
|
||||
context.append(xgbm).append("|"); //17 相关部门 -> 流经部门
|
||||
// String lwh = Util.null2String(requesData.get("lwh"));
|
||||
context.append("").append("|");// 18 收文号 -> 空
|
||||
String fs = "";
|
||||
context.append(fs).append("|"); // 19 份数 -> 份数
|
||||
String bz = Util.null2String(requesData.get("bz"));
|
||||
context.append("").append("|"); // 20 备注 -> 备注
|
||||
String yywh = Util.null2String(requesData.get("yywh"));
|
||||
context.append("").append("|"); // 21 引用文号 -> 引用文号
|
||||
String wjlx = Util.null2String(requesData.get("wjlx"));
|
||||
context.append("").append("|"); // 22 文件类型 -> 空
|
||||
String fwlx = Util.null2String(requesData.get("fwlx"));
|
||||
context.append("总行发文").append("|"); // 23 发文类型 -> 空
|
||||
String f = Util.null2String(requesData.get("f"));
|
||||
context.append(f).append("|"); // 24 发 -> 空
|
||||
String ngr = Util.null2String(requesData.get("ngr"));
|
||||
context.append(new User(Util.getIntValue(ngr)).getLoginid()).append("|"); // 25 拟稿人 -> 拟稿人
|
||||
context.append(ngbmName).append("|"); // 26 拟稿部门 -> 拟稿部门名称
|
||||
context.append("签报").append("|"); // 27 公文类型 -> "收文"
|
||||
//TODO
|
||||
context.append(ArchivesUtil.getAssociatedPersons(requestid,false)).append("|"); // 28 相关人员 -> 参与人员
|
||||
context.append("智慧OA").append("|"); // 29 数据来源 -> 数据来源
|
||||
context.append(year).append("|"); // 30 形成年度 -> 年份
|
||||
context.append(String.join("&&", zwFileName)).append("|"); // 31 正文名称
|
||||
context.append(String.join("&&", fjFileName)).append("|"); // 32 附件名称
|
||||
context.append("togd"+requestid).append("|"); // 33 主键
|
||||
context.append("").append("|"); // 34 关联主键
|
||||
context.append("").append("|"); // 35 被关联主键
|
||||
context.append(zipName);// 36 压缩包名称
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
log.error("getContextError:{}", e.getMessage());
|
||||
}
|
||||
|
||||
return context.toString();
|
||||
}
|
||||
private String getAssociatedDepts(Map<String, String> requesData) {
|
||||
HashSet<String> records = new HashSet<>();
|
||||
records.addAll(Arrays.asList(Util.null2String(requesData.get("ngbm")).split(","))); // 会签部门
|
||||
records.addAll(Arrays.asList(Util.null2String(requesData.get("hqbm")).split(","))); // 拟稿部门
|
||||
records.addAll(Arrays.asList(Util.null2String(requesData.get("ffbm")).split(","))); // 部门阅办
|
||||
records.addAll(Arrays.asList(Util.null2String(requesData.get("hqbmzj")).split(","))); // 抄送
|
||||
records.addAll(Arrays.asList(Util.null2String(requesData.get("bmffzj")).split(","))); // 本行发送
|
||||
|
||||
ArrayList<String> deptName = new ArrayList<>();
|
||||
DepartmentComInfo departmentComInfo = new DepartmentComInfo();
|
||||
for (String record : records) {
|
||||
try {
|
||||
if (StringUtil.isEmpty(record)){
|
||||
continue;
|
||||
}
|
||||
String departmentName = departmentComInfo.getDepartmentName(record);
|
||||
deptName.add(departmentName);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
return String.join("&&", deptName);
|
||||
}
|
||||
|
||||
private void updateRecord(int requestid, String s) {
|
||||
String sql = "update uf_pushArchivesLog set esbtxtml = ? where request = ?";
|
||||
RecordSet recordSet = new RecordSet();
|
||||
recordSet.executeUpdate(sql, s, requestid);
|
||||
}
|
||||
private void updateRecord(int requestid, String field , String fieldvalue) {
|
||||
String sql = "update uf_pushArchivesLog set "+field+" = ? where request = ?";
|
||||
RecordSet recordSet = new RecordSet();
|
||||
recordSet.executeUpdate(sql, fieldvalue, requestid);
|
||||
}
|
||||
|
||||
%>
|
@ -1,25 +0,0 @@
|
||||
<%@ page import="weaver.conn.RecordSet" %>
|
||||
<%@ page import="weaver.general.BaseBean" %>
|
||||
|
||||
<%@ page import="com.alibaba.fastjson.JSONObject" %>
|
||||
<%@ page import="com.alibaba.fastjson.JSONArray" %>
|
||||
<%@ page import="com.engine.common.util.ParamUtil" %>
|
||||
<%@ page import="java.util.Map" %>
|
||||
<%@ page import="com.weaverboot.weaComponent.impl.weaTable.table.impl.DefaultWeaTable" %>
|
||||
<%@ page import="com.weaverboot.tools.componentTools.table.WeaTableTools" %>
|
||||
<%@ page language="java" contentType="text/html; charset=UTF-8" %>
|
||||
|
||||
|
||||
<%!
|
||||
|
||||
%>
|
||||
<%
|
||||
|
||||
|
||||
Map<String, Object> param = ParamUtil.request2Map(request);
|
||||
String dataKey = (String) param.get("dataKey");
|
||||
DefaultWeaTable defaultWeaTable = WeaTableTools.checkTableStringConfig(dataKey, DefaultWeaTable.class);
|
||||
|
||||
|
||||
%>
|
||||
|
@ -0,0 +1,69 @@
|
||||
<%@ page import="java.io.*, java.util.zip.*, java.util.Map, java.util.HashMap" %>
|
||||
<%@ page import="weaver.conn.RecordSet" %>
|
||||
<%@ page import="weaver.general.StringUtil" %>
|
||||
<%@ page import="com.weaver.general.BaseBean" %>
|
||||
|
||||
<%
|
||||
//rootpath 根路径
|
||||
String rootpath = "/opt/weaver/ecology";
|
||||
// 文件路径和名称映射
|
||||
Map<String, String> files = new HashMap<>();
|
||||
RecordSet recordSet = new RecordSet();
|
||||
recordSet.executeQuery("select * from hrmresource where messagerurl is not null");
|
||||
while (recordSet.next()){
|
||||
String messagerurl = rootpath + recordSet.getString("messagerurl");
|
||||
String Format = messagerurl.substring(messagerurl.lastIndexOf(".")+1);
|
||||
String lastname = recordSet.getString("lastname");
|
||||
String loginid = recordSet.getString("loginid");
|
||||
if (!StringUtil.isEmpty(messagerurl)){
|
||||
files.put(lastname+"_"+loginid+"."+Format,messagerurl);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
new BaseBean().writeLog(files+":"+files);
|
||||
// files.put("example1.zip", "/opt/oadata/archivesFile/20240530/togd_20240530000000.zip");
|
||||
// files.put("example2.zip", "/opt/oadata/archivesFile/20240530/togd660720.zip");
|
||||
|
||||
// 设置响应类型为ZIP文件
|
||||
response.setContentType("application/zip");
|
||||
response.setHeader("Content-Disposition", "attachment;filename=files.zip");
|
||||
|
||||
// 创建ZIP输出流
|
||||
try (ZipOutputStream zipOut = new ZipOutputStream(response.getOutputStream())) {
|
||||
for (Map.Entry<String, String> fileEntry : files.entrySet()) {
|
||||
String fileName = fileEntry.getKey();
|
||||
String filePath = fileEntry.getValue();
|
||||
|
||||
File fileToZip = new File(filePath);
|
||||
if (fileToZip.exists() && fileToZip.isFile()) {
|
||||
try (FileInputStream fis = new FileInputStream(fileToZip)) {
|
||||
ZipEntry zipEntry = new ZipEntry(fileName);
|
||||
zipOut.putNextEntry(zipEntry);
|
||||
|
||||
byte[] bytes = new byte[1024];
|
||||
int length;
|
||||
while ((length = fis.read(bytes)) >= 0) {
|
||||
zipOut.write(bytes, 0, length);
|
||||
}
|
||||
zipOut.closeEntry();
|
||||
}
|
||||
} else {
|
||||
System.err.println("File not found or not a file: " + filePath);
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
%>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Download ZIP</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Download ZIP File</h1>
|
||||
<p>If the download does not start automatically, <a href="/weavernorth/custom/avatar/zipAvatar.jsp">click here</a>.</p>
|
||||
</body>
|
||||
</html>
|
Binary file not shown.
@ -0,0 +1,22 @@
|
||||
<%@ page import="java.io.*, java.util.zip.*, java.util.Map, java.util.HashMap" %>
|
||||
<%@ page import="weaver.conn.RecordSet" %>
|
||||
<%@ page import="weaver.general.StringUtil" %>
|
||||
<%@ page import="com.weaver.general.BaseBean" %>
|
||||
<%@ page import="weaver.hrm.company.DepartmentComInfo" %>
|
||||
<%@page contentType="text/html; charset=UTF-8" %>
|
||||
|
||||
<%
|
||||
DepartmentComInfo departmentComInfo = new DepartmentComInfo();
|
||||
response.setContentType("text/html; charset=UTF-8");
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
out.print(departmentComInfo.getDepartmentName("3588"));
|
||||
out.print("<br/>");
|
||||
out.print(departmentComInfo.getDepartmentmark("3588"));
|
||||
out.print("<br/>");
|
||||
out.print(departmentComInfo.getDepartmentmark("3454"));
|
||||
out.print("<br/>");
|
||||
out.print(departmentComInfo.getDepartmentmark("3454"));
|
||||
|
||||
|
||||
%>
|
||||
|
Loading…
Reference in New Issue