📄 gdfilemanager.java
字号:
*/
public static gdFile changeGdFile(attachment bean,String docId){
gdFile gd=new gdFile();
gd.setFileId(0);
gd.setDocId(docId);
gd.setTitle(bean.getTitle());
gd.setPath(bean.getPath());
gd.setFileName(bean.getFileName());
gd.setSite(bean.getSite());
gd.setFileSize(bean.getFileSize());
gd.setMimeType(bean.getMimeType());
gd.setStatus("1");
gd.setOrderBy("0");
gd.setTableName("rarchive");
return gd;
}
/**
* 发文归档 :脱密文件(gd)上传,Archive,GdFile插入记录 ,SendDocForm更改状态位,SendDocLog插入归档日志
*/
public static int saveSendDocArchive(PageContext pageContext) throws ServletException,SmartUploadException, IOException, DBPoolException, SQLException,Exception {
int ret=0;
SmartUpload upload = new SmartUpload();
upload.initialize(pageContext);
try {
upload.upload();
} catch(NegativeArraySizeException e) {}
Request req = upload.getRequest();
String docId = req.getParameter("docId");
String unitId = req.getParameter("unitId");
String userId = req.getParameter("userId");
String userName = req.getParameter("userName");
String trueName = req.getParameter("trueName");
String fileSize = req.getParameter("fileSize");
String fileType = req.getParameter("fileType");
Vector v=attachmentManager.getListVector(docId,"10");
attachment bean=(attachment)v.get(0);
String path=bean.getPath();
String site=bean.getSite();
path=path+site+"/";
trueName=trueName.substring(0,trueName.lastIndexOf("."))+".gd";
ret=saveSendDocArchive(docId,trueName,userId,userName,unitId,new Integer(fileSize).intValue(),fileType);
return ret;
}
public static int saveSendDocArchive(String docId,String trueName,String userId,String userName,String unitId,int size,String type) throws DBPoolException, SQLException ,NotFoundException{
int retval=0;
Connection conn=DBManager.getConnection();
try {
conn.setAutoCommit(false);
//SendDocForm置位
SendDocForm form=SendDocFormManager.getDoc(docId);
form.setStatus("5");//Status:0:草稿 1:待盖章 2:待发送 3:已发送 4:已重发 5:已归档
SendDocFormPersistent forms=new SendDocFormPersistent(form);
forms.setRecordExists(true);
forms.persist(conn);
//RecvDocLog写入归档日志信息
SendDocLog log=new SendDocLog();
log.setLogId(0);
log.setDocId(docId);
log.setOperateId("10");//0:登记 1:修改 2:登记完毕 3:盖章(加密) 4:发送 5:重发 6:签收 7:退回 10:发文方归档
log.setOperateDate(DateWrapper.getLongTime(new Date()));
log.setOperator(userName);
log.setOperatorId(userId);
log.setUnitId(unitId);
SendDocLogPersistent slog=new SendDocLogPersistent(log);
slog.persist(conn);
//GuiForm主表插入记录
GuiDocForm aform=changeGuiDocForm(form,docId,unitId,userName);
GuiDocFormPersistent aforms=new GuiDocFormPersistent(aform);
aforms.setRecordExists(false);
aforms.persist(conn);
int aId=aforms.getBean().getDocId().intValue();
retval=aId;
//GdFIle插入记录(注意正文重新上传,附件只建立映射)
Vector v=attachmentManager.getListVector(docId,"10");
attachment att=(attachment)v.firstElement();
gdFile bean=new gdFile();
bean.setFileId(0);
bean.setTitle(att.getTitle().substring(0,att.getTitle().length()-2)+"gd");
bean.setPath(att.getPath());
bean.setSite(att.getSite());
bean.setFileName(trueName);
bean.setTableName("sarchive");
bean.setDocId(Integer.toString(aId));
bean.setFileSize(size);
bean.setMimeType(type);
bean.setStatus("0");
bean.setOrderBy("0");
gdFilePersistent sbean=new gdFilePersistent(bean);
sbean.setRecordExists(false);
sbean.persist(conn);
Vector v1=attachmentManager.getListVector(docId,"11");
for(int i=0;i<v1.size();i++){
bean=changeGdFile((attachment)v1.get(i),Integer.toString(aId));
bean.setTableName("sarchive");
sbean=new gdFilePersistent(bean);
sbean.setRecordExists(false);
sbean.persist(conn);
}
conn.commit();
}
catch (Exception e)
{
conn.rollback();
e.printStackTrace();
}
finally {
conn.setAutoCommit(true);
conn.close();
return retval;
}
}
/**
* 收文归档 :其他类型文件归档不需要重新上传,Archive,GdFile插入记录 ,RecvPermission更改状态位,RecvDocLog插入归档日志
*/
public static int saveSendDocArchiveUn(String docId,String userId,String userName,String unitId) throws DBPoolException, SQLException ,NotFoundException{
int retval=0;
Connection conn=DBManager.getConnection();
try {
conn.setAutoCommit(false);
//SendDocForm置位
SendDocForm form=SendDocFormManager.getDoc(docId);
form.setStatus("5");//Status:0:草稿 1:待盖章 2:待发送 3:已发送 4:已重发 5:已归档
SendDocFormPersistent forms=new SendDocFormPersistent(form);
forms.setRecordExists(true);
forms.persist(conn);
//RecvDocLog写入归档日志信息
SendDocLog log=new SendDocLog();
log.setLogId(0);
log.setDocId(docId);
log.setOperateId("10");//0:登记 1:修改 2:登记完毕 3:盖章(加密) 4:发送 5:重发 6:签收 7:退回 10:发文方归档
log.setOperateDate(DateWrapper.getLongTime(new Date()));
log.setOperator(userName);
log.setOperatorId(userId);
log.setUnitId(unitId);
SendDocLogPersistent slog=new SendDocLogPersistent(log);
slog.persist(conn);
//GuiForm主表插入记录
GuiDocForm aform=changeGuiDocForm(form,docId,unitId,userName);
GuiDocFormPersistent aforms=new GuiDocFormPersistent(aform);
aforms.setRecordExists(false);
aforms.persist(conn);
int aId=aforms.getBean().getDocId().intValue();
retval=aId;
//GdFIle插入记录(注意正文重新上传,附件只建立映射)
Vector v=attachmentManager.getListVector(docId,"10");
attachment att=(attachment)v.firstElement();
gdFile bean=new gdFile();
bean.setFileId(0);
bean.setTitle(att.getTitle());
bean.setPath(att.getPath());
bean.setSite(att.getSite());
bean.setFileName(att.getFileName());
bean.setTableName("sarchive");
bean.setDocId(Integer.toString(aId));
bean.setFileSize(att.getFileSize());
bean.setMimeType(att.getMimeType());
bean.setStatus("0");
bean.setOrderBy("0");
gdFilePersistent sbean=new gdFilePersistent(bean);
sbean.setRecordExists(false);
sbean.persist(conn);
Vector v1=attachmentManager.getListVector(docId,"11");
for(int i=0;i<v1.size();i++){
bean=changeGdFile((attachment)v1.get(i),Integer.toString(aId));
bean.setTableName("sarchive");
sbean=new gdFilePersistent(bean);
sbean.setRecordExists(false);
sbean.persist(conn);
}
conn.commit();
}
catch (Exception e)
{
conn.rollback();
e.printStackTrace();
}
finally {
conn.setAutoCommit(true);
conn.close();
return retval;
}
}
/**
* 由SendDocForm 封装一个GuiDocForm
*/
public static GuiDocForm changeGuiDocForm(SendDocForm form,String docId,String unitId,String userName) throws SQLException,DBPoolException{
GuiDocForm aform=new GuiDocForm();
aform.setDocId(0);
aform.setSendDocId(form.getDocId().toString());
aform.setDocKind(form.getDocKind());
aform.setDocTitle(form.getDocTitle());
aform.setCreateDate(form.getCreateDate());
aform.setCreator(form.getCreator());
aform.setCreateUnitId(form.getCreateUnitId());
aform.setDocNoPre(form.getDocNoPre());
aform.setYearNo(form.getYearNo());
aform.setWaterNo(form.getWaterNo());
aform.setSecret(form.getSecret());
aform.setEmergency(form.getEmergency());
aform.setSubject(form.getSubject());
aform.setPublishDate(form.getPublishDate());
aform.setPublishPerson(form.getPublishPerson());
aform.setAllSignPerson(form.getAllSignPerson());
aform.setDealPerson(form.getDealPerson());
aform.setCheckPerson(form.getCheckPerson());
aform.setPrintUnit(form.getPrintUnit());
aform.setPrintDate(form.getPrintDate());
aform.setMainDealUnit(form.getMainDealunit());
aform.setAllUnit(form.getCombineUnit());
aform.setSaveTime(form.getSaveTime());
aform.setSendTo(form.getSendTo());
aform.setCc(form.getCc());
aform.setReportTo(form.getReportTo());
aform.setInerTo(form.getInerTo());
aform.setSendUnitId(form.getCreateUnitId().toString());
aform.setSendTime(form.getSendTime());
aform.setSendPerson(form.getSendPerson());
aform.setSealTime(form.getSealTime()); //盖章时间
aform.setSealPerson(form.getSealPerson()); //盖章人
aform.setSealName(form.getSealName()); //印章名称
aform.setPrintnumber(form.getPrintnumber());
aform.setFilePages(form.getFilePages());
aform.setAttachmentPages(form.getAttachmentPages());
aform.setMemo(form.getDocMemo());
aform.setGuiDate(DateWrapper.getLongTime(new Date()));
aform.setGuiUnitId(unitId);
aform.setGuiPerson(userName);
aform.setGuiId("");//归档号
aform.setGuiType("0");//未上传OA
aform.setStatus("1");//发文归档
return aform;
}
/**
* 获得某个文件的详情
*/
public static gdFile getGdFile(String fileId) throws DBPoolException, SQLException ,NotFoundException{
Connection conn = DBManager.getConnection();
String where="Where fileId='"+fileId+"'";
try {
return (gdFile)gdFilePersistent.load(conn, where).firstElement();
}
finally {
conn.close();
}
}
public static Vector getGdFileList(String docId) throws DBPoolException, SQLException ,NotFoundException{
Connection conn = DBManager.getConnection();
String where="Where docId='"+docId+"' order by fileId";
try {
return gdFilePersistent.load(conn,where);
}
finally {
conn.close();
}
}
/**
*获得某个归档文件所对应的正文或附件
*/
public static Vector getListVector(String docId,String status) throws DBPoolException, SQLException ,NotFoundException{
Connection conn = DBManager.getConnection();
String where="Where docId='"+docId+"' and status='"+status+"' order by FileId";
try{
return gdFilePersistent.load(conn,where);
} finally {
conn.close();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -