|
|
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";//压缩包路径
|
|
|
// 根据系统的实际情况选择目录分隔符bai(windows下是,dulinux下是/)
|
|
|
// linux下只认正斜杠,为了保证跨平台性,不建议使用反斜杠(在java程序中是转义字符,用\来表示反斜杠)
|
|
|
|
|
|
// 在内存中创建一个文件对象,注意:此时还没有在硬盘对应目录下创建实实在在的文件
|
|
|
// File f = new File(YJnewPath);
|
|
|
// bb.writeLog("====发文呈报单=====创建文件c="+YJnewPath);
|
|
|
bb.writeLog("====发文呈报单=====创建文件夹成功c="+YJnewPath);
|
|
|
|
|
|
|
|
|
File f2 = new File(GDnewPath+"/ww");
|
|
|
bb.writeLog("====发文呈报单=====创建文件c="+GDnewPath);
|
|
|
if(f2.exists()) {
|
|
|
bb.writeLog("====发文呈报单=====创建文件夹="+f2.getAbsolutePath());
|
|
|
|
|
|
bb.writeLog("====发文呈报单=====创建文件夹="+f2.getName());
|
|
|
bb.writeLog("====发文呈报单=====创建文件c="+f2.length());
|
|
|
|
|
|
bb.writeLog("-----");
|
|
|
} else {
|
|
|
// 先创建文件所在的目录
|
|
|
boolean su =f2.getParentFile().mkdirs();
|
|
|
if(su==true){
|
|
|
if(fj.length()>0){
|
|
|
fjFilename(fj, GDnewPath);
|
|
|
}
|
|
|
if(zwofdwj.length()>0){
|
|
|
fjFilename(zwofdwj, GDnewPath);
|
|
|
}
|
|
|
if(ofdwj.length()>0){
|
|
|
String filename = filename(ofdwj, GDnewPath);
|
|
|
mapList.put("cld",filename);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
bb.writeLog("====发文呈报单=====创建文件夹成功c="+GDnewPath);
|
|
|
//先创建文件夹,之后存放文件,再传递建模进行记录
|
|
|
CreatXML creatXML = new CreatXML();
|
|
|
try {
|
|
|
|
|
|
creatXML.createYJSMXml(YJnewPath,map);
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
bb.writeLog("发文呈报单----依据说明:" + e);
|
|
|
}
|
|
|
|
|
|
try {
|
|
|
creatXML.createGDWJXml(GDnewPath,mapList);
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
bb.writeLog("发文呈报单=====归档文件:" + e);
|
|
|
}
|
|
|
|
|
|
bb.writeLog("====发文呈报单=====写入xml文件="+src);
|
|
|
bb.writeLog("====发文呈报单====文件方法=");
|
|
|
|
|
|
File f1=null;
|
|
|
ZipOutputStream out=null;
|
|
|
String zip = YJnewPath+".zip";
|
|
|
// try {
|
|
|
// f1= new File(YJnewPath);
|
|
|
// out = new ZipOutputStream(new FileOutputStream(
|
|
|
// YJnewPath+".zip"));
|
|
|
// zip(out,f1,null);
|
|
|
// } catch (FileNotFoundException e) {
|
|
|
// e.printStackTrace();
|
|
|
// } catch (Exception e) {
|
|
|
// e.printStackTrace();
|
|
|
// }
|
|
|
|
|
|
// try {
|
|
|
// ZipUtil zipUtil = new ZipUtil();
|
|
|
// zipUtil.zip(YJnewPath,zippath);
|
|
|
// } catch (Exception e) {
|
|
|
// e.printStackTrace();
|
|
|
// }
|
|
|
zipu(YJnewPath,zippath);
|
|
|
bb.writeLog("====发文呈报单=====写入xml文件="+src);
|
|
|
Date date = new Date();
|
|
|
String day = new SimpleDateFormat("yyyy-MM-dd").format(date);
|
|
|
String daytime = new SimpleDateFormat("hh:mm").format(date);
|
|
|
//文件路径,收发文类别,文件夹名称,归档状态,流程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;
|
|
|
}
|
|
|
|
|
|
|
|
|
}
|