first commit 20230223

master
CL 2 years ago
commit 26dc0ba0bc

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

@ -0,0 +1,9 @@
<component name="libraryTable">
<library name="classbean">
<CLASSES>
<root url="file://$PROJECT_DIR$/../../../../../../../WEAVER/ecology/classbean" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</component>

@ -0,0 +1,13 @@
<component name="libraryTable">
<library name="lib">
<CLASSES>
<root url="file://$PROJECT_DIR$/../../../../../../../WEAVER/ecology/WEB-INF/lib" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="file://$PROJECT_DIR$/../../../../../../../WEAVER/ecology/WEB-INF/lib" />
</SOURCES>
<jarDirectory url="file://$PROJECT_DIR$/../../../../../../../WEAVER/ecology/WEB-INF/lib" recursive="false" />
<jarDirectory url="file://$PROJECT_DIR$/../../../../../../../WEAVER/ecology/WEB-INF/lib" recursive="false" type="SOURCES" />
</library>
</component>

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/DA.iml" filepath="$PROJECT_DIR$/DA.iml" />
</modules>
</component>
</project>

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$" isTestSource="false" packagePrefix="com.api.sfj.DA" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="classbean" level="project" />
<orderEntry type="library" name="lib" level="project" />
</component>
</module>

@ -0,0 +1,343 @@
package com.api.sfj.DA;
import com.api.sfj.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.api.sfj.DA.util.JY_action.filename;
import static com.api.sfj.DA.util.JY_action.fjFilename;
import static com.api.sfj.DA.util.ZipFile.zipu;
/**
* d
* 2020-10-14
*/
@SuppressWarnings("all")
public class DWSW_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) {
BaseBean bb = new BaseBean();
RecordSet rs = new RecordSet();
//=====================================================================读取主表数据
String requestid = requestinfo.getRequestid(); //请求ID
bb.writeLog("====党委收文单========START-->requestid--->"+requestid);
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--->"+time);
UUID uuid = UUID.randomUUID();
bb.writeLog("uuid--->"+uuid);
String str = uuid.toString().replaceAll("-","");
String fj ="";
String ofdwj ="";
String wjbt="";
if (rs.next()){
String ljdjid = rs.getString("ljdjid"); // 来件登记id
String swbh = rs.getString("swbh"); //收文编号
String swrq = rs.getString("swrq"); //收文日期
String lwjg = rs.getString("lwjg"); // 来文机关
String lwbh = rs.getString("lwbh"); // 来文编号
wjbt = rs.getString("wjbt"); //文件标题
String zsdw = rs.getString("zsdw"); //主送单位
String csdw = rs.getString("csdw"); //抄送单位
int mj = rs.getInt("mj"); //密级
String hj = rs.getString("hj"); // 缓急
String zw = rs.getString("zw"); // 正文
ofdwj = rs.getString("ofdwj"); // ofd文件
fj =rs.getString("xgfj"); //相关附件
String xzcs = rs.getString("xzcs"); //选择处室
String xzqtcs = rs.getString("xzqtcs");//选择其他处室
String xzblry = rs.getString("xzblry");//选择办理人员
Date date = new Date();
String da = new SimpleDateFormat("yyyy-MM-dd").format(date).replaceAll("-","");
String doctype="0";//收文类型
String mjstr="";
if(mj==0){
mjstr="非涉密";
}else if(mj==1){
mjstr="机密";
}else if(mj==2){
mjstr="秘密";
}
map.put("dh",time+"-"+requestid); //档号,归档存储文件文件夹名称
map.put("bt",wjbt); //标题
map.put("bh",lwbh);//文号
// map.put("zrz",lwjg); //责任者
map.put("rq",swrq.replaceAll("-","")); //日期
map.put("ys",1);
mapList.put("dh",str); //UUID档号
mapList.put("bt",wjbt); //文件标题
String depName="select departmentname from hrmdepartment where id="+48;
String zrzName ="";
try {
rs.execute(depName);
rs.writeLog(depName);
rs.next();
zrzName = rs.getString("departmentname");
}catch (Exception e){
bb.writeLog(""+e);
}
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<Map<String, Object>> nodeInfoList = new ArrayList<>();
try {
RecordSet recordSet = new RecordSet();
recordSet.execute(nodeInfoSql);
bb.writeLog("开始查询节点流程");
while (recordSet.next()){
Map<String,Object> 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<Map<String, Object>> 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<String,Object> 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("zrz","天津市司法局"); //责任者
// mapList.put("zrz",lwjg); //责任者 部门名称
map.put("zrz",zrzName);
mapList.put("zrz",zrzName);
mapList.put("jgryName",jgryName); //机构人员中文
mapList.put("jgryBmName",jgryBmName); //机构人员部门名称
mapList.put("jgryid",jgryid); //机构人员id
mapList.put("rq",swrq.replaceAll("-","")); //日期
mapList.put("kzbs","控制"); // 控制标识
mapList.put("zw",ofdwj); // 正文
mapList.put("nodeInfoList",nodeInfoList);
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("wz","收文"); //文种
mapList.put("mj",mjstr);
bb.writeLog("====党委收文单==内部=444=map="+map.toString());
bb.writeLog("====党委收文单==内部=444=maplist="+mapList.toString());
}
bb.writeLog("time-->"+time);
String filerealpath = "";
String YJnewPath = "/home/WEAVER/oadata792/DAGD/DWSW/"+str; //归档文件依据说明文件夹
String GDnewPath = "/home/WEAVER/oadata792/DAGD/DWSW/"+str+"/"+time+"-"+requestid; //归档文件正文附件文件夹
String zipname =str+".zip";
String zippath = YJnewPath+".zip";//压缩包路径
// 根据系统的实际情况选择目录分隔符baiwindows下是dulinux下是/
// linux下只认正斜杠为了保证跨平台性不建议使用反斜杠在java程序中是转义字符用\来表示反斜杠)
// 在内存中创建一个文件对象,注意:此时还没有在硬盘对应目录下创建实实在在的文件
// File f = new File(YJnewPath);
// if(f.exists()) {
//// 文件已经存在,输出文件的相关信息
// System.out.println(f.getAbsolutePath());
// System.out.println(f.getName());
// System.out.println(f.length());
// } else {
//// 先创建文件所在的目录
// f.getParentFile().mkdirs();
//
// } boolean su =
File f2 = new File(GDnewPath+"/ww");
if(f2.exists()) {
bb.writeLog("if(f2.exists()) {---->");
bb.writeLog("f2.getAbsolutePath()-->"+f2.getAbsolutePath());
bb.writeLog("f2.getName()-->"+f2.getName());
bb.writeLog("f2.length()-->"+f2.length());
} else {
// 先创建文件所在的目录
boolean su =f2.getParentFile().mkdirs();
if(su==true){
if(fj.length()>0){
fjFilename(fj,GDnewPath);
}
if(ofdwj.length()>0){
String filename = filename(ofdwj, GDnewPath);
mapList.put("cld",filename);
}
}
}
//先创建文件夹,之后存放文件,再传递建模进行记录
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);
}
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();
// }
zipu(YJnewPath,zippath);
// try {
// ZipUtil zipUtil = new ZipUtil();
// zipUtil.zip(YJnewPath,zippath);
// } catch (Exception e) {
// e.printStackTrace();
// }
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("-","");
//文件路径收发文类别文件夹名称归档状态流程id
// String insertsql = "insert into uf_dagd(wjlj,sfwlb,wjjmc,gdzt,lcid,lcgdrq,lcgdsj,gdlcm) values('"+zippath+"','"+0+"','"+zipname+"','"+0+"','"+requestid+"','"+day+"','"+daytime+"','"+wjbt+"')";
String insertsql = "insert into uf_dagd(wjlj,sfwlb,wjjmc,gdzt,lcid,lcgdrq,lcgdsj,ssbm,gdlcm) values('"+zippath+"','"+0+"','"+zipname+"','"+0+"','"+requestid+"','"+day+"','"+daytime+"','"+48+"','"+wjbt+"')";
RecordSet recordSet = new RecordSet();
recordSet.execute(insertsql);
recordSet.writeLog("建模台账添加数据"+insertsql);
return Action.SUCCESS;
}
}

@ -0,0 +1,366 @@
package com.api.sfj.DA;
import com.api.sfj.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.api.sfj.DA.util.JY_action.filename;
import static com.api.sfj.DA.util.JY_action.fjFilename;
import static com.api.sfj.DA.util.ZipFile.zipu;
/**
*
* 2020-10-14
*/
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) {
BaseBean bb = new BaseBean();
RecordSet rs = new RecordSet();
List<Map<String,String>> list = new ArrayList<Map<String,String>>();
//=====================================================================读取主表数据
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<String,Object> map = new HashMap(); // 依据说明
HashMap<String,Object> 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("wjbt"); //文件标题
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("ngcs"); //拟稿处室
String ngr = rs.getString("ngr"); //拟稿人
String zw = rs.getString("zw"); // 正文
ofdwj = rs.getString("ofdwj"); // 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<Map<String, Object>> nodeInfoList = new ArrayList<>();
try {
RecordSet recordSet = new RecordSet();
recordSet.execute(nodeInfoSql);
bb.writeLog("开始查询节点流程");
while (recordSet.next()){
Map<String,Object> 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<Map<String, Object>> 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<String,Object> 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 = "/home/WEAVER/oadata792/DAGD/FWCB/"+str; //归档文件依据说明文件夹
String GDnewPath = "/home/WEAVER/oadata792/DAGD/FWCB/"+str+"/"+time+"-"+requestid; //归档文件正文附件文件夹
String zipname =str+".zip";
String zippath = YJnewPath+".zip";//压缩包路径
// 根据系统的实际情况选择目录分隔符baiwindows下是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);
//文件路径收发文类别文件夹名称归档状态流程id
String insertsql = "insert into uf_dagd(wjlj,sfwlb,wjjmc,gdzt,lcid,lcgdrq,lcgdsj,ssbm,gdlcm) values('"+zippath+"','"+1+"','"+zipname+"','"+0+"','"+requestid+"','"+day+"','"+daytime+"','"+ngcs+"','"+wjbt+"')";
RecordSet recordSet = new RecordSet();
recordSet.execute(insertsql);
recordSet.writeLog("建模台账添加数据"+insertsql);
return Action.SUCCESS;
}
}

@ -0,0 +1,339 @@
package com.api.sfj.DA;
import com.api.sfj.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.api.sfj.DA.util.JY_action.filename;
import static com.api.sfj.DA.util.JY_action.fjFilename;
import static com.api.sfj.DA.util.ZipFile.zipu;
/**
*
* 2020-10-14
*/
public class FWDJ_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) {
BaseBean bb = new BaseBean();
RecordSet rs = new RecordSet();
//=====================================================================读取主表数据
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<String,Object> map = new HashMap(); // 依据说明
HashMap<String,Object> mapList = new HashMap(); // 归档文件
SimpleDateFormat fomat = new SimpleDateFormat("yyyyMMddHHmmss");
String time = fomat.format(new Date());
bb.writeLog("time-->"+time);
String dh =time+"-"+requestid;
UUID uuid = UUID.randomUUID();
bb.writeLog("uuid-->"+uuid);
String str = uuid.toString().replaceAll("-","");
String fj ="";
String ofdwj ="";
String wjbt="";
String ngcs="";
String zwofdwj ="";
while (rs.next()){
fj =rs.getString("fj"); //附件
wjbt = rs.getString("wjbt"); //文件标题
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("ngcs"); //拟稿处室
String ngr = rs.getString("ngr"); //拟稿人
String zw = rs.getString("zw"); // 正文
ofdwj = rs.getString("ofdwj"); // ofd文件
zwofdwj = rs.getString("zwofdwj"); // ofd附件文件
String mjstr="";
if(mj==0){
mjstr="非涉密";
}else if(mj==1){
mjstr="机密";
}else if(mj==2){
mjstr="秘密";
}else if(mj==3){
mjstr="绝密";
}
String ffrq = rs.getString("ffrq"); // 封发日期
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<Map<String, Object>> nodeInfoList = new ArrayList<>();
try {
RecordSet recordSet = new RecordSet();
recordSet.execute(nodeInfoSql);
bb.writeLog("开始查询节点流程");
while (recordSet.next()){
Map<String,Object> 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<Map<String, Object>> 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<String,Object> 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("zrz",ngcs); //责任者
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); // 正文
mapList.put("nodeInfoList",nodeInfoList); // 节点信息
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());
String filerealpath = "";
String YJnewPath = "/home/WEAVER/oadata792/DAGD/FWDJ/"+str; //归档文件依据说明文件夹
String GDnewPath = "/home/WEAVER/oadata792/DAGD/FWDJ/"+str+"/"+time+"-"+requestid; //归档文件正文附件文件夹
String zipname =str+".zip";
String zippath = YJnewPath+".zip";//压缩包路径
// 根据系统的实际情况选择目录分隔符baiwindows下是dulinux下是/
// linux下只认正斜杠为了保证跨平台性不建议使用反斜杠在java程序中是转义字符用\来表示反斜杠)
// 在内存中创建一个文件对象,注意:此时还没有在硬盘对应目录下创建实实在在的文件
// File f = new File(YJnewPath);
// if(f.exists()) {
//// 文件已经存在,输出文件的相关信息
// System.out.println(f.getAbsolutePath());
// System.out.println(f.getName());
// System.out.println(f.length());
// } else {
//// 先创建文件所在的目录
// f.getParentFile().mkdirs();
//
// }
bb.writeLog("====发文登记单=====创建文件夹成功c="+YJnewPath);
File f2 = new File(GDnewPath+"/ww");
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);
Date date = new Date();
String day = new SimpleDateFormat("yyyy-MM-dd").format(date);
String daytime = new SimpleDateFormat("hh:mm").format(date);
//文件路径收发文类别文件夹名称归档状态流程id
// String insertsql = "insert into uf_dagd(wjlj,sfwlb,wjjmc,gdzt,lcid,lcgdrq,lcgdsj,gdlcm) values('"+zippath+"','"+1+"','"+zipname+"','"+0+"','"+requestid+"','"+day+"','"+daytime+"','"+wjbt+"')";
String insertsql = "insert into uf_dagd(wjlj,sfwlb,wjjmc,gdzt,lcid,lcgdrq,lcgdsj,ssbm,gdlcm) values('"+zippath+"','"+1+"','"+zipname+"','"+0+"','"+requestid+"','"+day+"','"+daytime+"','"+ngcs+"','"+wjbt+"')";
RecordSet recordSet = new RecordSet();
recordSet.execute(insertsql);
recordSet.writeLog("建模台账添加数据"+insertsql);
return Action.SUCCESS;
}
}

@ -0,0 +1,322 @@
package com.api.sfj.DA;
import com.api.sfj.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.api.sfj.DA.util.JY_action.filename;
import static com.api.sfj.DA.util.JY_action.fjFilename;
import static com.api.sfj.DA.util.ZipFile.zipu;
/**
*
* 2020-10-14
*/
public class XXJBQY_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) {
BaseBean bb = new BaseBean();
RecordSet rs = new RecordSet();
//=====================================================================读取主表数据
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<String,Object> map = new HashMap(); // 依据说明
HashMap<String,Object> mapList = new HashMap(); // 归档文件
SimpleDateFormat fomat = new SimpleDateFormat("yyyyMMddHHmmss");
String time = fomat.format(new Date());
bb.writeLog("time-->"+time);
UUID uuid = UUID.randomUUID();
bb.writeLog("uuid-->"+uuid);
String str = uuid.toString().replaceAll("-","");
String fj ="";
String ofdwj ="";
String wjbt ="";
while (rs.next()){
String lwdw = rs.getString("lwdw"); //来文单位
String qyr = rs.getString("qyr");// 签阅人
String ljdjid = rs.getString("ljdjid"); // 来件登记id
String lwrq = rs.getString("lwrq"); // 收文日期
String lwjg = rs.getString("lwjg");// 来文机关
String lwbh = rs.getString("lwbh"); // 来文编号
wjbt = rs.getString("bt"); //文件标题
String zw = rs.getString("zw"); // 正文
ofdwj = rs.getString("ofdwj"); // ofd文件
fj =rs.getString("jbwj"); //附件
// Date date = new Date();
// String da = new SimpleDateFormat("yyyy-MM-dd").format(date).replaceAll("-","");
map.put("dh",time+"-"+requestid); //档号,归档存储文件文件夹名称
map.put("bt",wjbt); //标题
map.put("bh",lwbh);//文号
// map.put("zrz",lwdw); //责任者
map.put("rq",lwrq.replaceAll("-","")); //日期
map.put("ys",1);
bb.writeLog("====信息简报单=====文件添加数据="+map);
mapList.put("dh",str); //UUID档号
mapList.put("bt",wjbt); //文件标题
String depName="select departmentname from hrmdepartment where id="+53;
String zrzName ="";
try {
rs.execute(depName);
rs.writeLog(depName);
rs.next();
zrzName = rs.getString("departmentname");
}catch (Exception e){
bb.writeLog(""+e);
}
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<Map<String, Object>> nodeInfoList = new ArrayList<>();
try {
RecordSet recordSet = new RecordSet();
recordSet.execute(nodeInfoSql);
bb.writeLog("开始查询节点流程");
while (recordSet.next()){
Map<String,Object> 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<Map<String, Object>> 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<String,Object> 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("zrz","天津市司法局"); //责任者
map.put("zrz",zrzName);
mapList.put("zrz",zrzName);
mapList.put("jgryName",jgryName); //机构人员中文
mapList.put("jgryBmName",jgryBmName); //机构人员部门名称
mapList.put("jgryid",jgryid); //机构人员id
mapList.put("rq",lwrq.replaceAll("-","")); //日期
mapList.put("kzbs","控制"); // 控制标识
mapList.put("zw",ofdwj); // 正文
mapList.put("nodeInfoList",nodeInfoList);
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("wz","收文"); //文种
mapList.put("mj","非涉密");
bb.writeLog("====信息简报" +
"==内部=444=map="+map.toString());
bb.writeLog("====信息简报==内部=444=maplist="+mapList.toString());
}
;
bb.writeLog("time-->"+time);
String filerealpath = "";
String YJnewPath = "/home/WEAVER/oadata792/DAGD/XXJB/"+str; //归档文件依据说明文件夹
String GDnewPath = "/home/WEAVER/oadata792/DAGD/XXJB/"+str+"/"+time+"-"+requestid; //归档文件正文附件文件夹
String zipname =str+".zip";
String zippath = YJnewPath+".zip";//压缩包路径
// 根据系统的实际情况选择目录分隔符baiwindows下是dulinux下是/
// linux下只认正斜杠为了保证跨平台性不建议使用反斜杠在java程序中是转义字符用\来表示反斜杠)
// 在内存中创建一个文件对象,注意:此时还没有在硬盘对应目录下创建实实在在的文件
// File f = new File(YJnewPath);
// if(f.exists()) {
//// 文件已经存在,输出文件的相关信息
// System.out.println(f.getAbsolutePath());
// System.out.println(f.getName());
// System.out.println(f.length());
// } else {
//// 先创建文件所在的目录
// f.getParentFile().mkdirs();
//
// }
File f2 = new File(GDnewPath+"/ww");
if(f2.exists()) {
bb.writeLog("if(f2.exists()) {---->");
bb.writeLog("f2.getAbsolutePath()-->"+f2.getAbsolutePath());
bb.writeLog("f2.getName()-->"+f2.getName());
bb.writeLog("f2.length()-->"+f2.length());
} else {
// 先创建文件所在的目录
boolean su =f2.getParentFile().mkdirs();
if(su==true){
if(fj.length()>0){
fjFilename(fj,GDnewPath);
}
if(ofdwj.length()>0){
String filename = filename(ofdwj, GDnewPath);
mapList.put("cld",filename);
}
}
}
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();
// }
//先创建文件夹,之后存放文件,再传递建模进行记录
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);
}
// try {
// ZipUtil zipUtil = new ZipUtil();
// zipUtil.zip(YJnewPath,zippath);
// } catch (Exception e) {
// e.printStackTrace();
// }
zipu(YJnewPath,zippath);
Date date = new Date();
String day = new SimpleDateFormat("yyyy-MM-dd").format(date);
String daytime = new SimpleDateFormat("hh:mm").format(date);
//文件路径收发文类别文件夹名称归档状态流程id
// String insertsql = "insert into uf_dagd(wjlj,sfwlb,wjjmc,gdzt,lcid,lcgdrq,lcgdsj,gdlcm) values('"+zippath+"','"+1+"','"+zipname+"','"+0+"','"+requestid+"','"+day+"','"+daytime+"','"+wjbt+"')";
String insertsql = "insert into uf_dagd(wjlj,sfwlb,wjjmc,gdzt,lcid,lcgdrq,lcgdsj,ssbm,gdlcm) values('"+zippath+"','"+0+"','"+zipname+"','"+0+"','"+requestid+"','"+day+"','"+daytime+"','"+53+"','"+wjbt+"')";
RecordSet recordSet = new RecordSet();
recordSet.execute(insertsql);
recordSet.writeLog("建模台账添加数据"+insertsql);
//
return Action.SUCCESS;
}
}

@ -0,0 +1,337 @@
package com.api.sfj.DA;
import com.api.sfj.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.api.sfj.DA.util.JY_action.filename;
import static com.api.sfj.DA.util.JY_action.fjFilename;
import static com.api.sfj.DA.util.ZipFile.zipu;
/**
*
* 2020-10-14
*/
public class ZFSW_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) {
BaseBean bb = new BaseBean();
RecordSet rs = new RecordSet();
//=====================================================================读取主表数据
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);
UUID uuid = UUID.randomUUID();
bb.writeLog(uuid);
String str = uuid.toString().replaceAll("-","");
String fj ="";
String ofdwj ="";
String wjbt="";
while (rs.next()){
String ljdjid = rs.getString("ljdjid"); // 来件登记id
String swbh = rs.getString("swbh"); // 收文编号
String swrq = rs.getString("swrq"); // 收文日期
String lwjg = rs.getString("lwjg");// 来文机关
String lwbh = rs.getString("lwbh"); // 来文编号
String jzsj = rs.getString("jzsj"); // 截至时间
wjbt = rs.getString("wjbt"); //文件标题
String zsdw = rs.getString("zsdw"); //主送单位
String csdw = rs.getString("csdw"); //抄送单位
int mj = rs.getInt("mj"); //密级
String hj = rs.getString("hj"); // 缓急
String zw = rs.getString("zw"); // 正文
ofdwj = rs.getString("ofdwj"); // ofd文件
fj =rs.getString("xgfj"); //附件
String xzcs = rs.getString("xzcs"); // 选择处室
String xzqtcs = rs.getString("xzqtcs"); //选择其他处室
String xzblry = rs.getString("xzblry");//选择办理人员
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("-","");
map.put("dh",time+"-"+requestid); //档号,归档存储文件文件夹名称
map.put("bt",wjbt); //标题
map.put("bh",lwbh);//文号
// map.put("zrz",lwjg); //责任者
map.put("rq",swrq.replaceAll("-","")); //日期
map.put("ys",1);
mapList.put("dh",str); //UUID档号
mapList.put("bt",wjbt); //文件标题
String depName="select departmentname from hrmdepartment where id="+48;
String zrzName ="";
try {
rs.execute(depName);
rs.writeLog(depName);
rs.next();
zrzName = rs.getString("departmentname");
}catch (Exception e){
bb.writeLog(""+e);
}
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<Map<String, Object>> nodeInfoList = new ArrayList<>();
try {
RecordSet recordSet = new RecordSet();
recordSet.execute(nodeInfoSql);
bb.writeLog("开始查询节点流程");
while (recordSet.next()){
Map<String,Object> 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<Map<String, Object>> 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<String,Object> 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("zrz","天津市司法局"); //责任者
map.put("zrz",zrzName);
mapList.put("zrz",zrzName);
mapList.put("jgryName",jgryName); //机构人员中文
mapList.put("jgryBmName",jgryBmName); //机构人员部门名称
mapList.put("jgryid",jgryid); //机构人员id
mapList.put("rq",swrq.replaceAll("-","")); //日期
mapList.put("kzbs","控制"); // 控制标识
mapList.put("zw",ofdwj); // 正文
mapList.put("nodeInfoList",nodeInfoList);
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("wz","收文"); //文种
mapList.put("mj",mjstr);
bb.writeLog("====政府收文单==内部=444=map="+map.toString());
bb.writeLog("====政府收文单==内部=444=maplist="+mapList.toString());
}
bb.writeLog("time-->"+time);
String filerealpath = "";
String YJnewPath = "/home/WEAVER/oadata792/DAGD/ZFSW/"+str; //归档文件依据说明文件夹
String GDnewPath = "/home/WEAVER/oadata792/DAGD/ZFSW/"+str+"/"+time+"-"+requestid; //归档文件正文附件文件夹
String zipname =str+".zip";
String zippath = YJnewPath+".zip";//压缩包路径
// 根据系统的实际情况选择目录分隔符baiwindows下是dulinux下是/
// linux下只认正斜杠为了保证跨平台性不建议使用反斜杠在java程序中是转义字符用\来表示反斜杠)
// 在内存中创建一个文件对象,注意:此时还没有在硬盘对应目录下创建实实在在的文件
// File f = new File(YJnewPath);
// if(f.exists()) {
//// 文件已经存在,输出文件的相关信息
// System.out.println(f.getAbsolutePath());
// System.out.println(f.getName());
// System.out.println(f.length());
// } else {
//// 先创建文件所在的目录
// f.getParentFile().mkdirs();
//
// }
File f2 = new File(GDnewPath+"/ww");
if(f2.exists()) {
bb.writeLog("if(f2.exists()) {---->");
bb.writeLog("f2.getAbsolutePath()-->"+f2.getAbsolutePath());
bb.writeLog("f2.getName()-->"+f2.getName());
bb.writeLog("f2.length()-->"+f2.length());
} else {
// 先创建文件所在的目录
boolean su =f2.getParentFile().mkdirs();
if(su==true){
if(fj.length()>0){
fjFilename(fj,GDnewPath);
}
if(ofdwj.length()>0){
String filename = filename(ofdwj, GDnewPath);
mapList.put("cld",filename);
}
}
}
//先创建文件夹,之后存放文件,再传递建模进行记录
//先创建文件夹,之后存放文件,再传递建模进行记录
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);
}
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);
Date date = new Date();
String day = new SimpleDateFormat("yyyy-MM-dd").format(date);
String daytime = new SimpleDateFormat("hh:mm").format(date);
//文件路径收发文类别文件夹名称归档状态流程id
// String insertsql = "insert into uf_dagd(wjlj,sfwlb,wjjmc,gdzt,lcid,lcgdrq,lcgdsj,gdlcm) values('"+zippath+"','"+0+"','"+zipname+"','"+0+"','"+requestid+"','"+day+"','"+daytime+"','"+wjbt+"')";
String insertsql = "insert into uf_dagd(wjlj,sfwlb,wjjmc,gdzt,lcid,lcgdrq,lcgdsj,ssbm,gdlcm) values('"+zippath+"','"+0+"','"+zipname+"','"+0+"','"+requestid+"','"+day+"','"+daytime+"','"+48+"','"+wjbt+"')";
RecordSet recordSet = new RecordSet();
recordSet.execute(insertsql);
recordSet.writeLog("建模台账添加数据"+insertsql);
//
return Action.SUCCESS;
}
}

@ -0,0 +1,456 @@
package com.api.sfj.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<String, Object> 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<Map<String, Object>> nodeInfoList = (List<Map<String, Object>>)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("");
// 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<String, Object> 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<HashMap> getfilename(String fj) {
BaseBean bs = new BaseBean();
bs.writeLog("==11=进入查询方法-->fj"+fj);
List<HashMap> 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";
rs3.execute(docdetail);
HashMap<String, String> map = new HashMap();
// List<String> 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;
}
}

@ -0,0 +1,271 @@
package com.api.sfj.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.6.115.68:8082";
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;
}
}

@ -0,0 +1,98 @@
package com.api.sfj.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 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 + "";
}
}

@ -0,0 +1,178 @@
package com.api.sfj.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;
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<String,Object> 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<String, Object> resultMap = new HashMap<>();
resultMap.put("successCount", successCount);
resultMap.put("deftCount", deftCount);
return resultMap;
}
}

@ -0,0 +1,422 @@
package com.api.sfj.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 ,ecologyUUIDzip
*/
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 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";
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 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";
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();
}
}

@ -0,0 +1,144 @@
package com.api.sfj.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);
}
}
}

@ -0,0 +1,67 @@
package com.api.sfj.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();
}
}
}

@ -0,0 +1,133 @@
package com.api.sfj.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
* contentTypefilename
* @return response
*/
public static String formUpload(String urlStr, Map<String, String> textMap,
Map<String, String> 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;
}
}

@ -0,0 +1,171 @@
package com.api.sfj.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;
int flag = 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) {
flag = 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 flag + "";
}
}
Loading…
Cancel
Save