no message

master
rengp 1 year ago
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));
}
}

@ -73,7 +73,7 @@ public class WorkflowToDocCus {
private String aescode=""; private String aescode="";
//底部签字意见列表显示数量 //底部签字意见列表显示数量
private int pageSize =100; private int pageSize =99999;
public static Class<?> class_MultiLangFilter; public static Class<?> class_MultiLangFilter;
static { static {
@ -184,7 +184,7 @@ public class WorkflowToDocCus {
//离线html/pdf //离线html/pdf
WfToDocBizCus wfToDocBiz = new WfToDocBizCus(user,pageSize,keepsign,docfiles,modeid,isOpenWaterMark); WfToDocBizCus wfToDocBiz = new WfToDocBizCus(user,pageSize,keepsign,docfiles,modeid,isOpenWaterMark);
wfToDocBiz.setOnlineHtmlMethod(onlineHtmlMethod); wfToDocBiz.setOnlineHtmlMethod(onlineHtmlMethod);
wfToDocBiz.generatepdfandhtml(requestid,filename,temppath,src,reqType); wfToDocBiz.generatepdfandhtml(requestid,filename,temppath,src,reqType,workflowid);
fileids.putAll(wfToDocBiz.getfileids(requestname,filename,temppath)); fileids.putAll(wfToDocBiz.getfileids(requestname,filename,temppath));
//保存 //保存
List<String> docids = saveDocDetail(requestname, workflowid, requestid, wfdocpath, userid, fileids, requestManager, wfbiz); List<String> docids = saveDocDetail(requestname, workflowid, requestid, wfdocpath, userid, fileids, requestManager, wfbiz);
@ -210,7 +210,7 @@ public class WorkflowToDocCus {
//离线html/pdf //离线html/pdf
WfToDocBizCus wfToDocBiz = new WfToDocBizCus(user,pageSize,keepsign,docfiles,modeid,isOpenWaterMark); WfToDocBizCus wfToDocBiz = new WfToDocBizCus(user,pageSize,keepsign,docfiles,modeid,isOpenWaterMark);
wfToDocBiz.setOnlineHtmlMethod(onlineHtmlMethod); wfToDocBiz.setOnlineHtmlMethod(onlineHtmlMethod);
wfToDocBiz.generatepdfandhtml(requestid,filename,temppath,src, reqType); wfToDocBiz.generatepdfandhtml(requestid,filename,temppath,src, reqType,workflowid);
fileids.putAll(wfToDocBiz.getfileids(requestname,filename,temppath)); fileids.putAll(wfToDocBiz.getfileids(requestname,filename,temppath));
//保存 //保存
saveDocDetail(requestname, workflowid,requestid, wfdocpath,userid,fileids,requestManager,wfbiz); saveDocDetail(requestname, workflowid,requestid, wfdocpath,userid,fileids,requestManager,wfbiz);

@ -3,10 +3,16 @@ package com.engine.custom.archives.corn;
import com.engine.custom.archives.service.ReceivingPushArchivesService; import com.engine.custom.archives.service.ReceivingPushArchivesService;
import com.engine.custom.archives.service.SendingPushArchivesService; import com.engine.custom.archives.service.SendingPushArchivesService;
import com.engine.custom.archives.service.SignReportPushArchivesService; import com.engine.custom.archives.service.SignReportPushArchivesService;
import com.engine.custom.archives.service.firstBranch.FirstBranchReceivingPushArchivesService;
import com.engine.custom.archives.service.firstBranch.FirstBranchSendingPushArchivesService;
import com.engine.custom.archives.service.firstBranch.FirstBranchSignReportPushArchivesService;
import com.engine.custom.archives.service.secondBranch.SecondBranchReceivingPushArchivesService;
import com.engine.custom.archives.service.secondBranch.SecondBranchSendingPushArchivesService;
import com.engine.custom.archives.util.ArchivesUtil; import com.engine.custom.archives.util.ArchivesUtil;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import weaver.general.Util;
import weaver.interfaces.schedule.BaseCronJob; import weaver.interfaces.schedule.BaseCronJob;
@ -25,6 +31,7 @@ public class PushArchivesCorn extends BaseCronJob {
public String filePath = "/opt/weaver/archivesFile"; public String filePath = "/opt/weaver/archivesFile";
public String Url = "http://14.1.206.240:18080/fcscloud/composite/upload"; public String Url = "http://14.1.206.240:18080/fcscloud/composite/upload";
public String templatePath = "/opt/weaver/archivesFile/template/"; public String templatePath = "/opt/weaver/archivesFile/template/";
public String endTime = "7";
public String reqid = ""; public String reqid = "";
public static Logger log = LoggerFactory.getLogger("Archives"); public static Logger log = LoggerFactory.getLogger("Archives");
@ -32,6 +39,12 @@ public class PushArchivesCorn extends BaseCronJob {
SendingPushArchivesService sendingservice = new SendingPushArchivesService(); SendingPushArchivesService sendingservice = new SendingPushArchivesService();
SignReportPushArchivesService signReportservice =new SignReportPushArchivesService(); SignReportPushArchivesService signReportservice =new SignReportPushArchivesService();
FirstBranchReceivingPushArchivesService firstBranchReceivingPushArchivesService =new FirstBranchReceivingPushArchivesService();
FirstBranchSendingPushArchivesService firstBranchSendingPushArchivesService =new FirstBranchSendingPushArchivesService();
FirstBranchSignReportPushArchivesService firstBranchSignReportPushArchivesService =new FirstBranchSignReportPushArchivesService();
SecondBranchReceivingPushArchivesService secondBranchReceivingPushArchivesService =new SecondBranchReceivingPushArchivesService();
SecondBranchSendingPushArchivesService secondBranchSendingPushArchivesService =new SecondBranchSendingPushArchivesService();
@Override @Override
public void execute() { public void execute() {
log.info("PushArchivesCorn====Begin========"); log.info("PushArchivesCorn====Begin========");
@ -40,14 +53,24 @@ public class PushArchivesCorn extends BaseCronJob {
HashMap<String, String> param = new HashMap<>(); HashMap<String, String> param = new HashMap<>();
param.put("filePath",filePath+ File.separator+dateStr); param.put("filePath",filePath+ File.separator+dateStr);
param.put("Url",Url); param.put("Url",Url);
param.put("requestid",reqid); param.put("endTime", endTime);
// param.put("requestid",reqid);
param.put("templatePath",templatePath); param.put("templatePath",templatePath);
// receivingservice.setProp(param);
// receivingservice.pushArchives(param);
sendingservice.setProp(param); sendingservice.setProp(param);
sendingservice.pushArchives(param); sendingservice.pushArchives(param);
signReportservice.setProp(param); signReportservice.setProp(param);
signReportservice.pushArchives(param); signReportservice.pushArchives(param);
receivingservice.setProp(param);
receivingservice.pushArchives(param);
firstBranchReceivingPushArchivesService.setProp(param);
firstBranchReceivingPushArchivesService.pushArchives(param);
firstBranchSendingPushArchivesService.setProp(param);
firstBranchSendingPushArchivesService.pushArchives(param);
firstBranchSignReportPushArchivesService.setProp(param);
firstBranchSignReportPushArchivesService.pushArchives(param);
secondBranchReceivingPushArchivesService.setProp(param);
secondBranchReceivingPushArchivesService.pushArchives(param);
secondBranchSendingPushArchivesService.setProp(param);
secondBranchSendingPushArchivesService.pushArchives(param);
} }
} }

@ -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);
}));
}
}

@ -2,18 +2,15 @@ package com.engine.custom.archives.service;
import com.dcfs.fts.common.error.FtpException; 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.ArchivesUtil;
import com.engine.custom.hg.util.HgUtils; import com.engine.custom.hg.util.HgUtils;
import com.icbc.api.internal.apache.http.impl.cookie.S;
import lombok.extern.slf4j.Slf4j;
import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.Calendar; import java.util.Calendar;
import java.util.Date; import java.util.Date;
import java.nio.charset.StandardCharsets;
import java.io.*; import java.io.*;
import java.util.*; import java.util.*;
@ -26,36 +23,13 @@ import weaver.general.Util;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import weaver.file.ImageFileManager; import weaver.file.ImageFileManager;
import java.net.URL; import weaver.hrm.company.DepartmentComInfo;
import org.apache.commons.io.FileUtils;
import okhttp3.*;
import java.net.URLEncoder;
import weaver.soa.workflow.request.RequestService; import weaver.soa.workflow.request.RequestService;
import weaver.soa.workflow.request.RequestInfo; import weaver.soa.workflow.request.RequestInfo;
import com.engine.custom.archives.action.WorkflowToDocCus;
import weaver.docs.docs.DocRecycleManager;
import weaver.hrm.User; import weaver.hrm.User;
import com.api.workflow.service.RequestAuthenticationService; import weaver.workflow.workflow.WorkflowBillComInfo;
import weaver.workflow.workflow.WorkflowConfigComInfo; import weaver.workflow.workflow.WorkflowComInfo;
import weaver.hrm.resource.ResourceComInfo;
import weaver.crm.Maint.CustomerInfoComInfo;
import com.alibaba.fastjson.JSON;
import weaver.workflow.monitor.Monitor;
import com.engine.workflow.biz.RobotNode.RobotNodeServiceBiz;
import com.api.workflow.util.ServiceUtil;
import com.engine.workflow.biz.RobotNode.RobotNodeBiz;
import weaver.general.TimeUtil;
import org.apache.poi.xwpf.usermodel.XWPFDocument;
import cn.afterturn.easypoi.word.WordExportUtil;
import cn.hutool.core.util.ZipUtil; import cn.hutool.core.util.ZipUtil;
import freemarker.template.Configuration;
import freemarker.template.TemplateExceptionHandler;
import freemarker.template.Template;
import java.nio.charset.StandardCharsets;
public class ReceivingPushArchivesService { public class ReceivingPushArchivesService {
@ -68,6 +42,13 @@ public class ReceivingPushArchivesService {
private static final String zlcdir = "承办单" + File.separator + "子流程"; private static final String zlcdir = "承办单" + File.separator + "子流程";
private static final String lzxxdir = "流转信息"; private static final String lzxxdir = "流转信息";
private static final String fjFile = "附件"; 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 = "文件流转信息";
private int endTime= 7;
public static Logger log = LoggerFactory.getLogger("Archives"); public static Logger log = LoggerFactory.getLogger("Archives");
@ -75,13 +56,13 @@ public class ReceivingPushArchivesService {
filePath = Util.null2String(param.get("filePath")); filePath = Util.null2String(param.get("filePath"));
Url = Util.null2String(param.get("Url")); Url = Util.null2String(param.get("Url"));
templatePath = Util.null2String(param.get("templatePath")); templatePath = Util.null2String(param.get("templatePath"));
endTime = Util.getIntValue(param.get("endTime"),7);
} }
public void pushArchives(Map<String, String> param) { public void pushArchives(Map<String, String> param) {
log.info("PushArchivesCorn====Begin========{}", param); log.info("PushArchivesCorn====Begin========{}", param);
try { try {
ZipUtil zipUtil = new ZipUtil(); ZipUtil zipUtil = new ZipUtil();
Date date = ArchivesUtil.getDate(); Date date = ArchivesUtil.getDate();
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd"); SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd");
@ -92,23 +73,41 @@ public class ReceivingPushArchivesService {
// 获取当前时间的最后一秒 // 获取当前时间的最后一秒
String lastSecond = yyyyMMddHHmmss.format(getLastSecondOfDate(date)); String lastSecond = yyyyMMddHHmmss.format(getLastSecondOfDate(date));
Integer requestid = Util.getIntValue(param.get("requestid"));
log.error("requestid:{}", requestid); RecordSet recordSet = new RecordSet();
String context = extracted(requestid); List<PushArchivesBean> result = ArchivesUtil.getResultList(recordSet, firstSecond, lastSecond, 1);
log.error("context:{}", context); log.error("推送收文的数量:{}", result.size());
File file = ArchivesUtil.crFile(filePath + "/togd_" + new SimpleDateFormat("yyyyMMdd000000").format(date)); File file = ArchivesUtil.crFile(filePath + "/togd_" + new SimpleDateFormat("yyyyMMdd000000").format(date));
log.error("textfile:{}", file.getAbsolutePath()); log.error("textfile:{}", file.getAbsolutePath());
ArchivesUtil.writeToTxt(file.getPath(), file.getName(), context, true); for (PushArchivesBean pushArchivesBean : result) {
File txtzip = new File(filePath + File.separator + "togd_" + new SimpleDateFormat("yyyyMMdd000000").format(date) + ".zip"); if (ArchivesUtil.isAfterSevenAM(endTime)){
log.error("textZipFile:{}", txtzip.getAbsolutePath()); log.info("超过执行时间:{}点暂停计划任务",endTime);
OutputStream outputStream = new FileOutputStream(txtzip); break;
File writename = new File(file.getPath() + "/" + file.getName() + ".txt"); }
com.engine.custom.hg.util.ZipUtil.filesToZip(writename, outputStream, writename.getName()); int requestid = pushArchivesBean.getRequest();
log.error("writename:{}",writename.getName()); try {
String s = HgUtils.putFile(txtzip.getAbsolutePath(), txtzip.getName()); log.error("requestid:{}", requestid);
updateRecord(requestid, s); //1.生成文件及推送的txt
log.error("textZip:{}", s); 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) { } catch (Exception e) {
log.info("PushArchivesCorn====Exception========{}", e.getMessage()); log.info("PushArchivesCorn====Exception========{}", e.getMessage());
e.printStackTrace(); e.printStackTrace();
@ -123,17 +122,36 @@ public class ReceivingPushArchivesService {
} }
private String extracted(int requestid) throws FtpException, IOException { 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); Map<String, String> requesData = getRequestByid(requestid);
log.info("requesData:{}", requesData); log.info("requesData:{}", requesData);
String fj = Util.null2String(requesData.get("fj")); String fj = Util.null2String(requesData.get("fj"));
String zwkbj = Util.null2String(requesData.get("zwkbj")); 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); Map<String, String> signFiles = ArchivesUtil.getSignFiles(requestid,true);
List<String> docids = new ArrayList<>(); List<String> docids = new ArrayList<>();
// docids.addAll(Arrays.asList(fj.split(","))); // docids.addAll(Arrays.asList(fj.split(",")));
// docids.addAll(Arrays.asList(zwkbj.split(","))); // docids.addAll(Arrays.asList(zwkbj.split(",")));
Map<String, String> fjMap = ArchivesUtil.getFileIdByDocId(fj); Map<String, String> fjMap = ArchivesUtil.getFileIdByDocId(fj);
Map<String, String> zwkbjMap = ArchivesUtil.getFileIdByDocId(zwkbj);
// 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> zwFileName = new ArrayList<>();
List<String> fjFileName = new ArrayList<>(); List<String> fjFileName = new ArrayList<>();
final int[] i = {1}; final int[] i = {1};
@ -143,8 +161,8 @@ public class ReceivingPushArchivesService {
imageFileManager.getImageFileInfoById(Util.getIntValue(imageid)); imageFileManager.getImageFileInfoById(Util.getIntValue(imageid));
InputStream inputStream = imageFileManager.getInputStream(); InputStream inputStream = imageFileManager.getInputStream();
//中文路径/中文文件名 //中文路径/中文文件名
String imageFileName = filePath + File.separator + requestid + File.separator + fjdir + File.separator + imageFileManager.getImageFileName(); String imageFileName = filePath + File.separator + newRequestid + File.separator + fjdir + File.separator + lcfjWord+ i[0] +"-" + (imageFileManager.getImageFileName().replaceAll("/","-"));
fjFileName.add(imageFileManager.getImageFileName()); fjFileName.add(lcfjWord+ i[0] +"-" + imageFileManager.getImageFileName().replaceAll("/","-"));
log.info("生成附件路径:{}", imageFileName); log.info("生成附件路径:{}", imageFileName);
imageFileName = ArchivesUtil.codeUtf8(imageFileName); imageFileName = ArchivesUtil.codeUtf8(imageFileName);
try { try {
@ -157,21 +175,30 @@ public class ReceivingPushArchivesService {
JSONObject data = result.getJSONObject("data"); JSONObject data = result.getJSONObject("data");
String destFileName = data.getString("destFileName"); String destFileName = data.getString("destFileName");
String viewUrl = data.getString("viewUrl"); String viewUrl = data.getString("viewUrl");
ArchivesUtil.downloadFile(viewUrl, filePath + File.separator + requestid + File.separator + fjdir + File.separator + imageFileManager.getImageFileName() + ".pdf"); ArchivesUtil.downloadFile(viewUrl, filePath + File.separator + newRequestid + File.separator + fjdir + File.separator + lcfjWord+ i[0] + "-" + (imageFileManager.getImageFileName().replaceAll("/","-")) + ".pdf");
} }
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
}finally {
if(inputStream!=null) {
try {
inputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
} }
i[0]++;
}); });
i[0] = 1;
//签字意见附件 //签字意见附件
signFiles.forEach((docid, imageid) -> { signFiles.forEach((docid, imageid) -> {
ImageFileManager imageFileManager = new ImageFileManager(); ImageFileManager imageFileManager = new ImageFileManager();
imageFileManager.getImageFileInfoById(Util.getIntValue(imageid)); imageFileManager.getImageFileInfoById(Util.getIntValue(imageid));
InputStream inputStream = imageFileManager.getInputStream(); InputStream inputStream = imageFileManager.getInputStream();
//中文路径/中文文件名 //中文路径/中文文件名
String imageFileName = filePath + File.separator + requestid + File.separator + fjdir + File.separator + imageFileManager.getImageFileName(); String imageFileName = filePath + File.separator + newRequestid + File.separator + fjdir + File.separator + qzyjfjWord + i[0] + "-" +imageFileManager.getImageFileName();
fjFileName.add(imageFileManager.getImageFileName()); fjFileName.add(qzyjfjWord + i[0] + "-" +imageFileManager.getImageFileName());
log.info("生成签字意见附件路径:{}", imageFileName); log.info("生成签字意见附件路径:{}", imageFileName);
imageFileName = ArchivesUtil.codeUtf8(imageFileName); imageFileName = ArchivesUtil.codeUtf8(imageFileName);
try { try {
@ -184,21 +211,107 @@ public class ReceivingPushArchivesService {
JSONObject data = result.getJSONObject("data"); JSONObject data = result.getJSONObject("data");
String destFileName = data.getString("destFileName"); String destFileName = data.getString("destFileName");
String viewUrl = data.getString("viewUrl"); String viewUrl = data.getString("viewUrl");
ArchivesUtil.downloadFile(viewUrl, filePath + File.separator + requestid + File.separator + fjdir + File.separator + imageFileManager.getImageFileName() + ".pdf"); ArchivesUtil.downloadFile(viewUrl, filePath + File.separator + newRequestid + File.separator + fjdir + File.separator + qzyjfjWord + i[0] + "-" + imageFileManager.getImageFileName() + ".pdf");
} }
i[0]++;
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); 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;
//正文 //正文
zwkbjMap.forEach((docid, imageid) -> { lczwMap.forEach((docid, imageid) -> {
ImageFileManager imageFileManager = new ImageFileManager(); ImageFileManager imageFileManager = new ImageFileManager();
imageFileManager.getImageFileInfoById(Util.getIntValue(imageid)); imageFileManager.getImageFileInfoById(Util.getIntValue(imageid));
InputStream inputStream = imageFileManager.getInputStream(); InputStream inputStream = imageFileManager.getInputStream();
zwFileName.add(imageFileManager.getImageFileName()); zwFileName.add(imageFileManager.getImageFileName());
//中文路径/中文文件名 //中文路径/中文文件名
String imageFileName = filePath + File.separator + requestid + File.separator + zwdir + File.separator + imageFileManager.getImageFileName(); String imageFileName = filePath + File.separator + newRequestid + File.separator + zwdir + File.separator + (imageFileManager.getImageFileName().replaceAll("/","-"));
log.info("生成正文路径:{}", imageFileName); log.info("生成正文路径:{}", imageFileName);
imageFileName = ArchivesUtil.codeUtf8(imageFileName); imageFileName = ArchivesUtil.codeUtf8(imageFileName);
try { try {
@ -211,10 +324,19 @@ public class ReceivingPushArchivesService {
JSONObject data = result.getJSONObject("data"); JSONObject data = result.getJSONObject("data");
String destFileName = data.getString("destFileName"); String destFileName = data.getString("destFileName");
String viewUrl = data.getString("viewUrl"); String viewUrl = data.getString("viewUrl");
ArchivesUtil.downloadFile(viewUrl, filePath + File.separator + requestid + File.separator + zwdir + File.separator + imageFileManager.getImageFileName() + ".pdf"); ArchivesUtil.downloadFile(viewUrl, filePath + File.separator + newRequestid + File.separator + zwdir + File.separator + (imageFileManager.getImageFileName().replaceAll("/","-")) + ".pdf");
} }
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
}finally {
if(inputStream!=null) {
try {
inputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
} }
}); });
//开始承办单 先获取主流程的承办单 //开始承办单 先获取主流程的承办单
@ -229,13 +351,15 @@ public class ReceivingPushArchivesService {
docids.addAll(requestDocid); docids.addAll(requestDocid);
// 3.去掉生成子流程承办单 // 3.去掉生成子流程承办单
// docids.addAll(subRequestDocid); // docids.addAll(subRequestDocid);
//附件 //承办单
reqDocMap.forEach((docid, imageid) -> { reqDocMap.forEach((docid, imageid) -> {
ImageFileManager imageFileManager = new ImageFileManager(); ImageFileManager imageFileManager = new ImageFileManager();
imageFileManager.getImageFileInfoById(Util.getIntValue(imageid)); imageFileManager.getImageFileInfoById(Util.getIntValue(imageid));
InputStream inputStream = imageFileManager.getInputStream(); 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 + 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); log.info("主流程承办单路径:{}", imageFileName);
imageFileName = ArchivesUtil.codeUtf8(imageFileName); imageFileName = ArchivesUtil.codeUtf8(imageFileName);
try { try {
@ -248,11 +372,19 @@ public class ReceivingPushArchivesService {
JSONObject data = result.getJSONObject("data"); JSONObject data = result.getJSONObject("data");
String destFileName = data.getString("destFileName"); String destFileName = data.getString("destFileName");
String viewUrl = data.getString("viewUrl"); String viewUrl = data.getString("viewUrl");
ArchivesUtil.downloadFile(viewUrl, filePath + File.separator + requestid + File.separator + cbddir + File.separator + fjFile + i[0] + "_" + imageFileManager.getImageFileName() + ".pdf"); ArchivesUtil.downloadFile(viewUrl, filePath + File.separator + newRequestid + File.separator + cbddir + File.separator + wjcldWord + ".pdf" + ".pdf");
} }
i[0]++; i[0]++;
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
}finally {
if(inputStream!=null) {
try {
inputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
} }
}); });
//正文 //正文
@ -291,10 +423,9 @@ public class ReceivingPushArchivesService {
ArchivesUtil.deleteDocByid(docid); ArchivesUtil.deleteDocByid(docid);
} }
//-------------------------------------------------------------------- //--------------------------------------------------------------------
RequestService requestService = new RequestService();
RequestInfo requestInfo = requestService.getRequest(Util.getIntValue(requestid), 100);
String logFile = ArchivesUtil.getSignLog(requestid, cbddir+File.separator+lzxxdir, requestInfo.getCreatorid() + requestInfo.getDescription(),templatePath,filePath,true);
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)); String s = ArchivesUtil.callApi(Url, new File(logFile));
log.error(s); log.error(s);
JSONObject result = JSONObject.parseObject(s); JSONObject result = JSONObject.parseObject(s);
@ -305,16 +436,19 @@ public class ReceivingPushArchivesService {
String viewUrl = data.getString("viewUrl"); String viewUrl = data.getString("viewUrl");
ArchivesUtil.downloadFile(viewUrl, logFile + ".pdf"); ArchivesUtil.downloadFile(viewUrl, logFile + ".pdf");
} }
String zipName = filePath + File.separator + requestid + ".zip"; String zipName = filePath + File.separator + newRequestid + ".zip";
ZipUtil.zip(filePath + File.separator + requestid, zipName); ZipUtil.zip(filePath + File.separator + newRequestid, zipName);
log.error("zipName:{}", zipName); log.error("zipName:{}", zipName);
String ftpFilePath = HgUtils.putFile(zipName, requestid + ".zip"); String ftpFilePath = HgUtils.putFile(zipName, newRequestid + ".zip");
ArchivesUtil.deleteDirectory(filePath + File.separator + newRequestid);
updateRecord(requestid,"esbwjml",ftpFilePath);
log.error("ftpFilePath:{}", ftpFilePath); log.error("ftpFilePath:{}", ftpFilePath);
String ftpFilePathNew = HgUtils.putFile(zipName, "test" + File.separator + requestid + ".zip"); // String ftpFilePathNew = HgUtils.putFile(zipName, "test" + File.separator + newRequestid + ".zip");
log.error("ftpFilePathNew:{}", ftpFilePathNew); // log.error("ftpFilePathNew:{}", ftpFilePathNew);
String context = getContext(requestid, requesData, requestid + ".zip", zwFileName, fjFileName); String context = getContext(requestid, requesData, newRequestid + ".zip", zwFileName, fjFileName);
insertRecord(requestid, context, ftpFilePath); // insertRecord(requestid, context, ftpFilePath);
log.error("context:{}", context); log.error("context:{}", context);
updateRecord(requestid,"content",context);
return context; return context;
} }
@ -392,6 +526,9 @@ public class ReceivingPushArchivesService {
record.put("yffbm", Util.null2String(rs.getString("yffbm"))); record.put("yffbm", Util.null2String(rs.getString("yffbm")));
record.put("ffbmb", Util.null2String(rs.getString("ffbmb"))); record.put("ffbmb", Util.null2String(rs.getString("ffbmb")));
record.put("yffbm", Util.null2String(rs.getString("yffbm"))); 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); rs.executeQuery(reqsql, requestid);
if (rs.next()) { if (rs.next()) {
@ -405,18 +542,19 @@ public class ReceivingPushArchivesService {
StringBuilder context = new StringBuilder(); StringBuilder context = new StringBuilder();
try { try {
String swrq = Util.null2String(requesData.get("swrq")); String swrq = Util.null2String(requesData.get("lwrq"));
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
LocalDate date = LocalDate.parse(swrq, formatter); LocalDate date = LocalDate.parse(swrq, formatter);
int year = date.getYear(); int year = date.getYear();
context.append(year).append("|"); context.append(year).append("|");
String jghwt = Util.null2String(requesData.get("jghwt")); String jghwt = Util.null2String(requesData.get("jghwt"));
context.append(jghwt).append("|"); context.append(jghwt).append("|");
String swh = Util.null2String(requesData.get("swh")); // String swh = Util.null2String(requesData.get("swh"));
String swh = Util.null2String(requesData.get("lwh"));
context.append(swh).append("|"); context.append(swh).append("|");
String requestname = Util.null2String(requesData.get("REQUESTNAME")); String requestname = Util.null2String(requesData.get("REQUESTNAME"));
context.append(requestname).append("|"); context.append(requestname).append("|");
String lwdwmc = Util.null2String(requesData.get("lwdwmc")); //5 责任者 -> 来文单位 String lwdwmc = Util.null2String(requesData.get("lwdwsx")); //5 责任者 -> 来文单位
context.append(lwdwmc).append("|"); context.append(lwdwmc).append("|");
String bgqx = Util.null2String(requesData.get("bgqx")); //6 保管期限 -> 保管期限 String bgqx = Util.null2String(requesData.get("bgqx")); //6 保管期限 -> 保管期限
context.append(bgqx).append("|"); context.append(bgqx).append("|");
@ -428,8 +566,10 @@ public class ReceivingPushArchivesService {
context.append(wz).append("|"); context.append(wz).append("|");
String ngbm = Util.null2String(requesData.get("ngbm")); String ngbm = Util.null2String(requesData.get("ngbm"));
String[] deptData = ArchivesUtil.getDeptNameAndCode(ngbm); String[] deptData = ArchivesUtil.getDeptNameAndCode(ngbm);
context.append(deptData[0]).append("|"); //10 行编号 -> 拟稿部门 String[] subData = ArchivesUtil.getSubCom(ngbm);
context.append(deptData[1]).append("|"); //11 行名称 context.append("D10001").append("|"); //10 行编号 -> 拟稿部门
context.append("总行机关").append("|"); //11 行名称
context.append("").append("|"); // 12 保管期限编号 context.append("").append("|"); // 12 保管期限编号
context.append("").append("|"); // 13 保管期限及编号 context.append("").append("|"); // 13 保管期限及编号
context.append("").append("|"); // 14 是否开放 context.append("").append("|"); // 14 是否开放
@ -439,7 +579,8 @@ public class ReceivingPushArchivesService {
//TODO //TODO
String xgbm = Util.null2String(getAssociatedDepts(requesData)); String xgbm = Util.null2String(getAssociatedDepts(requesData));
context.append(xgbm).append("|"); //17 相关部门 -> 流经部门 context.append(xgbm).append("|"); //17 相关部门 -> 流经部门
String lwh = Util.null2String(requesData.get("lwh"));// 18 收文号 -> 来文文号 // String lwh = Util.null2String(requesData.get("lwh"));// 18 收文号 -> 来文文号
String lwh = Util.null2String(requesData.get("swh"));// 18 收文号 -> 来文文号
context.append(lwh).append("|"); context.append(lwh).append("|");
String fs = ""; String fs = "";
context.append(fs).append("|"); // 19 份数 -> 份数 context.append(fs).append("|"); // 19 份数 -> 份数
@ -463,7 +604,7 @@ public class ReceivingPushArchivesService {
context.append(year).append("|"); // 30 形成年度 -> 年份 context.append(year).append("|"); // 30 形成年度 -> 年份
context.append(String.join("&&", zwFileName)).append("|"); // 31 正文名称 context.append(String.join("&&", zwFileName)).append("|"); // 31 正文名称
context.append(String.join("&&", fjFileName)).append("|"); // 32 附件名称 context.append(String.join("&&", fjFileName)).append("|"); // 32 附件名称
context.append(requestid).append("|"); // 33 主键 context.append("togd"+requestid).append("|"); // 33 主键
context.append("").append("|"); // 34 关联主键 context.append("").append("|"); // 34 关联主键
context.append("").append("|"); // 35 被关联主键 context.append("").append("|"); // 35 被关联主键
context.append(zipName);// 36 压缩包名称 context.append(zipName);// 36 压缩包名称
@ -482,7 +623,88 @@ public class ReceivingPushArchivesService {
records.addAll(Arrays.asList(Util.null2String(requesData.get("yffbm")).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("ffbmb")).split(",")));
records.addAll(Arrays.asList(Util.null2String(requesData.get("zfbm")).split(","))); records.addAll(Arrays.asList(Util.null2String(requesData.get("zfbm")).split(",")));
return String.join("&&", records); 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 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);
}
} }

@ -33,6 +33,7 @@ public class SendingPushArchivesService {
private static String filePath; private static String filePath;
private static String Url; private static String Url;
private static String templatePath; // 模板文件路径 private static String templatePath; // 模板文件路径
private int endTime= 7;
private static final String zwdir = "正文"; private static final String zwdir = "正文";
private static final String fjdir = "附件"; private static final String fjdir = "附件";
private static final String cbddir = "承办单"; private static final String cbddir = "承办单";
@ -51,6 +52,7 @@ public class SendingPushArchivesService {
filePath = Util.null2String(param.get("filePath")); filePath = Util.null2String(param.get("filePath"));
Url = Util.null2String(param.get("Url")); Url = Util.null2String(param.get("Url"));
templatePath = Util.null2String(param.get("templatePath")); templatePath = Util.null2String(param.get("templatePath"));
endTime = Util.getIntValue(param.get("endTime"),7);
} }
public void pushArchives(Map<String, String> param) { public void pushArchives(Map<String, String> param) {
@ -69,11 +71,18 @@ public class SendingPushArchivesService {
File file = ArchivesUtil.crFile(filePath + "/togd_" + new SimpleDateFormat("yyyyMMdd000000").format(date)); File file = ArchivesUtil.crFile(filePath + "/togd_" + new SimpleDateFormat("yyyyMMdd000000").format(date));
log.error("textfile:{}", file.getAbsolutePath()); log.error("textfile:{}", file.getAbsolutePath());
for (PushArchivesBean pushArchivesBean : result) { for (PushArchivesBean pushArchivesBean : result) {
int id = pushArchivesBean.getId(); if (ArchivesUtil.isAfterSevenAM(endTime)){
log.info("超过执行时间:{}点暂停计划任务",endTime);
break;
}
// int id = pushArchivesBean.getId();
int request = pushArchivesBean.getRequest(); int request = pushArchivesBean.getRequest();
log.error("推送的requestId:{}", request); log.error("推送的requestId:{}", request);
try { try {
String context = generateFile(request); String context = generateFile(request);
if ("-1".equals(context)){
continue;
}
ArchivesUtil.writeToTxt(file.getPath(), file.getName(), context, true); ArchivesUtil.writeToTxt(file.getPath(), file.getName(), context, true);
File txtzip = new File(filePath + File.separator + "togd_" + new SimpleDateFormat("yyyyMMdd000000").format(date) + ".zip"); File txtzip = new File(filePath + File.separator + "togd_" + new SimpleDateFormat("yyyyMMdd000000").format(date) + ".zip");
log.error("textZipFile:{}", txtzip.getAbsolutePath()); log.error("textZipFile:{}", txtzip.getAbsolutePath());
@ -82,12 +91,18 @@ public class SendingPushArchivesService {
com.engine.custom.hg.util.ZipUtil.filesToZip(writename, outputStream, writename.getName()); com.engine.custom.hg.util.ZipUtil.filesToZip(writename, outputStream, writename.getName());
log.error("writename:{}", writename.getName()); log.error("writename:{}", writename.getName());
String s = HgUtils.putFile(txtzip.getAbsolutePath(), txtzip.getName()); String s = HgUtils.putFile(txtzip.getAbsolutePath(), txtzip.getName());
updateRecord(request, s); updateRecord(request,"esbtxtml",s);
updateRecord(request,"zt","0");
log.error("textZip:{}", s); log.error("textZip:{}", s);
} catch (FtpException e) { } catch (FtpException e) {
e.printStackTrace(); e.printStackTrace();
log.error("推送档案requestid:{}异常,异常原因为:{}",request,e.getMessage());
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
log.error("推送档案requestid:{}异常,异常原因为:{}",request,e.getMessage());
} catch (Exception e){
e.printStackTrace();
log.error("推送档案requestid:{}异常,异常原因为:{}",request,e.getMessage());
} }
} }
@ -96,7 +111,12 @@ public class SendingPushArchivesService {
private String generateFile(int requestid) throws FtpException, IOException { private String generateFile(int requestid) throws FtpException, IOException {
Map<String, String> requesData = getRequestByid(requestid); Map<String, String> requesData = getRequestByid(requestid);
String newRequestid = "togd"+requestid;
log.info("requesData:{}", requesData); log.info("requesData:{}", requesData);
String bh = requesData.get("bh");
if (StringUtil.isEmpty(bh)){
return "-1";
}
String fj = Util.null2String(requesData.get("fj")); String fj = Util.null2String(requesData.get("fj"));
String dwd = Util.null2String(requesData.get("dwd")); String dwd = Util.null2String(requesData.get("dwd"));
String zw = Util.null2String(requesData.get("zw")); String zw = Util.null2String(requesData.get("zw"));
@ -123,8 +143,8 @@ public class SendingPushArchivesService {
imageFileManager.getImageFileInfoById(Util.getIntValue(imageid)); imageFileManager.getImageFileInfoById(Util.getIntValue(imageid));
InputStream inputStream = imageFileManager.getInputStream(); InputStream inputStream = imageFileManager.getInputStream();
//中文路径/中文文件名 //中文路径/中文文件名
String imageFileName = filePath + File.separator + requestid + File.separator + fjdir + File.separator + lcfjWord + "-" +imageFileManager.getImageFileName(); String imageFileName = filePath + File.separator + newRequestid + File.separator + fjdir + File.separator + lcfjWord + "-" +imageFileManager.getImageFileName();
fjFileName.add(imageFileManager.getImageFileName()); fjFileName.add(lcfjWord + "-" +imageFileManager.getImageFileName());
log.info("生成附件路径:{}", imageFileName); log.info("生成附件路径:{}", imageFileName);
imageFileName = ArchivesUtil.codeUtf8(imageFileName); imageFileName = ArchivesUtil.codeUtf8(imageFileName);
try { try {
@ -137,10 +157,18 @@ public class SendingPushArchivesService {
JSONObject data = result.getJSONObject("data"); JSONObject data = result.getJSONObject("data");
String destFileName = data.getString("destFileName"); String destFileName = data.getString("destFileName");
String viewUrl = data.getString("viewUrl"); String viewUrl = data.getString("viewUrl");
ArchivesUtil.downloadFile(viewUrl, filePath + File.separator + requestid + File.separator + fjdir + File.separator + lcfjWord + "-" + imageFileManager.getImageFileName() + ".pdf"); ArchivesUtil.downloadFile(viewUrl, filePath + File.separator + newRequestid + File.separator + fjdir + File.separator + lcfjWord + "-" + imageFileManager.getImageFileName() + ".pdf");
} }
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
}finally {
if(inputStream!=null) {
try {
inputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
} }
}); });
@ -150,8 +178,8 @@ public class SendingPushArchivesService {
imageFileManager.getImageFileInfoById(Util.getIntValue(imageid)); imageFileManager.getImageFileInfoById(Util.getIntValue(imageid));
InputStream inputStream = imageFileManager.getInputStream(); InputStream inputStream = imageFileManager.getInputStream();
//中文路径/中文文件名 //中文路径/中文文件名
String imageFileName = filePath + File.separator + requestid + File.separator + fjdir + File.separator + qzyjfjWord+ "-" +imageFileManager.getImageFileName(); String imageFileName = filePath + File.separator + newRequestid + File.separator + fjdir + File.separator + qzyjfjWord+ "-" +imageFileManager.getImageFileName();
fjFileName.add(imageFileManager.getImageFileName()); fjFileName.add(qzyjfjWord+ "-" +imageFileManager.getImageFileName());
log.info("生成签字意见附件路径:{}", imageFileName); log.info("生成签字意见附件路径:{}", imageFileName);
imageFileName = ArchivesUtil.codeUtf8(imageFileName); imageFileName = ArchivesUtil.codeUtf8(imageFileName);
try { try {
@ -164,10 +192,18 @@ public class SendingPushArchivesService {
JSONObject data = result.getJSONObject("data"); JSONObject data = result.getJSONObject("data");
String destFileName = data.getString("destFileName"); String destFileName = data.getString("destFileName");
String viewUrl = data.getString("viewUrl"); String viewUrl = data.getString("viewUrl");
ArchivesUtil.downloadFile(viewUrl, filePath + File.separator + requestid + File.separator + fjdir + File.separator + qzyjfjWord+ "-" + imageFileManager.getImageFileName() + ".pdf"); ArchivesUtil.downloadFile(viewUrl, filePath + File.separator + newRequestid + File.separator + fjdir + File.separator + qzyjfjWord+ "-" + imageFileManager.getImageFileName() + ".pdf");
} }
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
}finally {
if(inputStream!=null) {
try {
inputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
} }
}); });
@ -204,9 +240,9 @@ public class SendingPushArchivesService {
imageFileManager.getImageFileInfoById(Util.getIntValue(imageid)); imageFileManager.getImageFileInfoById(Util.getIntValue(imageid));
InputStream inputStream = imageFileManager.getInputStream(); InputStream inputStream = imageFileManager.getInputStream();
String newFile = fjWord + i[0] + "_" + zwWord + "-" + imageFileManager.getImageFileName(); String newFile = fjWord + i[0] + "_" + zwWord + "-" + (imageFileManager.getImageFileName().replaceAll("/","-"));
//中文路径/中文文件名 //中文路径/中文文件名
String imageFileName = filePath + File.separator + requestid + File.separator + zwdir + File.separator + newFile; String imageFileName = filePath + File.separator + newRequestid + File.separator + zwdir + File.separator + newFile;
zwFileName.add(newFile); zwFileName.add(newFile);
log.info("生成正文路径:{}", imageFileName); log.info("生成正文路径:{}", imageFileName);
imageFileName = ArchivesUtil.codeUtf8(imageFileName); imageFileName = ArchivesUtil.codeUtf8(imageFileName);
@ -220,10 +256,18 @@ public class SendingPushArchivesService {
JSONObject data = result.getJSONObject("data"); JSONObject data = result.getJSONObject("data");
String destFileName = data.getString("destFileName"); String destFileName = data.getString("destFileName");
String viewUrl = data.getString("viewUrl"); String viewUrl = data.getString("viewUrl");
ArchivesUtil.downloadFile(viewUrl, filePath + File.separator + requestid + File.separator + zwdir + File.separator + newFile + ".pdf"); ArchivesUtil.downloadFile(viewUrl, filePath + File.separator + newRequestid + File.separator + zwdir + File.separator + newFile + ".pdf");
} }
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
}finally {
if(inputStream!=null) {
try {
inputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
} }
i[0]++; i[0]++;
}); });
@ -233,10 +277,10 @@ public class SendingPushArchivesService {
imageFileManager.getImageFileInfoById(Util.getIntValue(imageid)); imageFileManager.getImageFileInfoById(Util.getIntValue(imageid));
InputStream inputStream = imageFileManager.getInputStream(); InputStream inputStream = imageFileManager.getInputStream();
String newFile = fjWord + i[0] + "_" + lhgWord + "-" + imageFileManager.getImageFileName(); String newFile = fjWord + i[0] + "_" + lhgWord + "-" + (imageFileManager.getImageFileName().replaceAll("/","-"));
zwFileName.add(newFile); zwFileName.add(newFile);
//中文路径/中文文件名 //中文路径/中文文件名
String imageFileName = filePath + File.separator + requestid + File.separator + zwdir + File.separator + newFile; String imageFileName = filePath + File.separator + newRequestid + File.separator + zwdir + File.separator + newFile;
log.info("生成清稿前痕迹路径:{}", imageFileName); log.info("生成清稿前痕迹路径:{}", imageFileName);
imageFileName = ArchivesUtil.codeUtf8(imageFileName); imageFileName = ArchivesUtil.codeUtf8(imageFileName);
try { try {
@ -249,10 +293,18 @@ public class SendingPushArchivesService {
JSONObject data = result.getJSONObject("data"); JSONObject data = result.getJSONObject("data");
String destFileName = data.getString("destFileName"); String destFileName = data.getString("destFileName");
String viewUrl = data.getString("viewUrl"); String viewUrl = data.getString("viewUrl");
ArchivesUtil.downloadFile(viewUrl, filePath + File.separator + requestid + File.separator + zwdir + File.separator + newFile + ".pdf"); ArchivesUtil.downloadFile(viewUrl, filePath + File.separator + newRequestid + File.separator + zwdir + File.separator + newFile + ".pdf");
} }
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
}finally {
if(inputStream!=null) {
try {
inputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
} }
i[0]++; i[0]++;
}); });
@ -304,7 +356,8 @@ public class SendingPushArchivesService {
InputStream inputStream = imageFileManager.getInputStream(); 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 + requestid + File.separator + cbddir + File.separator + fjFile + i[0] + "_" + imageFileManager.getImageFileName();
String imageFileName = filePath + File.separator + requestid + File.separator + cbddir + File.separator + fjFile + i[0] + "_" + wjcldWord+".pdf"; // 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); log.info("主流程承办单路径:{}", imageFileName);
imageFileName = ArchivesUtil.codeUtf8(imageFileName); imageFileName = ArchivesUtil.codeUtf8(imageFileName);
try { try {
@ -317,11 +370,19 @@ public class SendingPushArchivesService {
JSONObject data = result.getJSONObject("data"); JSONObject data = result.getJSONObject("data");
String destFileName = data.getString("destFileName"); String destFileName = data.getString("destFileName");
String viewUrl = data.getString("viewUrl"); String viewUrl = data.getString("viewUrl");
ArchivesUtil.downloadFile(viewUrl, filePath + File.separator + requestid + 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]++; i[0]++;
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
}finally {
if(inputStream!=null) {
try {
inputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
} }
}); });
//正文 //正文
@ -347,15 +408,18 @@ public class SendingPushArchivesService {
String viewUrl = data.getString("viewUrl"); String viewUrl = data.getString("viewUrl");
ArchivesUtil.downloadFile(viewUrl, logFile + ".pdf"); ArchivesUtil.downloadFile(viewUrl, logFile + ".pdf");
} }
String zipName = filePath + File.separator + requestid + ".zip"; String zipName = filePath + File.separator + newRequestid + ".zip";
ZipUtil.zip(filePath + File.separator + requestid, zipName); ZipUtil.zip(filePath + File.separator + newRequestid, zipName);
log.error("zipName:{}", zipName); log.error("zipName:{}", zipName);
String ftpFilePath = HgUtils.putFile(zipName, requestid + ".zip"); String ftpFilePath = HgUtils.putFile(zipName, newRequestid + ".zip");
log.error("ftpFilePath:{}", ftpFilePath); log.error("ftpFilePath:{}", ftpFilePath);
updateRecord(requestid,"esbwjml",ftpFilePath);
ArchivesUtil.deleteDirectory(filePath + File.separator + newRequestid);
// String ftpFilePathNew = HgUtils.putFile(zipName, "test" + File.separator + requestid + ".zip"); // String ftpFilePathNew = HgUtils.putFile(zipName, "test" + File.separator + requestid + ".zip");
// log.error("ftpFilePathNew:{}", ftpFilePathNew); // log.error("ftpFilePathNew:{}", ftpFilePathNew);
String context = getContext(requestid, requesData, requestid + ".zip", zwFileName, fjFileName); String context = getContext(requestid, requesData, newRequestid + ".zip", zwFileName, fjFileName);
// insertRecord(requestid, context, ftpFilePath); // insertRecord(requestid, context, ftpFilePath);
updateRecord(requestid,"content",context);
log.error("context:{}", context); log.error("context:{}", context);
return context; return context;
} }
@ -430,8 +494,10 @@ public class SendingPushArchivesService {
context.append(wz).append("|"); context.append(wz).append("|");
String ngbm = Util.null2String(requesData.get("ngbm")); String ngbm = Util.null2String(requesData.get("ngbm"));
String[] deptData = ArchivesUtil.getDeptNameAndCode(ngbm); String[] deptData = ArchivesUtil.getDeptNameAndCode(ngbm);
context.append(deptData[0]).append("|"); //10 行编号 -> 拟稿部门 String[] subData = ArchivesUtil.getSubCom(ngbm);
context.append(deptData[1]).append("|"); //11 行名称 context.append("D10001").append("|"); //10 行编号 -> 拟稿部门
context.append("总行机关").append("|"); //11 行名称
context.append("").append("|"); // 12 保管期限编号 context.append("").append("|"); // 12 保管期限编号
context.append("").append("|"); // 13 保管期限及编号 context.append("").append("|"); // 13 保管期限及编号
context.append("").append("|"); // 14 是否开放 context.append("").append("|"); // 14 是否开放
@ -465,7 +531,7 @@ public class SendingPushArchivesService {
context.append(year).append("|"); // 30 形成年度 -> 年份 context.append(year).append("|"); // 30 形成年度 -> 年份
context.append(String.join("&&", zwFileName)).append("|"); // 31 正文名称 context.append(String.join("&&", zwFileName)).append("|"); // 31 正文名称
context.append(String.join("&&", fjFileName)).append("|"); // 32 附件名称 context.append(String.join("&&", fjFileName)).append("|"); // 32 附件名称
context.append(requestid).append("|"); // 33 主键 context.append("togd"+requestid).append("|"); // 33 主键
context.append("").append("|"); // 34 关联主键 context.append("").append("|"); // 34 关联主键
context.append("").append("|"); // 35 被关联主键 context.append("").append("|"); // 35 被关联主键
context.append(zipName);// 36 压缩包名称 context.append(zipName);// 36 压缩包名称
@ -478,6 +544,8 @@ public class SendingPushArchivesService {
} }
private String getAssociatedDepts(Map<String, String> requesData) { private String getAssociatedDepts(Map<String, String> requesData) {
HashSet<String> records = new HashSet<>(); HashSet<String> records = new HashSet<>();
records.addAll(Arrays.asList(Util.null2String(requesData.get("hqbm")).split(","))); // 会签部门 records.addAll(Arrays.asList(Util.null2String(requesData.get("hqbm")).split(","))); // 会签部门
@ -494,7 +562,10 @@ public class SendingPushArchivesService {
DepartmentComInfo departmentComInfo = new DepartmentComInfo(); DepartmentComInfo departmentComInfo = new DepartmentComInfo();
for (String record : records) { for (String record : records) {
try { try {
String departmentName = departmentComInfo.getDepartmentName(record); if (StringUtil.isEmpty(record)){
continue;
}
String departmentName = departmentComInfo.getDepartmentmark(record);
deptName.add(departmentName); deptName.add(departmentName);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
@ -504,10 +575,10 @@ public class SendingPushArchivesService {
return String.join("&&", deptName); return String.join("&&", deptName);
} }
private void updateRecord(int requestid, String s) { private void updateRecord(int requestid, String field , String fieldvalue) {
String sql = "update uf_pushArchivesLog set esbtxtml = ? where request = ?"; String sql = "update uf_pushArchivesLog set "+field+" = ? where request = ?";
RecordSet recordSet = new RecordSet(); RecordSet recordSet = new RecordSet();
recordSet.executeUpdate(sql, s, requestid); recordSet.executeUpdate(sql, fieldvalue, requestid);
} }

@ -10,6 +10,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import weaver.conn.RecordSet; import weaver.conn.RecordSet;
import weaver.file.ImageFileManager; import weaver.file.ImageFileManager;
import weaver.general.StringUtil;
import weaver.general.Util; import weaver.general.Util;
import weaver.hrm.User; import weaver.hrm.User;
import weaver.hrm.company.DepartmentComInfo; import weaver.hrm.company.DepartmentComInfo;
@ -40,11 +41,13 @@ public class SignReportPushArchivesService {
private static final String qzyjfjWord = "签字意见附件"; private static final String qzyjfjWord = "签字意见附件";
private static final String wjcldWord = "文件处理单"; private static final String wjcldWord = "文件处理单";
private static final String wjlzxxWord = "文件流转信息"; private static final String wjlzxxWord = "文件流转信息";
private int endTime= 7;
public void setProp(Map<String, String> param) { public void setProp(Map<String, String> param) {
filePath = Util.null2String(param.get("filePath")); filePath = Util.null2String(param.get("filePath"));
Url = Util.null2String(param.get("Url")); Url = Util.null2String(param.get("Url"));
templatePath = Util.null2String(param.get("templatePath")); templatePath = Util.null2String(param.get("templatePath"));
endTime = Util.getIntValue(param.get("endTime"),7);
} }
public void pushArchives(Map<String, String> param) { public void pushArchives(Map<String, String> param) {
@ -63,11 +66,18 @@ public class SignReportPushArchivesService {
File file = ArchivesUtil.crFile(filePath + "/togd_" + new SimpleDateFormat("yyyyMMdd000000").format(date)); File file = ArchivesUtil.crFile(filePath + "/togd_" + new SimpleDateFormat("yyyyMMdd000000").format(date));
log.error("textfile:{}", file.getAbsolutePath()); log.error("textfile:{}", file.getAbsolutePath());
for (PushArchivesBean pushArchivesBean : result) { for (PushArchivesBean pushArchivesBean : result) {
if (ArchivesUtil.isAfterSevenAM(endTime)){
log.info("超过执行时间:{}点暂停计划任务",endTime);
break;
}
int id = pushArchivesBean.getId(); int id = pushArchivesBean.getId();
int request = pushArchivesBean.getRequest(); int request = pushArchivesBean.getRequest();
log.error("推送的requestId:{}", request); log.error("推送的requestId:{}", request);
try { try {
String context = generateFile(request); String context = generateFile(request);
if ("-1".equals(context)){
continue;
}
ArchivesUtil.writeToTxt(file.getPath(), file.getName(), context, true); ArchivesUtil.writeToTxt(file.getPath(), file.getName(), context, true);
File txtzip = new File(filePath + File.separator + "togd_" + new SimpleDateFormat("yyyyMMdd000000").format(date) + ".zip"); File txtzip = new File(filePath + File.separator + "togd_" + new SimpleDateFormat("yyyyMMdd000000").format(date) + ".zip");
log.error("textZipFile:{}", txtzip.getAbsolutePath()); log.error("textZipFile:{}", txtzip.getAbsolutePath());
@ -77,10 +87,18 @@ public class SignReportPushArchivesService {
log.error("writename:{}", writename.getName()); log.error("writename:{}", writename.getName());
String s = HgUtils.putFile(txtzip.getAbsolutePath(), txtzip.getName()); String s = HgUtils.putFile(txtzip.getAbsolutePath(), txtzip.getName());
// updateRecord(request, s); // updateRecord(request, s);
updateRecord(request,"esbtxtml",s);
updateRecord(request,"zt","0");
log.error("textZip:{}", s); log.error("textZip:{}", s);
} catch (FtpException e) { } catch (FtpException e) {
log.error("推送档案requestid:{}异常,异常原因为:{}",request,e.getMessage());
e.printStackTrace(); e.printStackTrace();
} catch (IOException e) { } catch (IOException e) {
log.error("推送档案requestid:{}异常,异常原因为:{}",request,e.getMessage());
e.printStackTrace();
} catch (Exception e) {
log.error("推送档案requestid:{}异常,异常原因为:{}",request,e.getMessage());
e.printStackTrace(); e.printStackTrace();
} }
} }
@ -90,11 +108,19 @@ public class SignReportPushArchivesService {
private String generateFile(int requestid) throws FtpException, IOException { private String generateFile(int requestid) throws FtpException, IOException {
Map<String, String> requesData = getRequestByid(requestid); Map<String, String> requesData = getRequestByid(requestid);
String newRequestid = "togd"+requestid;
log.info("requesData:{}", requesData); 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 fj = Util.null2String(requesData.get("fj"));
String dwd = Util.null2String(requesData.get("dwd")); String dwd = Util.null2String(requesData.get("dwd"));
String zw = Util.null2String(requesData.get("zw")); String zw = Util.null2String(requesData.get("zw"));
String qgqhj = Util.null2String(requesData.get("qgqhj")); String qgqhj = Util.null2String(requesData.get("qgqhj"));
//可能有多个,获取id最大的一个
qgqhj = Util.null2String(ArchivesUtil.findMaxValue(qgqhj));
//增加签字意见中的附件到附件文件夹中 //增加签字意见中的附件到附件文件夹中
Map<String, String> signFiles = ArchivesUtil.getSignFiles(requestid,true); Map<String, String> signFiles = ArchivesUtil.getSignFiles(requestid,true);
@ -113,7 +139,7 @@ public class SignReportPushArchivesService {
imageFileManager.getImageFileInfoById(Util.getIntValue(imageid)); imageFileManager.getImageFileInfoById(Util.getIntValue(imageid));
InputStream inputStream = imageFileManager.getInputStream(); InputStream inputStream = imageFileManager.getInputStream();
//中文路径/中文文件名 //中文路径/中文文件名
String imageFileName = filePath + File.separator + requestid + File.separator + fjdir + File.separator + lcfjWord + "-" +imageFileManager.getImageFileName(); String imageFileName = filePath + File.separator + newRequestid + File.separator + fjdir + File.separator + lcfjWord + "-" +imageFileManager.getImageFileName();
fjFileName.add(imageFileManager.getImageFileName()); fjFileName.add(imageFileManager.getImageFileName());
log.info("生成附件路径:{}", imageFileName); log.info("生成附件路径:{}", imageFileName);
imageFileName = ArchivesUtil.codeUtf8(imageFileName); imageFileName = ArchivesUtil.codeUtf8(imageFileName);
@ -127,10 +153,18 @@ public class SignReportPushArchivesService {
JSONObject data = result.getJSONObject("data"); JSONObject data = result.getJSONObject("data");
String destFileName = data.getString("destFileName"); String destFileName = data.getString("destFileName");
String viewUrl = data.getString("viewUrl"); String viewUrl = data.getString("viewUrl");
ArchivesUtil.downloadFile(viewUrl, filePath + File.separator + requestid + File.separator + fjdir + File.separator + lcfjWord + "-" + imageFileManager.getImageFileName() + ".pdf"); ArchivesUtil.downloadFile(viewUrl, filePath + File.separator + newRequestid + File.separator + fjdir + File.separator + lcfjWord + "-" + imageFileManager.getImageFileName() + ".pdf");
} }
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} finally {
if(inputStream!=null) {
try {
inputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
} }
}); });
@ -140,7 +174,7 @@ public class SignReportPushArchivesService {
imageFileManager.getImageFileInfoById(Util.getIntValue(imageid)); imageFileManager.getImageFileInfoById(Util.getIntValue(imageid));
InputStream inputStream = imageFileManager.getInputStream(); InputStream inputStream = imageFileManager.getInputStream();
//中文路径/中文文件名 //中文路径/中文文件名
String imageFileName = filePath + File.separator + requestid + File.separator + fjdir + File.separator + qzyjfjWord+ "-" +imageFileManager.getImageFileName(); String imageFileName = filePath + File.separator + newRequestid + File.separator + fjdir + File.separator + qzyjfjWord+ "-" +imageFileManager.getImageFileName();
fjFileName.add(imageFileManager.getImageFileName()); fjFileName.add(imageFileManager.getImageFileName());
log.info("生成签字意见附件路径:{}", imageFileName); log.info("生成签字意见附件路径:{}", imageFileName);
imageFileName = ArchivesUtil.codeUtf8(imageFileName); imageFileName = ArchivesUtil.codeUtf8(imageFileName);
@ -154,10 +188,18 @@ public class SignReportPushArchivesService {
JSONObject data = result.getJSONObject("data"); JSONObject data = result.getJSONObject("data");
String destFileName = data.getString("destFileName"); String destFileName = data.getString("destFileName");
String viewUrl = data.getString("viewUrl"); String viewUrl = data.getString("viewUrl");
ArchivesUtil.downloadFile(viewUrl, filePath + File.separator + requestid + File.separator + fjdir + File.separator + qzyjfjWord+ "-" + imageFileManager.getImageFileName() + ".pdf"); ArchivesUtil.downloadFile(viewUrl, filePath + File.separator + newRequestid + File.separator + fjdir + File.separator + qzyjfjWord+ "-" + imageFileManager.getImageFileName() + ".pdf");
} }
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} finally {
if(inputStream!=null) {
try {
inputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
} }
}); });
@ -168,9 +210,9 @@ public class SignReportPushArchivesService {
imageFileManager.getImageFileInfoById(Util.getIntValue(imageid)); imageFileManager.getImageFileInfoById(Util.getIntValue(imageid));
InputStream inputStream = imageFileManager.getInputStream(); InputStream inputStream = imageFileManager.getInputStream();
String newFile = fjWord + i[0] + "_" + zwWord + "-" + imageFileManager.getImageFileName(); String newFile = fjWord + i[0] + "_" + zwWord + "-" + (imageFileManager.getImageFileName().replaceAll("/","-"));
//中文路径/中文文件名 //中文路径/中文文件名
String imageFileName = filePath + File.separator + requestid + File.separator + zwdir + File.separator + newFile; String imageFileName = filePath + File.separator + newRequestid + File.separator + zwdir + File.separator + newFile;
zwFileName.add(newFile); zwFileName.add(newFile);
log.info("生成正文路径:{}", imageFileName); log.info("生成正文路径:{}", imageFileName);
imageFileName = ArchivesUtil.codeUtf8(imageFileName); imageFileName = ArchivesUtil.codeUtf8(imageFileName);
@ -184,10 +226,18 @@ public class SignReportPushArchivesService {
JSONObject data = result.getJSONObject("data"); JSONObject data = result.getJSONObject("data");
String destFileName = data.getString("destFileName"); String destFileName = data.getString("destFileName");
String viewUrl = data.getString("viewUrl"); String viewUrl = data.getString("viewUrl");
ArchivesUtil.downloadFile(viewUrl, filePath + File.separator + requestid + File.separator + zwdir + File.separator + newFile + ".pdf"); ArchivesUtil.downloadFile(viewUrl, filePath + File.separator + newRequestid + File.separator + zwdir + File.separator + newFile + ".pdf");
} }
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} finally {
if(inputStream!=null) {
try {
inputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
} }
i[0]++; i[0]++;
}); });
@ -197,10 +247,10 @@ public class SignReportPushArchivesService {
imageFileManager.getImageFileInfoById(Util.getIntValue(imageid)); imageFileManager.getImageFileInfoById(Util.getIntValue(imageid));
InputStream inputStream = imageFileManager.getInputStream(); InputStream inputStream = imageFileManager.getInputStream();
String newFile = fjWord + i[0] + "_" + lhgWord + "-" + imageFileManager.getImageFileName(); String newFile = fjWord + i[0] + "_" + lhgWord + "-" + (imageFileManager.getImageFileName().replaceAll("/","-"));
zwFileName.add(newFile); zwFileName.add(newFile);
//中文路径/中文文件名 //中文路径/中文文件名
String imageFileName = filePath + File.separator + requestid + File.separator + zwdir + File.separator + newFile; String imageFileName = filePath + File.separator + newRequestid + File.separator + zwdir + File.separator + newFile;
log.info("生成清稿前痕迹路径:{}", imageFileName); log.info("生成清稿前痕迹路径:{}", imageFileName);
imageFileName = ArchivesUtil.codeUtf8(imageFileName); imageFileName = ArchivesUtil.codeUtf8(imageFileName);
try { try {
@ -213,10 +263,18 @@ public class SignReportPushArchivesService {
JSONObject data = result.getJSONObject("data"); JSONObject data = result.getJSONObject("data");
String destFileName = data.getString("destFileName"); String destFileName = data.getString("destFileName");
String viewUrl = data.getString("viewUrl"); String viewUrl = data.getString("viewUrl");
ArchivesUtil.downloadFile(viewUrl, filePath + File.separator + requestid + File.separator + zwdir + File.separator + newFile + ".pdf"); ArchivesUtil.downloadFile(viewUrl, filePath + File.separator + newRequestid + File.separator + zwdir + File.separator + newFile + ".pdf");
} }
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} finally {
if(inputStream!=null) {
try {
inputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
} }
i[0]++; i[0]++;
}); });
@ -268,7 +326,8 @@ public class SignReportPushArchivesService {
InputStream inputStream = imageFileManager.getInputStream(); 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 + requestid + File.separator + cbddir + File.separator + fjFile + i[0] + "_" + imageFileManager.getImageFileName();
String imageFileName = filePath + File.separator + requestid + File.separator + cbddir + File.separator + fjFile + i[0] + "_" + wjcldWord+".pdf"; // 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); log.info("主流程承办单路径:{}", imageFileName);
imageFileName = ArchivesUtil.codeUtf8(imageFileName); imageFileName = ArchivesUtil.codeUtf8(imageFileName);
try { try {
@ -281,11 +340,20 @@ public class SignReportPushArchivesService {
JSONObject data = result.getJSONObject("data"); JSONObject data = result.getJSONObject("data");
String destFileName = data.getString("destFileName"); String destFileName = data.getString("destFileName");
String viewUrl = data.getString("viewUrl"); String viewUrl = data.getString("viewUrl");
ArchivesUtil.downloadFile(viewUrl, filePath + File.separator + requestid + File.separator + cbddir + File.separator + fjFile + i[0] + "_" + wjcldWord + ".pdf" + ".pdf"); // 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]++; i[0]++;
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
}finally {
if(inputStream!=null) {
try {
inputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
} }
}); });
//正文 //正文
@ -311,15 +379,19 @@ public class SignReportPushArchivesService {
String viewUrl = data.getString("viewUrl"); String viewUrl = data.getString("viewUrl");
ArchivesUtil.downloadFile(viewUrl, logFile + ".pdf"); ArchivesUtil.downloadFile(viewUrl, logFile + ".pdf");
} }
String zipName = filePath + File.separator + requestid + ".zip"; String zipName = filePath + File.separator + newRequestid + ".zip";
ZipUtil.zip(filePath + File.separator + requestid, zipName); ZipUtil.zip(filePath + File.separator + newRequestid, zipName);
log.error("zipName:{}", zipName); log.error("zipName:{}", zipName);
String ftpFilePath = HgUtils.putFile(zipName, requestid + ".zip"); String ftpFilePath = HgUtils.putFile(zipName, newRequestid + ".zip");
log.error("ftpFilePath:{}", ftpFilePath); log.error("ftpFilePath:{}", ftpFilePath);
updateRecord(requestid,"esbwjml",ftpFilePath);
ArchivesUtil.deleteDirectory(filePath + File.separator + newRequestid);
// String ftpFilePathNew = HgUtils.putFile(zipName, "test" + File.separator + requestid + ".zip"); // String ftpFilePathNew = HgUtils.putFile(zipName, "test" + File.separator + requestid + ".zip");
// log.error("ftpFilePathNew:{}", ftpFilePathNew); // log.error("ftpFilePathNew:{}", ftpFilePathNew);
String context = getContext(requestid, requesData, requestid + ".zip", zwFileName, fjFileName); String context = getContext(requestid, requesData, newRequestid + ".zip", zwFileName, fjFileName);
// insertRecord(requestid, context, ftpFilePath); // insertRecord(requestid, context, ftpFilePath);
updateRecord(requestid,"content",context);
log.error("context:{}", context); log.error("context:{}", context);
return context; return context;
} }
@ -338,7 +410,8 @@ public class SignReportPushArchivesService {
rs.executeQuery(sql, requestid); rs.executeQuery(sql, requestid);
if (rs.next()) { if (rs.next()) {
record.put("bh", Util.null2String(rs.getString("bh"))); record.put("bh", Util.null2String(rs.getString("bh")));
record.put("ngbm", Util.null2String(rs.getString("ngbm "))); 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("ngr", Util.null2String(rs.getString("ngr")));
record.put("ngrq", Util.null2String(rs.getString("ngrq"))); record.put("ngrq", Util.null2String(rs.getString("ngrq")));
record.put("lxfs", Util.null2String(rs.getString("lxfs"))); record.put("lxfs", Util.null2String(rs.getString("lxfs")));
@ -374,7 +447,7 @@ public class SignReportPushArchivesService {
context.append(year).append("|"); //1.年度 -> 拟稿日期 context.append(year).append("|"); //1.年度 -> 拟稿日期
String jghwt = Util.null2String(requesData.get("jghwt"));//2.机构或问题 -> 机构或问题 String jghwt = Util.null2String(requesData.get("jghwt"));//2.机构或问题 -> 机构或问题
context.append(jghwt).append("|"); context.append(jghwt).append("|");
String bh = Util.null2String(requesData.get("bh"));// 3.文号 -> 编号 String bh = Util.null2String(requesData.get("bhnew"));// 3.文号 -> 编号
context.append(bh).append("|"); context.append(bh).append("|");
String requestname = Util.null2String(requesData.get("REQUESTNAME")); // 4.文件题名 -> 流程名称 String requestname = Util.null2String(requesData.get("REQUESTNAME")); // 4.文件题名 -> 流程名称
context.append(requestname).append("|"); context.append(requestname).append("|");
@ -382,16 +455,18 @@ public class SignReportPushArchivesService {
context.append(ngbmName).append("|"); context.append(ngbmName).append("|");
String bgqx = Util.null2String(requesData.get("bgqx")); //6 保管期限 -> 保管期限 String bgqx = Util.null2String(requesData.get("bgqx")); //6 保管期限 -> 保管期限
context.append(bgqx).append("|"); context.append(bgqx).append("|");
String cwrq = Util.null2String(requesData.get("cwrq")); //7 日期 -> 成文日期 // String cwrq = Util.null2String(requesData.get("cwrq")); //7 日期 -> 成文日期
context.append(cwrq).append("|"); context.append(ngrq).append("|");
String ys = Util.null2String(requesData.get("ys")); //8 页数 -> 页数 String ys = Util.null2String(requesData.get("ys")); //8 页数 -> 页数
context.append(ys).append("|"); context.append(ys).append("|");
String wz = Util.null2String(requesData.get("wz")); //9 文种 -> 文种 String wz = Util.null2String(requesData.get("wz")); //9 文种 -> 文种
context.append(wz).append("|"); context.append(wz).append("|");
String ngbm = Util.null2String(requesData.get("ngbm")); String ngbm = Util.null2String(requesData.get("ngbm"));
String[] deptData = ArchivesUtil.getDeptNameAndCode(ngbm); String[] deptData = ArchivesUtil.getDeptNameAndCode(ngbm);
context.append(deptData[0]).append("|"); //10 行编号 -> 拟稿部门 String[] subData = ArchivesUtil.getSubCom(ngbm);
context.append(deptData[1]).append("|"); //11 行名称 context.append("D10001").append("|"); //10 行编号 -> 拟稿部门
context.append("总行机关").append("|"); //11 行名称
context.append("").append("|"); // 12 保管期限编号 context.append("").append("|"); // 12 保管期限编号
context.append("").append("|"); // 13 保管期限及编号 context.append("").append("|"); // 13 保管期限及编号
context.append("").append("|"); // 14 是否开放 context.append("").append("|"); // 14 是否开放
@ -412,20 +487,20 @@ public class SignReportPushArchivesService {
String wjlx = Util.null2String(requesData.get("wjlx")); String wjlx = Util.null2String(requesData.get("wjlx"));
context.append("").append("|"); // 22 文件类型 -> 空 context.append("").append("|"); // 22 文件类型 -> 空
String fwlx = Util.null2String(requesData.get("fwlx")); String fwlx = Util.null2String(requesData.get("fwlx"));
context.append("总行发文").append("|"); // 23 发文类型 -> 空 context.append("总行签报").append("|"); // 23 发文类型 -> 空
String f = Util.null2String(requesData.get("f")); String f = Util.null2String(requesData.get("f"));
context.append(f).append("|"); // 24 发 -> 空 context.append(f).append("|"); // 24 发 -> 空
String ngr = Util.null2String(requesData.get("ngr")); String ngr = Util.null2String(requesData.get("ngr"));
context.append(new User(Util.getIntValue(ngr)).getLoginid()).append("|"); // 25 拟稿人 -> 拟稿人 context.append(new User(Util.getIntValue(ngr)).getLoginid()).append("|"); // 25 拟稿人 -> 拟稿人
context.append(ngbmName).append("|"); // 26 拟稿部门 -> 拟稿部门名称 context.append(ngbmName).append("|"); // 26 拟稿部门 -> 拟稿部门名称
context.append("发文").append("|"); // 27 公文类型 -> "收文" context.append("签报").append("|"); // 27 公文类型 -> "收文"
//TODO //TODO
context.append(ArchivesUtil.getAssociatedPersons(requestid,false)).append("|"); // 28 相关人员 -> 参与人员 context.append(ArchivesUtil.getAssociatedPersons(requestid,false)).append("|"); // 28 相关人员 -> 参与人员
context.append("智慧OA").append("|"); // 29 数据来源 -> 数据来源 context.append("智慧OA").append("|"); // 29 数据来源 -> 数据来源
context.append(year).append("|"); // 30 形成年度 -> 年份 context.append(year).append("|"); // 30 形成年度 -> 年份
context.append(String.join("&&", zwFileName)).append("|"); // 31 正文名称 context.append(String.join("&&", zwFileName)).append("|"); // 31 正文名称
context.append(String.join("&&", fjFileName)).append("|"); // 32 附件名称 context.append(String.join("&&", fjFileName)).append("|"); // 32 附件名称
context.append(requestid).append("|"); // 33 主键 context.append("togd"+requestid).append("|"); // 33 主键
context.append("").append("|"); // 34 关联主键 context.append("").append("|"); // 34 关联主键
context.append("").append("|"); // 35 被关联主键 context.append("").append("|"); // 35 被关联主键
context.append(zipName);// 36 压缩包名称 context.append(zipName);// 36 压缩包名称
@ -448,7 +523,10 @@ public class SignReportPushArchivesService {
DepartmentComInfo departmentComInfo = new DepartmentComInfo(); DepartmentComInfo departmentComInfo = new DepartmentComInfo();
for (String record : records) { for (String record : records) {
try { try {
String departmentName = departmentComInfo.getDepartmentName(record); if (StringUtil.isEmpty(record)){
continue;
}
String departmentName = departmentComInfo.getDepartmentmark(record);
deptName.add(departmentName); deptName.add(departmentName);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
@ -463,4 +541,9 @@ public class SignReportPushArchivesService {
RecordSet recordSet = new RecordSet(); RecordSet recordSet = new RecordSet();
recordSet.executeUpdate(sql, s, requestid); 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);
}
} }

@ -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

@ -4,10 +4,12 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.engine.core.impl.Service; import com.engine.core.impl.Service;
import com.engine.custom.archives.service.HtmlToPdfServiceCus; import com.engine.custom.archives.service.HtmlToPdfServiceCus;
import com.engine.custom.archives.util.ArchivesUtil;
import com.engine.custom.archives.workflow.cmd.requestLog.LoadRequestLogDataCusCmd; import com.engine.custom.archives.workflow.cmd.requestLog.LoadRequestLogDataCusCmd;
import com.engine.workflow.biz.RequestLogBiz; import com.engine.workflow.biz.RequestLogBiz;
import com.engine.workflow.biz.requestForm.LayoutInfoBiz; import com.engine.workflow.biz.requestForm.LayoutInfoBiz;
import com.engine.workflow.cmd.requestForm.*; import com.engine.workflow.cmd.requestForm.*;
import com.engine.workflow.entity.requestForm.FieldValueBean;
import com.engine.workflow.entity.requestForm.TableInfo; import com.engine.workflow.entity.requestForm.TableInfo;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
@ -17,14 +19,14 @@ import weaver.conn.RecordSet;
import weaver.general.BaseBean; import weaver.general.BaseBean;
import weaver.general.Util; import weaver.general.Util;
import weaver.hrm.User; import weaver.hrm.User;
import weaver.hrm.company.DepartmentComInfo;
import weaver.workflow.request.RequestManagerForTipsinfo; import weaver.workflow.request.RequestManagerForTipsinfo;
import weaver.workflow.request.WFLinkInfo; import weaver.workflow.request.WFLinkInfo;
import weaver.workflow.workflow.WorkflowBillComInfo;
import weaver.workflow.workflow.WorkflowComInfo;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList; import java.util.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class HtmlToPdfServiceCusImpl extends Service implements HtmlToPdfServiceCus { public class HtmlToPdfServiceCusImpl extends Service implements HtmlToPdfServiceCus {
public static Logger log = LoggerFactory.getLogger("Archives"); public static Logger log = LoggerFactory.getLogger("Archives");
@ -39,6 +41,7 @@ public class HtmlToPdfServiceCusImpl extends Service implements HtmlToPdfService
Map<String, Object> result =new HashMap<String, Object>(); Map<String, Object> result =new HashMap<String, Object>();
String requestid = Util.null2String(reqpParams.get("requestid")); String requestid = Util.null2String(reqpParams.get("requestid"));
String modeid = Util.null2String(reqpParams.get("modeid")); String modeid = Util.null2String(reqpParams.get("modeid"));
String workflowid = Util.null2String(reqpParams.get("workflowid"));
//只需要转换html //只需要转换html
int onlyHtml = Util.getIntValue(Util.null2String(reqpParams.get("onlyHtml")),0); int onlyHtml = Util.getIntValue(Util.null2String(reqpParams.get("onlyHtml")),0);
//用wktohtml转换 //用wktohtml转换
@ -92,6 +95,105 @@ public class HtmlToPdfServiceCusImpl extends Service implements HtmlToPdfService
Map<String, Object> maindata = commandExecutor.execute(new FormDataCmd(requestMap, user, params, (Map<String, TableInfo>) forminfo.get("tableInfo"))); Map<String, Object> maindata = commandExecutor.execute(new FormDataCmd(requestMap, user, params, (Map<String, TableInfo>) forminfo.get("tableInfo")));
apidatas.put("maindata", maindata.get("datas")); apidatas.put("maindata", maindata.get("datas"));
//根据流程id获取是否需要协办
RecordSet rs = new RecordSet();
rs.executeQuery("select * from uf_ArchivesSet where mainwfid = ?",workflowid);
//是否有协办流程
//------------------------------start----------------------------
try {
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<>();
List<String> Cowfids = Arrays.asList(cowfid.split(","));
Map<String, String> subRequest = ArchivesUtil.getSubRequest(requestid, 6);
log.info("subRequest:{}",subRequest);
for (Map.Entry<String, String> subRequestEntry : subRequest.entrySet()) {
String subWFid = subRequestEntry.getValue();
if (Cowfids.contains(subWFid)){
CoSubRequest.add(subRequestEntry.getKey());
}
}
log.info("CoSubRequest.size:{}",CoSubRequest.size());
if (CoSubRequest.size() != 0){
WorkflowComInfo wf = new WorkflowComInfo();
WorkflowBillComInfo wcInfo = new WorkflowBillComInfo();
String formId = wf.getFormId(Cowfids.get(0));
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 codept = cofieldsplit[0]; //协办部门
String corequirement = cofieldsplit[1]; //协办要求
while (rs.next()){
String codeptValue = Util.null2String(rs.getString(codept));
String corequirementText = Util.null2String(rs.getString(corequirement));
log.info("codeptValue:{}",codeptValue);
log.info("corequirementText:{}",corequirementText);
String codeptText = "";
String[] split = codeptValue.split(",");
DepartmentComInfo deptCom = new DepartmentComInfo();
for (String item : split) {
try {
String departmentName = deptCom.getDepartmentName(item);
codeptText = codeptText + "," + departmentName;
} catch (Exception e) {
e.printStackTrace();
}
}
log.info("codeptText:{}",codeptText);
if (codeptText.startsWith(",")){
codeptText = codeptText.substring(1);
}
if (!StringUtils.isBlank(codeptText)) {
fieldValue = fieldValue + "\n" + codeptText + " : " + corequirementText;
}
}
log.info("fieldValue:{}",fieldValue);
if (fieldValue.startsWith("\n")){
fieldValue = fieldValue.substring(1);
}
log.info("fieldValue:{}",fieldValue);
HashMap<String, Object> cofieldMap = new HashMap<>();
cofieldMap.put("value",fieldValue);
log.info("maindataold:{}",maindata);
FieldValueBean fieldValueBean = new FieldValueBean();
fieldValueBean.setValue(fieldValue);
Map datas = (Map)maindata.get("datas");
log.info("datas:{}",datas);
log.info("datas:{}", datas.getClass().getName() );
datas.put(cofieldid,fieldValueBean);
log.info("maindatanew:{}",maindata);
}
}
}catch (Exception e){
e.printStackTrace();
log.error(e.getMessage());
}
//------------------------------end----------------------------
//明细表数据 //明细表数据
Map<String, TableInfo> tableinfomap = (Map<String, TableInfo>)forminfo.get("tableInfo"); Map<String, TableInfo> tableinfomap = (Map<String, TableInfo>)forminfo.get("tableInfo");
List<String> detailmark = new ArrayList<String> (); List<String> detailmark = new ArrayList<String> ();
@ -150,7 +252,7 @@ public class HtmlToPdfServiceCusImpl extends Service implements HtmlToPdfService
} }
//获取签字意见 //获取签字意见
HttpServletRequest request = null; HttpServletRequest request = null;
int workflowid = (int) params.get("workflowid"); // int workflowid = (int) params.get("workflowid");
int nodeid =(int) params.get("nodeid"); int nodeid =(int) params.get("nodeid");
String isFormSignature = ""; String isFormSignature = "";
recordSet.executeSql("select isFormSignature from workflow_flownode where workflowId=" + workflowid + " and nodeId=" + nodeid); recordSet.executeSql("select isFormSignature from workflow_flownode where workflowId=" + workflowid + " and nodeId=" + nodeid);
@ -178,6 +280,7 @@ public class HtmlToPdfServiceCusImpl extends Service implements HtmlToPdfService
long end2 = System.currentTimeMillis()-start2; long end2 = System.currentTimeMillis()-start2;
BaseBean baseBean = new BaseBean(); BaseBean baseBean = new BaseBean();
log.error("loadform接口+底部签字意见+detail耗时"+end2); log.error("loadform接口+底部签字意见+detail耗时"+end2);
log.error("apidata"+JSONObject.toJSONString(apidatas));
//是否开启水印 //是否开启水印
apidatas.put("isOpenWaterMark",reqpParams.get("isOpenWaterMark")); apidatas.put("isOpenWaterMark",reqpParams.get("isOpenWaterMark"));

@ -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);
}
}

@ -35,14 +35,15 @@ import java.lang.reflect.Field;
import java.net.URL; import java.net.URL;
import java.net.URLEncoder; import java.net.URLEncoder;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.time.LocalTime;
import java.util.*; import java.util.*;
public class ArchivesUtil { public class ArchivesUtil {
public static Logger log = LoggerFactory.getLogger("Archives"); public static Logger log = LoggerFactory.getLogger("Archives");
public static final String SQL = "select * from uf_pushArchivesLog where ddsj >= ? and ddsj <= ? " + public static final String SQL = "select request from uf_pushArchivesLog where ddsj <= ? " +
" and type = ? and ( zt is null or zt = 1 ) "; " and type = ? and ( zt is null or zt = 1 ) group by REQUEST";
/** /**
* date * date
@ -105,13 +106,13 @@ public class ArchivesUtil {
public static List<PushArchivesBean> getResultList(RecordSet rs, String beginTime, String endTime, int type) { public static List<PushArchivesBean> getResultList(RecordSet rs, String beginTime, String endTime, int type) {
rs.executeQuery(SQL, beginTime, endTime, type); rs.executeQuery(SQL, endTime, type);
// Field[] fields = PushArchivesBean.class.getDeclaredFields(); // Field[] fields = PushArchivesBean.class.getDeclaredFields();
log.info("getResultListSQL:{}?{}?{}",SQL,endTime,type);
LinkedList<PushArchivesBean> result = new LinkedList<>(); LinkedList<PushArchivesBean> result = new LinkedList<>();
while (rs.next()) { while (rs.next()) {
PushArchivesBean pushArchivesBean = new PushArchivesBean(); PushArchivesBean pushArchivesBean = new PushArchivesBean();
pushArchivesBean.setId(Util.getIntValue(rs.getString("id"))); // pushArchivesBean.setId(Util.getIntValue(rs.getString("id")));
pushArchivesBean.setRequest(Util.getIntValue(rs.getString("request"))); pushArchivesBean.setRequest(Util.getIntValue(rs.getString("request")));
result.add(pushArchivesBean); result.add(pushArchivesBean);
} }
@ -121,7 +122,7 @@ public class ArchivesUtil {
/** /**
* *
* *
* @param mainAndSubRequestId * @param workflowid
* @return * @return
*/ */
public static List<String> getAutoInitNodeIds(String workflowid) { public static List<String> getAutoInitNodeIds(String workflowid) {
@ -139,7 +140,7 @@ public class ArchivesUtil {
recordSet.executeQuery(sql,workflowid); recordSet.executeQuery(sql,workflowid);
String exclusenodeid= ""; String exclusenodeid= "";
if (recordSet.next()){ if (recordSet.next()){
recordSet.getString("exclusenodeid"); exclusenodeid = recordSet.getString("exclusenodeid");
} }
return Arrays.asList(exclusenodeid.split(",")); return Arrays.asList(exclusenodeid.split(","));
} }
@ -296,7 +297,7 @@ public class ArchivesUtil {
HashMap<String, Object> params = new HashMap<>(); HashMap<String, Object> params = new HashMap<>();
params.put("requestid", reqid); params.put("requestid", reqid);
params.put("desremark", "all"); params.put("desremark", "all");
params.put("pageSize", "999"); params.put("pageSize", "9999");
params.put("isfirst", "true"); params.put("isfirst", "true");
// params.put("request", request); // params.put("request", request);
Map<String, Object> data = ArchivesUtil.getSignLogCmd(params, new User(1)); Map<String, Object> data = ArchivesUtil.getSignLogCmd(params, new User(1));
@ -389,7 +390,7 @@ public class ArchivesUtil {
// 加载模板并填充数据 // 加载模板并填充数据
log.error("模板路径:{}", TemplatePath); log.error("模板路径:{}", TemplatePath);
// 导出Word文档 // 导出Word文档
String outputPath = filePath + File.separator + requestid + File.separator + dirName + File.separator + "文件流转信息" + ".docx"; // 输出文件路径 String outputPath = filePath + File.separator + "togd" +requestid + File.separator + dirName + File.separator + "文件流转信息" + ".docx"; // 输出文件路径
log.error("生成文件路径:{}", TemplatePath); log.error("生成文件路径:{}", TemplatePath);
return generate(TemplatePath, TemplateName, dataMap, outputPath); return generate(TemplatePath, TemplateName, dataMap, outputPath);
@ -1047,16 +1048,17 @@ public class ArchivesUtil {
/** /**
* (5) *
* *
* @param requestid * @param requestid id
* @param max
* @return * @return
*/ */
public static Map<String, String> getSubRequest(String requestid) { public static Map<String, String> getSubRequest(String requestid,int max) {
HashMap<String, String> records = new HashMap<>(); HashMap<String, String> records = new HashMap<>();
RecordSet rs = new RecordSet(); RecordSet rs = new RecordSet();
String ids = requestid; String ids = requestid;
for (int i = 0; i < 5; i++) { for (int i = 0; i < max; i++) {
ArrayList<String> idList = new ArrayList<>(); ArrayList<String> idList = new ArrayList<>();
String sql = "select requestid , workflowid from workflow_requestbase where mainrequestid in ( " + ids + " )"; String sql = "select requestid , workflowid from workflow_requestbase where mainrequestid in ( " + ids + " )";
rs.executeQuery(sql); rs.executeQuery(sql);
@ -1065,7 +1067,7 @@ public class ArchivesUtil {
String workflowid = Util.null2String(rs.getString("workflowid")); String workflowid = Util.null2String(rs.getString("workflowid"));
idList.add(subrequestid); idList.add(subrequestid);
// 使用map自动去重,一种流程类型只取一个requestid // 使用map自动去重,一种流程类型只取一个requestid
records.put(workflowid, subrequestid); records.put(subrequestid, workflowid);
} }
ids = String.join(",", idList); ids = String.join(",", idList);
} }
@ -1278,7 +1280,7 @@ public class ArchivesUtil {
} else if (extName.matches("(ofd|OFD)")) { } else if (extName.matches("(ofd|OFD)")) {
convertType = "57"; convertType = "57";
} else if (extName.matches("(GIF|JPEG|JPG|BMP|PNG|gif|jpeg|jpg|bmp|png)")) { } else if (extName.matches("(GIF|JPEG|JPG|BMP|PNG|gif|jpeg|jpg|bmp|png)")) {
convertType = "44"; convertType = "32";
} else if (extName.matches("(PDF|pdf)")) { } else if (extName.matches("(PDF|pdf)")) {
convertType = "34"; convertType = "34";
} }
@ -1367,6 +1369,9 @@ public class ArchivesUtil {
if (loginid.length() > 8) { if (loginid.length() > 8) {
loginid = loginid.substring(0, 8); loginid = loginid.substring(0, 8);
} }
if ("fenfa".equals(loginid)){
continue;
}
set.add(loginid); set.add(loginid);
} }
return String.join("&&", set); return String.join("&&", set);
@ -1379,7 +1384,8 @@ public class ArchivesUtil {
List<String> subRequest = ArchivesUtil.getSubRequestIds(requestid, isSubReq); List<String> subRequest = ArchivesUtil.getSubRequestIds(requestid, isSubReq);
String sql = "select * from WORKFLOW_REQUESTLOG where REQUESTID in ( " + String sql = "select * from WORKFLOW_REQUESTLOG where REQUESTID in ( " +
String.join(",", subRequest) + " )" + String.join(",", subRequest) + " )" +
" and (annexdocids is not null or annexdocids <> '')"; "and logtype != '1' and (annexdocids is not null or annexdocids <> '' ) ";
log.error("getSignFilessql:{}",sql);
recordSet.executeQuery(sql); recordSet.executeQuery(sql);
while (recordSet.next()) { while (recordSet.next()) {
String annexdocids = Util.null2String(recordSet.getString("annexdocids")); String annexdocids = Util.null2String(recordSet.getString("annexdocids"));
@ -1402,7 +1408,7 @@ public class ArchivesUtil {
*/ */
public static List<String> generaSubRequestFormPdf(String requestid) { public static List<String> generaSubRequestFormPdf(String requestid) {
log.error("generaSubRequestFormPdf,requestid:{}", requestid); log.error("generaSubRequestFormPdf,requestid:{}", requestid);
Map<String, String> subRequest = ArchivesUtil.getSubRequest(requestid); Map<String, String> subRequest = ArchivesUtil.getSubRequest(requestid,5);
for (String s : subRequest.keySet()) { for (String s : subRequest.keySet()) {
requestid = subRequest.get(s); requestid = subRequest.get(s);
break; break;
@ -1440,4 +1446,77 @@ public class ArchivesUtil {
return workflowToDoc.execute(requestInfo, reqType); return workflowToDoc.execute(requestInfo, reqType);
} }
//
public static int findMaxValue(String commaSeparatedValues) {
try {
// 分割字符串
String[] numbers = commaSeparatedValues.split(",");
// 初始化最大值为整数的最小值
int max = 0;
// 遍历字符串数组
for (String number : numbers) {
// 转换为整数
int value = Integer.parseInt(number.trim()); // 使用trim()移除可能的空格
// 检查是否为最大值
if (value > max) {
max = value;
}
}
return max;
}catch (NumberFormatException e){
log.error("ConversionException:"+commaSeparatedValues);
return 0;
}
}
public static String[] getSubCom(String ngbm) {
RecordSet rs = new RecordSet();
rs.executeQuery("select sub.id subid , SUBCOMPANYNAME from HRMDEPARTMENT dept left join HRMSUBCOMPANY sub " +
" on dept.SUBCOMPANYID1 = sub.ID " +
" where dept.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};
}
public static void deleteDirectory( String directoryPath ){
// 创建File对象
File directory = new File(directoryPath);
try {
// 使用FileUtils.deleteDirectory删除目录及其子目录和文件
FileUtils.deleteDirectory(directory);
log.info("目录删除成功:{}",directory);
} catch (IOException e) {
e.printStackTrace();
log.error("目录删除失败:{}",directory);
log.error("失败原因:{}",e.getMessage());
}
}
public static boolean isAfterSevenAM(int time) {
// 获取当前时间
LocalTime currentTime = LocalTime.now();
// 定义早上7点的时间
LocalTime sevenAM = LocalTime.of(time, 0);
// 比较当前时间和早上7点
return currentTime.isAfter(sevenAM);
}
} }

@ -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 = "协办部门附件";
}

@ -34,7 +34,7 @@ public class WfToDocBizCus extends BaseBean {
public static Logger log = LoggerFactory.getLogger("Archives"); public static Logger log = LoggerFactory.getLogger("Archives");
//底部签字意见列表显示数量 //底部签字意见列表显示数量
private int pageSize =100; private int pageSize =99999;
//是否用wk转换 //是否用wk转换
private String useWk=""; private String useWk="";
private int keepsign; private int keepsign;
@ -154,7 +154,7 @@ public class WfToDocBizCus extends BaseBean {
/* /*
* htmlpdf * htmlpdf
*/ */
public void generatepdfandhtml(String requestid, String filename, String temppath, String src, int reqType){ public void generatepdfandhtml(String requestid, String filename, String temppath, String src, int reqType ,String workflowid){
int onlyHtml =0; int onlyHtml =0;
if (docfiles.contains("2")&&!docfiles.contains("3")){ //只选了生成离线html 没选pdf if (docfiles.contains("2")&&!docfiles.contains("3")){ //只选了生成离线html 没选pdf
onlyHtml =1; onlyHtml =1;
@ -174,6 +174,7 @@ public class WfToDocBizCus extends BaseBean {
params.put("src",src); params.put("src",src);
params.put("modeid",useModeid); params.put("modeid",useModeid);
params.put("isSubrequest",reqType == 1); params.put("isSubrequest",reqType == 1);
params.put("workflowid",workflowid);
//是否使用wk,在config表中读配置 //是否使用wk,在config表中读配置
WorkflowConfigComInfo configComInfo = new WorkflowConfigComInfo(); WorkflowConfigComInfo configComInfo = new WorkflowConfigComInfo();
useWk = Util.null2String(configComInfo.getValue("htmltopdf_usewk")); useWk = Util.null2String(configComInfo.getValue("htmltopdf_usewk"));

@ -98,7 +98,7 @@ public class RequestLogCusBiz {
public static ArrayList getRequestLog(int requestid, int workflowid, String viewLogIds, String orderby, int pageSize, int pagenumber, String sqlwhere , boolean isSubrequest) { public static ArrayList getRequestLog(int requestid, int workflowid, String viewLogIds, String orderby, int pageSize, int pagenumber, String sqlwhere , boolean isSubrequest) {
ArrayList logs = new ArrayList(); ArrayList logs = new ArrayList();
RecordSet rs = new RecordSet(); RecordSet rs = new RecordSet();
pageSize = 999999;
int min = (pagenumber - 1) * pageSize; int min = (pagenumber - 1) * pageSize;
int max = pagenumber * pageSize; int max = pagenumber * pageSize;
@ -121,6 +121,7 @@ public class RequestLogCusBiz {
splitinertSql.append(" select t.*,rownum rn from (" + sql + ") t "); splitinertSql.append(" select t.*,rownum rn from (" + sql + ") t ");
splitinertSql.append(" ) t1 where rn >").append(min).append(" and rn <=").append(max); splitinertSql.append(" ) t1 where rn >").append(min).append(" and rn <=").append(max);
} }
log.error("splitinertSql:{}"+splitinertSql);
rs.execute(splitinertSql.toString()); rs.execute(splitinertSql.toString());
while (rs.next()) { while (rs.next()) {
Hashtable hashtable = addLogItem(rs); Hashtable hashtable = addLogItem(rs);

@ -0,0 +1,36 @@
package com.engine.custom.audit.corn;
import com.engine.custom.audit.service.PushAuditService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import weaver.general.BaseBean;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
public class OA2AuditCorn extends weaver.interfaces.schedule.BaseCronJob {
public static Logger log = LoggerFactory.getLogger("Audit");
public String filePath = "/opt/weaver/auditFile";
PushAuditService service = new PushAuditService();
@Override
public void execute() {
log.info("OA2AuditCorn====Begin========");
System.out.println("OA2AuditCorn====Begin========");
Date date = new Date();
// Calendar calendar = Calendar.getInstance();
// calendar.setTime(date);
// //把日期往后增加一天.整数往后推,负数往前移动(1:表示明天、-1表示昨天0表示今天)
// calendar.add(Calendar.DATE, -1);
// date = calendar.getTime();
SimpleDateFormat yyyyMMdd = new SimpleDateFormat("yyyyMMdd");
String format = yyyyMMdd.format(date);
HashMap<String, String> param = new HashMap<>();
param.put("filePath",filePath);
service.initData(param);
service.genDocTxt(format,"SJ");
}
}

@ -0,0 +1,350 @@
package com.engine.custom.audit.service;
import com.engine.custom.hg.entity.HGBean;
import com.engine.custom.hg.util.HgUtils;
import com.engine.custom.hg.util.ZipUtil;
import org.apache.tools.zip.ZipOutputStream;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import weaver.conn.RecordSet;
import weaver.file.ImageFileManager;
import weaver.general.BaseBean;
import weaver.general.Util;
import java.io.*;
import java.nio.charset.StandardCharsets;
import java.nio.file.Path;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
public class PushAuditService {
private static ZipUtil zipUtil= new ZipUtil();
BaseBean bean = new BaseBean();
public static Logger log = LoggerFactory.getLogger("Audit");
private String filePath = "/opt/weaver/auditFile";
// private static final String filePath = "E:\\test";
//出巡时间内推送失败或未推送的数据
public static final String getrqBydatesql = "select * from uf_tosjLog where ddsj > ? and ddsj < ? ";
public static final String updatesql = "update uf_tosjLog set esbml = ? where id = ?";
public static final String updatetxtsql = "update uf_tosjLog set zt = 1 , esbtxtml = ? where id in (";
public void initData(Map<String, String> param){
filePath = param.get("filePath");
}
public void genDocTxt(String day, String tranCode) {
String dirDate = zipUtil.mkTemper(filePath);
RecordSet recordSet = new RecordSet();
log.info("dirDate====="+dirDate);
Date date = getDate(day);
// 获取当前时间的第一秒
SimpleDateFormat yyyyMMddHHmmss = new SimpleDateFormat("yyyy-MM-dd HH:mm");
String firstSecond = yyyyMMddHHmmss.format(getFirstSecondOfDate(date));
// 获取当前时间的最后一秒
String lastSecond =yyyyMMddHHmmss.format(getLastSecondOfDate(date));
File file = null;
List<HGBean> HGBeans = getData(firstSecond, lastSecond);
String dateDir = "tosj_" + new SimpleDateFormat("yyyyMMdd000000").format(date);
if ("SJ".equals(tranCode)) {
file = zipUtil.crFile(dirDate + "/tosj_" + new SimpleDateFormat("yyyyMMdd000000").format(date));
log.info("推送合规系统"+file.getPath()+file.getName());
} else {
// log.info("无此系统" + tranCode + ",拒绝推送");
}
ArrayList<String> ids = new ArrayList<>();
if (HGBeans.size() == 0) {
// zipUtil.writeToTxt(file.getPath(), file.getName(), "", false);
}else{
for (HGBean hgBean : HGBeans) {
if (!isEnd(hgBean.getRequestId()+"")){
continue;
}
//生成TXT
// String s1 = new String(hgBean.getContent().getBytes(StandardCharsets.UTF_8));
zipUtil.writeToTxt(file.getPath(), file.getName(), hgBean.getContent() , true);
// zipUtil.writeToTxt(file.getPath(), file.getName(), s1 , true);
//生成附件
Map<String,String> fjIdName = new HashMap<String,String>();
Map<String,String> fjIdPath = new HashMap<String,String>();
Map<String,String> zwIdName = new HashMap<String,String>();
Map<String,String> zwIdPath = new HashMap<String,String>();
Map<String,String> fjIdimg = new HashMap<String,String>();
Map<String,String> zwIdimg = new HashMap<String,String>();
Map<String,String> reqESBpathMap = new HashMap<String,String>();
getIdPathName(hgBean.getFjid(),fjIdPath,fjIdName);
getIdPathName(hgBean.getZwid(),zwIdPath,zwIdName);
// log.info(fjIdName.toString());
// log.info(fjIdPath.toString());
// log.info(zwIdName.toString());
// log.info(zwIdPath.toString());
getIdIMIDName(hgBean.getFjid(),fjIdimg);
getIdIMIDName(hgBean.getZwid(),zwIdimg);
//压缩 =正文附件文件
log.info("压缩文件开始====="+file.getPath() + File.separator + "sj"+hgBean.getRequestId()+".zip");
File filezip = new File(file.getPath() + File.separator + "sj"+hgBean.getRequestId()+".zip");
ZipOutputStream zos =null;
try {
zos = new ZipOutputStream( new FileOutputStream(filezip));
// zos.setEncoding("gbk");
addFile2zip(file, hgBean, fjIdimg,1,zos);
addFile2zip(file, hgBean, zwIdimg,2,zos);
// } catch (UnsupportedEncodingException e) {
// log.info("压缩文件异常====="+file.getPath() + File.separator + hgBean.getRequestId()+".zip");
// log.info("压缩文件异常信息====="+e.getMessage());
// e.printStackTrace();
} catch ( FileNotFoundException e) {
log.info("压缩文件异常====="+file.getPath() + File.separator + "sj"+hgBean.getRequestId()+".zip");
log.info("压缩文件异常信息====="+e.getMessage());
e.printStackTrace();
} finally {
try {
zos.close();
log.info("压缩文件结束====="+file.getPath() + File.separator + "sj"+hgBean.getRequestId()+".zip");
} catch (IOException e) {
e.printStackTrace();
}
}
try {
log.info("filezip.getAbsolutePath()==="+filezip.getAbsolutePath());
log.info("hgBean.getRequestId()+\".zip\"==="+"sj"+hgBean.getRequestId()+".zip");
//推送附件
// String s = HgUtils.putFile(filezip.getAbsolutePath(), dateDir+File.separator+hgBean.getRequestId() + ".zip");
String s = HgUtils.putFile(filezip.getAbsolutePath(), "sj"+hgBean.getRequestId() + ".zip");
if (s.length()>0){
ids.add(hgBean.getId()+"");
recordSet.executeUpdate(updatesql,s,hgBean.getId());
}
log.info("ESB返回==="+s);
} catch (com.dcfs.fts.common.error.FtpException e) {
log.info("FTP异常==="+e.getMessage());
} catch (IOException e) {
log.info("FTP异常==="+e.getMessage());
e.printStackTrace();
}
}
// 压缩txt推送
File writename = new File(file.getPath() + File.separator+"tosj_" + new SimpleDateFormat("yyyyMMdd000000").format(date)+".txt");
File txtzip = new File(file.getPath() + File.separator + "tosj_" + new SimpleDateFormat("yyyyMMdd000000").format(date)+".zip");
log.info("writename ==== "+writename.getAbsolutePath() +"===="+ writename.getName());
log.info("txtzip ==== "+txtzip.getAbsolutePath() +"===="+ txtzip.getName());
try {
OutputStream outputStream = new FileOutputStream(txtzip);
ZipUtil.filesToZip(writename , outputStream ,"tosj_" + new SimpleDateFormat("yyyyMMdd000000").format(date)+File.separator+writename.getName());
// String s = HgUtils.putFile(txtzip.getAbsolutePath(), dateDir+File.separator+dateDir + ".zip");
String s = HgUtils.putFile(txtzip.getAbsolutePath(), dateDir + ".zip");
log.info("ESB返回==="+s);
if (s.length()>0){
String idstr = String.join(",",ids);
recordSet.executeUpdate(updatetxtsql+idstr+" )",s);
}
} catch (Exception e) {
log.info("FTP异常==="+e.getMessage());
e.printStackTrace();
}
}
}
private void addFile2zip(File file, HGBean hgBean, Map<String, String> Idimg, int type, ZipOutputStream zos) {
String fileType = "";
if (type == 1){
fileType = "sj"+hgBean.getRequestId()+File.separator+"附件"+File.separator;
}else if(type == 2){
fileType = "sj"+hgBean.getRequestId()+File.separator+"正文"+File.separator;
}
// String path = new String(fileType.getBytes(StandardCharsets.UTF_8));
// File filepath = zipUtil.crFile(file.getPath() + File.separator + hgBean.getRequestId());
String finalFileType = fileType;
ArrayList<String> fileNameList = new ArrayList<>();
Idimg.forEach((key, value) ->{
FileOutputStream fos = null;
try {
// fos = new FileOutputStream(filezip);
// org.apache.tools.zip.ZipOutputStream zos = new org.apache.tools.zip.ZipOutputStream(fos);
//
// zos.setEncoding("utf-8");
ImageFileManager ifm = new ImageFileManager();
ifm.getImageFileInfoById(Integer.parseInt(value));
//writeLogs("2622 downloadFlag=" + downloadFlag);
InputStream imagefile = ifm.getInputStream();
String filename = finalFileType +ifm.getImageFileName();
if (fileNameList.contains(filename)){
String tepName= filename.contains(".")? filename.substring(0, filename.indexOf(".")) : "";
if(tepName!=null&&!"".equals(tepName)){
String extNameTemp = filename.contains(".")? filename.substring(filename.lastIndexOf(".") + 1) : "";
filename = tepName + "_"+value+"."+extNameTemp;
}
}else {
fileNameList.add(filename);
}
log.info("filename===="+filename);
String filename2 = new String(filename.getBytes(StandardCharsets.UTF_8));
log.info("filename2===="+filename2);
ZipUtil.addInputStreamToZip(imagefile,zos,filename);
} catch (Exception e) {
e.printStackTrace();
}
});
}
// 1 附件 2 正文
private void addFile2Temp(Path tempFile, Map<String, String> IdPath, Map<String, String> IdName, int type) throws UnsupportedEncodingException {
String fileType = "";;
if (type == 1){
fileType = File.separator+"附件";
}else if(type == 2){
fileType = File.separator+"正文";
}
String finalFileType = new String(fileType.getBytes(StandardCharsets.UTF_8));
IdPath.forEach((key , value) ->{
// ZipUtil.zipToFolder(value,tempFile.toString()+ finalFileType,IdName.get(key) , );
});
}
private Date getDate(String day) {
Date date = new Date();
if (day != null) {
try {
date = new SimpleDateFormat("yyyyMMdd").parse(day);
} catch (ParseException e) {
// writeLog("时间格式错误,重新发送指定日期失败");
e.printStackTrace();
}
}
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
//把日期往后增加一天.整数往后推,负数往前移动(1:表示明天、-1表示昨天0表示今天)
calendar.add(Calendar.DATE, -1);
date = calendar.getTime();
return date;
}
private List<HGBean> getData(String startTime, String endTime){
log.info("获取推送审计系统数据start");
RecordSet recordSet = new RecordSet();
recordSet.executeQuery(getrqBydatesql , startTime ,endTime);
log.info("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);
}
log.info("数据条数="+hgBeans.size());
return hgBeans;
}
// 获取指定日期的第一秒
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 ids
* @return id
*/
public static void getIdPathName(String ids ,Map<String,String> idFilePathMap ,Map<String,String> idFileNameMap ){
String sql = "select docid,df.imagefilename filename,filerealpath filepath from docimagefile df left join imagefile imf on df.imagefileid = imf.imagefileid where DOCID in ("+ids+")";
RecordSet recordSet = new RecordSet();
recordSet.execute(sql);
while (recordSet.next()){
String docid = Util.null2String(recordSet.getString("docid"));
String filename = Util.null2String(recordSet.getString("filename"));
String filepath = Util.null2String(recordSet.getString("filepath"));
idFileNameMap.put(docid,filename);
idFilePathMap.put(docid,filepath);
}
};
public static void getIdIMIDName(String ids ,Map<String,String> idimageIDMap ){
String sql = "select docid,df.imagefileid imgid from docimagefile df left join imagefile imf on df.imagefileid = imf.imagefileid where DOCID in ("+ids+")";
RecordSet recordSet = new RecordSet();
recordSet.execute(sql);
while (recordSet.next()){
String docid = Util.null2String(recordSet.getString("docid"));
String imgid = Util.null2String(recordSet.getString("imgid"));
idimageIDMap.put(docid,imgid);
}
};
public static boolean isEnd(String requestid ){
String sql = "select CURRENTNODETYPE,CURRENTNODEID from WORKFLOW_REQUESTBASE where requestid = ?";
RecordSet recordSet = new RecordSet();
recordSet.executeQuery(sql,requestid);
String CURRENTNODETYPE = "";
String CURRENTNODEID = "";
if(recordSet.next()){
CURRENTNODETYPE = recordSet.getString("CURRENTNODETYPE");
CURRENTNODEID = recordSet.getString("CURRENTNODEID");
}
log.error("isEnd"+CURRENTNODETYPE);
return "3".equals(CURRENTNODETYPE);
};
// public void put(String filenameL, String filenameR, String tranCode, int flg) throws FtpException {
// FtpClientConfig config = FtpClientConfig.getInstance();
// log.info("配置文件路径________________________________________________________________"+filePath);
// config.loadConf(filePath);
// FtpPut put = new FtpPut(filenameL, filenameR, tranCode, flg, config);
// log.info("PUT————————>response:[" + put.doPutFile() + "]");
// put.close();
// }
// public static String putFile(String localFileName, String remoteFileName, String tranCode) throws FtpException, IOException, com.dcfs.fts.common.error.FtpException {
// FtpClientConfig config = FtpClientConfig.getInstance();
// FtpPut ftpPut = new FtpPut(localFileName, remoteFileName, tranCode, true, true, config);
// String filePath = ftpPut.doPutFile();
// return filePath;
// }
}

@ -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
}
}

@ -0,0 +1,671 @@
package com.engine.workflow.cmd.codeMaintenance;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import weaver.conn.RecordSet;
import weaver.general.Util;
import weaver.hrm.User;
import weaver.hrm.company.DepartmentComInfo;
import weaver.hrm.company.SubCompanyComInfo;
import weaver.system.code.CodeBuild;
import weaver.system.code.CoderBean;
import weaver.systeminfo.SystemEnv;
import com.api.browser.bean.SearchConditionItem;
import com.api.browser.bean.SearchConditionOption;
import com.api.browser.util.ConditionFactory;
import com.api.browser.util.ConditionType;
import com.engine.core.interceptor.Command;
import com.engine.core.interceptor.CommandContext;
/**
*
* @author longxx
* */
public class GetReserveCodeNewInfosCmd implements Command<Map<String,Object>>{
private Map<String,Object> params;
private User user;
protected String formId;
protected String isBill;
protected ConditionFactory conditionFactory;
public GetReserveCodeNewInfosCmd(Map<String,Object> params,User user) {
this.params = params;
this.user = user;
conditionFactory = new ConditionFactory(user);
}
@Override
public Map<String, Object> execute(CommandContext commandContext) {
return getReserveCodeNewInfos();
}
/**
*
* */
public Map<String,Object> getReserveCodeNewInfos(){
Map<String,Object> finalReturnMap = new HashMap<String, Object>();
Map<String,Object> conditionInfos = new HashMap<String,Object>();
String workflowId = Util.null2String(params.get("workflowid"));
boolean isFromForm = "1".equals(Util.null2String(params.get("isFromForm")));//是否由表单中进来
if(!isFromForm) {
int subCompanyId = Util.getIntValue(Util.null2String(params.get("subCompanyId")),-1);
subCompanyId = WorkflowCodeUtil.getSubComIdByWfId(workflowId,subCompanyId);
String isFromPathSet = Util.null2String(params.get("isFromPathSet"));
String codeType = "1";
//编号设置进来,校验流程编号权限
if ("1".equals(isFromPathSet)) {
codeType = "2";
}
int operateLevel = WorkflowCodeUtil.getCodeOperateLevel(user, subCompanyId, codeType);
if (operateLevel < 0) {
conditionInfos.put("newInfo_state", "noright");
return conditionInfos;
}
}
//从表单过来的参数
String form_yearId = Util.null2String(params.get("yearId"));
String form_monthId = Util.null2String(params.get("monthId"));
String form_dateId = Util.null2String(params.get("dateId"));
String form_fieldId = Util.null2String(params.get("fieldId"));
String form_fieldValue = Util.null2String(params.get("fieldValue"));
String form_supSubCompanyId = Util.null2String(params.get("supSubCompanyId"));
String form_subCompanyId = Util.null2String(params.get("subCompanyId"));
String form_departmentId = Util.null2String(params.get("departmentId"));
List<String> formYearIdList = Util.splitString2List(form_yearId, ",");
List<String> formMonthIdList = Util.splitString2List(form_monthId, ",");
List<String> formDateIdList = Util.splitString2List(form_dateId, ",");
List<String> formFieldIdList = Util.splitString2List(form_fieldId, ",");
List<String> formFieldValueList = Util.splitString2List(form_fieldValue, ",");
List<String> formSupSubcompanyIdList = Util.splitString2List(form_supSubCompanyId, ",");
List<String> formSubcompanyIdList = Util.splitString2List(form_subCompanyId, ",");
List<String> formDepartmentIdList = Util.splitString2List(form_departmentId, ",");
int yearIndex = 0;
int monthIndex = 0;
int dateIndex = 0;
int supSubCompanyIndex = 0;
int subCompanyIndex = 0;
int departmentIndex = 0;
Map<String, String> formInfo = WorkflowCodeUtil.getFormInfo(workflowId);
isBill = Util.null2String(formInfo.get("isbill"));
formId = Util.null2String(formInfo.get("formid"));
Map<String,List<String>> codeInfos = getCodeRegulateInfo(workflowId);
List<String> conCreteFieldList = codeInfos.get("concreteFields");
List<String> codeValueList = codeInfos.get("codeValues");
List<Map<String,Object>> groupList = new ArrayList<Map<String,Object>>();
Map<String,Object> codeSetGroupItem = new HashMap<String,Object>();
Map<String,Object> seqSetGroupItem = new HashMap<String,Object>();
List<SearchConditionItem> codeSetItemList = new ArrayList<SearchConditionItem>();
List<SearchConditionItem> seqSetItemList = new ArrayList<SearchConditionItem>();
codeSetGroupItem.put("defaultshow", true);
codeSetGroupItem.put("items", codeSetItemList);
codeSetGroupItem.put("title", SystemEnv.getHtmlLabelName(83549, user.getLanguage()));
seqSetGroupItem.put("defaultshow", true);
seqSetGroupItem.put("items", seqSetItemList);
seqSetGroupItem.put("title", SystemEnv.getHtmlLabelName(10000891, Util.getIntValue(user.getLanguage())));
groupList.add(codeSetGroupItem);
groupList.add(seqSetGroupItem);
//当前流水号
SearchConditionItem currentSeqId = conditionFactory.createCondition(ConditionType.INPUT, 125356, "currentSeqId");
currentSeqId.setViewAttr(1);
currentSeqId.setFieldcol(16);
currentSeqId.setLabelcol(6);
Map<String, Object> cruuentSeqIdOtherParams = new HashMap<String, Object>();
cruuentSeqIdOtherParams.put("hasBorder", true);
currentSeqId.setOtherParams(cruuentSeqIdOtherParams);
seqSetItemList.add(currentSeqId);
int strNum = 0;//记录字符串个数
int selectedMonthId = 0;
int selectedYearId = 0;
CodeBuild cbuild = new CodeBuild(Util.getIntValue(formId),isBill,Util.getIntValue(workflowId));
CoderBean cbean = cbuild.getFlowCBuild();
String dateSeqAlone = cbean.getDateSeqAlone();//1:日期单独流水
String dateSeqSelect = cbean.getDateSeqSelect();//获取日期单独流水方式
String dateSeqFieldId = cbean.getCorrespondDate();//获取日期单独流水字段
boolean seqYearExists = false;
boolean seqMonthExists = false;
//先遍历一遍,查看日期单独流水字段年月日,是否都存在编号组成中
for(int i = 0;i < conCreteFieldList.size();i++) {
String conCreteField = conCreteFieldList.get(i);
String codeValue = codeValueList.get(i);
if(Util.null2String(dateSeqFieldId).equals(codeValue)) {
if(conCreteField.equals("4")) {
seqYearExists = true;
}else if(conCreteField.equals("5")) {
seqMonthExists = true;
}
}
}
for(int i = 0;i < conCreteFieldList.size();i++){
String conCreteField = conCreteFieldList.get(i);
String codeValue = codeValueList.get(i);//codevalue存放的是字段的id,如果是文本类型,就是字符串或者流水号位数,如果是选择框则为value
Calendar today = Calendar.getInstance();
int yearIdToday = today.get(Calendar.YEAR);
int monthIdToday = today.get(Calendar.MONTH) + 1;
int dateIdToday = today.get(Calendar.DAY_OF_MONTH);
if(conCreteField.equals("0")){//选择框
Map<String,List<String>> selectInfos = getSelectInfos(codeValue, isBill);//这里的codevalue为字段id
String selectItemName = "selectValue" + codeValue;//前端name组成为selectValue+字段id
String selectValue = "";
if(isFromForm) {
int index = formFieldIdList.indexOf(codeValue);
if(index != -1) {
selectValue = formFieldValueList.get(index);
}
}
if(selectValue.equals("")){
selectValue = "0";
}
SearchConditionItem selectItem = conditionFactory.createCondition(ConditionType.SELECT, 22755, selectItemName,getSelectOptions(selectInfos,selectValue));
Map<String, Object> otherParams = new HashMap<String, Object>();
otherParams.put("hasBorder", true);
selectItem.setFieldcol(16);
selectItem.setLabelcol(6);
selectItem.setOtherParams(otherParams);
if(isFromForm) selectItem.setViewAttr(1);
codeSetItemList.add(selectItem);
}else if(conCreteField.equals("1")){//部门
String deptItemName = "deptId";
if(codeValue.equals("-2"))
deptItemName += "_2";//创建人部门
else
deptItemName += codeValue;//来自表单字段,codeValue为deptid
String deptId = "";
if(isFromForm) {
deptId = formDepartmentIdList.get(departmentIndex);
departmentIndex++;
}
SearchConditionItem deptItem = conditionFactory.createCondition(ConditionType.BROWSER, 124, deptItemName,"4");
deptItem.setViewAttr(isFromForm ? 1 : 3);
deptItem.setRules("required|string");
deptItem.setFieldcol(16);
deptItem.setLabelcol(6);
if(!deptId.equals("")){
List<Map<String,Object>> replaceDatas = new ArrayList<Map<String,Object>>();
Map<String,Object> datas = getDefaultDept(deptId);
replaceDatas.add(datas);//用于页面浏览框默认显示
deptItem.getBrowserConditionParam().setReplaceDatas(replaceDatas);
}
deptItem.getBrowserConditionParam().setHasBorder(true);
codeSetItemList.add(deptItem);
}else if(conCreteField.equals("2")){//分部
String subComItemName = "subComId";
if(codeValue.equals("-2"))
subComItemName += "_2";//创建人分部
else
subComItemName += codeValue;//来自表单字段
String subComId = "";
if(isFromForm) {
subComId = formSubcompanyIdList.get(subCompanyIndex);
subCompanyIndex++;
}
SearchConditionItem subComItem = conditionFactory.createCondition(ConditionType.BROWSER, 141, subComItemName,"164");
subComItem.setViewAttr(isFromForm ? 1 : 3);
subComItem.setFieldcol(16);
subComItem.setLabelcol(6);
subComItem.setRules("required|string");
if(!subComId.equals("")){
List<Map<String,Object>> replaceDatas = new ArrayList<Map<String,Object>>();
Map<String,Object> datas = getDefaultSubCom(subComId);
replaceDatas.add(datas);
subComItem.getBrowserConditionParam().setReplaceDatas(replaceDatas);
}
subComItem.getBrowserConditionParam().setHasBorder(true);
codeSetItemList.add(subComItem);
}else if(conCreteField.equals("3")){//上级分部
String supSubComItemName = "supSubComId";
if(codeValue.equals("-2"))
supSubComItemName += "_2";//创建人分部
else
supSubComItemName += codeValue;//来自表单字段
String supSubComId = "";
if(isFromForm) {
supSubComId = formSupSubcompanyIdList.get(supSubCompanyIndex);
supSubCompanyIndex++;
}
SearchConditionItem supSubComItem = conditionFactory.createCondition(ConditionType.BROWSER, 22753, supSubComItemName,"164");
supSubComItem.setViewAttr(isFromForm ? 1 : 3);
supSubComItem.setFieldcol(16);
supSubComItem.setLabelcol(6);
supSubComItem.setRules("required|string");
if(!supSubComId.equals("")){
List<Map<String,Object>> replaceDatas = new ArrayList<Map<String,Object>>();
Map<String,Object> datas = getDefaultSubCom(supSubComId);
replaceDatas.add(datas);
supSubComItem.getBrowserConditionParam().setReplaceDatas(replaceDatas);
}
supSubComItem.getBrowserConditionParam().setHasBorder(true);
codeSetItemList.add(supSubComItem);
}else if(conCreteField.equals("4")){//年
String yearItemName = getFieldMark("yearId", codeValue);
String yearId = "";
if(isFromForm) {
if(codeValue.equals("-2")) {
yearId = yearIdToday + "";
} else {
String fieldValue = Util.null2String(params.get("field" + codeValue));
yearId = fieldValue.split("-").length > 1 ? fieldValue.split("-")[0] : fieldValue;
}
}
//获取默认选中值
String yearValue = getYearDefaultValue(yearId);
selectedYearId = Util.getIntValue(yearValue);
codeSetItemList.add(getYearItem(yearItemName, yearValue, isFromForm));
}
if(conCreteField.equals("5")){//月
String yearItemName = getFieldMark("yearId", codeValue);
String monthItemName = getFieldMark("monthId", codeValue);
String yearId = "";
String monthId = "";
if(isFromForm) {
if(codeValue.equals("-2")) {
yearId = yearIdToday + "";
monthId = monthIdToday + "";
} else {
String fieldValue = Util.null2String(params.get("field" + codeValue));
yearId = fieldValue.split("-").length > 1 ? fieldValue.split("-")[0] : fieldValue;
monthId = fieldValue.split("-").length > 1 ? fieldValue.split("-")[1] : fieldValue;
}
}
//获取默认选中月
String defaultSelectMonth = getMonthDefaultValue(monthId);
//按月单独流水,当前字段为单独流水字段,且未设置年编号组成,补充一个年选择框,让用户选择年份
if("1".equals(dateSeqAlone) && dateSeqSelect.equals("2") && codeValue.equals(dateSeqFieldId) && !seqYearExists) {
codeSetItemList.add(getYearItem(yearItemName, getYearDefaultValue(yearId), isFromForm));
}
selectedMonthId = Util.getIntValue(defaultSelectMonth);//用户选中的月份
codeSetItemList.add(getMonthItem(monthItemName, defaultSelectMonth, isFromForm));
}
if(conCreteField.equals("6")){//日
String yearItemName = getFieldMark("yearId", codeValue);
String monthItemName = getFieldMark("monthId", codeValue);
String dateItemName = getFieldMark("dateId", codeValue);
String yearId = "";
String monthId = "";
String dateId = "";
if(isFromForm) {
if(codeValue.equals("-2")) {
yearId = yearIdToday + "";
monthId = monthIdToday + "";
dateId = dateIdToday + "";
} else {
String fieldValue = Util.null2String(params.get("field" + codeValue));
yearId = fieldValue.split("-").length == 3 ? fieldValue.split("-")[0] : fieldValue;
monthId = fieldValue.split("-").length == 3 ? fieldValue.split("-")[1] : fieldValue;
dateId = fieldValue.split("-").length == 3 ? fieldValue.split("-")[2] : fieldValue;
}
}
String defaultSelectDate = "";
if(!dateId.equals("")){
defaultSelectDate = dateId;
}else{
String dateIdStr = "";
if(dateIdToday < 10)
dateIdStr = "0" + dateIdToday;
else
dateIdStr = "" + dateIdToday;
defaultSelectDate = dateIdStr;
}
//按日单独流水,当前字段为单独流水字段
if("1".equals(dateSeqAlone) && dateSeqSelect.equals("3") && codeValue.equals(dateSeqFieldId)) {
//未设置年编号组成,补充一个年选择框,让用户选择年份
if(!seqYearExists) {
codeSetItemList.add(getYearItem(yearItemName, getYearDefaultValue(yearId), isFromForm));
}
if (!seqMonthExists) {
codeSetItemList.add(getMonthItem(monthItemName, getMonthDefaultValue(monthId), isFromForm));
}
}
codeSetItemList.add(getDateItem(dateItemName, selectedYearId, selectedMonthId, defaultSelectDate, isFromForm));
}else if(conCreteField.equals("7")){//字符串
strNum++;
Map<String,Object> otherParams = new HashMap<String, Object>();
String strItemName = "str_" + strNum;
String labelName = SystemEnv.getHtmlLabelName(27903, user.getLanguage()) + strNum;
otherParams.put("hasBorder", true);
SearchConditionItem strItem = conditionFactory.createCondition(ConditionType.INPUT, 0, strItemName);
strItem.setValue(codeValue);
strItem.setLabel(labelName);
strItem.setViewAttr(1);
strItem.setOtherParams(otherParams);
strItem.setFieldcol(16);
strItem.setLabelcol(6);
codeSetItemList.add(strItem);
}else if(conCreteField.equals("8")){//这里获取流水号
//流水号
SearchConditionItem codeItem = conditionFactory.createCondition(ConditionType.INPUT, 383362, "flowcode");
codeItem.setViewAttr(3);
codeItem.setFieldcol(16);
codeItem.setLabelcol(6);
codeItem.setRules("required|string");
seqSetItemList.add(codeItem);
}else if(conCreteField.equals("9")){//字母
SearchConditionItem strItem = conditionFactory.createCondition(ConditionType.INPUT, 27903, "letter");
strItem.setValue(codeValue);
strItem.setViewAttr(1);
strItem.setFieldcol(16);
strItem.setLabelcol(6);
codeSetItemList.add(strItem);
}
}
//描述,可编辑
SearchConditionItem descItem = conditionFactory.createCondition(ConditionType.TEXTAREA, 433, "desc");
descItem.setFieldcol(16);
descItem.setLabelcol(6);
seqSetItemList.add(descItem);
conditionInfos.put("conditioninfo", groupList);
finalReturnMap = conditionInfos;
return finalReturnMap;
}
public String getFieldMark(String typeMark, String codeValue) {
if(codeValue.equals("-2"))
typeMark += "_2";
else
typeMark += codeValue;//来自表单字段
return typeMark;
}
/**
*
* @param yearId
* @return
*/
public String getYearDefaultValue(String yearId) {
Calendar today = Calendar.getInstance();
int yearIdToday = today.get(Calendar.YEAR);
String yearValue = "";
if(!yearId.equals("")){
yearValue = yearId;
}else{
yearValue = yearIdToday + "";
}
return yearValue;
}
/**
*
*/
public SearchConditionItem getYearItem(String yearItemName, String yearValue, boolean isFromForm) {
Map<String,Object> otherParamMap = new HashMap<>();
otherParamMap.put("format", "yyyy");
otherParamMap.put("hasBorder", true);
SearchConditionItem yearItem = conditionFactory.createCondition(ConditionType.DATEPICKER, 445, yearItemName);
yearItem.setValue(yearValue);
yearItem.setFieldcol(10);
yearItem.setLabelcol(6);
yearItem.setOtherParams(otherParamMap);
//if(isFromForm) yearItem.setViewAttr(1);
return yearItem;
}
/**
*
* @param monthId
* @return
*/
public String getMonthDefaultValue(String monthId) {
Calendar today = Calendar.getInstance();
int monthIdToday = today.get(Calendar.MONTH) + 1;
String defaultSelectMonth = "";
if(!monthId.equals("")){
defaultSelectMonth = monthId;
}else{
defaultSelectMonth = monthIdToday + "";
}
if (defaultSelectMonth.length() == 1) {
defaultSelectMonth = "0" + defaultSelectMonth;
}
return defaultSelectMonth;
}
/**
*
*/
public SearchConditionItem getMonthItem(String monthItemName, String defaultSelectMonth, boolean isFromForm) {
SearchConditionItem monthItem = conditionFactory.createCondition(ConditionType.SELECT, 6076, monthItemName,WorkflowCodeUtil.getMonthOptions(defaultSelectMonth));
monthItem.setFieldcol(8);
monthItem.setLabelcol(6);
Map<String, Object> otherParams = new HashMap<String, Object>();
otherParams.put("hasBorder", true);
monthItem.setOtherParams(otherParams);
monthItem.setValue(defaultSelectMonth);
if(isFromForm) monthItem.setViewAttr(1);
return monthItem;
}
/**
*
* @param dateItemName
* @param selectedYearId
* @param selectedMonthId
* @param defaultSelectDate
* @param isFromForm
* @return
*/
public SearchConditionItem getDateItem(String dateItemName, int selectedYearId, int selectedMonthId, String defaultSelectDate, boolean isFromForm) {
if (selectedYearId <= 0) {
selectedYearId = Util.getIntValue(getYearDefaultValue(""));
}
//月份未设置取为31天的月
if (selectedMonthId <= 0) {
selectedMonthId = 1;
}
SearchConditionItem dateItem = conditionFactory.createCondition(ConditionType.SELECT, 390, dateItemName,WorkflowCodeUtil.getDateOptions(defaultSelectDate,selectedYearId,selectedMonthId));
dateItem.setFieldcol(8);
dateItem.setLabelcol(6);
Map<String, Object> otherParams = new HashMap<String, Object>();
otherParams.put("hasBorder", true);
dateItem.setOtherParams(otherParams);
//只有一位前面添加一个0
if (Util.null2String(defaultSelectDate).length() == 1) {
defaultSelectDate = "0" + defaultSelectDate;
}
dateItem.setValue(defaultSelectDate);
//if(isFromForm) dateItem.setViewAttr(1);
return dateItem;
}
//获取下拉框选项
public static Map<String,List<String>> getSelectInfos(String fieldId,String isBill){
Map<String,List<String>> selectInfos = new HashMap<String, List<String>>();
List<String> selectNames = new ArrayList<String>();
List<String> selectValues = new ArrayList<String>();
String sql = "select selectvalue,selectname from workflow_selectitem where fieldid=? and isbill=? order by listorder";
RecordSet rs = new RecordSet();
rs.executeQuery(sql, fieldId, isBill);
while(rs.next()){
String selectValue = Util.null2String(rs.getString("selectvalue"));
String selectName = Util.null2String(rs.getString("selectname"));
selectNames.add(selectName);
selectValues.add(selectValue);
}
selectInfos.put("selectNames", selectNames);
selectInfos.put("selectValues", selectValues);
return selectInfos;
}
//获取选择框流水的选项
public List<SearchConditionOption> getSelectOptions(Map<String,List<String>> selectInfos,String defaultSelectValue){
List<SearchConditionOption> options = new ArrayList<SearchConditionOption>();
SearchConditionOption optionItem = null;
List<String> selectNames = selectInfos.get("selectNames");
List<String> selectValues = selectInfos.get("selectValues");
String selectName = "";
String selectValue = "";
for(int i = 0;i < selectValues.size();i++){
selectName = selectNames.get(i);
selectValue = selectValues.get(i);
optionItem = new SearchConditionOption(selectValue,selectName,(selectValue.equals(defaultSelectValue)) ? true : false );
options.add(optionItem);
}
return options;
}
//得到编号组成
public Map<String,List<String>> getCodeRegulateInfo(String workflowId){
Map<String,List<String>> codeInfos = new HashMap<String, List<String>>();
List<String> conCreteFieldList = new ArrayList<String>();
List<String> codeValueList = new ArrayList<String>();
List<String> enableCodeList = new ArrayList<String>();
CodeBuild cb = new CodeBuild();
boolean isWorkflowSeqAlone = cb.isWorkflowSeqAlone(new RecordSet(), Util.getIntValue(workflowId));
RecordSet rs = new RecordSet();
if(isWorkflowSeqAlone) {
rs.executeQuery("select * from workflow_coderegulate where workflowId = ? order by codeorder", workflowId);
} else {
rs.executeQuery("select * from workflow_coderegulate where formid = ? and isbill = ? order by codeorder", formId, isBill);
}
while(rs.next()){
conCreteFieldList.add(rs.getString("concreteField"));
codeValueList.add(rs.getString("codeValue"));
enableCodeList.add(rs.getString("enablecode"));
}
codeInfos.put("concreteFields", conCreteFieldList);
codeInfos.put("codeValues", codeValueList);
codeInfos.put("enableCodes", enableCodeList);
return codeInfos;
}
//获取选中选择框预览选项
public static String getSelectDefaultPreView(Map<String,List<String>> selectInfos,String selectValue){
String returnStr = "";
List<String> selectValues = selectInfos.get("selectValues");
List<String> selectNames = selectInfos.get("selectNames");
for(int i = 0;i < selectValues.size();i++){
if(selectValues.get(i).equals(selectValue)){
returnStr = selectNames.get(i);
}
}
return returnStr;
}
//用于默认显示部门
public Map<String,Object> getDefaultDept(String deptId){
Map<String,Object> deptInfoMap = new HashMap<String, Object>();
DepartmentComInfo depCom = new DepartmentComInfo();
String deptName = depCom.getDepartmentname(deptId);
deptInfoMap.put("id", deptId);
deptInfoMap.put("name", deptName);
return deptInfoMap;
}
//获取默认分部,用于默认显示
public Map<String,Object> getDefaultSubCom(String subComId){
Map<String,Object> subComInfoMap = new HashMap<String, Object>();
SubCompanyComInfo subCom = new SubCompanyComInfo();
String subName = subCom.getSubCompanyname(subComId);
subComInfoMap.put("id", subComId);
subComInfoMap.put("name", subName);
return subComInfoMap;
}
/**
* ,-
* */
public String validateFlowCode(String flowCode){
String returnCode = "";
//1 判断有没有-字符
if(flowCode.indexOf("-") == -1){//没有
//判断字符串里面是否有非数字
int flowCodeNum = Util.getIntValue(flowCode,-1);
if(flowCodeNum != -1){
if(flowCodeNum !=0 && flowCode.matches("^[0-9]+")){
returnCode = flowCodeNum + "";
}
}
}else{//有
String[] values = flowCode.split("-");// -5这样的解析成["","5"],也存在05-06这样的情况啊,这个时候需要解析
if(values.length == 2){
if(values[0].trim().matches("^[0-9]+")){
if(values[1].trim().matches("^[0-9]+")){
returnCode = Util.getIntValue(values[0].trim()) + "-" + Util.getIntValue(values[1].trim());
}
}
}
if(values.length == 1){
if(values[0].trim().matches("^[0-9]+")){
returnCode = Util.getIntValue(values[0].trim()) + "-";
}
}
}
return returnCode;
}
public Map<String, Object> getParams() {
return params;
}
public void setParams(Map<String, Object> params) {
this.params = params;
}
public User getUser() {
return user;
}
public void setUser(User user) {
this.user = user;
}
}

@ -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.

@ -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);
}
%>

@ -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();
}
%>

@ -10,13 +10,16 @@
<%@ page import="weaver.conn.RecordSet" %> <%@ page import="weaver.conn.RecordSet" %>
<%@ page import="com.engine.custom.archives.entity.Dept" %> <%@ page import="com.engine.custom.archives.entity.Dept" %>
<%@ page import="com.alibaba.fastjson.JSONObject" %> <%@ page import="com.alibaba.fastjson.JSONObject" %>
<%@ page import="weaver.general.BaseBean" %>
<% <%
List<Dept> depts = readExcelFile("/opt/weaver/filesys/zzxx.xlsx"); List<Dept> depts = readExcelFile("/opt/weaver/archivesFile/template/zzxx.xlsx");
// 输出或处理dept列表 // 输出或处理dept列表
out.println(depts.size()); out.println(depts.size());
out.println(JSONObject.toJSONString(depts)); out.println(JSONObject.toJSONString(depts));
BaseBean bb = new BaseBean();
bb.writeLog(JSONObject.toJSONString(depts));
RecordSet recordSet = new RecordSet(); RecordSet recordSet = new RecordSet();
String comSql = "update hrmsubcompanydefined set DAPYBH = ? where SUBCOMID = (select id from hrmsubcompany where SUBCOMPANYNAME = ? )"; String comSql = "update hrmsubcompanydefined set DAPYBH = ? where SUBCOMID = (select id from hrmsubcompany where SUBCOMPANYNAME = ? )";
// String deptByDeptSql = "update hrmdepartmentdefined set DAPYBH = ? where SUBCOMPANYNAME = ? and SUPDEPID = (select * from hrmdepartmentdefined where DAPYBH = ? )"; // String deptByDeptSql = "update hrmdepartmentdefined set DAPYBH = ? where SUBCOMPANYNAME = ? and SUPDEPID = (select * from hrmdepartmentdefined where DAPYBH = ? )";
@ -24,21 +27,27 @@
String deptSql = "update hrmdepartmentdefined set DAPYBH = ? where deptid in (select id from hrmdepartment where DEPARTMENTNAME = ? ) and deptid in (select id from hrmdepartment where SUBCOMPANYID1 = (select SUBCOMID from hrmsubcompanydefined where DAPYBH = ? ) or SUPDEPID = (select DEPTID from hrmdepartmentdefined where DAPYBH = ? ) )"; String deptSql = "update hrmdepartmentdefined set DAPYBH = ? where deptid in (select id from hrmdepartment where DEPARTMENTNAME = ? ) and deptid in (select id from hrmdepartment where SUBCOMPANYID1 = (select SUBCOMID from hrmsubcompanydefined where DAPYBH = ? ) or SUPDEPID = (select DEPTID from hrmdepartmentdefined where DAPYBH = ? ) )";
for (Dept dept : depts) { for (Dept dept : depts) {
bb.writeLog(JSONObject.toJSONString(dept));
if ("zgs".equals(dept.getType())) { if ("zgs".equals(dept.getType())) {
continue; continue;
} }
if ("zonghang".equals(dept.getType())) { if ("zonghang".equals(dept.getType())) {
recordSet.executeUpdate(comSql, dept.getId(), dept.getName()); recordSet.executeUpdate(comSql, dept.getId(), dept.getName());
bb.writeLog(comSql+ "_"+dept.getId()+"_"+ dept.getName());
} }
if ("zhih".equals(dept.getType()) || "fh".equals(dept.getType())) { if ("zhih".equals(dept.getType()) || "fh".equals(dept.getType())) {
if ("10".equals(dept.getParentId())) { if ("10".equals(dept.getParentId())) {
recordSet.executeUpdate(comSql, dept.getId(), dept.getName()); recordSet.executeUpdate(comSql, dept.getId(), dept.getName());
bb.writeLog(comSql+ "_"+dept.getId()+"_"+ dept.getName());
} else { } else {
recordSet.executeUpdate(deptSql, dept.getId(), dept.getName(), dept.getParentId(), dept.getParentId()); recordSet.executeUpdate(deptSql, dept.getId(), dept.getName(), dept.getParentId(), dept.getParentId());
bb.writeLog(deptSql+ "_"+dept.getId()+"_"+ dept.getName()+"_"+dept.getParentId()+"_"+dept.getParentId());
} }
} }
if ("ld".equals(dept.getType()) || "bm".equals(dept.getType())) { if ("ld".equals(dept.getType()) || "bm".equals(dept.getType())) {
recordSet.executeUpdate(deptSql, dept.getId(), dept.getName(), dept.getParentId(), dept.getParentId()); recordSet.executeUpdate(deptSql, dept.getId(), dept.getName(), dept.getParentId(), dept.getParentId());
bb.writeLog(deptSql +"_"+ dept.getId()+"_"+ dept.getName()+"_"+ dept.getParentId()+"_"+ dept.getParentId());
} }
} }
@ -63,9 +72,9 @@
Dept Dept = new Dept(); Dept Dept = new Dept();
Dept.setId(row.getCell(0).getStringCellValue()); Dept.setId(row.getCell(0).getStringCellValue());
Dept.setName(row.getCell(1).getStringCellValue()); Dept.setName(row.getCell(1).getStringCellValue());
Dept.setType(row.getCell(2).getStringCellValue()); Dept.setType(row.getCell(3).getStringCellValue());
Dept.setParentId(row.getCell(3).getStringCellValue()); Dept.setParentId(row.getCell(4).getStringCellValue());
Dept.setAllName(row.getCell(4).getStringCellValue()); Dept.setAllName(row.getCell(2).getStringCellValue());
// 假设第一列是姓名,第二列是年龄 // 假设第一列是姓名,第二列是年龄
dept.add(Dept); dept.add(Dept);
} }

File diff suppressed because it is too large Load Diff

@ -1,812 +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" %>
<%
response.setCharacterEncoding("utf-8");
HashMap<String, Object> params = new HashMap<>();
params.put("requestid", "727734");
params.put("desremark", "all");
params.put("pageSize", "50");
params.put("isfirst", "true");
params.put("request", request);
Map<String, Object> data = execute(params, new User(23));
Map<String, Object> datas = (Map<String, Object>) data.get("datas");
List<Map.Entry<String, Object>> entries = new ArrayList<>(datas.entrySet());
entries.sort(new Comparator<Map.Entry<String, Object>>() {
@Override
public int compare(Map.Entry<String, Object> o1, Map.Entry<String, Object> o2) {
Integer key1 = Util.getIntValue((Util.null2String(o1.getKey())).replace("key", ""));
Integer key2 = Util.getIntValue((Util.null2String(o2.getKey())).replace("key", ""));
return key1 - key2;
}
}); // 自然顺序
ArrayList<Map<String,String>> results = new ArrayList<>();
// out.print(JSONObject.toJSONString(entries));
for (Map.Entry<String, Object> entry : entries) {
Map value = (Map)entry.getValue();
List<Map<String, Object>> list = (List)value.get("list");
for (Map<String, Object> item : list) {
String operator = (String)item.get("operator");
String operatorid = (String)item.get("operatorid");
String operatortype = (String)item.get("operatortype");
String operatedate = (String)item.get("operatedate");
String nodename = (String)value.get("nodename");
HashMap<String, String> itemMap = new HashMap<>();
itemMap.put("operator",operator);
itemMap.put("operatorid",operatorid);
itemMap.put("operatortype",operatortype);
itemMap.put("operatedate",operatedate);
itemMap.put("nodename",nodename);
results.add(itemMap);
}
}
String encoding = System.getProperty("file.encoding");
out.print(encoding);
try {
Map<String, Object> dataMap = new HashMap<>();
dataMap.put("users", results); // 将用户列表添加到数据映射中
// dataMap.put("name", results); // 将用户列表添加到数据映射中
// 加载模板并填充数据
String templatePath = "/opt/weaver/filesys/template.docx"; // 模板文件路径
String templatePath2 = "/opt/weaver/filesys/xinxi2.docx"; // 模板文件路径
File file = new File(templatePath);
File file2 = new File(templatePath2);
// out.print(file.exists());
// out.print(file2.exists());
System.out.println(dataMap);
XWPFDocument doc = WordExportUtil.exportWord07(templatePath, dataMap);
// 导出Word文档
String lastname = new User(6473).getLastname();
String outputPath = "/opt/weaver/filesys/"+lastname+".docx"; // 输出文件路径
// byte[] gbks = outputPath.getBytes("gbk");
System.out.print(outputPath);
String outputPath1 = new String( outputPath.getBytes("UTF-8"),"ISO-8859-1");
String outputPath2 = new String( outputPath1.getBytes("ISO-8859-1"),"UTF-8");
// ChangeCharset changeCharset = new ChangeCharset();
// String outputPath1 = changeCharset.toUTF_8(outputPath);
System.out.print(outputPath1);
System.out.print(outputPath2);
outputPath = new String(outputPath.getBytes("ISO8859_1"), "UTF-8");
File file11 = new File(outputPath1);
File file22 = new File(outputPath2);
// if(!file1.exists()){
file11.createNewFile();
file22.createNewFile();
// }
FileOutputStream fos = new FileOutputStream(outputPath) ;
doc.write(fos);
fos.close();
} catch (Exception e) {
System.out.println("errorerrorerror");
System.out.println(e.getMessage());
out.print(e.getMessage()+"123");
e.printStackTrace();
}
%>
<%!
private void test1(ArrayList<Map<String,String>> results) {
try {
Map<String, Object> dataMap = new HashMap<>();
dataMap.put("users", results); // 将用户列表添加到数据映射中
// 加载模板并填充数据
String templatePath = "/opt/weaver/filesys/xinxi.docx"; // 模板文件路径
String templatePath2 = "/opt/weaver/filesys/xinxi2.docx"; // 模板文件路径
File file = new File(templatePath);
File file2 = new File(templatePath2);
// out.print(file.exists());
// out.print(file2.exists());
System.out.println(dataMap);
XWPFDocument doc = WordExportUtil.exportWord07(templatePath, dataMap);
// 导出Word文档
String lastname = new User(22).getLastname();
String outputPath = "/opt/weaver/filesys/"+lastname+".docx"; // 输出文件路径
// byte[] gbks = outputPath.getBytes("gbk");
String outputPath1 = new String( outputPath.getBytes("UTF-8"));
// outputPath = new String(outputPath.getBytes("ISO8859_1"), "UTF-8");
File file1 = new File(outputPath1);
if(!file1.exists()){
file1.createNewFile();
}
// FileOutputStream fos = new FileOutputStream(outputPath) ;
// doc.write(fos);
// fos.close();
} catch (Exception e) {
System.out.println("errorerrorerror");
System.out.println(e.getMessage());
// out.print(e.getMessage()+"123");
e.printStackTrace();
}
}
public Map<String, Object> execute(Map<String, Object> params, User user) {
Map<String, Object> result = new HashMap<String, Object>();
RequestAuthenticationService authService = new RequestAuthenticationService();
authService.setUser(user);
long date1 = new Date().getTime();
try {
RecordSet rs = new RecordSet();
RecordSet rs1 = new RecordSet();
int pageSize = Util.getIntValue(Util.null2String(params.get("pageSize")), 30);
int desrequestid = Util.getIntValue(Util.null2String(params.get("desrequestid")), 0);
String isfirst = Util.null2String(params.get("isfirst"));
String isurger = Util.null2String(params.get("isurger"));
String desremark = Util.null2String(params.get("desremark"));
int desremarkIndex = desremark.indexOf("_");
boolean isAdSearch = false;//是否有过滤条件
if (desremarkIndex > -1) {
isAdSearch = true;
desremark = desremark.substring(0, desremarkIndex);
}
String parameter = Util.null2String(params.get("parameter"));
int selectedNode = Util.getIntValue(Util.null2String(params.get("selectedNode")), -1);//选中的节点
String selectedOperator = Util.null2String(params.get("selectedOperator"));//选中的操作者
int requestid = Util.getIntValue(Util.null2String(params.get("requestid")), 0);
int workflowid = -1;
rs.executeQuery("select workflowid from workflow_requestbase where requestid=" + requestid);
if (rs.next())
workflowid = Util.getIntValue(rs.getString("workflowid"));
// 将json字符串转换成jsonObject
int currentMaxId = 0;
int currentMinId = 0;
int currentId = 0;
int currentId2 = 0;
int lastNodeId = 0;
String viewlogids = "";
int index = 0;
try {
if (!"true".equals(isfirst)) {
Map<String, String> parameterMap = JSON.parseObject(parameter, Map.class);//Weibo类在下边定义
currentMaxId = Util.getIntValue(parameterMap.get("currentMaxId"), 0);
currentMinId = Util.getIntValue(parameterMap.get("currentMinId"), 0);
String currentId12 = Util.null2String(parameterMap.get("currentId"));
if (currentId12.contains("_")) {
String[] currentId12Arr = currentId12.split("_");
currentId = Util.getIntValue(currentId12Arr[0]);
currentId2 = Util.getIntValue(currentId12Arr[1]);
} else {
currentId = Util.getIntValue(currentId12);
}
viewlogids = Util.null2String(parameterMap.get("viewlogids"));
index = Util.getIntValue(parameterMap.get("nodeindex"), 0);
lastNodeId = Util.getIntValue(parameterMap.get("lastNodeId"), 0);
}
} catch (Exception e) {
e.printStackTrace();
}
Map<String, String> putpara = new HashMap<String, String>();
Monitor monitor = new Monitor();
// String joinStr = ("oracle".equalsIgnoreCase(rs.getDBType()) || "mysql".equalsIgnoreCase(rs.getDBType())) ? " left join " : " left hash join ";
String joinStr = " left join ";
// if (isurger.equals("true") || monitor.hasMonitor(requestid+"", user.getUID() + "")) {
// StringBuffer sqlsb = new StringBuffer();
// sqlsb.append(" select a.id,a.nodeid, ");
// sqlsb.append(" b.nodename, ");
// sqlsb.append(" a.userid, ");
// sqlsb.append(" a.isremark, ");
// sqlsb.append(" a.lastisremark, ");
// sqlsb.append(" a.usertype, ");
// sqlsb.append(" a.agentorbyagentid, ");
// sqlsb.append(" a.agenttype, ");
// sqlsb.append(" a.receivedate, ");
// sqlsb.append(" a.receivetime, ");
// sqlsb.append(" a.operatedate, ");
// sqlsb.append(" a.operatetime, ");
// sqlsb.append(" a.viewtype, ");
// sqlsb.append(" a.nodetype ");
// sqlsb.append(" ,a.operator ");
// sqlsb.append(" from (SELECT distinct top ").append(pageSize);
// sqlsb.append(" o.id, " );
// sqlsb.append(" o.requestid, " );
// sqlsb.append(" o.userid, ");
// sqlsb.append(" o.workflowid, ");
// sqlsb.append(" o.workflowtype, ");
// sqlsb.append(" o.isremark, ");
// sqlsb.append(" o.lastisremark, ");
// sqlsb.append(" o.usertype, ");
// sqlsb.append(" o.nodeid, ");
// sqlsb.append(" o.agentorbyagentid, ");
// sqlsb.append(" o.agenttype, ");
// sqlsb.append(" o.receivedate, ");
// sqlsb.append(" o.receivetime, ");
// sqlsb.append(" o.viewtype, ");
// sqlsb.append(" o.iscomplete, ");
// sqlsb.append(" o.operatedate, ");
// sqlsb.append(" o.operatetime, ");
// sqlsb.append(" nodetype ");
// sqlsb.append(" ,wr.operator ");
// sqlsb.append(" FROM workflow_currentoperator o ");
//
// sqlsb.append(" left join workflow_requestlog wr");
// sqlsb.append(" on wr.requestid=o.requestid");
// sqlsb.append(" and wr.nodeid=o.nodeid");
// sqlsb.append(" and wr.operator = o.userid");
// sqlsb.append(" and wr.logtype <> '1'");
//
// sqlsb.append(" , workflow_flownode ");
//
// sqlsb.append(" where o.nodeid = ");
// sqlsb.append(" workflow_flownode.nodeid ");
// if(desremark ==1){//1:已提交
// sqlsb.append(" AND o.isremark='2' AND wr.operator IS NOT null ");
// }else if(desremark == 2){//2未提交
// sqlsb.append(" and ((o.isremark = '0' and (o.takisremark is null or o.takisremark=0)) or o.isremark in ('1','5','7','8','9') )");
// }else if(desremark == 3){//3:已查看
// sqlsb.append(" and (((o.isremark = '2' AND wr.operator IS NULL) or o.isremark in ('0','1','4','5','7','8','9')) AND o.viewtype IN (-1,-2)) ");
// }else if(desremark == 4){//4:未查看
// sqlsb.append(" AND o.viewtype = 0 ");
// }
// sqlsb.append(" and o.id > ").append(currentId);
// sqlsb.append(" and o.requestid = " + requestid + ") a, ");
// sqlsb.append(" workflow_nodebase b ");
// sqlsb.append(" where a.nodeid = b.id ");
// sqlsb.append(" and a.requestid = " + requestid + " ");
// sqlsb.append(" and a.agenttype <> 1 ");
// sqlsb.append(" order by a.id ");
// //System.out.println("20170309 =====> sqlsb.toString() = "+sqlsb.toString());
// rs.executeSql(sqlsb.toString());
//
// } else {
// 处理相关流程的查看权限
// if ("".equals(viewlogids)) {
// viewlogids = this.getViewLogids();
// }
StringBuffer sqlsb = new StringBuffer();
if ("sqlserver".equalsIgnoreCase(rs.getDBType())) { // sqlserver 排序提到这里
sqlsb.append(" select top ").append(pageSize).append(" a.id,a.nodeid, ");
} else {
sqlsb.append(" select a.id,a.nodeid, ");
}
sqlsb.append("(CASE WHEN a.nodeid < -1 THEN (SELECT nodename FROM workflow_freenode t WHERE t.id = a.nodeid) ELSE (SELECT nodename FROM workflow_nodebase t1 WHERE t1.id = a.nodeid) END) AS nodename,");
sqlsb.append(" a.userid, ");
sqlsb.append(" a.isremark, ");
sqlsb.append(" a.preisremark, ");
sqlsb.append(" a.lastisremark, ");
sqlsb.append(" a.usertype, ");
sqlsb.append(" a.agentorbyagentid, ");
sqlsb.append(" a.agenttype, ");
sqlsb.append(" a.receivedate, ");
sqlsb.append(" a.receivetime, ");
sqlsb.append(" a.operatedate, ");
sqlsb.append(" a.operatetime, ");
sqlsb.append(" a.processuser, ");
sqlsb.append(" a.viewtype, ");
sqlsb.append(" a.nodetype ");
sqlsb.append(" ,a.operator ");
sqlsb.append(" ,a.tab ");
//if("true".equals(isfirst)){
/*if("oracle".equals(rs.getDBType()) || "mysql".equals(rs.getDBType())){
sqlsb.append(" from (SELECT distinct ");
}else{
sqlsb.append(" from (SELECT distinct top ").append(pageSize); // sqlserver排序提到外层查询
}*/
sqlsb.append(" from (SELECT distinct ");
// }else{
// sqlsb.append(" from (SELECT distinct ");
// }
sqlsb.append(" o.id, ");
sqlsb.append(" o.requestid, ");
sqlsb.append(" o.userid, ");
sqlsb.append(" o.workflowid, ");
sqlsb.append(" o.workflowtype, ");
//workflow_otheroperator表中isremark为字符型这里转下字符
if (rs.getDBType().toLowerCase().equals("oracle") || rs.getDBType().toLowerCase().equals("postgresql")) {
sqlsb.append(" to_char(o.isremark) as isremark, ");
sqlsb.append(" to_char(o.preisremark) AS preisremark, ");
sqlsb.append(" to_char(o.lastisremark) AS lastisremark, ");
} else if (rs.getDBType().toLowerCase().equals("mysql")) {
sqlsb.append(" o.isremark, ");
sqlsb.append(" o.preisremark, ");
sqlsb.append(" o.lastisremark, ");
} else {
sqlsb.append(" cast(o.isremark as varchar) as isremark, ");
sqlsb.append(" cast(o.preisremark as varchar) as preisremark, ");
sqlsb.append(" cast(o.lastisremark as varchar) as lastisremark, ");
}
sqlsb.append(" o.usertype, ");
sqlsb.append(" o.nodeid, ");
sqlsb.append(" o.agentorbyagentid, ");
sqlsb.append(" o.agenttype, ");
sqlsb.append(" o.receivedate, ");
sqlsb.append(" o.receivetime, ");
sqlsb.append(" o.viewtype, ");
sqlsb.append(" o.iscomplete, ");
sqlsb.append(" o.operatedate, ");
sqlsb.append(" o.operatetime, ");
sqlsb.append(" o.processuser, ");
sqlsb.append("(case when o.nodeid < -1 then (select nodetype from workflow_freenode t where t.id = o.nodeid) else (select nodetype from workflow_flownode t1 where t1.nodeid = o.nodeid) end) as nodetype ");
sqlsb.append(" ,wr.operator ");
sqlsb.append(" ,1 as tab ");
sqlsb.append(" FROM workflow_currentoperator o ");
sqlsb.append(" " + joinStr + " workflow_requestlog wr");
sqlsb.append(" on wr.requestid=o.requestid");
sqlsb.append(" and wr.nodeid=o.nodeid");
sqlsb.append(" and wr.operator = o.userid");
sqlsb.append(" and wr.logtype <> '1'");
sqlsb.append(" and o.operatedate = wr.operatedate");
sqlsb.append(" and o.operatetime = wr.operatetime");//再通过时间关联一下,防止流程状态操作状态显示错误
sqlsb.append(" where o.id > ").append(currentId);
if ("submit".equals(desremark)) {//1:已提交----isremark等于4preisremark=11实际对应已提交数据
sqlsb.append(" AND (o.isremark='2' or (o.isremark=4 and o.preisremark=11)) AND (wr.operator IS NOT null or o.userid = o.processuser)");
} else if ("nosubmit".equals(desremark)) {//2未提交
sqlsb.append(" AND( (o.isremark != '2' AND o.isremark != '4') OR (o.isremark = '4' AND o.viewtype = 0 and o.preisremark != 11) ) ");
} else if ("view".equals(desremark)) {//3:已查看
sqlsb.append(" and ((o.isremark = '2' AND wr.operator IS NULL) or o.isremark in ('0','1','5','7','8','9','11') or (o.isremark=4 and o.preisremark!=11)) AND o.viewtype IN (-1,-2) ");
} else if ("noview".equals(desremark)) {//4:未查看
sqlsb.append(" AND o.viewtype=0 AND (o.isremark IN ('0','1','5','7','8','9','11') or (o.isremark = '2' AND wr.operator IS NULL) or (o.isremark=4 and o.preisremark!=11)) ");
}
sqlsb.append(" and o.requestid = " + requestid);
sqlsb.append(" union ");
sqlsb.append(" SELECT DISTINCT ");
sqlsb.append(" o.id, ");
sqlsb.append(" o.requestid, ");
sqlsb.append(" o.userid, ");
sqlsb.append(" o.workflowid, ");
sqlsb.append(" 0 as workflowtype, ");
sqlsb.append(" o.isremark, ");
sqlsb.append(" o.isremark as preisremark, ");
sqlsb.append(" o.isremark as lastisremark, ");
sqlsb.append(" o.usertype, ");
sqlsb.append(" o.nodeid, ");
sqlsb.append(" 0 as agentorbyagentid, ");
sqlsb.append(" '0' as agenttype, ");
sqlsb.append(" o.receivedate, ");
sqlsb.append(" o.receivetime, ");
sqlsb.append(" o.viewtype, ");
sqlsb.append(" 1 as iscomplete, ");
sqlsb.append(" o.operatedate, ");
sqlsb.append(" o.operatetime, ");
sqlsb.append(" wr.operator as processuser, ");
sqlsb.append("(case when o.nodeid < -1 then (select nodetype from workflow_freenode t where t.id = o.nodeid) else (select nodetype from workflow_flownode t1 where t1.nodeid = o.nodeid) end) as nodetype, ");
sqlsb.append(" wr.operator ");
sqlsb.append(" ,2 as tab ");
sqlsb.append(" FROM workflow_otheroperator o LEFT JOIN workflow_requestlog wr ON wr.requestid = o.requestid ");
sqlsb.append(" AND wr.nodeid = o.nodeid ");
sqlsb.append(" AND wr.operator = o.userid ");
sqlsb.append(" AND wr.logtype <> '1' ");
sqlsb.append(" WHERE o.requestid = " + requestid + " ");
sqlsb.append(" and o.id > ").append(currentId2);
sqlsb.append(" ) a ");
sqlsb.append(" where a.requestid = " + requestid + " ");
sqlsb.append(" and a.agenttype <> 1 ");
if (!"".equals(viewlogids)) {
sqlsb.append(" and a.nodeid in (" + viewlogids + ") ");
}
if (selectedNode != -1) {
sqlsb.append(" AND a.nodeid = " + selectedNode + " ");
}
if (!"".equals(selectedOperator)) {
sqlsb.append(" AND a.userid = " + selectedOperator + " ");
}
WorkflowConfigComInfo configComInfo = new WorkflowConfigComInfo();
boolean showdelFreeNodeInfo = "1".equals(configComInfo.getValue("showdelete_freenode_info"));
sqlsb.append(" and (a.nodeid > -1 or (a.nodeid < -1 and exists (select id from workflow_freenode where id = a.nodeid and requestid = " + requestid + (showdelFreeNodeInfo ? "" : " and groupid > 0 ") + " ))) ");
//搜索时返回状态
if (isAdSearch && "true".equals(isfirst)) {
rs.executeQuery("select count(id) as count from (" + sqlsb.toString().replace("top " + pageSize, "") + ") t");
result.put("countTime", new Date().getTime() - date1);
if (rs.next()) {
result.put("count", Util.null2String(rs.getString("count")));
}
}
sqlsb.append(" order by a.receivedate, a.receivetime,a.id , a.nodetype");
//System.out.println("20170309 =====> sqlsb.toString() = "+sqlsb.toString());
if ("oracle".equals(rs.getDBType())) { //必须排序后再限制rownum
String sql_oracle = sqlsb.toString();
sqlsb.setLength(0);
sqlsb.append("select * from (" + sql_oracle + ") where rownum < ").append(pageSize);
} else if ("mysql".equals(rs.getDBType())) {
sqlsb.append(" LIMIT " + pageSize);
} else if ("postgresql".equals(rs.getDBType())) {
sqlsb.append(" LIMIT " + pageSize);
}
if (requestid > 0) {
rs.executeSql(sqlsb.toString());
}
result.put("dataTime", new Date().getTime() - date1);
// }
List<Map<String, String>> statuslist = new ArrayList<Map<String, String>>();
int tmpnodeid = 0;
while (rs.next()) {
int tab = rs.getInt("tab");
if (tab == 1) {
currentId = rs.getInt("id");
} else {
currentId2 = rs.getInt("id");
}
tmpnodeid = rs.getInt("nodeid");
String tmpnodename = rs.getString("nodename");
Map<String, String> nodekv = null;
if (statuslist.size() == 0) {
currentMinId = currentId;
nodekv = new HashMap<String, String>();
statuslist.add(nodekv);
} else {
Map<String, String> temmap = statuslist.get(statuslist.size() - 1);
int tnodeid = Util.getIntValue(temmap.get("nodeid"), 0);
if (tnodeid == tmpnodeid) {
nodekv = temmap;
} else {
currentMinId = currentId;
nodekv = new HashMap<String, String>();
statuslist.add(nodekv);
}
}
nodekv.put("nodeid", tmpnodeid + "");
nodekv.put("nodename", tmpnodename + "");
}
int nextlistcount = 0;
int nextsubmitCount = 0;
int nextviewCount = 0;
int nextnoviewCount = 0;
if ("all".equals(desremark) && !isAdSearch) {
currentMaxId = currentId;
String maxsql = " select a.id,a.nodeid from workflow_currentoperator a where a.id > " + currentId + " and a.requestid=" + requestid + " order by a.id ,a.receivedate, a.receivetime";
rs1.executeSql(maxsql);
while (rs1.next()) {
int currentid = rs1.getInt("id");
int currentnodeid = rs1.getInt("nodeid");
if (currentnodeid == tmpnodeid) {
currentMaxId = currentid;
} else {
break;
}
}
String listcountsql = " select count(id) num from workflow_currentoperator where id > " + currentId + " and id <= " + currentMaxId + " and requestid=" + requestid + " and nodeid=" + tmpnodeid + " and agenttype <> 1 and usertype <> 1 ";
//String submitCountsql = " select count(id) num from workflow_currentoperator where id > "+currentId +" and id <= "+currentMaxId+" and requestid="+requestid +" and nodeid="+tmpnodeid +" and agenttype <> 1 and usertype <> 1 and isremark = 2 and exists (select 1 from workflow_requestlog where workflow_requestlog.requestid = workflow_currentoperator.requestid and workflow_currentoperator.nodeid=workflow_requestlog.nodeid and workflow_requestlog.operator=workflow_currentoperator.userid )";
//String viewCountsql = " select count(id) num from workflow_currentoperator where id > "+currentId +" and id <= "+currentMaxId+" and requestid="+requestid +" and nodeid="+tmpnodeid + " and agenttype <> 1 and usertype <> 1 and (viewtype = -1 or viewtype=-2) and ((isremark = '0' and (takisremark is null or takisremark=0)) or isremark in ('1','5','7','8','9') or (isremark = '2' and not exists (select 1 from workflow_requestlog where workflow_requestlog.requestid = workflow_currentoperator.requestid and workflow_currentoperator.nodeid=workflow_requestlog.nodeid and (workflow_requestlog.operator is null or workflow_requestlog.operator ='' )))) ";
//String noviewCountsql = " select count(id) num from workflow_currentoperator where id > "+currentId +" and id <= "+currentMaxId+" and requestid="+requestid +" and nodeid="+tmpnodeid + " and agenttype <> 1 and usertype <> 1 AND viewtype=0 AND (isremark IN ('0','1','4','5','7','8','9') or (isremark = '2' and not exists (select 1 from workflow_requestlog where workflow_requestlog.requestid = workflow_currentoperator.requestid and workflow_currentoperator.nodeid=workflow_requestlog.nodeid and (workflow_requestlog.operator is null or workflow_requestlog.operator ='' )))) ";
String submitCountsql = " SELECT Count(distinct wc.id) num FROM workflow_currentoperator wc " + joinStr + " workflow_requestlog wr ON wr.requestid = wc.requestid AND wc.nodeid = wr.nodeid AND wr.operator = wc.userid WHERE wc.id > " + currentId + " AND wc.id <= " + currentMaxId + " AND wc.requestid = " + requestid + " AND wc.nodeid = " + tmpnodeid + " AND wc.agenttype <> 1 AND wc.usertype <> 1 AND wc.isremark = 2 and wr.operator is NOT null ";
String viewCountsql = " SELECT Count(distinct wc.id) num FROM workflow_currentoperator wc " + joinStr + " workflow_requestlog wr ON wr.requestid = wc.requestid AND wc.nodeid = wr.nodeid AND wr.operator = wc.userid WHERE wc.id > " + currentId + " AND wc.id <= " + currentMaxId + " AND wc.requestid = " + requestid + " AND wc.nodeid = " + tmpnodeid + " AND wc.agenttype <> 1 AND wc.usertype <> 1 AND wc.viewtype IN (-1,-2) and ((wc.isremark = '2' AND wr.operator IS NULL) or wc.isremark in ('0','1','4','5','7','8','9')) ";
String noviewCountsql = " SELECT Count(distinct wc.id) num FROM workflow_currentoperator wc " + joinStr + " workflow_requestlog wr ON wr.requestid = wc.requestid AND wc.nodeid = wr.nodeid AND wr.operator = wc.userid WHERE wc.id > " + currentId + " AND wc.id <= " + currentMaxId + " AND wc.requestid = " + requestid + " AND wc.nodeid = " + tmpnodeid + " AND wc.agenttype <> 1 AND wc.usertype <> 1 AND wc.viewtype=0 AND (wc.isremark IN ('0','1','4','5','7','8','9','11') or (wc.isremark = '2' and wr.operator is null )) ";
rs1.executeSql(listcountsql);
while (rs1.next()) {
nextlistcount = rs1.getInt("num");
}
rs1.executeSql(submitCountsql);
while (rs1.next()) {
nextsubmitCount = rs1.getInt("num");
}
rs1.executeSql(viewCountsql);
while (rs1.next()) {
nextviewCount = rs1.getInt("num");
}
rs1.executeSql(noviewCountsql);
while (rs1.next()) {
nextnoviewCount = rs1.getInt("num");
}
}
Map<String, Object> allstatusmap = new HashMap<String, Object>();
Map<String, Object> submitstatusmap = new HashMap<String, Object>();
Map<String, Object> nosubmitstatusmap = new HashMap<String, Object>();
Map<String, Object> viewstatusmap = new HashMap<String, Object>();
Map<String, Object> noviewstatusmap = new HashMap<String, Object>();
//提交节点信息--滚动加载到当前currentoperator对应最大id
//数字统计转到新接口count中
ResourceComInfo resourceComInfo = new ResourceComInfo();
CustomerInfoComInfo customerInfoComInfo = new CustomerInfoComInfo();
Map<String, Object> all_nodemap = new HashMap<String, Object>();
Map<String, Object> submit_nodemap = new HashMap<String, Object>();
Map<String, Object> nosubmit_nodemap = new HashMap<String, Object>();
Map<String, Object> view_nodemap = new HashMap<String, Object>();
Map<String, Object> noview_nodemap = new HashMap<String, Object>();
rs.beforFirst();
int currentnum = 0;
for (Iterator<Map<String, String>> it = statuslist.iterator(); it.hasNext(); index++) {
Map<String, String> nodekv = it.next();
int fnodeid = Util.getIntValue(nodekv.get("nodeid"));
String namename = nodekv.get("nodename");
int submitCount = 0;
int viewCount = 0;
int noviewCount = 0;
int listcount = 0;
if ("false".equals(isfirst) && currentnum == 0 && lastNodeId == fnodeid) {
index -= 1;
}
if (tmpnodeid == fnodeid && currentnum == (statuslist.size() - 1)) {
submitCount = nextsubmitCount;
viewCount = nextviewCount;
noviewCount = nextnoviewCount;
listcount = nextlistcount;
}
currentnum++;
Map<String, Object> all_nodemap_in = new HashMap<String, Object>();
all_nodemap_in.put("nodeid", fnodeid);
all_nodemap_in.put("nodename", namename);
Map<String, Object> submit_nodemap_in = new HashMap<String, Object>();
Map<String, Object> nosubmit_nodemap_in = new HashMap<String, Object>();
Map<String, Object> view_nodemap_in = new HashMap<String, Object>();
Map<String, Object> noview_nodemap_in = new HashMap<String, Object>();
List<Map<String, String>> nodeallstatuslist = new ArrayList<Map<String, String>>();
List<Map<String, String>> nodesubmitstatuslist = new ArrayList<Map<String, String>>();
List<Map<String, String>> nodenosubmitstatuslist = new ArrayList<Map<String, String>>();
List<Map<String, String>> nodeviewstatuslist = new ArrayList<Map<String, String>>();
List<Map<String, String>> nodenoviewstatuslist = new ArrayList<Map<String, String>>();
if ("submit".equals(desremark)) {//1:已提交
//提交节点信息
submit_nodemap_in.putAll(all_nodemap_in);
submitstatusmap.put("datas", submit_nodemap);
submit_nodemap.put("key" + index, submit_nodemap_in);
submit_nodemap_in.put("list", nodesubmitstatuslist);
} else if ("nosubmit".equals(desremark)) {//2未提交
nosubmit_nodemap_in.putAll(all_nodemap_in);
nosubmitstatusmap.put("datas", nosubmit_nodemap);
nosubmit_nodemap.put("key" + index, nosubmit_nodemap_in);
nosubmit_nodemap_in.put("list", nodenosubmitstatuslist);
} else if ("view".equals(desremark)) {//3:已查看
view_nodemap_in.putAll(all_nodemap_in);
viewstatusmap.put("datas", view_nodemap);
view_nodemap.put("key" + index, view_nodemap_in);
view_nodemap_in.put("list", nodeviewstatuslist);
} else if ("noview".equals(desremark)) {//4:未查看
noview_nodemap_in.putAll(all_nodemap_in);
noviewstatusmap.put("datas", noview_nodemap);
noview_nodemap.put("key" + index, noview_nodemap_in);
noview_nodemap_in.put("list", nodenoviewstatuslist);
} else {
//所有节点信息
allstatusmap.put("datas", all_nodemap);
all_nodemap.put("key" + index, all_nodemap_in);
all_nodemap_in.put("list", nodeallstatuslist);
}
boolean islight = false;
RobotNodeServiceBiz robotNodeServiceBiz = new RobotNodeServiceBiz();
while (rs.next()) {
int tmpnodeid1 = rs.getInt("nodeid");
if (tmpnodeid1 != fnodeid) {
rs.previous();
break;
}
//String tmpnodename = rs.getString("nodename");
int tmpcurrid = rs.getInt("id");
String tmpuserid = rs.getString("userid");
String tmpisremark = Util.null2String(rs.getString("isremark"));
if (tmpisremark.equals("")) {
tmpisremark = Util.null2String(rs.getString("lastisremark"));
}
int tmpusertype = rs.getInt("usertype");
String tmpagentorbyagentid = rs.getString("agentorbyagentid");
int tmpagenttype = rs.getInt("agenttype");
String tmpreceivedate = rs.getString("receivedate");
String tmpreceivetime = rs.getString("receivetime");
String tmpoperatedate = rs.getString("operatedate");
String tmpoperatetime = rs.getString("operatetime");
String viewtype = rs.getString("viewtype");
String nodetype = rs.getString("nodetype");
int preisremark = rs.getInt("preisremark");
String processuser = rs.getString("processuser");
boolean flags = false;
String tmpIntervel = "";
// 如果tmpisremark=2 判断时候在日志表里有该人确定是否是由非会签得到的isremark=2
String operator = rs.getString("operator");
if (operator != null && !"".equals(operator)) {
flags = true;
}
if ((tmpisremark.equals("2") || (tmpisremark.equals("4") && preisremark == 11)) && tmpoperatedate != null && !tmpoperatedate.equals("")) {
tmpIntervel = TimeUtil.timeInterval2(tmpreceivedate + " " + tmpreceivetime, tmpoperatedate + " " + tmpoperatetime, user.getLanguage());
}
islight = !islight;
Map<String, String> _statusmap = new HashMap<String, String>();
// 操作人
String _statususername = "";
String _operatorid = "";
String _beagentid = "";
String _beagentname = "";
String _operatortype = "0";
if (tmpusertype == 0) {
_operatorid = tmpuserid;
_statususername = ServiceUtil.convertChar(resourceComInfo.getResourcename(tmpuserid));
if (tmpagenttype == 2) { //代理情况
_beagentid = tmpagentorbyagentid;
_beagentname = ServiceUtil.convertChar(resourceComInfo.getResourcename(tmpagentorbyagentid));
}
_statusmap.put("operatorImg", resourceComInfo.getMessagerUrls(tmpuserid));
_statusmap.put("operatorImgDefName", _statususername);
} else if (RobotNodeBiz.operatortype.equals(tmpusertype + "")) {
_statususername = Util.formatMultiLang(robotNodeServiceBiz.getRobotNodeSet(tmpnodeid1).getOperatorName());
_operatorid = tmpuserid;
_operatortype = "2";
} else {
_operatorid = tmpuserid;
_operatortype = "1";
_statususername = ServiceUtil.convertChar(customerInfoComInfo.getCustomerInfoname(tmpuserid));
}
// 查看状态 1:未查看, 2:以查看, 3已提交 4:暂停, 5:撤销, 6:启用 7:已查阅 8:退回 9:被撤回
int _statusCode = 0;
if (preisremark != 8 && (tmpisremark.equals("2") || (tmpisremark.equals("4") && preisremark == 11)) && (flags || tmpuserid.equals(processuser))) {
_statusCode = 3;
submitCount++;
if ("4".equals(nodetype) && preisremark == 0) {
_statusCode = 7;
}
} else if (tmpisremark.equals("0") || tmpisremark.equals("1") || tmpisremark.equals("5") || tmpisremark.equals("4") || tmpisremark.equals("8") || tmpisremark.equals("9") || tmpisremark.equals("7") || tmpisremark.equals("11") || (tmpisremark.equals("2") && !flags)) {
if (viewtype.equals("-2") || (viewtype.equals("-1") && !tmpoperatedate.equals(""))) {
_statusCode = 2;
viewCount++;
} else {
_statusCode = 1;
noviewCount++;
}
} else if ("s".equals(tmpisremark)) {
_statusCode = 4;
} else if ("r".equals(tmpisremark)) {
_statusCode = 6;
} else if ("c".equals(tmpisremark)) {
_statusCode = 5;
} else if (preisremark == 8 && viewtype.equals("-2") && tmpisremark.equals("2")) {
_statusCode = 2;
viewCount++;
}
RecordSet recordSet = new RecordSet();
recordSet.executeQuery("select operatetype from workflow_currentoperator where id=?", tmpcurrid);
if (recordSet.next()) {
int operatetype = recordSet.getInt(1);
if (operatetype == 3) {//退回
_statusCode = 8;
} else if (operatetype == 4) {//被撤回
_statusCode = 9;
}
}
listcount++;
if ("view".equals(desremark)) {//3:已查看
if (processuser.equals(tmpuserid) && ("2".equals(tmpisremark) || "4".equals(tmpisremark))) {
listcount--;
}
}
String _receivedate = "";
String _operatedate = "";
String _intervel = "";
if (!tmpisremark.equals("s") && !tmpisremark.equals("c") && !tmpisremark.equals("r")) {
_receivedate = Util.toScreen(tmpreceivedate, user.getLanguage()) + " " + Util.toScreen(tmpreceivetime, user.getLanguage());
}
_operatedate = Util.toScreen(tmpoperatedate, user.getLanguage()) + " " + Util.toScreen(tmpoperatetime, user.getLanguage());
_intervel = Util.toScreen(tmpIntervel, user.getLanguage());
_statusmap.put("statuscode", String.valueOf(_statusCode));
_statusmap.put("operator", _statususername);
_statusmap.put("receivedate", _receivedate);
_statusmap.put("operatedate", _operatedate);
_statusmap.put("intervel", _intervel);
_statusmap.put("operatorid", _operatorid);
_statusmap.put("operatortype", _operatortype);
_statusmap.put("beagentid", _beagentid);
_statusmap.put("beagentname", _beagentname);
_statusmap.put("nodetype", nodetype);
//所有节点
nodeallstatuslist.add(_statusmap);
//查看状态 1:未查看, 2:以查看, 3已提交 4:暂停, 5:撤销, 6:启用 7:已查阅
if ((tmpisremark.equals("2") || (tmpisremark.equals("4") && preisremark == 11)) && (flags || tmpuserid.equals(processuser))) {
nodesubmitstatuslist.add(_statusmap);
} else if (tmpisremark.equals("0") || tmpisremark.equals("1") || tmpisremark.equals("5") || tmpisremark.equals("4") || tmpisremark.equals("8") || tmpisremark.equals("9") || tmpisremark.equals("7") || tmpisremark.equals("11") || (tmpisremark.equals("2") && !flags)) {
if (viewtype.equals("-2") || (viewtype.equals("-1") && !tmpoperatedate.equals(""))) {
nodeviewstatuslist.add(_statusmap);
} else if (viewtype.equals("0")) {
nodenoviewstatuslist.add(_statusmap);
}
}
if ((!tmpisremark.equals("2") && !tmpisremark.equals("4")) || (tmpisremark.equals("4") && viewtype.equals("0"))) {
if (!tmpisremark.equals("s") && !tmpisremark.equals("s") && !tmpisremark.equals("c") && !tmpisremark.equals("r")) {
nodenosubmitstatuslist.add(_statusmap);
}
}
}
//--已提交、已查看、未查看
all_nodemap_in.put("submitCount", submitCount);//--已提交
all_nodemap_in.put("viewCount", viewCount);//--已查看
all_nodemap_in.put("noviewCount", noviewCount);//--未查看
if ("submit".equals(desremark)) {//1:已提交
//提交节点信息
submit_nodemap_in.put("listcount", listcount);
result.putAll(submitstatusmap);
} else if ("nosubmit".equals(desremark)) {//2未提交
nosubmit_nodemap_in.put("listcount", listcount);
result.putAll(nosubmitstatusmap);
} else if ("view".equals(desremark)) {//3:已查看
view_nodemap_in.put("listcount", listcount);
result.putAll(viewstatusmap);
} else if ("noview".equals(desremark)) {//4:未查看
noview_nodemap_in.put("listcount", listcount);
result.putAll(noviewstatusmap);
} else {
//所有节点信息
all_nodemap_in.put("listcount", listcount);
result.putAll(allstatusmap);
}
lastNodeId = fnodeid;
}
// if(maxid == currentMaxId){
// isfinish = 1;
// }
putpara.put("nodeindex", index + "");
putpara.put("currentMaxId", currentMaxId + "");
putpara.put("currentMinId", currentMinId + "");
putpara.put("currentId", currentId + "_" + currentId2);
putpara.put("lastNodeId", lastNodeId + "");
putpara.put("viewlogids", viewlogids + "");
result.put("parameter", putpara);
result.put("otherTime", new Date().getTime() - date1);
} catch (Exception e) {
e.printStackTrace();
}
return result;
}
%>

@ -1,99 +0,0 @@
<%@ page import="java.io.*" %>
<%@ page import="weaver.hrm.User" %>
<%@ page import="java.util.*" %>
<%@ page import="freemarker.template.Configuration" %>
<%@ page import="freemarker.template.TemplateExceptionHandler" %>
<%@ page import="freemarker.template.Template" %>
<%@ page import="java.nio.charset.StandardCharsets" %>
<%
String TemplatePath = "/opt/weaver/filesys/";
//String TemplateName = "html模版.ftl";
String TemplateName = "qwer.ftl";
Map<String, Object> root = new HashMap<>();
// root.put("title", "期末成绩表");
ArrayList<Map> list = new ArrayList<>();
Map<String, String> map = new HashMap<>();
map.put("lastname",new User(22).getLastname() );
map.put("subject", new User(22).getLastname() );
map.put("achievement", "98");
list.add(map);
Map<String, String> map2 = new HashMap<>();
map2.put("lastname", new User(22).getLastname() );
map2.put("subject", new User(22).getLastname());
map2.put("achievement", "97");
list.add(map2);
list.add(map2);
list.add(map2);
list.add(map2);
list.add(map2);
ArrayList<Map> lists = new ArrayList<Map>();
root.put("achievementList", list);
lists.add(root);
lists.add(root);
lists.add(root);
Map<String, Object> roots = new HashMap<String, Object>();
System.out.println(lists.size());
roots.put("testlist",lists);
//generate(TemplatePath, TemplateName, root, "shengcheng.html");
generate(TemplatePath, TemplateName, roots, "shengcheng1.docx");
%>
<%!
/**
* @param TemplatePath 模版存放目录
* @param TemplateName 模版名
* @param root 填充的数据
* @param GenerateFilename 生成文件名
* @throws Exception
*/
public static void generate(String TemplatePath, String TemplateName, Map<String, Object> root, String GenerateFilename) throws Exception {
Configuration cfg = new Configuration();
//指定模板文件的来源目录
cfg.setDirectoryForTemplateLoading(new File(TemplatePath));
cfg.setDefaultEncoding("UTF-8");
//设置错误的显示方式(日志)
//在生产系统中TemplateExceptionHandler.RETHROW_HANDLER 默认值
//在开发HTML模板期间TemplateExceptionHandler.HTML_DEBUG_HANDLER
//在开发非HTML模板期间TemplateExceptionHandler.DEBUG_HANDLER
cfg.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
cfg.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
//获取模板文件
Template temp = cfg.getTemplate(TemplateName);
//合并模板和数据模型
File file = new File(TemplatePath + "new-built");
//如果文件夹不存在,则创建文件夹
if (!file.exists()) {
//file.mkdirs();//多级目录
file.mkdir();//只创建一级目录
}
//Writer out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(TemplatePath + "new-built/" + GenerateFilename)));//输出文件
// FileWriter out = new FileWriter(TemplatePath + "new-built/" + GenerateFilename);
//Writer out = new OutputStreamWriter(System.out);//输出控制台
//StringWriter out = new StringWriter();//输出为字符串,可作为接口动态返回
FileOutputStream fos = new FileOutputStream(TemplatePath + "new-built/" + GenerateFilename);
Writer out = new OutputStreamWriter(fos, StandardCharsets.UTF_8);
temp.process(root, out);
out.flush();//可不手动调用
}
public static String codeUtf8(String text) {
String ISOtext = null;
ISOtext = new String(text.getBytes(StandardCharsets.UTF_8), StandardCharsets.ISO_8859_1);
return new String(ISOtext.getBytes(StandardCharsets.ISO_8859_1), StandardCharsets.UTF_8);
}
%>

@ -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");
}
%>

@ -1,75 +0,0 @@
<%@ page import="com.alibaba.fastjson.JSONObject" %>
<%@ page import="java.util.*" %>
<%@ page import="com.engine.common.util.ParamUtil" %>
<%@ page import="com.alibaba.fastjson.JSONArray" %>
<%@ page import="weaver.conn.RecordSet" %>
<%@ page import="java.sql.Array" %>
<%@ page import="com.wbi.util.Util" %>
<%@ page import="java.math.BigDecimal" %>
<%@ page import="tebie.applib.api.O" %>
<%@ page import="weaver.general.BaseBean" %>
<%@ page import="javax.xml.parsers.SAXParserFactory" %>
<%@ page import="javax.xml.parsers.SAXParser" %>
<%@ page import="java.io.InputStream" %>
<%@ page import="java.io.ByteArrayInputStream" %>
<%@ page import="com.engine.util.XMLUtils" %>
<%@ page import="org.xml.sax.helpers.DefaultHandler" %>
<%@ page import="org.xml.sax.Attributes" %>
<%@ page import="org.xml.sax.SAXException" %>
<%@ page language="java" contentType="text/html; charset=UTF-8" %>
<%
%>
<%!
public static Map<String, String> parseXMLToMap(String xmlString) {
new BaseBean().writeLog("XMLUtils:xmlString==>"+xmlString);
Map<String, String> resultMap = new HashMap<>();
try {
SAXParserFactory factory = SAXParserFactory.newInstance();
SAXParser saxParser = factory.newSAXParser();
InputStream xmlInput = new ByteArrayInputStream(xmlString.getBytes("UTF-8"));
saxParser.parse(xmlInput, new XMLUtils.SAXHandler(resultMap));
} catch (Exception e) {
e.printStackTrace();
}
return resultMap;
}
private static class SAXHandler extends DefaultHandler {
private Map<String, String> resultMap;
private Stack<String> elementStack = new Stack<>();
private StringBuilder elementValue = new StringBuilder();
public SAXHandler(Map<String, String> resultMap) {
this.resultMap = resultMap;
}
@Override
public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
elementStack.push(qName);
elementValue.setLength(0); // 清空字符缓存
}
@Override
public void endElement(String uri, String localName, String qName) throws SAXException {
String value = elementValue.toString().trim();
if (!value.isEmpty()) {
// 如果当前元素有值且没有子元素则将其添加到结果Map中
if (elementStack.size() > 1) {
resultMap.put(elementStack.peek(), value);
}
}
elementStack.pop();
}
@Override
public void characters(char[] ch, int start, int length) throws SAXException {
elementValue.append(ch, start, length);
}
}
%>

File diff suppressed because one or more lines are too long

@ -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,176 @@
<%@ page import="weaver.file.Prop" %>
<%@ page import="com.engine.custom.sl.entity.EsbRequestHeader" %>
<%@ page import="java.text.SimpleDateFormat" %>
<%@ page import="com.engine.custom.sl.entity.TravelToEsbBean" %>
<%@ page import="java.nio.charset.StandardCharsets" %>
<%@ page import="com.engine.util.SocketClientUtil" %>
<%@ page import="com.engine.util.XMLUtils" %>
<%@ page import="com.alibaba.fastjson.JSONObject" %>
<%@ page import="com.engine.common.util.ParamUtil" %>
<%@ page import="weaver.hrm.HrmUserVarify" %>
<%@ page import="weaver.hrm.User" %>
<%@ page import="weaver.conn.RecordSet" %>
<%@ page import="weaver.soa.workflow.request.RequestInfo" %>
<%@ page import="weaver.hrm.company.DepartmentComInfo" %>
<%@ page import="weaver.general.Util" %>
<%@ page import="weaver.interfaces.workflow.action.Action" %>
<%@ page import="java.util.*" %>
<%@ 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;
}
Map<String, Object> param = ParamUtil.request2Map(request);
String sql = "select main.*, base.REQUESTNAME from formtable_main_11 main " +
"left join uf_tosjLog log on log.REQUEST = main.REQUESTID " +
"left join WORKFLOW_REQUESTBASE base on base.REQUESTID = main.REQUESTID " +
" where log.ID is null ";
RecordSet recordSet = new RecordSet();
RecordSet rs = new RecordSet();
recordSet.executeQuery(sql);
StringBuilder execute = new StringBuilder();
int i = 0;
while (recordSet.next()){
String result = this.execute(recordSet, rs);
execute.append(result).append("\n");
i++;
}
out.print("共添加"+i+"条" +"\n");
out.print(execute.toString());
%>
<%!
public static String generateTimestamp() {
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMddHHmmss");
Date currentDate = new Date();
return dateFormat.format(currentDate);
}
public String execute(RecordSet recordSet, RecordSet rs) {
try {
String insertsql = "INSERT INTO uf_tosjLog(REQUEST, CONTENT, ZT, ML, DDSJ, TSSJ, FJML, ZWID, FJID) VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ? )";
DepartmentComInfo departmentComInfo = new DepartmentComInfo();
//公文标题
String requestname = recordSet.getString("REQUESTNAME");
String requestId = recordSet.getString("REQUESTID");
// String requestId = request.getRequestid();
// // 4获取表单名称
// String tablename = request.getRequestManager().getBillTableName();
// 5查找表单内容
// RecordSet rs = new RecordSet();
// rs.execute("select * from " + tablename + " where requestid = " + requestId);
// rs.next();
//是否推送合规 0 - 否 1 - 是
// int isTohg = Util.getIntValue(rs.getString("tohg"), 1);
// if (isTohg == 0){
// return Action.SUCCESS;
// }
//id表单主键
String mainid = recordSet.getString("id");
//公文编号
String fwwh = recordSet.getString("bh");
//发文部门名称
String ngbm = recordSet.getString("ngbm");
//成文时间
String cwrq = recordSet.getString("cwrq");
String ngr = recordSet.getString("ngr");
// String zw = rs.getString("zw"); //word格式
//生成的pdf
String zw = recordSet.getString("dwd");
String fj = recordSet.getString("fj");
User user = new User(Integer.parseInt(ngr));
//拼接数据
String subcompanyid = departmentComInfo.getSubcompanyid1(ngbm);
String departmentNames = departmentComInfo.getAllParentDepartmentBlankNames(ngbm, subcompanyid, "-");
departmentNames = "天津银行股份有限公司-"+departmentNames;
String context = "";
String flag = "|";
// context = requestname + flag + fwwh + flag +departmentNames + flag + cwrq +flag+ user.getLoginid()+flag+user.getLastname()+flag;
context = fwwh + flag + departmentNames + flag + cwrq + flag + user.getLastname();
//获取文件命
Map<String, String> fjName = getIdIMIDName(fj);
Map<String, String> zwName = getIdIMIDName(zw);
String fjStr = "";
String zwStr = "";
//附件
ArrayList<String> fileNameList = new ArrayList<>();
Set<Map.Entry<String, String>> entries = fjName.entrySet();
for (Map.Entry<String, String> entry : entries) {
String filename = entry.getValue();
if (fileNameList.contains(filename)){
String tepName= filename.contains(".")? filename.substring(0, filename.indexOf(".")) : "";
if(tepName!=null&&!"".equals(tepName)){
String extNameTemp = filename.contains(".")? filename.substring(filename.lastIndexOf(".") + 1) : "";
filename = tepName + "_"+entry.getKey()+"."+extNameTemp;
}
}else {
fileNameList.add(filename);
}
fjStr = fjStr + "&&"+ filename;
}
if (fjStr.startsWith("&&")){
fjStr = fjStr.substring(2);
}
fileNameList.clear();
//正文
Set<Map.Entry<String, String>> zwEntries = zwName.entrySet();
for (Map.Entry<String, String> entry : zwEntries) {
String filename = entry.getValue();
if (fileNameList.contains(filename)){
String tepName= filename.contains(".")? filename.substring(0, filename.indexOf(".")) : "";
if(tepName!=null&&!"".equals(tepName)){
String extNameTemp = filename.contains(".")? filename.substring(filename.lastIndexOf(".") + 1) : "";
filename = tepName + "_"+entry.getKey()+"."+extNameTemp;
}
}else {
fileNameList.add(filename);
}
zwStr = zwStr + "&&" + filename;
}
if (zwStr.startsWith("&&")){
zwStr = zwStr.substring(2);
}
context = zwStr+flag+fjStr+flag+context+flag+"sj"+requestId+flag;
Date date = new Date();
String time = new SimpleDateFormat("yyyy-MM-dd hh:mm").format(date);
rs.executeUpdate(insertsql,requestId,context,0,null,time,null,null,zw,fj);
return insertsql + "?"+ requestId + "|"+context + "|"+0 + "|"+null + "|"+time + "|"+null + "|"+null + "|"+zw + "|"+fj;
} catch (Exception e) {
// writeLog(e.getMessage()+ "||||||异常流程id==="+request.getRequestid());
e.printStackTrace();
//不管是否推送成功,都返回成功,不影响流程流转
return "error";
}
// boolean error = false;
// if (error) {
// request.getRequestManager().setMessageid("90001");
// request.getRequestManager().setMessagecontent("System Abnormal Termination Process Submission");
// }
// return Action.SUCCESS;
}
public static Map<String,String> getIdIMIDName(String ids ){
Map<String,String> idimageIDMap = new HashMap<>();
String sql = "select docid,df.imagefilename filename from docimagefile df left join imagefile imf on df.imagefileid = imf.imagefileid where DOCID in ("+ids+")";
RecordSet recordSet = new RecordSet();
recordSet.execute(sql);
while (recordSet.next()){
String docid = Util.null2String(recordSet.getString("docid"));
String filename = Util.null2String(recordSet.getString("filename"));
idimageIDMap.put(docid,filename);
}
return idimageIDMap;
};
%>

@ -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;
};
%>

@ -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);
%>
<%!
%>

@ -30,7 +30,7 @@ public class LoginEMFilter implements Filter {
StringBuffer url = request.getRequestURL(); StringBuffer url = request.getRequestURL();
new BaseBean().writeLog("请求地址====>getRequestURL" + url); new BaseBean().writeLog("请求地址====>getRequestURL" + url);
//内网请求 //内网请求
if(url.indexOf("14.1.209.146:8080") == -1){ if(url.indexOf("14.1.") == -1){
// String currentDateTime = request.getHeader("currentDateTime"); // String currentDateTime = request.getHeader("currentDateTime");
// String MdToken = request.getHeader("MdToken"); // String MdToken = request.getHeader("MdToken");
String currentDateTime = getCookie(request,"currentDateTime"); String currentDateTime = getCookie(request,"currentDateTime");
@ -109,8 +109,9 @@ public class LoginEMFilter implements Filter {
Date currentDate = new Date(); Date currentDate = new Date();
long difference = currentDate.getTime() - parsedDate.getTime(); long difference = currentDate.getTime() - parsedDate.getTime();
// System.out.println(difference);
if (difference > 5 * 60 * 1000) { // 10分钟 = 10 * 60 * 1000 毫秒 // 10分钟 = 10 * 60 * 1000 毫秒
if ( Math.abs(difference) > 5 * 60 * 1000) {
return true; return true;
} else { } else {
return false; return false;
@ -143,9 +144,13 @@ public class LoginEMFilter implements Filter {
public static void main(String[] args) { public static void main(String[] args) {
String originalString = "tq33q#LzDw$98HwEA@"; // String originalString = "tq33q#LzDw$98HwEA@";
String md5String = toMD5(originalString); // String md5String = toMD5(originalString);
System.out.println("Original: " + originalString); // System.out.println("Original: " + originalString);
System.out.println("MD5 Hash: " + md5String); // System.out.println("MD5 Hash: " + md5String);
System.out.println(DateExample("20240613071112"));
;
} }
} }

@ -12,6 +12,7 @@ import weaver.soa.workflow.request.RequestInfo;
import java.io.IOException; import java.io.IOException;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
import java.util.TreeSet;
/** /**
* Online custom action interface * Online custom action interface
@ -23,52 +24,83 @@ public class Action20231113045722 extends BaseBean implements Action {
@Override @Override
public String execute(RequestInfo request) { public String execute(RequestInfo request) {
try {
String requestId = request.getRequestid(); String requestId = request.getRequestid();
String tablename = request.getRequestManager().getBillTableName();
RecordSet rs = new RecordSet();
rs.execute("select * from " + tablename + " where requestid = " + requestId);
rs.next();
// if (1 == 1 ){
// throw new Exception("11111"+requestId);
// }
String mainid = rs.getString("id");
String fsr = rs.getString("fsr");
//标题
String title = rs.getString("fsnr");
//内容
String context = rs.getString("txxx");
//PC端链接 纯文本就传空字符串
String linkUrl = rs.getString("pclj");
//移动端链接 纯文本就传空字符串
String linkMobileUrl = rs.getString("applj");
//codeid codeid
int codeid = Util.getIntValue(rs.getString("codeid"));
if (codeid <= 0) {
request.getRequestManager().setMessageid("90001");
request.getRequestManager().setMessagecontent("codeid异常");
return Action.FAILURE_AND_CONTINUE;
}
String tablename = request.getRequestManager().getBillTableName(); //消息来源(见文档第四点补充)
MessageType messageType = null;
try {
messageType = MessageType.newInstance(codeid);
}catch (Exception e){
throw new Exception("MessageType.newInstance推送消息异常:"+codeid);
}
RecordSet rs = new RecordSet();
rs.execute("select * from " + tablename + " where requestid = " + requestId);
rs.next();
String mainid = rs.getString("id");
String fsr = rs.getString("fsr");
//标题
String title = rs.getString("fsnr");
//内容
String context = rs.getString("txxx");
//PC端链接 纯文本就传空字符串
String linkUrl = rs.getString("pclj");
//移动端链接 纯文本就传空字符串
String linkMobileUrl = rs.getString("applj");
//codeid codeid
int codeid = Util.getIntValue(rs.getString("codeid"));
if (codeid <= 0) {
request.getRequestManager().setMessageid("90001");
request.getRequestManager().setMessagecontent("codeid异常");
return Action.FAILURE_AND_CONTINUE;
}
//接收人id
Set<String> userIdList = new TreeSet<>();
try {
userIdList = convertToHashSet(fsr);
}catch (Exception e){
throw new Exception("convertToHashSet推送消息异常:"+fsr);
}
//消息来源(见文档第四点补充) // if (1 == 1 ) {
MessageType messageType = MessageType.newInstance(codeid); // throw new Exception("userIdList:" + userIdList);
// }
try {
MessageBean messageBean = Util_Message.createMessage(messageType, userIdList, title, context, linkUrl, linkMobileUrl);
messageBean.setCreater(1);//创建人id
//message.setBizState("0");需要修改消息状态时传入,表示消息最初状态为待处理
// messageBean.setTargetId("121|22"); //消息来源code +“|”+业务id 需要修改消息状态时传入,这个字段是自定义的,和修改消息状态的时候传入相同的值,可做更新。
boolean store = Util_Message.store(messageBean);
} catch (IOException e) {
e.printStackTrace();
request.getRequestManager().setMessageid("90002");
request.getRequestManager().setMessagecontent("异常1111111"+e.getMessage()+ e);
return Action.FAILURE_AND_CONTINUE;
// throw new Exception("推送消息异常");
//接收人id }
Set<String> userIdList = convertToHashSet(fsr);
try { }catch (Exception e){
MessageBean messageBean = Util_Message.createMessage(messageType, userIdList, title, context, linkUrl, linkMobileUrl); request.getRequestManager().setMessageid("90002");
messageBean.setCreater(1);//创建人id request.getRequestManager().setMessagecontent("异常"+e.getMessage()+ e);
//message.setBizState("0");需要修改消息状态时传入,表示消息最初状态为待处理 return Action.FAILURE_AND_CONTINUE;
// messageBean.setTargetId("121|22"); //消息来源code +“|”+业务id 需要修改消息状态时传入,这个字段是自定义的,和修改消息状态的时候传入相同的值,可做更新。
Util_Message.store(messageBean);
} catch (IOException e) {
e.printStackTrace();
} }
return Action.SUCCESS; return Action.SUCCESS;
} }

@ -1,419 +1,419 @@
package weaver.interfaces.workflow.action.javacode; // package weaver.interfaces.workflow.action.javacode;
//
import cn.wps.yun.StringUtil; // import cn.wps.yun.StringUtil;
import com.google.common.base.Charsets; // import com.google.common.base.Charsets;
import com.google.common.io.ByteSource; // import com.google.common.io.ByteSource;
import com.icbc.api.internal.apache.http.impl.cookie.S; // import com.icbc.api.internal.apache.http.impl.cookie.S;
import org.apache.commons.compress.archivers.zip.ZipArchiveEntry; // import org.apache.commons.compress.archivers.zip.ZipArchiveEntry;
import org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream; // import org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream;
import org.apache.commons.lang3.StringUtils; // import org.apache.commons.lang3.StringUtils;
import weaver.conn.RecordSet; // import weaver.conn.RecordSet;
import weaver.file.ImageFileManager; // import weaver.file.ImageFileManager;
import weaver.general.Util; // import weaver.general.Util;
//
import weaver.hrm.User; // import weaver.hrm.User;
import weaver.hrm.company.DepartmentComInfo; // import weaver.hrm.company.DepartmentComInfo;
import weaver.interfaces.workflow.action.Action; // import weaver.interfaces.workflow.action.Action;
import weaver.general.BaseBean; // import weaver.general.BaseBean;
import weaver.soa.workflow.request.RequestInfo; // import weaver.soa.workflow.request.RequestInfo;
//
import java.io.*; // import java.io.*;
import java.nio.charset.Charset; // import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets; // import java.nio.charset.StandardCharsets;
import java.nio.file.Files; // import java.nio.file.Files;
import java.nio.file.Path; // import java.nio.file.Path;
import java.nio.file.Paths; // import java.nio.file.Paths;
import java.text.SimpleDateFormat; // import java.text.SimpleDateFormat;
import java.time.LocalDate; // import java.time.LocalDate;
import java.time.format.DateTimeFormatter; // import java.time.format.DateTimeFormatter;
import java.util.*; // import java.util.*;
import java.util.zip.ZipEntry; // import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream; // import java.util.zip.ZipOutputStream;
//
import static java.nio.charset.StandardCharsets.UTF_8; // import static java.nio.charset.StandardCharsets.UTF_8;
//
/** // /**
* Online custom action interface // * Online custom action interface
*/ // */
public class Action20231123035106 implements Action{ // public class Action20231123035106 implements Action{
private static final BaseBean bb = new BaseBean(); // private static final BaseBean bb = new BaseBean();
private static final String postSQl = ""; // private static final String postSQl = "";
private static final String receiptSQL = ""; // private static final String receiptSQL = "";
//
private static final String queryDocIdSql = // private static final String queryDocIdSql =
"select * from docimagefile docfile " + // "select * from docimagefile docfile " +
"left join docdetail doc on docfile.DOCID = doc.ID " + // "left join docdetail doc on docfile.DOCID = doc.ID " +
"left join imagefile file on docfile.IMAGEFILEID = file.IMAGEFILEID " + // "left join imagefile file on docfile.IMAGEFILEID = file.IMAGEFILEID " +
// "left join uf_tssjb tssjb on docfile.DOCID = tssjb.wdid " + // // "left join uf_tssjb tssjb on docfile.DOCID = tssjb.wdid " +
"where (doc.docsubject like '%食品%' or doc.docsubject like '%专项%' ) "; // "where (doc.docsubject like '%食品%' or doc.docsubject like '%专项%' ) ";
//
private static final String dataEqualSql = "and doc.DOCCREATEDATE = ? "; // private static final String dataEqualSql = "and doc.DOCCREATEDATE = ? ";
private static final String dataRangeSql = "and doc.DOCCREATEDATE >= ? and doc.DOCCREATEDATE <= ? "; // private static final String dataRangeSql = "and doc.DOCCREATEDATE >= ? and doc.DOCCREATEDATE <= ? ";
public String url = ""; // public String url = "";
public String queryType = ""; // public String queryType = "";
public String queryDate = ""; // public String queryDate = "";
public String startDate = ""; // public String startDate = "";
public String endDate = ""; // public String endDate = "";
public String deptIds = ""; // public String deptIds = "";
// public String userNames = ""; // // public String userNames = "";
public String dirPath = "/opt/weaver/scjgw"; // public String dirPath = "/opt/weaver/scjgw";
public String postSeccategory = ""; // public String postSeccategory = "";
public String receiptSeccategory = ""; // public String receiptSeccategory = "";
//
//
//
//
@Override // @Override
public String execute(RequestInfo requestInfo) { // public String execute(RequestInfo requestInfo) {
writeLog("执行定时任务开始","PushCorn"); // writeLog("执行定时任务开始","PushCorn");
writeLog("url",url); // writeLog("url",url);
writeLog("queryType",queryType); // writeLog("queryType",queryType);
writeLog("queryDate",queryDate); // writeLog("queryDate",queryDate);
writeLog("startDate",startDate); // writeLog("startDate",startDate);
writeLog("endDate",endDate); // writeLog("endDate",endDate);
writeLog("deptIds",deptIds); // writeLog("deptIds",deptIds);
// writeLog("userNames",userNames); // // writeLog("userNames",userNames);
writeLog("dirPath",dirPath); // writeLog("dirPath",dirPath);
writeLog("postSeccategory",postSeccategory); // writeLog("postSeccategory",postSeccategory);
writeLog("receiptSeccategory",receiptSeccategory); // writeLog("receiptSeccategory",receiptSeccategory);
try { // try {
System.setOut(new PrintStream(System.out, true, "UTF-8")); // System.setOut(new PrintStream(System.out, true, "UTF-8"));
} catch (UnsupportedEncodingException e) { // } catch (UnsupportedEncodingException e) {
e.printStackTrace(); // e.printStackTrace();
} // }
writeLog("new String(s.getBytes(UTF_8))",new String("通".getBytes(UTF_8))); // writeLog("new String(s.getBytes(UTF_8))",new String("通".getBytes(UTF_8)));
writeLog("new String(s.getBytes(StandardCharsets.UTF_8), StandardCharsets.UTF_8)", new String("通".getBytes(StandardCharsets.UTF_8), StandardCharsets.UTF_8)); // writeLog("new String(s.getBytes(StandardCharsets.UTF_8), StandardCharsets.UTF_8)", new String("通".getBytes(UTF_8), UTF_8));
writeLog("new String(s.getBytes(StandardCharsets.UTF_8), StandardCharsets.UTF_8)", new String("通".getBytes(StandardCharsets.UTF_8), Charset.forName("GBK"))); // writeLog("new String(s.getBytes(StandardCharsets.UTF_8), StandardCharsets.UTF_8)", new String("通".getBytes(UTF_8), Charset.forName("GBK")));
//
//
// 假设 s 是 UTF-8 编码的字符串 // // 假设 s 是 UTF-8 编码的字符串
String s1 = "通"; // String s1 = "通";
//
// 将 s 从 UTF-8 转换为字节数组 // // 将 s 从 UTF-8 转换为字节数组
//
byte[] utf8Bytes = s1.getBytes(StandardCharsets.UTF_8); // byte[] utf8Bytes = s1.getBytes(UTF_8);
//
// 将字节数组从 UTF-8 转换为 GBK // // 将字节数组从 UTF-8 转换为 GBK
String gbkString = new String(utf8Bytes, Charset.forName("GBK")); // String gbkString = new String(utf8Bytes, Charset.forName("GBK"));
//
// 打印日志 // // 打印日志
writeLog("new String(s.getBytes(StandardCharsets.UTF_8), Charset.forName(\"GBK\"))", gbkString); // writeLog("new String(s.getBytes(StandardCharsets.UTF_8), Charset.forName(\"GBK\"))", gbkString);
//
//
//
//
//
//
//
//
//
//
writeLog("new String(s.getBytes(UTF_8))",new String("通报".getBytes(UTF_8))); // writeLog("new String(s.getBytes(UTF_8))",new String("通报".getBytes(UTF_8)));
writeLog("new String(s.getBytes(UTF_8))",new String("关于2023年天津市食品安全抽检监测任务完成情况的通报第三期.zip".getBytes(UTF_8))); // writeLog("new String(s.getBytes(UTF_8))",new String("关于2023年天津市食品安全抽检监测任务完成情况的通报第三期.zip".getBytes(UTF_8)));
String x= "关于2023年天津市食品安全抽检监测任务完成情况的通报第三期.zip"; // String x= "关于2023年天津市食品安全抽检监测任务完成情况的通报第三期.zip";
writeLog("utf8Str===>",convertGbkToUtf8(x)); // writeLog("utf8Str===>",convertGbkToUtf8(x));
String querySql = queryDocIdSql; // String querySql = queryDocIdSql;
//生成人员map // //生成人员map
final HashMap<String, String> useridNamemap = new HashMap<>(); // final HashMap<String, String> useridNamemap = new HashMap<>();
//
RecordSet recordSet = new RecordSet(); // RecordSet recordSet = new RecordSet();
// if (!StringUtil.isEmpty(deptIds)) { // // if (!StringUtil.isEmpty(deptIds)) {
// querySql = querySql + "and doc.docdepartmentid in (" + deptIds + " )"; // // querySql = querySql + "and doc.docdepartmentid in (" + deptIds + " )";
// // String[] deptids = deptIds.split(","); // // // String[] deptids = deptIds.split(",");
// // String[] usernames = deptIds.split(","); // // // String[] usernames = deptIds.split(",");
// // for (int i = 0; i < userids.length; i++) { // // // for (int i = 0; i < userids.length; i++) {
// // useridNamemap.put(userids[i],usernames[i]); // // // useridNamemap.put(userids[i],usernames[i]);
// // } // // // }
// }else { // // }else {
// return; // // return;
// } // // }
// List<String> childNodeIds = getChildNodeIds(postSeccategory); // // List<String> childNodeIds = getChildNodeIds(postSeccategory);
// childNodeIds.add(postSeccategory); // // childNodeIds.add(postSeccategory);
// List<String> childNodeIds1 = getChildNodeIds(receiptSeccategory); // // List<String> childNodeIds1 = getChildNodeIds(receiptSeccategory);
// childNodeIds1.add(receiptSeccategory); // // childNodeIds1.add(receiptSeccategory);
// childNodeIds.addAll(childNodeIds1); // // childNodeIds.addAll(childNodeIds1);
//
//
//添加目录 // //添加目录
// querySql = querySql + "and ( seccategory in ( "+ String.join(",",childNodeIds)+" ) )" ; // // querySql = querySql + "and ( seccategory in ( "+ String.join(",",childNodeIds)+" ) )" ;
//
//查询指定天的 // //查询指定天的
// if ("0".equals(queryType)) { // // if ("0".equals(queryType)) {
// writeLog("查询指定天的文档"); // // writeLog("查询指定天的文档");
// querySql = querySql + dataEqualSql; // // querySql = querySql + dataEqualSql;
// recordSet.executeQuery(querySql, queryDate); // // recordSet.executeQuery(querySql, queryDate);
// } else if ("1".equals(queryType)) { // // } else if ("1".equals(queryType)) {
// writeLog("查询指定范围的文档",startDate,endDate); // // writeLog("查询指定范围的文档",startDate,endDate);
// querySql = querySql + dataRangeSql; // // querySql = querySql + dataRangeSql;
// recordSet.executeQuery(querySql, startDate, endDate); // // recordSet.executeQuery(querySql, startDate, endDate);
// } else if ("2".equals(queryType)) { // // } else if ("2".equals(queryType)) {
// writeLog("查询昨天的文档"); // // writeLog("查询昨天的文档");
// querySql = querySql + dataEqualSql; // // querySql = querySql + dataEqualSql;
// recordSet.executeQuery(querySql, getYesterdayDateStr()); // // recordSet.executeQuery(querySql, getYesterdayDateStr());
// } // // }
recordSet.executeQuery(querySql); // recordSet.executeQuery(querySql);
writeLog("查询sql",querySql); // writeLog("查询sql",querySql);
writeLog("查询sql",recordSet.getExceptionMsg()); // writeLog("查询sql",recordSet.getExceptionMsg());
writeLog("查询数量", recordSet.getCounts()+""); // writeLog("查询数量", recordSet.getCounts()+"");
//开始推送数据 // //开始推送数据
//检查文件夹路径 // //检查文件夹路径
checkAndCreateDir(); // checkAndCreateDir();
HashMap<String, String> docid_docNameMap = new HashMap<>(); // HashMap<String, String> docid_docNameMap = new HashMap<>();
HashMap<String, List<String>> docid_imagefilleIdMap = new HashMap<>(); // HashMap<String, List<String>> docid_imagefilleIdMap = new HashMap<>();
HashMap<String,HashMap<String, String>> fileinfo = new HashMap<>(); // HashMap<String,HashMap<String, String>> fileinfo = new HashMap<>();
while (recordSet.next()){ // while (recordSet.next()){
//文档id // //文档id
String docid = weaver.general.Util.null2String(recordSet.getString("DOCID")); // String docid = Util.null2String(recordSet.getString("DOCID"));
//文档标题 // //文档标题
String docsubject = weaver.general.Util.null2String(recordSet.getString("docsubject")); // String docsubject = Util.null2String(recordSet.getString("docsubject"));
//附件id // //附件id
String imagefileid = weaver.general.Util.null2String(recordSet.getString("IMAGEFILEID")); // String imagefileid = Util.null2String(recordSet.getString("IMAGEFILEID"));
//文档时间 // //文档时间
String DOCCREATEDATE = weaver.general.Util.null2String(recordSet.getString("DOCCREATEDATE")); // String DOCCREATEDATE = Util.null2String(recordSet.getString("DOCCREATEDATE"));
//目录 seccategory // //目录 seccategory
String seccategory = weaver.general.Util.null2String(recordSet.getString("seccategory")); // String seccategory = Util.null2String(recordSet.getString("seccategory"));
String DOCCREATERID = weaver.general.Util.null2String(recordSet.getString("DOCCREATERID")); // String DOCCREATERID = Util.null2String(recordSet.getString("DOCCREATERID"));
HashMap<String, String> map = new HashMap<>(); // HashMap<String, String> map = new HashMap<>();
map.put("DOCCREATEDATE",DOCCREATEDATE); // map.put("DOCCREATEDATE",DOCCREATEDATE);
map.put("seccategory",postSeccategory.equals(seccategory) ? "2" : "1"); // map.put("seccategory",postSeccategory.equals(seccategory) ? "2" : "1");
map.put("DOCCREATERID",new User(Util.getIntValue(DOCCREATERID)).getLastname() ); // map.put("DOCCREATERID",new User(Util.getIntValue(DOCCREATERID)).getLastname() );
docid_docNameMap.put(docid,docsubject); // docid_docNameMap.put(docid,docsubject);
fileinfo.put(docid,map); // fileinfo.put(docid,map);
List<String> imagefilleIdList = docid_imagefilleIdMap.get(docid); // List<String> imagefilleIdList = docid_imagefilleIdMap.get(docid);
if (imagefilleIdList == null){ // if (imagefilleIdList == null){
ArrayList<String> filleIdList = new ArrayList<>(); // ArrayList<String> filleIdList = new ArrayList<>();
filleIdList.add(imagefileid); // filleIdList.add(imagefileid);
docid_imagefilleIdMap.put(docid,filleIdList); // docid_imagefilleIdMap.put(docid,filleIdList);
}else { // }else {
imagefilleIdList.add(imagefileid); // imagefilleIdList.add(imagefileid);
} // }
} // }
writeLog("需要推送的文档",docid_docNameMap.toString()); // writeLog("需要推送的文档",docid_docNameMap.toString());
// 开始封装文件 // // 开始封装文件
String DateDirFile = ""; // String DateDirFile = "";
if(docid_docNameMap.keySet().size() > 0 ){ // if(docid_docNameMap.keySet().size() > 0 ){
// 创建今天的文件夹 // // 创建今天的文件夹
DateDirFile = checkAndCreateDir(getTodayDateStr()); // DateDirFile = checkAndCreateDir(getTodayDateStr());
}else { // }else {
return ""; // return "";
} // }
String finalDateDirFile = DateDirFile; // String finalDateDirFile = DateDirFile;
writeLog("今天的文件目录",DateDirFile); // writeLog("今天的文件目录",DateDirFile);
writeLog("docid_imagefilleIdMap",docid_imagefilleIdMap.toString()); // writeLog("docid_imagefilleIdMap",docid_imagefilleIdMap.toString());
docid_imagefilleIdMap.forEach((docid, filleIdList)->{ // docid_imagefilleIdMap.forEach((docid, filleIdList)->{
String FileDir = docid_docNameMap.get(docid); // String FileDir = docid_docNameMap.get(docid);
String FileDir2 = new String(FileDir.getBytes(UTF_8)); // String FileDir2 = new String(FileDir.getBytes(UTF_8));
writeLog("编码修改前 FileDir",FileDir); // writeLog("编码修改前 FileDir",FileDir);
writeLog("编码修改后 FileDir2",FileDir2); // writeLog("编码修改后 FileDir2",FileDir2);
String zipFileName = finalDateDirFile + File.separator + docid +".zip"; // String zipFileName = finalDateDirFile + File.separator + docid +".zip";
//修改下编码 // //修改下编码
String zipFileName2 = new String(zipFileName.getBytes(StandardCharsets.UTF_8)); // String zipFileName2 = new String(zipFileName.getBytes(UTF_8));
String zipFileName3 = null; // String zipFileName3 = null;
try { // try {
// zipFileName.getBytes(UTF_8) // // zipFileName.getBytes(UTF_8)
zipFileName3 = new String(zipFileName.getBytes("GBK"), UTF_8); // zipFileName3 = new String(zipFileName.getBytes("GBK"), UTF_8);
} catch (Exception e) { // } catch (Exception e) {
e.printStackTrace(); // e.printStackTrace();
} // }
//
//
writeLog("编码修改前 zipFileName",zipFileName); // writeLog("编码修改前 zipFileName",zipFileName);
writeLog("编码修改后 zipFileName",zipFileName2); // writeLog("编码修改后 zipFileName",zipFileName2);
writeLog("编码修改后 zipFileName3",zipFileName3); // writeLog("编码修改后 zipFileName3",zipFileName3);
File filezip = new File(new String(zipFileName.getBytes(UTF_8))); // File filezip = new File(new String(zipFileName.getBytes(UTF_8)));
//
byte[] folderBytes = new byte[0]; // 假设原始编码是GBK // byte[] folderBytes = new byte[0]; // 假设原始编码是GBK
try { // try {
folderBytes = zipFileName.getBytes("GBK"); // folderBytes = zipFileName.getBytes("GBK");
} catch (UnsupportedEncodingException e) { // } catch (UnsupportedEncodingException e) {
e.printStackTrace(); // e.printStackTrace();
} // }
String encodedFolderName = new String(folderBytes, Charset.defaultCharset()); // String encodedFolderName = new String(folderBytes, Charset.defaultCharset());
writeLog("编码修改后 encodedFolderName",encodedFolderName); // writeLog("编码修改后 encodedFolderName",encodedFolderName);
ZipArchiveOutputStream zos =null; // ZipArchiveOutputStream zos =null;
writeLog("filezip",zipFileName); // writeLog("filezip",zipFileName);
try { // try {
zos = new ZipArchiveOutputStream( new FileOutputStream(filezip)); // zos = new ZipArchiveOutputStream( new FileOutputStream(filezip));
zos.setEncoding("UTF-8"); // zos.setEncoding("UTF-8");
for (String filleId : filleIdList) { // for (String filleId : filleIdList) {
ImageFileManager ifm = new ImageFileManager(); // ImageFileManager ifm = new ImageFileManager();
ifm.getImageFileInfoById(Integer.parseInt(filleId)); // ifm.getImageFileInfoById(Integer.parseInt(filleId));
InputStream imagefile = ifm.getInputStream(); // InputStream imagefile = ifm.getInputStream();
// String s1 = ifm.getImageFileName().split(".")[0]; // // String s1 = ifm.getImageFileName().split(".")[0];
writeLog("压缩文件",ifm.getImageFileName()); // writeLog("压缩文件",ifm.getImageFileName());
addInputStreamToZip(imagefile,zos,FileDir+File.separator+ifm.getImageFileName()); // addInputStreamToZip(imagefile,zos,FileDir+File.separator+ifm.getImageFileName());
} // }
} catch (FileNotFoundException e) { // } catch (FileNotFoundException e) {
writeLog("压缩文件异常",e.toString()); // writeLog("压缩文件异常",e.toString());
e.printStackTrace(); // e.printStackTrace();
} catch (IOException e) { // } catch (IOException e) {
writeLog("压缩文件异常",e.toString()); // writeLog("压缩文件异常",e.toString());
e.printStackTrace(); // e.printStackTrace();
}catch (Exception e){ // }catch (Exception e){
writeLog("压缩文件异常",e.toString()); // writeLog("压缩文件异常",e.toString());
e.printStackTrace(); // e.printStackTrace();
}finally { // }finally {
try { // try {
zos.close(); // zos.close();
} catch (IOException e) { // } catch (IOException e) {
e.printStackTrace(); // e.printStackTrace();
} // }
} // }
//
writeLog("压缩完文件名",filezip.getName()); // writeLog("压缩完文件名",filezip.getName());
//
String s = "通.zip"; // String s = "通.zip";
String convertedString =""; // String convertedString ="";
try { // try {
//
byte[] bytes = StringUtils.getBytes(s, "UTF-8"); // byte[] bytes = StringUtils.getBytes(s, "UTF-8");
//
// 使用Guava转换编码 // // 使用Guava转换编码
ByteSource byteSource = ByteSource.wrap(s.getBytes(Charsets.UTF_8)); // ByteSource byteSource = ByteSource.wrap(s.getBytes(Charsets.UTF_8));
byte[] gbkBytes = byteSource.asCharSource(Charsets.UTF_8).asByteSource(Charsets.UTF_8).read(); // byte[] gbkBytes = byteSource.asCharSource(Charsets.UTF_8).asByteSource(Charsets.UTF_8).read();
// String gbkString = new String(gbkBytes, "GBK"); // // String gbkString = new String(gbkBytes, "GBK");
} catch (UnsupportedEncodingException e) { // } catch (UnsupportedEncodingException e) {
//
} catch (IOException e) { // } catch (IOException e) {
e.printStackTrace(); // e.printStackTrace();
} // }
//
// filezip.renameTo(new File(convertedString)); // // filezip.renameTo(new File(convertedString));
// HashMap<String, String> map = fileinfo.get(docid); // // HashMap<String, String> map = fileinfo.get(docid);
//
//开始推送数据 // //开始推送数据
// try { // // try {
// String s = ApiClient.callApi(url, docid, docid_docNameMap.get(docid), map.get("DOCCREATEDATE"), // // String s = ApiClient.callApi(url, docid, docid_docNameMap.get(docid), map.get("DOCCREATEDATE"),
// map.get("seccategory"), map.get("DOCCREATERID"), filezip); // // map.get("seccategory"), map.get("DOCCREATERID"), filezip);
// writeLog("返回数据",s); // // writeLog("返回数据",s);
// } catch (IOException e) { // // } catch (IOException e) {
// e.printStackTrace(); // // e.printStackTrace();
// writeLog(e.getMessage()); // // writeLog(e.getMessage());
// writeLog(e.getMessage()); // // writeLog(e.getMessage());
// } // // }
}); // });
return ""; // return "";
} // }
private static String getTodayDateStr() { // private static String getTodayDateStr() {
// 获取当前日期 // // 获取当前日期
LocalDate today = LocalDate.now(); // LocalDate today = LocalDate.now();
// 定义日期格式 // // 定义日期格式
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMdd"); // DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMdd");
// 将昨天的日期格式化为字符串 // // 将昨天的日期格式化为字符串
return today.format(formatter); // return today.format(formatter);
} // }
//
private static String getYesterdayDateStr() { // private static String getYesterdayDateStr() {
// 获取当前日期 // // 获取当前日期
LocalDate today = LocalDate.now(); // LocalDate today = LocalDate.now();
// 减去一天得到前一天的日期 // // 减去一天得到前一天的日期
LocalDate yesterday = today.minusDays(1); // LocalDate yesterday = today.minusDays(1);
// 定义日期格式 // // 定义日期格式
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); // DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
// 将昨天的日期格式化为字符串 // // 将昨天的日期格式化为字符串
return yesterday.format(formatter); // return yesterday.format(formatter);
} // }
//
private static void writeLog(String... log) { // private static void writeLog(String... log) {
StringBuilder logStr = new StringBuilder(); // StringBuilder logStr = new StringBuilder();
for (String s : log) { // for (String s : log) {
logStr.append("|").append(s); // logStr.append("|").append(s);
} // }
bb.writeLog("PushCornTest.class"+"==>"+logStr); // bb.writeLog("PushCornTest.class"+"==>"+logStr);
} // }
//
private void checkAndCreateDir(){ // private void checkAndCreateDir(){
// 创建File对象 // // 创建File对象
File directory = new File(dirPath); // File directory = new File(dirPath);
//
// 检查路径是否存在 // // 检查路径是否存在
if (!directory.exists()) { // if (!directory.exists()) {
// 不存在,尝试创建多级目录 // // 不存在,尝试创建多级目录
boolean result = directory.mkdirs(); // boolean result = directory.mkdirs();
if (result) { // if (result) {
writeLog("多级目录已创建成功:" + dirPath); // writeLog("多级目录已创建成功:" + dirPath);
} else { // } else {
writeLog("目录创建失败,请检查路径是否正确,或者程序是否有相应的权限。"); // writeLog("目录创建失败,请检查路径是否正确,或者程序是否有相应的权限。");
} // }
} else { // } else {
writeLog("目录已存在:" + dirPath); // writeLog("目录已存在:" + dirPath);
} // }
} // }
//
//
private String checkAndCreateDir(String date){ // private String checkAndCreateDir(String date){
// 创建File对象 // // 创建File对象
File directory = new File(dirPath+File.separator+date); // File directory = new File(dirPath+File.separator+date);
//
// 检查路径是否存在 // // 检查路径是否存在
if (!directory.exists()) { // if (!directory.exists()) {
// 不存在,尝试创建多级目录 // // 不存在,尝试创建多级目录
boolean result = directory.mkdirs(); // boolean result = directory.mkdirs();
if (result) { // if (result) {
writeLog("多级目录已创建成功:" + dirPath+File.separator+date); // writeLog("多级目录已创建成功:" + dirPath+File.separator+date);
} else { // } else {
writeLog(dirPath+File.separator+date,"目录创建失败,请检查路径是否正确,或者程序是否有相应的权限。"); // writeLog(dirPath+File.separator+date,"目录创建失败,请检查路径是否正确,或者程序是否有相应的权限。");
return "-1"; // return "-1";
} // }
} else { // } else {
writeLog("目录已存在:" + dirPath+File.separator+date); // writeLog("目录已存在:" + dirPath+File.separator+date);
} // }
return dirPath+File.separator+date; // return dirPath+File.separator+date;
} // }
//
public void addInputStreamToZip(InputStream inputStream, ZipArchiveOutputStream zos, String entryName) throws IOException { // public void addInputStreamToZip(InputStream inputStream, ZipArchiveOutputStream zos, String entryName) throws IOException {
writeLog("编码修改后 entryName",entryName); // writeLog("编码修改后 entryName",entryName);
ZipArchiveEntry zipEntry = new ZipArchiveEntry(entryName); // ZipArchiveEntry zipEntry = new ZipArchiveEntry(entryName);
zos.putArchiveEntry(zipEntry); // zos.putArchiveEntry(zipEntry);
byte[] buffer = new byte[1024]; // byte[] buffer = new byte[1024];
int length; // int length;
while ((length = inputStream.read(buffer)) > 0) { // while ((length = inputStream.read(buffer)) > 0) {
zos.write(buffer, 0, length); // zos.write(buffer, 0, length);
} // }
inputStream.close(); // inputStream.close();
zos.closeArchiveEntry(); // zos.closeArchiveEntry();
} // }
//
public static List<String> getChildNodeIds(String parentId) { // public static List<String> getChildNodeIds(String parentId) {
String sql = "SELECT id FROM docseccategory WHERE parentid = ?"; // String sql = "SELECT id FROM docseccategory WHERE parentid = ?";
List<String> childIds = new ArrayList<>(); // List<String> childIds = new ArrayList<>();
RecordSet rs = new RecordSet(); // RecordSet rs = new RecordSet();
rs.executeQuery(sql , parentId); // rs.executeQuery(sql , parentId);
while (rs.next()) { // while (rs.next()) {
String id = rs.getString("id"); // String id = rs.getString("id");
childIds.add(id); // childIds.add(id);
childIds.addAll(getChildNodeIds(id)); // 递归调用以获取所有后代节点 // childIds.addAll(getChildNodeIds(id)); // 递归调用以获取所有后代节点
} // }
return childIds; // return childIds;
} // }
//
//
public static String convertGbkToUtf8(String gbkStr) { // public static String convertGbkToUtf8(String gbkStr) {
// 将GBK字符串转换为Unicode // // 将GBK字符串转换为Unicode
String unicodeStr = new String(gbkStr.getBytes(Charset.forName("GBK")), Charset.forName("UTF-8")); // String unicodeStr = new String(gbkStr.getBytes(Charset.forName("GBK")), Charset.forName("UTF-8"));
//
// 从Unicode转换为UTF-8 // // 从Unicode转换为UTF-8
byte[] utf8Bytes = unicodeStr.getBytes(Charset.forName("UTF-8")); // byte[] utf8Bytes = unicodeStr.getBytes(Charset.forName("UTF-8"));
return new String(utf8Bytes, Charset.forName("UTF-8")); // return new String(utf8Bytes, Charset.forName("UTF-8"));
} // }
//
//
public static String toUnicodeString(String str) { // public static String toUnicodeString(String str) {
StringBuilder unicode = new StringBuilder(); // StringBuilder unicode = new StringBuilder();
for (int i = 0; i < str.length(); i++) { // for (int i = 0; i < str.length(); i++) {
unicode.append(String.format("\\u%04X", (int) str.charAt(i))); // unicode.append(String.format("\\u%04X", (int) str.charAt(i)));
} // }
return unicode.toString(); // return unicode.toString();
} // }
//
public static String unicodeToUtf8(String unicodeStr) { // public static String unicodeToUtf8(String unicodeStr) {
String stringFromUnicode = unicodeStr.replace("\\u", ""); // String stringFromUnicode = unicodeStr.replace("\\u", "");
byte[] utf8Bytes = new byte[stringFromUnicode.length() / 2]; // byte[] utf8Bytes = new byte[stringFromUnicode.length() / 2];
for (int i = 0; i < stringFromUnicode.length(); i += 2) { // for (int i = 0; i < stringFromUnicode.length(); i += 2) {
int value = Integer.parseInt(stringFromUnicode.substring(i, i + 2), 16); // int value = Integer.parseInt(stringFromUnicode.substring(i, i + 2), 16);
utf8Bytes[i / 2] = (byte) value; // utf8Bytes[i / 2] = (byte) value;
} // }
return new String(utf8Bytes, StandardCharsets.UTF_8); // return new String(utf8Bytes, StandardCharsets.UTF_8);
} // }
//
} // }

@ -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;
}
}

@ -0,0 +1,645 @@
package weaver.meeting.video.consumer;
import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.api.meeting.cusvideo.util.YealinkVideoUtil;
import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.apache.commons.lang3.time.DateUtils;
import weaver.Constants;
import weaver.WorkPlan.WorkPlanHandler;
import weaver.WorkPlan.WorkPlanService;
import weaver.WorkPlan.WorkPlanShare;
import weaver.conn.RecordSet;
import weaver.domain.workplan.WorkPlan;
import weaver.general.BaseBean;
import weaver.general.Util;
import weaver.hrm.User;
import weaver.hrm.resource.ResourceComInfo;
import weaver.meeting.video.util.VideoMeetingUtil;
import weaver.systeminfo.SystemEnv;
import java.net.URLEncoder;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @Description:
* @Author: lj
* @CreateTime: 2023-06-05 15:41
* @Version: 1.0
*/
public class YealinkVideoClient extends VideoMeetingClient {
private static BaseBean logger = new BaseBean();
@Override
public Map<String, Object> addMeeting(Map<String, Object> otherParam) {
Map<String, Object> apiData = new HashMap<>();
try {
if ("".equals(Util.null2String(getDomainName_url()))) {
throw new RuntimeException("获取亿联会议地址URl未配置请检查视频会议是否配置正常");
}
//获取参数
logger.writeLog("^^^ YealinkVideoClient.addMeeting : otherParam = " + otherParam);
String userid = Util.null2String(otherParam.get("userid"));//创建人ID
String topic = Util.null2String(otherParam.get("topic"));//会议标题
String start_time = Util.null2String(otherParam.get("starttime")) + ":00";//会议开始时间
String end_time = Util.null2String(otherParam.get("end_time")) + ":00";//会议结束时间
String hrmids = Util.null2String(otherParam.get("hrmids"));//会议参与人
String password = Util.null2String(otherParam.get("password"));//会议密码
String apiKey = Util.null2String(otherParam.get("api_key"));//对应亿联的client id
String apiSecret = Util.null2String(otherParam.get("api_secret"));//对应亿联的client secret
//这里需要替换创建人的ID
String host = StringUtils.removeEnd(getDomainName_url(), "/");
//获取token
String token = YealinkVideoUtil.getToken(host, apiKey, apiSecret);
//开始执行请求
String createUserId = YealinkVideoUtil.getYeaLinkUserId(host, token, userid);
String url = host + "/users/" + createUserId + "/meetings";
//构建请求体
JSONObject body = new JSONObject();
//会议主题长度小于128
if (topic.length() > 128) {
topic = StringUtils.substring(topic, 0, 128);
}
body.put("subject", topic);
//会议开始日期格式为yyyy-MM-dd
Date start = DateUtils.parseDate(start_time, "yyyy-MM-dd HH:mm:ss");
if (start.compareTo(new Date()) < 0) {
start = new Date();
}
String startDate = DateFormatUtils.format(start, "yyyy-MM-dd");
body.put("startDate", startDate);
//会议开始时间格式为HH:mm小时部分使用24小时计算分钟部分为5的倍数。会议开始时间必须大于当前时间。
int minute = DateUtil.minute(start);
start = DateUtils.addMinutes(DateUtils.addMinutes(start, -minute % 5), 5);
String startTime = DateFormatUtils.format(start, "HH:mm");
body.put("startTime", startTime);
//会议持续时间小时部分,取值范围为[0, 48)。
int[] dateHoursAndMinute = getDateHoursAndMinute(start, DateUtils.parseDate(end_time, "yyyy-MM-dd HH:mm:ss"));
int durationHour = dateHoursAndMinute[0];
body.put("durationHour", durationHour);
//会议持续时间分钟部分当durationHour为0时可选值为30、45其他情况下可选值为0、15、30、45。
int durationMinute = dateHoursAndMinute[1];
body.put("durationMinute", durationMinute);
//参会成员列表。参会成员数量默认支持100个如需调整请联系亿联会议默认创建者为组织者
JSONArray participants = new JSONArray();
//首先添加组织者
JSONObject createUser = new JSONObject();
createUser.put("id", createUserId);
createUser.put("role", 0);
participants.add(createUser);
for (String hrmid : StringUtils.split(hrmids, ",")) {
JSONObject participant = new JSONObject();
participant.put("id", YealinkVideoUtil.getYeaLinkUserId(host, token, hrmid));
participant.put("role", 2);
participants.add(participant);
}
body.put("participants", participants);
//是否使用随机会议号true使用随机会议号false使用会议室会议号
body.put("enableRandomMeetingNumber", true);
//会议密码格式为6位数字
body.put("meetingPassword", password);
body.put("enableWatermark", true);
body.put("watermarkTransparency", 2);
body.put("watermarkFontSize", 1);
//执行接口
JSONObject resultJson = YealinkVideoUtil.doPost(url, token, null, body);
//返回结果
apiData.put("maxid", videoData2OA(host, token, createUserId, resultJson, otherParam));
apiData.put("api_status", true);
} catch (Exception e) {
logger.writeLog("^^^ YealinkVideoClient.addMeeting : error !!!", e);
apiData.put("api_status", false);
apiData.put("msg", "新增亿联会议失败:" + e.getMessage());
}
return apiData;
}
@Override
public Map<String, Object> editMeeting(Map<String, Object> otherParam) {
Map<String, Object> apiData = new HashMap<>();
try {
if ("".equals(Util.null2String(getDomainName_url()))) {
throw new RuntimeException("获取亿联会议地址URl未配置请检查视频会议是否配置正常");
}
//获取参数
logger.writeLog("^^^ YealinkVideoClient.editMeeting : otherParam = " + otherParam);
String userid = Util.null2String(otherParam.get("userid"));//创建人ID
String topic = Util.null2String(otherParam.get("topic"));//会议标题
String start_time = Util.null2String(otherParam.get("starttime")) + ":00";//会议开始时间
String end_time = Util.null2String(otherParam.get("end_time")) + ":00";//会议结束时间
String hrmids = Util.null2String(otherParam.get("hrmids"));//会议参与人
String password = Util.null2String(otherParam.get("password"));//会议密码
String apiKey = Util.null2String(otherParam.get("api_key"));//对应亿联的client id
String apiSecret = Util.null2String(otherParam.get("api_secret"));//对应亿联的client secret
//这里需要替换创建人的ID
String host = StringUtils.removeEnd(getDomainName_url(), "/");
//获取token
String token = YealinkVideoUtil.getToken(host, apiKey, apiSecret);
//开始执行请求
String createUserId = YealinkVideoUtil.getYeaLinkUserId(host, token, userid);
//会议ID
String meetingId = Util.null2String(otherParam.get("id"));
String url = host + "/users/" + createUserId + "/meetings/" + meetingId;
//先获取原始会议信息
JSONObject meetingInfo = getMeetingInfoById(host, token, createUserId, meetingId);
//构建请求体
JSONObject body = new JSONObject();
//更新类型可选值0更新单个会议1更新会议序列
body.put("updateType", 0);
//会议顺序号,取值范围为[1, 100],更新单个会议时必输
body.put("sequence", 1);
//时区ID。具体时区列表信息详见基础信息-查询时区列表接口
body.put("zoneId", meetingInfo.getString("zoneId"));
//会议主题长度小于128
if (topic.length() > 128) {
topic = StringUtils.substring(topic, 0, 128);
}
body.put("subject", topic);
//会议开始日期格式为yyyy-MM-dd
Date start = DateUtils.parseDate(start_time, "yyyy-MM-dd HH:mm:ss");
if (start.compareTo(new Date()) < 0) {
start = new Date();
}
String startDate = DateFormatUtils.format(start, "yyyy-MM-dd");
body.put("startDate", startDate);
//会议开始时间格式为HH:mm小时部分使用24小时计算分钟部分为5的倍数。会议开始时间必须大于当前时间。
int minute = DateUtil.minute(start);
start = DateUtils.addMinutes(DateUtils.addMinutes(start, -minute % 5), 5);
String startTime = DateFormatUtils.format(start, "HH:mm");
body.put("startTime", startTime);
//会议持续时间小时部分,取值范围为[0, 48)。
int[] dateHoursAndMinute = getDateHoursAndMinute(start, DateUtils.parseDate(end_time, "yyyy-MM-dd HH:mm:ss"));
int durationHour = dateHoursAndMinute[0];
body.put("durationHour", durationHour);
//会议持续时间分钟部分当durationHour为0时可选值为30、45其他情况下可选值为0、15、30、45。
int durationMinute = dateHoursAndMinute[1];
body.put("durationMinute", durationMinute);
//参会成员列表。参会成员数量默认支持100个如需调整请联系亿联会议默认创建者为组织者
JSONArray participants = new JSONArray();
//首先添加组织者
JSONObject createUser = new JSONObject();
createUser.put("id", createUserId);
createUser.put("role", 0);
participants.add(createUser);
for (String hrmid : StringUtils.split(hrmids, ",")) {
JSONObject participant = new JSONObject();
participant.put("id", YealinkVideoUtil.getYeaLinkUserId(host, token, hrmid));
participant.put("role", 2);
participants.add(participant);
}
body.put("participants", participants);
//是否使用随机会议号true使用随机会议号false使用会议室会议号
body.put("enableRandomMeetingNumber", true);
//会议密码格式为6位数字
body.put("meetingPassword", meetingInfo.getString("meetingPassword"));
//执行接口
JSONObject resultJson = YealinkVideoUtil.doPut(url, token, null, body);
if (resultJson == null) {
resultJson = new JSONObject();
resultJson.put("id", meetingId);
}
//返回结果
apiData.put("maxid", videoData2OA(host, token, createUserId, resultJson, otherParam));
apiData.put("api_status", true);
} catch (Exception e) {
logger.writeLog("^^^ YealinkVideoClient.editMeeting : error !!!", e);
apiData.put("api_status", false);
apiData.put("msg", "编辑亿联会议失败:" + e.getMessage());
}
return apiData;
}
@Override
public Map<String, Object> overMeeting(Map<String, Object> otherParam) {
otherParam.put("completed", true);
RecordSet rs = new RecordSet();
String id = MapUtils.getString(otherParam, "id", "");
String manufacturers = MapUtils.getString(otherParam, "manufacturers", "");
rs.executeQuery("select id from meeting_videolist where videomtid=? and manufacturers=?", id, manufacturers);
if (rs.next()) {
String videoid = rs.getString(1);
otherParam.put("videoid", videoid);
}
return cancelMeeting(otherParam);
}
@Override
public Map<String, Object> cancelMeeting(Map<String, Object> otherParam) {
Map<String, Object> apiData = new HashMap<>();
try {
if ("".equals(Util.null2String(getDomainName_url()))) {
throw new RuntimeException("获取亿联会议地址URl未配置请检查视频会议是否配置正常");
}
//获取参数
logger.writeLog("^^^ YealinkVideoClient.cancelMeeting : otherParam = " + otherParam);
String userid = Util.null2String(otherParam.get("userid"));//创建人ID
//这两个需要重新获取
otherParam = VideoMeetingUtil.dealParams(otherParam);
String apiKey = Util.null2String(otherParam.get("api_key"));//对应亿联的client id
String apiSecret = Util.null2String(otherParam.get("api_secret"));//对应亿联的client secret
//这里需要替换创建人的ID
String host = StringUtils.removeEnd(getDomainName_url(), "/");
//获取token
String token = YealinkVideoUtil.getToken(host, apiKey, apiSecret);
//开始执行请求
String createUserId = YealinkVideoUtil.getYeaLinkUserId(host, token, userid);
//会议ID
String meetingId = Util.null2String(otherParam.get("id"));
String url = host + "/users/" + createUserId + "/meetings/" + meetingId;
//构建请求体
JSONObject body = new JSONObject();
//删除类型可选值0删除单个会议1删除会议序列
body.put("deleteType", 0);
//会议顺序号,取值范围为[1, 100],删除单个会议时必输
body.put("sequence", 1);
//执行接口
JSONObject resultJson = YealinkVideoUtil.doDelete(url, token, null, body);
//处理对应的日程
String videoid = MapUtils.getString(otherParam, "videoid", "-1");
if (otherParam.containsKey("completed")) {
finishWorkPlan(videoid);
} else {
deleteWorkPlan(videoid);
}
//返回结果
apiData.put("result", true);
} catch (Exception e) {
logger.writeLog("^^^ YealinkVideoClient.editMeeting : error !!!", e);
apiData.put("result", false);
apiData.put("msg", "删除亿联会议失败:" + e.getMessage());
}
return apiData;
}
@Override
public Map<String, Object> getUserInfo(Map<String, Object> otherParam) {
return null;
}
/**
*
*
* @param start
* @param end
* @return
*/
private int[] getDateHoursAndMinute(Date start, Date end) {
int[] arr = new int[2];
long milliseconds = end.getTime() - start.getTime();
long seconds = milliseconds / 1000;
int hours = Math.round(seconds / 3600);
int minutes = Math.round((seconds % 3600) / 60);
if (minutes > 45) {
hours += 1;
minutes = 0;
} else if (minutes > 30) {
minutes = 45;
} else {
if (hours > 0) {
if (minutes > 15) {
minutes = 30;
} else if (minutes > 0) {
minutes = 15;
}
} else {
minutes = 30;
}
}
if (hours >= 48) {
hours = 47;
}
arr[0] = hours;
arr[1] = minutes;
return arr;
}
/**
* OA
*
* @param resultJson
* @param map
* @return
*/
private String videoData2OA(String host, String token, String creater, JSONObject resultJson, Map<String, Object> map) {
String maxId = "";
String videomthostid = Util.null2String(map.get("host_id"));
String videomtname = Util.null2String(map.get("topic"));
// String videomtbegindate = Util.null2String(map.get("start_time"));
String starttime = Util.null2String(map.get("starttime"));
String videomtenddate = Util.null2String(map.get("end_time"));
String videomtcreater = Util.null2String(map.get("userid"));
// String mtpassword = Util.null2String(map.get("password"));
// String mtcontrolpassword = Util.null2String(map.get("controlpassword"));
// String userid = Util.null2String(map.get("userid"));
String manufacturers = Util.null2String(map.get("manufacturers"));
String mouldkey = Util.null2String(map.get("mouldkey"));//模块主键
String frommould = Util.null2String(map.get("frommould"));//所属模块
String videoid = Util.null2String(map.get("videoid"));
String hrmids = Util.null2String(map.get("hrmids"));
RecordSet recordSet = new RecordSet();
recordSet.executeQuery("SELECT * FROM meeting_videomould WHERE mouldvalue = ? or mouldname = ?", frommould, frommould);
if (recordSet.next()) {
//这里强制约定。这里传的标识,必须和表里保持一致,否则,作为垃圾数据处理。
frommould = Util.null2String(recordSet.getString("mouldvalue"));
} else {
frommould = "";
mouldkey = "";
}
//获取接口返回的会议ID
String videomtstatus = "1";//0未开始1进行中2结束3取消根据时间来判断
String videomtid = Util.null2String(resultJson.getString("id"));//虚拟会议id
//这里需要根据会议ID再次查询会议详细信息
JSONObject json = getMeetingInfoById(host, token, creater, videomtid);
String mtpwd = Util.null2String(json.getString("meetingPassword"));
String mtnum = Util.null2String(json.getString("meetingNumber"));
String url2 = getYealinkUrl(host, token, mtnum, videomtcreater, mtpwd);
String url1 = url2;
try {
ResourceComInfo resourceComInfo = new ResourceComInfo();
url1 = StringUtils.replace(url1, "&name=", "&name=" + URLEncoder.encode(resourceComInfo.getLastname(videomtcreater), "utf-8"));
if (url1.contains("&autojoin=false")) {
url1 = StringUtils.replace(url1, "&autojoin=false", "&autojoin=true");
}
} catch (Exception e) {
logger.writeLog("^^^ YealinkVideoClient.videoData2OA : encode error !!!", e);
}
//更新到视频会议表
RecordSet rs = new RecordSet();
String oaMtid = mtnum;
VideoMeetingUtil videoMeetingUtil = new VideoMeetingUtil();
if (StringUtils.isBlank(videoid)) {
if (rs.getDBType().equalsIgnoreCase("oracle") && Util.null2String(rs.getOrgindbtype()).equals("oracle")) {
rs.executeUpdate("INSERT INTO meeting_videolist (videomtid ,videomthostid , videomtname ,videomtbegindate ," +
"videomtenddate ,videomtcreater ,videomtstatus ,manufacturers ,frommould ,mouldkey,mtpassword," +
"oaMtid,videomtstarturl,videomtjoinurl) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?)",
videomtid, videomthostid, videomtname, starttime, videomtenddate, videomtcreater, videomtstatus,
manufacturers, frommould, mouldkey, mtpwd, oaMtid, url1, url2);
} else {
rs.executeUpdate("INSERT INTO meeting_videolist (videomtid ,videomthostid , videomtname ,videomtbegindate ," +
"videomtenddate ,videomtcreater ,videomtstatus ,manufacturers ,frommould ,mouldkey,mtpassword," +
"oaMtid,hrmids,videomtstarturl,videomtjoinurl) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)",
videomtid, videomthostid, videomtname, starttime, videomtenddate, videomtcreater, videomtstatus,
manufacturers, frommould, mouldkey, mtpwd, oaMtid, hrmids, url1, url2);
}
rs.executeQuery("SELECT max(id) FROM meeting_videolist where videomtcreater = ?", videomtcreater);
rs.next();
String MaxID = rs.getString(1);
if (rs.getDBType().equalsIgnoreCase("oracle") && Util.null2String(rs.getOrgindbtype()).equals("oracle")) {
rs.executeUpdate("update meeting_videolist set hrmids = empty_clob() where id = ?", MaxID);
videoMeetingUtil.updateHrmmembers(MaxID, hrmids);
}
maxId = MaxID;
} else {
if (rs.getDBType().equalsIgnoreCase("oracle") && Util.null2String(rs.getOrgindbtype()).equals("oracle")) {
rs.executeUpdate("update meeting_videolist set videomtid = ?, videomtname = ?,videomtbegindate = ?," +
"videomtenddate = ?,mtpassword = ?,videomtstarturl = ?,videomtjoinurl = ?,hrmids = empty_clob() " +
"where id =?", videomtid, videomtname, starttime, videomtenddate, mtpwd, url1, url2, videoid);
videoMeetingUtil.updateHrmmembers(videoid, hrmids);
} else {
rs.executeUpdate("update meeting_videolist set videomtid = ?, videomtname = ?,videomtbegindate = ?," +
"videomtenddate = ?,mtpassword = ?,videomtstarturl = ?,videomtjoinurl = ?,hrmids=? " +
"where id =?", videomtid, videomtname, starttime, videomtenddate, mtpwd, url1, url2, hrmids, videoid);
}
maxId = videoid;
}
//同步日程
handleWorkPlan(maxId, Util.getIntValue(videomtcreater), videomtname, hrmids, starttime, videomtenddate, oaMtid);
return maxId;
}
/**
*
*
* @param videoMtId
* @param createrId
* @param title
* @param hrmids
* @param start
* @param end
* @param mtNum
*/
private void handleWorkPlan(String videoMtId, int createrId, String title,
String hrmids, String start, String end,
String mtNum) {
try {
WorkPlan workPlan = new WorkPlan();
RecordSet rs = new RecordSet();
//查询是否存在此日程
rs.executeQuery("select id from workplan where videomtid=?", videoMtId);
int workPlanId = -1;
if (rs.next()) {
workPlanId = Util.getIntValue(rs.getString(1));
}
if (workPlanId > 0) {//修改
workPlan.setWorkPlanID(workPlanId);
//获取原日程信息
getWorkPlanById(rs, workPlan);
} else {//新增
workPlan.setCreateType(1);
//紧急程度
workPlan.setUrgentLevel("1");
//日程提醒方式
workPlan.setRemindType(com.engine.workplan.util.WorkPlanUtil.getWorkPlanDefaultRemindTypeIds());
//日程类型
workPlan.setWorkPlanType(1);
//是否开始前提醒
workPlan.setRemindBeforeStart("1");
//是否结束前提醒
workPlan.setRemindBeforeEnd("0");
//
workPlan.setRemindTimesBeforeStart(10);
workPlan.setRemindTimesBeforeEnd(10);
//
workPlan.setStatus(Constants.WorkPlan_Status_Unfinished);
}
//创建人
workPlan.setCreaterId(createrId);
//标题
workPlan.setWorkPlanName(title);
//接收人
workPlan.setResourceId(hrmids); //系统参与人
if (StringUtils.isBlank(workPlan.getResourceId()) && createrId > 0) {//接收人为空,默认直接
workPlan.setResourceId(createrId + "");
}
//开始时间
String beginDate = "", beginTime = "";
if (StringUtils.isNotBlank(start)) {
String[] s = StringUtils.split(start, " ");
beginDate = s[0];
if (s.length > 1) {
beginTime = s[1];
if (beginTime.length() == 8) {
beginTime = StringUtils.substringBeforeLast(beginTime, ":");
}
}
}
workPlan.setBeginDate(beginDate); //开始日期
workPlan.setBeginTime(beginTime); //开始时间
//结束时间
String endDate = "", endTime = "";
if (StringUtils.isNotBlank(end)) {
String[] s = StringUtils.split(end, " ");
endDate = s[0];
if (s.length > 1) {
endTime = s[1];
if (endTime.length() == 8) {
endTime = StringUtils.substringBeforeLast(endTime, ":");
}
}
}
workPlan.setEndDate(endDate); //结束日期
workPlan.setEndTime(endTime); //结束时间
//内容
User user = User.getUser(createrId, 0);
String description = SystemEnv.getHtmlLabelName(10000849, Util.getIntValue(user.getLanguage())) + "" + workPlan.getWorkPlanName()
+ " " + SystemEnv.getHtmlLabelName(81901, user.getLanguage()) + "" + workPlan.getBeginDate() + " " + workPlan.getBeginTime()
+ " " + SystemEnv.getHtmlLabelName(525536, user.getLanguage()) + "[亿联] " + mtNum;
workPlan.setDescription(description);
//是否来自外部系统
workPlan.setIsFromOthSystem(false);
if (!"".equals(workPlan.getBeginDate()) && null != workPlan.getBeginDate()) {
List beginDateTimeRemindList = Util.processTimeBySecond(workPlan.getBeginDate(), workPlan.getBeginTime(), workPlan.getRemindTimesBeforeStart() * -1 * 60);
workPlan.setRemindDateBeforeStart((String) beginDateTimeRemindList.get(0)); //开始前提醒日期
workPlan.setRemindTimeBeforeStart((String) beginDateTimeRemindList.get(1)); //开始前提醒时间
}
if (!"".equals(workPlan.getEndDate()) && null != workPlan.getEndDate()) {
List endDateTimeRemindList = Util.processTimeBySecond(workPlan.getEndDate(), workPlan.getEndTime(), workPlan.getRemindTimesBeforeEnd() * -1 * 60);
workPlan.setRemindDateBeforeEnd((String) endDateTimeRemindList.get(0)); //结束前提醒日期
workPlan.setRemindTimeBeforeEnd((String) endDateTimeRemindList.get(1)); //结束前提醒时间
}
//附件
String workPlanType = workPlan.getWorkPlanType() + "";
WorkPlanService workPlanService = new WorkPlanService();
WorkPlanShare workPlanShare = new WorkPlanShare();
if (workPlan.getWorkPlanID() > 0) {
//修改
WorkPlan oldWorkPlan = new WorkPlan();
oldWorkPlan.setWorkPlanID(workPlan.getWorkPlanID());
workPlanService.updateWorkPlan(oldWorkPlan, workPlan);
try {
workPlanShare.setShareDetail(workPlan.getWorkPlanID() + "");
} catch (Exception e) {
logger.writeLog("^^^ YealinkVideoClient.handleWorkPlan : setShareDetail error !!!", e);
}
} else {
//新增
workPlanService.insertWorkPlan(workPlan); //插入日程
try {
workPlanShare.setDefaultShareDetail(user, String.valueOf(workPlan.getWorkPlanID()), workPlanType);//只在新增的时候设置默认共享
} catch (Exception e) {
logger.writeLog("^^^ YealinkVideoClient.handleWorkPlan : setDefaultShareDetail error !!!", e);
}
rs.executeUpdate("update workplan set videomtid=? where id=?", videoMtId, workPlan.getWorkPlanID());
}
} catch (Exception e) {
logger.writeLog("^^^ YealinkVideoClient.handleWorkPlan : 用户[" + createrId + "]日程处理处理失败!", e);
}
}
/**
*
*
* @param videoMtId
*/
private void deleteWorkPlan(String videoMtId) {
RecordSet rs = new RecordSet();
rs.executeQuery("select id from workplan where videomtid=?", videoMtId);
int workPlanId = -1;
if (rs.next()) {
workPlanId = Util.getIntValue(rs.getString(1));
}
if (workPlanId > 0) {
new WorkPlanHandler().delete(workPlanId + "");
}
}
/**
*
*
* @param videoMtId
*/
private void finishWorkPlan(String videoMtId) {
RecordSet rs = new RecordSet();
rs.executeQuery("select id from workplan where videomtid=?", videoMtId);
int workPlanId = -1;
if (rs.next()) {
workPlanId = Util.getIntValue(rs.getString(1));
}
if (workPlanId > 0) {
new WorkPlanHandler().finishWorkPlan(workPlanId + "");
}
}
/**
*
*
* @param rs
* @param workPlan
*/
private void getWorkPlanById(RecordSet rs, WorkPlan workPlan) {
rs.executeQuery("select * from workplan where id=?", workPlan.getWorkPlanID());
rs.next();
workPlan.setWorkPlanType(Util.getIntValue(rs.getString("type_n")));
workPlan.setBeginDate(Util.null2String(rs.getString("begindate")));
workPlan.setBeginTime(Util.null2String(rs.getString("begintime")));
workPlan.setEndDate(Util.null2String(rs.getString("enddate")));
workPlan.setEndTime(Util.null2String(rs.getString("endtime")));
workPlan.setStatus(Util.null2String(rs.getString("status")));
workPlan.setCreaterId(Util.getIntValue(rs.getString("createrid")));
workPlan.setWorkPlanName(Util.null2String(rs.getString("name")));
workPlan.setCreateType(Util.getIntValue(rs.getString("creatertype")));
workPlan.setUrgentLevel(Util.null2String(rs.getString("urgentlevel")));
workPlan.setRemindType(Util.null2String(rs.getString("remindtype")));
workPlan.setRemindTimesBeforeStart(Util.getIntValue(rs.getString("remindtimesbeforestart")));
workPlan.setRemindTimesBeforeEnd(Util.getIntValue(rs.getString("remindtimesbeforeend")));
workPlan.setRemindBeforeStart(Util.null2String(rs.getString("remindbeforestart")));
workPlan.setRemindBeforeEnd(Util.null2String(rs.getString("remindbeforeend")));
workPlan.setRemindDateBeforeStart(Util.null2String(rs.getString("reminddatebeforestart")));
workPlan.setRemindTimeBeforeStart(Util.null2String(rs.getString("remindtimebeforestart")));
workPlan.setRemindDateBeforeEnd(Util.null2String(rs.getString("reminddatebeforeend")));
workPlan.setRemindTimeBeforeEnd(Util.null2String(rs.getString("remindtimebeforeend")));
workPlan.setResourceId(Util.null2String(rs.getString("resourceid")));
workPlan.setUuid(Util.null2String(rs.getString("uuid")));
}
/**
*
*
* @param host
* @param token
* @param mtnum
* @param userId
* @param meetingPassword
* @return
*/
private String getYealinkUrl(String host, String token, String mtnum, String userId, String meetingPassword) {
String url = host + "/meeting-join-links/" + mtnum;
JSONObject body = new JSONObject();
body.put("language", "zh");
body.put("password", meetingPassword);
JSONObject resultJson = YealinkVideoUtil.doGet(url, token, null, body);
return resultJson.getString("joinLink");
}
/**
*
*
* @param host
* @param token
* @param userId
* @param mtId
* @return
*/
private JSONObject getMeetingInfoById(String host, String token, String userId, String mtId) {
String url = host + "/users/" + userId + "/meetings/" + mtId;
JSONObject body = new JSONObject();
body.put("sequence", 1);
return YealinkVideoUtil.doGet(url, token, null, body);
}
}

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>

@ -0,0 +1,90 @@
<%@ page import="weaver.conn.RecordSet" %>
<%@ page import="com.wbi.util.ParamUtil" %>
<%@ page import="java.util.Map" %>
<%@ page import="weaver.general.Util" %>
<%@ page import="java.util.HashMap" %>
<%@ page import="com.alibaba.fastjson.JSONObject" %>
<%@ page language="java" contentType="text/html; charset=UTF-8" %>
<%
Map<String, Object> paramMap = ParamUtil.request2Map(request);
int id = Util.getIntValue(Util.null2String(paramMap.get("id")));
HashMap<String, String> results = new HashMap<>();
int requestId = -1;
int type = -1;
RecordSet rs = new RecordSet();
String sql = "select lcbt , sqdlx ,spwhscpdfwj from uf_CCSPDTZ where id = ?";
rs.executeQuery(sql, id);
if (rs.next()) {
requestId = rs.getInt("lcbt");
type = rs.getInt("sqdlx");
} else {
results.put("code", "0");
results.put("msg", "审批单无数据");
out.print(JSONObject.toJSONString(results));
}
//请休审批单PDF附件qxspdpdffj中。
String qxspdpdffj = "";
//天津银行国内出差审批单附件PDFtjyxgnccspdfjpdf
String tjyxgnccspdfjpdf = "";
if (6 == type || 7 == type) {
// 总行差旅行程变更审批单 || 分行差旅行程变更审批单
rs.executeQuery("select mainid from uf_CCBGJLB_dt1 where ccbgjllc = ?",requestId);
rs.next();
String mainid = rs.getString("mainid");
rs.executeQuery("select ccqqlc from uf_CCBGJLB where id = ?",mainid);
rs.next();
String ccqqlc = rs.getString("ccqqlc");
rs.executeQuery("select sqdlx , spwhscpdfwj from uf_CCSPDTZ where lcbt = ?",ccqqlc);
rs.next();
int sqdlx = rs.getInt("sqdlx");
if(0 == sqdlx){
//请休假审批单-总行部门正职
qxspdpdffj = Util.null2String(rs.getString("spwhscpdfwj"));
}else if( 2 == sqdlx){
//请休假审批单-分行行长
tjyxgnccspdfjpdf = Util.null2String(rs.getString("spwhscpdfwj"));
rs.executeQuery("select qxspdpdffj from formtable_main_442 where requestid = ?",ccqqlc);
rs.next();
qxspdpdffj = Util.null2String(rs.getString("qxspdpdffj"));
}
}else if( 8 == type ){
tjyxgnccspdfjpdf = Util.null2String(rs.getString("spwhscpdfwj"));
rs.executeQuery("select qxspdpdffj from formtable_main_442 where requestid = ?",requestId);
rs.next();
qxspdpdffj = Util.null2String(rs.getString("qxspdpdffj"));
}
out.print(tjyxgnccspdfjpdf);
out.print("<br/>");
out.print(qxspdpdffj);
%>
<%!
private boolean isEmpty(String str) {
if ("".equals(str) || "(null)".equals(str) || str == null) {
return true;
} else {
return false;
}
}
private int getwfid(int requestId, RecordSet rs) {
if (requestId <= 0) {
return -1;
}
String sql = "select WORKFLOWID from WORKFLOW_REQUESTBASE where REQUESTID = ?";
rs.executeQuery(sql, requestId);
if (rs.next()) {
return rs.getInt(0);
} else {
return -1;
}
}
%>

@ -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…
Cancel
Save