diff --git a/com/cloudstore/eccom/MessageReceiveTest.java b/com/cloudstore/eccom/MessageReceiveTest.java new file mode 100644 index 0000000..1795519 --- /dev/null +++ b/com/cloudstore/eccom/MessageReceiveTest.java @@ -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 map) { + log.error("setProp:{}",map); + bean.writeLog("setProp:{}"+map); + } + + @Override + public void setList(List list) { + log.error("setList:{}", JSONObject.toJSONString(list)); + bean.writeLog("setList:{}"+ JSONObject.toJSONString(list)); + } +} diff --git a/com/engine/custom/archives/action/WorkflowToDocCus.java b/com/engine/custom/archives/action/WorkflowToDocCus.java index e99234f..89b6479 100644 --- a/com/engine/custom/archives/action/WorkflowToDocCus.java +++ b/com/engine/custom/archives/action/WorkflowToDocCus.java @@ -73,7 +73,7 @@ public class WorkflowToDocCus { private String aescode=""; //底部签字意见列表显示数量 - private int pageSize =100; + private int pageSize =99999; public static Class class_MultiLangFilter; static { @@ -184,7 +184,7 @@ public class WorkflowToDocCus { //离线html/pdf WfToDocBizCus wfToDocBiz = new WfToDocBizCus(user,pageSize,keepsign,docfiles,modeid,isOpenWaterMark); 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)); //保存 List docids = saveDocDetail(requestname, workflowid, requestid, wfdocpath, userid, fileids, requestManager, wfbiz); @@ -210,7 +210,7 @@ public class WorkflowToDocCus { //离线html/pdf WfToDocBizCus wfToDocBiz = new WfToDocBizCus(user,pageSize,keepsign,docfiles,modeid,isOpenWaterMark); 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)); //保存 saveDocDetail(requestname, workflowid,requestid, wfdocpath,userid,fileids,requestManager,wfbiz); diff --git a/com/engine/custom/archives/corn/PushArchivesCorn.java b/com/engine/custom/archives/corn/PushArchivesCorn.java index 458b91a..db43df7 100644 --- a/com/engine/custom/archives/corn/PushArchivesCorn.java +++ b/com/engine/custom/archives/corn/PushArchivesCorn.java @@ -3,10 +3,16 @@ 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.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 lombok.extern.slf4j.Slf4j; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import weaver.general.Util; import weaver.interfaces.schedule.BaseCronJob; @@ -25,6 +31,7 @@ public class PushArchivesCorn 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 endTime = "7"; public String reqid = ""; public static Logger log = LoggerFactory.getLogger("Archives"); @@ -32,6 +39,12 @@ public class PushArchivesCorn extends BaseCronJob { SendingPushArchivesService sendingservice = new SendingPushArchivesService(); 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 public void execute() { log.info("PushArchivesCorn====Begin========"); @@ -40,14 +53,24 @@ public class PushArchivesCorn extends BaseCronJob { HashMap param = new HashMap<>(); param.put("filePath",filePath+ File.separator+dateStr); param.put("Url",Url); - param.put("requestid",reqid); + param.put("endTime", endTime); + // param.put("requestid",reqid); param.put("templatePath",templatePath); - // receivingservice.setProp(param); - // receivingservice.pushArchives(param); sendingservice.setProp(param); sendingservice.pushArchives(param); signReportservice.setProp(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); } } diff --git a/com/engine/custom/archives/corn/PushArchivesCornMultiThread.java b/com/engine/custom/archives/corn/PushArchivesCornMultiThread.java new file mode 100644 index 0000000..3a7c206 --- /dev/null +++ b/com/engine/custom/archives/corn/PushArchivesCornMultiThread.java @@ -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 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); + })); + + } +} diff --git a/com/engine/custom/archives/service/ReceivingPushArchivesService.java b/com/engine/custom/archives/service/ReceivingPushArchivesService.java index 6309e30..e509353 100644 --- a/com/engine/custom/archives/service/ReceivingPushArchivesService.java +++ b/com/engine/custom/archives/service/ReceivingPushArchivesService.java @@ -2,18 +2,15 @@ package com.engine.custom.archives.service; import com.dcfs.fts.common.error.FtpException; +import com.engine.custom.archives.entity.PushArchivesBean; import com.engine.custom.archives.util.ArchivesUtil; import com.engine.custom.hg.util.HgUtils; -import com.icbc.api.internal.apache.http.impl.cookie.S; -import lombok.extern.slf4j.Slf4j; -import java.text.ParseException; import java.text.SimpleDateFormat; import java.time.LocalDate; import java.time.format.DateTimeFormatter; import java.util.Calendar; import java.util.Date; -import java.nio.charset.StandardCharsets; import java.io.*; import java.util.*; @@ -26,36 +23,13 @@ import weaver.general.Util; import com.alibaba.fastjson.JSONObject; import weaver.file.ImageFileManager; -import java.net.URL; - -import org.apache.commons.io.FileUtils; -import okhttp3.*; - -import java.net.URLEncoder; - +import weaver.hrm.company.DepartmentComInfo; import weaver.soa.workflow.request.RequestService; import weaver.soa.workflow.request.RequestInfo; -import com.engine.custom.archives.action.WorkflowToDocCus; -import weaver.docs.docs.DocRecycleManager; import weaver.hrm.User; -import com.api.workflow.service.RequestAuthenticationService; -import weaver.workflow.workflow.WorkflowConfigComInfo; -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 weaver.workflow.workflow.WorkflowBillComInfo; +import weaver.workflow.workflow.WorkflowComInfo; 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 { @@ -68,6 +42,13 @@ public class ReceivingPushArchivesService { 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 = "文件流转信息"; + private int endTime= 7; + public static Logger log = LoggerFactory.getLogger("Archives"); @@ -75,13 +56,13 @@ public class ReceivingPushArchivesService { 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 param) { log.info("PushArchivesCorn====Begin========{}", param); try { - ZipUtil zipUtil = new ZipUtil(); Date date = ArchivesUtil.getDate(); SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd"); @@ -92,23 +73,41 @@ public class ReceivingPushArchivesService { // 获取当前时间的最后一秒 String lastSecond = yyyyMMddHHmmss.format(getLastSecondOfDate(date)); - Integer requestid = Util.getIntValue(param.get("requestid")); - log.error("requestid:{}", requestid); - String context = extracted(requestid); - log.error("context:{}", context); + RecordSet recordSet = new RecordSet(); + List 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()); - 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); - log.error("textZip:{}", s); + 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(); @@ -123,17 +122,36 @@ public class ReceivingPushArchivesService { } 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 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 signFiles = ArchivesUtil.getSignFiles(requestid,true); List docids = new ArrayList<>(); // docids.addAll(Arrays.asList(fj.split(","))); // docids.addAll(Arrays.asList(zwkbj.split(","))); Map fjMap = ArchivesUtil.getFileIdByDocId(fj); - Map zwkbjMap = ArchivesUtil.getFileIdByDocId(zwkbj); + + // Map zwkbjMap = ArchivesUtil.getFileIdByDocId(zwkbj); + // Map lczwMap = ArchivesUtil.getFileIdByDocId(lczw); + Map lczwMap = new HashMap<>(); + //判断公文来源 + if ("0".equals(gwly)){ + lczwMap = ArchivesUtil.getFileIdByDocId(lczw); + }else { + lczwMap = ArchivesUtil.getFileIdByDocId(zwkbj); + } + + + + List zwFileName = new ArrayList<>(); List fjFileName = new ArrayList<>(); final int[] i = {1}; @@ -143,8 +161,8 @@ public class ReceivingPushArchivesService { imageFileManager.getImageFileInfoById(Util.getIntValue(imageid)); InputStream inputStream = imageFileManager.getInputStream(); //中文路径/中文文件名 - String imageFileName = filePath + File.separator + requestid + File.separator + fjdir + File.separator + imageFileManager.getImageFileName(); - fjFileName.add(imageFileManager.getImageFileName()); + String imageFileName = filePath + File.separator + newRequestid + File.separator + fjdir + File.separator + lcfjWord+ i[0] +"-" + (imageFileManager.getImageFileName().replaceAll("/","-")); + fjFileName.add(lcfjWord+ i[0] +"-" + imageFileManager.getImageFileName().replaceAll("/","-")); log.info("生成附件路径:{}", imageFileName); imageFileName = ArchivesUtil.codeUtf8(imageFileName); try { @@ -157,21 +175,30 @@ public class ReceivingPushArchivesService { JSONObject data = result.getJSONObject("data"); String destFileName = data.getString("destFileName"); 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) { 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 + requestid + File.separator + fjdir + File.separator + imageFileManager.getImageFileName(); - fjFileName.add(imageFileManager.getImageFileName()); + 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 { @@ -184,21 +211,107 @@ public class ReceivingPushArchivesService { JSONObject data = result.getJSONObject("data"); String destFileName = data.getString("destFileName"); 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) { e.printStackTrace(); + }finally { + if(inputStream!=null) { + try { + inputStream.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } } + }); + i[0] = 1; + Map 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.getImageFileInfoById(Util.getIntValue(imageid)); InputStream inputStream = imageFileManager.getInputStream(); 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); imageFileName = ArchivesUtil.codeUtf8(imageFileName); try { @@ -211,10 +324,19 @@ public class ReceivingPushArchivesService { 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 + imageFileManager.getImageFileName() + ".pdf"); + 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(); + } + } } }); //开始承办单 先获取主流程的承办单 @@ -229,13 +351,15 @@ public class ReceivingPushArchivesService { 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 + 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 { @@ -248,11 +372,19 @@ public class ReceivingPushArchivesService { JSONObject data = result.getJSONObject("data"); String destFileName = data.getString("destFileName"); 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]++; } catch (IOException e) { e.printStackTrace(); + }finally { + if(inputStream!=null) { + try { + inputStream.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } } }); //正文 @@ -291,10 +423,9 @@ public class ReceivingPushArchivesService { 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)); log.error(s); JSONObject result = JSONObject.parseObject(s); @@ -305,16 +436,19 @@ public class ReceivingPushArchivesService { String viewUrl = data.getString("viewUrl"); ArchivesUtil.downloadFile(viewUrl, logFile + ".pdf"); } - String zipName = filePath + File.separator + requestid + ".zip"; - ZipUtil.zip(filePath + File.separator + requestid, zipName); + String zipName = filePath + File.separator + newRequestid + ".zip"; + ZipUtil.zip(filePath + File.separator + newRequestid, 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); - String ftpFilePathNew = HgUtils.putFile(zipName, "test" + File.separator + requestid + ".zip"); - log.error("ftpFilePathNew:{}", ftpFilePathNew); - String context = getContext(requestid, requesData, requestid + ".zip", zwFileName, fjFileName); - insertRecord(requestid, context, 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; } @@ -392,6 +526,9 @@ public class ReceivingPushArchivesService { 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()) { @@ -405,18 +542,19 @@ public class ReceivingPushArchivesService { StringBuilder context = new StringBuilder(); try { - String swrq = Util.null2String(requesData.get("swrq")); + String swrq = Util.null2String(requesData.get("lwrq")); 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("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("lwdwmc")); //5 责任者 -> 来文单位 + String lwdwmc = Util.null2String(requesData.get("lwdwsx")); //5 责任者 -> 来文单位 context.append(lwdwmc).append("|"); String bgqx = Util.null2String(requesData.get("bgqx")); //6 保管期限 -> 保管期限 context.append(bgqx).append("|"); @@ -428,8 +566,10 @@ public class ReceivingPushArchivesService { context.append(wz).append("|"); String ngbm = Util.null2String(requesData.get("ngbm")); String[] deptData = ArchivesUtil.getDeptNameAndCode(ngbm); - context.append(deptData[0]).append("|"); //10 行编号 -> 拟稿部门 - context.append(deptData[1]).append("|"); //11 行名称 + 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 是否开放 @@ -439,7 +579,8 @@ public class ReceivingPushArchivesService { //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("lwh"));// 18 收文号 -> 来文文号 + String lwh = Util.null2String(requesData.get("swh"));// 18 收文号 -> 来文文号 context.append(lwh).append("|"); String fs = ""; context.append(fs).append("|"); // 19 份数 -> 份数 @@ -463,7 +604,7 @@ public class ReceivingPushArchivesService { context.append(year).append("|"); // 30 形成年度 -> 年份 context.append(String.join("&&", zwFileName)).append("|"); // 31 正文名称 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("|"); // 35 被关联主键 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("ffbmb")).split(","))); records.addAll(Arrays.asList(Util.null2String(requesData.get("zfbm")).split(","))); - return String.join("&&", records); + ArrayList 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 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 CoSubRequest = new ArrayList<>(); + Map subRequest = ArchivesUtil.getSubRequest(Util.null2String(requestid) , 6); + log.info("subRequest:{}",subRequest); + for (Map.Entry 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 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); + } } diff --git a/com/engine/custom/archives/service/SendingPushArchivesService.java b/com/engine/custom/archives/service/SendingPushArchivesService.java index 34f7c80..473a5c2 100644 --- a/com/engine/custom/archives/service/SendingPushArchivesService.java +++ b/com/engine/custom/archives/service/SendingPushArchivesService.java @@ -33,6 +33,7 @@ public class SendingPushArchivesService { private static String filePath; private static String Url; private static String templatePath; // 模板文件路径 + private int endTime= 7; private static final String zwdir = "正文"; private static final String fjdir = "附件"; private static final String cbddir = "承办单"; @@ -51,6 +52,7 @@ public class SendingPushArchivesService { 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 param) { @@ -69,11 +71,18 @@ public class SendingPushArchivesService { File file = ArchivesUtil.crFile(filePath + "/togd_" + new SimpleDateFormat("yyyyMMdd000000").format(date)); log.error("textfile:{}", file.getAbsolutePath()); for (PushArchivesBean pushArchivesBean : result) { - int id = pushArchivesBean.getId(); + 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()); @@ -82,12 +91,18 @@ public class SendingPushArchivesService { 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) { 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()); } } @@ -96,7 +111,12 @@ public class SendingPushArchivesService { private String generateFile(int requestid) throws FtpException, IOException { Map 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")); @@ -123,8 +143,8 @@ public class SendingPushArchivesService { imageFileManager.getImageFileInfoById(Util.getIntValue(imageid)); InputStream inputStream = imageFileManager.getInputStream(); //中文路径/中文文件名 - String imageFileName = filePath + File.separator + requestid + File.separator + fjdir + File.separator + lcfjWord + "-" +imageFileManager.getImageFileName(); - fjFileName.add(imageFileManager.getImageFileName()); + 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 { @@ -137,10 +157,18 @@ public class SendingPushArchivesService { JSONObject data = result.getJSONObject("data"); String destFileName = data.getString("destFileName"); 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) { 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)); InputStream inputStream = imageFileManager.getInputStream(); //中文路径/中文文件名 - String imageFileName = filePath + File.separator + requestid + File.separator + fjdir + File.separator + qzyjfjWord+ "-" +imageFileManager.getImageFileName(); - fjFileName.add(imageFileManager.getImageFileName()); + 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 { @@ -164,10 +192,18 @@ public class SendingPushArchivesService { JSONObject data = result.getJSONObject("data"); String destFileName = data.getString("destFileName"); 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) { 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)); 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); log.info("生成正文路径:{}", imageFileName); imageFileName = ArchivesUtil.codeUtf8(imageFileName); @@ -220,10 +256,18 @@ public class SendingPushArchivesService { 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 + newFile + ".pdf"); + 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]++; }); @@ -233,10 +277,10 @@ public class SendingPushArchivesService { imageFileManager.getImageFileInfoById(Util.getIntValue(imageid)); InputStream inputStream = imageFileManager.getInputStream(); - String newFile = fjWord + i[0] + "_" + lhgWord + "-" + imageFileManager.getImageFileName(); + String newFile = fjWord + i[0] + "_" + lhgWord + "-" + (imageFileManager.getImageFileName().replaceAll("/","-")); 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); imageFileName = ArchivesUtil.codeUtf8(imageFileName); try { @@ -249,10 +293,18 @@ public class SendingPushArchivesService { 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 + newFile + ".pdf"); + 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]++; }); @@ -304,7 +356,8 @@ public class SendingPushArchivesService { 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] + "_" + 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); imageFileName = ArchivesUtil.codeUtf8(imageFileName); try { @@ -317,11 +370,19 @@ public class SendingPushArchivesService { JSONObject data = result.getJSONObject("data"); String destFileName = data.getString("destFileName"); 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]++; } catch (IOException e) { 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"); ArchivesUtil.downloadFile(viewUrl, logFile + ".pdf"); } - String zipName = filePath + File.separator + requestid + ".zip"; - ZipUtil.zip(filePath + File.separator + requestid, zipName); + String zipName = filePath + File.separator + newRequestid + ".zip"; + ZipUtil.zip(filePath + File.separator + newRequestid, zipName); log.error("zipName:{}", zipName); - String ftpFilePath = HgUtils.putFile(zipName, requestid + ".zip"); + 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, requestid + ".zip", zwFileName, fjFileName); + String context = getContext(requestid, requesData, newRequestid + ".zip", zwFileName, fjFileName); // insertRecord(requestid, context, ftpFilePath); + updateRecord(requestid,"content",context); log.error("context:{}", context); return context; } @@ -430,8 +494,10 @@ public class SendingPushArchivesService { context.append(wz).append("|"); String ngbm = Util.null2String(requesData.get("ngbm")); String[] deptData = ArchivesUtil.getDeptNameAndCode(ngbm); - context.append(deptData[0]).append("|"); //10 行编号 -> 拟稿部门 - context.append(deptData[1]).append("|"); //11 行名称 + 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 是否开放 @@ -465,7 +531,7 @@ public class SendingPushArchivesService { context.append(year).append("|"); // 30 形成年度 -> 年份 context.append(String.join("&&", zwFileName)).append("|"); // 31 正文名称 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("|"); // 35 被关联主键 context.append(zipName);// 36 压缩包名称 @@ -478,6 +544,8 @@ public class SendingPushArchivesService { } + + private String getAssociatedDepts(Map requesData) { HashSet records = new HashSet<>(); records.addAll(Arrays.asList(Util.null2String(requesData.get("hqbm")).split(","))); // 会签部门 @@ -494,7 +562,10 @@ public class SendingPushArchivesService { DepartmentComInfo departmentComInfo = new DepartmentComInfo(); for (String record : records) { try { - String departmentName = departmentComInfo.getDepartmentName(record); + if (StringUtil.isEmpty(record)){ + continue; + } + String departmentName = departmentComInfo.getDepartmentmark(record); deptName.add(departmentName); } catch (Exception e) { e.printStackTrace(); @@ -504,10 +575,10 @@ public class SendingPushArchivesService { return String.join("&&", deptName); } - private void updateRecord(int requestid, String s) { - String sql = "update uf_pushArchivesLog set esbtxtml = ? where request = ?"; + 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, s, requestid); + recordSet.executeUpdate(sql, fieldvalue, requestid); } diff --git a/com/engine/custom/archives/service/SignReportPushArchivesService.java b/com/engine/custom/archives/service/SignReportPushArchivesService.java index 107f6a3..a0235a4 100644 --- a/com/engine/custom/archives/service/SignReportPushArchivesService.java +++ b/com/engine/custom/archives/service/SignReportPushArchivesService.java @@ -10,6 +10,7 @@ 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; @@ -40,11 +41,13 @@ public class SignReportPushArchivesService { private static final String qzyjfjWord = "签字意见附件"; private static final String wjcldWord = "文件处理单"; private static final String wjlzxxWord = "文件流转信息"; + private int endTime= 7; public void setProp(Map 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 param) { @@ -63,11 +66,18 @@ public class SignReportPushArchivesService { 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()); @@ -77,10 +87,18 @@ public class SignReportPushArchivesService { 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(); } } @@ -90,11 +108,19 @@ public class SignReportPushArchivesService { private String generateFile(int requestid) throws FtpException, IOException { Map 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 signFiles = ArchivesUtil.getSignFiles(requestid,true); @@ -113,7 +139,7 @@ public class SignReportPushArchivesService { imageFileManager.getImageFileInfoById(Util.getIntValue(imageid)); 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()); log.info("生成附件路径:{}", imageFileName); imageFileName = ArchivesUtil.codeUtf8(imageFileName); @@ -127,10 +153,18 @@ public class SignReportPushArchivesService { JSONObject data = result.getJSONObject("data"); String destFileName = data.getString("destFileName"); 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) { 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)); 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()); log.info("生成签字意见附件路径:{}", imageFileName); imageFileName = ArchivesUtil.codeUtf8(imageFileName); @@ -154,10 +188,18 @@ public class SignReportPushArchivesService { JSONObject data = result.getJSONObject("data"); String destFileName = data.getString("destFileName"); 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) { 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)); 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); log.info("生成正文路径:{}", imageFileName); imageFileName = ArchivesUtil.codeUtf8(imageFileName); @@ -184,10 +226,18 @@ public class SignReportPushArchivesService { 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 + newFile + ".pdf"); + 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]++; }); @@ -197,10 +247,10 @@ public class SignReportPushArchivesService { imageFileManager.getImageFileInfoById(Util.getIntValue(imageid)); InputStream inputStream = imageFileManager.getInputStream(); - String newFile = fjWord + i[0] + "_" + lhgWord + "-" + imageFileManager.getImageFileName(); + String newFile = fjWord + i[0] + "_" + lhgWord + "-" + (imageFileManager.getImageFileName().replaceAll("/","-")); 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); imageFileName = ArchivesUtil.codeUtf8(imageFileName); try { @@ -213,10 +263,18 @@ public class SignReportPushArchivesService { 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 + newFile + ".pdf"); + 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]++; }); @@ -268,7 +326,8 @@ public class SignReportPushArchivesService { 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] + "_" + 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); imageFileName = ArchivesUtil.codeUtf8(imageFileName); try { @@ -281,11 +340,20 @@ public class SignReportPushArchivesService { JSONObject data = result.getJSONObject("data"); String destFileName = data.getString("destFileName"); 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]++; } catch (IOException e) { 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"); ArchivesUtil.downloadFile(viewUrl, logFile + ".pdf"); } - String zipName = filePath + File.separator + requestid + ".zip"; - ZipUtil.zip(filePath + File.separator + requestid, zipName); + String zipName = filePath + File.separator + newRequestid + ".zip"; + ZipUtil.zip(filePath + File.separator + newRequestid, zipName); log.error("zipName:{}", zipName); - String ftpFilePath = HgUtils.putFile(zipName, requestid + ".zip"); + 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, requestid + ".zip", zwFileName, fjFileName); + String context = getContext(requestid, requesData, newRequestid + ".zip", zwFileName, fjFileName); // insertRecord(requestid, context, ftpFilePath); + updateRecord(requestid,"content",context); log.error("context:{}", context); return context; } @@ -338,7 +410,8 @@ public class SignReportPushArchivesService { rs.executeQuery(sql, requestid); if (rs.next()) { 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("ngrq", Util.null2String(rs.getString("ngrq"))); record.put("lxfs", Util.null2String(rs.getString("lxfs"))); @@ -374,7 +447,7 @@ public class SignReportPushArchivesService { 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.文号 -> 编号 + String bh = Util.null2String(requesData.get("bhnew"));// 3.文号 -> 编号 context.append(bh).append("|"); String requestname = Util.null2String(requesData.get("REQUESTNAME")); // 4.文件题名 -> 流程名称 context.append(requestname).append("|"); @@ -382,16 +455,18 @@ public class SignReportPushArchivesService { 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 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); - context.append(deptData[0]).append("|"); //10 行编号 -> 拟稿部门 - context.append(deptData[1]).append("|"); //11 行名称 + 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 是否开放 @@ -412,20 +487,20 @@ public class SignReportPushArchivesService { String wjlx = Util.null2String(requesData.get("wjlx")); context.append("").append("|"); // 22 文件类型 -> 空 String fwlx = Util.null2String(requesData.get("fwlx")); - context.append("总行发文").append("|"); // 23 发文类型 -> 空 + 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 公文类型 -> "收文" + 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(requestid).append("|"); // 33 主键 + context.append("togd"+requestid).append("|"); // 33 主键 context.append("").append("|"); // 34 关联主键 context.append("").append("|"); // 35 被关联主键 context.append(zipName);// 36 压缩包名称 @@ -448,7 +523,10 @@ public class SignReportPushArchivesService { DepartmentComInfo departmentComInfo = new DepartmentComInfo(); for (String record : records) { try { - String departmentName = departmentComInfo.getDepartmentName(record); + if (StringUtil.isEmpty(record)){ + continue; + } + String departmentName = departmentComInfo.getDepartmentmark(record); deptName.add(departmentName); } catch (Exception e) { e.printStackTrace(); @@ -463,4 +541,9 @@ public class SignReportPushArchivesService { 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); + } } diff --git a/com/engine/custom/archives/service/firstBranch/FirstBranchReceivingPushArchivesService.java b/com/engine/custom/archives/service/firstBranch/FirstBranchReceivingPushArchivesService.java new file mode 100644 index 0000000..2ef9245 --- /dev/null +++ b/com/engine/custom/archives/service/firstBranch/FirstBranchReceivingPushArchivesService.java @@ -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 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 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 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 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 signFiles = ArchivesUtil.getSignFiles(requestid,false); + List docids = new ArrayList<>(); + // docids.addAll(Arrays.asList(fj.split(","))); + // docids.addAll(Arrays.asList(zwkbj.split(","))); + Map fjMap = ArchivesUtil.getFileIdByDocId(fj); + + // Map zwkbjMap = ArchivesUtil.getFileIdByDocId(zwkbj); + // Map lczwMap = ArchivesUtil.getFileIdByDocId(lczw); + Map lczwMap = new HashMap<>(); + //判断公文来源 + if ("0".equals(gwly)){ + lczwMap = ArchivesUtil.getFileIdByDocId(lczw); + }else { + lczwMap = ArchivesUtil.getFileIdByDocId(zwkbj); + } + + + + + List zwFileName = new ArrayList<>(); + List 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 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 requestDocid = ArchivesUtil.generaRequestFormPdf(requestid,0); + // 1.去掉生成子流程承办单 + // List subRequestDocid = generaSubRequestFormPdf(requestid); + Map reqDocMap = ArchivesUtil.getFileIdByDocId(String.join(",", requestDocid)); + // 2.去掉生成子流程承办单 + // Map 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 getRequestByid(int requestid) { + HashMap 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 requesData, String zipName, List zwFileName, List 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 requesData) { + HashSet 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 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 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 CoSubRequest = new ArrayList<>(); + Map subRequest = ArchivesUtil.getSubRequest(Util.null2String(requestid) , 6); + log.info("subRequest:{}",subRequest); + for (Map.Entry 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 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}; + } +} diff --git a/com/engine/custom/archives/service/firstBranch/FirstBranchSendingPushArchivesService.java b/com/engine/custom/archives/service/firstBranch/FirstBranchSendingPushArchivesService.java new file mode 100644 index 0000000..50d1e25 --- /dev/null +++ b/com/engine/custom/archives/service/firstBranch/FirstBranchSendingPushArchivesService.java @@ -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 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 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 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 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 signFiles = ArchivesUtil.getSignFiles(requestid,false); + List docids = new ArrayList<>(); + // docids.addAll(Arrays.asList(fj.split(","))); + // docids.addAll(Arrays.asList(zwkbj.split(","))); + Map fjMap = ArchivesUtil.getFileIdByDocId(fj); + Map dwdMap = ArchivesUtil.getFileIdByDocId(dwd); + Map zwMap = ArchivesUtil.getFileIdByDocId(zw); + Map qgqhjMap = ArchivesUtil.getFileIdByDocId(qgqhj); + Map thhlhMap = ArchivesUtil.getFileIdByDocId(thhlh); + List zwFileName = new ArrayList<>(); + List 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 requestDocid = ArchivesUtil.generaRequestFormPdf(requestid, 0); + // 1.去掉生成子流程承办单 + // List subRequestDocid = generaSubRequestFormPdf(requestid); + Map reqDocMap = ArchivesUtil.getFileIdByDocId(String.join(",", requestDocid)); + // 2.去掉生成子流程承办单 + // Map 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 getRequestByid(int requestid) { + HashMap 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 requesData, String zipName, List zwFileName, List 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 requesData) { + HashSet 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 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); + } + + +} diff --git a/com/engine/custom/archives/service/firstBranch/FirstBranchSignReportPushArchivesService.java b/com/engine/custom/archives/service/firstBranch/FirstBranchSignReportPushArchivesService.java new file mode 100644 index 0000000..56a8d2b --- /dev/null +++ b/com/engine/custom/archives/service/firstBranch/FirstBranchSignReportPushArchivesService.java @@ -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 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 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 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 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 signFiles = ArchivesUtil.getSignFiles(requestid,true); + List docids = new ArrayList<>(); + // docids.addAll(Arrays.asList(fj.split(","))); + // docids.addAll(Arrays.asList(zwkbj.split(","))); + Map fjMap = ArchivesUtil.getFileIdByDocId(fj); + Map zwMap = ArchivesUtil.getFileIdByDocId(zw); + Map qgqhjMap = ArchivesUtil.getFileIdByDocId(qgqhj); + List zwFileName = new ArrayList<>(); + List 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 requestDocid = ArchivesUtil.generaRequestFormPdf(requestid, 0); + // 1.去掉生成子流程承办单 + // List subRequestDocid = generaSubRequestFormPdf(requestid); + Map reqDocMap = ArchivesUtil.getFileIdByDocId(String.join(",", requestDocid)); + // 2.去掉生成子流程承办单 + // Map 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 getRequestByid(int requestid) { + HashMap 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 requesData, String zipName, List zwFileName, List 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 requesData) { + HashSet 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 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 \ No newline at end of file diff --git a/com/engine/custom/archives/service/impl/HtmlToPdfServiceCusImpl.java b/com/engine/custom/archives/service/impl/HtmlToPdfServiceCusImpl.java index 0dadc36..56f7c49 100644 --- a/com/engine/custom/archives/service/impl/HtmlToPdfServiceCusImpl.java +++ b/com/engine/custom/archives/service/impl/HtmlToPdfServiceCusImpl.java @@ -4,10 +4,12 @@ import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.engine.core.impl.Service; 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.workflow.biz.RequestLogBiz; import com.engine.workflow.biz.requestForm.LayoutInfoBiz; import com.engine.workflow.cmd.requestForm.*; +import com.engine.workflow.entity.requestForm.FieldValueBean; import com.engine.workflow.entity.requestForm.TableInfo; import org.apache.commons.lang.StringUtils; @@ -17,14 +19,14 @@ import weaver.conn.RecordSet; import weaver.general.BaseBean; import weaver.general.Util; import weaver.hrm.User; +import weaver.hrm.company.DepartmentComInfo; import weaver.workflow.request.RequestManagerForTipsinfo; import weaver.workflow.request.WFLinkInfo; +import weaver.workflow.workflow.WorkflowBillComInfo; +import weaver.workflow.workflow.WorkflowComInfo; import javax.servlet.http.HttpServletRequest; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; public class HtmlToPdfServiceCusImpl extends Service implements HtmlToPdfServiceCus { public static Logger log = LoggerFactory.getLogger("Archives"); @@ -39,6 +41,7 @@ public class HtmlToPdfServiceCusImpl extends Service implements HtmlToPdfService Map result =new HashMap(); String requestid = Util.null2String(reqpParams.get("requestid")); String modeid = Util.null2String(reqpParams.get("modeid")); + String workflowid = Util.null2String(reqpParams.get("workflowid")); //只需要转换html int onlyHtml = Util.getIntValue(Util.null2String(reqpParams.get("onlyHtml")),0); //用wktohtml转换 @@ -92,6 +95,105 @@ public class HtmlToPdfServiceCusImpl extends Service implements HtmlToPdfService Map maindata = commandExecutor.execute(new FormDataCmd(requestMap, user, params, (Map) forminfo.get("tableInfo"))); 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 CoSubRequest = new ArrayList<>(); + List Cowfids = Arrays.asList(cowfid.split(",")); + Map subRequest = ArchivesUtil.getSubRequest(requestid, 6); + log.info("subRequest:{}",subRequest); + for (Map.Entry 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 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 tableinfomap = (Map)forminfo.get("tableInfo"); List detailmark = new ArrayList (); @@ -150,7 +252,7 @@ public class HtmlToPdfServiceCusImpl extends Service implements HtmlToPdfService } //获取签字意见 HttpServletRequest request = null; - int workflowid = (int) params.get("workflowid"); + // int workflowid = (int) params.get("workflowid"); int nodeid =(int) params.get("nodeid"); String isFormSignature = ""; 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; BaseBean baseBean = new BaseBean(); log.error("loadform接口+底部签字意见+detail耗时:"+end2); + log.error("apidata"+JSONObject.toJSONString(apidatas)); //是否开启水印 apidatas.put("isOpenWaterMark",reqpParams.get("isOpenWaterMark")); diff --git a/com/engine/custom/archives/service/secondBranch/SecondBranchReceivingPushArchivesService.java b/com/engine/custom/archives/service/secondBranch/SecondBranchReceivingPushArchivesService.java new file mode 100644 index 0000000..f05b285 --- /dev/null +++ b/com/engine/custom/archives/service/secondBranch/SecondBranchReceivingPushArchivesService.java @@ -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 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 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 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 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 signFiles = ArchivesUtil.getSignFiles(requestid,false); + List docids = new ArrayList<>(); + // docids.addAll(Arrays.asList(fj.split(","))); + // docids.addAll(Arrays.asList(zwkbj.split(","))); + Map fjMap = ArchivesUtil.getFileIdByDocId(fj); + + // Map zwkbjMap = ArchivesUtil.getFileIdByDocId(zwkbj); + // Map lczwMap = ArchivesUtil.getFileIdByDocId(lczw); + Map lczwMap = new HashMap<>(); + //判断公文来源 + if ("0".equals(gwly)){ + lczwMap = ArchivesUtil.getFileIdByDocId(lczw); + }else { + lczwMap = ArchivesUtil.getFileIdByDocId(zwkbj); + } + + + + + List zwFileName = new ArrayList<>(); + List 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 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 requestDocid = ArchivesUtil.generaRequestFormPdf(requestid,0); + // 1.去掉生成子流程承办单 + // List subRequestDocid = generaSubRequestFormPdf(requestid); + Map reqDocMap = ArchivesUtil.getFileIdByDocId(String.join(",", requestDocid)); + // 2.去掉生成子流程承办单 + // Map 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 getRequestByid(int requestid) { + HashMap 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 requesData, String zipName, List zwFileName, List 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 requesData) { + HashSet 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 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 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 CoSubRequest = new ArrayList<>(); + Map subRequest = ArchivesUtil.getSubRequest(Util.null2String(requestid) , 6); + log.info("subRequest:{}",subRequest); + for (Map.Entry 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 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}; + } +} diff --git a/com/engine/custom/archives/service/secondBranch/SecondBranchSendingPushArchivesService.java b/com/engine/custom/archives/service/secondBranch/SecondBranchSendingPushArchivesService.java new file mode 100644 index 0000000..6285560 --- /dev/null +++ b/com/engine/custom/archives/service/secondBranch/SecondBranchSendingPushArchivesService.java @@ -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 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 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 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 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 signFiles = ArchivesUtil.getSignFiles(requestid,false); + List docids = new ArrayList<>(); + // docids.addAll(Arrays.asList(fj.split(","))); + // docids.addAll(Arrays.asList(zwkbj.split(","))); + Map fjMap = ArchivesUtil.getFileIdByDocId(fj); + Map dwdMap = ArchivesUtil.getFileIdByDocId(dwd); + Map zwMap = ArchivesUtil.getFileIdByDocId(zw); + Map qgqhjMap = ArchivesUtil.getFileIdByDocId(qgqhj); + Map thhlhMap = ArchivesUtil.getFileIdByDocId(thhlh); + List zwFileName = new ArrayList<>(); + List 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 requestDocid = ArchivesUtil.generaRequestFormPdf(requestid, 0); + // 1.去掉生成子流程承办单 + // List subRequestDocid = generaSubRequestFormPdf(requestid); + Map reqDocMap = ArchivesUtil.getFileIdByDocId(String.join(",", requestDocid)); + // 2.去掉生成子流程承办单 + // Map 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 getRequestByid(int requestid) { + HashMap 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 requesData, String zipName, List zwFileName, List 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 requesData) { + HashSet 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 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); + } + + +} diff --git a/com/engine/custom/archives/util/ArchivesUtil.java b/com/engine/custom/archives/util/ArchivesUtil.java index 39e403f..eff25d8 100644 --- a/com/engine/custom/archives/util/ArchivesUtil.java +++ b/com/engine/custom/archives/util/ArchivesUtil.java @@ -35,14 +35,15 @@ import java.lang.reflect.Field; import java.net.URL; import java.net.URLEncoder; import java.nio.charset.StandardCharsets; +import java.time.LocalTime; import java.util.*; public class ArchivesUtil { public static Logger log = LoggerFactory.getLogger("Archives"); - public static final String SQL = "select * from uf_pushArchivesLog where ddsj >= ? and ddsj <= ? " + - " and type = ? and ( zt is null or zt = 1 ) "; + public static final String SQL = "select request from uf_pushArchivesLog where ddsj <= ? " + + " and type = ? and ( zt is null or zt = 1 ) group by REQUEST"; /** * 获取前一天的date @@ -105,13 +106,13 @@ public class ArchivesUtil { public static List 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(); - + log.info("getResultListSQL:{}?{}?{}",SQL,endTime,type); LinkedList result = new LinkedList<>(); while (rs.next()) { 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"))); result.add(pushArchivesBean); } @@ -121,7 +122,7 @@ public class ArchivesUtil { /** * 获取流程自动发起的节点 * - * @param mainAndSubRequestId + * @param workflowid * @return */ public static List getAutoInitNodeIds(String workflowid) { @@ -139,7 +140,7 @@ public class ArchivesUtil { recordSet.executeQuery(sql,workflowid); String exclusenodeid= ""; if (recordSet.next()){ - recordSet.getString("exclusenodeid"); + exclusenodeid = recordSet.getString("exclusenodeid"); } return Arrays.asList(exclusenodeid.split(",")); } @@ -296,7 +297,7 @@ public class ArchivesUtil { HashMap params = new HashMap<>(); params.put("requestid", reqid); params.put("desremark", "all"); - params.put("pageSize", "999"); + params.put("pageSize", "9999"); params.put("isfirst", "true"); // params.put("request", request); Map data = ArchivesUtil.getSignLogCmd(params, new User(1)); @@ -389,7 +390,7 @@ public class ArchivesUtil { // 加载模板并填充数据 log.error("模板路径:{}", TemplatePath); // 导出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); return generate(TemplatePath, TemplateName, dataMap, outputPath); @@ -1047,16 +1048,17 @@ public class ArchivesUtil { /** - * 获取当前流程下的所有子流程(最大5层) + * 获取当前流程下的所有子流程 * - * @param requestid + * @param requestid 主流程id + * @param max 遍历次数 * @return */ - public static Map getSubRequest(String requestid) { + public static Map getSubRequest(String requestid,int max) { HashMap records = new HashMap<>(); RecordSet rs = new RecordSet(); String ids = requestid; - for (int i = 0; i < 5; i++) { + for (int i = 0; i < max; i++) { ArrayList idList = new ArrayList<>(); String sql = "select requestid , workflowid from workflow_requestbase where mainrequestid in ( " + ids + " )"; rs.executeQuery(sql); @@ -1065,7 +1067,7 @@ public class ArchivesUtil { String workflowid = Util.null2String(rs.getString("workflowid")); idList.add(subrequestid); // 使用map自动去重,一种流程类型只取一个requestid - records.put(workflowid, subrequestid); + records.put(subrequestid, workflowid); } ids = String.join(",", idList); } @@ -1278,7 +1280,7 @@ public class ArchivesUtil { } else if (extName.matches("(ofd|OFD)")) { convertType = "57"; } else if (extName.matches("(GIF|JPEG|JPG|BMP|PNG|gif|jpeg|jpg|bmp|png)")) { - convertType = "44"; + convertType = "32"; } else if (extName.matches("(PDF|pdf)")) { convertType = "34"; } @@ -1367,6 +1369,9 @@ public class ArchivesUtil { if (loginid.length() > 8) { loginid = loginid.substring(0, 8); } + if ("fenfa".equals(loginid)){ + continue; + } set.add(loginid); } return String.join("&&", set); @@ -1379,7 +1384,8 @@ public class ArchivesUtil { List subRequest = ArchivesUtil.getSubRequestIds(requestid, isSubReq); String sql = "select * from WORKFLOW_REQUESTLOG where REQUESTID in ( " + 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); while (recordSet.next()) { String annexdocids = Util.null2String(recordSet.getString("annexdocids")); @@ -1402,7 +1408,7 @@ public class ArchivesUtil { */ public static List generaSubRequestFormPdf(String requestid) { log.error("generaSubRequestFormPdf,requestid:{}", requestid); - Map subRequest = ArchivesUtil.getSubRequest(requestid); + Map subRequest = ArchivesUtil.getSubRequest(requestid,5); for (String s : subRequest.keySet()) { requestid = subRequest.get(s); break; @@ -1440,4 +1446,77 @@ public class ArchivesUtil { 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); + } + } diff --git a/com/engine/custom/archives/util/KeyWord.java b/com/engine/custom/archives/util/KeyWord.java new file mode 100644 index 0000000..140b076 --- /dev/null +++ b/com/engine/custom/archives/util/KeyWord.java @@ -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 = "协办部门附件"; + + + + + +} diff --git a/com/engine/custom/archives/workflow/biz/requestForm/WfToDocBizCus.java b/com/engine/custom/archives/workflow/biz/requestForm/WfToDocBizCus.java index 566c497..674e334 100644 --- a/com/engine/custom/archives/workflow/biz/requestForm/WfToDocBizCus.java +++ b/com/engine/custom/archives/workflow/biz/requestForm/WfToDocBizCus.java @@ -34,7 +34,7 @@ public class WfToDocBizCus extends BaseBean { public static Logger log = LoggerFactory.getLogger("Archives"); //底部签字意见列表显示数量 - private int pageSize =100; + private int pageSize =99999; //是否用wk转换 private String useWk=""; private int keepsign; @@ -154,7 +154,7 @@ public class WfToDocBizCus extends BaseBean { /* * 生成html和pdf */ - 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; if (docfiles.contains("2")&&!docfiles.contains("3")){ //只选了生成离线html 没选pdf onlyHtml =1; @@ -174,6 +174,7 @@ public class WfToDocBizCus extends BaseBean { params.put("src",src); params.put("modeid",useModeid); params.put("isSubrequest",reqType == 1); + params.put("workflowid",workflowid); //是否使用wk,在config表中读配置 WorkflowConfigComInfo configComInfo = new WorkflowConfigComInfo(); useWk = Util.null2String(configComInfo.getValue("htmltopdf_usewk")); diff --git a/com/engine/custom/archives/workflow/biz/requestLog/RequestLogCusBiz.java b/com/engine/custom/archives/workflow/biz/requestLog/RequestLogCusBiz.java index 28a1654..d6955de 100644 --- a/com/engine/custom/archives/workflow/biz/requestLog/RequestLogCusBiz.java +++ b/com/engine/custom/archives/workflow/biz/requestLog/RequestLogCusBiz.java @@ -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) { ArrayList logs = new ArrayList(); RecordSet rs = new RecordSet(); - + pageSize = 999999; int min = (pagenumber - 1) * pageSize; int max = pagenumber * pageSize; @@ -121,6 +121,7 @@ public class RequestLogCusBiz { splitinertSql.append(" select t.*,rownum rn from (" + sql + ") t "); splitinertSql.append(" ) t1 where rn >").append(min).append(" and rn <=").append(max); } + log.error("splitinertSql:{}"+splitinertSql); rs.execute(splitinertSql.toString()); while (rs.next()) { Hashtable hashtable = addLogItem(rs); diff --git a/com/engine/custom/audit/corn/OA2AuditCorn.java b/com/engine/custom/audit/corn/OA2AuditCorn.java new file mode 100644 index 0000000..faaaaec --- /dev/null +++ b/com/engine/custom/audit/corn/OA2AuditCorn.java @@ -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 param = new HashMap<>(); + param.put("filePath",filePath); + service.initData(param); + service.genDocTxt(format,"SJ"); + } +} diff --git a/com/engine/custom/audit/service/PushAuditService.java b/com/engine/custom/audit/service/PushAuditService.java new file mode 100644 index 0000000..e0646f1 --- /dev/null +++ b/com/engine/custom/audit/service/PushAuditService.java @@ -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 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 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 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 fjIdName = new HashMap(); + Map fjIdPath = new HashMap(); + Map zwIdName = new HashMap(); + Map zwIdPath = new HashMap(); + Map fjIdimg = new HashMap(); + Map zwIdimg = new HashMap(); + Map reqESBpathMap = new HashMap(); + 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 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 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 IdPath, Map 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 getData(String startTime, String endTime){ + log.info("获取推送审计系统数据start"); + RecordSet recordSet = new RecordSet(); + recordSet.executeQuery(getrqBydatesql , startTime ,endTime); + log.info("getrqBydatesql=="+getrqBydatesql + startTime + endTime); + ArrayList 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 idFilePathMap ,Map 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 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; + // } + + + +} diff --git a/com/engine/custom/msg/MessageReceiveTest.java b/com/engine/custom/msg/MessageReceiveTest.java new file mode 100644 index 0000000..3c44a4c --- /dev/null +++ b/com/engine/custom/msg/MessageReceiveTest.java @@ -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 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 map) { + log.error("setProp:{}",map); + bean.writeLog("setProp:{}"+map); + } + + @Override + public void setList(List 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 + } + +} diff --git a/com/engine/workflow/cmd/codeMaintenance/GetReserveCodeNewInfosCmd.java b/com/engine/workflow/cmd/codeMaintenance/GetReserveCodeNewInfosCmd.java new file mode 100644 index 0000000..8be7fb7 --- /dev/null +++ b/com/engine/workflow/cmd/codeMaintenance/GetReserveCodeNewInfosCmd.java @@ -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>{ + + private Map params; + private User user; + protected String formId; + protected String isBill; + protected ConditionFactory conditionFactory; + + public GetReserveCodeNewInfosCmd(Map params,User user) { + this.params = params; + this.user = user; + conditionFactory = new ConditionFactory(user); + } + + @Override + public Map execute(CommandContext commandContext) { + return getReserveCodeNewInfos(); + } + + /** + * 获取预留编号新建页面信息 + * */ + public Map getReserveCodeNewInfos(){ + Map finalReturnMap = new HashMap(); + Map conditionInfos = new HashMap(); + + 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 formYearIdList = Util.splitString2List(form_yearId, ","); + List formMonthIdList = Util.splitString2List(form_monthId, ","); + List formDateIdList = Util.splitString2List(form_dateId, ","); + List formFieldIdList = Util.splitString2List(form_fieldId, ","); + List formFieldValueList = Util.splitString2List(form_fieldValue, ","); + List formSupSubcompanyIdList = Util.splitString2List(form_supSubCompanyId, ","); + List formSubcompanyIdList = Util.splitString2List(form_subCompanyId, ","); + List formDepartmentIdList = Util.splitString2List(form_departmentId, ","); + int yearIndex = 0; + int monthIndex = 0; + int dateIndex = 0; + int supSubCompanyIndex = 0; + int subCompanyIndex = 0; + int departmentIndex = 0; + + Map formInfo = WorkflowCodeUtil.getFormInfo(workflowId); + isBill = Util.null2String(formInfo.get("isbill")); + formId = Util.null2String(formInfo.get("formid")); + Map> codeInfos = getCodeRegulateInfo(workflowId); + List conCreteFieldList = codeInfos.get("concreteFields"); + List codeValueList = codeInfos.get("codeValues"); + + List> groupList = new ArrayList>(); + + Map codeSetGroupItem = new HashMap(); + Map seqSetGroupItem = new HashMap(); + List codeSetItemList = new ArrayList(); + List seqSetItemList = new ArrayList(); + + 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 cruuentSeqIdOtherParams = new HashMap(); + 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> 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 otherParams = new HashMap(); + 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> replaceDatas = new ArrayList>(); + Map 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> replaceDatas = new ArrayList>(); + Map 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> replaceDatas = new ArrayList>(); + Map 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 otherParams = new HashMap(); + 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 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 otherParams = new HashMap(); + 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 otherParams = new HashMap(); + 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> getSelectInfos(String fieldId,String isBill){ + Map> selectInfos = new HashMap>(); + List selectNames = new ArrayList(); + List selectValues = new ArrayList(); + 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 getSelectOptions(Map> selectInfos,String defaultSelectValue){ + List options = new ArrayList(); + SearchConditionOption optionItem = null; + List selectNames = selectInfos.get("selectNames"); + List 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> getCodeRegulateInfo(String workflowId){ + Map> codeInfos = new HashMap>(); + List conCreteFieldList = new ArrayList(); + List codeValueList = new ArrayList(); + List enableCodeList = new ArrayList(); + 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> selectInfos,String selectValue){ + String returnStr = ""; + List selectValues = selectInfos.get("selectValues"); + List 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 getDefaultDept(String deptId){ + Map deptInfoMap = new HashMap(); + DepartmentComInfo depCom = new DepartmentComInfo(); + String deptName = depCom.getDepartmentname(deptId); + deptInfoMap.put("id", deptId); + deptInfoMap.put("name", deptName); + return deptInfoMap; + } + + //获取默认分部,用于默认显示 + public Map getDefaultSubCom(String subComId){ + Map subComInfoMap = new HashMap(); + 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 getParams() { + return params; + } + + public void setParams(Map params) { + this.params = params; + } + + public User getUser() { + return user; + } + + public void setUser(User user) { + this.user = user; + } + +} diff --git a/demo/demoDate.jsp b/demo/demoDate.jsp deleted file mode 100644 index 9b822b1..0000000 --- a/demo/demoDate.jsp +++ /dev/null @@ -1,66 +0,0 @@ -<%@ page import="java.io.FileInputStream" %> -<%@ page import="java.net.URLEncoder" %> -<%@ page import="com.api.login.util.LoginUtil" %> -<%@ page import="weaver.conn.RecordSet" %> -<%@ page import="com.icbc.api.internal.apache.http.impl.cookie.S" %> -<%@ page import="weaver.hrm.HrmUserVarify" %> -<%@ page import="weaver.hrm.User" %> -<%@ page import="com.alibaba.fastjson.JSONArray" %> -<%@ page import="com.alibaba.fastjson.JSONObject" %> -<%@ page import="java.time.LocalDate" %> -<%@ page import="java.time.format.DateTimeFormatter" %> -<%@ page import="weaver.general.Util" %> -<%@ page import="weaver.general.StringUtil" %> -<%@ page import="java.time.DayOfWeek" %> -<%@ page import="weaver.file.Prop" %> -<%@ page import="java.io.IOException" %> -<%@ page import="java.util.*" %> -<%@ page language="java" contentType="text/html; charset=UTF-8" %> - - -<% - List weekends = getAllWeekendsOfYear(LocalDate.now().getYear()); - for (String weekend : weekends) { - out.print(weekend+"
"); - } - out.print(weekends.size()); - -%> -<%! - private static List getAllWeekendsOfYear(int year) { - //将本年的周六周日加到list中 - List 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 WorkDates = new ArrayList<>(); - List 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 set = new HashSet<>(); - set.addAll(weekendDates); - set.addAll(holidayDates); - return new ArrayList<>(set); - } - - -%> \ No newline at end of file diff --git a/docment/字段映射_1694422244889.xlsx b/docment/字段映射_1694422244889.xlsx deleted file mode 100644 index 521d8f4..0000000 Binary files a/docment/字段映射_1694422244889.xlsx and /dev/null differ diff --git a/docment/字段映射_1694514327253.xlsx b/docment/字段映射_1694514327253.xlsx deleted file mode 100644 index dee2bd0..0000000 Binary files a/docment/字段映射_1694514327253.xlsx and /dev/null differ diff --git a/docment/补贴报销单.wewf b/docment/补贴报销单.wewf deleted file mode 100644 index 9ae0a30..0000000 Binary files a/docment/补贴报销单.wewf and /dev/null differ diff --git a/docment/阿里差旅推送财务系统_字段梳理_V4.0.xlsx b/docment/阿里差旅推送财务系统_字段梳理_V4.0.xlsx deleted file mode 100644 index f2e4433..0000000 Binary files a/docment/阿里差旅推送财务系统_字段梳理_V4.0.xlsx and /dev/null differ diff --git a/interface/transfer/HistoryDataPushArchiveLog.jsp b/interface/transfer/HistoryDataPushArchiveLog.jsp new file mode 100644 index 0000000..56a46fd --- /dev/null +++ b/interface/transfer/HistoryDataPushArchiveLog.jsp @@ -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("
"); + long startTime = System.currentTimeMillis(); + RecordSet recordSet = new RecordSet(); + String sql = "select MAINWFID , endnodeid , type from uf_ArchivesSet"; + recordSet.executeQuery(sql); + ArrayList> wfids = new ArrayList<>(); + while (recordSet.next()){ + HashMap 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 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 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("
"); + while (recordSet.next()){ + String reqid = recordSet.getString("reqid"); + String insertStr = reqid + sep + timestamp + sep + type; + out.print(insertStr); + out.print("
"); + 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); + } + +%> \ No newline at end of file diff --git a/interface/transfer/HistoryDataPushArchiveLog2023.jsp b/interface/transfer/HistoryDataPushArchiveLog2023.jsp new file mode 100644 index 0000000..8ac2abb --- /dev/null +++ b/interface/transfer/HistoryDataPushArchiveLog2023.jsp @@ -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("
"); + long startTime = System.currentTimeMillis(); + RecordSet recordSet = new RecordSet(); + String sql = "select MAINWFID , endnodeid , type from uf_ArchivesSet"; + recordSet.executeQuery(sql); + ArrayList> wfids = new ArrayList<>(); + while (recordSet.next()){ + HashMap 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 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 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("
"); + while (recordSet.next()){ + String reqid = recordSet.getString("reqid"); + String insertStr = reqid + sep + timestamp + sep + type; + out.print(insertStr); + out.print("
"); + 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); + } + +%> \ No newline at end of file diff --git a/interface/transfer/HistoryDataPushArchiveLog202312.jsp b/interface/transfer/HistoryDataPushArchiveLog202312.jsp new file mode 100644 index 0000000..ccb82e9 --- /dev/null +++ b/interface/transfer/HistoryDataPushArchiveLog202312.jsp @@ -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("
"); + long startTime = System.currentTimeMillis(); + RecordSet recordSet = new RecordSet(); + String sql = "select MAINWFID , endnodeid , type from uf_ArchivesSet"; + recordSet.executeQuery(sql); + ArrayList> wfids = new ArrayList<>(); + while (recordSet.next()){ + HashMap 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 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 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("
"); + while (recordSet.next()){ + String reqid = recordSet.getString("reqid"); + String insertStr = reqid + sep + timestamp + sep + type; + out.print(insertStr); + out.print("
"); + 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); + } + +%> \ No newline at end of file diff --git a/interface/transfer/HistoryDataPushArchiveLog202312.zip b/interface/transfer/HistoryDataPushArchiveLog202312.zip new file mode 100644 index 0000000..39af52e Binary files /dev/null and b/interface/transfer/HistoryDataPushArchiveLog202312.zip differ diff --git a/interface/transfer/reportApp.jsp b/interface/transfer/reportApp.jsp deleted file mode 100644 index e50cdfa..0000000 --- a/interface/transfer/reportApp.jsp +++ /dev/null @@ -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("
最爱用APP更新开始执行"); - execute(); - out.print("
最爱用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(); - } - - -%> \ No newline at end of file diff --git a/interface/transfer/reportGjc.jsp b/interface/transfer/reportGjc.jsp deleted file mode 100644 index 08ff074..0000000 --- a/interface/transfer/reportGjc.jsp +++ /dev/null @@ -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("
关键词更新开始执行"); - String execute = execute(); - out.print(execute); - out.print("
关键词更新结束"); - -%> -<%! - 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 + "
updateRoleGjc==>" + i; - int i1 = updateGjcOfficialWf(rs, 650); - out = out + "
updateGjcOfficialWf==>" + i1; - int i2 = updateGjcAffairsWf(rs, 650); - out = out + "
updateGjcAffairsWf==>" + i2; - int i3 = updateGjcBusinessWf(rs, 650); - out = out + "
updateGjcBusinessWf==>" + i3; - int i4 = updateGjcShareDoc(rs, 650); - out = out + "
updateGjcShareDoc==>" + i4; - int i5 = updateGjcMeeting(rs, 650); - out = out + "
updateGjcMeeting==>" + i5; - int i6 = updateGjcLogin(rs, 650); - out = out + "
updateGjcLogin==>" + i6; - int i7 = updateGjcMsg(rs, 650); - out = out + "
updateGjcMsg==>" + i7; - int i8 = updateGjcNull(rs); - out = out + "
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(); - } - -%> \ No newline at end of file diff --git a/interface/transfer/testDemo2.jsp b/interface/transfer/syncDepartment.jsp similarity index 79% rename from interface/transfer/testDemo2.jsp rename to interface/transfer/syncDepartment.jsp index 23b5ce5..85eeaaa 100644 --- a/interface/transfer/testDemo2.jsp +++ b/interface/transfer/syncDepartment.jsp @@ -10,13 +10,16 @@ <%@ page import="weaver.conn.RecordSet" %> <%@ page import="com.engine.custom.archives.entity.Dept" %> <%@ page import="com.alibaba.fastjson.JSONObject" %> +<%@ page import="weaver.general.BaseBean" %> <% - List depts = readExcelFile("/opt/weaver/filesys/zzxx.xlsx"); + List depts = readExcelFile("/opt/weaver/archivesFile/template/zzxx.xlsx"); // 输出或处理dept列表 out.println(depts.size()); out.println(JSONObject.toJSONString(depts)); + BaseBean bb = new BaseBean(); + bb.writeLog(JSONObject.toJSONString(depts)); RecordSet recordSet = new RecordSet(); 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 = ? )"; @@ -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 = ? ) )"; for (Dept dept : depts) { + bb.writeLog(JSONObject.toJSONString(dept)); if ("zgs".equals(dept.getType())) { continue; } if ("zonghang".equals(dept.getType())) { + recordSet.executeUpdate(comSql, dept.getId(), dept.getName()); + bb.writeLog(comSql+ "_"+dept.getId()+"_"+ dept.getName()); } if ("zhih".equals(dept.getType()) || "fh".equals(dept.getType())) { if ("10".equals(dept.getParentId())) { recordSet.executeUpdate(comSql, dept.getId(), dept.getName()); + bb.writeLog(comSql+ "_"+dept.getId()+"_"+ dept.getName()); } else { 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())) { 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.setId(row.getCell(0).getStringCellValue()); Dept.setName(row.getCell(1).getStringCellValue()); - Dept.setType(row.getCell(2).getStringCellValue()); - Dept.setParentId(row.getCell(3).getStringCellValue()); - Dept.setAllName(row.getCell(4).getStringCellValue()); + Dept.setType(row.getCell(3).getStringCellValue()); + Dept.setParentId(row.getCell(4).getStringCellValue()); + Dept.setAllName(row.getCell(2).getStringCellValue()); // 假设第一列是姓名,第二列是年龄 dept.add(Dept); } diff --git a/interface/transfer/testDemo.jsp b/interface/transfer/testDemo.jsp deleted file mode 100644 index 442b232..0000000 --- a/interface/transfer/testDemo.jsp +++ /dev/null @@ -1,1188 +0,0 @@ -<%@ page import="java.nio.charset.StandardCharsets" %> -<%@ page import="java.io.*" %> -<%@ page import="java.util.*" %> -<%@ page import="weaver.conn.RecordSet" %> -<%@ page import="weaver.general.Util" %> -<%@ page import="com.alibaba.fastjson.JSONObject" %> -<%@ page import="weaver.file.ImageFileManager" %> -<%@ page import="java.net.URL" %> -<%@ page import="org.apache.commons.io.FileUtils" %> -<%@ page import="okhttp3.*" %> -<%@ page import="java.net.URLEncoder" %> -<%@ page import="weaver.soa.workflow.request.RequestService" %> -<%@ page import="weaver.soa.workflow.request.RequestInfo" %> -<%@ page import="com.engine.custom.archives.action.WorkflowToDocCus" %> -<%@ page import="weaver.docs.docs.DocRecycleManager" %> -<%@ page import="weaver.hrm.User" %> -<%@ page import="com.api.workflow.service.RequestAuthenticationService" %> -<%@ page import="weaver.workflow.workflow.WorkflowConfigComInfo" %> -<%@ page import="weaver.hrm.resource.ResourceComInfo" %> -<%@ page import="weaver.crm.Maint.CustomerInfoComInfo" %> -<%@ page import="com.alibaba.fastjson.JSON" %> -<%@ page import="weaver.workflow.monitor.Monitor" %> -<%@ page import="com.engine.workflow.biz.RobotNode.RobotNodeServiceBiz" %> -<%@ page import="com.api.workflow.util.ServiceUtil" %> -<%@ page import="com.engine.workflow.biz.RobotNode.RobotNodeBiz" %> -<%@ page import="weaver.general.TimeUtil" %> -<%@ page import="org.apache.poi.xwpf.usermodel.XWPFDocument" %> -<%@ page import="cn.afterturn.easypoi.word.WordExportUtil" %> -<%@ page import="com.icbc.api.internal.apache.http.impl.cookie.F" %> -<%@ page import="cn.hutool.core.util.ZipUtil" %> - - -<% - String requestid = "607615"; - String filePath = "/opt/weaver/filesys/test"; - String zwdir = getKeyword("7"); - String fjdir = getKeyword("8"); - String cbddir = getKeyword("9"); - String zlcdir = getKeyword("9") + File.separator + getKeyword("10"); - String lzxxdir = getKeyword("11"); - String Url = "http://14.1.206.240:18080/fcscloud/composite/upload"; - String fjFile = fjdir; - - Map subRequest = getSubRequest(requestid); - - Map requesData = getRequestByid(requestid); - String fj = Util.null2String(requesData.get("fj")); - String zwkbj = Util.null2String(requesData.get("zwkbj")); - List docids = new ArrayList<>(); - docids.addAll(Arrays.asList(fj.split(","))); - docids.addAll(Arrays.asList(zwkbj.split(","))); - Map fjMap = getFileIdByDocId(fj); - Map zwkbjMap = getFileIdByDocId(zwkbj); - 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 + fjdir + File.separator + imageFileManager.getImageFileName(); -// imageFileName = codeUtf8(imageFileName); -// try { -// File file = saveInputStreamToFile(inputStream, imageFileName); -// String s = callApi(Url, file); -// System.out.println(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"); -// downloadFile(viewUrl, filePath + File.separator + fjdir + File.separator + imageFileManager.getImageFileName() + ".pdf"); -// } -// } catch (IOException e) { -// e.printStackTrace(); -// } -// }); -// //正文 -// zwkbjMap.forEach((docid, imageid) -> { -// ImageFileManager imageFileManager = new ImageFileManager(); -// imageFileManager.getImageFileInfoById(Util.getIntValue(imageid)); -// InputStream inputStream = imageFileManager.getInputStream(); -// //中文路径/中文文件名 -// String imageFileName = filePath + File.separator + zwdir + File.separator + imageFileManager.getImageFileName(); -// imageFileName = codeUtf8(imageFileName); -// try { -// File file = saveInputStreamToFile(inputStream, imageFileName); -// String s = callApi(Url, file); -// System.out.println(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"); -// downloadFile(viewUrl, filePath + File.separator + zwdir + File.separator + imageFileManager.getImageFileName() + ".pdf"); -// } -// } catch (IOException e) { -// e.printStackTrace(); -// } -// }); -// //开始承办单 先获取主流程的承办单 -// -// List requestDocid = generaRequestFormPdf(requestid); -// List requestDocid1 = generaSubRequestFormPdf(requestid); -// Map map1 = getFileIdByDocId(String.join(",",requestDocid)); -// Map map2 = getFileIdByDocId(String.join(",",requestDocid1)); -// out.print("
"); -// out.print("map1:"+JSONObject.toJSONString(map1)); -// out.print("
"); -// out.print("map2:"+JSONObject.toJSONString(map2)); -// out.print("
"); -// -// docids.addAll(requestDocid); -// docids.addAll(requestDocid1); -// -// //附件 -// map1.forEach((docid, imageid) -> { -// ImageFileManager imageFileManager = new ImageFileManager(); -// imageFileManager.getImageFileInfoById(Util.getIntValue(imageid)); -// InputStream inputStream = imageFileManager.getInputStream(); -// //中文路径/中文文件名 -// String imageFileName = filePath + File.separator + cbddir + File.separator + fjFile + i[0] +"_"+ imageFileManager.getImageFileName(); -// imageFileName = codeUtf8(imageFileName); -// try { -// File file = saveInputStreamToFile(inputStream, imageFileName); -// String s = callApi(Url, file); -// System.out.println(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"); -// downloadFile(viewUrl, filePath + File.separator + cbddir + File.separator +fjFile + i[0] +"_"+ imageFileManager.getImageFileName() + ".pdf"); -// } -// i[0]++; -// } catch (IOException e) { -// e.printStackTrace(); -// } -// }); -// //正文 -// i[0] = 1; -// map2.forEach((docid, imageid) -> { -// ImageFileManager imageFileManager = new ImageFileManager(); -// imageFileManager.getImageFileInfoById(Util.getIntValue(imageid)); -// InputStream inputStream = imageFileManager.getInputStream(); -// //中文路径/中文文件名 -// String imageFileName = filePath + File.separator + zlcdir + File.separator + fjFile + i[0] +"_"+ imageFileManager.getImageFileName(); -// imageFileName = codeUtf8(imageFileName); -// try { -// File file = saveInputStreamToFile(inputStream, imageFileName); -// String s = callApi(Url, file); -// System.out.println(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"); -// downloadFile(viewUrl, filePath + File.separator + zlcdir + File.separator + fjFile + i[0] +"_"+ imageFileManager.getImageFileName() + ".pdf"); -// } -// i[0]++; -// } catch (IOException e) { -// e.printStackTrace(); -// } -// }); -// // -// out.print(JSONObject.toJSONString(requestDocid)); -// out.print(JSONObject.toJSONString(requestDocid1)); -// for (String docid : docids) { -// out.print("删除了"+docids); -// out.print("
"); -// deleteDocByid(docid); -// } -// //-------------------------------------------------------------------- - RequestService requestService = new RequestService(); - RequestInfo requestInfo = requestService.getRequest(Util.getIntValue(requestid), 100); - String logFile = getSignLog(requestid, lzxxdir, requestInfo.getCreatorid() + requestInfo.getDescription()); - String s = callApi(Url, new File(logFile)); - System.out.println(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"); - downloadFile(viewUrl, logFile + ".pdf"); - } - ZipUtil.zip(filePath,filePath+"test.zip"); -%> - -<%! - /** - * 生成子流程承办单 - * @param requestid 主流程id - */ - private List generaSubRequestFormPdf(String requestid) { - Map subRequest = getSubRequest(requestid); - List docids = new ArrayList<>(); - for (String wfid : subRequest.keySet()) { - RequestService requestService = new RequestService(); - RequestInfo requestInfo = requestService.getRequest(Util.getIntValue(subRequest.get(wfid)), 100); - WorkflowToDocCus workflowToDoc = new WorkflowToDocCus(); - requestInfo.setLastoperator("1"); - requestInfo.setDescription(getWfNameByid(requestInfo.getWorkflowid()) + "-" + requestInfo.getDescription()); - List subDocids = workflowToDoc.execute(requestInfo, 1); - docids.addAll(subDocids); - } - return docids; - } - - /** - * 生成主流程承办单 - * @param requestid - */ - private static List generaRequestFormPdf(String requestid) { - RequestService requestService = new RequestService(); - RequestInfo requestInfo = requestService.getRequest(Util.getIntValue(requestid), 100); - WorkflowToDocCus workflowToDoc = new WorkflowToDocCus(); - requestInfo.setLastoperator("1"); - requestInfo.setDescription(getWfNameByid(requestInfo.getWorkflowid()) + "-" + requestInfo.getDescription()); - - return workflowToDoc.execute(requestInfo, 0); - } - - /*** - * 封装数据 - * @param requestid - * @return - */ - public Map getRequestByid(String requestid) { - HashMap record = new HashMap<>(); - String sql = "select * from formtable_main_30 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); - } - return record; - } - - - /** - * 将gbk转为UTF-8,创建ISO-8859-1编码的字符串, - * ISO-8859-1编码是一个字节对应一个字符,因此不会使最后一个字节错误。 - * @param text - * @return - */ - 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); - - } - - /** - * 获取当前流程下的所有子流程(最大5层) - * @param requestid - * @return - */ - public static Map getSubRequest(String requestid) { - HashMap records = new HashMap<>(); - RecordSet rs = new RecordSet(); - String ids = requestid; - for (int i = 0; i < 5; i++) { - ArrayList idList = new ArrayList<>(); - String sql = "select requestid , workflowid from workflow_requestbase where mainrequestid in ( " + ids + " )"; - rs.executeQuery(sql); - while (rs.next()) { - String subrequestid = Util.null2String(rs.getString("requestid")); - String workflowid = Util.null2String(rs.getString("workflowid")); - idList.add(subrequestid); - // 使用map自动去重,一种流程类型只取一个requestid - records.put(workflowid, subrequestid); - } - ids = String.join(",", idList); - } - - - // String sql = "select requestid from workflow_requestbase where mainrequestid = ?"; - // RecordSet rs = new RecordSet(); - // rs.executeQuery(sql, requestid); - // if (rs.next()) { - // String subrequestid = Util.null2String(rs.getString("requestid")); - // records.add(subrequestid); - // } - return records; - } - - /** - * 获取imageid Map - * @param ids - * @return - */ - public static Map getFileIdByDocId(String ids) { - HashMap records = new HashMap<>(); - - 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")); - records.put(docid, imgid); - } - return records; - } - - /** - * 将InputStream写入本地文件 - * @param inputStream 输入流 - * @param localFilePath 本地文件路径 - * @throws IOException 如果发生输入输出异常 - * @return - */ - public static File saveInputStreamToFile(InputStream inputStream, String localFilePath) throws IOException { - File targetFile = new File(localFilePath); - - // 确保目标文件的父目录存在 - File parentDir = targetFile.getParentFile(); - if (parentDir != null && !parentDir.exists()) { - parentDir.mkdirs(); - } - - - // 使用try-with-resources语句确保流的正确关闭 - try (InputStream in = inputStream; - OutputStream outputStream = new FileOutputStream(targetFile)) { - int read; - byte[] bytes = new byte[1024]; - while ((read = in.read(bytes)) != -1) { - outputStream.write(bytes, 0, read); - } - } // 自动关闭 in 和 outputStream - return targetFile; - } - - - /** - * 根据链接下载文件 - * @param fileURL - * @param saveDir - */ - public static void downloadFile(String fileURL, String saveDir) { - - try { - saveDir = codeUtf8(saveDir); - URL url = new URL(fileURL); - File file = new File(saveDir); - FileUtils.copyURLToFile(url, file); - System.out.println("Download completed successfully."); - } catch (IOException e) { - e.printStackTrace(); - System.out.println("Download failed."); - } - } - - - /** - * 调用永中接口 - * @param BASE_URL - * @param file - * @return - * @throws IOException - */ - public static String callApi(String BASE_URL, File file) throws IOException { - OkHttpClient client = new OkHttpClient(); - // Debugging: Check if the file exists and can be read - if (file.exists() && file.canRead()) { - System.out.println("File exists and is readable. File path: " + file.getAbsolutePath()); - } else { - System.out.println("File does not exist or cannot be read. File path: " + file.getAbsolutePath()); - } - RequestBody requestBody = null; - String code = getCodeByFileType(file.getName()); - String fileName = URLEncoder.encode(file.getName(), StandardCharsets.UTF_8.toString()); - try { - requestBody = new MultipartBody.Builder() - .setType(MultipartBody.FORM) - .addFormDataPart("convertType", code) - .addFormDataPart("file", fileName, RequestBody.create(MediaType.parse("application/zip"), file)) - .build(); - } catch (Exception e) { - System.out.println(e); - e.printStackTrace(); - } - - Request request = new Request.Builder() - .url(BASE_URL) - .post(requestBody) - .build(); - - try (Response response = client.newCall(request).execute()) { - return response.body().string(); - } - } - - /** - * 根据文件类型获取转为pdf的编码 - * @param FileName - * @return - */ - - public static String getCodeByFileType(String FileName) { - String extName = FileName.substring(FileName.lastIndexOf(".") + 1); - String convertType = ""; - if (extName.matches("(doc|dot|dtd|docx|docm|dotx|ppt|pptx|ppsx|potx|xlsx|xlsm|wps|dps|et|wpt|xls|xlc|xlt|xlm|xlw|DOC|DOT|DTD|DOCX|DOCM|DOTX|PPT|PPTX|PPSX|POTX|XLSX|XLSM|WPS|DPS|ET|WPT|XLS|XLC|XLT|XLM|XLW)")) { - convertType = "3"; - } else if (extName.matches("(ofd|OFD)")) { - convertType = "57"; - } else if (extName.matches("(GIF|JPEG|JPG|BMP|PNG|gif|jpeg|jpg|bmp|png)")) { - convertType = "44"; - } else if (extName.matches("(PDF|pdf)")) { - convertType = "34"; - } - return convertType; - } - - - /*** - * 获取关键词 - * @param id - * @return - */ - public static String getKeyword(String id) { - String sql = "select * from uf_test where id = ?"; - RecordSet rs = new RecordSet(); - rs.executeQuery(sql, id); - rs.next(); - return Util.null2String(rs.getString("label")); - } - - /** - * 删除文档及附件,调用移到回收站,再从回收站删除 - * @param docid - */ - 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"); - } - - /** - * 获取流程类型名称 - * @param wfid - * @return - */ - - public static String getWfNameByid(String wfid) { - String sql = "select WORKFLOWNAME from WORKFLOW_BASE where id = ?"; - RecordSet rs = new RecordSet(); - rs.executeQuery(sql, wfid); - rs.next(); - return Util.null2String(rs.getString("WORKFLOWNAME")); - } - - /** - * 生成流转意见 意见 - * @param params - * @param user - * @return - */ - public static String getSignLog(String requestid, String dirName, String requestName) { - HashMap params = new HashMap<>(); - params.put("requestid", requestid); - params.put("desremark", "all"); - params.put("pageSize", "50"); - params.put("isfirst", "true"); - // params.put("request", request); - Map data = getSignLogCmd(params, new User(1)); - System.out.println("data===>"); - System.out.println(JSONObject.toJSONString(data)); - Map datas = (Map) data.get("datas"); - List> entries = new ArrayList<>(datas.entrySet()); - entries.sort(new Comparator>() { - @Override - public int compare(Map.Entry o1, Map.Entry 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> results = new ArrayList<>(); - // out.print(JSONObject.toJSONString(entries)); - for (Map.Entry entry : entries) { - Map value = (Map) entry.getValue(); - List> list = (List) value.get("list"); - for (Map 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 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); - } - } - - System.out.println("results===>"); - System.out.println(JSONObject.toJSONString(results)); - try { - Map dataMap = new HashMap<>(); - dataMap.put("results", results); // 将用户列表添加到数据映射中 - dataMap.put("name", requestName); // 将用户列表添加到数据映射中 - - // 加载模板并填充数据 - String templatePath = "/opt/weaver/filesys/template.docx"; // 模板文件路径 - System.out.println(dataMap); - XWPFDocument doc = WordExportUtil.exportWord07(templatePath, dataMap); - // 导出Word文档 - String outputPath = "/opt/weaver/filesys/test" + File.separator + dirName + File.separator + requestName + ".docx"; // 输出文件路径 - outputPath = codeUtf8(outputPath); - - File targetFile = new File(outputPath); - - // 确保目标文件的父目录存在 - File parentDir = targetFile.getParentFile(); - if (parentDir != null && !parentDir.exists()) { - parentDir.mkdirs(); - } - FileOutputStream fos = new FileOutputStream(outputPath); - doc.write(fos); - fos.close(); - return outputPath; - } catch (Exception e) { - System.out.println("errorerrorerror"); - System.out.println(e.getMessage()); - e.printStackTrace(); - } - return requestid; - } - - - public static Map getSignLogCmd(Map params, User user) { - Map result = new HashMap(); - 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 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 putpara = new HashMap(); - - 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等于4,preisremark=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> statuslist = new ArrayList>(); - 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 nodekv = null; - if (statuslist.size() == 0) { - currentMinId = currentId; - nodekv = new HashMap(); - statuslist.add(nodekv); - } else { - Map 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(); - 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 allstatusmap = new HashMap(); - Map submitstatusmap = new HashMap(); - Map nosubmitstatusmap = new HashMap(); - Map viewstatusmap = new HashMap(); - Map noviewstatusmap = new HashMap(); - //提交节点信息--滚动加载到当前currentoperator对应最大id - - //数字统计转到新接口count中 - ResourceComInfo resourceComInfo = new ResourceComInfo(); - CustomerInfoComInfo customerInfoComInfo = new CustomerInfoComInfo(); - Map all_nodemap = new HashMap(); - Map submit_nodemap = new HashMap(); - Map nosubmit_nodemap = new HashMap(); - Map view_nodemap = new HashMap(); - Map noview_nodemap = new HashMap(); - - rs.beforFirst(); - int currentnum = 0; - for (Iterator> it = statuslist.iterator(); it.hasNext(); index++) { - - Map 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 all_nodemap_in = new HashMap(); - all_nodemap_in.put("nodeid", fnodeid); - all_nodemap_in.put("nodename", namename); - Map submit_nodemap_in = new HashMap(); - Map nosubmit_nodemap_in = new HashMap(); - Map view_nodemap_in = new HashMap(); - Map noview_nodemap_in = new HashMap(); - - List> nodeallstatuslist = new ArrayList>(); - List> nodesubmitstatuslist = new ArrayList>(); - List> nodenosubmitstatuslist = new ArrayList>(); - List> nodeviewstatuslist = new ArrayList>(); - List> nodenoviewstatuslist = new ArrayList>(); - - 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 _statusmap = new HashMap(); - // 操作人 - 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; - } - - -%> - - diff --git a/interface/transfer/testError.jsp b/interface/transfer/testError.jsp deleted file mode 100644 index d863b26..0000000 --- a/interface/transfer/testError.jsp +++ /dev/null @@ -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 params = new HashMap<>(); - params.put("requestid", "727734"); - params.put("desremark", "all"); - params.put("pageSize", "50"); - params.put("isfirst", "true"); - params.put("request", request); - Map data = execute(params, new User(23)); - Map datas = (Map) data.get("datas"); - List> entries = new ArrayList<>(datas.entrySet()); - entries.sort(new Comparator>() { - @Override - public int compare(Map.Entry o1, Map.Entry 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> results = new ArrayList<>(); - // out.print(JSONObject.toJSONString(entries)); - for (Map.Entry entry : entries) { - Map value = (Map)entry.getValue(); - List> list = (List)value.get("list"); - for (Map 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 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 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> results) { - try { - Map 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 execute(Map params, User user) { - Map result = new HashMap(); - 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 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 putpara = new HashMap(); - - 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等于4,preisremark=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> statuslist = new ArrayList>(); - 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 nodekv = null; - if (statuslist.size() == 0) { - currentMinId = currentId; - nodekv = new HashMap(); - statuslist.add(nodekv); - } else { - Map 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(); - 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 allstatusmap = new HashMap(); - Map submitstatusmap = new HashMap(); - Map nosubmitstatusmap = new HashMap(); - Map viewstatusmap = new HashMap(); - Map noviewstatusmap = new HashMap(); - //提交节点信息--滚动加载到当前currentoperator对应最大id - - //数字统计转到新接口count中 - ResourceComInfo resourceComInfo = new ResourceComInfo(); - CustomerInfoComInfo customerInfoComInfo = new CustomerInfoComInfo(); - Map all_nodemap = new HashMap(); - Map submit_nodemap = new HashMap(); - Map nosubmit_nodemap = new HashMap(); - Map view_nodemap = new HashMap(); - Map noview_nodemap = new HashMap(); - - rs.beforFirst(); - int currentnum = 0; - for (Iterator> it = statuslist.iterator(); it.hasNext(); index++) { - - Map 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 all_nodemap_in = new HashMap(); - all_nodemap_in.put("nodeid", fnodeid); - all_nodemap_in.put("nodename", namename); - Map submit_nodemap_in = new HashMap(); - Map nosubmit_nodemap_in = new HashMap(); - Map view_nodemap_in = new HashMap(); - Map noview_nodemap_in = new HashMap(); - - List> nodeallstatuslist = new ArrayList>(); - List> nodesubmitstatuslist = new ArrayList>(); - List> nodenosubmitstatuslist = new ArrayList>(); - List> nodeviewstatuslist = new ArrayList>(); - List> nodenoviewstatuslist = new ArrayList>(); - - 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 _statusmap = new HashMap(); - // 操作人 - 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; - } - - - -%> - - diff --git a/interface/transfer/testError2.jsp b/interface/transfer/testError2.jsp deleted file mode 100644 index 6e1be93..0000000 --- a/interface/transfer/testError2.jsp +++ /dev/null @@ -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 root = new HashMap<>(); - // root.put("title", "期末成绩表"); - - ArrayList list = new ArrayList<>(); - Map 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 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 lists = new ArrayList(); - root.put("achievementList", list); - lists.add(root); - lists.add(root); - lists.add(root); - - Map roots = new HashMap(); - 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 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); - - } - -%> - - diff --git a/interface/transfer/testError3.jsp b/interface/transfer/testError3.jsp deleted file mode 100644 index 70e1043..0000000 --- a/interface/transfer/testError3.jsp +++ /dev/null @@ -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"); - } - -%> - - diff --git a/interface/transfer/testXML.jsp b/interface/transfer/testXML.jsp deleted file mode 100644 index 4a087c6..0000000 --- a/interface/transfer/testXML.jsp +++ /dev/null @@ -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 parseXMLToMap(String xmlString) { - new BaseBean().writeLog("XMLUtils:xmlString==>"+xmlString); - Map 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 resultMap; - private Stack elementStack = new Stack<>(); - private StringBuilder elementValue = new StringBuilder(); - - public SAXHandler(Map 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); - } - } -%> \ No newline at end of file diff --git a/interface/transfer/最终测试一下1106.html b/interface/transfer/最终测试一下1106.html deleted file mode 100644 index 2ef0ce8..0000000 --- a/interface/transfer/最终测试一下1106.html +++ /dev/null @@ -1,2580 +0,0 @@ - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
- - - 天津银行总行 
收文阅办单
- -
-
- -
- - - 标题 - -
-
- -
- - - 最终测试一下1106 - -
-
- -
- - - 来文单位 - -
-
- -
- - - -市委组织部 - - - - - - - -
-
- -
- - - 收文号 - -
-
- -
- - - 2023-S139号 - -
-
- -
- - - 来文号 - -
-
- -
- - - - -
-
- -
- - - 反馈时限 - -
-
- -
- - - - -
-
- -
- - - 分发意见 - -
-
- -
- - - - - - - - - -
-
- 办公室/ - 测试-杨芳_10110033[ - 2023-11-06  - 14:16:33]: - 测试_10110013、个人金融部、信用卡部、测试_10110223、信息技术部  - -
23
-
-
- -
- - - 行外收文 - -
-
- -
- - - 正文 - -
-
- -
- - - - -
-
- -
- - - 正文 - -
-
- -
- - - - -
-
- -
- - - 附件 - -
-
- -
- - - -
- -
-
- -
- - - 备注 - -
-
- -
- - - - -
-
- -
- - - 行领导意见 - -
-
- -
- - - - - - - - - - - -
-
- 行领导/ - 测试_10110013[ - 2023-11-06  - 14:18:30]: - 行领导阅批  - -
22
- - - - - - - - - - -
-
- 行领导/ - 测试_10110223[ - 2023-11-06  - 14:18:01]: - 行领导阅知  - -
22
- - -
-
- -
- - - 主办部门办理意见 - -
-
- -
- - - - - - - - - - - -
-
- 个人金融部/ - 测试_10110141[ - 2023-11-06  - 15:13:31]: - 阅办——部门领导2  - -
30
-
- 信用卡部/ - 测试_10110152[ - 2023-11-06  - 14:21:08]: - 阅办——部门领导1  - -
31
- - - - - - - - - - - - - - -
-
- 个人金融部/ - 测试_10111252[ - 2023-11-07  - 11:15:40]: - 阅办——员工6  - -
30
-
- 个人金融部/ - 测试_10110145[ - 2023-11-07  - 10:50:31]: - 阅办——员工3  - -
30
-
- 信用卡部/ - 测试_10110160[ - 2023-11-06  - 15:04:50]: - 阅办——又回到员工2  - -
31
-
- 信用卡部/ - 测试_10110155[ - 2023-11-06  - 14:48:50]: - 阅办——又回到员工1  - -
31
- - -
-
- -
- - - 协办部门办理意见 - -
-
- -
- - - - - - - - - - - -
-
- 安全保卫部(人民武装部)/ - 测试_10111050[ - 2023-11-07  - 10:58:21]: - 部门协办——领导6  - -
50
-
- 综合管理团队/ - 测试_10110772[ - 2023-11-07  - 10:56:04]: - 部门协办——领导5  - -
3490
-
- 授信管理部/ - 测试_10110277[ - 2023-11-06  - 14:56:41]: - 部门协办——领导4
 
- -
36
-
- 资产保全部/ - 测试_10110308[ - 2023-11-06  - 14:54:13]: - 部门协办——领导3  - -
37
-
- 法律事务部/ - 测试_10110349[ - 2023-11-06  - 14:46:03]: - 部门协办——领导2  - -
38
-
- 运营管理部/ - 测试_10110396[ - 2023-11-06  - 14:43:47]: - 部门协办——领导1  - -
42
- - - - - - - - - - - - - - -
-
- 安全保卫部(人民武装部)/ - 测试_10111050[ - 2023-11-07  - 10:59:00]: - 部门协办——员工6  - -
50
-
- 综合管理团队/ - 测试_10110772[ - 2023-11-07  - 10:56:46]: - 部门协办——员工5  - -
3490
-
- 授信管理部/ - 测试_10110277[ - 2023-11-06  - 14:58:08]: - 部门协办——员工4  - -
36
-
- 资产保全部/ - 测试_10110308[ - 2023-11-06  - 14:54:56]: - 部门协办——员工3  - -
37
-
- 法律事务部/ - 测试_10110349[ - 2023-11-06  - 14:46:31]: - 部门协办-员工办理2  - -
38
-
- 运营管理部/ - 测试_10110396[ - 2023-11-06  - 14:44:25]: - 部门协办-员工办理1  - -
42
- - -
-
- -
- - - 阅件部门办理意见 - -
-
- -
- - - - - - - - - - - -
-
- 信息技术部/ - 测试_10110632[ - 2023-11-06  - 14:19:16]: - 阅知——部门领导  - -
48
- - - - - - - - - - - - - - -
-
- 信息技术部/ - 测试_10110632[ - 2023-11-06  - 14:19:47]: - 阅知——员工办理  - -
48
- - -
-
- -
- - - 矩阵 - -
-
- -
- - - - -
-
- -
- - - 阅办负责人 - -
-
- -
- - - 魏来 - -
-
- -
- - - 抄送人员 - -
-
- - -
- -
- - - 当前部门 - -
-
- -
- - - - -
-
- -
- - - 测试_10110223 - -
-
- -
- - - 是否屏蔽移动端 - -
-
- -
- - - - -
-
- -
- - - 办理期限 - -
-
- -
- - - 2023-12-11 - -
-
-
- -
- -
-
-
- -
-
-
-
- - - - - - - -
- -
-
-
-
-
-
-

接收人 : 测试_10110141

-

2023-11-07 11:29:53[综合文员 / 提交]

-
-
-
- - - - - - - -
-
- - -
-
-
- 自动流转至下一操作者 -
-
-
-
-

接收人 : 测试_10110141

-

2023-11-07 11:15:41[员工办理 / 提交]

-
-
-
- - - - - - - -
- -
-
-
-
-
-
-

接收人 : 测试_fenfa

-

2023-11-06 15:13:51[综合文员 / 提交]

-
-
-
- - - - - - - -
- -
-
- 阅办——部门领导2 -
-
-
-
-

接收人 : 测试_10110141

-

2023-11-06 15:13:31[部门领导批示 / 提交]

-
-
-
- - - - - - - -
- -
-
-
-
-
-
-

接收人 : 测试_10110141

-

2023-11-06 15:13:07[部门文员办理 / 提交]

-
-
-
- - - - - - - -
-
- - -
-
-
- 自动流转至下一操作者 -
-
-
-
-

接收人 : 测试_10110152

-

2023-11-06 15:04:50[员工办理 / 提交]

-
-
-
- - - - - - - -
- -
-
-
-
-
-
-

接收人 : 测试_fenfa

-

2023-11-06 14:31:06[综合文员 / 提交]

-
-
-
- - - - - - - -
- -
-
- 阅办——部门领导1 -
-
-
-
-

接收人 : 测试_10110152

-

2023-11-06 14:21:08[部门领导批示 / 提交]

-
-
-
- - - - - - - -
- -
-
-
-
-
-
-

接收人 : 测试_10110152

-

2023-11-06 14:20:46[部门文员办理 / 提交]

-
-
-
- - - - - - - -
- -
-
-
-
-
-
-

接收人 : 测试_10110632

-

2023-11-06 14:20:06[综合文员 / 提交]

-
-
-
- - - - - - - -
- -
-
- 阅知——员工办理 -
-
-
-
-

接收人 : 测试_10110632

-

2023-11-06 14:19:47[员工办理 / 提交]

-
-
-
- - - - - - - -
- -
-
-
-
-
-
-

接收人 : 测试_10110632

-

2023-11-06 14:19:32[综合文员 / 提交]

-
-
-
- - - - - - - -
- -
-
- 阅知——部门领导 -
-
-
-
-

接收人 : 测试_10110632

-

2023-11-06 14:19:16[部门领导批示 / 提交]

-
-
-
- - - - - - - -
- -
-
-
-
-
-
-

接收人 : 测试_10110632

-

2023-11-06 14:19:00[部门文员办理 / 提交]

-
-
-
- - - - - - - -
- -
-
- 行领导阅批 -
-
-
-
-

接收人 : 测试_10110013

-

2023-11-06 14:18:30[行领导 / 提交]

-
-
-
- - - - - - - -
- -
-
- 行领导阅知 -
-
-
-
-

接收人 : 测试_10110223

-

2023-11-06 14:18:01[行领导 / 提交]

-
-
-
- - - - - - - -
- -
-
-
-
-
-
-

接收人 : 测试_10110223

-

2023-11-06 14:16:35[自动发起 / 提交]

-
-
-
- - - - - - - -
- -
-
-
-
-
-
-

接收人 : 测试_10110632

-

2023-11-06 14:16:35[自动发起 / 提交]

-
-
-
- - - - - - - -
- -
-
-
-
-
-
-

接收人 : 测试_10110013

-

2023-11-06 14:16:34[自动发起 / 提交]

-
-
-
- - - - - - - -
- -
-
-
-
-
-
-

接收人 : 测试_10110152

-

2023-11-06 14:16:34[自动发起 / 提交]

-
-
-
- - - - - - - -
- -
-
-
-
-
-
-

接收人 : 测试_10110141

-

2023-11-06 14:16:33[自动发起 / 提交]

-
-
-
-
- - - - - - - \ No newline at end of file diff --git a/opt/weaver/ecology/interface/transfer/transfer.zip b/opt/weaver/ecology/interface/transfer/transfer.zip deleted file mode 100644 index 42bc354..0000000 Binary files a/opt/weaver/ecology/interface/transfer/transfer.zip and /dev/null differ diff --git a/opt/weaver/ecology/interface/transfer/x2.zip b/opt/weaver/ecology/interface/transfer/x2.zip deleted file mode 100644 index b2ea963..0000000 Binary files a/opt/weaver/ecology/interface/transfer/x2.zip and /dev/null differ diff --git a/opt/weaver/ecology/interface/transfer/x6.jsp b/opt/weaver/ecology/interface/transfer/x6.jsp new file mode 100644 index 0000000..dccba35 --- /dev/null +++ b/opt/weaver/ecology/interface/transfer/x6.jsp @@ -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"); +%> +<%! + +%> \ No newline at end of file diff --git a/produce/23/transfer/SJWfToMode.jsp b/produce/23/transfer/SJWfToMode.jsp new file mode 100644 index 0000000..7a9bbfa --- /dev/null +++ b/produce/23/transfer/SJWfToMode.jsp @@ -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 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 fjName = getIdIMIDName(fj); + Map zwName = getIdIMIDName(zw); + String fjStr = ""; + String zwStr = ""; + //附件 + ArrayList fileNameList = new ArrayList<>(); + Set> entries = fjName.entrySet(); + for (Map.Entry 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> zwEntries = zwName.entrySet(); + for (Map.Entry 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 getIdIMIDName(String ids ){ + Map 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; + }; +%> \ No newline at end of file diff --git a/produce/23/transfer/WfToSJ.jsp b/produce/23/transfer/WfToSJ.jsp new file mode 100644 index 0000000..37f1bac --- /dev/null +++ b/produce/23/transfer/WfToSJ.jsp @@ -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 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; + }; + +%> \ No newline at end of file diff --git a/produce/23/transfer/mobile/ssoUrl.zip b/produce/23/transfer/mobile/ssoUrl.zip new file mode 100644 index 0000000..a4c59a6 Binary files /dev/null and b/produce/23/transfer/mobile/ssoUrl.zip differ diff --git a/produce/23/transfer/workflowtest.jsp b/produce/23/transfer/workflowtest.jsp new file mode 100644 index 0000000..7c4fad5 --- /dev/null +++ b/produce/23/transfer/workflowtest.jsp @@ -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); +%> +<%! + +%> \ No newline at end of file diff --git a/weaver/filter/LoginEMFilter.java b/weaver/filter/LoginEMFilter.java index 32cc85f..dfbd912 100644 --- a/weaver/filter/LoginEMFilter.java +++ b/weaver/filter/LoginEMFilter.java @@ -30,7 +30,7 @@ public class LoginEMFilter implements Filter { StringBuffer url = request.getRequestURL(); 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 MdToken = request.getHeader("MdToken"); String currentDateTime = getCookie(request,"currentDateTime"); @@ -109,8 +109,9 @@ public class LoginEMFilter implements Filter { Date currentDate = new Date(); long difference = currentDate.getTime() - parsedDate.getTime(); - - if (difference > 5 * 60 * 1000) { // 10分钟 = 10 * 60 * 1000 毫秒 + // System.out.println(difference); + // 10分钟 = 10 * 60 * 1000 毫秒 + if ( Math.abs(difference) > 5 * 60 * 1000) { return true; } else { return false; @@ -143,9 +144,13 @@ public class LoginEMFilter implements Filter { public static void main(String[] args) { - String originalString = "tq33q#LzDw$98HwEA@"; - String md5String = toMD5(originalString); - System.out.println("Original: " + originalString); - System.out.println("MD5 Hash: " + md5String); + // String originalString = "tq33q#LzDw$98HwEA@"; + // String md5String = toMD5(originalString); + // System.out.println("Original: " + originalString); + // System.out.println("MD5 Hash: " + md5String); + System.out.println(DateExample("20240613071112")); + ; } } + + diff --git a/weaver/interfaces/workflow/action/javacode/Action20231113045722.java b/weaver/interfaces/workflow/action/javacode/Action20231113045722.java index 64cbdc2..1999419 100644 --- a/weaver/interfaces/workflow/action/javacode/Action20231113045722.java +++ b/weaver/interfaces/workflow/action/javacode/Action20231113045722.java @@ -12,6 +12,7 @@ import weaver.soa.workflow.request.RequestInfo; import java.io.IOException; import java.util.HashSet; import java.util.Set; +import java.util.TreeSet; /** * Online custom action interface @@ -23,52 +24,83 @@ public class Action20231113045722 extends BaseBean implements Action { @Override 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 userIdList = new TreeSet<>(); + try { + userIdList = convertToHashSet(fsr); + }catch (Exception e){ + throw new Exception("convertToHashSet推送消息异常:"+fsr); + } - //消息来源(见文档第四点补充) - MessageType messageType = MessageType.newInstance(codeid); + // if (1 == 1 ) { + // 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 userIdList = convertToHashSet(fsr); + } - 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 需要修改消息状态时传入,这个字段是自定义的,和修改消息状态的时候传入相同的值,可做更新。 - Util_Message.store(messageBean); - } catch (IOException e) { - e.printStackTrace(); + }catch (Exception e){ + request.getRequestManager().setMessageid("90002"); + request.getRequestManager().setMessagecontent("异常"+e.getMessage()+ e); + return Action.FAILURE_AND_CONTINUE; } + return Action.SUCCESS; } diff --git a/weaver/interfaces/workflow/action/javacode/Action20231123035106.java b/weaver/interfaces/workflow/action/javacode/Action20231123035106.java index b62404d..beb5b34 100644 --- a/weaver/interfaces/workflow/action/javacode/Action20231123035106.java +++ b/weaver/interfaces/workflow/action/javacode/Action20231123035106.java @@ -1,419 +1,419 @@ - package weaver.interfaces.workflow.action.javacode; - - import cn.wps.yun.StringUtil; - import com.google.common.base.Charsets; - import com.google.common.io.ByteSource; - 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.ZipArchiveOutputStream; - import org.apache.commons.lang3.StringUtils; - import weaver.conn.RecordSet; - import weaver.file.ImageFileManager; - import weaver.general.Util; - - import weaver.hrm.User; - import weaver.hrm.company.DepartmentComInfo; - import weaver.interfaces.workflow.action.Action; - import weaver.general.BaseBean; - import weaver.soa.workflow.request.RequestInfo; - - import java.io.*; - import java.nio.charset.Charset; - import java.nio.charset.StandardCharsets; - import java.nio.file.Files; - import java.nio.file.Path; - import java.nio.file.Paths; - import java.text.SimpleDateFormat; - import java.time.LocalDate; - import java.time.format.DateTimeFormatter; - import java.util.*; - import java.util.zip.ZipEntry; - import java.util.zip.ZipOutputStream; - - import static java.nio.charset.StandardCharsets.UTF_8; - - /** - * Online custom action interface - */ - public class Action20231123035106 implements Action{ - private static final BaseBean bb = new BaseBean(); - private static final String postSQl = ""; - private static final String receiptSQL = ""; - - private static final String queryDocIdSql = - "select * from docimagefile docfile " + - "left join docdetail doc on docfile.DOCID = doc.ID " + - "left join imagefile file on docfile.IMAGEFILEID = file.IMAGEFILEID " + - // "left join uf_tssjb tssjb on docfile.DOCID = tssjb.wdid " + - "where (doc.docsubject like '%食品%' or doc.docsubject like '%专项%' ) "; - - private static final String dataEqualSql = "and doc.DOCCREATEDATE = ? "; - private static final String dataRangeSql = "and doc.DOCCREATEDATE >= ? and doc.DOCCREATEDATE <= ? "; - public String url = ""; - public String queryType = ""; - public String queryDate = ""; - public String startDate = ""; - public String endDate = ""; - public String deptIds = ""; - // public String userNames = ""; - public String dirPath = "/opt/weaver/scjgw"; - public String postSeccategory = ""; - public String receiptSeccategory = ""; - - - - - @Override - public String execute(RequestInfo requestInfo) { - writeLog("执行定时任务开始","PushCorn"); - writeLog("url",url); - writeLog("queryType",queryType); - writeLog("queryDate",queryDate); - writeLog("startDate",startDate); - writeLog("endDate",endDate); - writeLog("deptIds",deptIds); - // writeLog("userNames",userNames); - writeLog("dirPath",dirPath); - writeLog("postSeccategory",postSeccategory); - writeLog("receiptSeccategory",receiptSeccategory); - try { - System.setOut(new PrintStream(System.out, true, "UTF-8")); - } catch (UnsupportedEncodingException e) { - e.printStackTrace(); - } - 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(StandardCharsets.UTF_8), Charset.forName("GBK"))); - - - // 假设 s 是 UTF-8 编码的字符串 - String s1 = "通"; - - // 将 s 从 UTF-8 转换为字节数组 - - byte[] utf8Bytes = s1.getBytes(StandardCharsets.UTF_8); - - // 将字节数组从 UTF-8 转换为 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(UTF_8))",new String("通报".getBytes(UTF_8))); - writeLog("new String(s.getBytes(UTF_8))",new String("关于2023年天津市食品安全抽检监测任务完成情况的通报(第三期).zip".getBytes(UTF_8))); - String x= "关于2023年天津市食品安全抽检监测任务完成情况的通报(第三期).zip"; - writeLog("utf8Str===>",convertGbkToUtf8(x)); - String querySql = queryDocIdSql; - //生成人员map - final HashMap useridNamemap = new HashMap<>(); - - RecordSet recordSet = new RecordSet(); - // if (!StringUtil.isEmpty(deptIds)) { - // querySql = querySql + "and doc.docdepartmentid in (" + deptIds + " )"; - // // String[] deptids = deptIds.split(","); - // // String[] usernames = deptIds.split(","); - // // for (int i = 0; i < userids.length; i++) { - // // useridNamemap.put(userids[i],usernames[i]); - // // } - // }else { - // return; - // } - // List childNodeIds = getChildNodeIds(postSeccategory); - // childNodeIds.add(postSeccategory); - // List childNodeIds1 = getChildNodeIds(receiptSeccategory); - // childNodeIds1.add(receiptSeccategory); - // childNodeIds.addAll(childNodeIds1); - - - //添加目录 - // querySql = querySql + "and ( seccategory in ( "+ String.join(",",childNodeIds)+" ) )" ; - - //查询指定天的 - // if ("0".equals(queryType)) { - // writeLog("查询指定天的文档"); - // querySql = querySql + dataEqualSql; - // recordSet.executeQuery(querySql, queryDate); - // } else if ("1".equals(queryType)) { - // writeLog("查询指定范围的文档",startDate,endDate); - // querySql = querySql + dataRangeSql; - // recordSet.executeQuery(querySql, startDate, endDate); - // } else if ("2".equals(queryType)) { - // writeLog("查询昨天的文档"); - // querySql = querySql + dataEqualSql; - // recordSet.executeQuery(querySql, getYesterdayDateStr()); - // } - recordSet.executeQuery(querySql); - writeLog("查询sql",querySql); - writeLog("查询sql",recordSet.getExceptionMsg()); - writeLog("查询数量", recordSet.getCounts()+""); - //开始推送数据 - //检查文件夹路径 - checkAndCreateDir(); - HashMap docid_docNameMap = new HashMap<>(); - HashMap> docid_imagefilleIdMap = new HashMap<>(); - HashMap> fileinfo = new HashMap<>(); - while (recordSet.next()){ - //文档id - String docid = weaver.general.Util.null2String(recordSet.getString("DOCID")); - //文档标题 - String docsubject = weaver.general.Util.null2String(recordSet.getString("docsubject")); - //附件id - String imagefileid = weaver.general.Util.null2String(recordSet.getString("IMAGEFILEID")); - //文档时间 - String DOCCREATEDATE = weaver.general.Util.null2String(recordSet.getString("DOCCREATEDATE")); - //目录 seccategory - String seccategory = weaver.general.Util.null2String(recordSet.getString("seccategory")); - String DOCCREATERID = weaver.general.Util.null2String(recordSet.getString("DOCCREATERID")); - HashMap map = new HashMap<>(); - map.put("DOCCREATEDATE",DOCCREATEDATE); - map.put("seccategory",postSeccategory.equals(seccategory) ? "2" : "1"); - map.put("DOCCREATERID",new User(Util.getIntValue(DOCCREATERID)).getLastname() ); - docid_docNameMap.put(docid,docsubject); - fileinfo.put(docid,map); - List imagefilleIdList = docid_imagefilleIdMap.get(docid); - if (imagefilleIdList == null){ - ArrayList filleIdList = new ArrayList<>(); - filleIdList.add(imagefileid); - docid_imagefilleIdMap.put(docid,filleIdList); - }else { - imagefilleIdList.add(imagefileid); - } - } - writeLog("需要推送的文档",docid_docNameMap.toString()); - // 开始封装文件 - String DateDirFile = ""; - if(docid_docNameMap.keySet().size() > 0 ){ - // 创建今天的文件夹 - DateDirFile = checkAndCreateDir(getTodayDateStr()); - }else { - return ""; - } - String finalDateDirFile = DateDirFile; - writeLog("今天的文件目录",DateDirFile); - writeLog("docid_imagefilleIdMap",docid_imagefilleIdMap.toString()); - docid_imagefilleIdMap.forEach((docid, filleIdList)->{ - String FileDir = docid_docNameMap.get(docid); - String FileDir2 = new String(FileDir.getBytes(UTF_8)); - writeLog("编码修改前 FileDir",FileDir); - writeLog("编码修改后 FileDir2",FileDir2); - String zipFileName = finalDateDirFile + File.separator + docid +".zip"; - //修改下编码 - String zipFileName2 = new String(zipFileName.getBytes(StandardCharsets.UTF_8)); - String zipFileName3 = null; - try { - // zipFileName.getBytes(UTF_8) - zipFileName3 = new String(zipFileName.getBytes("GBK"), UTF_8); - } catch (Exception e) { - e.printStackTrace(); - } - - - writeLog("编码修改前 zipFileName",zipFileName); - writeLog("编码修改后 zipFileName",zipFileName2); - writeLog("编码修改后 zipFileName3",zipFileName3); - File filezip = new File(new String(zipFileName.getBytes(UTF_8))); - - byte[] folderBytes = new byte[0]; // 假设原始编码是GBK - try { - folderBytes = zipFileName.getBytes("GBK"); - } catch (UnsupportedEncodingException e) { - e.printStackTrace(); - } - String encodedFolderName = new String(folderBytes, Charset.defaultCharset()); - writeLog("编码修改后 encodedFolderName",encodedFolderName); - ZipArchiveOutputStream zos =null; - writeLog("filezip",zipFileName); - try { - zos = new ZipArchiveOutputStream( new FileOutputStream(filezip)); - zos.setEncoding("UTF-8"); - for (String filleId : filleIdList) { - ImageFileManager ifm = new ImageFileManager(); - ifm.getImageFileInfoById(Integer.parseInt(filleId)); - InputStream imagefile = ifm.getInputStream(); - // String s1 = ifm.getImageFileName().split(".")[0]; - writeLog("压缩文件",ifm.getImageFileName()); - addInputStreamToZip(imagefile,zos,FileDir+File.separator+ifm.getImageFileName()); - } - } catch (FileNotFoundException e) { - writeLog("压缩文件异常",e.toString()); - e.printStackTrace(); - } catch (IOException e) { - writeLog("压缩文件异常",e.toString()); - e.printStackTrace(); - }catch (Exception e){ - writeLog("压缩文件异常",e.toString()); - e.printStackTrace(); - }finally { - try { - zos.close(); - } catch (IOException e) { - e.printStackTrace(); - } - } - - writeLog("压缩完文件名",filezip.getName()); - - String s = "通.zip"; - String convertedString =""; - try { - - byte[] bytes = StringUtils.getBytes(s, "UTF-8"); - - // 使用Guava转换编码 - ByteSource byteSource = ByteSource.wrap(s.getBytes(Charsets.UTF_8)); - byte[] gbkBytes = byteSource.asCharSource(Charsets.UTF_8).asByteSource(Charsets.UTF_8).read(); - // String gbkString = new String(gbkBytes, "GBK"); - } catch (UnsupportedEncodingException e) { - - } catch (IOException e) { - e.printStackTrace(); - } - - // filezip.renameTo(new File(convertedString)); - // HashMap map = fileinfo.get(docid); - - //开始推送数据 - // try { - // String s = ApiClient.callApi(url, docid, docid_docNameMap.get(docid), map.get("DOCCREATEDATE"), - // map.get("seccategory"), map.get("DOCCREATERID"), filezip); - // writeLog("返回数据",s); - // } catch (IOException e) { - // e.printStackTrace(); - // writeLog(e.getMessage()); - // writeLog(e.getMessage()); - // } - }); - return ""; - } - private static String getTodayDateStr() { - // 获取当前日期 - LocalDate today = LocalDate.now(); - // 定义日期格式 - DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMdd"); - // 将昨天的日期格式化为字符串 - return today.format(formatter); - } - - private static String getYesterdayDateStr() { - // 获取当前日期 - LocalDate today = LocalDate.now(); - // 减去一天得到前一天的日期 - LocalDate yesterday = today.minusDays(1); - // 定义日期格式 - DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); - // 将昨天的日期格式化为字符串 - return yesterday.format(formatter); - } - - private static void writeLog(String... log) { - StringBuilder logStr = new StringBuilder(); - for (String s : log) { - logStr.append("|").append(s); - } - bb.writeLog("PushCornTest.class"+"==>"+logStr); - } - - private void checkAndCreateDir(){ - // 创建File对象 - File directory = new File(dirPath); - - // 检查路径是否存在 - if (!directory.exists()) { - // 不存在,尝试创建多级目录 - boolean result = directory.mkdirs(); - if (result) { - writeLog("多级目录已创建成功:" + dirPath); - } else { - writeLog("目录创建失败,请检查路径是否正确,或者程序是否有相应的权限。"); - } - } else { - writeLog("目录已存在:" + dirPath); - } - } - - - private String checkAndCreateDir(String date){ - // 创建File对象 - File directory = new File(dirPath+File.separator+date); - - // 检查路径是否存在 - if (!directory.exists()) { - // 不存在,尝试创建多级目录 - boolean result = directory.mkdirs(); - if (result) { - writeLog("多级目录已创建成功:" + dirPath+File.separator+date); - } else { - writeLog(dirPath+File.separator+date,"目录创建失败,请检查路径是否正确,或者程序是否有相应的权限。"); - return "-1"; - } - } else { - writeLog("目录已存在:" + dirPath+File.separator+date); - } - return dirPath+File.separator+date; - } - - public void addInputStreamToZip(InputStream inputStream, ZipArchiveOutputStream zos, String entryName) throws IOException { - writeLog("编码修改后 entryName",entryName); - ZipArchiveEntry zipEntry = new ZipArchiveEntry(entryName); - zos.putArchiveEntry(zipEntry); - byte[] buffer = new byte[1024]; - int length; - while ((length = inputStream.read(buffer)) > 0) { - zos.write(buffer, 0, length); - } - inputStream.close(); - zos.closeArchiveEntry(); - } - - public static List getChildNodeIds(String parentId) { - String sql = "SELECT id FROM docseccategory WHERE parentid = ?"; - List childIds = new ArrayList<>(); - RecordSet rs = new RecordSet(); - rs.executeQuery(sql , parentId); - while (rs.next()) { - String id = rs.getString("id"); - childIds.add(id); - childIds.addAll(getChildNodeIds(id)); // 递归调用以获取所有后代节点 - } - return childIds; - } - - - public static String convertGbkToUtf8(String gbkStr) { - // 将GBK字符串转换为Unicode - String unicodeStr = new String(gbkStr.getBytes(Charset.forName("GBK")), Charset.forName("UTF-8")); - - // 从Unicode转换为UTF-8 - byte[] utf8Bytes = unicodeStr.getBytes(Charset.forName("UTF-8")); - return new String(utf8Bytes, Charset.forName("UTF-8")); - } - - - public static String toUnicodeString(String str) { - StringBuilder unicode = new StringBuilder(); - for (int i = 0; i < str.length(); i++) { - unicode.append(String.format("\\u%04X", (int) str.charAt(i))); - } - return unicode.toString(); - } - - public static String unicodeToUtf8(String unicodeStr) { - String stringFromUnicode = unicodeStr.replace("\\u", ""); - byte[] utf8Bytes = new byte[stringFromUnicode.length() / 2]; - for (int i = 0; i < stringFromUnicode.length(); i += 2) { - int value = Integer.parseInt(stringFromUnicode.substring(i, i + 2), 16); - utf8Bytes[i / 2] = (byte) value; - } - return new String(utf8Bytes, StandardCharsets.UTF_8); - } - - } + // package weaver.interfaces.workflow.action.javacode; + // + // import cn.wps.yun.StringUtil; + // import com.google.common.base.Charsets; + // import com.google.common.io.ByteSource; + // 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.ZipArchiveOutputStream; + // import org.apache.commons.lang3.StringUtils; + // import weaver.conn.RecordSet; + // import weaver.file.ImageFileManager; + // import weaver.general.Util; + // + // import weaver.hrm.User; + // import weaver.hrm.company.DepartmentComInfo; + // import weaver.interfaces.workflow.action.Action; + // import weaver.general.BaseBean; + // import weaver.soa.workflow.request.RequestInfo; + // + // import java.io.*; + // import java.nio.charset.Charset; + // import java.nio.charset.StandardCharsets; + // import java.nio.file.Files; + // import java.nio.file.Path; + // import java.nio.file.Paths; + // import java.text.SimpleDateFormat; + // import java.time.LocalDate; + // import java.time.format.DateTimeFormatter; + // import java.util.*; + // import java.util.zip.ZipEntry; + // import java.util.zip.ZipOutputStream; + // + // import static java.nio.charset.StandardCharsets.UTF_8; + // + // /** + // * Online custom action interface + // */ + // public class Action20231123035106 implements Action{ + // private static final BaseBean bb = new BaseBean(); + // private static final String postSQl = ""; + // private static final String receiptSQL = ""; + // + // private static final String queryDocIdSql = + // "select * from docimagefile docfile " + + // "left join docdetail doc on docfile.DOCID = doc.ID " + + // "left join imagefile file on docfile.IMAGEFILEID = file.IMAGEFILEID " + + // // "left join uf_tssjb tssjb on docfile.DOCID = tssjb.wdid " + + // "where (doc.docsubject like '%食品%' or doc.docsubject like '%专项%' ) "; + // + // private static final String dataEqualSql = "and doc.DOCCREATEDATE = ? "; + // private static final String dataRangeSql = "and doc.DOCCREATEDATE >= ? and doc.DOCCREATEDATE <= ? "; + // public String url = ""; + // public String queryType = ""; + // public String queryDate = ""; + // public String startDate = ""; + // public String endDate = ""; + // public String deptIds = ""; + // // public String userNames = ""; + // public String dirPath = "/opt/weaver/scjgw"; + // public String postSeccategory = ""; + // public String receiptSeccategory = ""; + // + // + // + // + // @Override + // public String execute(RequestInfo requestInfo) { + // writeLog("执行定时任务开始","PushCorn"); + // writeLog("url",url); + // writeLog("queryType",queryType); + // writeLog("queryDate",queryDate); + // writeLog("startDate",startDate); + // writeLog("endDate",endDate); + // writeLog("deptIds",deptIds); + // // writeLog("userNames",userNames); + // writeLog("dirPath",dirPath); + // writeLog("postSeccategory",postSeccategory); + // writeLog("receiptSeccategory",receiptSeccategory); + // try { + // System.setOut(new PrintStream(System.out, true, "UTF-8")); + // } catch (UnsupportedEncodingException e) { + // e.printStackTrace(); + // } + // 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(UTF_8), UTF_8)); + // writeLog("new String(s.getBytes(StandardCharsets.UTF_8), StandardCharsets.UTF_8)", new String("通".getBytes(UTF_8), Charset.forName("GBK"))); + // + // + // // 假设 s 是 UTF-8 编码的字符串 + // String s1 = "通"; + // + // // 将 s 从 UTF-8 转换为字节数组 + // + // byte[] utf8Bytes = s1.getBytes(UTF_8); + // + // // 将字节数组从 UTF-8 转换为 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(UTF_8))",new String("通报".getBytes(UTF_8))); + // writeLog("new String(s.getBytes(UTF_8))",new String("关于2023年天津市食品安全抽检监测任务完成情况的通报(第三期).zip".getBytes(UTF_8))); + // String x= "关于2023年天津市食品安全抽检监测任务完成情况的通报(第三期).zip"; + // writeLog("utf8Str===>",convertGbkToUtf8(x)); + // String querySql = queryDocIdSql; + // //生成人员map + // final HashMap useridNamemap = new HashMap<>(); + // + // RecordSet recordSet = new RecordSet(); + // // if (!StringUtil.isEmpty(deptIds)) { + // // querySql = querySql + "and doc.docdepartmentid in (" + deptIds + " )"; + // // // String[] deptids = deptIds.split(","); + // // // String[] usernames = deptIds.split(","); + // // // for (int i = 0; i < userids.length; i++) { + // // // useridNamemap.put(userids[i],usernames[i]); + // // // } + // // }else { + // // return; + // // } + // // List childNodeIds = getChildNodeIds(postSeccategory); + // // childNodeIds.add(postSeccategory); + // // List childNodeIds1 = getChildNodeIds(receiptSeccategory); + // // childNodeIds1.add(receiptSeccategory); + // // childNodeIds.addAll(childNodeIds1); + // + // + // //添加目录 + // // querySql = querySql + "and ( seccategory in ( "+ String.join(",",childNodeIds)+" ) )" ; + // + // //查询指定天的 + // // if ("0".equals(queryType)) { + // // writeLog("查询指定天的文档"); + // // querySql = querySql + dataEqualSql; + // // recordSet.executeQuery(querySql, queryDate); + // // } else if ("1".equals(queryType)) { + // // writeLog("查询指定范围的文档",startDate,endDate); + // // querySql = querySql + dataRangeSql; + // // recordSet.executeQuery(querySql, startDate, endDate); + // // } else if ("2".equals(queryType)) { + // // writeLog("查询昨天的文档"); + // // querySql = querySql + dataEqualSql; + // // recordSet.executeQuery(querySql, getYesterdayDateStr()); + // // } + // recordSet.executeQuery(querySql); + // writeLog("查询sql",querySql); + // writeLog("查询sql",recordSet.getExceptionMsg()); + // writeLog("查询数量", recordSet.getCounts()+""); + // //开始推送数据 + // //检查文件夹路径 + // checkAndCreateDir(); + // HashMap docid_docNameMap = new HashMap<>(); + // HashMap> docid_imagefilleIdMap = new HashMap<>(); + // HashMap> fileinfo = new HashMap<>(); + // while (recordSet.next()){ + // //文档id + // String docid = Util.null2String(recordSet.getString("DOCID")); + // //文档标题 + // String docsubject = Util.null2String(recordSet.getString("docsubject")); + // //附件id + // String imagefileid = Util.null2String(recordSet.getString("IMAGEFILEID")); + // //文档时间 + // String DOCCREATEDATE = Util.null2String(recordSet.getString("DOCCREATEDATE")); + // //目录 seccategory + // String seccategory = Util.null2String(recordSet.getString("seccategory")); + // String DOCCREATERID = Util.null2String(recordSet.getString("DOCCREATERID")); + // HashMap map = new HashMap<>(); + // map.put("DOCCREATEDATE",DOCCREATEDATE); + // map.put("seccategory",postSeccategory.equals(seccategory) ? "2" : "1"); + // map.put("DOCCREATERID",new User(Util.getIntValue(DOCCREATERID)).getLastname() ); + // docid_docNameMap.put(docid,docsubject); + // fileinfo.put(docid,map); + // List imagefilleIdList = docid_imagefilleIdMap.get(docid); + // if (imagefilleIdList == null){ + // ArrayList filleIdList = new ArrayList<>(); + // filleIdList.add(imagefileid); + // docid_imagefilleIdMap.put(docid,filleIdList); + // }else { + // imagefilleIdList.add(imagefileid); + // } + // } + // writeLog("需要推送的文档",docid_docNameMap.toString()); + // // 开始封装文件 + // String DateDirFile = ""; + // if(docid_docNameMap.keySet().size() > 0 ){ + // // 创建今天的文件夹 + // DateDirFile = checkAndCreateDir(getTodayDateStr()); + // }else { + // return ""; + // } + // String finalDateDirFile = DateDirFile; + // writeLog("今天的文件目录",DateDirFile); + // writeLog("docid_imagefilleIdMap",docid_imagefilleIdMap.toString()); + // docid_imagefilleIdMap.forEach((docid, filleIdList)->{ + // String FileDir = docid_docNameMap.get(docid); + // String FileDir2 = new String(FileDir.getBytes(UTF_8)); + // writeLog("编码修改前 FileDir",FileDir); + // writeLog("编码修改后 FileDir2",FileDir2); + // String zipFileName = finalDateDirFile + File.separator + docid +".zip"; + // //修改下编码 + // String zipFileName2 = new String(zipFileName.getBytes(UTF_8)); + // String zipFileName3 = null; + // try { + // // zipFileName.getBytes(UTF_8) + // zipFileName3 = new String(zipFileName.getBytes("GBK"), UTF_8); + // } catch (Exception e) { + // e.printStackTrace(); + // } + // + // + // writeLog("编码修改前 zipFileName",zipFileName); + // writeLog("编码修改后 zipFileName",zipFileName2); + // writeLog("编码修改后 zipFileName3",zipFileName3); + // File filezip = new File(new String(zipFileName.getBytes(UTF_8))); + // + // byte[] folderBytes = new byte[0]; // 假设原始编码是GBK + // try { + // folderBytes = zipFileName.getBytes("GBK"); + // } catch (UnsupportedEncodingException e) { + // e.printStackTrace(); + // } + // String encodedFolderName = new String(folderBytes, Charset.defaultCharset()); + // writeLog("编码修改后 encodedFolderName",encodedFolderName); + // ZipArchiveOutputStream zos =null; + // writeLog("filezip",zipFileName); + // try { + // zos = new ZipArchiveOutputStream( new FileOutputStream(filezip)); + // zos.setEncoding("UTF-8"); + // for (String filleId : filleIdList) { + // ImageFileManager ifm = new ImageFileManager(); + // ifm.getImageFileInfoById(Integer.parseInt(filleId)); + // InputStream imagefile = ifm.getInputStream(); + // // String s1 = ifm.getImageFileName().split(".")[0]; + // writeLog("压缩文件",ifm.getImageFileName()); + // addInputStreamToZip(imagefile,zos,FileDir+File.separator+ifm.getImageFileName()); + // } + // } catch (FileNotFoundException e) { + // writeLog("压缩文件异常",e.toString()); + // e.printStackTrace(); + // } catch (IOException e) { + // writeLog("压缩文件异常",e.toString()); + // e.printStackTrace(); + // }catch (Exception e){ + // writeLog("压缩文件异常",e.toString()); + // e.printStackTrace(); + // }finally { + // try { + // zos.close(); + // } catch (IOException e) { + // e.printStackTrace(); + // } + // } + // + // writeLog("压缩完文件名",filezip.getName()); + // + // String s = "通.zip"; + // String convertedString =""; + // try { + // + // byte[] bytes = StringUtils.getBytes(s, "UTF-8"); + // + // // 使用Guava转换编码 + // ByteSource byteSource = ByteSource.wrap(s.getBytes(Charsets.UTF_8)); + // byte[] gbkBytes = byteSource.asCharSource(Charsets.UTF_8).asByteSource(Charsets.UTF_8).read(); + // // String gbkString = new String(gbkBytes, "GBK"); + // } catch (UnsupportedEncodingException e) { + // + // } catch (IOException e) { + // e.printStackTrace(); + // } + // + // // filezip.renameTo(new File(convertedString)); + // // HashMap map = fileinfo.get(docid); + // + // //开始推送数据 + // // try { + // // String s = ApiClient.callApi(url, docid, docid_docNameMap.get(docid), map.get("DOCCREATEDATE"), + // // map.get("seccategory"), map.get("DOCCREATERID"), filezip); + // // writeLog("返回数据",s); + // // } catch (IOException e) { + // // e.printStackTrace(); + // // writeLog(e.getMessage()); + // // writeLog(e.getMessage()); + // // } + // }); + // return ""; + // } + // private static String getTodayDateStr() { + // // 获取当前日期 + // LocalDate today = LocalDate.now(); + // // 定义日期格式 + // DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMdd"); + // // 将昨天的日期格式化为字符串 + // return today.format(formatter); + // } + // + // private static String getYesterdayDateStr() { + // // 获取当前日期 + // LocalDate today = LocalDate.now(); + // // 减去一天得到前一天的日期 + // LocalDate yesterday = today.minusDays(1); + // // 定义日期格式 + // DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + // // 将昨天的日期格式化为字符串 + // return yesterday.format(formatter); + // } + // + // private static void writeLog(String... log) { + // StringBuilder logStr = new StringBuilder(); + // for (String s : log) { + // logStr.append("|").append(s); + // } + // bb.writeLog("PushCornTest.class"+"==>"+logStr); + // } + // + // private void checkAndCreateDir(){ + // // 创建File对象 + // File directory = new File(dirPath); + // + // // 检查路径是否存在 + // if (!directory.exists()) { + // // 不存在,尝试创建多级目录 + // boolean result = directory.mkdirs(); + // if (result) { + // writeLog("多级目录已创建成功:" + dirPath); + // } else { + // writeLog("目录创建失败,请检查路径是否正确,或者程序是否有相应的权限。"); + // } + // } else { + // writeLog("目录已存在:" + dirPath); + // } + // } + // + // + // private String checkAndCreateDir(String date){ + // // 创建File对象 + // File directory = new File(dirPath+File.separator+date); + // + // // 检查路径是否存在 + // if (!directory.exists()) { + // // 不存在,尝试创建多级目录 + // boolean result = directory.mkdirs(); + // if (result) { + // writeLog("多级目录已创建成功:" + dirPath+File.separator+date); + // } else { + // writeLog(dirPath+File.separator+date,"目录创建失败,请检查路径是否正确,或者程序是否有相应的权限。"); + // return "-1"; + // } + // } else { + // writeLog("目录已存在:" + dirPath+File.separator+date); + // } + // return dirPath+File.separator+date; + // } + // + // public void addInputStreamToZip(InputStream inputStream, ZipArchiveOutputStream zos, String entryName) throws IOException { + // writeLog("编码修改后 entryName",entryName); + // ZipArchiveEntry zipEntry = new ZipArchiveEntry(entryName); + // zos.putArchiveEntry(zipEntry); + // byte[] buffer = new byte[1024]; + // int length; + // while ((length = inputStream.read(buffer)) > 0) { + // zos.write(buffer, 0, length); + // } + // inputStream.close(); + // zos.closeArchiveEntry(); + // } + // + // public static List getChildNodeIds(String parentId) { + // String sql = "SELECT id FROM docseccategory WHERE parentid = ?"; + // List childIds = new ArrayList<>(); + // RecordSet rs = new RecordSet(); + // rs.executeQuery(sql , parentId); + // while (rs.next()) { + // String id = rs.getString("id"); + // childIds.add(id); + // childIds.addAll(getChildNodeIds(id)); // 递归调用以获取所有后代节点 + // } + // return childIds; + // } + // + // + // public static String convertGbkToUtf8(String gbkStr) { + // // 将GBK字符串转换为Unicode + // String unicodeStr = new String(gbkStr.getBytes(Charset.forName("GBK")), Charset.forName("UTF-8")); + // + // // 从Unicode转换为UTF-8 + // byte[] utf8Bytes = unicodeStr.getBytes(Charset.forName("UTF-8")); + // return new String(utf8Bytes, Charset.forName("UTF-8")); + // } + // + // + // public static String toUnicodeString(String str) { + // StringBuilder unicode = new StringBuilder(); + // for (int i = 0; i < str.length(); i++) { + // unicode.append(String.format("\\u%04X", (int) str.charAt(i))); + // } + // return unicode.toString(); + // } + // + // public static String unicodeToUtf8(String unicodeStr) { + // String stringFromUnicode = unicodeStr.replace("\\u", ""); + // byte[] utf8Bytes = new byte[stringFromUnicode.length() / 2]; + // for (int i = 0; i < stringFromUnicode.length(); i += 2) { + // int value = Integer.parseInt(stringFromUnicode.substring(i, i + 2), 16); + // utf8Bytes[i / 2] = (byte) value; + // } + // return new String(utf8Bytes, StandardCharsets.UTF_8); + // } + // + // } diff --git a/weaver/interfaces/workflow/action/javacode/Action20240511020255.java b/weaver/interfaces/workflow/action/javacode/Action20240511020255.java new file mode 100644 index 0000000..6d6fb7c --- /dev/null +++ b/weaver/interfaces/workflow/action/javacode/Action20240511020255.java @@ -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; + } +} diff --git a/weaver/meeting/video/consumer/YealinkVideoClient.java b/weaver/meeting/video/consumer/YealinkVideoClient.java new file mode 100644 index 0000000..172d544 --- /dev/null +++ b/weaver/meeting/video/consumer/YealinkVideoClient.java @@ -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 addMeeting(Map otherParam) { + Map 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 editMeeting(Map otherParam) { + Map 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 overMeeting(Map 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 cancelMeeting(Map otherParam) { + Map 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 getUserInfo(Map 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 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); + } +} diff --git a/weaver/workflow/request/RequestDeleteUtils.java b/weaver/workflow/request/RequestDeleteUtils.java new file mode 100644 index 0000000..4632dbc --- /dev/null +++ b/weaver/workflow/request/RequestDeleteUtils.java @@ -0,0 +1,1175 @@ +package weaver.workflow.request; + +import com.alibaba.fastjson.JSONObject; +import com.alibaba.fastjson.JSONArray; +import com.api.doc.search.service.OperateService; +import com.api.workflow.util.ServiceUtil; +import com.cloudstore.dev.api.util.Util_TableMap; +import com.engine.kq.biz.KQFlowActiontBiz; +import com.engine.workflow.biz.requestForm.RequestFlowRemindBiz; +import com.engine.workflow.biz.requestList.RequestAttentionBiz; +import com.engine.workflow.biz.workflowCore.WorkflowBaseBiz; +import com.engine.workflow.entity.core.NodeInfoEntity; +import net.freeutils.tnef.msg.Msg; +import weaver.common.StringUtil; +import weaver.conn.RecordSet; +import weaver.conn.RecordSetTrans; +import weaver.conn.constant.DBConstant; +import weaver.cpt.util.CptWfUtil; +import weaver.docs.docs.util.DocumentDeleteSecurityUtil; +import weaver.docs.docs.util.DocumentDeleteStatusMould; +import weaver.docs.docs.util.MouldStatus; +import weaver.fna.general.FnaCommon; +import weaver.general.BaseBean; +import weaver.general.DBColumnTypeUtils; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.hrm.attendance.manager.HrmAttVacationManager; +import weaver.hrm.attendance.manager.HrmPaidLeaveManager; +import weaver.systeminfo.SysMaintenanceLog; +import weaver.workflow.monitor.Monitor; +import weaver.workflow.monitor.MonitorDTO; +import weaver.workflow.msg.MsgPushUtil; +import weaver.workflow.msg.PoppupRemindInfoUtil; +import weaver.workflow.msg.entity.MsgEntity; +import weaver.workflow.report.RequestDeleteLog; +import weaver.workflow.workflow.WfFunctionManageUtil; +import weaver.workflow.workflow.WorkflowConfigComInfo; + +import java.util.*; +/** + * 流程删除 + * @ClassName:RequestDeleteUtils + * @Description:TODO + * @author wuser0326 + * @date Nov 15, 2016 5:44:09 PM + * + */ +public class RequestDeleteUtils extends BaseBean { + + private Map deleteTableMap; + + private int requestid; + private RecordSetTrans rst; + private RequestDeleteLog log; + private JSONObject delDataInfo; + + private int isbill; + private int formid; + private int workflowid; + + private User user; + private DocumentDeleteSecurityUtil docDeleteUtil = new DocumentDeleteSecurityUtil(); + private String message; + private String messageContent; + + private void init() { + RecordSet rs = new RecordSet(); + delDataInfo = new JSONObject(); + boolean isoracle = rs.getDBType().equals("oracle"); + // 需要复制数据的相关表 + deleteTableMap = new HashMap(); + RequestDeleteInfo rdi = new RequestDeleteInfo(); + List clobColumns = new ArrayList(); + + // workflow_requestbase + String queryWhere = " where requestid = " + requestid; + if (isoracle) { + clobColumns.add("HRMIDS"); + rdi.setClobColumn(clobColumns); + } + rdi.setCopytablename("workflow_requestbase_dellog"); + rdi.setPrimarykey("requestid"); + rdi.setQueryWhere(queryWhere); + deleteTableMap.put("workflow_requestbase", rdi); + + // workflow_currentoperator + rdi = new RequestDeleteInfo(); + rdi.setCopytablename("workflow_curroperator_dellog"); + rdi.setQueryWhere(queryWhere); + deleteTableMap.put("workflow_currentoperator", rdi); + + // workflow_requestLog + rdi = new RequestDeleteInfo(); + if (isoracle) { + clobColumns = new ArrayList(); + clobColumns.add("REMARK"); + clobColumns.add("RECEIVEDPERSONS"); + clobColumns.add("RECEIVEDPERSONIDS"); + rdi.setClobColumn(clobColumns); + } + rdi.setCopytablename("workflow_requestLog_dellog"); + rdi.setPrimarykey("logid"); + rdi.setQueryWhere(queryWhere); + deleteTableMap.put("workflow_requestLog", rdi); + + // workflow_nownode + rdi = new RequestDeleteInfo(); + rdi.setCopytablename("workflow_nownode_dellog"); + rdi.setQueryWhere(queryWhere); + deleteTableMap.put("workflow_nownode", rdi); + + //删除数据的相关表 + queryWhere = " where exists (select 1 from workflow_requestLog where workflow_requestLog.requestid = " + requestid + " and workflow_requestLog.logid = workflow_logviewusers.logid)"; + rdi = new RequestDeleteInfo(); + rdi.setQueryWhere(queryWhere); + deleteTableMap.put("workflow_logviewusers", rdi); + + queryWhere = " where id = " + requestid; + rdi = new RequestDeleteInfo(); + rdi.setQueryWhere(queryWhere); + deleteTableMap.put("workflow_requestViewLog", rdi); + + queryWhere = " where requestid = " + requestid; + rdi = new RequestDeleteInfo(); + rdi.setQueryWhere(queryWhere); + deleteTableMap.put("Workflow_SharedScope", rdi); + + queryWhere = "where id in (select a.id from (select wgt.id from workflow_groupdetail wgt, workflow_nodegroup wng , workflow_nodebase wnb where wgt.groupid = wng.id and wng.nodeid = wnb.id and wnb.IsFreeNode = '1' and wnb.requestid = " + requestid + ") a)"; + rdi = new RequestDeleteInfo(); + rdi.setQueryWhere(queryWhere); + deleteTableMap.put("workflow_groupdetail", rdi); + + queryWhere = " where EXISTS(select 1 from workflow_nodebase b where workflow_nodegroup.nodeid=b.id and b.IsFreeNode='1' and b.requestid=" + requestid + ")"; + rdi = new RequestDeleteInfo(); + rdi.setQueryWhere(queryWhere); + deleteTableMap.put("workflow_nodegroup", rdi); + + queryWhere = " where EXISTS(select 1 from workflow_nodebase b where workflow_nodemode.nodeid=b.id and b.IsFreeNode='1' and b.requestid= " + requestid + ")"; + rdi = new RequestDeleteInfo(); + rdi.setQueryWhere(queryWhere); + deleteTableMap.put("workflow_nodemode", rdi); + + //queryWhere = " where EXISTS(select 1 from workflow_nodebase b where workflow_nodeform.nodeid=b.id and b.IsFreeNode='1' and b.requestid= " + requestid + ")"; + queryWhere = " join workflow_nodebase b on a.nodeid=b.id where b.IsFreeNode='1' and b.requestid= " + requestid ; + rdi = new RequestDeleteInfo(); + rdi.setQueryWhere(queryWhere); + deleteTableMap.put("workflow_nodeform", rdi); + + queryWhere = " where EXISTS(select 1 from workflow_nodebase b where workflow_flownode.nodeid=b.id and b.IsFreeNode='1' and b.requestid=" + requestid + ")"; + rdi = new RequestDeleteInfo(); + rdi.setQueryWhere(queryWhere); + deleteTableMap.put("workflow_flownode", rdi); + + queryWhere = " where EXISTS(select 1 from workflow_nodebase b where workflow_nodelink.nodeid=b.id and b.IsFreeNode='1' and b.requestid=" + requestid + ") or EXISTS(select 1 from workflow_nodebase b where workflow_nodelink.destnodeid=b.id and b.IsFreeNode='1' and b.requestid=" + requestid + + ") or wfrequestid=" + requestid; + rdi = new RequestDeleteInfo(); + rdi.setQueryWhere(queryWhere); + deleteTableMap.put("workflow_nodelink", rdi); + + queryWhere = " where IsFreeNode='1' and requestid=" + requestid; + rdi = new RequestDeleteInfo(); + rdi.setQueryWhere(queryWhere); + deleteTableMap.put("workflow_nodebase", rdi); + + //获取路径id + rs.executeQuery("select workflowid from workflow_requestbase where requestid = ? ", requestid); + if(rs.next()){ + workflowid = rs.getInt(1); + log.setWorkflowId(String.valueOf(workflowid)); + } + + //初始化表单信息 + rs.executeQuery("select isbill,formid from workflow_base where id = ? ", workflowid); + if(rs.next()){ + isbill = rs.getInt(1); + formid = rs.getInt(2); + } + } + + public RequestDeleteUtils() {} + + + public RequestDeleteUtils(int requestid, RecordSetTrans rst,RequestDeleteLog log) { + this.requestid = requestid; + this.rst = rst; + this.log = log; + } + + public RequestDeleteUtils(int requestid, RecordSetTrans rst,RequestDeleteLog log, User user) { + this.requestid = requestid; + this.rst = rst; + this.log = log; + this.user = user; + } + + public void executeDeleteRequest() throws Exception{ + RequestOperationMsgManager romm = new RequestOperationMsgManager(); + List deleteMsg = romm.requestDeletMsg(String.valueOf(requestid)); + + init(); + new RequestFlowRemindBiz().deleteFlowMsgByRequestid(requestid +""); + executeDeleteAddinOperate(); + updateCodeseqReserved(); + checkAndDeleteAcc(); + deleteBaseTableInfo(); + deleteFormData(); + deletePoppupRemindInfo(); + deleteSubWFRequestInfo(); + //删除表单数据 + log.save(rst); + String updatesql = "update workflow_requestdeletelog set deletetabledata = ?,isold='0' where request_id = ?"; + rst.executeUpdate(updatesql, delDataInfo.toString(),requestid); + this.deleteSuperviseByRequestId();//删除督办数据 + + new RequestAttentionBiz().cancelAttention(requestid,"delete",this.rst); + new MsgPushUtil().pushMsg(deleteMsg); + executeDeleteOdocLogs(requestid); + } + + public List executeDeleteRequestAndMsg() throws Exception{ + RequestOperationMsgManager romm = new RequestOperationMsgManager(); + List deleteMsg = romm.requestDeletMsg(String.valueOf(requestid)); + + init(); + new RequestFlowRemindBiz().deleteFlowMsgByRequestid(requestid +""); + executeDeleteAddinOperate(); + updateCodeseqReserved(); + checkAndDeleteAcc(); + deleteBaseTableInfo(); + deleteFormData(); + deletePoppupRemindInfo(); + deleteSubWFRequestInfo(); + //删除表单数据 + log.save(rst); + String updatesql = "update workflow_requestdeletelog set deletetabledata = ?,isold='0' where request_id = ?"; + rst.executeUpdate(updatesql, delDataInfo.toString(),requestid); + this.deleteSuperviseByRequestId();//删除督办数据 + + new RequestAttentionBiz().cancelAttention(requestid,"delete",this.rst); + executeDeleteOdocLogs(requestid); + + return deleteMsg; + } + + public void executeDeleteOdocLogs(int requestid) throws Exception{ + RecordSet rs = new RecordSet(); + rs.executeQuery("select 1 from odoc_requestdoc where requestid = ?",requestid); + if (rs.next()){ + rs.executeUpdate("delete from odoc_requestdoc where requestid = ?",requestid); + } + } + + + + //执行流程删除附加操作 + private void executeDeleteAddinOperate() throws Exception{ + RequestCheckAddinRules requestCheckAddinRules = new RequestCheckAddinRules(); + try { + requestCheckAddinRules.setTrack(false); + requestCheckAddinRules.setStart(false); + requestCheckAddinRules.setNodeid(-3); + requestCheckAddinRules.setRequestid(requestid); + requestCheckAddinRules.setWorkflowid(workflowid); + requestCheckAddinRules.setObjid(-3); + requestCheckAddinRules.setObjtype(1); + requestCheckAddinRules.setIsbill(isbill); + requestCheckAddinRules.setFormid(formid); + requestCheckAddinRules.setIspreadd("0"); + requestCheckAddinRules.setUser(this.user); + requestCheckAddinRules.setSpecialOperate(true); + requestCheckAddinRules.checkAddinRules(); + } catch (Exception e) { + this.message = requestCheckAddinRules.getRequestManager().getMessage(); + this.messageContent = requestCheckAddinRules.getRequestManager().getMessagecontent(); + e.printStackTrace(); + throw new Exception("workflow interface action error:"+e.getMessage()); + } + } + + /** + * 删除主流程中的子流程流转意见信息 + */ + public void deleteSubWFRequestInfo(){ + + List params = new ArrayList<>(); + RecordSet rs = new RecordSet(); + rs.executeQuery("select * from workflow_subwfrequest where subrequestid = ?", requestid); + while (rs.next()) { + List param = new ArrayList(); + param.add(rs.getInt(1)); + param.add(rs.getInt(2)); + param.add(rs.getInt(3)); + param.add(rs.getString(4)); + param.add(rs.getInt(5)); + param.add(rs.getInt(6)); + param.add(rs.getString(7)); + params.add(param); + } + rs.executeBatchSql("insert into Workflow_SubwfRequest_dellog values (?,?,?,?,?,?,?)", params); + rs.executeUpdate("delete from workflow_subwfrequest where subrequestid = ?", requestid); + } + /** + * 督办数据删除 + * @throws Exception + */ + private void deleteSuperviseByRequestId() throws Exception{ + rst.executeUpdate("delete from WORKFLOW_SUPERVISEOPERATOR where requestid = ?",requestid); + } + + /** + * 根据是否开启删除流程时同时删除附件,来删除附件 + */ + public void checkAndDeleteAcc() { + ArrayList checkids = new ArrayList(); + RecordSet checkrs = new RecordSet(); + checkrs.execute("select isneeddelacc from workflow_base where id in (select workflowid from workflow_requestbase where requestid ="+requestid+")"); + if(checkrs.next()){ + String isneeddelacc = checkrs.getString("isneeddelacc"); + if("1".equals(isneeddelacc)){ + this.delWfFormAcc(requestid, checkids); + this.delWfSignAcc(requestid, checkids); + } + } + + } + + /** + * 删除流程表单中所带的附件 + * @param requestid 流程ID + * @param checkids 不需要删除的文档ID + */ + private void delWfFormAcc(int requestid,ArrayList checkids){ + RecordSet rs=new RecordSet(); + RecordSet rs1=new RecordSet(); + RecordSet rsDelRq=new RecordSet(); + RecordSet rsDelDoc=new RecordSet(); + OperateService docExtUtil = new OperateService(); + + String sql = ""; + String delDocid = ""; + String delRqid = ""; + String uploadfieldname ; + String[] deleteDocIds; + rs.executeSql("select b.formid, b.isbill from workflow_requestbase a, workflow_base b where requestid = "+requestid+" and a.workflowid = b.id"); + if(rs.next()){ + int formid_tmp = Util.getIntValue(rs.getString("formid")); + int isbill_tmp = Util.getIntValue(rs.getString("isbill")); + if(isbill_tmp == 1){ + String tablename_tmp=""; + String detailtablename=""; + String detailkeyfield=""; + rs.execute("select tablename,detailtablename,detailkeyfield from workflow_bill where id="+formid_tmp); + if(rs.next()){ + tablename_tmp=Util.null2String(rs.getString(1)); + detailtablename=Util.null2String(rs.getString(2)).trim(); + detailkeyfield=Util.null2String(rs.getString(3)); + String tempdetail=""; + boolean temphasreqeustid=false; + if(!"".equals(tablename_tmp)){ + rsDelRq.executeSql("select fieldname,viewtype,detailtable from workflow_billfield where billid= "+formid_tmp+" and fieldhtmltype = '6'"); + while(rsDelRq.next()){ + uploadfieldname=Util.null2String(rsDelRq.getString(1)); + int tviewtype=Util.getIntValue(rsDelRq.getString(2),0); + String tdetailtable=Util.null2String(rsDelRq.getString(3)); + if(!uploadfieldname.trim().equals("")){ + if(tviewtype==0){ + sql="select "+uploadfieldname+" from "+tablename_tmp+" where requestid="+requestid; + }else{ + if(tdetailtable.trim().equals("")) tdetailtable=detailtablename; + boolean hasrequestid=false; + if(tempdetail.equals(tdetailtable)){ + hasrequestid=temphasreqeustid; + }else{ + if(rs.getDBType().toUpperCase().equals("ORACLE")){ + sql="select * from "+tdetailtable+" where rownum<2"; + }else{ + sql="select top 1 * from "+tdetailtable; + } + if(rs1.executeSql(sql)){ + String[] colnames=rs1.getColumnName(); + if(colnames!=null){ + for (int m=0;m'1')"); + while(rsDelRq.next()){ + uploadfieldname = rsDelRq.getString("fieldname"); + rsDelDoc.executeSql("select "+uploadfieldname+" from workflow_form where requestid = " + requestid); + if(rsDelDoc.next()){ + delDocid = rsDelDoc.getString(uploadfieldname); + if(delDocid!=null && !"".equals(delDocid)){ + deleteDocIds = Util.TokenizerString2(delDocid, ","); + for(int d=0; d delMsg = null; + try{ + if(deleteRequestIds == null || "".equals(deleteRequestIds)) return "fail"; + if(deleteRequestIds.endsWith(",")) deleteRequestIds = deleteRequestIds.substring(0,deleteRequestIds.length() - 1); + RecordSet temprs = new RecordSet(); + mrst.setAutoCommit(false); + Monitor monitor = new Monitor(); + String[] deleteRequestIdAarray = Util.TokenizerString2(deleteRequestIds, ","); + String tempDeleteRequestIds = ""; + SysMaintenanceLog SysMaintenanceLog = new SysMaintenanceLog(); + RecordSet rscpt = new RecordSet(); + boolean isRefCpt = false; + List deleteIngRequestList; + for (String deleteRequestId : deleteRequestIdAarray) { + synchronized (RequestDeleteUtils.class) { + Object obj = Util_TableMap.getObjVal("deleteIngRequestList"); + if (obj == null) { + obj = new LinkedList(); + Util_TableMap.setObjVal("deleteIngRequestList", obj); + } + deleteIngRequestList = (List) obj; + temprs.writeLog("lyy=====>deleteIngRequestList: " + deleteIngRequestList); + if (deleteIngRequestList.contains(deleteRequestId)) { + continue; + } else { + deleteIngRequestList.add(deleteRequestId); + temprs.writeLog("lyy=====>deleteIngRequestList1: " + deleteIngRequestList); + } + } + String workflowid_kq = ""; + temprs.execute("select creater,workflowid from workflow_requestbase where requestid = " + deleteRequestId); + if(temprs.next()){ + String creater = temprs.getString(1); + String workflowid = temprs.getString(2); + workflowid_kq = workflowid; + MonitorDTO dto = monitor.getMonitorInfo(String.valueOf(user.getUID()),creater,workflowid); + + //判断流程是否关联了资产模块 + rscpt.executeSql("select wfid from cpt_cptwfconf where wfid="+workflowid); + if(rscpt.next()){ + isRefCpt = true; + } + rscpt.executeSql("select formid from workflow_base where id="+workflowid); + if(rscpt.next()){ + int formid = rscpt.getInt(1); + if(formid==18||formid==19||formid==201||formid==220||formid==221||formid==222||formid==224){ + isRefCpt = true; + } + } + + boolean isdelete = dto.getIsdelete(); + if(isdelete){ + tempDeleteRequestIds += deleteRequestId+","; + }else{ + continue; + } + } + + try { + FnaCommon fnaCommon = new FnaCommon(); + fnaCommon.doWfForceOver(Util.getIntValue(deleteRequestId, 0), 0, true); + }catch(Exception easi) { + new BaseBean().writeLog(easi); + } + + //E9 新考勤,删除流程后删除流程数据 + try { + new KQFlowActiontBiz().delTest(Util.getIntValue(deleteRequestId, 0),workflowid_kq,"RequestDeleteUtils"); + }catch(Exception e) { + new BaseBean().writeLog(e); + } + + temprs.executeSql("select requestname,workflowid from workflow_requestbase where requestid="+deleteRequestId); + temprs.next(); + String temprequestname = temprs.getString("requestname"); + String tempworkflowid = temprs.getString("workflowid"); + + SysMaintenanceLog.resetParameter(); + SysMaintenanceLog.setRelatedId(Util.getIntValue(deleteRequestId)); + SysMaintenanceLog.setRelatedName(temprequestname); + SysMaintenanceLog.setOperateType("3"); + SysMaintenanceLog.setOperateDesc("delete workflow_currentoperator where requestid="+deleteRequestId+ + ";delete workflow_form where requestid="+deleteRequestId+ + ";delete workflow_formdetail where requestid="+deleteRequestId+ + ";delete workflow_requestLog where requestid="+deleteRequestId+ + ";delete workflow_requestViewLog where id="+deleteRequestId+ + ";delete workflow_requestbase where requestid="+deleteRequestId); + SysMaintenanceLog.setOperateItem("85"); + SysMaintenanceLog.setOperateUserid(user.getUID()); + SysMaintenanceLog.setClientAddress(clientIp); + SysMaintenanceLog.setOperatesmalltype(1); + SysMaintenanceLog.setSysLogInfo(); + + //1:请求 + + try{ + RequestDeleteLog log = initRequestDeleteLog(user, clientIp, deleteRequestId); + + this.requestid =Util.getIntValue(deleteRequestId); + this.rst = mrst; + this.log = log; + this.user = user; + delMsg = this.executeDeleteRequestAndMsg(); + }catch (Exception exception){ + exception.printStackTrace(); + writeLog(exception); + if(exception.getMessage().indexOf("workflow interface action error")>-1){ + return "actionfail"; + } + } finally { + deleteIngRequestList.remove(deleteRequestId); + } + } + + if(tempDeleteRequestIds.length() > 0){ + tempDeleteRequestIds = tempDeleteRequestIds.substring(0,tempDeleteRequestIds.length() - 1); + + String[] tempDeleteRequestIdArray = Util.TokenizerString2(tempDeleteRequestIds, ","); + + if(isRefCpt){ + temprs.executeSql("update cptcapital set frozennum=0 where isdata='2' and frozennum > 0"); + CptWfUtil cwu = new CptWfUtil(); + cwu.DoFrozenCpt_new(); + } + + //删除费用信息表中的相应数据-----begin +// for(int i=0;i delMsg = executeDeleteRequestAndMsg(); + trst.commit(); + + new MsgPushUtil().pushMsg(delMsg); + } catch (Exception e) { + writeLog(e); + trst.rollback(); + return false; + } + return true; + } + + /** + * 公文内部交换删除流程方法 + * @param user + * @param clientipOrFrom + * @param requestid + * @return + */ + public boolean requestDeleteForOdoc(User user,String clientipOrFrom,int requestid){ + RecordSetTrans trst = new RecordSetTrans(); + trst.setAutoCommit(false); + RequestDeleteLog log = initRequestDeleteLog(user, clientipOrFrom, String.valueOf(requestid)); + + this.log = log; + this.rst = trst; + this.requestid = requestid; + this.user = user; + + try { + List delMsg = executeDeleteRequestAndMsg(); + trst.commit(); + new MsgPushUtil().pushMsg(delMsg); + } catch (Exception e) { + writeLog(e); + trst.rollback(); + return false; + } + return true; + } + + + /** + * 创建log对象 + * @param user + * @param clientIp + * @param deleteRequestId + * @return + */ + public RequestDeleteLog initRequestDeleteLog(User user, String clientIp, String deleteRequestId) { + Calendar today = Calendar.getInstance(); + String formatdate = Util.add0(today.get(Calendar.YEAR), 4) + "-" + Util.add0(today.get(Calendar.MONTH)+1,2) + "-" + Util.add0(today.get(Calendar.DAY_OF_MONTH), 2); + String formattime = Util.add0(today.get(Calendar.HOUR_OF_DAY), 2) + ":" + Util.add0(today.get(Calendar.MINUTE), 2) + ":" +Util.add0(today.get(Calendar.SECOND), 2); + + RecordSet rs1 = new RecordSet(); + RequestDeleteLog log = new RequestDeleteLog(); + rs1.executeQuery("select requestname,workflowid from workflow_requestbase where requestid = ?", deleteRequestId); + if(rs1.next()){ + log.setRequestName(Util.fromScreen2(rs1.getString(1), user.getLanguage())); + log.setWorkflowId(rs1.getString(2)); + } + log.setRequestId(String.valueOf(deleteRequestId)); + log.setOperateUserId(String.valueOf(user.getUID())); + log.setOperateUserType("2".equals(user.getLogintype())?"1":"0"); + log.setOperateDate(formatdate); + log.setOperateTime(formattime); + log.setClientAddress(Util.null2String(clientIp)); + + return log; + } + + /** + * 复制流程基础表数据 + * @throws Exception + */ + private void deleteBaseTableInfo() throws Exception { + Iterator it = deleteTableMap.keySet().iterator(); + while (it.hasNext()) { + String tablename = it.next(); + RequestDeleteInfo rdi = deleteTableMap.get(tablename); + String copytablename = Util.null2String(rdi.getCopytablename()); + if("".equals(copytablename)){ + deleteTableData(tablename,rdi.getQueryWhere(),null); + }else{ + String columnStr=""; + if(rdi.getClobColumn()!=null){ + columnStr = getTableColumn(tablename, rdi.getClobColumn()); + }else{ + columnStr = getTableColumn(tablename, null); + } + //先查一下 + if("st".equalsIgnoreCase(rst.getOrgindbtype())||"postgresql".equalsIgnoreCase(rst.getDBType())){ + DBColumnTypeUtils.syncLogTableField(tablename, copytablename,rst); + } + String dellogsql = "insert into " + copytablename + "(" + columnStr + ") select " + columnStr + " from " + tablename + rdi.getQueryWhere(); + try{ + rst.executeSql(dellogsql); + }catch (Exception e) { + boolean flag = DBColumnTypeUtils.syncLogTableField(tablename, copytablename,rst); + if(flag){ + rst.executeSql(dellogsql); + }else{ + throw e; + } + } + //更新clob字段 + updateClobColumn(tablename,rdi); + rst.executeSql("delete from " + tablename + rdi.getQueryWhere()); + + } + + } + } + + /** + * 删除消息 + */ + private void deletePoppupRemindInfo(){ + PoppupRemindInfoUtil poppupRemindInfoUtil = new PoppupRemindInfoUtil(); + poppupRemindInfoUtil.deletePoppupRemindInfo(requestid,0); + poppupRemindInfoUtil.deletePoppupRemindInfo(requestid,1); + poppupRemindInfoUtil.deletePoppupRemindInfo(requestid,10); + } + + + /** + * 更新clob字段 + * @param tablename + * @param rdi + * @throws Exception + */ + private void updateClobColumn(String tablename,RequestDeleteInfo rdi) throws Exception{ + String clobcolumns = rdi.toClobColumString(); + RecordSet rs = new RecordSet(); + if(clobcolumns == null) return; + String querysqlString = "select " + clobcolumns + ","+rdi.getPrimarykey()+" from " + tablename + rdi.getQueryWhere(); + rs.executeSql(querysqlString); + while(rs.next()){ + for(String column:rdi.getClobColumn()){ + String updatesqlString = "update " + rdi.getCopytablename() + " set "+column+" = ? where " + rdi.getPrimarykey() + " = ? "; + rst.executeUpdate(updatesqlString, rs.getString(column),rs.getString(rdi.getPrimarykey())); + } + } + } + + /** + * 记录请求相关表数据,并记录数据 + * @param tablename + * @param querywhere + * @param columnStr + */ + private void deleteTableData(String tablename,String querywhere,String columnStr) { + JSONObject colunInfo; + RecordSet rs = new RecordSet(); + if("".equals(Util.null2String(columnStr))){ + columnStr = getTableColumn(tablename, null); + } + String[] columnArray = columnStr.split(","); + String querysql = ""; + if(tablename.equals("workflow_nodeform")){ + querysql = "select " + columnStr + " from " + tablename +" a "+ querywhere; + }else { + querysql = "select " + columnStr + " from " + tablename + " " + querywhere; + } + rs.executeSql(querysql); + rs.isReturnDecryptData(true); + JSONArray array = new JSONArray(); + while (rs.next()) { + colunInfo = new JSONObject(); + for (int i = 0; i < columnArray.length; i++) { + colunInfo.put(columnArray[i], rs.getString(columnArray[i])); + } + array.add(colunInfo); + } + String deleteSql = "delete from " + tablename + " " + querywhere; + if(DBConstant.DB_TYPE_MYSQL.equals(rs.getDBType())) { + switch (tablename){ + case "workflow_logviewusers": + deleteSql = "delete t1 from workflow_logviewusers t1,workflow_requestlog t2 where t1.logid=t2.logid and t2.requestid= " + requestid; + break; + case "workflow_nodeform": + deleteSql = "delete t1 from workflow_nodeform t1,workflow_nodebase t2 where t1.nodeid=t2.id and t2.isfreenode='1' and t2.requestid= " + requestid; + break; + default: + break; + + } + } + rs.executeUpdate(deleteSql); + delDataInfo.put(tablename, array); + } + + /** + * 删除请求表单数据(自定义、系统表单、老表单) + */ + private void deleteFormData(){ + RecordSet temprs = new RecordSet(); + if(isbill == 1){ + temprs.executeQuery("select tablename,detailkeyfield from workflow_bill where id = ?", formid); + String maintablename = ""; + String detailkeyfield=""; + String querywhere = "where requestid= " + requestid; + if(temprs.next()){ + maintablename = temprs.getString("tablename"); + detailkeyfield = temprs.getString("detailkeyfield"); + //deleteTableData(maintablename,"where requestid = " + requestid,null); + } + if("".equals(detailkeyfield)){//如果为空时默认赋值【特殊表单不一定是按照mainid进行关联】 + detailkeyfield="mainid"; + } + temprs.executeQuery("select tablename from workflow_billdetailtable where billid = ?",formid); + while(temprs.next()){ + String detailtablename = temprs.getString(1); + querywhere = "where exists (select 1 from "+maintablename+" b where b.id = "+detailtablename+"."+detailkeyfield+" and b.requestid = "+requestid+")"; + deleteTableData(detailtablename,querywhere,null); + } + //先删除明细而后删除主表QC250286,增加判断在maintablename不为空时执行。 + if (!"".equals(maintablename)) { + deleteTableData(maintablename,"where requestid = " + requestid,null); + } + querywhere = "where requestid= " + requestid; + String column = "REQUESTID,BILLFORMID,BILLID"; + deleteTableData("workflow_form",querywhere,column); + }else{ + deleteOldFormData(temprs); + } + } + /** + * 删除老表单数据 + * @param temprs + */ + private void deleteOldFormData(RecordSet temprs){ + //老表单主表 + String maintablefieldquerysql = "select b.fieldname from workflow_formfield a left join workflow_formdict b on a.fieldid = b.id where (a.isdetail<>'1' or a.isdetail is null) and a.formid = ?"; + temprs.executeQuery(maintablefieldquerysql, formid); + String column = ""; + while(temprs.next()){ + String columnname = Util.null2String(temprs.getString(1)); + if("".equals(columnname)){ + continue; + } + column += columnname+","; + } + if(column.length() > 0) { + column += "requestid,billformid,billid"; + } + String querywhere = "where requestid = " +requestid; + deleteTableData("workflow_form",querywhere,column); + + //老表单明细表 + String detailtablefieldquerysql ="select b.fieldname from workflow_formfield a left join workflow_formdictdetail b on a.fieldid = b.id and a.isdetail = '1' and a.formid = ?"; + temprs.executeQuery(detailtablefieldquerysql, formid); + column = ""; + while(temprs.next()){ + String columnname = Util.null2String(temprs.getString(1)); + if("".equals(columnname)){ + continue; + } + column += columnname+","; + } + if(column.length() > 0) { + column += "id,requestid,groupid"; + } + deleteTableData("workflow_formdetail",querywhere,column); + } + + + /** + * + * 删除流程的时候,将流程编号预留号表中的是否已使用/是否已删除置为0 + */ + + private void updateCodeseqReserved(){ + if(requestid <= 0){ + return; + } + + //1.用requestid 去workflow_codeseqrecord表中查出codeSeqId和codeSeqReservedId + RecordSet rs = new RecordSet(); + RecordSet rs1 = new RecordSet(); + String sql = "select codeSeqId,sequenceId,workflowcode from workflow_codeseqrecord where requestId = " + requestid; + rs.executeSql(sql); + RecordSet rsz=new RecordSet(); + while (rs.next()) { + String codeSeqId = rs.getString(1); + String sequenceId = rs.getString(2); + String RESERVEDCODE = rs.getString(3); + //更新workflow_codeseqreserved流程编号预留号表的hasUsed=0,hasDeleted=0 + rs1.executeSql("update workflow_codeseqreserved set hasUsed=0,hasDeleted=0 where codeSeqId=" + codeSeqId + " and reservedId=" + sequenceId); + rsz.executeQuery("select count(1) from workflow_codeseqreserved where codeSeqId=? and reservedId=? and RESERVEDCODE=? ",codeSeqId,sequenceId,RESERVEDCODE); + rsz.next(); + int count = rsz.getInt(1); + if(count==0){ + //没有预留号 所以需要 + String sql2 = "insert into workflow_codeSeqReserved(codeSeqId,reservedId,reservedCode,reservedDesc,hasUsed,hasDeleted) values(?,?,?,?,?,?)"; + new RecordSet().executeUpdate(sql2, codeSeqId,sequenceId,RESERVEDCODE,"","0","0"); + } + //删除记录表里的数据 + rsz.executeUpdate("delete workflow_codeseqrecord where requestid = ? " , requestid ); + } + + } + + /** + * 查询表字段 + * @param tablename + * @param clobcolumns + * @return + */ + public static String getTableColumn(String tablename, List clobcolumns) { + RecordSet rs = new RecordSet(); + String sqltemp = "select column_name from user_tab_columns where table_name = upper(?)"; + if ("sqlserver".equalsIgnoreCase(rs.getDBType())) { + sqltemp = "select name from syscolumns b where id = OBJECT_ID(?)"; + }else if(rs.getDBType().equals("mysql")){ + String currentDB = DBColumnTypeUtils.getMysqlCurrentDBName(); + sqltemp = "select DISTINCT column_name from Information_schema.columns where table_schema = database() and table_name = upper(?)"; + if(!"".equalsIgnoreCase(currentDB)) sqltemp += " and table_schema = '" + currentDB + "' "; + }else if(rs.getDBType().equals("postgresql")){ + sqltemp = "select DISTINCT column_name from Information_schema.columns where table_schema = 'public' and lower(table_name) = lower(?)"; + } + + rs.executeQuery(sqltemp, tablename); + StringBuffer column = new StringBuffer(); + while (rs.next()) { + String columnname =""; + if(tablename.equals("workflow_nodeform")){ + columnname = "a." + rs.getString(1).toUpperCase(); + }else { + columnname = rs.getString(1).toUpperCase(); + } + // clob字段特殊处理 + if (clobcolumns != null && clobcolumns.size() > 0 && clobcolumns.contains(columnname)) { + continue; + } + if(rs.getDBType().equals("mysql") && "CONDITION".equals(columnname)){ + columnname = "`CONDITION`"; + } + column.append(columnname).append(","); + } + String coumntemp = ""; + if (column.length() > 0) { + coumntemp = column.substring(0, column.length() - 1); + } + column = null; + return coumntemp; + } + + /** + * 校验流程删除权限 + * @param requestid + * @param user + * @param isMonitor + * @return + */ + public static boolean verifyDelRight(int requestid,User user,boolean isMonitor) { + int userType = "2".equals(user.getLogintype()) ? 1 : 0; + RecordSet rs = new RecordSet(); + if(isMonitor) { + rs.executeQuery("select creater,workflowId from workflow_requestbase where requestid = ?",requestid); + if(rs.next()) { + String workflowId = rs.getString("workflowId"); + String creater = rs.getString("creater"); + Monitor monitor = new Monitor(); + MonitorDTO monitorInfo = monitor.getMonitorInfo(String.valueOf(user.getUID()),creater,workflowId); + return monitorInfo.getIsdelete(); + } + } else { + String querySql = ServiceUtil.calculateCurrentNodeSql(String.valueOf(requestid),user.getUID(),userType); + rs.executeQuery(querySql); + if(rs.next()) { + int nodeid = rs.getInt("nodeid"); + int isremark = rs.getInt("isremark"); + int workflowid = rs.getInt("workflowid"); + NodeInfoEntity nodeInfoEntity = WorkflowBaseBiz.getNodeInfo(nodeid); + if(nodeInfoEntity == null) return false; + WfFunctionManageUtil wfFunctionManageUtil = new WfFunctionManageUtil(); + return (nodeInfoEntity.getNodetype() == 0 && isremark == 0 && wfFunctionManageUtil.IsShowDelButtonByReject(requestid, workflowid)); + } + } + return false; + } + + public void setRequestid(int requestid) { + this.requestid = requestid; + } + + public String getMessage() { + return this.message; + } + + public String getMessagecontent() { + return this.messageContent; + } + + public void setMessageContent(String messageContent) { + this.messageContent = messageContent; + } + + public void setMessage(String message) { + this.message = message; + } + + private class RequestDeleteInfo{ + private String queryWhere; + private String copytablename; + private String primarykey; + private List clobColumn; + + public String getQueryWhere() { + return queryWhere; + } + public void setQueryWhere(String queryWhere) { + this.queryWhere = queryWhere; + } + public String getCopytablename() { + return copytablename; + } + public void setCopytablename(String copytablename) { + this.copytablename = copytablename; + } + public String getPrimarykey() { + return primarykey; + } + public void setPrimarykey(String primarykey) { + this.primarykey = primarykey; + } + public List getClobColumn() { + return clobColumn; + } + public void setClobColumn(List clobColumn) { + this.clobColumn = clobColumn; + } + + public String toClobColumString(){ + if(clobColumn == null) return null; + String columnString = ""; + for(String column:clobColumn){ + columnString += column+","; + } + return ((columnString.length() > 0)?(columnString.substring(0, columnString.length() - 1)):null); + + } + } + + public User getUser() { + return user; + } + + public void setUser(User user) { + this.user = user; + } +} diff --git a/weavernorth/com/ReceivingPushArchivesService.jsp b/weavernorth/com/ReceivingPushArchivesService.jsp new file mode 100644 index 0000000..066df7a --- /dev/null +++ b/weavernorth/com/ReceivingPushArchivesService.jsp @@ -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 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 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 param) { + filePath = Util.null2String(param.get("filePath")); + Url = Util.null2String(param.get("Url")); + templatePath = Util.null2String(param.get("templatePath")); + } + + + public void pushArchives(List 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 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 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 signFiles = ArchivesUtil.getSignFiles(requestid,true); + List docids = new ArrayList<>(); + // docids.addAll(Arrays.asList(fj.split(","))); + // docids.addAll(Arrays.asList(zwkbj.split(","))); + Map fjMap = ArchivesUtil.getFileIdByDocId(fj); + + // Map zwkbjMap = ArchivesUtil.getFileIdByDocId(zwkbj); + // Map lczwMap = ArchivesUtil.getFileIdByDocId(lczw); + Map lczwMap = new HashMap<>(); + //判断公文来源 + if ("0".equals(gwly)){ + lczwMap = ArchivesUtil.getFileIdByDocId(lczw); + }else { + lczwMap = ArchivesUtil.getFileIdByDocId(zwkbj); + } + + + + + List zwFileName = new ArrayList<>(); + List 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 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 requestDocid = ArchivesUtil.generaRequestFormPdf(requestid,1); + // 1.去掉生成子流程承办单 + // List subRequestDocid = generaSubRequestFormPdf(requestid); + Map reqDocMap = ArchivesUtil.getFileIdByDocId(String.join(",", requestDocid)); + // 2.去掉生成子流程承办单 + // Map 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 getRequestByid(int requestid) { + HashMap 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 requesData, String zipName, List zwFileName, List 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 requesData) { + HashSet 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 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 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 CoSubRequest = new ArrayList<>(); + Map subRequest = ArchivesUtil.getSubRequest(Util.null2String(requestid) , 6); + log.info("subRequest:{}",subRequest); + for (Map.Entry 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 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); + } +%> + diff --git a/weavernorth/com/SendingPushArchivesService.jsp b/weavernorth/com/SendingPushArchivesService.jsp new file mode 100644 index 0000000..af797cd --- /dev/null +++ b/weavernorth/com/SendingPushArchivesService.jsp @@ -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 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 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 param) { + filePath = Util.null2String(param.get("filePath")); + Url = Util.null2String(param.get("Url")); + templatePath = Util.null2String(param.get("templatePath")); + } + + public void pushArchives(List 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 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 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 signFiles = ArchivesUtil.getSignFiles(requestid,false); + List docids = new ArrayList<>(); + // docids.addAll(Arrays.asList(fj.split(","))); + // docids.addAll(Arrays.asList(zwkbj.split(","))); + Map fjMap = ArchivesUtil.getFileIdByDocId(fj); + Map dwdMap = ArchivesUtil.getFileIdByDocId(dwd); + Map zwMap = ArchivesUtil.getFileIdByDocId(zw); + Map qgqhjMap = ArchivesUtil.getFileIdByDocId(qgqhj); + Map thhlhMap = ArchivesUtil.getFileIdByDocId(thhlh); + List zwFileName = new ArrayList<>(); + List 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 requestDocid = ArchivesUtil.generaRequestFormPdf(requestid, 0); + // 1.去掉生成子流程承办单 + // List subRequestDocid = generaSubRequestFormPdf(requestid); + Map reqDocMap = ArchivesUtil.getFileIdByDocId(String.join(",", requestDocid)); + // 2.去掉生成子流程承办单 + // Map 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 getRequestByid(int requestid) { + HashMap 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 requesData, String zipName, List zwFileName, List 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 requesData) { + HashSet 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 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); + } + + + +%> \ No newline at end of file diff --git a/weavernorth/com/SignReportPushArchivesService.jsp b/weavernorth/com/SignReportPushArchivesService.jsp new file mode 100644 index 0000000..7cb814f --- /dev/null +++ b/weavernorth/com/SignReportPushArchivesService.jsp @@ -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 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 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 param) { + filePath = Util.null2String(param.get("filePath")); + Url = Util.null2String(param.get("Url")); + templatePath = Util.null2String(param.get("templatePath")); + } + + public void pushArchives(List 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 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 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 signFiles = ArchivesUtil.getSignFiles(requestid,true); + List docids = new ArrayList<>(); + // docids.addAll(Arrays.asList(fj.split(","))); + // docids.addAll(Arrays.asList(zwkbj.split(","))); + Map fjMap = ArchivesUtil.getFileIdByDocId(fj); + Map zwMap = ArchivesUtil.getFileIdByDocId(zw); + Map qgqhjMap = ArchivesUtil.getFileIdByDocId(qgqhj); + List zwFileName = new ArrayList<>(); + List 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 requestDocid = ArchivesUtil.generaRequestFormPdf(requestid, 1); + // 1.去掉生成子流程承办单 + // List subRequestDocid = generaSubRequestFormPdf(requestid); + Map reqDocMap = ArchivesUtil.getFileIdByDocId(String.join(",", requestDocid)); + // 2.去掉生成子流程承办单 + // Map 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 getRequestByid(int requestid) { + HashMap 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 requesData, String zipName, List zwFileName, List 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 requesData) { + HashSet 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 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); + } + +%> \ No newline at end of file diff --git a/weavernorth/com/testDateKey.jsp b/weavernorth/com/testDateKey.jsp deleted file mode 100644 index 8d994c2..0000000 --- a/weavernorth/com/testDateKey.jsp +++ /dev/null @@ -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 param = ParamUtil.request2Map(request); - String dataKey = (String) param.get("dataKey"); - DefaultWeaTable defaultWeaTable = WeaTableTools.checkTableStringConfig(dataKey, DefaultWeaTable.class); - - -%> - diff --git a/weavernorth/custom/avatar/zipAvatar.jsp b/weavernorth/custom/avatar/zipAvatar.jsp new file mode 100644 index 0000000..1424ae0 --- /dev/null +++ b/weavernorth/custom/avatar/zipAvatar.jsp @@ -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 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 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(); + } +%> + + + + + Download ZIP + + +

Download ZIP File

+

If the download does not start automatically, click here.

+ + diff --git a/weavernorth/custom/businessTravel/getdeleType.jsp b/weavernorth/custom/businessTravel/getdeleType.jsp new file mode 100644 index 0000000..92ed50e --- /dev/null +++ b/weavernorth/custom/businessTravel/getdeleType.jsp @@ -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 paramMap = ParamUtil.request2Map(request); + int id = Util.getIntValue(Util.null2String(paramMap.get("id"))); + HashMap 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 = ""; + //天津银行国内出差审批单附件PDF(tjyxgnccspdfjpdf)中 + 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("
"); + 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; + } + } + + +%> diff --git a/weavernorth/custom/dept/CommUtil.class b/weavernorth/custom/dept/CommUtil.class new file mode 100644 index 0000000..58cc4c4 Binary files /dev/null and b/weavernorth/custom/dept/CommUtil.class differ diff --git a/weavernorth/custom/dept/deptTest.jsp b/weavernorth/custom/dept/deptTest.jsp new file mode 100644 index 0000000..960c3f8 --- /dev/null +++ b/weavernorth/custom/dept/deptTest.jsp @@ -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("
"); + out.print(departmentComInfo.getDepartmentmark("3588")); + out.print("
"); + out.print(departmentComInfo.getDepartmentmark("3454")); + out.print("
"); + out.print(departmentComInfo.getDepartmentmark("3454")); + + +%> +