commit 341c397375bce9ab9282f92c4d16030f49d34b28 Author: CL <2502239547@qq.com> Date: Mon Apr 17 10:19:27 2023 +0800 档案对接 diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/artifacts/shoufagongwen.xml b/.idea/artifacts/shoufagongwen.xml new file mode 100644 index 0000000..a7cbd3b --- /dev/null +++ b/.idea/artifacts/shoufagongwen.xml @@ -0,0 +1,8 @@ + + + $PROJECT_DIR$/../../WEAVER/ecology/WEB-INF/lib + + + + + \ No newline at end of file diff --git a/.idea/encodings.xml b/.idea/encodings.xml new file mode 100644 index 0000000..9de3c4a --- /dev/null +++ b/.idea/encodings.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 0000000..6560a98 --- /dev/null +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,36 @@ + + + + \ No newline at end of file diff --git a/.idea/libraries/classbean.xml b/.idea/libraries/classbean.xml new file mode 100644 index 0000000..bfcf648 --- /dev/null +++ b/.idea/libraries/classbean.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/lib.xml b/.idea/libraries/lib.xml new file mode 100644 index 0000000..ccfcd39 --- /dev/null +++ b/.idea/libraries/lib.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..3725f55 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..c66ee77 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/uiDesigner.xml b/.idea/uiDesigner.xml new file mode 100644 index 0000000..e96534f --- /dev/null +++ b/.idea/uiDesigner.xml @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/out/production/shoufagongwen/com/api/files/GD_Action.class b/out/production/shoufagongwen/com/api/files/GD_Action.class new file mode 100644 index 0000000..cecfd62 Binary files /dev/null and b/out/production/shoufagongwen/com/api/files/GD_Action.class differ diff --git a/out/production/shoufagongwen/com/engine/workflow/web/danganfiles/DA/FWCB_Action.class b/out/production/shoufagongwen/com/engine/workflow/web/danganfiles/DA/FWCB_Action.class new file mode 100644 index 0000000..9097559 Binary files /dev/null and b/out/production/shoufagongwen/com/engine/workflow/web/danganfiles/DA/FWCB_Action.class differ diff --git a/out/production/shoufagongwen/com/engine/workflow/web/danganfiles/DA/JWJCPD_Action.class b/out/production/shoufagongwen/com/engine/workflow/web/danganfiles/DA/JWJCPD_Action.class new file mode 100644 index 0000000..9e6aa47 Binary files /dev/null and b/out/production/shoufagongwen/com/engine/workflow/web/danganfiles/DA/JWJCPD_Action.class differ diff --git a/out/production/shoufagongwen/com/engine/workflow/web/danganfiles/DA/JWJCYD_Action.class b/out/production/shoufagongwen/com/engine/workflow/web/danganfiles/DA/JWJCYD_Action.class new file mode 100644 index 0000000..8430de4 Binary files /dev/null and b/out/production/shoufagongwen/com/engine/workflow/web/danganfiles/DA/JWJCYD_Action.class differ diff --git a/out/production/shoufagongwen/com/engine/workflow/web/danganfiles/DA/SWBLCPD_Action.class b/out/production/shoufagongwen/com/engine/workflow/web/danganfiles/DA/SWBLCPD_Action.class new file mode 100644 index 0000000..5084103 Binary files /dev/null and b/out/production/shoufagongwen/com/engine/workflow/web/danganfiles/DA/SWBLCPD_Action.class differ diff --git a/out/production/shoufagongwen/com/engine/workflow/web/danganfiles/DA/YZSQ_Action.class b/out/production/shoufagongwen/com/engine/workflow/web/danganfiles/DA/YZSQ_Action.class new file mode 100644 index 0000000..3c417d1 Binary files /dev/null and b/out/production/shoufagongwen/com/engine/workflow/web/danganfiles/DA/YZSQ_Action.class differ diff --git a/out/production/shoufagongwen/com/engine/workflow/web/danganfiles/DA/util/CreatXML.class b/out/production/shoufagongwen/com/engine/workflow/web/danganfiles/DA/util/CreatXML.class new file mode 100644 index 0000000..2858d79 Binary files /dev/null and b/out/production/shoufagongwen/com/engine/workflow/web/danganfiles/DA/util/CreatXML.class differ diff --git a/out/production/shoufagongwen/com/engine/workflow/web/danganfiles/DA/util/DaHttpAction.class b/out/production/shoufagongwen/com/engine/workflow/web/danganfiles/DA/util/DaHttpAction.class new file mode 100644 index 0000000..f6aebac Binary files /dev/null and b/out/production/shoufagongwen/com/engine/workflow/web/danganfiles/DA/util/DaHttpAction.class differ diff --git a/out/production/shoufagongwen/com/engine/workflow/web/danganfiles/DA/util/GDS_Action.class b/out/production/shoufagongwen/com/engine/workflow/web/danganfiles/DA/util/GDS_Action.class new file mode 100644 index 0000000..5b5b308 Binary files /dev/null and b/out/production/shoufagongwen/com/engine/workflow/web/danganfiles/DA/util/GDS_Action.class differ diff --git a/out/production/shoufagongwen/com/engine/workflow/web/danganfiles/DA/util/GD_Action.class b/out/production/shoufagongwen/com/engine/workflow/web/danganfiles/DA/util/GD_Action.class new file mode 100644 index 0000000..49e3d4b Binary files /dev/null and b/out/production/shoufagongwen/com/engine/workflow/web/danganfiles/DA/util/GD_Action.class differ diff --git a/out/production/shoufagongwen/com/engine/workflow/web/danganfiles/DA/util/JY_action.class b/out/production/shoufagongwen/com/engine/workflow/web/danganfiles/DA/util/JY_action.class new file mode 100644 index 0000000..7c7f418 Binary files /dev/null and b/out/production/shoufagongwen/com/engine/workflow/web/danganfiles/DA/util/JY_action.class differ diff --git a/out/production/shoufagongwen/com/engine/workflow/web/danganfiles/DA/util/ZipFile.class b/out/production/shoufagongwen/com/engine/workflow/web/danganfiles/DA/util/ZipFile.class new file mode 100644 index 0000000..9629ed5 Binary files /dev/null and b/out/production/shoufagongwen/com/engine/workflow/web/danganfiles/DA/util/ZipFile.class differ diff --git a/out/production/shoufagongwen/com/engine/workflow/web/danganfiles/DA/util/ZipUtil.class b/out/production/shoufagongwen/com/engine/workflow/web/danganfiles/DA/util/ZipUtil.class new file mode 100644 index 0000000..95fb233 Binary files /dev/null and b/out/production/shoufagongwen/com/engine/workflow/web/danganfiles/DA/util/ZipUtil.class differ diff --git a/out/production/shoufagongwen/com/engine/workflow/web/danganfiles/DA/util/demo.class b/out/production/shoufagongwen/com/engine/workflow/web/danganfiles/DA/util/demo.class new file mode 100644 index 0000000..7a1a14c Binary files /dev/null and b/out/production/shoufagongwen/com/engine/workflow/web/danganfiles/DA/util/demo.class differ diff --git a/out/production/shoufagongwen/com/engine/workflow/web/danganfiles/DA/util/test.class b/out/production/shoufagongwen/com/engine/workflow/web/danganfiles/DA/util/test.class new file mode 100644 index 0000000..ef04681 Binary files /dev/null and b/out/production/shoufagongwen/com/engine/workflow/web/danganfiles/DA/util/test.class differ diff --git a/out/production/shoufagongwen/rebel.xml b/out/production/shoufagongwen/rebel.xml new file mode 100644 index 0000000..a7abe20 --- /dev/null +++ b/out/production/shoufagongwen/rebel.xml @@ -0,0 +1,16 @@ + + + + + + shoufagongwen + + + + + + + diff --git a/shoufagongwen.iml b/shoufagongwen.iml new file mode 100644 index 0000000..90d593e --- /dev/null +++ b/shoufagongwen.iml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/com/api/files/GD_Action.java b/src/com/api/files/GD_Action.java new file mode 100644 index 0000000..73e795d --- /dev/null +++ b/src/com/api/files/GD_Action.java @@ -0,0 +1,180 @@ +package com.api.files; + + + +import com.engine.workflow.web.danganfiles.DA.util.DaHttpAction; +import weaver.conn.RecordSet; +import weaver.general.BaseBean; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import java.util.HashMap; +import java.util.Map; + +/** + * 调用归档的方法,建模表单的按钮触发 + */ +@Path("/inter/file") +public class GD_Action { + + + + @GET + @Path("/dofiling") + @Produces(MediaType.TEXT_PLAIN) + public String interfile (@Context HttpServletRequest request, @Context HttpServletResponse response){ + BaseBean bb = new BaseBean(); + String id =request.getParameter("id"); + bb.writeLog("进入方法--归档执行开始"+id); + RecordSet rs = new RecordSet(); +// String depidSql="SELECT b.id as depid FROM hrmresource a,hrmdepartment b WHERE a.departmentid = b.id AND a.ID=(select creater FROM workflow_requestbase WHERE REQUESTID=(select lcid from uf_dagd where id="+id+"))"; + String depidSql="select ssbm from uf_dagd where id="+id; + String depid =""; + try { + rs.executeQuery(depidSql); + if ( rs.next()){ + depid = rs.getString("ssbm"); + bb.writeLog("执行部门语句----"+depidSql); + } + }catch (Exception e){ + bb.writeLog("执行部门语句失败----"+e); + } + + //查询归档记录表 + String sql ="select * from uf_dagd where id="+id; + int gdzt =-1; + try { + rs.executeQuery(sql); + if (rs.next()){ + gdzt = rs.getInt("gdzt"); + bb.writeLog("执行语句----"+sql); + } + }catch (Exception e){ + bb.writeLog("执行语句失败----"+e); + e.printStackTrace(); + } + + bb.writeLog("状态信息"+gdzt); + boolean success = false; + int i = 10; + //判断文件归档状态,0为未归档 + bb.writeLog("归档状态"+gdzt); + if(gdzt==0){ + + String filename = rs.getString("wjjmc"); + String filepath = rs.getString("wjlj"); + String sfwlb = rs.getString("sfwlb"); + //执行档案归档文件上传方法 + + bb.writeLog("文件相关信息"+filename+"--"+filepath+"--"+sfwlb); + DaHttpAction daHttpAction = new DaHttpAction(); + + try { + bb.writeLog("进入daHttpAction.doit方法"); + i= daHttpAction.doit(filename,filepath,sfwlb,depid); + } catch (Exception e) { + e.printStackTrace(); + } + bb.writeLog("返回信息str"+i); + //将记录表中的未归档状态修改为归档=" + if(i!=0){ + bb.writeLog("上传出问题了-----"+i); + }else if(i==0){ + String upsql = "update uf_dagd set gdzt =1 where id="+id; + RecordSet rs1 = new RecordSet(); + bb.writeLog("sql--->"+upsql); + success = rs1.executeUpdate(upsql); + bb.writeLog("上传成功-----"+success); + } + } + +//除0 以外的所有返回信息都是错误 + return i+""; + } + + @GET + @Path("/dofilings") + @Produces(MediaType.APPLICATION_JSON) + public Map interfiles (@Context HttpServletRequest request, @Context HttpServletResponse response) { + BaseBean bb = new BaseBean(); + String id = request.getParameter("id"); + bb.writeLog("进入方法--归档执行开始" + id); + RecordSet rs = new RecordSet(); + String[] arr = id.split(","); + int i = 10; + int successCount = 0; + int deftCount = 0; + for (int y = 0; y < arr.length; y++) { + boolean success = false; + String depidSql="select ssbm from uf_dagd where id="+arr[y]; + String depid =""; + try { + rs.executeQuery(depidSql); + if (rs.next()){ + depid = rs.getString("ssbm"); + bb.writeLog("执行部门语句----"+depidSql); + } + }catch (Exception e){ + bb.writeLog("执行部门语句失败----"+e); + } + + //查询归档记录表 + String sql = "select * from uf_dagd where id=" + arr[y]; + int gdzt = -1; + try { + rs.executeQuery(sql); + if (rs.next()){ + gdzt = rs.getInt("gdzt"); + bb.writeLog("执行语句----" + sql); + } + } catch (Exception e) { + bb.writeLog("执行语句失败----" + e); + e.printStackTrace(); + } + + + bb.writeLog("状态信息" + gdzt); + //判断文件归档状态,0为未归档 + bb.writeLog("归档状态" + gdzt); + if (gdzt == 0) { + String filename = rs.getString("wjjmc"); + String filepath = rs.getString("wjlj"); + String sfwlb = rs.getString("sfwlb"); + //执行档案归档文件上传方法 + bb.writeLog("文件相关信息" + filename + "--" + filepath + "--" + sfwlb); + DaHttpAction daHttpAction = new DaHttpAction(); + + try { + bb.writeLog("进入daHttpAction.doit方法"); + i = daHttpAction.doit(filename,filepath,sfwlb,depid); + } catch (Exception e) { + e.printStackTrace(); + } + bb.writeLog("返回信息str" + i); + //将记录表中的未归档状态修改为归档=" + if (i != 0) { + deftCount += 1; + bb.writeLog("归档出问题了----->" + i); + } else if (i == 0) { + successCount += 1; + String upsql = "update uf_dagd set gdzt =1 where id=" + arr[y]; + RecordSet rs1 = new RecordSet(); + bb.writeLog("sql--->" + upsql); + success = rs1.executeUpdate(upsql); + bb.writeLog("上传成功更新数据库----->"+success); + } + + } + } +//除0 以外的所有返回信息都是错误 + HashMap resultMap = new HashMap<>(); + resultMap.put("successCount", successCount); + resultMap.put("deftCount", deftCount); + return resultMap; + } +} diff --git a/src/com/engine/workflow/web/danganfiles/DA/FWCB_Action.java b/src/com/engine/workflow/web/danganfiles/DA/FWCB_Action.java new file mode 100644 index 0000000..ff5b579 --- /dev/null +++ b/src/com/engine/workflow/web/danganfiles/DA/FWCB_Action.java @@ -0,0 +1,373 @@ +package com.engine.workflow.web.danganfiles.DA; + + +import com.engine.workflow.web.danganfiles.DA.util.CreatXML; +import org.apache.ibatis.jdbc.SQL; +import weaver.conn.RecordSet; +import weaver.general.BaseBean; +import weaver.interfaces.workflow.action.Action; +import weaver.soa.workflow.request.RequestInfo; + +import java.io.File; +import java.text.SimpleDateFormat; +import java.util.*; +import java.util.zip.ZipOutputStream; + +import static com.engine.workflow.web.danganfiles.DA.util.JY_action.filename; +import static com.engine.workflow.web.danganfiles.DA.util.JY_action.fjFilename; +import static com.engine.workflow.web.danganfiles.DA.util.ZipFile.zipu; +/** + * 发文呈报 + * 2020-10-14 + */ +@SuppressWarnings("all") +public class FWCB_Action implements Action { + + public static String getFileNameNoEx(String filename) { + + if ((filename != null) && (filename.length() > 0)) { + + int dot = filename.lastIndexOf('.'); + + if ((dot >-1) && (dot < (filename.length()))) { + + return filename.substring(0, dot); + + } + + } + + return filename; + + } + + @Override + public String execute(RequestInfo requestinfo) { + String creatorid = requestinfo.getCreatorid(); + + String sqls="select departmentid FROM HrmResource where lastname=?"; + RecordSet recordSet2=new RecordSet(); + recordSet2.execute(sqls,creatorid); + if(recordSet2.next()){ + String departmentid = recordSet2.getString("departmentid"); + } + + BaseBean bb = new BaseBean(); + RecordSet rs = new RecordSet(); + List> list = new ArrayList>(); + //=====================================================================读取主表数据 + bb.writeLog("====局文件传阅单========START="+requestinfo.getRequestid()); + String requestid = requestinfo.getRequestid(); //请求ID + + String src = requestinfo.getRequestManager().getSrc(); + bb.writeLog("====局文件传阅单=====src="+src); + //当前操作类型 submit:提交/reject:退回 + String workflowid = requestinfo.getWorkflowid(); //流程ID + String tablename = requestinfo.getRequestManager().getBillTableName();//表单名称 + + String sql = "select * from "+tablename+" where requestid = "+requestid; + + rs.execute(sql); + rs.writeLog(sql); + HashMap map = new HashMap(); // 依据说明 + HashMap mapList = new HashMap(); // 归档文件 + SimpleDateFormat fomat = new SimpleDateFormat("yyyyMMddHHmmss"); + String time = fomat.format(new Date()); + bb.writeLog(time); + + String dh =time+"-"+requestid; + UUID uuid = UUID.randomUUID(); + bb.writeLog(uuid); + String str = uuid.toString().replaceAll("-",""); + + String fj =""; + String ofdwj =""; + String zwofdwj =""; + String wjbt =""; + String ngcs=""; + if (rs.next()){ + fj =rs.getString("fj"); //附件 + wjbt = rs.getString("bt"); //文件标题 + String zsdw = rs.getString("zsdw"); //主送单位 + String csdw = rs.getString("csdw"); //抄送单位 + int mj = rs.getInt("mj"); //密级 + String hj = rs.getString("hj"); // 缓急 + String ys = rs.getString("ys"); // 印数 + String wh = rs.getString("wh"); //文号 + ngcs = rs.getString("szbm"); //拟稿处室 + String ngr = rs.getString("ngr"); //拟稿人 + String zw = rs.getString("zw"); // 正文 + ofdwj = rs.getString("fj"); // ofd文件 + zwofdwj = rs.getString("zwofdwj"); // ofd附件文件 + String mjstr=""; + if(mj==0){ + mjstr="非涉密"; + }else if(mj==1){ + mjstr="机密"; + }else if(mj==2){ + mjstr="秘密"; + } + Date date = new Date(); + String da = new SimpleDateFormat("yyyy-MM-dd").format(date).replaceAll("-",""); + + bb.writeLog("====局文件传阅单=====文件添加数据="+time+requestid+wjbt+wh+ngr+da); + bb.writeLog("====局文件传阅单=====文件添加数据="+src); + map.put("dh",time+"-"+requestid); //档号,归档存储文件文件夹名称 + map.put("bt",wjbt); //标题 + map.put("bh",wh);//文号 +// map.put("zrz",ngcs); //责任者 + map.put("rq",da.replaceAll("-","")); //日期 + map.put("ys",1); + + bb.writeLog("====局文件传阅单=====文件添加数据="+map); + + mapList.put("dh",str); //UUID档号 + mapList.put("wz","发文"); //文种 + mapList.put("bt",wjbt); //文件标题 + + + String depName="select departmentname from hrmdepartment where id="+ngcs; + String zrzName =""; + try { + rs.execute(depName); + rs.writeLog(depName); + rs.next(); + zrzName = rs.getString("departmentname"); + }catch (Exception e){ + bb.writeLog(""+e); + } + map.put("zrz",zrzName); + + + + String createrId="SELECT CREATER FROM workflow_requestbase WHERE REQUESTID="+requestid; + String jgryid =""; + try { + rs.execute(createrId); + rs.writeLog(createrId); + rs.next(); + jgryid = rs.getString("CREATER"); + }catch (Exception e){ + bb.writeLog(""+e); + } + + + String createrName="SELECT LASTNAME FROM hrmresource WHERE id=(SELECT CREATER FROM workflow_requestbase WHERE REQUESTID="+requestid+")"; + String jgryName =""; + try { + rs.execute(createrName); + rs.writeLog(createrName); + rs.next(); + jgryName = rs.getString("LASTNAME"); + }catch (Exception e){ + bb.writeLog(""+e); + } + + + String createrDepName="SELECT b.DEPARTMENTNAME FROM hrmresource a,hrmdepartment b WHERE a.departmentid = b.id AND a.ID=(SELECT CREATER FROM workflow_requestbase WHERE REQUESTID="+requestid+")"; + String jgryBmName =""; + try { + rs.execute(createrDepName); + rs.writeLog(createrDepName); + rs.next(); + jgryBmName = rs.getString("DEPARTMENTNAME"); + }catch (Exception e){ + bb.writeLog(""+e); + } + + + String nodeInfoSql="SELECT a.id,b.nodename,a.lastname,a.departmentname,a.receivedate,a.receivetime,a.operatedate,a.operatetime FROM (SELECT a.nodeid,a.receivedate,a.receivetime,a.operatedate,a.operatetime,c.lastname,a.requestid,c.id,c.departmentid,d.departmentname FROM workflow_currentoperator a,workflow_nodebase b,hrmresource c,hrmdepartment d" + + " WHERE a.nodeid=b.id AND a.processuser=c.id AND d.id=c.departmentid and a.requestid="+requestid+") a right JOIN (SELECT id ,nodename FROM workflow_nodebase WHERE id in(SELECT nodeid FROM workflow_currentoperator WHERE requestid="+requestid+")) b ON a.nodeid=b.id order by nodeid"; + List> nodeInfoList = new ArrayList<>(); + try { + RecordSet recordSet = new RecordSet(); + recordSet.execute(nodeInfoSql); + bb.writeLog("开始查询节点流程"); + while (recordSet.next()){ + Map nodeInfo = new HashMap<>(); + nodeInfo.put("id",recordSet.getString("id")); + nodeInfo.put("nodename",recordSet.getString("nodename")); + nodeInfo.put("lastname",recordSet.getString("lastname")); + nodeInfo.put("departmentname",recordSet.getString("departmentname")); + nodeInfo.put("receivedate",recordSet.getString("receivedate")); + nodeInfo.put("receivetime",recordSet.getString("receivetime")); + nodeInfo.put("operatedate",recordSet.getString("operatedate")); + nodeInfo.put("operatetime",recordSet.getString("operatetime")); + nodeInfoList.add(nodeInfo); + } + bb.writeLog("查询节点流程"); + }catch (Exception e){ + e.printStackTrace(); + } + bb.writeLog("节点信息-->"+nodeInfoList); + + bb.writeLog("查询出的附件-->"+fj); + String[] arr = fj.split(","); + List> fjList = new ArrayList<>(); + for (int i = 0; i < arr.length; i++) { + //附件 + String fjSQL="SELECT filerealpath,imagefilename FROM imagefile WHERE imagefileid ="+ arr[i]; + try { + RecordSet recordSet = new RecordSet(); + recordSet.execute(fjSQL); + bb.writeLog("开始附件列表"); + while (recordSet.next()){ + Map fjMap = new HashMap<>(); + String filerealpath = recordSet.getString("filerealpath"); + String imagefilename = recordSet.getString("imagefilename"); + int index = filerealpath.lastIndexOf("/"); + int index2 = imagefilename.lastIndexOf("."); + String zipPath = filerealpath.substring(index + 1); //压缩文件名 + String newname = imagefilename.substring(0, index2); + String fileNameNoEx = getFileNameNoEx(zipPath); + fjMap.put("filerealpath",filerealpath); + fjMap.put("imagefilename",imagefilename); + fjMap.put("fjUUID",fileNameNoEx); + fjList.add(fjMap); + } + bb.writeLog("查询附件结束 fjList.size()==="+fjList.size()); + }catch (Exception e){ + bb.writeLog("查询附件异常==="+e); + } + } + + mapList.put("ys",1); //页数 + mapList.put("zrz",zrzName); //责任者 部门名称 + mapList.put("jgryName",jgryName); //机构人员中文 + mapList.put("jgryBmName",jgryBmName); //机构人员部门名称 + mapList.put("jgryid",jgryid); //机构人员id + mapList.put("rq",da.replaceAll("-","")); //日期 + mapList.put("kzbs","控制"); // 控制标识 + mapList.put("zw",ofdwj); // 正文 + mapList.put("zwofd",zwofdwj); // 正文ofd + mapList.put("nodeInfoList",nodeInfoList); // 节点信息 + if(fj!=null && fj!=""){ + mapList.put("fj",fj); //附件 + }else{ + mapList.put("fj","0"); //附件 + } + if(fj!=null && fj!=""){ + mapList.put("fj",fj); //附件 + }else{ + mapList.put("fj","0"); //附件 + } + if(fj!=null && fj!=""){ + mapList.put("fjList",fjList); //附件 + }else{ + mapList.put("fjList","0"); //附件 + } + +// mapList.put("cld",ofdwj); //处理单 + mapList.put("mj",mjstr); + + bb.writeLog("====局文件传阅单==内部=444=map="+map.toString()); + bb.writeLog("====局文件传阅单==内部=444=maplist="+mapList.toString()); + } + bb.writeLog("====局文件传阅单===444=src="); + bb.writeLog("====局文件传阅单===444=map="+map.toString()); + bb.writeLog("====局文件传阅单===444=maplist="+mapList.toString()); + + String filerealpath = ""; +// String YJnewPath = "/home/WEAVER/ecology/DA/FWCB/"+str; //归档文件依据说明文件夹 +// String GDnewPath = "/home/WEAVER/ecology/DA/FWCB/"+str+"/"+time+"-"+requestid; //归档文件正文附件文件夹 + String YJnewPath = "/WEAVER/oadata792/DAGD/FWCB/"+str; //归档文件依据说明文件夹 + String GDnewPath = "/WEAVER/oadata792/DAGD/FWCB/"+str+"/"+time+"-"+requestid; //归档文件正文附件文件夹 + String zipname =str+".zip"; + String zippath = YJnewPath+".zip";//压缩包路径 + // 根据系统的实际情况选择目录分隔符bai(windows下是,dulinux下是/) +// linux下只认正斜杠,为了保证跨平台性,不建议使用反斜杠(在java程序中是转义字符,用\来表示反斜杠) + +// 在内存中创建一个文件对象,注意:此时还没有在硬盘对应目录下创建实实在在的文件 +// File f = new File(YJnewPath); +// bb.writeLog("====局文件传阅单=====创建文件c="+YJnewPath); + bb.writeLog("====局文件传阅单=====创建文件夹成功c="+YJnewPath); + + + File f2 = new File(GDnewPath+"/ww"); + bb.writeLog("====局文件传阅单=====创建文件c="+GDnewPath); + if(f2.exists()) { + bb.writeLog("====局文件传阅单=====创建文件夹="+f2.getAbsolutePath()); + + bb.writeLog("====局文件传阅单=====创建文件夹="+f2.getName()); + bb.writeLog("====局文件传阅单=====创建文件c="+f2.length()); + + bb.writeLog("-----"); + } else { +// 先创建文件所在的目录 + boolean su =f2.getParentFile().mkdirs(); + if(su==true){ + if(fj.length()>0){ + fjFilename(fj, GDnewPath); + } + if(zwofdwj.length()>0){ + fjFilename(zwofdwj, GDnewPath); + } + if(ofdwj.length()>0){ + String filename = filename(ofdwj, GDnewPath); + mapList.put("cld",filename); + } + } + + } + + bb.writeLog("====局文件传阅单=====创建文件夹成功c="+GDnewPath); + //先创建文件夹,之后存放文件,再传递建模进行记录 + CreatXML creatXML = new CreatXML(); + try { + + creatXML.createYJSMXml(YJnewPath,map); + + } catch (Exception e) { + e.printStackTrace(); + bb.writeLog("局文件传阅单----依据说明:" + e); + } + try { + creatXML.createGDWJXml(GDnewPath,mapList); + } catch (Exception e) { + e.printStackTrace(); + bb.writeLog("局文件传阅单=====归档文件:" + e); + } + + bb.writeLog("====局文件传阅单=====写入xml文件="+src); + bb.writeLog("====局文件传阅单====文件方法="); + + File f1=null; + ZipOutputStream out=null; + String zip = YJnewPath+".zip"; +// try { +// f1= new File(YJnewPath); +// out = new ZipOutputStream(new FileOutputStream( +// YJnewPath+".zip")); +// zip(out,f1,null); +// } catch (FileNotFoundException e) { +// e.printStackTrace(); +// } catch (Exception e) { +// e.printStackTrace(); +// } + +// try { +// ZipUtil zipUtil = new ZipUtil(); +// zipUtil.zip(YJnewPath,zippath); +// } catch (Exception e) { +// e.printStackTrace(); +// } + zipu(YJnewPath,zippath); + bb.writeLog("====局文件传阅单=====写入xml文件="+src); + Date date = new Date(); + String day = new SimpleDateFormat("yyyy-MM-dd").format(date); + String daytime = new SimpleDateFormat("hh:mm").format(date); + //文件路径,收发文类别0是收文1是发文,文件夹名称,归档状态,流程id + String insertsql = "insert into uf_dagd(wjlj,sfwlb,wjjmc,gdzt,lcid,lcgdrq,lcgdsj,ssbm,gdlcm) values('"+zippath+"','"+0+"','"+zipname+"','"+0+"','"+requestid+"','"+day+"','"+daytime+"','"+ngcs+"','"+wjbt+"')"; + RecordSet recordSet = new RecordSet(); + recordSet.execute(insertsql); + recordSet.writeLog("建模台账添加数据"+insertsql); + + return Action.SUCCESS; + } + +} + + + + + diff --git a/src/com/engine/workflow/web/danganfiles/DA/JWJCPD_Action.java b/src/com/engine/workflow/web/danganfiles/DA/JWJCPD_Action.java new file mode 100644 index 0000000..ad749eb --- /dev/null +++ b/src/com/engine/workflow/web/danganfiles/DA/JWJCPD_Action.java @@ -0,0 +1,382 @@ +package com.engine.workflow.web.danganfiles.DA; + + +import com.engine.workflow.web.danganfiles.DA.util.CreatXML; +import weaver.conn.RecordSet; +import weaver.general.BaseBean; +import weaver.interfaces.workflow.action.Action; +import weaver.soa.workflow.request.RequestInfo; + +import java.io.File; +import java.text.SimpleDateFormat; +import java.util.*; +import java.util.zip.ZipOutputStream; + +import static com.engine.workflow.web.danganfiles.DA.util.JY_action.filename; +import static com.engine.workflow.web.danganfiles.DA.util.JY_action.fjFilename; +import static com.engine.workflow.web.danganfiles.DA.util.ZipFile.zipu; + +/** + * @author:CL + * @date:2023/4/3 10:20 + * 文件呈批单 发文 + */ +@SuppressWarnings("all") +public class JWJCPD_Action implements Action { + + public static String getFileNameNoEx(String filename) { + + if ((filename != null) && (filename.length() > 0)) { + + int dot = filename.lastIndexOf('.'); + + if ((dot >-1) && (dot < (filename.length()))) { + + return filename.substring(0, dot); + + } + + } + + return filename; + + } + + @Override + public String execute(RequestInfo requestinfo) { + String creatorid = requestinfo.getCreatorid(); + + String sqls="select departmentid FROM HrmResource where lastname=?"; + RecordSet recordSet2=new RecordSet(); + recordSet2.executeQuery(sqls,creatorid); + String departmentid=null; + if(recordSet2.next()){ + departmentid = recordSet2.getString("departmentid"); + } + + BaseBean bb = new BaseBean(); + RecordSet rs = new RecordSet(); + List> list = new ArrayList>(); + bb.writeLog("====文件呈批单 责任者id ==="+departmentid); + //=====================================================================读取主表数据 + bb.writeLog("====文件呈批单========START="+requestinfo.getRequestid()); + String requestid = requestinfo.getRequestid(); //请求ID + + String src = requestinfo.getRequestManager().getSrc(); + bb.writeLog("====文件呈批单=====src="+src); + //当前操作类型 submit:提交/reject:退回 + String workflowid = requestinfo.getWorkflowid(); //流程ID + String tablename = requestinfo.getRequestManager().getBillTableName();//表单名称 + + String sql = "select * from "+tablename+" where requestid = "+requestid; + + rs.execute(sql); + rs.writeLog(sql); + HashMap map = new HashMap(); // 依据说明 + HashMap mapList = new HashMap(); // 归档文件 + SimpleDateFormat fomat = new SimpleDateFormat("yyyyMMddHHmmss"); + String time = fomat.format(new Date()); + bb.writeLog(time); + + String dh =time+"-"+requestid; + UUID uuid = UUID.randomUUID(); + bb.writeLog(uuid); + String str = uuid.toString().replaceAll("-",""); + + String fj =""; + String ofdwj =""; + String zwofdwj =""; + String wjbt =""; +// String zrz="3"; //责任者id(部门id) + String zrz=departmentid; //责任者id(部门id) + if (rs.next()){ + String swrq1 = rs.getString("swrq1"); // +// fj =rs.getString("fj"); //附件 + wjbt = rs.getString("cpwjbt"); //文件标题 ** + String zsdw = rs.getString("zsdw"); //主送单位 + String csdw = rs.getString("csdw"); //抄送单位 +// int mj = rs.getInt("mj"); //密级 + String hj = rs.getString("hj"); // 缓急 + String ys = rs.getString("ys"); // 印数 + String wh = rs.getString("wh"); //文号 +// ngcs = rs.getString("szbm"); //拟稿处室 + String ngr = rs.getString("ngr"); //拟稿人 + String zw = rs.getString("zw"); // 正文 + ofdwj = rs.getString("fj"); // ofd文件 ** + zwofdwj = rs.getString("zwofdwj"); // ofd附件文件 +// String mjstr="内部"; //暂时用内部测试 等档案那边调整后 变为"" + String mjstr=""; //暂时用内部测试 等档案那边调整后 变为"" + +// if(mj==0){ +// mjstr="非涉密"; +// }else if(mj==1){ +// mjstr="机密"; +// }else if(mj==2){ +// mjstr="秘密"; +// } + Date date = new Date(); + String da = new SimpleDateFormat("yyyy-MM-dd").format(date).replaceAll("-",""); + + bb.writeLog("====文件呈批单=====文件添加数据="+time+requestid+wjbt+wh+ngr+da); + bb.writeLog("====文件呈批单=====文件添加数据="+src); + map.put("dh",time+"-"+requestid); //档号,归档存储文件文件夹名称 + map.put("bt",wjbt); //标题 + map.put("bh",wh);//文号 +// map.put("zrz",ngcs); //责任者 + map.put("rq",swrq1.replaceAll("-","")); //日期 + map.put("ys",1); + + bb.writeLog("====文件呈批单=====文件添加数据="+map); + + mapList.put("dh",str); //UUID档号 + mapList.put("wz","发文"); //文种 + mapList.put("bt",wjbt); //文件标题 + + + String depName="select departmentname from hrmdepartment where id="+zrz; + String zrzName =""; + try { + rs.execute(depName); + rs.writeLog(depName); + rs.next(); + zrzName = rs.getString("departmentname"); + }catch (Exception e){ + bb.writeLog(""+e); + } + map.put("zrz",zrzName); + map.put("jghwt",zrzName); // 机构或问题 也就是归档机构 + mapList.put("jghwt",zrzName); // 机构或问题 也就是归档机构 + + + String createrId="SELECT CREATER FROM workflow_requestbase WHERE REQUESTID="+requestid; + String jgryid =""; + try { + rs.execute(createrId); + rs.writeLog(createrId); + rs.next(); + jgryid = rs.getString("CREATER"); + }catch (Exception e){ + bb.writeLog(""+e); + } + + + String createrName="SELECT LASTNAME FROM hrmresource WHERE id=(SELECT CREATER FROM workflow_requestbase WHERE REQUESTID="+requestid+")"; + String jgryName =""; + try { + rs.execute(createrName); + rs.writeLog(createrName); + rs.next(); + jgryName = rs.getString("LASTNAME"); + }catch (Exception e){ + bb.writeLog(""+e); + } + + + String createrDepName="SELECT b.DEPARTMENTNAME FROM hrmresource a,hrmdepartment b WHERE a.departmentid = b.id AND a.ID=(SELECT CREATER FROM workflow_requestbase WHERE REQUESTID="+requestid+")"; + String jgryBmName =""; + try { + rs.execute(createrDepName); + rs.writeLog(createrDepName); + rs.next(); + jgryBmName = rs.getString("DEPARTMENTNAME"); + }catch (Exception e){ + bb.writeLog(""+e); + } + + + String nodeInfoSql="SELECT a.id,b.nodename,a.lastname,a.departmentname,a.receivedate,a.receivetime,a.operatedate,a.operatetime FROM (SELECT a.nodeid,a.receivedate,a.receivetime,a.operatedate,a.operatetime,c.lastname,a.requestid,c.id,c.departmentid,d.departmentname FROM workflow_currentoperator a,workflow_nodebase b,hrmresource c,hrmdepartment d" + + " WHERE a.nodeid=b.id AND a.processuser=c.id AND d.id=c.departmentid and a.requestid="+requestid+") a right JOIN (SELECT id ,nodename FROM workflow_nodebase WHERE id in(SELECT nodeid FROM workflow_currentoperator WHERE requestid="+requestid+")) b ON a.nodeid=b.id order by nodeid"; + List> nodeInfoList = new ArrayList<>(); + try { + RecordSet recordSet = new RecordSet(); + recordSet.execute(nodeInfoSql); + bb.writeLog("开始查询节点流程"); + while (recordSet.next()){ + Map nodeInfo = new HashMap<>(); + nodeInfo.put("id",recordSet.getString("id")); + nodeInfo.put("nodename",recordSet.getString("nodename")); + nodeInfo.put("lastname",recordSet.getString("lastname")); + nodeInfo.put("departmentname",recordSet.getString("departmentname")); + nodeInfo.put("receivedate",recordSet.getString("receivedate")); + nodeInfo.put("receivetime",recordSet.getString("receivetime")); + nodeInfo.put("operatedate",recordSet.getString("operatedate")); + nodeInfo.put("operatetime",recordSet.getString("operatetime")); + nodeInfoList.add(nodeInfo); + } + bb.writeLog("查询节点流程"); + }catch (Exception e){ + e.printStackTrace(); + } + bb.writeLog("节点信息-->"+nodeInfoList); + + bb.writeLog("查询出的附件-->"+fj); + String[] arr = fj.split(","); + List> fjList = new ArrayList<>(); + for (int i = 0; i < arr.length; i++) { + //附件 + String fjSQL="SELECT filerealpath,imagefilename FROM imagefile WHERE imagefileid ="+ arr[i]; + try { + RecordSet recordSet = new RecordSet(); + recordSet.execute(fjSQL); + bb.writeLog("开始附件列表"); + while (recordSet.next()){ + Map fjMap = new HashMap<>(); + String filerealpath = recordSet.getString("filerealpath"); + String imagefilename = recordSet.getString("imagefilename"); + int index = filerealpath.lastIndexOf("/"); + int index2 = imagefilename.lastIndexOf("."); + String zipPath = filerealpath.substring(index + 1); //压缩文件名 + String newname = imagefilename.substring(0, index2); + String fileNameNoEx = getFileNameNoEx(zipPath); + fjMap.put("filerealpath",filerealpath); + fjMap.put("imagefilename",imagefilename); + fjMap.put("fjUUID",fileNameNoEx); + fjList.add(fjMap); + } + bb.writeLog("查询附件结束 fjList.size()==="+fjList.size()); + }catch (Exception e){ + bb.writeLog("查询附件异常==="+e); + } + } + + mapList.put("ys",1); //页数 + mapList.put("zrz",zrzName); //责任者 部门名称 + mapList.put("jgryName",jgryName); //机构人员中文 + mapList.put("jgryBmName",jgryBmName); //机构人员部门名称 + mapList.put("jgryid",jgryid); //机构人员id + mapList.put("rq",da.replaceAll("-","")); //日期 + mapList.put("kzbs","推送"); // 控制标识 默认推送 + mapList.put("zw",ofdwj); // 正文 + mapList.put("zwofd",zwofdwj); // 正文ofd + mapList.put("nodeInfoList",nodeInfoList); // 节点信息 + if(fj!=null && fj!=""){ + mapList.put("fj",fj); //附件 + }else{ + mapList.put("fj","0"); //附件 + } + if(fj!=null && fj!=""){ + mapList.put("fj",fj); //附件 + }else{ + mapList.put("fj","0"); //附件 + } + if(fj!=null && fj!=""){ + mapList.put("fjList",fjList); //附件 + }else{ + mapList.put("fjList","0"); //附件 + } + +// mapList.put("cld",ofdwj); //处理单 + mapList.put("mj",mjstr); + + bb.writeLog("====文件呈批单==内部=444=map="+map.toString()); + bb.writeLog("====文件呈批单==内部=444=maplist="+mapList.toString()); + } + bb.writeLog("====文件呈批单===444=src="); + bb.writeLog("====文件呈批单===444=map="+map.toString()); + bb.writeLog("====文件呈批单===444=maplist="+mapList.toString()); + + String filerealpath = ""; +// String YJnewPath = "/home/WEAVER/ecology/DA/FWCB/"+str; //归档文件依据说明文件夹 +// String GDnewPath = "/home/WEAVER/ecology/DA/FWCB/"+str+"/"+time+"-"+requestid; //归档文件正文附件文件夹 + String YJnewPath = "/opt/weaver/oadata792/DAGD/JWJCPD/"+str; //归档文件依据说明文件夹 + String GDnewPath = "/opt/weaver/oadata792/DAGD/JWJCPD/"+str+"/"+time+"-"+requestid; //归档文件正文附件文件夹 + String zipname =str+".zip"; + String zippath = YJnewPath+".zip";//压缩包路径 + // 根据系统的实际情况选择目录分隔符bai(windows下是,dulinux下是/) +// linux下只认正斜杠,为了保证跨平台性,不建议使用反斜杠(在java程序中是转义字符,用\来表示反斜杠) + +// 在内存中创建一个文件对象,注意:此时还没有在硬盘对应目录下创建实实在在的文件 +// File f = new File(YJnewPath); +// bb.writeLog("====文件呈批单=====创建文件c="+YJnewPath); + bb.writeLog("====文件呈批单=====创建文件夹成功c="+YJnewPath); + + + File f2 = new File(GDnewPath+"/ww"); + bb.writeLog("====文件呈批单=====创建文件c="+GDnewPath); + if(f2.exists()) { + bb.writeLog("====文件呈批单=====创建文件夹="+f2.getAbsolutePath()); + + bb.writeLog("====文件呈批单=====创建文件夹="+f2.getName()); + bb.writeLog("====文件呈批单=====创建文件c="+f2.length()); + + bb.writeLog("-----"); + } else { +// 先创建文件所在的目录 + boolean su =f2.getParentFile().mkdirs(); + if(su==true){ + if(fj.length()>0){ + fjFilename(fj, GDnewPath); + } + if(zwofdwj.length()>0){ + fjFilename(zwofdwj, GDnewPath); + } + if(ofdwj.length()>0){ + String filename = filename(ofdwj, GDnewPath); + mapList.put("cld",filename); + } + } + + } + + bb.writeLog("====文件呈批单=====创建文件夹成功c="+GDnewPath); + //先创建文件夹,之后存放文件,再传递建模进行记录 + CreatXML creatXML = new CreatXML(); + try { + + creatXML.createYJSMXml(YJnewPath,map); + + } catch (Exception e) { + e.printStackTrace(); + bb.writeLog("文件呈批单----依据说明:" + e); + } + try { + creatXML.createGDWJXml(GDnewPath,mapList); + } catch (Exception e) { + e.printStackTrace(); + bb.writeLog("文件呈批单=====归档文件:" + e); + } + + bb.writeLog("====文件呈批单=====写入xml文件="+src); + bb.writeLog("====文件呈批单====文件方法="); + + File f1=null; + ZipOutputStream out=null; + String zip = YJnewPath+".zip"; +// try { +// f1= new File(YJnewPath); +// out = new ZipOutputStream(new FileOutputStream( +// YJnewPath+".zip")); +// zip(out,f1,null); +// } catch (FileNotFoundException e) { +// e.printStackTrace(); +// } catch (Exception e) { +// e.printStackTrace(); +// } + +// try { +// ZipUtil zipUtil = new ZipUtil(); +// zipUtil.zip(YJnewPath,zippath); +// } catch (Exception e) { +// e.printStackTrace(); +// } + zipu(YJnewPath,zippath); + bb.writeLog("====文件呈批单=====写入xml文件="+src); +// Date date = new Date(); +// String day = new SimpleDateFormat("yyyy-MM-dd").format(date); +// String daytime = new SimpleDateFormat("hh:mm").format(date); + Date date = new Date(); + String day = new SimpleDateFormat("yyyy-MM-dd").format(date); + String daytime = new SimpleDateFormat("hh:mm").format(date); + String da = new SimpleDateFormat("yyyy-MM-dd").format(date).replaceAll("-", ""); + //文件路径,收发文类别 0是收文 1是发文,文件夹名称,归档状态,流程id +// String insertsql = "insert into uf_dagd(wjlj,sfwlb,wjjmc,gdzt,lcid,lcgdrq,lcgdsj,ssbm,gdlcm) values('"+zippath+"','"+0+"','"+zipname+"','"+0+"','"+requestid+"','"+day+"','"+daytime+"','"+zrz+"','"+wjbt+"')"; + + String insertsql = "insert into uf_dagd(wjlj,sfwlb,wjjmc,gdzt,lcid,lcgdrq,lcgdsj,ssbm,gdlcm) values('" + zippath + "','" + 1 + "','" + zipname + "','" + 0 + "','" + requestid + "','" + day + "','" + daytime + "','" + zrz + "','" + wjbt + "')"; + RecordSet recordSet = new RecordSet(); + recordSet.execute(insertsql); + recordSet.writeLog("建模台账添加数据"+insertsql); + + return Action.SUCCESS; + } + +} diff --git a/src/com/engine/workflow/web/danganfiles/DA/JWJCYD_Action.java b/src/com/engine/workflow/web/danganfiles/DA/JWJCYD_Action.java new file mode 100644 index 0000000..87efe0e --- /dev/null +++ b/src/com/engine/workflow/web/danganfiles/DA/JWJCYD_Action.java @@ -0,0 +1,382 @@ + package com.engine.workflow.web.danganfiles.DA; + + +import com.engine.workflow.web.danganfiles.DA.util.CreatXML; +import weaver.conn.RecordSet; +import weaver.general.BaseBean; +import weaver.interfaces.workflow.action.Action; +import weaver.soa.workflow.request.RequestInfo; + +import java.io.File; +import java.text.SimpleDateFormat; +import java.util.*; +import java.util.zip.ZipOutputStream; + +import static com.engine.workflow.web.danganfiles.DA.util.JY_action.filename; +import static com.engine.workflow.web.danganfiles.DA.util.JY_action.fjFilename; +import static com.engine.workflow.web.danganfiles.DA.util.ZipFile.zipu; + +/** + * @author:CL + * @date:2023/4/3 10:20 + * 局文件传阅单 收文 + */ +@SuppressWarnings("all") +public class JWJCYD_Action implements Action { + + public static String getFileNameNoEx(String filename) { + + if ((filename != null) && (filename.length() > 0)) { + + int dot = filename.lastIndexOf('.'); + + if ((dot >-1) && (dot < (filename.length()))) { + + return filename.substring(0, dot); + + } + + } + + return filename; + + } + + @Override + public String execute(RequestInfo requestinfo) { + String creatorid = requestinfo.getCreatorid(); + + String sqls="select departmentid FROM HrmResource where lastname=?"; + RecordSet recordSet2=new RecordSet(); + recordSet2.executeQuery(sqls,creatorid); + String departmentid=null; + if(recordSet2.next()){ + departmentid = recordSet2.getString("departmentid"); + } + + BaseBean bb = new BaseBean(); + RecordSet rs = new RecordSet(); + List> list = new ArrayList>(); + bb.writeLog("====局文件传阅单 责任者id ==="+departmentid); + //=====================================================================读取主表数据 + bb.writeLog("====局文件传阅单========START="+requestinfo.getRequestid()); + String requestid = requestinfo.getRequestid(); //请求ID + + String src = requestinfo.getRequestManager().getSrc(); + bb.writeLog("====局文件传阅单=====src="+src); + //当前操作类型 submit:提交/reject:退回 + String workflowid = requestinfo.getWorkflowid(); //流程ID + String tablename = requestinfo.getRequestManager().getBillTableName();//表单名称 + + String sql = "select * from "+tablename+" where requestid = "+requestid; + + rs.execute(sql); + rs.writeLog(sql); + HashMap map = new HashMap(); // 依据说明 + HashMap mapList = new HashMap(); // 归档文件 + SimpleDateFormat fomat = new SimpleDateFormat("yyyyMMddHHmmss"); + String time = fomat.format(new Date()); + bb.writeLog(time); + + String dh =time+"-"+requestid; + UUID uuid = UUID.randomUUID(); + bb.writeLog(uuid); + String str = uuid.toString().replaceAll("-",""); + + String fj =""; + String ofdwj =""; + String zwofdwj =""; + String wjbt =""; +// String zrz="3"; //责任者id(部门id) + String zrz=departmentid; //责任者id(部门id) + if (rs.next()){ + String swrq1 = rs.getString("sj"); //收文日期 *** +// fj =rs.getString("fj"); //附件 + wjbt = rs.getString("bt0"); //文件标题 + String zsdw = rs.getString("zsdw"); //主送单位 + String csdw = rs.getString("csdw"); //抄送单位 +// int mj = rs.getInt("mj"); //密级 + String hj = rs.getString("hj"); // 缓急 + String ys = rs.getString("ys"); // 印数 + String wh = rs.getString("wh"); //文号 *** +// ngcs = rs.getString("szbm"); //拟稿处室 + String ngr = rs.getString("ngr"); //拟稿人 + String zw = rs.getString("zw"); // 正文 + ofdwj = rs.getString("fj"); // ofd文件 *** + zwofdwj = rs.getString("zwofdwj"); // ofd附件文件 +// String mjstr="内部"; //暂时用内部测试 等档案那边调整后 变为"" + String mjstr=""; //暂时用内部测试 等档案那边调整后 变为"" +// if(mj==0){ +// mjstr="非涉密"; +// }else if(mj==1){ +// mjstr="机密"; +// }else if(mj==2){ +// mjstr="秘密"; +// } + Date date = new Date(); + String da = new SimpleDateFormat("yyyy-MM-dd").format(date).replaceAll("-",""); + + bb.writeLog("====局文件传阅单=====文件添加数据="+time+requestid+wjbt+wh+ngr+da); + bb.writeLog("====局文件传阅单=====文件添加数据="+src); + map.put("dh",time+"-"+requestid); //档号,归档存储文件文件夹名称 + map.put("bt",wjbt); //标题 + map.put("bh",wh);//文号 +// map.put("zrz",ngcs); //责任者 + map.put("rq",swrq1.replaceAll("-","")); //日期 + map.put("ys",1); + + bb.writeLog("====局文件传阅单=====文件添加数据="+map); + + mapList.put("dh",str); //UUID档号 + mapList.put("wz","收文"); //文种 + mapList.put("bt",wjbt); //文件标题 + + + String depName="select departmentname from hrmdepartment where id="+zrz; + String zrzName =""; + try { + rs.execute(depName); + rs.writeLog(depName); + rs.next(); + zrzName = rs.getString("departmentname"); + }catch (Exception e){ + bb.writeLog(""+e); + } + map.put("zrz",zrzName); + map.put("jghwt",zrzName); // 机构或问题 也就是归档机构 + mapList.put("jghwt",zrzName); // 机构或问题 也就是归档机构 + + + + String createrId="SELECT CREATER FROM workflow_requestbase WHERE REQUESTID="+requestid; + String jgryid =""; + try { + rs.execute(createrId); + rs.writeLog(createrId); + rs.next(); + jgryid = rs.getString("CREATER"); + }catch (Exception e){ + bb.writeLog(""+e); + } + + + String createrName="SELECT LASTNAME FROM hrmresource WHERE id=(SELECT CREATER FROM workflow_requestbase WHERE REQUESTID="+requestid+")"; + String jgryName =""; + try { + rs.execute(createrName); + rs.writeLog(createrName); + rs.next(); + jgryName = rs.getString("LASTNAME"); + }catch (Exception e){ + bb.writeLog(""+e); + } + + + String createrDepName="SELECT b.DEPARTMENTNAME FROM hrmresource a,hrmdepartment b WHERE a.departmentid = b.id AND a.ID=(SELECT CREATER FROM workflow_requestbase WHERE REQUESTID="+requestid+")"; + String jgryBmName =""; + try { + rs.execute(createrDepName); + rs.writeLog(createrDepName); + rs.next(); + jgryBmName = rs.getString("DEPARTMENTNAME"); + }catch (Exception e){ + bb.writeLog(""+e); + } + + + String nodeInfoSql="SELECT a.id,b.nodename,a.lastname,a.departmentname,a.receivedate,a.receivetime,a.operatedate,a.operatetime FROM (SELECT a.nodeid,a.receivedate,a.receivetime,a.operatedate,a.operatetime,c.lastname,a.requestid,c.id,c.departmentid,d.departmentname FROM workflow_currentoperator a,workflow_nodebase b,hrmresource c,hrmdepartment d" + + " WHERE a.nodeid=b.id AND a.processuser=c.id AND d.id=c.departmentid and a.requestid="+requestid+") a right JOIN (SELECT id ,nodename FROM workflow_nodebase WHERE id in(SELECT nodeid FROM workflow_currentoperator WHERE requestid="+requestid+")) b ON a.nodeid=b.id order by nodeid"; + List> nodeInfoList = new ArrayList<>(); + try { + RecordSet recordSet = new RecordSet(); + recordSet.execute(nodeInfoSql); + bb.writeLog("开始查询节点流程"); + while (recordSet.next()){ + Map nodeInfo = new HashMap<>(); + nodeInfo.put("id",recordSet.getString("id")); + nodeInfo.put("nodename",recordSet.getString("nodename")); + nodeInfo.put("lastname",recordSet.getString("lastname")); + nodeInfo.put("departmentname",recordSet.getString("departmentname")); + nodeInfo.put("receivedate",recordSet.getString("receivedate")); + nodeInfo.put("receivetime",recordSet.getString("receivetime")); + nodeInfo.put("operatedate",recordSet.getString("operatedate")); + nodeInfo.put("operatetime",recordSet.getString("operatetime")); + nodeInfoList.add(nodeInfo); + } + bb.writeLog("查询节点流程"); + }catch (Exception e){ + e.printStackTrace(); + } + bb.writeLog("节点信息-->"+nodeInfoList); + + bb.writeLog("查询出的附件-->"+fj); + String[] arr = fj.split(","); + List> fjList = new ArrayList<>(); + for (int i = 0; i < arr.length; i++) { + //附件 + String fjSQL="SELECT filerealpath,imagefilename FROM imagefile WHERE imagefileid ="+ arr[i]; + try { + RecordSet recordSet = new RecordSet(); + recordSet.execute(fjSQL); + bb.writeLog("开始附件列表"); + while (recordSet.next()){ + Map fjMap = new HashMap<>(); + String filerealpath = recordSet.getString("filerealpath"); + String imagefilename = recordSet.getString("imagefilename"); + int index = filerealpath.lastIndexOf("/"); + int index2 = imagefilename.lastIndexOf("."); + String zipPath = filerealpath.substring(index + 1); //压缩文件名 + String newname = imagefilename.substring(0, index2); + String fileNameNoEx = getFileNameNoEx(zipPath); + fjMap.put("filerealpath",filerealpath); + fjMap.put("imagefilename",imagefilename); + fjMap.put("fjUUID",fileNameNoEx); + fjList.add(fjMap); + } + bb.writeLog("查询附件结束 fjList.size()==="+fjList.size()); + }catch (Exception e){ + bb.writeLog("查询附件异常==="+e); + } + } + + mapList.put("ys",1); //页数 + mapList.put("zrz",zrzName); //责任者 部门名称 + mapList.put("jgryName",jgryName); //机构人员中文 + mapList.put("jgryBmName",jgryBmName); //机构人员部门名称 + mapList.put("jgryid",jgryid); //机构人员id + mapList.put("rq",da.replaceAll("-","")); //日期 + mapList.put("kzbs","推送"); // 控制标识 默认推送 + mapList.put("zw",ofdwj); // 正文 + mapList.put("zwofd",zwofdwj); // 正文ofd + mapList.put("nodeInfoList",nodeInfoList); // 节点信息 + if(fj!=null && fj!=""){ + mapList.put("fj",fj); //附件 + }else{ + mapList.put("fj","0"); //附件 + } + if(fj!=null && fj!=""){ + mapList.put("fj",fj); //附件 + }else{ + mapList.put("fj","0"); //附件 + } + if(fj!=null && fj!=""){ + mapList.put("fjList",fjList); //附件 + }else{ + mapList.put("fjList","0"); //附件 + } + +// mapList.put("cld",ofdwj); //处理单 + mapList.put("mj",mjstr); + + bb.writeLog("====局文件传阅单==内部=444=map="+map.toString()); + bb.writeLog("====局文件传阅单==内部=444=maplist="+mapList.toString()); + } + bb.writeLog("====局文件传阅单===444=src="); + bb.writeLog("====局文件传阅单===444=map="+map.toString()); + bb.writeLog("====局文件传阅单===444=maplist="+mapList.toString()); + + String filerealpath = ""; +// String YJnewPath = "/home/WEAVER/ecology/DA/FWCB/"+str; //归档文件依据说明文件夹 +// String GDnewPath = "/home/WEAVER/ecology/DA/FWCB/"+str+"/"+time+"-"+requestid; //归档文件正文附件文件夹 + String YJnewPath = "/opt/weaver/oadata792/DAGD/JWJCYD/"+str; //归档文件依据说明文件夹 + String GDnewPath = "/opt/weaver/oadata792/DAGD/JWJCYD/"+str+"/"+time+"-"+requestid; //归档文件正文附件文件夹 + String zipname =str+".zip"; + String zippath = YJnewPath+".zip";//压缩包路径 + // 根据系统的实际情况选择目录分隔符bai(windows下是,dulinux下是/) +// linux下只认正斜杠,为了保证跨平台性,不建议使用反斜杠(在java程序中是转义字符,用\来表示反斜杠) + +// 在内存中创建一个文件对象,注意:此时还没有在硬盘对应目录下创建实实在在的文件 +// File f = new File(YJnewPath); +// bb.writeLog("====局文件传阅单=====创建文件c="+YJnewPath); + bb.writeLog("====局文件传阅单=====创建文件夹成功c="+YJnewPath); + + + File f2 = new File(GDnewPath+"/ww"); + bb.writeLog("====局文件传阅单=====创建文件c="+GDnewPath); + if(f2.exists()) { + bb.writeLog("====局文件传阅单=====创建文件夹="+f2.getAbsolutePath()); + + bb.writeLog("====局文件传阅单=====创建文件夹="+f2.getName()); + bb.writeLog("====局文件传阅单=====创建文件c="+f2.length()); + + bb.writeLog("-----"); + } else { +// 先创建文件所在的目录 + boolean su =f2.getParentFile().mkdirs(); + if(su==true){ + if(fj.length()>0){ + fjFilename(fj, GDnewPath); + } + if(zwofdwj.length()>0){ + fjFilename(zwofdwj, GDnewPath); + } + if(ofdwj.length()>0){ + String filename = filename(ofdwj, GDnewPath); + mapList.put("cld",filename); + } + } + + } + + bb.writeLog("====局文件传阅单=====创建文件夹成功c="+GDnewPath); + //先创建文件夹,之后存放文件,再传递建模进行记录 + CreatXML creatXML = new CreatXML(); + try { + + creatXML.createYJSMXml(YJnewPath,map); + + } catch (Exception e) { + e.printStackTrace(); + bb.writeLog("局文件传阅单----依据说明:" + e); + } + try { + creatXML.createGDWJXml(GDnewPath,mapList); + } catch (Exception e) { + e.printStackTrace(); + bb.writeLog("局文件传阅单=====归档文件:" + e); + } + + bb.writeLog("====局文件传阅单=====写入xml文件="+src); + bb.writeLog("====局文件传阅单====文件方法="); + + File f1=null; + ZipOutputStream out=null; + String zip = YJnewPath+".zip"; +// try { +// f1= new File(YJnewPath); +// out = new ZipOutputStream(new FileOutputStream( +// YJnewPath+".zip")); +// zip(out,f1,null); +// } catch (FileNotFoundException e) { +// e.printStackTrace(); +// } catch (Exception e) { +// e.printStackTrace(); +// } + +// try { +// ZipUtil zipUtil = new ZipUtil(); +// zipUtil.zip(YJnewPath,zippath); +// } catch (Exception e) { +// e.printStackTrace(); +// } + zipu(YJnewPath,zippath); + bb.writeLog("====局文件传阅单=====写入xml文件="+src); +// Date date = new Date(); +// String day = new SimpleDateFormat("yyyy-MM-dd").format(date); +// String daytime = new SimpleDateFormat("hh:mm").format(date); + Date date = new Date(); + String day = new SimpleDateFormat("yyyy-MM-dd").format(date); + String daytime = new SimpleDateFormat("hh:mm").format(date); + String da = new SimpleDateFormat("yyyy-MM-dd").format(date).replaceAll("-", ""); + //文件路径,收发文类别 0是收文 1是发文,文件夹名称,归档状态,流程id +// String insertsql = "insert into uf_dagd(wjlj,sfwlb,wjjmc,gdzt,lcid,lcgdrq,lcgdsj,ssbm,gdlcm) values('"+zippath+"','"+0+"','"+zipname+"','"+0+"','"+requestid+"','"+day+"','"+daytime+"','"+zrz+"','"+wjbt+"')"; + + String insertsql = "insert into uf_dagd(wjlj,sfwlb,wjjmc,gdzt,lcid,lcgdrq,lcgdsj,ssbm,gdlcm) values('" + zippath + "','" + 0 + "','" + zipname + "','" + 0 + "','" + requestid + "','" + day + "','" + daytime + "','" + zrz + "','" + wjbt + "')"; + RecordSet recordSet = new RecordSet(); + recordSet.execute(insertsql); + recordSet.writeLog("建模台账添加数据"+insertsql); + + return Action.SUCCESS; + } + +} diff --git a/src/com/engine/workflow/web/danganfiles/DA/SWBLCPD_Action.java b/src/com/engine/workflow/web/danganfiles/DA/SWBLCPD_Action.java new file mode 100644 index 0000000..24b8cac --- /dev/null +++ b/src/com/engine/workflow/web/danganfiles/DA/SWBLCPD_Action.java @@ -0,0 +1,382 @@ +package com.engine.workflow.web.danganfiles.DA; + + +import com.engine.workflow.web.danganfiles.DA.util.CreatXML; +import weaver.conn.RecordSet; +import weaver.general.BaseBean; +import weaver.interfaces.workflow.action.Action; +import weaver.soa.workflow.request.RequestInfo; + +import java.io.File; +import java.text.SimpleDateFormat; +import java.util.*; +import java.util.zip.ZipOutputStream; + +import static com.engine.workflow.web.danganfiles.DA.util.JY_action.filename; +import static com.engine.workflow.web.danganfiles.DA.util.JY_action.fjFilename; +import static com.engine.workflow.web.danganfiles.DA.util.ZipFile.zipu; + +/** + * @author:CL + * @date:2023/4/3 10:20 + * 收文办理呈批单 + */ +@SuppressWarnings("all") +public class SWBLCPD_Action implements Action { + + public static String getFileNameNoEx(String filename) { + + if ((filename != null) && (filename.length() > 0)) { + + int dot = filename.lastIndexOf('.'); + + if ((dot >-1) && (dot < (filename.length()))) { + + return filename.substring(0, dot); + + } + + } + + return filename; + + } + + @Override + public String execute(RequestInfo requestinfo) { + String creatorid = requestinfo.getCreatorid(); + + String sqls="select departmentid FROM HrmResource where lastname=?"; + RecordSet recordSet2=new RecordSet(); + recordSet2.executeQuery(sqls,creatorid); + String departmentid=null; + if(recordSet2.next()){ + departmentid = recordSet2.getString("departmentid"); + } + + BaseBean bb = new BaseBean(); + RecordSet rs = new RecordSet(); + List> list = new ArrayList>(); + bb.writeLog("====收文办理呈批单 责任者id ==="+departmentid); + //=====================================================================读取主表数据 + bb.writeLog("====收文办理呈批单========START="+requestinfo.getRequestid()); + String requestid = requestinfo.getRequestid(); //请求ID + + String src = requestinfo.getRequestManager().getSrc(); + bb.writeLog("====收文办理呈批单=====src="+src); + //当前操作类型 submit:提交/reject:退回 + String workflowid = requestinfo.getWorkflowid(); //流程ID + String tablename = requestinfo.getRequestManager().getBillTableName();//表单名称 + + String sql = "select * from "+tablename+" where requestid = "+requestid; + + rs.execute(sql); + rs.writeLog(sql); + HashMap map = new HashMap(); // 依据说明 + HashMap mapList = new HashMap(); // 归档文件 + SimpleDateFormat fomat = new SimpleDateFormat("yyyyMMddHHmmss"); + String time = fomat.format(new Date()); + bb.writeLog(time); + + String dh =time+"-"+requestid; + UUID uuid = UUID.randomUUID(); + bb.writeLog(uuid); + String str = uuid.toString().replaceAll("-",""); + + String fj =""; + String ofdwj =""; + String zwofdwj =""; + String wjbt =""; +// String zrz="3"; //责任者id(部门id) + String zrz=departmentid; //责任者id(部门id) + if (rs.next()){ + String swrq1 = rs.getString("swrq1"); //收文日期 +// fj =rs.getString("fj"); //附件 + wjbt = rs.getString("bt2"); //文件标题 ** + String zsdw = rs.getString("zsdw"); //主送单位 + String csdw = rs.getString("csdw"); //抄送单位 +// int mj = rs.getInt("mj"); //密级 + String hj = rs.getString("hj"); // 缓急 + String ys = rs.getString("ys"); // 印数 + String wh = rs.getString("wh"); //文号 ** +// ngcs = rs.getString("szbm"); //拟稿处室 + String ngr = rs.getString("ngr"); //拟稿人 + String zw = rs.getString("zw"); // 正文 + ofdwj = rs.getString("fj"); // ofd文件 ** + zwofdwj = rs.getString("zwofdwj"); // ofd附件文件 +// String mjstr="内部"; //暂时用内部测试 等档案那边调整后 变为"" + String mjstr=""; //暂时用内部测试 等档案那边调整后 变为"" +// if(mj==0){ +// mjstr="非涉密"; +// }else if(mj==1){ +// mjstr="机密"; +// }else if(mj==2){ +// mjstr="秘密"; +// } + Date date = new Date(); + String da = new SimpleDateFormat("yyyy-MM-dd").format(date).replaceAll("-",""); + + bb.writeLog("====收文办理呈批单=====文件添加数据="+time+requestid+wjbt+wh+ngr+da); + bb.writeLog("====收文办理呈批单=====文件添加数据="+src); + map.put("dh",time+"-"+requestid); //档号,归档存储文件文件夹名称 + map.put("bt",wjbt); //标题 + map.put("bh",wh);//文号 +// map.put("zrz",ngcs); //责任者 + map.put("rq",swrq1.replaceAll("-","")); //日期 + map.put("ys",1); + + bb.writeLog("====收文办理呈批单=====文件添加数据="+map); + + mapList.put("dh",str); //UUID档号 + mapList.put("wz","收文"); //文种 + mapList.put("bt",wjbt); //文件标题 + + + String depName="select departmentname from hrmdepartment where id="+zrz; + String zrzName =""; + try { + rs.execute(depName); + rs.writeLog(depName); + rs.next(); + zrzName = rs.getString("departmentname"); + }catch (Exception e){ + bb.writeLog(""+e); + } + map.put("zrz",zrzName); + map.put("jghwt",zrzName); // 机构或问题 也就是归档机构 + mapList.put("jghwt",zrzName); // 机构或问题 也就是归档机构 + + + + String createrId="SELECT CREATER FROM workflow_requestbase WHERE REQUESTID="+requestid; + String jgryid =""; + try { + rs.execute(createrId); + rs.writeLog(createrId); + rs.next(); + jgryid = rs.getString("CREATER"); + }catch (Exception e){ + bb.writeLog(""+e); + } + + + String createrName="SELECT LASTNAME FROM hrmresource WHERE id=(SELECT CREATER FROM workflow_requestbase WHERE REQUESTID="+requestid+")"; + String jgryName =""; + try { + rs.execute(createrName); + rs.writeLog(createrName); + rs.next(); + jgryName = rs.getString("LASTNAME"); + }catch (Exception e){ + bb.writeLog(""+e); + } + + + String createrDepName="SELECT b.DEPARTMENTNAME FROM hrmresource a,hrmdepartment b WHERE a.departmentid = b.id AND a.ID=(SELECT CREATER FROM workflow_requestbase WHERE REQUESTID="+requestid+")"; + String jgryBmName =""; + try { + rs.execute(createrDepName); + rs.writeLog(createrDepName); + rs.next(); + jgryBmName = rs.getString("DEPARTMENTNAME"); + }catch (Exception e){ + bb.writeLog(""+e); + } + + + String nodeInfoSql="SELECT a.id,b.nodename,a.lastname,a.departmentname,a.receivedate,a.receivetime,a.operatedate,a.operatetime FROM (SELECT a.nodeid,a.receivedate,a.receivetime,a.operatedate,a.operatetime,c.lastname,a.requestid,c.id,c.departmentid,d.departmentname FROM workflow_currentoperator a,workflow_nodebase b,hrmresource c,hrmdepartment d" + + " WHERE a.nodeid=b.id AND a.processuser=c.id AND d.id=c.departmentid and a.requestid="+requestid+") a right JOIN (SELECT id ,nodename FROM workflow_nodebase WHERE id in(SELECT nodeid FROM workflow_currentoperator WHERE requestid="+requestid+")) b ON a.nodeid=b.id order by nodeid"; + List> nodeInfoList = new ArrayList<>(); + try { + RecordSet recordSet = new RecordSet(); + recordSet.execute(nodeInfoSql); + bb.writeLog("开始查询节点流程"); + while (recordSet.next()){ + Map nodeInfo = new HashMap<>(); + nodeInfo.put("id",recordSet.getString("id")); + nodeInfo.put("nodename",recordSet.getString("nodename")); + nodeInfo.put("lastname",recordSet.getString("lastname")); + nodeInfo.put("departmentname",recordSet.getString("departmentname")); + nodeInfo.put("receivedate",recordSet.getString("receivedate")); + nodeInfo.put("receivetime",recordSet.getString("receivetime")); + nodeInfo.put("operatedate",recordSet.getString("operatedate")); + nodeInfo.put("operatetime",recordSet.getString("operatetime")); + nodeInfoList.add(nodeInfo); + } + bb.writeLog("查询节点流程"); + }catch (Exception e){ + e.printStackTrace(); + } + bb.writeLog("节点信息-->"+nodeInfoList); + + bb.writeLog("查询出的附件-->"+fj); + String[] arr = fj.split(","); + List> fjList = new ArrayList<>(); + for (int i = 0; i < arr.length; i++) { + //附件 + String fjSQL="SELECT filerealpath,imagefilename FROM imagefile WHERE imagefileid ="+ arr[i]; + try { + RecordSet recordSet = new RecordSet(); + recordSet.execute(fjSQL); + bb.writeLog("开始附件列表"); + while (recordSet.next()){ + Map fjMap = new HashMap<>(); + String filerealpath = recordSet.getString("filerealpath"); + String imagefilename = recordSet.getString("imagefilename"); + int index = filerealpath.lastIndexOf("/"); + int index2 = imagefilename.lastIndexOf("."); + String zipPath = filerealpath.substring(index + 1); //压缩文件名 + String newname = imagefilename.substring(0, index2); + String fileNameNoEx = getFileNameNoEx(zipPath); + fjMap.put("filerealpath",filerealpath); + fjMap.put("imagefilename",imagefilename); + fjMap.put("fjUUID",fileNameNoEx); + fjList.add(fjMap); + } + bb.writeLog("查询附件结束 fjList.size()==="+fjList.size()); + }catch (Exception e){ + bb.writeLog("查询附件异常==="+e); + } + } + + mapList.put("ys",1); //页数 + mapList.put("zrz",zrzName); //责任者 部门名称 + mapList.put("jgryName",jgryName); //机构人员中文 + mapList.put("jgryBmName",jgryBmName); //机构人员部门名称 + mapList.put("jgryid",jgryid); //机构人员id + mapList.put("rq",da.replaceAll("-","")); //日期 + mapList.put("kzbs","推送"); // 控制标识 默认推送 + mapList.put("zw",ofdwj); // 正文 + mapList.put("zwofd",zwofdwj); // 正文ofd + mapList.put("nodeInfoList",nodeInfoList); // 节点信息 + if(fj!=null && fj!=""){ + mapList.put("fj",fj); //附件 + }else{ + mapList.put("fj","0"); //附件 + } + if(fj!=null && fj!=""){ + mapList.put("fj",fj); //附件 + }else{ + mapList.put("fj","0"); //附件 + } + if(fj!=null && fj!=""){ + mapList.put("fjList",fjList); //附件 + }else{ + mapList.put("fjList","0"); //附件 + } + +// mapList.put("cld",ofdwj); //处理单 + mapList.put("mj",mjstr); + + bb.writeLog("====收文办理呈批单==内部=444=map="+map.toString()); + bb.writeLog("====收文办理呈批单==内部=444=maplist="+mapList.toString()); + } + bb.writeLog("====收文办理呈批单===444=src="); + bb.writeLog("====收文办理呈批单===444=map="+map.toString()); + bb.writeLog("====收文办理呈批单===444=maplist="+mapList.toString()); + + String filerealpath = ""; +// String YJnewPath = "/home/WEAVER/ecology/DA/FWCB/"+str; //归档文件依据说明文件夹 +// String GDnewPath = "/home/WEAVER/ecology/DA/FWCB/"+str+"/"+time+"-"+requestid; //归档文件正文附件文件夹 + String YJnewPath = "/opt/weaver/oadata792/DAGD/SWBLCPD/"+str; //归档文件依据说明文件夹 + String GDnewPath = "/opt/weaver/oadata792/DAGD/SWBLCPD/"+str+"/"+time+"-"+requestid; //归档文件正文附件文件夹 + String zipname =str+".zip"; + String zippath = YJnewPath+".zip";//压缩包路径 + // 根据系统的实际情况选择目录分隔符bai(windows下是,dulinux下是/) +// linux下只认正斜杠,为了保证跨平台性,不建议使用反斜杠(在java程序中是转义字符,用\来表示反斜杠) + +// 在内存中创建一个文件对象,注意:此时还没有在硬盘对应目录下创建实实在在的文件 +// File f = new File(YJnewPath); +// bb.writeLog("====收文办理呈批单=====创建文件c="+YJnewPath); + bb.writeLog("====收文办理呈批单=====创建文件夹成功c="+YJnewPath); + + + File f2 = new File(GDnewPath+"/ww"); + bb.writeLog("====收文办理呈批单=====创建文件c="+GDnewPath); + if(f2.exists()) { + bb.writeLog("====收文办理呈批单=====创建文件夹="+f2.getAbsolutePath()); + + bb.writeLog("====收文办理呈批单=====创建文件夹="+f2.getName()); + bb.writeLog("====收文办理呈批单=====创建文件c="+f2.length()); + + bb.writeLog("-----"); + } else { +// 先创建文件所在的目录 + boolean su =f2.getParentFile().mkdirs(); + if(su==true){ + if(fj.length()>0){ + fjFilename(fj, GDnewPath); + } + if(zwofdwj.length()>0){ + fjFilename(zwofdwj, GDnewPath); + } + if(ofdwj.length()>0){ + String filename = filename(ofdwj, GDnewPath); + mapList.put("cld",filename); + } + } + + } + + bb.writeLog("====收文办理呈批单=====创建文件夹成功c="+GDnewPath); + //先创建文件夹,之后存放文件,再传递建模进行记录 + CreatXML creatXML = new CreatXML(); + try { + + creatXML.createYJSMXml(YJnewPath,map); + + } catch (Exception e) { + e.printStackTrace(); + bb.writeLog("收文办理呈批单----依据说明:" + e); + } + try { + creatXML.createGDWJXml(GDnewPath,mapList); + } catch (Exception e) { + e.printStackTrace(); + bb.writeLog("收文办理呈批单=====归档文件:" + e); + } + + bb.writeLog("====收文办理呈批单=====写入xml文件="+src); + bb.writeLog("====收文办理呈批单====文件方法="); + + File f1=null; + ZipOutputStream out=null; + String zip = YJnewPath+".zip"; +// try { +// f1= new File(YJnewPath); +// out = new ZipOutputStream(new FileOutputStream( +// YJnewPath+".zip")); +// zip(out,f1,null); +// } catch (FileNotFoundException e) { +// e.printStackTrace(); +// } catch (Exception e) { +// e.printStackTrace(); +// } + +// try { +// ZipUtil zipUtil = new ZipUtil(); +// zipUtil.zip(YJnewPath,zippath); +// } catch (Exception e) { +// e.printStackTrace(); +// } + zipu(YJnewPath,zippath); + bb.writeLog("====收文办理呈批单=====写入xml文件="+src); +// Date date = new Date(); +// String day = new SimpleDateFormat("yyyy-MM-dd").format(date); +// String daytime = new SimpleDateFormat("hh:mm").format(date); + Date date = new Date(); + String day = new SimpleDateFormat("yyyy-MM-dd").format(date); + String daytime = new SimpleDateFormat("hh:mm").format(date); + String da = new SimpleDateFormat("yyyy-MM-dd").format(date).replaceAll("-", ""); + //文件路径,收发文类别0是收文1是发文,文件夹名称,归档状态,流程id +// String insertsql = "insert into uf_dagd(wjlj,sfwlb,wjjmc,gdzt,lcid,lcgdrq,lcgdsj,ssbm,gdlcm) values('"+zippath+"','"+0+"','"+zipname+"','"+0+"','"+requestid+"','"+day+"','"+daytime+"','"+zrz+"','"+wjbt+"')"; + + String insertsql = "insert into uf_dagd(wjlj,sfwlb,wjjmc,gdzt,lcid,lcgdrq,lcgdsj,ssbm,gdlcm) values('" + zippath + "','" + 0 + "','" + zipname + "','" + 0 + "','" + requestid + "','" + day + "','" + daytime + "','" + zrz + "','" + wjbt + "')"; + RecordSet recordSet = new RecordSet(); + recordSet.execute(insertsql); + recordSet.writeLog("建模台账添加数据"+insertsql); + + return Action.SUCCESS; + } + +} diff --git a/src/com/engine/workflow/web/danganfiles/DA/YZSQ_Action.java b/src/com/engine/workflow/web/danganfiles/DA/YZSQ_Action.java new file mode 100644 index 0000000..0275cd7 --- /dev/null +++ b/src/com/engine/workflow/web/danganfiles/DA/YZSQ_Action.java @@ -0,0 +1,389 @@ +package com.engine.workflow.web.danganfiles.DA; + + +import com.engine.workflow.web.danganfiles.DA.util.CreatXML; +import weaver.conn.RecordSet; +import weaver.general.BaseBean; +import weaver.interfaces.workflow.action.Action; +import weaver.soa.workflow.request.RequestInfo; + +import java.io.File; +import java.text.SimpleDateFormat; +import java.util.*; +import java.util.zip.ZipOutputStream; + +import static com.engine.workflow.web.danganfiles.DA.util.JY_action.filename; +import static com.engine.workflow.web.danganfiles.DA.util.JY_action.fjFilename; +import static com.engine.workflow.web.danganfiles.DA.util.ZipFile.zipu; + +/** + * @author:CL + * @date:2023/4/3 10:20 + * 用章申请 发文 + */ +@SuppressWarnings("all") +public class YZSQ_Action implements Action { + + public static String getFileNameNoEx(String filename) { + + if ((filename != null) && (filename.length() > 0)) { + + int dot = filename.lastIndexOf('.'); + + if ((dot >-1) && (dot < (filename.length()))) { + + return filename.substring(0, dot); + + } + + } + + return filename; + + } + + @Override + public String execute(RequestInfo requestinfo) { + String creatorid = requestinfo.getCreatorid(); + + String sqls="select departmentid FROM HrmResource where lastname=?"; + RecordSet recordSet2=new RecordSet(); + recordSet2.executeQuery(sqls,creatorid); + String departmentid=null; + if(recordSet2.next()){ + departmentid = recordSet2.getString("departmentid"); + } + + + BaseBean bb = new BaseBean(); + RecordSet rs = new RecordSet(); + List> list = new ArrayList>(); + bb.writeLog("====用章申请 责任者id ==="+departmentid); + + //=====================================================================读取主表数据 + bb.writeLog("====用章申请========START="+requestinfo.getRequestid()); + String requestid = requestinfo.getRequestid(); //请求ID + + String src = requestinfo.getRequestManager().getSrc(); + bb.writeLog("====用章申请=====src="+src); + //当前操作类型 submit:提交/reject:退回 + String workflowid = requestinfo.getWorkflowid(); //流程ID + String tablename = requestinfo.getRequestManager().getBillTableName();//表单名称 + + String sql = "select * from "+tablename+" where requestid = "+requestid; + + rs.execute(sql); + rs.writeLog(sql); + HashMap map = new HashMap(); // 依据说明 + HashMap mapList = new HashMap(); // 归档文件 + SimpleDateFormat fomat = new SimpleDateFormat("yyyyMMddHHmmss"); + String time = fomat.format(new Date()); + bb.writeLog(time); + + String dh =time+"-"+requestid; + UUID uuid = UUID.randomUUID(); + bb.writeLog(uuid); + String str = uuid.toString().replaceAll("-",""); + + String fj =""; + String ofdwj =""; + String zwofdwj =""; + String wjbt =""; +// String zrz="3"; //责任者id(部门id) + String zrz=departmentid; //责任者id(部门id) + + if (rs.next()){ + String gjz=rs.getString("yzmc"); + String swrq1 = rs.getString("syrq2"); //收文日期 *** +// fj =rs.getString("fj"); //附件 +// wjbt = rs.getString("cpwjbt"); //文件标题 + wjbt="用章申请"; + String zsdw = rs.getString("wjfsdw"); //主送单位 + String csdw = rs.getString("csdw"); //抄送单位 +// int mj = rs.getInt("mj"); //密级 + String hj = rs.getString("hj"); // 缓急 + String ys = rs.getString("ys"); // 印数 + String wh = rs.getString("wh"); //文号 +// ngcs = rs.getString("szbm"); //拟稿处室 + String ngr = rs.getString("ngr"); //拟稿人 + String zw = rs.getString("zw"); // 正文 + ofdwj = rs.getString("fj"); // ofd文件 + zwofdwj = rs.getString("zwofdwj"); // ofd附件文件 +// String mjstr="内部"; //暂时用内部测试 等档案那边调整后 变为"" + String mjstr=""; //暂时用内部测试 等档案那边调整后 变为"" +// if(mj==0){ +// mjstr="非涉密"; +// }else if(mj==1){ +// mjstr="机密"; +// }else if(mj==2){ +// mjstr="秘密"; +// } + Date date = new Date(); + String da = new SimpleDateFormat("yyyy-MM-dd").format(date).replaceAll("-",""); + + bb.writeLog("====用章申请=====文件添加数据="+time+requestid+wjbt+wh+ngr+da); + bb.writeLog("====用章申请=====文件添加数据="+src); + map.put("dh",time+"-"+requestid); //档号,归档存储文件文件夹名称 + map.put("bt",wjbt); //标题 + map.put("bh",wh);//文号 +// map.put("zrz",ngcs); //责任者 + map.put("rq",swrq1.replaceAll("-","")); //日期 + map.put("ys",1); + map.put("zsdw",zsdw); + map.put("gjz",gjz); + + bb.writeLog("====用章申请=====文件添加数据="+map); + + mapList.put("dh",str); //UUID档号 + mapList.put("wz","发文"); //文种 + mapList.put("bt",wjbt); //文件标题 + + + String depName="select departmentname from hrmdepartment where id="+zrz; + String zrzName =""; + try { + rs.execute(depName); + rs.writeLog(depName); + rs.next(); + zrzName = rs.getString("departmentname"); + }catch (Exception e){ + bb.writeLog(""+e); + } + map.put("zrz",zrzName); + map.put("jghwt",zrzName); // 机构或问题 也就是归档机构 + mapList.put("jghwt",zrzName); // 机构或问题 也就是归档机构 + + + + String createrId="SELECT CREATER FROM workflow_requestbase WHERE REQUESTID="+requestid; + String jgryid =""; + try { + rs.execute(createrId); + rs.writeLog(createrId); + rs.next(); + jgryid = rs.getString("CREATER"); + }catch (Exception e){ + bb.writeLog(""+e); + } + + + String createrName="SELECT LASTNAME FROM hrmresource WHERE id=(SELECT CREATER FROM workflow_requestbase WHERE REQUESTID="+requestid+")"; + String jgryName =""; + try { + rs.execute(createrName); + rs.writeLog(createrName); + rs.next(); + jgryName = rs.getString("LASTNAME"); + }catch (Exception e){ + bb.writeLog(""+e); + } + + + String createrDepName="SELECT b.DEPARTMENTNAME FROM hrmresource a,hrmdepartment b WHERE a.departmentid = b.id AND a.ID=(SELECT CREATER FROM workflow_requestbase WHERE REQUESTID="+requestid+")"; + String jgryBmName =""; + try { + rs.execute(createrDepName); + rs.writeLog(createrDepName); + rs.next(); + jgryBmName = rs.getString("DEPARTMENTNAME"); + }catch (Exception e){ + bb.writeLog(""+e); + } + + + String nodeInfoSql="SELECT a.id,b.nodename,a.lastname,a.departmentname,a.receivedate,a.receivetime,a.operatedate,a.operatetime FROM (SELECT a.nodeid,a.receivedate,a.receivetime,a.operatedate,a.operatetime,c.lastname,a.requestid,c.id,c.departmentid,d.departmentname FROM workflow_currentoperator a,workflow_nodebase b,hrmresource c,hrmdepartment d" + + " WHERE a.nodeid=b.id AND a.processuser=c.id AND d.id=c.departmentid and a.requestid="+requestid+") a right JOIN (SELECT id ,nodename FROM workflow_nodebase WHERE id in(SELECT nodeid FROM workflow_currentoperator WHERE requestid="+requestid+")) b ON a.nodeid=b.id order by nodeid"; + List> nodeInfoList = new ArrayList<>(); + try { + RecordSet recordSet = new RecordSet(); + recordSet.execute(nodeInfoSql); + bb.writeLog("开始查询节点流程"); + while (recordSet.next()){ + Map nodeInfo = new HashMap<>(); + nodeInfo.put("id",recordSet.getString("id")); + nodeInfo.put("nodename",recordSet.getString("nodename")); + nodeInfo.put("lastname",recordSet.getString("lastname")); + nodeInfo.put("departmentname",recordSet.getString("departmentname")); + nodeInfo.put("receivedate",recordSet.getString("receivedate")); + nodeInfo.put("receivetime",recordSet.getString("receivetime")); + nodeInfo.put("operatedate",recordSet.getString("operatedate")); + nodeInfo.put("operatetime",recordSet.getString("operatetime")); + nodeInfoList.add(nodeInfo); + } + bb.writeLog("查询节点流程"); + }catch (Exception e){ + e.printStackTrace(); + } + bb.writeLog("节点信息-->"+nodeInfoList); + + bb.writeLog("查询出的附件-->"+fj); + String[] arr = fj.split(","); + List> fjList = new ArrayList<>(); + for (int i = 0; i < arr.length; i++) { + //附件 + String fjSQL="SELECT filerealpath,imagefilename FROM imagefile WHERE imagefileid ="+ arr[i]; + try { + RecordSet recordSet = new RecordSet(); + recordSet.execute(fjSQL); + bb.writeLog("开始附件列表"); + while (recordSet.next()){ + Map fjMap = new HashMap<>(); + String filerealpath = recordSet.getString("filerealpath"); + String imagefilename = recordSet.getString("imagefilename"); + int index = filerealpath.lastIndexOf("/"); + int index2 = imagefilename.lastIndexOf("."); + String zipPath = filerealpath.substring(index + 1); //压缩文件名 + String newname = imagefilename.substring(0, index2); + String fileNameNoEx = getFileNameNoEx(zipPath); + fjMap.put("filerealpath",filerealpath); + fjMap.put("imagefilename",imagefilename); + fjMap.put("fjUUID",fileNameNoEx); + fjList.add(fjMap); + } + bb.writeLog("查询附件结束 fjList.size()==="+fjList.size()); + }catch (Exception e){ + bb.writeLog("查询附件异常==="+e); + } + } + + mapList.put("ys",1); //页数 + mapList.put("zrz",zrzName); //责任者 部门名称 + mapList.put("jgryName",jgryName); //机构人员中文 + mapList.put("jgryBmName",jgryBmName); //机构人员部门名称 + mapList.put("jgryid",jgryid); //机构人员id + mapList.put("rq",da.replaceAll("-","")); //日期 + mapList.put("kzbs","推送"); // 控制标识 默认推送 + mapList.put("zw",ofdwj); // 正文 + mapList.put("zwofd",zwofdwj); // 正文ofd + mapList.put("nodeInfoList",nodeInfoList); // 节点信息 + if(fj!=null && fj!=""){ + mapList.put("fj",fj); //附件 + }else{ + mapList.put("fj","0"); //附件 + } + if(fj!=null && fj!=""){ + mapList.put("fj",fj); //附件 + }else{ + mapList.put("fj","0"); //附件 + } + if(fj!=null && fj!=""){ + mapList.put("fjList",fjList); //附件 + }else{ + mapList.put("fjList","0"); //附件 + } + +// mapList.put("cld",ofdwj); //处理单 + mapList.put("mj",mjstr); + + bb.writeLog("====用章申请==内部=444=map="+map.toString()); + bb.writeLog("====用章申请==内部=444=maplist="+mapList.toString()); + } + bb.writeLog("====用章申请===444=src="); + bb.writeLog("====用章申请===444=map="+map.toString()); + bb.writeLog("====用章申请===444=maplist="+mapList.toString()); + + String filerealpath = ""; +// String YJnewPath = "/home/WEAVER/ecology/DA/FWCB/"+str; //归档文件依据说明文件夹 +// String GDnewPath = "/home/WEAVER/ecology/DA/FWCB/"+str+"/"+time+"-"+requestid; //归档文件正文附件文件夹 + String YJnewPath = "/opt/weaver/oadata792/DAGD/YZSQ/"+str; //归档文件依据说明文件夹 + String GDnewPath = "/opt/weaver/oadata792/DAGD/YZSQ/"+str+"/"+time+"-"+requestid; //归档文件正文附件文件夹 + String zipname =str+".zip"; + String zippath = YJnewPath+".zip";//压缩包路径 + // 根据系统的实际情况选择目录分隔符bai(windows下是,dulinux下是/) +// linux下只认正斜杠,为了保证跨平台性,不建议使用反斜杠(在java程序中是转义字符,用\来表示反斜杠) + +// 在内存中创建一个文件对象,注意:此时还没有在硬盘对应目录下创建实实在在的文件 +// File f = new File(YJnewPath); +// bb.writeLog("====用章申请=====创建文件c="+YJnewPath); + bb.writeLog("====用章申请=====创建文件夹成功c="+YJnewPath); + + + File f2 = new File(GDnewPath+"/ww"); + bb.writeLog("====用章申请=====创建文件c="+GDnewPath); + if(f2.exists()) { + bb.writeLog("====用章申请=====创建文件夹="+f2.getAbsolutePath()); + + bb.writeLog("====用章申请=====创建文件夹="+f2.getName()); + bb.writeLog("====用章申请=====创建文件c="+f2.length()); + + bb.writeLog("-----"); + } else { +// 先创建文件所在的目录 + boolean su =f2.getParentFile().mkdirs(); + if(su==true){ + if(fj.length()>0){ + fjFilename(fj, GDnewPath); + } + if(zwofdwj.length()>0){ + fjFilename(zwofdwj, GDnewPath); + } + if(ofdwj.length()>0){ + String filename = filename(ofdwj, GDnewPath); + mapList.put("cld",filename); + } + } + + } + + bb.writeLog("====用章申请=====创建文件夹成功c="+GDnewPath); + //先创建文件夹,之后存放文件,再传递建模进行记录 + CreatXML creatXML = new CreatXML(); + try { + + creatXML.createYJSMXml(YJnewPath,map); + + } catch (Exception e) { + e.printStackTrace(); + bb.writeLog("用章申请----依据说明:" + e); + } + try { + creatXML.createGDWJXml(GDnewPath,mapList); + } catch (Exception e) { + e.printStackTrace(); + bb.writeLog("用章申请=====归档文件:" + e); + } + + bb.writeLog("====用章申请=====写入xml文件="+src); + bb.writeLog("====用章申请====文件方法="); + + File f1=null; + ZipOutputStream out=null; + String zip = YJnewPath+".zip"; +// try { +// f1= new File(YJnewPath); +// out = new ZipOutputStream(new FileOutputStream( +// YJnewPath+".zip")); +// zip(out,f1,null); +// } catch (FileNotFoundException e) { +// e.printStackTrace(); +// } catch (Exception e) { +// e.printStackTrace(); +// } + +// try { +// ZipUtil zipUtil = new ZipUtil(); +// zipUtil.zip(YJnewPath,zippath); +// } catch (Exception e) { +// e.printStackTrace(); +// } + zipu(YJnewPath,zippath); + bb.writeLog("====用章申请=====写入xml文件="+src); +// Date date = new Date(); +// String day = new SimpleDateFormat("yyyy-MM-dd").format(date); +// String daytime = new SimpleDateFormat("hh:mm").format(date); + Date date = new Date(); + String day = new SimpleDateFormat("yyyy-MM-dd").format(date); + String daytime = new SimpleDateFormat("hh:mm").format(date); + String da = new SimpleDateFormat("yyyy-MM-dd").format(date).replaceAll("-", ""); + //文件路径,收发文类别 0是收文 1是发文,文件夹名称,归档状态,流程id +// String insertsql = "insert into uf_dagd(wjlj,sfwlb,wjjmc,gdzt,lcid,lcgdrq,lcgdsj,ssbm,gdlcm) values('"+zippath+"','"+0+"','"+zipname+"','"+0+"','"+requestid+"','"+day+"','"+daytime+"','"+zrz+"','"+wjbt+"')"; + + String insertsql = "insert into uf_dagd(wjlj,sfwlb,wjjmc,gdzt,lcid,lcgdrq,lcgdsj,ssbm,gdlcm) values('" + zippath + "','" + 1 + "','" + zipname + "','" + 0 + "','" + requestid + "','" + day + "','" + daytime + "','" + zrz + "','" + wjbt + "')"; + RecordSet recordSet = new RecordSet(); + recordSet.execute(insertsql); + recordSet.writeLog("建模台账添加数据"+insertsql); + + return Action.SUCCESS; + } + +} diff --git a/src/com/engine/workflow/web/danganfiles/DA/util/CreatXML.java b/src/com/engine/workflow/web/danganfiles/DA/util/CreatXML.java new file mode 100644 index 0000000..f64119c --- /dev/null +++ b/src/com/engine/workflow/web/danganfiles/DA/util/CreatXML.java @@ -0,0 +1,456 @@ +package com.engine.workflow.web.danganfiles.DA.util; + +import org.dom4j.Document; +import org.dom4j.DocumentHelper; +import org.dom4j.Element; +import org.dom4j.io.OutputFormat; +import org.dom4j.io.XMLWriter; +import weaver.conn.RecordSet; +import weaver.general.BaseBean; + +import java.io.File; +import java.io.FileOutputStream; +import java.util.*; + +public class CreatXML { + + +// +// public static void main(String[] args) { +// Long start = System.currentTimeMillis(); +// HashMap map = new HashMap(); +// // createGDWJXml("","D:/WEAVER/DA",map); +// // createYJSMXml(); +// System.out.println("运行时间:"+ (System.currentTimeMillis() - start)); +// } + +// public static void main(String[] args) { +// String fileName="1e01r515g45g5g015.zip"; +// String fileNameNoEx = getFileNameNoEx(fileName); +// System.out.println(fileNameNoEx); +// +// } + + public static String getFileNameNoEx(String filename) { + + if ((filename != null) && (filename.length() > 0)) { + + int dot = filename.lastIndexOf('.'); + + if ((dot >-1) && (dot < (filename.length()))) { + + return filename.substring(0, dot); + + } + + } + + return filename; + + } + + public static boolean isEmpty(String str) { + if ("".equals(str) || str == null) { + return true; + } else { + return false; + } + } + + /** + * 生成xml方法 + */ + public void createGDWJXml(String path, HashMap map) throws Exception { + + BaseBean bs = new BaseBean(); + bs.writeLog("进入xml生成方法---归档文件"); + + bs.writeLog("进入xml生成方法---归档文件---" + map); + + bs.writeLog("进入xml生成方法---归档文件---准备执行sql"); + String fj = map.get("fj").toString(); + + + + bs.writeLog("创建document对象"); + // 1、创建document对象 + Document document = DocumentHelper.createDocument(); + // 2、创建根节点rss + Element root = document.addElement("root"); + // 3、向rss节点添加version属性 + // root.addAttribute("version", "2.0"); + // 4、生成子节点及子节点内容 + Element v1 = root.addElement("电子文件移交存储数据包"); + Element v2 = v1.addElement("文件实体"); + Element w1 = v2.addElement("档号"); + Element w2 = v2.addElement("题名"); + Element w3 = v2.addElement("并列题名"); + Element w4 = v2.addElement("类别"); + Element w5 = v2.addElement("主题词或关键字"); + Element w6 = v2.addElement("人名"); + Element w7 = v2.addElement("文件编号"); + Element w8 = v2.addElement("责任者"); + Element w9 = v2.addElement("保管期限"); + Element w10 = v2.addElement("机构或问题"); + Element w11 = v2.addElement("控制标识"); + Element w12 = v2.addElement("日期"); + Element w13 = v2.addElement("文种"); + Element w14 = v2.addElement("主送"); + Element w15 = v2.addElement("抄送"); + Element w16 = v2.addElement("密级"); + Element w17 = v2.addElement("保密期限"); + Element w18 = v2.addElement("页数"); + Element w19 = v2.addElement("附注"); + Element w20 = v2.addElement("脱机载体编号"); + //正文 稿本块 + Element g21 = v2.addElement("稿本块"); + Element g211 = g21.addElement("稿本"); + Element g2111 = g211.addElement("稿本类型"); + Element g2112 = g211.addElement("稿本文件"); + Element g2113 = g211.addElement("文件标识符"); + + g2111.setText("正文"); + w18.setText("1"); + // g2112.setText("正文文件"); + // g2113.setText("正文标识符"); + + String aq = getfilename(map.get("zw").toString()).get(0).get("gbwj").toString(); + String aq2 = getfilename(map.get("zw").toString()).get(0).get("bsf").toString(); + bs.writeLog("---------------------------正文稿本文件" + aq + "---" + aq2); + + g2112.setText(aq); + String fileNameNoEx = getFileNameNoEx(aq2); + g2113.setText(fileNameNoEx); + //附件稿本块 + bs.writeLog("获取附件"+map.get("fj").toString()); + if(map.get("fj").toString()=="0" && "0".equals(map.get("fj").toString())){ +// Element g311 = g21.addElement("稿本"); +// Element g3111 = g311.addElement("稿本类型"); +// Element g3112 = g311.addElement("稿本文件"); +// Element g3113 = g311.addElement("文件标识符"); +// g3111.setText("附件"); +// g3112.setText(""); +// g3113.setText(""); + bs.writeLog("---------------------------没有附件"); + }else{ + int i = getfilename(map.get("fj").toString()).size(); + for (int o = 0; o < i; o++) { + Element g312 = g21.addElement("稿本"); + g312.addElement("稿本类型").setText("附件"); + g312.addElement("稿本文件").setText(getfilename(map.get("fj").toString()).get(o).get("gbwj").toString()); + g312.addElement("文件标识符").setText(getFileNameNoEx(getfilename(map.get("fj").toString()).get(o).get("bsf").toString())); + } + String zwofd = map.get("zwofd").toString(); + if (!isEmpty(zwofd)){ + bs.writeLog("zwofd不为空-->"+zwofd); + int y = getfilename(zwofd).size(); + if (y>0){ + for (int o = 0; o < y; o++) { + Element g312 = g21.addElement("稿本"); + g312.addElement("稿本类型").setText("附件"); + g312.addElement("稿本文件").setText(getfilename(map.get("zwofd").toString()).get(o).get("gbwj").toString()); + g312.addElement("文件标识符").setText(getFileNameNoEx(getfilename(map.get("zwofd").toString()).get(o).get("bsf").toString())); + } + } + } + } + bs.writeLog("---------------------------附件稿本文件" ); + +// Element g311 = g21.addElement("稿本"); +// Element g3111 = g311.addElement("稿本类型"); +// Element g3112 = g311.addElement("稿本文件"); +// Element g3113 = g311.addElement("文件标识符"); +// g3111.setText("附件"); +// g3112.setText("文件"); +// g3113.setText("uuid"); + //处理单稿本块 + + Element g411 = g21.addElement("稿本"); + Element g4111 = g411.addElement("稿本类型"); + Element g4112 = g411.addElement("稿本文件"); + Element g4113 = g411.addElement("文件标识符"); + g4111.setText("处理单"); + bs.writeLog(map.get("zw").toString()); + g4112.setText(getfilename(map.get("zw").toString()).get(0).get("gbwj").toString()); + g4113.setText(map.get("cld").toString()); + //附件稿本块 +// bs.writeLog("-----------------------处理单稿本文件" +cldname+"(2)"); + + List> nodeInfoList = (List>)map.get("nodeInfoList"); + bs.writeLog("-----进入生成xmlAction-----nodeInfoList-->" +nodeInfoList); + + int size = nodeInfoList.size(); + bs.writeLog("--nodeInfoList--size-->" +size); + + if (size==0){ + Element w22 = v2.addElement("流程跟踪");//需要循环节点信息 + w22.addElement("环节名称"); + w22.addElement("办理人"); + w22.addElement("办理部门"); + w22.addElement("接收时间"); + w22.addElement("当前状态"); + w22.addElement("完成时间"); + }else { + for (int i = 0; i < nodeInfoList.size(); i++) { + //a.id,b.nodename,a.lastname,a.departmentname,a.receivedate,a.receivetime,a.operatedate,a.operatetime + Element w22 = v2.addElement("流程跟踪");//需要循环节点信息 + w22.addElement("环节名称").setText(nodeInfoList.get(i).get("nodename").toString()); + w22.addElement("办理人").setText(nodeInfoList.get(i).get("lastname").toString()); + w22.addElement("办理部门").setText(nodeInfoList.get(i).get("departmentname").toString()); + String receivedate = nodeInfoList.get(i).get("receivedate").toString(); + String receivetime = nodeInfoList.get(i).get("receivetime").toString(); + String receivet = receivedate+" "+receivetime; + bs.writeLog("--接收时间-->" +receivet); + w22.addElement("接收时间").setText(receivet); + String operatedate = nodeInfoList.get(i).get("operatedate").toString(); + String operatetime = nodeInfoList.get(i).get("operatetime").toString(); + String operate = operatedate+" "+operatetime; + bs.writeLog("--完成时间-->" +operate); + String id = nodeInfoList.get(i).get("id").toString(); + if (isEmpty(id)){ + bs.writeLog("--id为空-->" +id); + w22.addElement("当前状态").setText("未完成"); + }else { + bs.writeLog("--id不为空-->" +id); + w22.addElement("当前状态").setText("已完成"); + } + w22.addElement("完成时间").setText(operate); + } + + } + + + + + w1.setText(map.get("dh").toString()); + w2.setText(map.get("bt").toString()); +// w3.setText(""); +// w4.setText(""); +// w5.setText(""); +// w6.setText(""); +// w7.setText(""); + w8.setText(map.get("zrz").toString()); + +// w9.setText(""); + w10.setText(map.get("jghwt").toString()); + // w11.setText("控制"); + w11.setText(map.get("kzbs").toString()); + w12.setText(map.get("rq").toString()); + w13.setText(map.get("wz").toString()); +// w14.setText(""); +// w15.setText(""); + w16.setText(map.get("mj").toString()); +// w17.setText(""); +// w18.setText("1"); +// w19.setText(""); +// w20.setText(""); + Element v3 = v1.addElement("业务实体块"); + Element w31 = v3.addElement("业务实体"); + Element w311 = w31.addElement("机构人员标识符"); + Element w312 = w31.addElement("业务行为"); + Element w313 = w31.addElement("行为时间"); + Element w314 = w31.addElement("文件标识符"); + + w311.setText(map.get("jgryid").toString()); + w312.setText("归档"); + Date date = new Date(); + w313.setText(date.toString()); + w314.setText(fileNameNoEx); + +// w311.setText(""); +// w312.setText(""); +// w313.setText(""); +// w314.setText(""); + + Element v4 = v1.addElement("机构人员实体块"); + Element v41 = v4.addElement("机构人员实体"); + Element v411 = v41.addElement("机构人员标识符"); + Element v412 = v41.addElement("机构名称"); + Element v413 = v41.addElement("人员名称"); + v411.setText(map.get("jgryid").toString()); + v412.setText(map.get("jgryBmName").toString()); + v413.setText(map.get("jgryName").toString()); + if (size==0){ + bs.writeLog("--size==0--机构人员实体块-->" ); + }else { + for (int i = 0; i < nodeInfoList.size(); i++) { + String id = nodeInfoList.get(i).get("id").toString(); + if (isEmpty(id)){ + bs.writeLog("--id为空不插入机构人员数据-->" +id); + }else { + bs.writeLog("--id不为空-->" +id); + Element v42 = v4.addElement("机构人员实体"); + Element v421 = v42.addElement("机构人员标识符"); + Element v422 = v42.addElement("机构名称"); + Element v423 = v42.addElement("人员名称"); + v421.setText(nodeInfoList.get(i).get("id").toString()); + v422.setText(nodeInfoList.get(i).get("departmentname").toString()); + v423.setText(nodeInfoList.get(i).get("lastname").toString()); + } + + } + } + + + +// v411.setText(""); +// v412.setText(""); +// v413.setText(""); + + Element v5 = v1.addElement("实体关系块"); + Element v51 = v5.addElement("实体关系"); + Element v511 = v51.addElement("实体标识"); + Element v512 = v51.addElement("文件标识符"); + v511.setText(map.get("dh").toString()); + v512.setText(fileNameNoEx); + Element v52 = v5.addElement("实体关系"); + v52.addElement("实体标识").setText(map.get("dh").toString()); + v52.addElement("文件标识符").setText(map.get("cld").toString()); + if(map.get("fj").toString()=="0" && "0".equals(map.get("fj").toString())){ +// v511.setText(map.get("dh").toString()); +// v512.setText(fileNameNoEx); + }else { + int y = getfilename(map.get("fj").toString()).size(); + for (int i = 0; i < y; i++) { + Element v53 = v5.addElement("实体关系"); + v53.addElement("实体标识").setText(map.get("dh").toString()); + v53.addElement("文件标识符").setText(getFileNameNoEx(getfilename(map.get("fj").toString()).get(i).get("bsf").toString())); + } + String zwofd = map.get("zwofd").toString(); + if (!isEmpty(zwofd)){ + int z = getfilename(zwofd).size(); + if(z>0){ + for (int i = 0; i < z; i++) { + Element v53 = v5.addElement("实体关系"); + v53.addElement("实体标识").setText(map.get("dh").toString()); + v53.addElement("文件标识符").setText(getFileNameNoEx(getfilename(map.get("zwofd").toString()).get(i).get("bsf").toString())); + } + } + } + + } + + + + bs.writeLog("进入xml生成方法----22-"); + ////文档实体块--文档详细信息 + bs.writeLog("进入xml生成方法"); + + // 5、设置生成xml的格式 + OutputFormat format = OutputFormat.createPrettyPrint(); + // 设置编码格式 + format.setEncoding("UTF-8"); + + + // 6、生成xml文件 + File file = new File(path + "/gdwj.xml"); + file.createNewFile(); + bs.writeLog("进入xml生成方法----33"); + XMLWriter writer = new XMLWriter(new FileOutputStream(file), format); + // 设置是否转义,默认使用转义字符 + writer.setEscapeText(false); + writer.write(document); + writer.close(); + bs.writeLog("生成gdwj.xml成功"); + bs.writeLog("进入xml生成方法----44生成gdwj.xml成功"); + + } + + public void createYJSMXml(String path, HashMap map) throws Exception { + + BaseBean bs = new BaseBean(); + bs.writeLog("进入xml生成方法-----11+依据说明"); + + + bs.writeLog("进入xml生成方法-----22----1+依据说明"); + // 1、创建document对象 + Document document = DocumentHelper.createDocument(); + // 2、创建根节点rss + Element root = document.addElement("root"); + // 3、向rss节点添加version属性 + // root.addAttribute("version", "2.0"); + // 4、生成子节点及子节点内容 + Element v1 = root.addElement("电子文件移交说明及目录描述"); + Element v2 = v1.addElement("目录描述"); + bs.writeLog("依据说明-----"); + Element w1 = v2.addElement("档号"); + Element w2 = v2.addElement("题名"); + Element w3 = v2.addElement("文件编号"); + Element w4 = v2.addElement("责任者"); + Element w5 = v2.addElement("日期"); + Element w6 = v2.addElement("页数"); + bs.writeLog("进入xml生成方法-----33----1+依据说明" + map); + + w1.setText(map.get("dh").toString()); + w2.setText(map.get("bt").toString()); + w3.setText(map.get("bh").toString()); + w4.setText(map.get("zrz").toString()); + w5.setText(map.get("rq").toString()); + w6.setText(map.get("ys").toString()); + + bs.writeLog("进入xml生成方法----222"); + // 5、设置生成xml的格式 + OutputFormat format = OutputFormat.createPrettyPrint(); + // 设置编码格式 + format.setEncoding("UTF-8"); + + + // 6、生成xml文件 + File file = new File(path + "/yjsm.xml"); + file.createNewFile(); + + bs.writeLog("进入xml生成方法----33" + file); + XMLWriter writer = new XMLWriter(new FileOutputStream(file), format); + // 设置是否转义,默认使用转义字符 + writer.setEscapeText(false); + writer.write(document); + writer.close(); + bs.writeLog("生成yjsm.xml成功"); + bs.writeLog("进入xml生成方法-----22----1+生成yjsm.xml成功"); + + } + + /** + * 根据参数信息返回文件名,及标识符 + * @param fj + * @return + */ + public static List getfilename(String fj) { + BaseBean bs = new BaseBean(); + bs.writeLog("==11=进入查询方法-->fj"+fj); + List list = new ArrayList<>(); + // HashMap map = new HashMap(); + String[] arr = fj.split(","); + bs.writeLog("==22=进入查询方法"); + // RecordSet rs3 = new RecordSet(); + for (int i = 0; i < arr.length; i++) { + RecordSet rs3 = new RecordSet(); +// String docdetail = "select top(1) im.filerealpath,do.imagefilename,im.iszip from imagefile im left join docimagefile do on im.imagefileid = do.imagefileid where docid=" + arr[i] + " order by versionid desc"; + String docdetail = "SELECT filerealpath,docimagefile.imagefilename,iszip FROM imagefile LEFT JOIN docimagefile ON imagefile.imagefileid = docimagefile.imagefileid WHERE docid = "+arr[i]+" ORDER BY versionid DESC"; + rs3.execute(docdetail); + HashMap map = new HashMap(); + // List list = new ArrayList<>(); + bs.writeLog("==22=" + docdetail); + if (rs3.next()) { + String filerealpath = rs3.getString("filerealpath"); + String imagefilename = rs3.getString("imagefilename"); + bs.writeLog("==33=" + filerealpath + "---" + imagefilename); + int index = filerealpath.lastIndexOf("/"); + int index2 = imagefilename.lastIndexOf("."); + String zipPath = filerealpath.substring(index + 1); //压缩文件名 + + String newname = imagefilename.substring(0, index2); + bs.writeLog("==44=" + zipPath + "---" + newname); + map.put("bsf", zipPath); + map.put("gbwj", newname); + + bs.writeLog("==45=" + map); + } + list.add(map); + + } + bs.writeLog("=55==" + list); + return list; + } +} + diff --git a/src/com/engine/workflow/web/danganfiles/DA/util/DaHttpAction.java b/src/com/engine/workflow/web/danganfiles/DA/util/DaHttpAction.java new file mode 100644 index 0000000..0d63e1e --- /dev/null +++ b/src/com/engine/workflow/web/danganfiles/DA/util/DaHttpAction.java @@ -0,0 +1,271 @@ +package com.engine.workflow.web.danganfiles.DA.util; + +import com.alibaba.fastjson.JSONObject; +import org.apache.http.HttpEntity; +import org.apache.http.HttpResponse; +import org.apache.http.HttpStatus; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.entity.ContentType; +import org.apache.http.entity.mime.MultipartEntityBuilder; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClients; +import org.apache.http.util.EntityUtils; +import weaver.general.BaseBean; + +import java.io.BufferedInputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; + + +public class DaHttpAction { + + + private static String FILENAME = ""; + private static String SESSION = ""; + private static File file = new File(""); + + public static String getSESSION() { + return SESSION; + } + + public static void setSESSION(String SESSION) { + DaHttpAction.SESSION = SESSION; + } + + public String getFILENAME() { + return FILENAME; + } + + public void setFILENAME(String FILENAME) { + this.FILENAME = FILENAME; + } + + public File getFile() { + return file; + } + + public void setFile(File file) { + this.file = file; + } + + private static CloseableHttpClient httpClient = HttpClients.createDefault(); + + private static final String ADDRESS_URL = "http://10.96.30.95:8083"; + + private static String init() throws IOException { + + BaseBean bs = new BaseBean(); + bs.writeLog("进入归档初始化方法-->文件名称-->"+FILENAME); + bs.writeLog("进入归档初始化方法-->文件名称长度-->"+String.valueOf(file.length())); + String initpath = ADDRESS_URL + "/oa/InitUpload.do"; + bs.writeLog("进入归档初始化方法-->上传接口路径-->"+initpath); + HttpPost httppost = new HttpPost(initpath); + MultipartEntityBuilder mEntityBuilder = MultipartEntityBuilder.create(); + mEntityBuilder.addTextBody("fileName", FILENAME, ContentType.TEXT_PLAIN.withCharset("utf-8")); + mEntityBuilder.addTextBody("fileSize", String.valueOf(file.length())); + String reStr; + JSONObject jsonObject; + HttpResponse responce; + httppost.setEntity(mEntityBuilder.build()); + try { + bs.writeLog("进入初始化try/catch-->"+httppost); + responce = httpClient.execute(httppost); + bs.writeLog("进入归档初始化方法--执行接口返回结果-->"+responce); + int resStatu = responce.getStatusLine().getStatusCode(); + bs.writeLog("第一个接口--resStatu--->"+resStatu); + bs.writeLog("第一个接口--SC_OK--->"+HttpStatus.SC_OK); + if (resStatu == HttpStatus.SC_OK) { + HttpEntity entity = responce.getEntity(); + bs.writeLog(entity); + reStr = EntityUtils.toString(entity); + bs.writeLog("进入归档初始化方法响应-->"+reStr); + jsonObject = JSONObject.parseObject(reStr); + String session = jsonObject.getString("session"); + Integer code = jsonObject.getInteger("code"); + if (0==code){ + return session; + } + } + }catch (Exception e) { + e.printStackTrace(); + } + return "f"; + } + + private static boolean processData(String depId,String doctype) throws IOException { + BaseBean bs = new BaseBean(); + bs.writeLog("进入上传校验方法-->"); + String upfile = ADDRESS_URL +"/oa/UploadFile.do"; + HttpPost httppost = new HttpPost(upfile); + bs.writeLog("进入上传校验方法接口-->"+upfile); + bs.writeLog("进入上传校验方法--打印FileName-->"+FILENAME); + bs.writeLog("进入上传校验方法--打印Dept-->"+depId); + bs.writeLog("进入上传校验方法--打印doctype-->"+doctype); + MultipartEntityBuilder mEntityBuilder = MultipartEntityBuilder.create(); + mEntityBuilder.addTextBody("FileName", FILENAME, ContentType.TEXT_PLAIN.withCharset("utf-8")); + mEntityBuilder.addTextBody("OffSoftName", "今易", ContentType.TEXT_PLAIN.withCharset("utf-8")); + mEntityBuilder.addTextBody("OffSoftVer", "V1.0", ContentType.TEXT_PLAIN.withCharset("utf-8")); + mEntityBuilder.addTextBody("Dept", depId, ContentType.TEXT_PLAIN.withCharset("utf-8"));//部门id + mEntityBuilder.addTextBody("doctype", doctype, ContentType.TEXT_PLAIN.withCharset("utf-8"));//0收文,1发文 +// mEntityBuilder.addTextBody("Strategy", "sw", ContentType.TEXT_PLAIN.withCharset("utf-8")); + String reStr; + JSONObject jsonObject; + HttpResponse responce; + httppost.setEntity(mEntityBuilder.build()); + responce = httpClient.execute(httppost); + int resStatu = responce.getStatusLine().getStatusCode(); + bs.writeLog("第三个接口--resStatu--->"+resStatu); + bs.writeLog("第三个接口--SC_OK--->"+HttpStatus.SC_OK); + if (resStatu == HttpStatus.SC_OK) { + // get result data + HttpEntity entity = responce.getEntity(); + reStr = EntityUtils.toString(entity); + bs.writeLog("进入上传校验方法打印返回值-->"+reStr); + jsonObject = JSONObject.parseObject(reStr); + return 0 == jsonObject.getInteger("code"); + } else { + return false; + } + + } + + public static boolean uploadFile(String filePath) throws Exception{ + BaseBean bs = new BaseBean(); +// String url = ADDRESS_URL +"/oa/UploadData.do"; +// System.out.println("进入归档上传方法---session---->"+session); +// System.out.println("进入归档上传方法---服务端发布的接口地址---->"+url); +// System.out.println("进入归档上传方法---文件名称---->"+FILENAME); +// System.out.println("进入归档上传方法-->文件名称长度-->"+String.valueOf(file.length())); +// System.out.println("进入归档上传方法----需要传递到服务器的文件路径---"+filePath);//需要传递到服务器的文件路径 +// File file = new File(filePath); +// ZipInputStream zipInputStream = null; +// InputStream inputStream = null; +// try { +// //InputStream in = new FileInputStream(file); +// if(!file.exists()) +// { +// throw new WebApplicationException(404); +// } +// zipInputStream = new ZipInputStream(new FileInputStream(file)); +// if (zipInputStream.getNextEntry() != null) { +// inputStream = new BufferedInputStream(zipInputStream); +// } +// MultipartEntityBuilder entityBuilder = MultipartEntityBuilder.create(); +// entityBuilder.addTextBody("fileName", FILENAME); +// entityBuilder.addTextBody("fileSize", String.valueOf(file.length())); +// entityBuilder.addBinaryBody("file", inputStream, +// ContentType.MULTIPART_FORM_DATA, FILENAME); +// HttpPost httpPost = new HttpPost(url); +// httpPost.setEntity(entityBuilder.build()); +// //执行post接口 +// HttpResponse response = httpClient.execute(httpPost); +// String result=""; +// if (response!=null && response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) { +// HttpEntity resEntity = response.getEntity(); +// if(resEntity != null){ +// result = EntityUtils.toString(resEntity, Consts.UTF_8); +// } +// } +// System.out.println("进入上传校验方法打印返回值-->"+result); +// JSONObject jsonObject = JSONObject.parseObject(result); +// return 0 == jsonObject.getInteger("code"); +// } catch (FileNotFoundException e) { +// e.printStackTrace(); +// } catch (ClientProtocolException e) { +// e.printStackTrace(); +// } catch (IOException e) { +// e.printStackTrace(); +// } + try { + String url = ADDRESS_URL +"/oa/UploadData.do"; + HttpPost httppost = new HttpPost(url); + FileInputStream fis = new FileInputStream(file); + BufferedInputStream bis = new BufferedInputStream(fis); + int count = 1000000; + byte[] bytes = new byte[count]; + int len = -1; + String reStr; + JSONObject jsonObject; + HttpResponse responce; + HttpEntity entity; + while ((len = bis.read(bytes, 0, count)) != -1) { + MultipartEntityBuilder mEntityBuilder = MultipartEntityBuilder.create(); + mEntityBuilder.addTextBody("fileName", FILENAME, ContentType.TEXT_PLAIN.withCharset("utf-8")); + mEntityBuilder.addTextBody("fileSize", String.valueOf(len), ContentType.TEXT_PLAIN.withCharset("utf-8")); + mEntityBuilder.addBinaryBody("file", bytes, ContentType.DEFAULT_BINARY, FILENAME); + //mEntityBuilder.addTextBody("Dept", "市委", ContentType.TEXT_PLAIN.withCharset("utf-8")); + httppost.setEntity(mEntityBuilder.build()); + responce = httpClient.execute(httppost); + int resStatu = responce.getStatusLine().getStatusCode(); + + if (resStatu == HttpStatus.SC_OK) { + // get result data + entity = responce.getEntity(); + reStr = EntityUtils.toString(entity); + jsonObject = JSONObject.parseObject(reStr); + bs.writeLog("reStr->"+reStr); + if (0 != jsonObject.getInteger("code")) { + bs.writeLog("上传出错"); + return false; + } + } else { + bs.writeLog("上传出错"); + return false; + } + } + bs.writeLog("上传完成"); + return true; + } finally { + bs.writeLog("上传完成"); + } + } + + + + public static int doit(String filename,String filepath ,String doctype,String depId) throws Exception{ + BaseBean bs = new BaseBean(); + bs.writeLog("点击归档按钮-->filename-->"+filename); + bs.writeLog("点击归档按钮-->filepath-->"+filepath); + int success =9; + DaHttpAction HttpAction = new DaHttpAction(); + HttpAction.setFILENAME(filename); + HttpAction.setFile(new File(filepath)); + bs.writeLog("设置文件名称-->"+FILENAME); + bs.writeLog("设置文件大小-->"+String.valueOf(file.length())); + try { + String session = init(); + if ("f".equals(session)) { + bs.writeLog("初始化出错"); + return 2; + }else { + bs.writeLog("第一个接口执行成功-->文件初始化成功-->session-->"+session); + if (!uploadFile(filepath)) { + bs.writeLog("文件上传出错"); + return 4; + }else { + bs.writeLog("第二个接口执行成功-->文件上传成功"); + bs.writeLog("上传成功"); + if (!processData(depId,doctype)) { + bs.writeLog("处理失败"); + return 5; + } else { + success=0; + bs.writeLog("第三个接口执行成功-->文件验证成功"); + } + } + } + + } finally { + success=0; +// httpClient.close(); + } + return success; + } + + + +} + + + diff --git a/src/com/engine/workflow/web/danganfiles/DA/util/GDS_Action.java b/src/com/engine/workflow/web/danganfiles/DA/util/GDS_Action.java new file mode 100644 index 0000000..f73cf6b --- /dev/null +++ b/src/com/engine/workflow/web/danganfiles/DA/util/GDS_Action.java @@ -0,0 +1,99 @@ +package com.engine.workflow.web.danganfiles.DA.util; + + +import com.engine.workflow.web.danganfiles.DA.util.DaHttpAction; +import weaver.conn.RecordSet; +import weaver.general.BaseBean; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; + +/** + * 调用归档的方法,建模表单的按钮触发 + */ +@Path("/inter/file") +public class GDS_Action { + + + + @GET + @Path("/dofilings") + @Produces(MediaType.TEXT_PLAIN) + public String interfiles (@Context HttpServletRequest request, @Context HttpServletResponse response) { + BaseBean bb = new BaseBean(); + String id = request.getParameter("id"); + bb.writeLog("进入方法--归档执行开始" + id); + RecordSet rs = new RecordSet(); + String[] arr = id.split(","); + int i = 10; + for (int y = 0; y < arr.length; y++) { + boolean success = false; + String depidSql="select ssbm from uf_dagd where id="+arr[y]; + String depid =""; + try { + rs.executeQuery(depidSql); + rs.next(); + depid = rs.getString("ssbm"); + bb.writeLog("执行部门语句----"+depidSql); + }catch (Exception e){ + bb.writeLog("执行部门语句失败----"+e); + } + + //查询归档记录表 + String sql = "select * from uf_dagd where id=" + arr[y]; + int gdzt = -1; + try { + rs.executeQuery(sql); + rs.next(); + gdzt = rs.getInt("gdzt"); + bb.writeLog("执行语句----" + sql); + } catch (Exception e) { + bb.writeLog("执行语句失败----" + e); + e.printStackTrace(); + } + + + bb.writeLog("状态信息" + gdzt); + + //判断文件归档状态,0为未归档 + bb.writeLog("归档状态" + gdzt); + if (gdzt == 0) { + + String filename = rs.getString("wjjmc"); + String filepath = rs.getString("wjlj"); + String sfwlb = rs.getString("sfwlb"); + //执行档案归档文件上传方法 + + bb.writeLog("文件相关信息" + filename + "--" + filepath + "--" + sfwlb); + DaHttpAction daHttpAction = new DaHttpAction(); + + try { + bb.writeLog("进入daHttpAction.doit方法"); + i = daHttpAction.doit(filename,filepath,sfwlb,depid); + } catch (Exception e) { + e.printStackTrace(); + } + bb.writeLog("返回信息str" + i); + //将记录表中的未归档状态修改为归档=" + if (i != 0) { + bb.writeLog("归档出问题了----->" + i); + } else if (i == 0) { + String upsql = "update uf_dagd set gdzt =1 where id=" + arr[y]; + RecordSet rs1 = new RecordSet(); + bb.writeLog("---" + upsql); + success = rs1.execute(upsql); + bb.writeLog("上传出boolean----->"+success); + } + + + } + } +//除0 以外的所有返回信息都是错误 + return i + ""; + } +} diff --git a/src/com/engine/workflow/web/danganfiles/DA/util/GD_Action.java b/src/com/engine/workflow/web/danganfiles/DA/util/GD_Action.java new file mode 100644 index 0000000..50f5301 --- /dev/null +++ b/src/com/engine/workflow/web/danganfiles/DA/util/GD_Action.java @@ -0,0 +1,167 @@ +package com.engine.workflow.web.danganfiles.DA.util; + + +import weaver.conn.RecordSet; +import weaver.general.BaseBean; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; + +/** + * 调用归档的方法,建模表单的按钮触发 + */ +@Path("/inter/file") +public class GD_Action { + + @GET + @Path("/dofiling") + @Produces(MediaType.TEXT_PLAIN) + public String interfile (@Context HttpServletRequest request, @Context HttpServletResponse response){ + BaseBean bb = new BaseBean(); + String id =request.getParameter("id"); + bb.writeLog("进入方法--归档执行开始"+id); + RecordSet rs = new RecordSet(); +// String depidSql="SELECT b.id as depid FROM hrmresource a,hrmdepartment b WHERE a.departmentid = b.id AND a.ID=(select creater FROM workflow_requestbase WHERE REQUESTID=(select lcid from uf_dagd where id="+id+"))"; + String depidSql="select ssbm from uf_dagd where id="+id; + String depid =""; + try { + rs.executeQuery(depidSql); + if ( rs.next()){ + depid = rs.getString("ssbm"); + bb.writeLog("执行部门语句----"+depidSql); + } + }catch (Exception e){ + bb.writeLog("执行部门语句失败----"+e); + } + + //查询归档记录表 + String sql ="select * from uf_dagd where id="+id; + int gdzt =-1; + try { + rs.executeQuery(sql); + if (rs.next()){ + gdzt = rs.getInt("gdzt"); + bb.writeLog("执行语句----"+sql); + } + }catch (Exception e){ + bb.writeLog("执行语句失败----"+e); + e.printStackTrace(); + } + + bb.writeLog("状态信息"+gdzt); + boolean success = false; + int i = 10; + //判断文件归档状态,0为未归档 + bb.writeLog("归档状态"+gdzt); + if(gdzt==0){ + + String filename = rs.getString("wjjmc"); + String filepath = rs.getString("wjlj"); + String sfwlb = rs.getString("sfwlb"); + //执行档案归档文件上传方法 + + bb.writeLog("文件相关信息"+filename+"--"+filepath+"--"+sfwlb); + DaHttpAction daHttpAction = new DaHttpAction(); + + try { + bb.writeLog("进入daHttpAction.doit方法"); + i= daHttpAction.doit(filename,filepath,sfwlb,depid); + } catch (Exception e) { + e.printStackTrace(); + } + bb.writeLog("返回信息str"+i); + //将记录表中的未归档状态修改为归档=" + if(i!=0){ + bb.writeLog("上传出问题了-----"+i); + }else if(i==0){ + String upsql = "update uf_dagd set gdzt =1 where id="+id; + RecordSet rs1 = new RecordSet(); + bb.writeLog("sql--->"+upsql); + success = rs1.executeUpdate(upsql); + bb.writeLog("上传成功-----"+success); + } + } + +//除0 以外的所有返回信息都是错误 + return i+""; + } + + @GET + @Path("/dofilings") + @Produces(MediaType.TEXT_PLAIN) + public String interfiles (@Context HttpServletRequest request, @Context HttpServletResponse response) { + BaseBean bb = new BaseBean(); + String id = request.getParameter("id"); + bb.writeLog("进入方法--归档执行开始" + id); + RecordSet rs = new RecordSet(); + String[] arr = id.split(","); + int i = 10; + for (int y = 0; y < arr.length; y++) { + boolean success = false; + String depidSql="select ssbm from uf_dagd where id="+arr[y]; + String depid =""; + try { + rs.executeQuery(depidSql); + if (rs.next()){ + depid = rs.getString("ssbm"); + bb.writeLog("执行部门语句----"+depidSql); + } + }catch (Exception e){ + bb.writeLog("执行部门语句失败----"+e); + } + + //查询归档记录表 + String sql = "select * from uf_dagd where id=" + arr[y]; + int gdzt = -1; + try { + rs.executeQuery(sql); + if (rs.next()){ + gdzt = rs.getInt("gdzt"); + bb.writeLog("执行语句----" + sql); + } + } catch (Exception e) { + bb.writeLog("执行语句失败----" + e); + e.printStackTrace(); + } + + + bb.writeLog("状态信息" + gdzt); + //判断文件归档状态,0为未归档 + bb.writeLog("归档状态" + gdzt); + if (gdzt == 0) { + String filename = rs.getString("wjjmc"); + String filepath = rs.getString("wjlj"); + String sfwlb = rs.getString("sfwlb"); + //执行档案归档文件上传方法 + bb.writeLog("文件相关信息" + filename + "--" + filepath + "--" + sfwlb); + DaHttpAction daHttpAction = new DaHttpAction(); + + try { + bb.writeLog("进入daHttpAction.doit方法"); + i = daHttpAction.doit(filename,filepath,sfwlb,depid); + } catch (Exception e) { + e.printStackTrace(); + } + bb.writeLog("返回信息str" + i); + //将记录表中的未归档状态修改为归档=" + if (i != 0) { + bb.writeLog("归档出问题了----->" + i); + } else if (i == 0) { + String upsql = "update uf_dagd set gdzt =1 where id=" + arr[y]; + RecordSet rs1 = new RecordSet(); + bb.writeLog("sql--->" + upsql); + success = rs1.executeUpdate(upsql); + bb.writeLog("上传成功更新数据库----->"+success); + } + + } + } +//除0 以外的所有返回信息都是错误 + return i + ""; + } +} diff --git a/src/com/engine/workflow/web/danganfiles/DA/util/JY_action.java b/src/com/engine/workflow/web/danganfiles/DA/util/JY_action.java new file mode 100644 index 0000000..899a50a --- /dev/null +++ b/src/com/engine/workflow/web/danganfiles/DA/util/JY_action.java @@ -0,0 +1,422 @@ +package com.engine.workflow.web.danganfiles.DA.util; + +import weaver.conn.RecordSet; +import weaver.general.BaseBean; + +import java.io.*; +import java.nio.channels.FileChannel; +import java.util.UUID; +import java.util.zip.ZipEntry; +import java.util.zip.ZipInputStream; + +/** + * ClassName: JY_action + * date: 2020/8/10 17:23 + * author LiLei + * remake 文件处理类,获取ecology存储的附件转换为原文件类型,要注意的是,一般附件都会被重命名为UUID形式并被压缩为zip形式。 + */ + +public class JY_action { + + /** + * zip文件解压 + * + * @param inputFile 待解压文件夹/文件 + * @param destDirPath 解压路径 + */ + public static void zipUncompress(String inputFile, String destDirPath) throws Exception { + File srcFile = new File(inputFile);//获取当前压缩文件 + // 判断源文件是否存在 + if (!srcFile.exists()) { + throw new Exception(srcFile.getPath() + "所指文件不存在"); + } + //开始解压 + //构建解压输入流 + ZipInputStream zIn = new ZipInputStream(new FileInputStream(srcFile)); + ZipEntry entry = null; + File file = null; + while ((entry = zIn.getNextEntry()) != null) { + if (!entry.isDirectory()) { + file = new File(destDirPath, entry.getName()); + if (!file.exists()) { + new File(file.getParent()).mkdirs();//创建此文件的上级目录 + } + OutputStream out = new FileOutputStream(file); + BufferedOutputStream bos = new BufferedOutputStream(out); + int len = -1; + byte[] buf = new byte[1024]; + while ((len = zIn.read(buf)) != -1) { + bos.write(buf, 0, len); + } + // 关流顺序,先打开的后关闭 + bos.close(); + out.close(); + } + } + } + + /** + * 兼容linux的解压 + * + * @param zipFilePath + * @param destDir + */ + public static void unzip(String zipFilePath, String destDir) { + System.setProperty("sun.zip.encoding", System.getProperty("sun.jnu.encoding")); //防止文件名中有中文时出错 + //System.out.println(System.getProperty("sun.zip.encoding")); //ZIP编码方式 + //System.out.println(System.getProperty("sun.jnu.encoding")); //当前文件编码方式 + //System.out.println(System.getProperty("file.encoding")); //这个是当前文件内容编码方式 + + File dir = new File(destDir); + // create output directory if it doesn't exist + if (!dir.exists()) dir.mkdirs(); + FileInputStream fis; + // buffer for read and write data to file + byte[] buffer = new byte[1024]; + try { + fis = new FileInputStream(zipFilePath); + ZipInputStream zis = new ZipInputStream(fis); + ZipEntry ze = zis.getNextEntry(); + while (ze != null) { + String fileName = ze.getName(); + File newFile = new File(destDir + File.separator + fileName); + //System.out.println("Unzipping to " + newFile.getAbsolutePath()); + // create directories for sub directories in zip + new File(newFile.getParent()).mkdirs(); + FileOutputStream fos = new FileOutputStream(newFile); + int len; + while ((len = zis.read(buffer)) > 0) { + fos.write(buffer, 0, len); + } + fos.close(); + // close this ZipEntry + zis.closeEntry(); + ze = zis.getNextEntry(); + } + // close last ZipEntry + zis.closeEntry(); + zis.close(); + fis.close(); + } catch (IOException e) { + e.printStackTrace(); + } + + } + + /** + * 删除文件 + */ + public static boolean deleteFile(String path) { + BaseBean bs = new BaseBean(); + boolean flag = true; + File file = new File(path); + + if (file.isFile() && file.exists()) { + file.delete(); + flag = true; + bs.writeLog("删除成功"); + } + return flag; + } + + /** + * 重命名文件 + */ + public static void singleChange(String path, String oldName, String newName) { + + File file = new File(path + oldName); //指定文件名及路径 + BaseBean bs = new BaseBean(); + if (file.renameTo(new File(path + newName))) { + bs.writeLog("修改成功!"); + } else { + bs.writeLog("修改失败"); + } + + } + + public static String getFileNameNoEx(String filename) { + + if ((filename != null) && (filename.length() > 0)) { + + int dot = filename.lastIndexOf('.'); + + if ((dot >-1) && (dot < (filename.length()))) { + + return filename.substring(0, dot); + + } + + } + + return filename; + + } + + /** + * 用缓冲区读写,来提升读写效率。 + */ + private static void fileCopyRightWay(String oldPath,String newPath) { + BaseBean bs = new BaseBean(); + bs.writeLog("oldPath-->"+oldPath); + bs.writeLog("newPath-->"+newPath); + + FileWriter fw = null; + FileReader fr = null; + try { + fr = new FileReader(oldPath);//读 + fw = new FileWriter(newPath);//写 + char[] buf = new char[1024];//缓冲区 + int len; + while ((len = fr.read(buf)) != -1) { + fw.write(buf, 0, len);//读几个写几个 + } + } catch (IOException e) { + bs.writeLog(e.getMessage()); + } finally { + if (fr != null) { + try { + fr.close(); + } catch (IOException e) { + bs.writeLog(e.getMessage()); + } + } + + if (fw != null) { + try { + fw.flush(); + fw.close(); + } catch (IOException e) { + bs.writeLog(e.getMessage()); + } + } + } + } + + private static void copyFileUsingFileChannels(File source, File dest) throws IOException { + FileChannel inputChannel = null; + FileChannel outputChannel = null; + try { + inputChannel = new FileInputStream(source).getChannel(); + outputChannel = new FileOutputStream(dest).getChannel(); + outputChannel.transferFrom(inputChannel, 0, inputChannel.size()); + } finally { + inputChannel.close(); + outputChannel.close(); + } + } + + + public static void fjFilename(String fj, String GDnewPath) { + + String[] arr = fj.split(","); + BaseBean bs = new BaseBean(); + bs.writeLog("进入附件方法---111"+GDnewPath); + for (int i = 0; i < arr.length; i++) { + RecordSet rs33 = new RecordSet(); + String docdetail = "select im.filerealpath,d.imagefilename,im.iszip from imagefile im left join docimagefile d on im.imagefileid = d.imagefileid where docid=" + arr[i] + " order by versionid desc"; + boolean su = rs33.execute(docdetail); + + bs.writeLog("语句执行" + su); + bs.writeLog("===" + docdetail); + if (rs33.next()) { + String filerealpath = rs33.getString("filerealpath"); + String imagefilename = rs33.getString("imagefilename"); + int zip = rs33.getInt("iszip"); + + bs.writeLog("获取数据--11--44--" + filerealpath); + bs.writeLog("获取数据--11--44--" + imagefilename); + bs.writeLog("进入正文方法---111====判断是否压缩" + zip); + + if (zip == 1) { + try { + bs.writeLog("进入正文方法--22====是压缩" + zip); + int index = filerealpath.lastIndexOf("/"); + int index2 = imagefilename.lastIndexOf("."); + String zipPath = filerealpath.substring(index + 1); //压缩文件名 + int index3 = zipPath.lastIndexOf("."); + String zipPath1 = zipPath.substring(0,index3); + String newname = imagefilename.substring(index2); + unzip(filerealpath, GDnewPath); + bs.writeLog(GDnewPath); + singleChange(GDnewPath+"/", zipPath1, zipPath1 + newname); + bs.writeLog("重命名"+zipPath1 + newname); +// bs.writeLog("重命名"+zipPath+ newname); + + } catch (Exception e) { + e.printStackTrace(); + } + } else { + bs.writeLog("进入正文方法---33==OFD==否压缩" + zip); + int index = filerealpath.lastIndexOf("/"); + int index2 = imagefilename.lastIndexOf("."); + String zipPath = filerealpath.substring(index + 1); //未压缩文件名 + String newname = imagefilename.substring(index2); + + bs.writeLog("进入正文方法---344==="+zipPath+"===="+newname); + + + File f = new File(GDnewPath+"/"+zipPath+newname); + + //复制文件到新文件夹下 + if(! f.exists()) { + bs.writeLog("进入正文方法--55==OFD==否压缩" + zip); + InputStream instream = null; + try { + instream = new FileInputStream(new File(filerealpath)); + } catch (FileNotFoundException e) { + e.printStackTrace(); + } + OutputStream out1 = null; + try { + out1 = new FileOutputStream(new File(GDnewPath+"/"+zipPath+newname)); + bs.writeLog("进入正文方法--66==OFD==否压缩" ); + int read = 0; + byte[] bytes = new byte[2048]; + while((read = instream.read(bytes)) != -1) { + out1.write(bytes, 0, read); + } + out1.flush(); + instream.close(); + out1.close(); + } + catch (Exception e) { + e.printStackTrace(); + + } + + } + } + } + + + } + } + + + + + + + + + + + public static String filename(String fj, String GDnewPath) { + + + String[] arr = fj.split(","); + BaseBean bs = new BaseBean(); + bs.writeLog("进入附件方法---111"+GDnewPath); + UUID uuid = UUID.randomUUID(); + for (int i = 0; i < arr.length; i++) { + RecordSet rs33 = new RecordSet(); + String docdetail = "select im.filerealpath,d.imagefilename,im.iszip from imagefile im left join docimagefile d on im.imagefileid = d.imagefileid where docid=" + arr[i] + " order by versionid desc"; + boolean su = rs33.execute(docdetail); + + bs.writeLog("语句执行" + su); + bs.writeLog("===" + docdetail); + if (rs33.next()) { + String filerealpath = rs33.getString("filerealpath"); + String imagefilename = rs33.getString("imagefilename"); + int zip = rs33.getInt("iszip"); + + bs.writeLog("获取数据--11--44--" + filerealpath); + bs.writeLog("获取数据--11--44--" + imagefilename); + bs.writeLog("进入正文方法---111====判断是否压缩" + zip); + + if (zip == 1) { + try { + bs.writeLog("进入正文方法--22====是压缩" + zip); + + int index = filerealpath.lastIndexOf("/"); + int index2 = imagefilename.lastIndexOf("."); + String zipPath = filerealpath.substring(index + 1); //压缩文件名 + int index3 = zipPath.lastIndexOf("."); + + String zipPath1 = zipPath.substring(0,index3); + String newname = imagefilename.substring(index2); + unzip(filerealpath, GDnewPath); + + bs.writeLog(GDnewPath); + singleChange(GDnewPath+"/", zipPath1, zipPath1 + newname); + bs.writeLog("重命名"+zipPath1 + newname); + bs.writeLog("重命名"+zipPath+ newname); + String oldPath=GDnewPath+"/"+zipPath1+newname; + bs.writeLog("oldPath-->"+oldPath); + String newPath=GDnewPath+"/"+uuid.toString()+newname; + bs.writeLog("newPath-->"+newPath); +// fileCopyRightWay(oldPath,newPath); + try { + copyFileUsingFileChannels(new File(oldPath), new File(newPath)); + }catch (Exception e){ + e.printStackTrace(); + } + bs.writeLog("执行完重命名-->"); + } catch (Exception e) { + e.printStackTrace(); + } + } else { + bs.writeLog("进入正文方法---33==OFD==否压缩" + zip); + int index = filerealpath.lastIndexOf("/"); + int index2 = imagefilename.lastIndexOf("."); + String zipPath = filerealpath.substring(index + 1); //未压缩文件名 + String newname = imagefilename.substring(index2); + + bs.writeLog("进入正文方法---344==="+zipPath+"===="+newname); + + + File f = new File(GDnewPath+"/"+zipPath+newname); + + //复制文件到新文件夹下 + if(! f.exists()) { + bs.writeLog("进入正文方法--55==OFD==否压缩" + zip); + InputStream instream = null; + try { + instream = new FileInputStream(new File(filerealpath)); + } catch (FileNotFoundException e) { + e.printStackTrace(); + } + OutputStream out1 = null; + try { + out1 = new FileOutputStream(new File(GDnewPath+"/"+zipPath+newname)); + bs.writeLog("进入正文方法--66==OFD==否压缩" ); + int read = 0; + byte[] bytes = new byte[2048]; + while((read = instream.read(bytes)) != -1) { + out1.write(bytes, 0, read); + } + out1.flush(); + instream.close(); + out1.close(); + bs.writeLog("uuid.toString2()-->"+uuid.toString()); + String oldPath=GDnewPath+"/"+zipPath+newname; + bs.writeLog("oldPath2-->"+oldPath); + String newPath=GDnewPath+"/"+uuid.toString()+newname; + bs.writeLog("newPath2-->"+newPath); +// fileCopyRightWay(oldPath,newPath); + try { + copyFileUsingFileChannels(new File(oldPath), new File(newPath)); + }catch (Exception e){ + e.printStackTrace(); + } + bs.writeLog("执行完重命名2-->"); + } + catch (Exception e) { + e.printStackTrace(); + + } + + } + } + } + + + } + return uuid.toString(); + } + + + + + +} diff --git a/src/com/engine/workflow/web/danganfiles/DA/util/ZipFile.java b/src/com/engine/workflow/web/danganfiles/DA/util/ZipFile.java new file mode 100644 index 0000000..5134210 --- /dev/null +++ b/src/com/engine/workflow/web/danganfiles/DA/util/ZipFile.java @@ -0,0 +1,144 @@ +package com.engine.workflow.web.danganfiles.DA.util;;//package com.api.sfj.DA.util; + +import org.apache.tools.zip.ZipEntry; +import org.apache.tools.zip.ZipOutputStream; + +import java.io.BufferedInputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.util.Properties; +import java.util.zip.CRC32; +import java.util.zip.CheckedOutputStream; + +/** + * 文件压缩 + * zip + */ +public class ZipFile { +// public static void main(String[] args) +// throws Exception { +// File f = new File("D:\\WEAVER\\20200928144159323"); +// ZipOutputStream out = new ZipOutputStream(new FileOutputStream( +// "d:\\WEAVER\\20200928144159323.zip")); +// zip(out, f, null); +// System.out.println("zip done"); +// out.close(); +// } + public static void zip(ZipOutputStream out, File f, String base) + throws Exception { + System.out.println("zipping " + f.getAbsolutePath()); + if (f.isDirectory()) { + File[] fc = f.listFiles(); + if (base != null) + out.putNextEntry(new ZipEntry(base + "/")); + base = base == null ? "" : base + "/"; + for (int i = 0; i < fc.length; i++) { + zip(out, fc[i], base + fc[i].getName()); + } + } else { + out.putNextEntry(new ZipEntry(base)); + FileInputStream in = new FileInputStream(f); + int b; + while ((b = in.read()) != -1) + out.write(b); + in.close(); + } + } + + /** + * linux压缩文件 + * @param srcPathName + * @param zipFileName + */ + public static void zipu(String srcPathName, String zipFileName) + { + File file = new File(srcPathName); + File zipFile = new File(zipFileName); + if (!file.exists()) throw new RuntimeException(srcPathName + "不存在!"); + try + { + FileOutputStream fileOutputStream = new FileOutputStream(zipFile); + CheckedOutputStream cos = new CheckedOutputStream(fileOutputStream, new CRC32()); + ZipOutputStream out = new ZipOutputStream(cos); + Properties pro=System.getProperties(); + String osName=pro.getProperty("os.name"); + if("Linux".equals(osName)||"linux".equals(osName)){ + out.setEncoding("GBK");//设置文件名编码方式 + }else{ + out.setEncoding(System.getProperty("sun.jnu.encoding"));//设置文件名编码方式 + } + + String basedir = ""; + compress(file, out, basedir); + out.close(); + } + catch (Exception e) + { + throw new RuntimeException(e); + } + } + + /* + * inputFileName 输入一个文件夹 + * zipFileName 输出一个压缩文件夹 + */ + private static void compress(File file, ZipOutputStream out, String basedir) + { + /* 判断是目录还是文件 */ + if (file.isDirectory()) + { + // System.out.println("压缩:" + basedir + file.getName()); + compressDirectory(file, out, basedir); + } + else + { + // System.out.println("压缩:" + basedir + file.getName()); + compressFile(file, out, basedir); + } + } + + /** 压缩一个目录 */ + private static void compressDirectory(File dir, ZipOutputStream out, String basedir) + { + if (!dir.exists()) return; + + File[] files = dir.listFiles(); + for (int i = 0; i < files.length; i++) + { + /* 递归 */ + compress(files[i], out, basedir + dir.getName() + "/"); + } + } + + /** 压缩一个文件 */ + private static void compressFile(File file, ZipOutputStream out, String basedir) + { + if (!file.exists()) + { + return; + } + try + { + BufferedInputStream bis = new BufferedInputStream(new FileInputStream(file)); + ZipEntry entry = new ZipEntry(basedir + file.getName()); + Properties pro=System.getProperties(); + String osName=pro.getProperty("os.name"); + if("Linux".equals(osName)||"linux".equals(osName)) { + entry.setUnixMode(644); + } + out.putNextEntry(entry); + int count; + byte data[] = new byte[8192]; + while ((count = bis.read(data, 0, 8192)) != -1) + { + out.write(data, 0, count); + } + bis.close(); + } + catch (Exception e) + { + throw new RuntimeException(e); + } + } +} diff --git a/src/com/engine/workflow/web/danganfiles/DA/util/ZipUtil.java b/src/com/engine/workflow/web/danganfiles/DA/util/ZipUtil.java new file mode 100644 index 0000000..587f8a5 --- /dev/null +++ b/src/com/engine/workflow/web/danganfiles/DA/util/ZipUtil.java @@ -0,0 +1,67 @@ +package com.engine.workflow.web.danganfiles.DA.util; + +import org.apache.tools.zip.ZipEntry; +import org.apache.tools.zip.ZipOutputStream; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.OutputStream; + +public class ZipUtil { + + /** + * @param inputFileName + * 输入一个文件夹 + * @param zipFileName + * 输出一个压缩文件夹,打包后文件名字 + * @throws Exception + */ + public OutputStream zip(String inputFileName, String zipFileName) throws Exception + { + return zip(zipFileName, new File(inputFileName)); + } + + private static OutputStream zip(String zipFileName, File inputFile) throws Exception + { + ZipOutputStream out = new ZipOutputStream(new FileOutputStream( + zipFileName)); + out.setEncoding("GBK");//解决linux乱码 + zip(out, inputFile, ""); + out.close(); + return out; + } + + private static void zip(ZipOutputStream out, File f, String base) throws Exception + { + if (f.isDirectory()) + { // 判断是否为目录 + File[] fl = f.listFiles(); + // out.putNextEntry(new org.apache.tools.zip.ZipEntry(base + "/")); +// out.putNextEntry(new ZipEntry(base + "/")); + ZipEntry zipEntry=new ZipEntry(base + System.getProperties().getProperty("file.separator")); + zipEntry.setUnixMode(755);//解决linux乱码 + out.putNextEntry(zipEntry); +// base = base.length() == 0 ? "" : base + "/"; + base = base.length() == 0 ? "" : base + System.getProperties().getProperty("file.separator"); + for (int i = 0; i < fl.length; i++) + { + zip(out, fl[i], base + fl[i].getName()); + } + } + else + { // 压缩目录中的所有文件 + // out.putNextEntry(new org.apache.tools.zip.ZipEntry(base)); + ZipEntry zipEntry=new ZipEntry(base); + zipEntry.setUnixMode(644);//解决linux乱码 + out.putNextEntry(zipEntry); + FileInputStream in = new FileInputStream(f); + int b; + while ((b = in.read()) != -1) + { + out.write(b); + } + in.close(); + } + } +} diff --git a/src/com/engine/workflow/web/danganfiles/DA/util/demo.java b/src/com/engine/workflow/web/danganfiles/DA/util/demo.java new file mode 100644 index 0000000..ee02233 --- /dev/null +++ b/src/com/engine/workflow/web/danganfiles/DA/util/demo.java @@ -0,0 +1,11 @@ +package com.engine.workflow.web.danganfiles.DA.util; + +/** + * @author:CL + * @date:2023/4/3 15:28 + */ +public class demo { + public static void main(String[] args) { + + } +} diff --git a/src/com/engine/workflow/web/danganfiles/DA/util/test.java b/src/com/engine/workflow/web/danganfiles/DA/util/test.java new file mode 100644 index 0000000..07c74ed --- /dev/null +++ b/src/com/engine/workflow/web/danganfiles/DA/util/test.java @@ -0,0 +1,133 @@ +package com.engine.workflow.web.danganfiles.DA.util; + +import javax.activation.MimetypesFileTypeMap; +import java.io.*; +import java.net.HttpURLConnection; +import java.net.URL; +import java.nio.charset.StandardCharsets; +import java.util.Iterator; +import java.util.Map; + +/** + * Created by Intellij IDEA. + * + * @Date: 2021/11/8 16:26 + * @Author: Judy + * @Description: + */ +public class test { + /** + * 上传图片 + * @param urlStr + * @param textMap + * @param fileMap + * @param contentType 没有传入文件类型默认采用application/octet-stream + * contentType非空采用filename匹配默认的图片类型 + * @return 返回response数据 + */ + public static String formUpload(String urlStr, Map textMap, + Map fileMap, String contentType) { + String res = ""; + HttpURLConnection conn = null; + // boundary就是request头和上传文件内容的分隔符 + String BOUNDARY = "---------------------------123821742118716"; + try { + URL url = new URL(urlStr); + conn = (HttpURLConnection) url.openConnection(); + conn.setConnectTimeout(5000); + conn.setReadTimeout(30000); + conn.setDoOutput(true); + conn.setDoInput(true); + conn.setUseCaches(false); + conn.setRequestMethod("POST"); + conn.setRequestProperty("Connection", "Keep-Alive"); + // conn.setRequestProperty("User-Agent","Mozilla/5.0 (Windows; U; Windows NT 6.1; zh-CN; rv:1.9.2.6)"); + conn.setRequestProperty("Content-Type","multipart/form-data; boundary=" + BOUNDARY); + OutputStream out = new DataOutputStream(conn.getOutputStream()); + // text + if (textMap != null) { + StringBuffer strBuf = new StringBuffer(); + Iterator iter = textMap.entrySet().iterator(); + while (iter.hasNext()) { + Map.Entry entry = (Map.Entry) iter.next(); + String inputName = (String) entry.getKey(); + String inputValue = (String) entry.getValue(); + if (inputValue == null) { + continue; + } + strBuf.append("\r\n").append("--").append(BOUNDARY).append("\r\n"); + strBuf.append("Content-Disposition: form-data; name=\"" + inputName + "\"\r\n\r\n"); + strBuf.append(inputValue); + } + out.write(strBuf.toString().getBytes()); + } + // file + if (fileMap != null) { + Iterator iter = fileMap.entrySet().iterator(); + while (iter.hasNext()) { + Map.Entry entry = (Map.Entry) iter.next(); + String inputName = (String) entry.getKey(); + String inputValue = (String) entry.getValue(); + if (inputValue == null) { + continue; + } + File file = new File(inputValue); + String filename = file.getName(); + + //没有传入文件类型,同时根据文件获取不到类型,默认采用application/octet-stream + contentType = new MimetypesFileTypeMap().getContentType(file); + //contentType非空采用filename匹配默认的图片类型 + if(!"".equals(contentType)){ + if (filename.endsWith(".png")) { + contentType = "image/png"; + }else if (filename.endsWith(".jpg") || filename.endsWith(".jpeg") || filename.endsWith(".jpe")) { + contentType = "image/jpeg"; + }else if (filename.endsWith(".gif")) { + contentType = "image/gif"; + }else if (filename.endsWith(".ico")) { + contentType = "image/image/x-icon"; + } + } + if (contentType == null || "".equals(contentType)) { + contentType = "application/octet-stream"; + } + StringBuffer strBuf = new StringBuffer(); + strBuf.append("\r\n").append("--").append(BOUNDARY).append("\r\n"); + strBuf.append("Content-Disposition: form-data; name=\"" + inputName + "\"; filename=\"" + filename + "\"\r\n"); + strBuf.append("Content-Type:" + contentType + "\r\n\r\n"); + out.write(strBuf.toString().getBytes()); + DataInputStream in = new DataInputStream(new FileInputStream(file)); + int bytes = 0; + byte[] bufferOut = new byte[1024]; + while ((bytes = in.read(bufferOut)) != -1) { + out.write(bufferOut, 0, bytes); + } + in.close(); + } + } + byte[] endData = ("\r\n--" + BOUNDARY + "--\r\n").getBytes(); + out.write(endData); + out.flush(); + out.close(); + // 读取返回数据 + StringBuffer strBuf = new StringBuffer(); + BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream(), StandardCharsets.UTF_8)); + String line = null; + while ((line = reader.readLine()) != null) { + strBuf.append(line).append("\n"); + } + res = strBuf.toString(); + reader.close(); + reader = null; + } catch (Exception e) { + System.out.println("发送POST请求出错。" + urlStr); + e.printStackTrace(); + } finally { + if (conn != null) { + conn.disconnect(); + conn = null; + } + } + return res; + } +} diff --git a/src/rebel.xml b/src/rebel.xml new file mode 100644 index 0000000..a7abe20 --- /dev/null +++ b/src/rebel.xml @@ -0,0 +1,16 @@ + + + + + + shoufagongwen + + + + + + +