📄 guidocformmanager.java
字号:
package com.sure.oa.archive;
import com.sure.businessmodel.Page;
import com.sure.businessmodel.UpdateException;
import com.sure.businesslogic.AlreadyExistsException;
import com.sure.businesslogic.NotFoundException;
import com.sure.dataabstraction.DBManager;
import com.sure.dataabstraction.DBPoolException;
import com.sure.util.StringUtils;
import com.sure.oa.gdfile.*;
import com.sure.util.*;
import com.sure.oa.gdfile.*;
import com.sure.oa.oaswitch.*;
import com.sure.oa.attachment.*;
import java.sql.SQLException;
import java.sql.Connection;
import java.util.*;
import java.io.*;
import java.sql.*;
import com.sure.oa.archive.GuiDocFormPersistentBase;
/**
* <p>Title: OA</p>
* <p>Description: 海关项目</p>
* <p>Copyright: Copyright (c) 2004</p>
* <p>Company: sure</p>
* @author mengzy
* @version 1.0
*/
public class GuiDocFormManager {
public GuiDocFormManager() {
}
/**
* 根据docID获得一个归档的主信息
*/
public static GuiDocForm getDoc(int docId) throws SQLException,DBPoolException, NotFoundException {
Connection cn = DBManager.getConnection();
try {
String where = "Where docId = " + docId ;
Vector beans = GuiDocFormPersistent.load(cn, where);
GuiDocForm bean = (GuiDocForm)beans.firstElement();
return bean;
}catch (SQLException sqle) {
throw new NotFoundException();
} finally {
cn.close();
}
}
public static GuiDocForm getDoc(String docId) throws SQLException,DBPoolException, NotFoundException {
return getDoc(Integer.parseInt(docId));
}
/**
* 获得归档列表(status: 0:收文归档 1:发文归档)
*/
public Page getArchiveList(int start, String unitId,String status,String cxtj) throws SQLException,NotFoundException,DBPoolException {
Connection cn = DBManager.getConnection();
try{
String where = "where guiUnitId="+unitId+" and status="+status+" "+cxtj+" order by Guidate desc";
Page p = GuiDocFormPersistent.load(cn, start, 15, where);
return p;
}finally {
cn.close();
}
}
/**
* 由GuiDocForm 封装一个oaswitch类
*/
public static oaswitch changeOaswitch(GuiDocForm form){
oaswitch oaform=new oaswitch();
oaform.setDocId(0);
oaform.setDocKind("0");
oaform.setDocTitle(form.getDocTitle());
oaform.setSendDate(form.getCreateDate());
oaform.setSendUnitName(form.getSendUnitName());
oaform.setSecret(form.getSecret());
oaform.setEmergency(form.getEmergency());
oaform.setDocNoPre(form.getDocNoPre());
oaform.setYearNo(form.getYearNo());
oaform.setWaterNo(form.getWaterNo());
oaform.setSubject(form.getSubject());
oaform.setPublishDate(form.getPublishDate());
oaform.setPublishPerson(form.getPublishPerson());
oaform.setInputPerson(form.getCreator());
oaform.setCheckPerson(form.getCheckPerson());
oaform.setSealTime(form.getSealTime());
oaform.setSealPerson(form.getSealPerson());
oaform.setPrintUnit(form.getPrintUnit());
oaform.setPrintDate(form.getPrintDate());
oaform.setSecretTime(form.getSaveTime());
oaform.setSendTo(form.getSendTo());
oaform.setCc(form.getCc());
oaform.setReportTo(form.getReportTo());
oaform.setPrintnumber(form.getPrintnumber());
oaform.setDocMemo(form.getMemo());
oaform.setStatus("0");
return oaform;
}
/**
* 由gdFile封装一个switchfile,并且把相应的文件保存入库
*/
public static void saveSwitch(gdFile gd,Connection cn,String rId) throws SQLException{
String path=attachmentManager.getUploadPath();
switchfile sfile=new switchfile();
sfile.setFileId("0");
sfile.setTitle(gd.getTitle());
sfile.setFileSize(gd.getFileSize());
sfile.setMimeType(gd.getMimeType());
sfile.setDocId(rId);
sfile.setOrderBy(0);
sfile.setStatus(gd.getStatus());
File file=new File(path+gd.getFilePath());
sfile.setContent(file);
switchfilePersistent rsfile=new switchfilePersistent(sfile);
rsfile.setRecordExists(false);
rsfile.persist(cn);
}
/**
* 导入OA交换库
*/
public static int uploadOa(String Id) throws Exception{
Connection cn = DBManager.getConnection();
int retval=0;
try{
cn.setAutoCommit(false);
GuiDocForm form=GuiDocFormManager.getDoc(Id);
//oaswitch插入记录
oaswitch oaform=changeOaswitch(form);
oaswitchPersistent rp=new oaswitchPersistent(oaform);
rp.setRecordExists(false);
rp.persist(cn);
String rId=rp.getBean().getDocId().toString();
//switchfile插入记录
Vector v=gdFileManager.getGdFileList(Id);
for(int i = 0; i < v.size(); i++){
gdFile gd=(gdFile)v.get(i);
saveSwitch(gd,cn,rId);
}
cn.commit();
} catch(Exception e) {
cn.rollback();
e.printStackTrace();
retval=1;
} finally {
cn.setAutoCommit(true);
cn.close();
return retval;
}
}
/**
* 更新归档收文上传OA标志,说明已成功上传OA
*/
public static void updateGuiType(String docId) throws Exception{
Connection cn = DBManager.getConnection();
try{
GuiDocForm form=GuiDocFormManager.getDoc(docId);
form.setGuiType("1");
GuiDocFormPersistent forms=new GuiDocFormPersistent(form);
forms.setRecordExists(true);
forms.persist(cn);
}
catch (Exception e){
e.printStackTrace();
}
finally{
cn.close();
}
}
public static void main(String args[]) throws Exception{
int ret=1;
try{
GuiDocFormManager.uploadOa("3");
}
catch(Exception e){
e.printStackTrace();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -