?? taskdaoimpl.java
字號:
package com.yuanchung.sales.dao.taskEvent.impl;
import java.sql.SQLException;
import java.util.List;
import org.hibernate.HibernateException;
import org.hibernate.Query;
import org.hibernate.Session;
import org.springframework.dao.DataAccessException;
import org.springframework.orm.hibernate3.HibernateCallback;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
import com.yuanchung.sales.dao.taskEvent.TaskDAO;
import com.yuanchung.sales.exception.ApplicationException;
import com.yuanchung.sales.model.businessOpportunity.BusinessOpportunity;
import com.yuanchung.sales.model.customer.Customer;
import com.yuanchung.sales.model.customer.CustomerContact;
import com.yuanchung.sales.model.taskEvent.ActivityTask;
import com.yuanchung.sales.model.user.User;
import com.yuanchung.sales.model.userDefined.UserDefined;
import com.yuanchung.sales.model.userDefined.UserField;
import com.yuanchung.sales.model.userDefined.UserFilter;
import com.yuanchung.sales.util.Constants;
import com.yuanchung.sales.util.DateTimeTool;
@SuppressWarnings("unchecked")
/**
*
* @author 福建圓創軟件;
* @function 實現任務DAO接口的實現類,具體處理任務活動的增刪改查;
*
*/
public class TaskDAOImpl extends HibernateDaoSupport implements TaskDAO {
/**
* @author 陸文邦;
* @function 獲取全部用戶;
* @param flag根據任務活動狀態來搜索;
* @return 返回全部用戶的列表;
*/
public List<User> getAllUsers(String userIds) throws DataAccessException {
return this.getHibernateTemplate().find(
"from User u where u.id in(" + userIds + ")");
}
/**
* @author 陸文邦;
* @function 用于獲取搜索符合條件的用戶;
* @param 用userName參數模糊搜索;
* @param flag
* 根據狀態來搜索記錄;
* @return 返回搜索的用戶列表;
*/
public List getUsersByNameLike(String familyName)
throws DataAccessException {
return this.getHibernateTemplate().find(
"from User u where u.familyName like '%" + familyName + "%'");
}
/**
* @author 陸文邦;
* @function 用于獲取搜索符合條件的客戶;
* @param 用userName參數模糊搜索;
* @param flag
* 根據狀態來搜索記錄;
* @return 返回搜索的客戶列表;
*/
public List getCustomerByNameLike(String name) throws DataAccessException {
return this.getHibernateTemplate().find(
"from Customer c where c.flag=" + Constants.ACTIVEFLAG
+ " and c.customerName like '%" + name + "%'");
}
/**
* @author 陸文邦;
* @function 用于獲取搜索符合條件的業務機會;
* @param 用userName參數模糊搜索;
* @param flag
* 根據狀態來搜索記錄;
* @return 返回搜索的業務機會列表;
*/
public List getOpportByNameLike(String name) throws DataAccessException {
return this.getHibernateTemplate().find(
"from BusinessOpportunity bo where bo.flag="
+ Constants.ACTIVEFLAG
+ " and bo.busiOpportName like '%" + name + "%'");
}
/**
* @author 陸文邦;
* @function 用于獲取搜索符合條件的聯系人;
* @param name
* @return
* @throws ApplicationException
*/
public List getCustomerContactByNameLike(String name)
throws ApplicationException {
return this.getHibernateTemplate().find(
"from CustomerContact cc where cc.flag=" + Constants.ACTIVEFLAG
+ " and cc.name like '%" + name + "%'");
}
/**
* @author 陸文邦;
* @function 搜索全部的聯系人;
* @param flag;根據記錄狀態來搜索;
* @return 返回搜索的聯系人;
*/
public List<CustomerContact> getAllCustomerContacts(Integer flag)
throws DataAccessException {
return this.getHibernateTemplate().find(
"from CustomerContact cc where cc.flag=?", flag);
}
/**
* @author 陸文邦;
* @function 獲取全部的客戶;
* @param flag;根據flag搜索是否被刪除的記錄
* @return 返回全部客戶的列表;
*/
public List<Customer> getAllCustomers(Integer flag)
throws DataAccessException {
return this.getHibernateTemplate().find(
"from Customer c where c.flag=?", flag);
}
/**
* @author 陸文邦;
* @function 獲取全部的業務機會;
* @param flag
* 根據任務記錄狀態來搜索;
* @return 返回全部業務機會的列表
*/
public List<BusinessOpportunity> getAllOpports(Integer flag)
throws DataAccessException {
return this.getHibernateTemplate().find(
"from BusinessOpportunity bo where bo.flag=?", flag);
}
/**
* @author 陸文邦;
* @function 添加任務活動;
* @param 保存raskPojo參數的實例
* @return 返回是否保存成功;
*/
public boolean addTask(ActivityTask taskPojo) throws DataAccessException {
this.getHibernateTemplate().save(taskPojo);
return true;
}
/**
* @author 陸文邦;
* @function 搜索具體某個用戶;
* @param id
* 根據用戶id的主鍵來搜索用戶
* @return 返回該id號的用戶;
*/
public User getUserById(Integer id) throws DataAccessException {
return (User) this.getHibernateTemplate().get(User.class, id);
}
/**
* @author 陸文邦;
* @function 搜索全部任務活動;
* @param user
* 根據用戶user搜索任務活動;
* @param flag
* 根據任務活動記錄狀態搜索;--是否已經被刪除;
* @return 返回全部的任務活動;
*/
public List getAllTasks(Integer flag, User user) throws DataAccessException {
return this
.getHibernateTemplate()
.find(
"from ActivityTask at where at.executeState<>3 and at.flag=? and at.assignerId=? order by at.finalTime",
new Object[] { flag, user.getId() });
}
/**
* @author 陸文邦;
* @function 搜索id號的任務活動;
* @param id
* 根據該id參數來搜索;
* @return 返回該任務活動;
*/
public ActivityTask getTsakById(Integer id) throws DataAccessException {
return (ActivityTask) this.getHibernateTemplate().get(
ActivityTask.class, id);
}
/**
* @author 陸文邦;
* @function 搜索id號的聯系人;
* @param id
* 根據該id參數來搜索;
* @return 返回該聯系人;
*/
public CustomerContact getgetCustomerContactById(Integer id)
throws DataAccessException {
return (CustomerContact) this.getHibernateTemplate().get(
CustomerContact.class, id);
}
/**
* @author 陸文邦;
* @function 搜索該rid號的客戶;
* @param id
* 根據該rid參數來搜索;
* @return 返回該具體客戶;
*/
public Customer getCustomerByRid(Integer rid) throws DataAccessException {
return (Customer) this.getHibernateTemplate().get(Customer.class, rid);
}
/**
* @author 陸文邦;
* @function 搜索該rid號的業務機會;
* @param id
* 根據該rid參數來搜索;
* @return 返回該具體業務機會;
*/
public BusinessOpportunity getOpportByRid(Integer rid)
throws DataAccessException {
return (BusinessOpportunity) this.getHibernateTemplate().get(
BusinessOpportunity.class, rid);
}
/**
* @author 陸文邦;
* @function 修改該任務活動對象;
* @param id
* 修改taskPojo對象的參數;
* @return 返回是否修改成功;
*/
public boolean modifyTask(ActivityTask task) throws DataAccessException {
this.getHibernateTemplate().update(task);
return true;
}
/**
* @author 陸文邦;
* @function 批量修改任務活動;
* @return 返回是否修改成功;
*/
public void updateTasks(int modifyManId, String modifyTime,
String classCode, int recordId, int flag)
throws DataAccessException {
this
.getHibernateTemplate()
.bulkUpdate(
"update ActivityTask as at set at.flag=?, at.modifyManId=?, at.lastModifyTime=? where at.functionId=? and at.recordId=?",
new Object[] { flag, modifyManId, modifyTime,
classCode, recordId });
}
/**
* @author 陸文邦;
* @function 搜索全部任務活動;
* @param whereSql
* 根據whereSql搜索記錄;
* @param type
* 根據類型任務活動;
* @return 返回全部的任務活動;
*/
public List getAllTasksByHql(Integer flag, User user, String whereSql)
throws DataAccessException {
return this
.getHibernateTemplate()
.find(
"from ActivityTask at where at.executeState<>3 and at.flag=? and at.assignerId=?"
+ whereSql
+ "'"
+ DateTimeTool.getCurrentDate("yyyy-MM-dd")
+ "'" + " order by at.finalTime",
new Object[] { flag, user.getId() });
}
/**
* @author 陸文邦;
* @function 搜索全部任務活動;
* @param whereSql
* 根據whereSql搜索記錄;
* @param type
* 根據類型任務活動;
* @param to區分重寫方法;
* @return 返回全部的任務活動;
*/
public List getAllTasksByFuture(Integer flag, User user, String toBeSql,
Integer to) throws DataAccessException {
return this
.getHibernateTemplate()
.find(
"from ActivityTask at where at.executeState<>3 and at.flag=? and at.assignerId=?"
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -