📄 archivedaoimpl.java
字号:
package com.zdvictory.oa.archive.dao;
import org.springframework.orm.hibernate3.*;
import org.hibernate.HibernateException;
import org.hibernate.Query;
import org.hibernate.transform.Transformers;
import java.util.*;
import com.zdvictory.platform.util.GenUtil;
import com.zdvictory.platform.common.PageInfo;
import com.zdvictory.platform.common.GenericHibernateDAO;
import com.zdvictory.oa.archive.view.Archive;
import com.zdvictory.workflow.qpdl.WfFormFile;
/**
* <p>Title: Workflow</p>
*
* <p>Description: Workflow</p>
*
* <p>Copyright: Copyright (c) 2008</p>
*
* <p>Company: zdvictory.com</p>
*
* @author jerrie
* @version 1.0
*/
public class ArchiveDAOImpl extends GenericHibernateDAO<Archive,
Integer> implements ArchiveDAO {
/**
* 登记密级公文
* */
public boolean create(Archive archive) throws Exception {
String SQL = "insert into OA_ARCHIVE(FLOWINSTID,BIAOTI,ZHUTICI,WENJIANBIANHAO,LEIBIE,MIMIDENGJI,JINJICHENGDU,NIANDU," +
"LAIWENDANWEI,BANLISHIXIAN,CHENGWENRIQI,DENGJIRIQI,DENGJIREN,SHIFOUYIDENGJI," +
"DENGJIHAO,FUZHU,STATE,BUSINESSTYPE,LAIWENSHIJIAN,SOURCE,CREATETIME,ORGANIZATIONID) values(" +
archive.getFlowInstId() + ",'" + archive.getBiaoti() +
"','" + archive.getZhutici() + "','" +
archive.getWenjianbianhao() + "','" +
archive.getLeibie() + "','" + archive.getMimidengji() +
"','" + archive.getJinjichengdu() + "','" +
archive.getNiandu() + "','" +
archive.getLaiwendanwei() + "','" +
archive.getBanlishixian() + "','" +
archive.getChengwenriqi() + "','" +
archive.getDengjiriqi() + "','" +
archive.getDengjiren() + "'," +
archive.getShifouyidengji() + ",'" +
archive.getDengjihao() + "','" +
archive.getFuzhu() + "',0,'" +
archive.getBusinessType() + "','" +
archive.getLaiwenshijian() + "'," +
archive.getSource() + ",sysdate," +
archive.getOrganizationId() + ")";
getHibernateTemplate().getSessionFactory().getCurrentSession().
createSQLQuery(SQL).executeUpdate();
return true;
}
/**
* 产生一个流程实例ID
* */
public int createFlowInstId() throws Exception {
String SQL =
"select SEQ_WF_WORKFLOW_INST.nextval as FLOWINSTID from dual";
Query query = createSQLQuery(SQL);
Iterator iter = query.list().iterator();
int flowInstId = -1;
while (iter.hasNext()) {
flowInstId = ((java.math.BigDecimal) ((Map) iter.next()).get(
"FLOWINSTID")).intValue();
}
return flowInstId;
}
/**
* 获取本单位的档案文件
* */
public List<Archive> findArchiveList(int organizationId, int currentPage,
int pageSize, String condition) throws
Exception {
String SQL = "select * from OA_ARCHIVE where state = 0 and ORGANIZATIONID in" +
"(select ID from pf_organization start with id=" +
organizationId +
" connect by prior id=parentid and type!=1)";
if (condition != null)
SQL += condition;
return super.findPageListBySQL(currentPage, pageSize, SQL);
}
public PageInfo findArchivePageInfo(int organizationId, int currentPage,
int pageSize,
String condition) throws Exception {
String SQL =
"select count(*) as amount from OA_ARCHIVE where state = 0 and ORGANIZATIONID in" +
"(select ID from pf_organization start with id=" +
organizationId + " connect by prior id=parentid and type!=1)";
if (condition != null)
SQL += condition;
return super.findPageInfoBySQL(currentPage, pageSize, SQL);
}
/**
* 根据ID查找单位文件
* */
public List<Archive> findArchiveListByIds(String[] ids) throws Exception {
String condition = "";
for (int i = 0; i < ids.length; i++) {
condition += ids[i] + ",";
}
String SQL = "select * from OA_ARCHIVE where FLOWINSTID in(" +
condition.substring(0, condition.length() - 1) + ")";
return super.findAllBySQL(SQL);
}
/**
* 根据流程ID查找档案文件详细信息
* */
public Archive findArchiveByFlowInstId(String flowInstId) throws Exception {
String SQL = "select * from OA_ARCHIVE where FLOWINSTID=" + flowInstId;
Archive archive = super.findBySQL(SQL);
/**
* 查找公文正文路径
* */
SQL = "select filepathname from OA_FILE where FLOWINSTID=" + flowInstId;
Query query = createSQLQuery(SQL);
Iterator iter = query.list().iterator();
while (iter.hasNext()) {
archive.setFilepathname((String) ((Map) iter.next()).get(
"FILEPATHNAME"));
}
/**
* 查找公文附件列表
* */
SQL = "select * from WF_ATTACHMENT where FLOWINSTID=" + flowInstId;
query = createSQLQuery(SQL);
iter = query.list().iterator();
while (iter.hasNext()) {
Map map=(Map) iter.next();
WfFormFile wfFormFile = new WfFormFile();
wfFormFile.setId(((java.math.BigDecimal) map.get("ID")).intValue());
wfFormFile.setFilename((String) map.get("FILENAME"));
wfFormFile.setFilepathname((String)map.get(
"FILEPATHNAME"));
archive.getAttachList().add(wfFormFile);
}
return archive;
}
/**
* 创建Hibernate查询对象
* @param SQL String
* @return Query
* @throws HibernateException
*/
private Query createSQLQuery(String SQL) throws HibernateException {
return getHibernateTemplate().getSessionFactory().
getCurrentSession().
createSQLQuery(SQL).
setResultTransformer(Transformers.ALIAS_TO_ENTITY_MAP);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -