?? relationmanagedaoimpl.java
字號:
package com.yuanchung.sales.dao;
import java.util.Date;
import java.util.List;
import org.hibernate.Query;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
import com.yuanchung.sales.config.ClassCodeMgr;
import com.yuanchung.sales.exception.ApplicationException;
import com.yuanchung.sales.exception.SystemException;
import com.yuanchung.sales.model.user.User;
import com.yuanchung.sales.util.Constants;
import com.yuanchung.sales.util.DateTimeTool;
public class RelationManageDAOImpl extends HibernateDaoSupport implements RelationManageDAO {
/**
* 根據相關項的ID和記錄查找任務
*/
public List getActivityRasksByRelation(String relationId, int recordId, int executeState) throws SystemException {
try{
//任務已完成
StringBuffer hql = new StringBuffer();
hql.append("from "+ClassCodeMgr.ACTIVITYRASK);
hql.append(" where flag=1 and functionId=?");
hql.append(" and recordId=?");
//若任務未完成
if(executeState != Constants.RASKEXECUTEED) {
hql.append(" and executeState!=?");
}else{
hql.append(" and executeState=?");
}
hql.append("order by beFirst");//按優先級的升序排列
return getHibernateTemplate().find(hql.toString(), new Object[]{relationId, recordId, Constants.RASKEXECUTEED});
}catch(Exception e){
e.printStackTrace();
logger.error(Constants.DATABASEFINDDATAEXCEPTION);
throw new SystemException(Constants.DATABASEFINDDATAEXCEPTION);
}
}
/**
* 根據兩個參數搜索該參數對象兩個表;
*/
public List getEventByRelation(String relationId, int recordId, boolean isNotOverdue)
throws SystemException {
try{
StringBuffer hql = new StringBuffer();
hql.append("from "+ClassCodeMgr.EVENT);
hql.append(" where flag=1 and functionId=?");
hql.append(" and recordId=?");
if(isNotOverdue) {//若事件不過期
hql.append("and endTime >= '"+DateTimeTool.dateToStrFormat("", new Date())+"'");
}else{
hql.append("and endTime < '"+DateTimeTool.dateToStrFormat("", new Date())+"'");
}
hql.append("order by endTime");//按結束時間的升序排列
return getHibernateTemplate().find(hql.toString(), new Object[]{relationId, recordId});
}catch(Exception e){
e.printStackTrace();
logger.error(Constants.DATABASEFINDDATAEXCEPTION);
throw new SystemException(Constants.DATABASEFINDDATAEXCEPTION);
}
}
/**
* 活動--->任務 根據聯系人ID和執行狀態查找任務
* @param contactId聯系人ID
* @param executeState執行狀態
* @return
* @throws ApplicationException
*/
public List getActivityRasks(int contactId, int executeState) throws SystemException {
try{
//任務已完成
StringBuffer hql = new StringBuffer();
hql.append("from "+ClassCodeMgr.ACTIVITYRASK);
hql.append(" where flag=1 and customerContact.id=?");
//若任務未完成
if(executeState != Constants.RASKEXECUTEED) {
hql.append(" and executeState!=?");
}else{
hql.append(" and executeState=?");
}
return getHibernateTemplate().find(hql.toString(), new Object[]{contactId, Constants.RASKEXECUTEED});
}catch(Exception e){
e.printStackTrace();
logger.error(Constants.DATABASEFINDDATAEXCEPTION);
throw new SystemException(Constants.DATABASEFINDDATAEXCEPTION);
}
}
/**
* 查找是否過期的事件
* @param contactId
* @param isNotOverdue
* @return
* @throws SystemException
*/
public List getEvents(int contactId, boolean isNotOverdue) throws SystemException {
try{
StringBuffer hql = new StringBuffer();
hql.append("from "+ClassCodeMgr.EVENT);
hql.append(" where flag=1 and customerContact.id=?");
if(isNotOverdue) {//若事件不過期
hql.append("and endTime >= '"+DateTimeTool.dateToStrFormat("", new Date())+"'");
}else{
hql.append("and endTime < '"+DateTimeTool.dateToStrFormat("", new Date())+"'");
}
hql.append("order by endTime");//按結束時間的升序排列
return getHibernateTemplate().find(hql.toString(), contactId);
}catch(Exception e) {
e.printStackTrace();
logger.error(Constants.DATABASEFINDDATAEXCEPTION);
throw new SystemException(Constants.DATABASEFINDDATAEXCEPTION);
}
}
/**
* 根據修改人的ID查找用戶
* @param modifyManId
* @return
* @throws SystemException
*/
public User getUserByModifyManId(int modifyManId) throws SystemException {
try{
return (User)getHibernateTemplate().get(User.class, modifyManId);
}catch(Exception e){
e.printStackTrace();
logger.error(Constants.DATABASEFINDDATAEXCEPTION);
throw new SystemException(Constants.DATABASEFINDDATAEXCEPTION);
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -